lkml.org 
[lkml]   [2020]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] KVM: VMX: Use wrapper macro ~RMODE_GUEST_OWNED_EFLAGS_BITS directly
From
Date
On 05/03/20 03:35, linmiaohe wrote:
> (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.

Paolo

Use wrapper
> macro directly to make it clear and also improve readability.
>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
> arch/x86/kvm/vmx/vmx.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 743b81642ce2..9571f8dea016 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -1466,7 +1466,7 @@ void vmx_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags)
> vmx->rflags = rflags;
> if (vmx->rmode.vm86_active) {
> vmx->rmode.save_rflags = rflags;
> - rflags |= X86_EFLAGS_IOPL | X86_EFLAGS_VM;
> + rflags |= ~RMODE_GUEST_OWNED_EFLAGS_BITS;
> }
> vmcs_writel(GUEST_RFLAGS, rflags);

\
 
 \ /
  Last update: 2020-03-05 12:50    [W:0.052 / U:1.576 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site