KVM: VMX: Use wrapper macro ~RMODE_GUEST_OWNED_EFLAGS_BITS directly
Quoted 8 lines · Paolo Bonzini
Quoted 2 lines · linmiaohe
(
X86_EFLAGS_IOPL|X86_EFLAGS_VM) indicates the eflag bits that can not be owned by realmode guest, i.e. ~RMODE_GUEST_OWNED_EFLAGS_BITS.... but ~RMODE_GUEST_OWNED_EFLAGS_BITS is the bits that are owned by the host; they could be 0 or 1 and that's why the code was using
X86_EFLAGS_IOPL|X86_EFLAGS_VM.I understand where ~RMODE_GUEST_OWNED_EFLAGS_BITS is better than
X86_EFLAGS_IOPL|X86_EFLAGS_VM, but I cannot think of a way to express it that is the best of both worlds.
Define a macro RMODE_HOST_OWNED_EFLAGS_BITS for (X86_EFLAGS_IOPL | X86_EFLAGS_VM) as suggested by Vitaly seems a good way to fix this ? Thanks.
Paolo Bonzini
maintainerQuoted 3 lines · linmiaohe
Define a macro
RMODE_HOST_OWNED_EFLAGS_BITSfor (X86_EFLAGS_IOPL|X86_EFLAGS_VM) as suggested by Vitaly seems a good way to fix this ? Thanks.
No, what if a host-owned flag was zero? I'd just leave it as is.
Paolo
Quoted 7 lines · Paolo Bonzini
Quoted 3 lines · linmiaohe
Define a macro
RMODE_HOST_OWNED_EFLAGS_BITSfor (X86_EFLAGS_IOPL|X86_EFLAGS_VM) as suggested by Vitaly seems a good way to fix this ? Thanks.No, what if a host-owned flag was zero? I'd just leave it as is.
I'm not saying my suggestion was a good idea but honestly I'm failing to wrap my head around this. The suggested 'RMODE_HOST_OWNED_EFLAGS_BITS' would just be a define for (X86_EFLAGS_IOPL | X86_EFLAGS_VM) so technically the patch would just be nop, no?
Signature · 1 line
Vitaly
Paolo Bonzini
maintainerQuoted 9 lines · Vitaly Kuznetsov
Quoted 5 lines
Quoted 3 lines
Define a macro
RMODE_HOST_OWNED_EFLAGS_BITSfor (X86_EFLAGS_IOPL|X86_EFLAGS_VM) as suggested by Vitaly seems a good way to fix this ? Thanks.No, what if a host-owned flag was zero? I'd just leave it as is.
I'm not saying my suggestion was a good idea but honestly I'm failing to wrap my head around this. The suggested '
RMODE_HOST_OWNED_EFLAGS_BITS' would just be a define for (X86_EFLAGS_IOPL|X86_EFLAGS_VM) so technically the patch would just be nop, no?
It would not be a nop for the reader.
Something called RMODE_{GUEST,HOST}_OWNED_EFLAGS_BITS is a mask. It tells you nothing about whether those bugs are 0 or 1. It's just by chance that all three host-owned EFLAGS bits are 1 while in real mode. It wouldn't be the case if, for example, we ran the guest using vm86 mode extensions (i.e. setting CR4.VME=1). Then VIF would be host-owned, but it wouldn't necessarily be 1.
Paolo
Quoted 11 lines · Paolo Bonzini
Quoted 9 lines · Vitaly Kuznetsov
Quoted 5 lines
Quoted 3 lines
Define a macro
RMODE_HOST_OWNED_EFLAGS_BITSfor (X86_EFLAGS_IOPL|X86_EFLAGS_VM) as suggested by Vitaly seems a good way to fix this ? Thanks.No, what if a host-owned flag was zero? I'd just leave it as is.
I'm not saying my suggestion was a good idea but honestly I'm failing to wrap my head around this. The suggested '
RMODE_HOST_OWNED_EFLAGS_BITS' would just be a define for (X86_EFLAGS_IOPL|X86_EFLAGS_VM) so technically the patch would just be nop, no?
Quoted 8 lines
It would not be a nop for the reader.
Something called RMODE_{GUEST,HOST}_OWNED_EFLAGS_BITS is a mask. It tells you nothing about whether those bugs are 0 or 1. It's just by chance that all three host-owned EFLAGS bits are 1 while in real mode. It wouldn't be the case if, for example, we ran the guest using vm86 mode extensions (i.e. setting CR4.VME=1). Then VIF would be host-owned, but it wouldn't necessarily be 1.
Got it, it's the name which is causing the confusion, we're using mask as something different. Make sense, let's keep the code as-is then.
Signature · 1 line
Vitaly