On Fri, Jan 14, 2022, Paolo Bonzini wrote: > On 1/14/22 11:54, Li RongQing wrote: > > After support paravirtualized TLB shootdowns, steal_time.preempted > > includes not only KVM_VCPU_PREEMPTED, but also KVM_VCPU_FLUSH_TLB > > > > and kvm_vcpu_is_preempted should test only with KVM_VCPU_PREEMPTED > > > > Signed-off-by: Li RongQing <lirongqing@xxxxxxxxx> > > --- > > diff with v1: > > clear the rest of rax, suggested by Sean and peter > > remove Fixes tag, since no issue in practice > > > > arch/x86/kernel/kvm.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c > > index b061d17..45c9ce8d 100644 > > --- a/arch/x86/kernel/kvm.c > > +++ b/arch/x86/kernel/kvm.c > > @@ -1025,8 +1025,8 @@ asm( > > ".type __raw_callee_save___kvm_vcpu_is_preempted, @function;" > > "__raw_callee_save___kvm_vcpu_is_preempted:" > > "movq __per_cpu_offset(,%rdi,8), %rax;" > > -"cmpb $0, " __stringify(KVM_STEAL_TIME_preempted) "+steal_time(%rax);" > > -"setne %al;" > > +"movb " __stringify(KVM_STEAL_TIME_preempted) "+steal_time(%rax), %al;" > > +"and $" __stringify(KVM_VCPU_PREEMPTED) ", %rax;" > > This assumes that KVM_VCPU_PREEMPTED is 1. Ah, right, because technically the compiler is only required to be able to store '1' and '0' in the boolean. That said, KVM_VCPU_PREEMPTED is ABI and isn't going to change, so this could be "solved" with a comment. > It could also be %eax (slightly cheaper). Ya. > Overall, I prefer to leave the code as is using setne. But that also makes dangerous assumptions: (a) that the return type is bool, and (b) that the compiler uses a single byte for bools. If the assumptiong about KVM_VCPU_PREEMPTED being '1' is a sticking point, what about combining the two to make everyone happy? andl $" __stringify(KVM_VCPU_PREEMPTED) ", %eax setnz %al