Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755809AbdGXS2R (ORCPT ); Mon, 24 Jul 2017 14:28:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43584 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753716AbdGXS2J (ORCPT ); Mon, 24 Jul 2017 14:28:09 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CCA9D61B8A Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=rkrcmar@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CCA9D61B8A Date: Mon, 24 Jul 2017 20:28:04 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Dan Carpenter Subject: Re: [PATCH] KVM: x86: do mask out upper bits of PAE CR3 Message-ID: <20170724182803.GA15042@potion> References: <1500915555-34207-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1500915555-34207-1-git-send-email-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 24 Jul 2017 18:28:09 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1619 Lines: 46 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 > Fixes: f85c758dbee54cc3612a6e873ef7cecdb66ebee5 > Signed-off-by: Paolo Bonzini > --- Thanks for catching this, Reviewed-by: Radim Krčmář > 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 >