[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f5aaab6f-8111-8d12-754f-027989fd4b06@redhat.com>
Date: Thu, 5 Mar 2020 12:49:23 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: linmiaohe <linmiaohe@...wei.com>, rkrcmar@...hat.com,
sean.j.christopherson@...el.com, vkuznets@...hat.com,
jmattson@...gle.com, joro@...tes.org, tglx@...utronix.de,
mingo@...hat.com, bp@...en8.de, hpa@...or.com
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org, x86@...nel.org
Subject: Re: [PATCH] KVM: VMX: Use wrapper macro
~RMODE_GUEST_OWNED_EFLAGS_BITS directly
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@...wei.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);
Powered by blists - more mailing lists