From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from BLU004-OMC4S7.hotmail.com (blu004-omc4s7.hotmail.com [65.55.111.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DB08E81D3D for ; Fri, 4 Nov 2016 06:32:41 -0700 (PDT) Received: from EUR01-VE1-obe.outbound.protection.outlook.com ([65.55.111.135]) by BLU004-OMC4S7.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Fri, 4 Nov 2016 06:32:43 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Z1TWqZ7e/+81ELB58exKFi0HfYWNkYGUzZMQ2DQAmMo=; b=KqYabGQdSTAFT6Fx0hl84ULwKC5op/3jaQdPigF43aaCuBIPz95fWJo1l4ee7hQe+9hxJZe9xib2X2HxIFcaSXlwCauzKmdPciqHFsVSBAqvTJn/oLRfrMlJnQFgT3d0XQyDskEZkciDc9YqMlOgKCdgEvqkq3LMRLxPL1ywEu0B/BMNGTcKfNO60P0gnUY8s96YekGlq2MTsaz9sojo0oDImJpW45pBXcZs1eXqH1YqewoU7uJpFCurlbncGdoVCIBc2k/dl4j4G+h9Qau8AcTSUlEgg6uD7E11f9lDmGLkyfYVYVEF2UX25FPFkIcMKdYQH8qs8uKLGoneoytMHQ== Received: from DB5EUR01FT027.eop-EUR01.prod.protection.outlook.com (10.152.4.60) by DB5EUR01HT074.eop-EUR01.prod.protection.outlook.com (10.152.5.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.6; Fri, 4 Nov 2016 13:32:40 +0000 Received: from AM5PR0601MB2579.eurprd06.prod.outlook.com (10.152.4.60) by DB5EUR01FT027.mail.protection.outlook.com (10.152.5.1) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.6 via Frontend Transport; Fri, 4 Nov 2016 13:32:39 +0000 Received: from AM5PR0601MB2579.eurprd06.prod.outlook.com ([10.168.154.13]) by AM5PR0601MB2579.eurprd06.prod.outlook.com ([10.168.154.13]) with mapi id 15.01.0693.016; Fri, 4 Nov 2016 13:32:39 +0000 From: =?iso-8859-1?Q?Marvin_H=E4user?= To: "edk2-devel@lists.01.org" CC: "jordan.l.justen@intel.com" , "lersek@redhat.com" Thread-Topic: [PATCH v4] OvmfPkg/ResetVector: Depend on PCD values of the page tables. Thread-Index: AQHSNp/pRuq3QiY5hUquzPFfwof2YQ== Date: Fri, 4 Nov 2016 13:32:39 +0000 Message-ID: Accept-Language: de-DE, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: lists.01.org; dkim=none (message not signed) header.d=none;lists.01.org; dmarc=none action=none header.from=outlook.com; x-incomingtopheadermarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:7131; Count:34 x-ms-exchange-messagesentrepresentingtype: 1 x-incomingheadercount: 34 x-eopattributedmessage: 0 x-microsoft-exchange-diagnostics: 1; DB5EUR01HT074; 7:YpAKdjkyYUp2GZjrfuu6TUujMHQtKeJNH2tn3wBxNuZm47eGqDhusS7SUHOdN0JnKPMlXu5446IDraGqQNaZdQiRgSdYejpo2DklmNlwzHdJTzFKQbq6pmmLjzO9AWD5giSNJxJq5ltzeLT70C7GrLAZ+qam6Zb5+a0tZkzgTyooE2J3OU/nJW/bwsb52TjDVPlr/o0TNguRATjxK1rhsOuacAZSk80P6b7HAGKtSXDs6W+1t6IgU4OZ2z1ga5cMf54mm+SJQy86FR5J1dvEbbU8YO++B9CQcfWppMD9ps2l0BYlMQefWDOTRRTGtXTfNx7TpQ7c/sewghh3IwmGaQlHKLsic45fwe7buLfgO9U= x-forefront-antispam-report: EFV:NLI; SFV:NSPM; SFS:(10019020)(98900003); DIR:OUT; SFP:1102; SCL:1; SRVR:DB5EUR01HT074; H:AM5PR0601MB2579.eurprd06.prod.outlook.com; FPR:; SPF:None; LANG:en; x-ms-office365-filtering-correlation-id: e5393259-63d0-4a77-72fd-08d404b70b8d x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(1601124038)(1603103113)(1601125047); SRVR:DB5EUR01HT074; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(432015012)(82015046); SRVR:DB5EUR01HT074; BCL:0; PCL:0; RULEID:; SRVR:DB5EUR01HT074; x-forefront-prvs: 01165471DB spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Nov 2016 13:32:39.6027 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5EUR01HT074 X-OriginalArrivalTime: 04 Nov 2016 13:32:43.0496 (UTC) FILETIME=[EC0A3E80:01D2369F] Subject: [PATCH v4] OvmfPkg/ResetVector: Depend on PCD values of the page tables. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 13:32:42 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Currently, the value of the page tables' address is hard-coded in the ResetVector. This patch replaces these values with a PCD dependency. A check for the size has been added to alert the developer to rewrite the ASM according to the new size, if it has been changed. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Marvin Haeuser --- OvmfPkg/ResetVector/Ia32/PageTables64.asm | 23 ++++++++++---------- OvmfPkg/ResetVector/ResetVector.inf | 5 +++++ OvmfPkg/ResetVector/ResetVector.nasmb | 7 ++++++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/OvmfPkg/ResetVector/Ia32/PageTables64.asm b/OvmfPkg/ResetVecto= r/Ia32/PageTables64.asm index b5a4cf8d7187..6201cad1f5dc 100644 --- a/OvmfPkg/ResetVector/Ia32/PageTables64.asm +++ b/OvmfPkg/ResetVector/Ia32/PageTables64.asm @@ -44,10 +44,11 @@ BITS 32 SetCr3ForPageTables64: =20 ; - ; For OVMF, build some initial page tables at 0x800000-0x806000. + ; For OVMF, build some initial page tables at + ; PcdOvmfSecPageTablesBase - (PcdOvmfSecPageTablesBase + 0x6000). ; - ; This range should match with PcdOvmfSecPageTablesBase and - ; PcdOvmfSecPageTablesSize which are declared in the FDF files. + ; This range should match with PcdOvmfSecPageTablesSize which is + ; declared in the FDF files. ; ; At the end of PEI, the pages tables will be rebuilt into a ; more permanent location by DxeIpl. @@ -56,21 +57,21 @@ SetCr3ForPageTables64: mov ecx, 6 * 0x1000 / 4 xor eax, eax clearPageTablesMemoryLoop: - mov dword[ecx * 4 + 0x800000 - 4], eax + mov dword[ecx * 4 + PT_ADDR (0) - 4], eax loop clearPageTablesMemoryLoop =20 ; ; Top level Page Directory Pointers (1 * 512GB entry) ; - mov dword[0x800000], 0x801000 + PAGE_PDP_ATTR + mov dword[PT_ADDR (0)], PT_ADDR (0x1000) + PAGE_PDP_ATTR =20 ; ; Next level Page Directory Pointers (4 * 1GB entries =3D> 4GB) ; - mov dword[0x801000], 0x802000 + PAGE_PDP_ATTR - mov dword[0x801008], 0x803000 + PAGE_PDP_ATTR - mov dword[0x801010], 0x804000 + PAGE_PDP_ATTR - mov dword[0x801018], 0x805000 + PAGE_PDP_ATTR + mov dword[PT_ADDR (0x1000)], PT_ADDR (0x2000) + PAGE_PDP_ATTR + mov dword[PT_ADDR (0x1008)], PT_ADDR (0x3000) + PAGE_PDP_ATTR + mov dword[PT_ADDR (0x1010)], PT_ADDR (0x4000) + PAGE_PDP_ATTR + mov dword[PT_ADDR (0x1018)], PT_ADDR (0x5000) + PAGE_PDP_ATTR =20 ; ; Page Table Entries (2048 * 2MB entries =3D> 4GB) @@ -81,13 +82,13 @@ pageTableEntriesLoop: dec eax shl eax, 21 add eax, PAGE_2M_PDE_ATTR - mov [ecx * 8 + 0x802000 - 8], eax + mov [ecx * 8 + PT_ADDR (0x2000 - 8)], eax loop pageTableEntriesLoop =20 ; ; Set CR3 now that the paging structures are available ; - mov eax, 0x800000 + mov eax, PT_ADDR (0) mov cr3, eax =20 OneTimeCallRet SetCr3ForPageTables64 diff --git a/OvmfPkg/ResetVector/ResetVector.inf b/OvmfPkg/ResetVector/Rese= tVector.inf index 46610d243ecf..d1e5d4d9bdea 100644 --- a/OvmfPkg/ResetVector/ResetVector.inf +++ b/OvmfPkg/ResetVector/ResetVector.inf @@ -29,9 +29,14 @@ [Sources] ResetVector.nasmb =20 [Packages] + OvmfPkg/OvmfPkg.dec MdePkg/MdePkg.dec UefiCpuPkg/UefiCpuPkg.dec =20 [BuildOptions] *_*_IA32_NASMB_FLAGS =3D -I$(WORKSPACE)/UefiCpuPkg/ResetVector/Vtf0/ *_*_X64_NASMB_FLAGS =3D -I$(WORKSPACE)/UefiCpuPkg/ResetVector/Vtf0/ + +[Pcd] + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize diff --git a/OvmfPkg/ResetVector/ResetVector.nasmb b/OvmfPkg/ResetVector/Re= setVector.nasmb index 31ac06ae4a8c..29cbad367711 100644 --- a/OvmfPkg/ResetVector/ResetVector.nasmb +++ b/OvmfPkg/ResetVector/ResetVector.nasmb @@ -53,6 +53,13 @@ %include "Ia32/SearchForSecEntry.asm" =20 %ifdef ARCH_X64 + #include + + %if (FixedPcdGet32 (PcdOvmfSecPageTablesSize) !=3D 0x6000) + %error "This implementation inherently depends on PcdOvmfSecPageTables= Size" + %endif + + %define PT_ADDR(Offset) (FixedPcdGet32 (PcdOvmfSecPageTablesBase) + (Off= set)) %include "Ia32/Flat32ToFlat64.asm" %include "Ia32/PageTables64.asm" %endif --=20 2.10.1.windows.1