From patchwork Mon Mar 30 02:49:00 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dong, Eddie" X-Patchwork-Id: 15081 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2U2oSIc016525 for ; Mon, 30 Mar 2009 02:50:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753735AbZC3Cu1 (ORCPT ); Sun, 29 Mar 2009 22:50:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756245AbZC3Cu1 (ORCPT ); Sun, 29 Mar 2009 22:50:27 -0400 Received: from mga02.intel.com ([134.134.136.20]:24025 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752218AbZC3Cu0 convert rfc822-to-8bit (ORCPT ); Sun, 29 Mar 2009 22:50:26 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 29 Mar 2009 19:43:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.38,443,1233561600"; d="scan'208";a="501806980" Received: from pgsmsx603.gar.corp.intel.com ([10.221.43.87]) by orsmga001.jf.intel.com with ESMTP; 29 Mar 2009 19:49:55 -0700 Received: from pdsmsx602.ccr.corp.intel.com (172.16.12.184) by pgsmsx603.gar.corp.intel.com (10.221.43.87) with Microsoft SMTP Server (TLS) id 8.1.340.0; Mon, 30 Mar 2009 10:49:02 +0800 Received: from pdsmsx503.ccr.corp.intel.com ([172.16.12.95]) by pdsmsx602.ccr.corp.intel.com ([172.16.12.184]) with mapi; Mon, 30 Mar 2009 10:49:01 +0800 From: "Dong, Eddie" To: "Dong, Eddie" , Avi Kivity CC: "kvm@vger.kernel.org" , "Dong, Eddie" Date: Mon, 30 Mar 2009 10:49:00 +0800 Subject: Use rsvd_bits_mask in load_pdptrs for cleanup and considing EXB bit Thread-Topic: Use rsvd_bits_mask in load_pdptrs for cleanup and considing EXB bit Thread-Index: AcmwWGazNA3uw50+Q6aDKED1Wo3cTQAgRGUgAAIY27A= Message-ID: <9832F13BD22FB94A829F798DA4A8280501A3C01EB3@pdsmsx503.ccr.corp.intel.com> References: <9832F13BD22FB94A829F798DA4A8280501A21068EF@pdsmsx503.ccr.corp.intel.com> <9832F13BD22FB94A829F798DA4A8280501A2106E6A@pdsmsx503.ccr.corp.intel.com> <49CC9DAB.8090802@redhat.com> <9832F13BD22FB94A829F798DA4A8280501A2107197@pdsmsx503.ccr.corp.intel.com> <49CCE275.9070608@redhat.com> <9832F13BD22FB94A829F798DA4A8280501A21071B0@pdsmsx503.ccr.corp.intel.com> <49CF4C1B.3010404@redhat.com> <9832F13BD22FB94A829F798DA4A8280501A3C01DDE@pdsmsx503.ccr.corp.intel.com> In-Reply-To: <9832F13BD22FB94A829F798DA4A8280501A3C01DDE@pdsmsx503.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This is followup of rsvd_bits emulation. thx, eddie commit 171eb2b2d8282dd913a5d5c6c695fd64e1ddcf4c Author: root Date: Mon Mar 30 11:39:50 2009 +0800 Use rsvd_bits_mask in load_pdptrs for cleanup and considing EXB bit. Signed-off-by: Eddie Dong To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 0a6f109..b0bf8b2 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -2255,6 +2255,9 @@ static int paging32E_init_context(struct kvm_vcpu *vcpu) if (!is_nx(vcpu)) exb_bit_rsvd = rsvd_bits(63, 63); + context->rsvd_bits_mask[0][2] = exb_bit_rsvd | + rsvd_bits(maxphyaddr, 62) | + rsvd_bits(7, 8) | rsvd_bits(1, 2); /* PDPTE */ context->rsvd_bits_mask[0][1] = exb_bit_rsvd | rsvd_bits(maxphyaddr, 62); /* PDE */ context->rsvd_bits_mask[0][0] = exb_bit_rsvd | @@ -2270,6 +2273,17 @@ static int paging32E_init_context(struct kvm_vcpu *vcpu) static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu) { struct kvm_mmu *context = &vcpu->arch.mmu; + int maxphyaddr = cpuid_maxphyaddr(vcpu); + u64 exb_bit_rsvd = 0; + + if (!is_long_mode(vcpu) && is_pae(vcpu) && is_paging(vcpu)) { + if (!is_nx(vcpu)) + exb_bit_rsvd = rsvd_bits(63, 63); + + context->rsvd_bits_mask[0][2] = exb_bit_rsvd | + rsvd_bits(maxphyaddr, 62) | + rsvd_bits(7, 8) | rsvd_bits(1, 2); /* PDPTE */ + } context->new_cr3 = nonpaging_new_cr3; context->page_fault = tdp_page_fault; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 961bd2b..ff178fd 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -233,7 +233,8 @@ int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3) goto out; } for (i = 0; i < ARRAY_SIZE(pdpte); ++i) { - if ((pdpte[i] & 1) && (pdpte[i] & 0xfffffff0000001e6ull)) { + if ((pdpte[i] & PT_PRESENT_MASK) && + (pdpte[i] & vcpu->arch.mmu.rsvd_bits_mask[0][2])) { ret = 0; goto out; }--