From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Maxim Levitsky <mlevitsk@redhat.com>, kvm@vger.kernel.org
Cc: Wanpeng Li <wanpengli@tencent.com>,
Borislav Petkov <bp@alien8.de>, Ingo Molnar <mingo@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org,
Sean Christopherson <seanjc@google.com>,
Joerg Roedel <joro@8bytes.org>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>, Thomas Gleixner <tglx@linutronix.de>,
Paolo Bonzini <pbonzini@redhat.com>,
Jim Mattson <jmattson@google.com>,
Maxim Levitsky <mlevitsk@redhat.com>
Subject: Re: [PATCH 1/3] KVM: nVMX: extract calculation of the L1's EFER
Date: Wed, 10 Nov 2021 15:43:55 +0100 [thread overview]
Message-ID: <87tugkm5p0.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <20211110100018.367426-2-mlevitsk@redhat.com>
Maxim Levitsky <mlevitsk@redhat.com> writes:
> This will be useful in the next patch.
Nitpick: "the next patch" may not be what you expect after merge/when
backporting/... so it's better to call things out explicityly, something
like:
"The newly introduced nested_vmx_get_vmcs12_host_efer() helper will be
used when nested state is restored in vmx_set_nested_state()".
>
> No functional change intended.
>
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
> arch/x86/kvm/vmx/nested.c | 22 ++++++++++++++++------
> 1 file changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index b4ee5e9f9e201..49ae96c0cc4d1 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -4228,6 +4228,21 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
> kvm_clear_interrupt_queue(vcpu);
> }
>
> +/*
> + * Given vmcs12, return the expected L1 value of IA32_EFER
> + * after VM exit from that vmcs12
> + */
> +static inline u64 nested_vmx_get_vmcs12_host_efer(struct kvm_vcpu *vcpu,
> + struct vmcs12 *vmcs12)
> +{
> + if (vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_EFER)
> + return vmcs12->host_ia32_efer;
> + else if (vmcs12->vm_exit_controls & VM_EXIT_HOST_ADDR_SPACE_SIZE)
> + return vcpu->arch.efer | (EFER_LMA | EFER_LME);
> + else
> + return vcpu->arch.efer & ~(EFER_LMA | EFER_LME);
> +}
> +
> /*
> * A part of what we need to when the nested L2 guest exits and we want to
> * run its L1 parent, is to reset L1's guest state to the host state specified
> @@ -4243,12 +4258,7 @@ static void load_vmcs12_host_state(struct kvm_vcpu *vcpu,
> enum vm_entry_failure_code ignored;
> struct kvm_segment seg;
>
> - if (vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_EFER)
> - vcpu->arch.efer = vmcs12->host_ia32_efer;
> - else if (vmcs12->vm_exit_controls & VM_EXIT_HOST_ADDR_SPACE_SIZE)
> - vcpu->arch.efer |= (EFER_LMA | EFER_LME);
> - else
> - vcpu->arch.efer &= ~(EFER_LMA | EFER_LME);
> + vcpu->arch.efer = nested_vmx_get_vmcs12_host_efer(vcpu, vmcs12);
> vmx_set_efer(vcpu, vcpu->arch.efer);
>
> kvm_rsp_write(vcpu, vmcs12->host_rsp);
--
Vitaly
next prev parent reply other threads:[~2021-11-10 14:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-10 10:00 [PATCH 0/3] VMX: nested migration fixes for 32 bit nested guests Maxim Levitsky
2021-11-10 10:00 ` [PATCH 1/3] KVM: nVMX: extract calculation of the L1's EFER Maxim Levitsky
2021-11-10 14:43 ` Vitaly Kuznetsov [this message]
2021-11-10 10:00 ` [PATCH 2/3] KVM: nVMX: restore L1's EFER prior to setting the nested state Maxim Levitsky
2021-11-10 15:01 ` Paolo Bonzini
2021-11-10 15:08 ` Maxim Levitsky
2021-11-10 10:00 ` [PATCH 3/3] KVM: x86/mmu: don't skip mmu initialization when mmu root level changes Maxim Levitsky
2021-11-10 14:48 ` Vitaly Kuznetsov
2021-11-10 15:00 ` Maxim Levitsky
2021-11-10 17:21 ` Sean Christopherson
2021-11-15 12:14 ` Maxim Levitsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tugkm5p0.fsf@vitty.brq.redhat.com \
--to=vkuznets@redhat.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mlevitsk@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox