[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f2a78f56-9742-6092-523c-1e81131bb020@amd.com>
Date: Fri, 7 May 2021 18:15:48 -0500
From: Tom Lendacky <thomas.lendacky@....com>
To: Sean Christopherson <seanjc@...gle.com>,
Paolo Bonzini <pbonzini@...hat.com>
Cc: Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, Peter Gonda <pgonda@...gle.com>,
Maxim Levitsky <mlevitsk@...hat.com>
Subject: Re: [PATCH 1/2] KVM: SVM: Update EFER software model on CR0 trap for
SEV-ES
On 5/7/21 11:59 AM, Sean Christopherson wrote:
> For protected guests, a.k.a. SEV-ES guests, update KVM's model of EFER
> when processing the side effect of the CPU entering long mode when paging
> is enabled. The whole point of intercepting CR0/CR4/EFER is to keep
> KVM's software model up-to-date.
>
> Fixes: f1c6366e3043 ("KVM: SVM: Add required changes to support intercepts under SEV-ES")
> Reported-by: Peter Gonda <pgonda@...gle.com>
> Cc: stable@...r.kernel.org
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>
Acked-by: Tom Lendacky <thomas.lendacky@....com>
> ---
> arch/x86/kvm/svm/svm.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index a7271f31df47..d271fe8e58de 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -1696,15 +1696,17 @@ void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
> u64 hcr0 = cr0;
>
> #ifdef CONFIG_X86_64
> - if (vcpu->arch.efer & EFER_LME && !vcpu->arch.guest_state_protected) {
> + if (vcpu->arch.efer & EFER_LME) {
> if (!is_paging(vcpu) && (cr0 & X86_CR0_PG)) {
> vcpu->arch.efer |= EFER_LMA;
> - svm->vmcb->save.efer |= EFER_LMA | EFER_LME;
> + if (!vcpu->arch.guest_state_protected)
> + svm->vmcb->save.efer |= EFER_LMA | EFER_LME;
> }
>
> if (is_paging(vcpu) && !(cr0 & X86_CR0_PG)) {
> vcpu->arch.efer &= ~EFER_LMA;
> - svm->vmcb->save.efer &= ~(EFER_LMA | EFER_LME);
> + if (!vcpu->arch.guest_state_protected)
> + svm->vmcb->save.efer &= ~(EFER_LMA | EFER_LME);
> }
> }
> #endif
>
Powered by blists - more mailing lists