All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH] KVM: x86: do mask out upper bits of PAE CR3
Date: Mon, 24 Jul 2017 20:28:04 +0200	[thread overview]
Message-ID: <20170724182803.GA15042@potion> (raw)
In-Reply-To: <1500915555-34207-1-git-send-email-pbonzini@redhat.com>

2017-07-24 18:59+0200, Paolo Bonzini:
> This reverts the change of commit f85c758dbee54cc3612a6e873ef7cecdb66ebee5,
> as the behavior it modified was intended.
> 
> The VM is running in 32-bit PAE mode, and Table 4-7 of the Intel manual
> says:
> 
> Table 4-7. Use of CR3 with PAE Paging
> Bit Position(s)	Contents
> 4:0		Ignored
> 31:5		Physical address of the 32-Byte aligned
> 		page-directory-pointer table used for linear-address
> 		translation
> 63:32		Ignored (these bits exist only on processors supporting
> 		the Intel-64 architecture)
> 
> To placate the static checker, write the mask explicitly as an
> unsigned long constant instead of using a 32-bit unsigned constant.
> 
> Cc: Dan Carpenter <dan.carpenter@oracle.com>
> Fixes: f85c758dbee54cc3612a6e873ef7cecdb66ebee5
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---

Thanks for catching this,

Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>

> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 82a63c59f77b..6c97c82814c4 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -597,8 +597,8 @@ bool pdptrs_changed(struct kvm_vcpu *vcpu)
>  		      (unsigned long *)&vcpu->arch.regs_avail))
>  		return true;
>  
> -	gfn = (kvm_read_cr3(vcpu) & ~31ul) >> PAGE_SHIFT;
> -	offset = (kvm_read_cr3(vcpu) & ~31ul) & (PAGE_SIZE - 1);
> +	gfn = (kvm_read_cr3(vcpu) & 0xffffffe0ul) >> PAGE_SHIFT;
> +	offset = (kvm_read_cr3(vcpu) & 0xffffffe0ul) & (PAGE_SIZE - 1);
>  	r = kvm_read_nested_guest_page(vcpu, gfn, pdpte, offset, sizeof(pdpte),
>  				       PFERR_USER_MASK | PFERR_WRITE_MASK);
>  	if (r < 0)
> -- 
> 1.8.3.1
> 

      reply	other threads:[~2017-07-24 18:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-24 16:59 [PATCH] KVM: x86: do mask out upper bits of PAE CR3 Paolo Bonzini
2017-07-24 18:28 ` Radim Krčmář [this message]

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=20170724182803.GA15042@potion \
    --to=rkrcmar@redhat.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.