From: Maxim Levitsky <mlevitsk@redhat.com>
To: Emanuele Giuseppe Esposito <eesposit@redhat.com>, kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] KVM: nSVM: move nested_vmcb_check_cr3_cr4 logic in nested_vmcb_valid_sregs
Date: Wed, 11 Aug 2021 23:37:56 +0300 [thread overview]
Message-ID: <3194331f42f5bcf760564b9714edf3d99d7a7b73.camel@redhat.com> (raw)
In-Reply-To: <20210809145343.97685-2-eesposit@redhat.com>
On Mon, 2021-08-09 at 16:53 +0200, Emanuele Giuseppe Esposito wrote:
> nested_vmcb_check_cr3_cr4 is not called by anyone else, and removing the
> call simplifies next patch
Tiny nitpick: I would call this 'inline the nested_vmcb_check_cr3_cr4' instead of
move, but please feel free to ignore.
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
>
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> ---
> arch/x86/kvm/svm/nested.c | 35 +++++++++++++----------------------
> 1 file changed, 13 insertions(+), 22 deletions(-)
>
> diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
> index 5e13357da21e..0ac2d14add15 100644
> --- a/arch/x86/kvm/svm/nested.c
> +++ b/arch/x86/kvm/svm/nested.c
> @@ -257,27 +257,6 @@ static bool nested_vmcb_check_controls(struct kvm_vcpu *vcpu,
> return true;
> }
>
> -static bool nested_vmcb_check_cr3_cr4(struct kvm_vcpu *vcpu,
> - struct vmcb_save_area *save)
> -{
> - /*
> - * These checks are also performed by KVM_SET_SREGS,
> - * except that EFER.LMA is not checked by SVM against
> - * CR0.PG && EFER.LME.
> - */
> - if ((save->efer & EFER_LME) && (save->cr0 & X86_CR0_PG)) {
> - if (CC(!(save->cr4 & X86_CR4_PAE)) ||
> - CC(!(save->cr0 & X86_CR0_PE)) ||
> - CC(kvm_vcpu_is_illegal_gpa(vcpu, save->cr3)))
> - return false;
> - }
> -
> - if (CC(!kvm_is_valid_cr4(vcpu, save->cr4)))
> - return false;
> -
> - return true;
> -}
> -
> /* Common checks that apply to both L1 and L2 state. */
> static bool nested_vmcb_valid_sregs(struct kvm_vcpu *vcpu,
> struct vmcb_save_area *save)
> @@ -299,7 +278,19 @@ static bool nested_vmcb_valid_sregs(struct kvm_vcpu *vcpu,
> if (CC(!kvm_dr6_valid(save->dr6)) || CC(!kvm_dr7_valid(save->dr7)))
> return false;
>
> - if (!nested_vmcb_check_cr3_cr4(vcpu, save))
> + /*
> + * These checks are also performed by KVM_SET_SREGS,
> + * except that EFER.LMA is not checked by SVM against
> + * CR0.PG && EFER.LME.
> + */
> + if ((save->efer & EFER_LME) && (save->cr0 & X86_CR0_PG)) {
> + if (CC(!(save->cr4 & X86_CR4_PAE)) ||
> + CC(!(save->cr0 & X86_CR0_PE)) ||
> + CC(kvm_vcpu_is_illegal_gpa(vcpu, save->cr3)))
> + return false;
> + }
> +
> + if (CC(!kvm_is_valid_cr4(vcpu, save->cr4)))
> return false;
>
> if (CC(!kvm_valid_efer(vcpu, save->efer)))
next prev parent reply other threads:[~2021-08-11 20:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-09 14:53 [PATCH 0/2] KVM: nSVM: avoid TOC/TOU race when checking vmcb12 Emanuele Giuseppe Esposito
2021-08-09 14:53 ` [PATCH 1/2] KVM: nSVM: move nested_vmcb_check_cr3_cr4 logic in nested_vmcb_valid_sregs Emanuele Giuseppe Esposito
2021-08-11 20:37 ` Maxim Levitsky [this message]
2021-08-09 14:53 ` [PATCH 2/2] KVM: nSVM: temporarly save vmcb12's efer, cr0 and cr4 to avoid TOC/TOU races Emanuele Giuseppe Esposito
2021-08-10 9:15 ` Paolo Bonzini
2021-08-11 20:37 ` Maxim Levitsky
2021-08-11 23:25 ` Sean Christopherson
2021-08-25 12:40 ` Emanuele Giuseppe Esposito
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=3194331f42f5bcf760564b9714edf3d99d7a7b73.camel@redhat.com \
--to=mlevitsk@redhat.com \
--cc=bp@alien8.de \
--cc=eesposit@redhat.com \
--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=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
--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
all inboxes | Powered by JetHome®