Re: [PATCH][v3] KVM: x86: refine kvm_vcpu_is_preempted

Peter Zijlstra
2022-02-02T22:17:38Z

On Wed, Feb 02, 2022 at 04:48:52PM +0000, Sean Christopherson wrote:

> > > +"movb " __stringify(KVM_STEAL_TIME_preempted) "+steal_time(%rax), %al;"
> > > +"andl $" __stringify(KVM_VCPU_PREEMPTED) ", %eax;"
> > > +"setnz %al;"
> >
> > Isn't the below the simpler way of writing that same?
>
> The AND is needed to clear RAX[63:8], e.g. to avoid breakage if the return value
> is changed from a bool to something larger, or the compiler uses more than a byte
> for _Bool.

While C doesn't specify _Bool the arch ABI most certainly does, and
x86_64 ABI guarantees a byte there, changing the return type is the only
possible option here.

Anyway, I don't mind the patch and the proposed Changelog does clarify
that this is an exercise in paranoia.