From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from SNT004-OMC3S3.hotmail.com (snt004-omc3s3.hotmail.com [65.55.90.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2260481D40 for ; Thu, 3 Nov 2016 14:41:32 -0700 (PDT) Received: from EUR03-DB5-obe.outbound.protection.outlook.com ([65.55.90.136]) by SNT004-OMC3S3.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Thu, 3 Nov 2016 14:41:33 -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=jNsjMZqj3UKQzqH1qkdHOxo5LWnrclj9sTEnaQ7HAtA=; b=giNOuSB1aaNP6Nq2hsT4D43i4k8sgK2qHFXhk1i5P1LwKwU5ZC7X1kksuAmhR8yQbAAFzq1UTnRPReRLeyxUZHxC4hzv6IdzJkd9fSWqf+LKhE+gBnYbe+YvTawC+YMACuHuTWG6nEeH2mxAXbm4qY6duMlAcrNwbVHBmpPlcu75uvi76taz4RWUwh/JxwlUA9N24b7mWX7/eZwKOHV3ckZnVV6dNSOPjJCBmUN4iO7YwYD6tJzOCfK0C1x+1bWpmJiGW0YU21NyJRGbAasy/PCmExfrtOXSk0YjblIfrhrHAIU+LWsSrtnXWIU7ak1RAOzQY/2ynXhJQT3U9QSEtw== Received: from DB5EUR03FT061.eop-EUR03.prod.protection.outlook.com (10.152.20.58) by DB5EUR03HT038.eop-EUR03.prod.protection.outlook.com (10.152.21.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.6; Thu, 3 Nov 2016 21:41:31 +0000 Received: from AM5PR0601MB2579.eurprd06.prod.outlook.com (10.152.20.53) by DB5EUR03FT061.mail.protection.outlook.com (10.152.21.234) 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; Thu, 3 Nov 2016 21:41:31 +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; Thu, 3 Nov 2016 21:41:31 +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 v3] OvmfPkg/ResetVector: Depend on PCD values of the page tables. Thread-Index: AQHSNhsKFB9ptxKET0KDdBGfDpSPTQ== Date: Thu, 3 Nov 2016 21:41:31 +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:7216; Count:35 x-ms-exchange-messagesentrepresentingtype: 1 x-incomingheadercount: 35 x-eopattributedmessage: 0 x-microsoft-exchange-diagnostics: 1; DB5EUR03HT038; 7:Gloh/U+ghnBPxbC9sVTw9nuIJaMAC8xWjvvRkeRUz03MUJuqUXnsXphaYpDHC+6BM3BDfnPY/4DMFq3obJnb5D8G94EJu6ZO6vIXj6TjIK0aX2QQ4KMFFgbHCJLIa/gohHfSd+7QnGQI3Tmxiuu8hR84kSz8MYCyF1mKtKY6eRyn8j1qtzzSlFnpCp/td2jJAUulMygBvXLpL98/WlwiaDktOi/LjxXHPYkDlj5EOEbDaU77W5fi3vphW9jsBaSjP45Lw5bsKRdly/CzGNhpu841y9/ZHp7Yuvc53aPDwHXI1buW6WYP1yaFO9gggBCTbelBQOom/21+o2UXCI0IvmHmtFb2OOmxsfKcsee7Jtk= x-forefront-antispam-report: EFV:NLI; SFV:NSPM; SFS:(10019020)(98900003); DIR:OUT; SFP:1102; SCL:1; SRVR:DB5EUR03HT038; H:AM5PR0601MB2579.eurprd06.prod.outlook.com; FPR:; SPF:None; LANG:en; x-ms-office365-filtering-correlation-id: 1a951d9a-21a6-4ce6-1415-08d404322c44 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(1601124038)(1603103106)(1601125047); SRVR:DB5EUR03HT038; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(432015012)(82015046); SRVR:DB5EUR03HT038; BCL:0; PCL:0; RULEID:; SRVR:DB5EUR03HT038; x-forefront-prvs: 011579F31F spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Nov 2016 21:41:31.2685 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5EUR03HT038 X-OriginalArrivalTime: 03 Nov 2016 21:41:33.0422 (UTC) FILETIME=[0BA008E0:01D2361B] Subject: [PATCH v3] 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: Thu, 03 Nov 2016 21:41:32 -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 | 6 +++++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/OvmfPkg/ResetVector/Ia32/PageTables64.asm b/OvmfPkg/ResetVecto= r/Ia32/PageTables64.asm index b5a4cf8d7187..0b95a7fa9a86 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..4bf8c97d8158 100644 --- a/OvmfPkg/ResetVector/ResetVector.nasmb +++ b/OvmfPkg/ResetVector/ResetVector.nasmb @@ -53,6 +53,12 @@ %include "Ia32/SearchForSecEntry.asm" =20 %ifdef ARCH_X64 + %if (FixedPcdGet32 (PcdOvmfSecPageTablesSize) !=3D 0x6000) + %error "This implementation inherently depends on PcdOvmfSecPageTables= Size" + %endif + + #include + %define PT_ADDR(Offset) FixedPcdGet32 (PcdOvmfSecPageTablesBase) %include "Ia32/Flat32ToFlat64.asm" %include "Ia32/PageTables64.asm" %endif --=20 2.10.1.windows.1