From: Paolo Bonzini <pbonzini@redhat.com>
To: Jim Mattson <jmattson@google.com>, kvm@vger.kernel.org
Cc: Oliver Upton <oupton@google.com>, Peter Shier <pshier@google.com>
Subject: Re: [PATCH] kvm: x86: Read PDPTEs on CR0.CD and CR0.NW changes
Date: Wed, 8 Jul 2020 11:45:34 +0200 [thread overview]
Message-ID: <c8f73f4c-59e2-1a57-164c-d9d4e11ce486@redhat.com> (raw)
In-Reply-To: <20200707223630.336700-1-jmattson@google.com>
On 08/07/20 00:36, Jim Mattson wrote:
> According to the SDM, when PAE paging would be in use following a
> MOV-to-CR0 that modifies any of CR0.CD, CR0.NW, or CR0.PG, then the
> PDPTEs are loaded from the address in CR3. Previously, kvm only loaded
> the PDPTEs when PAE paging would be in use following a MOV-to-CR0 that
> modified CR0.PG.
>
> Signed-off-by: Jim Mattson <jmattson@google.com>
> Reviewed-by: Oliver Upton <oupton@google.com>
> Reviewed-by: Peter Shier <pshier@google.com>
> ---
> arch/x86/kvm/x86.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 88c593f83b28..5a91c975487d 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -775,6 +775,7 @@ EXPORT_SYMBOL_GPL(pdptrs_changed);
> int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
> {
> unsigned long old_cr0 = kvm_read_cr0(vcpu);
> + unsigned long pdptr_bits = X86_CR0_CD | X86_CR0_NW | X86_CR0_PG;
> unsigned long update_bits = X86_CR0_PG | X86_CR0_WP;
>
> cr0 |= X86_CR0_ET;
> @@ -792,9 +793,9 @@ int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
> if ((cr0 & X86_CR0_PG) && !(cr0 & X86_CR0_PE))
> return 1;
>
> - if (!is_paging(vcpu) && (cr0 & X86_CR0_PG)) {
> + if (cr0 & X86_CR0_PG) {
> #ifdef CONFIG_X86_64
> - if ((vcpu->arch.efer & EFER_LME)) {
> + if (!is_paging(vcpu) && (vcpu->arch.efer & EFER_LME)) {
> int cs_db, cs_l;
>
> if (!is_pae(vcpu))
> @@ -804,8 +805,8 @@ int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
> return 1;
> } else
> #endif
> - if (is_pae(vcpu) && !load_pdptrs(vcpu, vcpu->arch.walk_mmu,
> - kvm_read_cr3(vcpu)))
> + if (is_pae(vcpu) && ((cr0 ^ old_cr0) & pdptr_bits) &&
> + !load_pdptrs(vcpu, vcpu->arch.walk_mmu, kvm_read_cr3(vcpu)))
> return 1;
> }
>
>
Queued, thanks.
Paolo
next prev parent reply other threads:[~2020-07-08 9:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-07 22:36 [PATCH] kvm: x86: Read PDPTEs on CR0.CD and CR0.NW changes Jim Mattson
2020-07-08 9:45 ` Paolo Bonzini [this message]
2020-08-12 1:34 ` Alex Williamson
2020-08-12 2:45 ` Jim Mattson
2020-08-12 3:18 ` Alex Williamson
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=c8f73f4c-59e2-1a57-164c-d9d4e11ce486@redhat.com \
--to=pbonzini@redhat.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=oupton@google.com \
--cc=pshier@google.com \
/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