From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on060f.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe49::60f]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 72B0282126 for ; Sun, 26 Feb 2017 09:43:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=0eyFS4CMXB2mAYgteKSLrCpaXg6yaFhCjCgQYFLhjAA=; b=N0JQ6EyHvgKgSvR4iQDLY1Jm7RVv0hknx7kK+fVJhuwBaQZaJSW7L/XRtPVi788MPmRx7vRJ3rq6qEDzZh4irXkA48+oykwiEiuMOyZoh6iExhOa2uNOOEfn84+tJY0UKWrJLCM5jvgA0vR7Bfcm/Rlc7ToPMxTFaIkya2ZEa0M= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=leo.duran@amd.com; Received: from leduran-Precision-WorkStation-T5400.amd.com (165.204.77.1) by CY4PR12MB1238.namprd12.prod.outlook.com (10.168.167.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.13; Sun, 26 Feb 2017 17:43:21 +0000 From: Leo Duran To: CC: Leo Duran , Jeff Fan , Feng Tian , Star Zeng , Laszlo Ersek , Brijesh Singh Date: Sun, 26 Feb 2017 11:43:06 -0600 Message-ID: <1488130987-2544-6-git-send-email-leo.duran@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488130987-2544-1-git-send-email-leo.duran@amd.com> References: <1488130987-2544-1-git-send-email-leo.duran@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR13CA0028.namprd13.prod.outlook.com (10.168.240.142) To CY4PR12MB1238.namprd12.prod.outlook.com (10.168.167.13) X-MS-Office365-Filtering-Correlation-Id: d1faa4e2-e2a5-4b8d-e6d1-08d45e6ef4e1 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:CY4PR12MB1238; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1238; 3:qJUo1qM+UYUJeZxKjFrQH+CVg0EGPkxSt089v7bSqhzrv5JD6HxWMyd1QzLFw2tiZpgLTQlb46KGMeEKj4o2P+oaTcRyS4LaSNL6UT2mOwAid4RP60yXGEqU40PuO6Mz5fmuvjIaXOO5kzZESU99vvp/xjGEfYSf+tbkNlQrD1Rv7PzyRikyAZA5wiNs0RVEj25f4wBOO9DLYzCgtfuulkRSKfu6gMgV30bLy5uYQX9K9SpXy63yl0AWXOBo5mZrBYAa55O1RrW8HF8p/DMCmVvhKOdZgq4+SCexV1vR3Ug=; 25:anuKoUOTsyq6wYedMccZSmdqt6xLqRYN+uivs0OkNTFxEpHQGtLeRJrImDd1FfHTovyGjAIDtAmUOEAqU9Afhs0F/Tv7m+tLFG4gRtPTvJb6zNxn9eLch5W/Vt/xDn1yqB6xXJME9Xyk7FkpMt5S74tkp9I9M506uuB7JnJ2EbbZDNqxYRmlKgpPS7AqkIKjwWmcz+VfcvltV3Ou4xLGG7Ey3xtK34nZG1E+APFm9nF1mRbzFoerW1rZxKi0HlFu87qjpatI+xtFuB1cDB2w80nZm9yqSNbwOgMi2jcbr0PkNH9w66MsthvKSTjCj7+ICIigZ8ZqjupYXVUFp7JJjijPyvWypbgcW93AQbtuH3babjjMHz5bE6arU0F2rGz6Ms1umM00oRVlOmocJH6KPG31ykqZA2CHljIdppfqZ4zsSGlGser4MyLGLUsmTpAB X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1238; 31:GBLFOwAtAB3ufHajV66xU9qtIpUBsAjY1Zs4hTHpiZtv7uQLTn7zhySl6+OfkMkVAYw57Mzr4HpWYPt2oUHexF77mV/p3FRsfvsep+AUqv7Vv1buWE+6gu6EpiA87526rbRwAv5PUi9yi9swwc1stjYDZttZ8NKubCdqzfZkRIYR/olKf4QqFAc192H6dI5ay5rVNWTf1s6N5YNCfUE4JT11EZ8p7cZ7D3G64Dre4DE=; 20:a5DlJ89bsIFVQ/+/YVwLLQJO37EBNOVPIQIK/d7s9QV15IqqdlR9c8PFZtbspEGqT7/BXt7EQIMHdWq4cCPMYUzz4N5+vER+Fbg3TcQV7DNUQmq+I8uTRA0cSRKAOJKPcyijOZHEr4QVJWOdCit//l6pRxNh5p3NsBpc4NHwEBbi20q/9aHRwgIlDZiAhSBXLX33QwW8RFYlw5/BiHcYVJnaLS2EjOmOaA8rg46cIhPShyngsCydOewaIHLdMWToEjA7nSzoCj+4O9t2SJuTOdZXil+eGhhcD866enQXUpi/upQ6zAzXag0FZJkHSFftHHWi4x20zTyEYWg1qlrRNyLkoYcG5hxdS3CkhOL0+YQO7aPljAKAa9gV8CGG+OWLn+XD0Mf0tHaAlweBEgjJeeKj4IrubLviTbfMCuNy6kMx4ma7/yimjkPXVnVbjoj4Ddj0q17gWE3HUVA5UGKhZE4ej8p77p4IoMYqGaFWB06EaMionX6MR3JlI3mhUIGD X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123555025)(20161123560025)(20161123562025)(20161123564025)(20161123558025)(6072148); SRVR:CY4PR12MB1238; BCL:0; PCL:0; RULEID:; SRVR:CY4PR12MB1238; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1238; 4:k3s8PhPMrKM3PdSFIZAhhnw7tueVCw4VVIpyX8UQRJ8swzItI/AkjoPDqc6mgVHSzbZaGsKUg5fQ+oZ0EnrZ6MlXQ7K8uaS6Fb983xQdW7XUfomKCkEVbj9+iyLZtBk+ow0RSzK+iiDCH/nvmZqyTO+RFWAP0IGGB8GVffS2jlfEw6ek82g2CzkgZQHtcQxYhFckKKlOolz3Fxg0mrGSlxbsxdwHnapVr7CKRnVP4ByxzHYz9j1QdHRw0ctELke49WkY9jsd0t5ZwOcJKjBS0vusFZpJlXTROd/kLt3Ou23lGnqASaEdvZeF47o0Y0as4AmX+olKOIOrPf27fIWVX8sZW57b3MUsgKx5lnGQYwVhWc6QawL6Wr42KhwLle4iEAt0AyWkjZ1NKtHbgVQopcroGtfFsE7av+h1v2luvhQK2gd/2qoEPcxrEO9u6AaaYew59w3JKVbTabX5mOY/oyyoaNpiEJB+RQQQ4wkV+g+1FyBowVQ4UmUxpAD50tXnzpVZsI7/JAmG6oXt0RHJd+wrzUZOjfZJ8E3rvq7a/vDh86YOTanHOmtvasmzYvrr/RwfwnXeshNuM9eWBrZTsVkIlSgfVOLPPfAdg7oey1LgHIXkpLEe1DpWeFgLyO311uFfEmmc+8t3QrqOOG4sQUFauytoo87U2AHACn0AL+tlN+Duu5iKZANUyiTp3dlM X-Forefront-PRVS: 0230B09AC4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6029001)(6009001)(7916002)(39450400003)(39840400002)(39410400002)(39850400002)(189002)(199003)(305945005)(53416004)(105586002)(106356001)(68736007)(33646002)(5003940100001)(92566002)(2351001)(189998001)(42186005)(81156014)(86362001)(97736004)(7736002)(6116002)(81166006)(36756003)(8676002)(54906002)(3846002)(50226002)(110136004)(6486002)(47776003)(66066001)(101416001)(25786008)(53936002)(38730400002)(50986999)(48376002)(50466002)(6666003)(76176999)(5660300001)(2906002)(2950100002)(6916009)(4326007)(213903007)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1238; H:leduran-Precision-WorkStation-T5400.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR12MB1238; 23:0d9YLrRsjxSZFZRLLrVej4owisM3Bzs1MfQZaQj/X?= =?us-ascii?Q?WsTcpmPPLVbzjXMWRG7txb0H+jLmSK6fAOBFm/fathzQ4goJfTccJRDgxijA?= =?us-ascii?Q?yCf0iM/rcqm0Ry2cbSOtTYLj7jp9UD8+siXMPCrdCnJ2xE0zr6mk3y8baQBa?= =?us-ascii?Q?F4V5IZDf7kjzWZbH/Mx9xI7hAS1U4atYKhf4Glik/UvOvdI46crwXBIX06ef?= =?us-ascii?Q?yTnqvRAcRkxv7mSLK3pBp9fa37fWhAOyrlxCeDURvqOSqttRwdRnEiJ5wjqr?= =?us-ascii?Q?lDJJKpG8fyMpRWYbdPpcWStudWYED8h/EwyvF/swZQhP0yPI//4q/RMzmPWV?= =?us-ascii?Q?xj8h/jqkljylthamKLJLjsnY+cp55km9hU1gs33aWnyIp/9S1+iov0gTVkwB?= =?us-ascii?Q?rFbQYIaaaSof+ftXgmfbRcCJWMdrB8d44iiG8UZ0qKUJ17h81h+xdFXzCIUE?= =?us-ascii?Q?FdIXWCZxWMBmSHUyM/h+UtoCNTXh8j+PNfMeI2nN5qzpI01omdhENK7YGI1W?= =?us-ascii?Q?TauAq3bXgq0PfpbQSgFN8H8F1A37a4cljqTwyfXMzg9QMJcunONOWObSRYca?= =?us-ascii?Q?Wtmb5ev0n5oxELrDQvLkK+qNSu9VyyamC8HItSQuyMuLC8uEZCBdnb14EiOV?= =?us-ascii?Q?f5r7KtBTqajdFp+w4Q2Wx55jP5GEJWGram6pI5UZX2tvD6YHdRMyCdwwYbJ5?= =?us-ascii?Q?yFFAHHuiEjfHxD2pnFo/UX9yuN4wsviNt2oObTRDfuMm9CfHpiORYrxLBPhs?= =?us-ascii?Q?QzcUb/7efqS+7dJ7ux6g5suc7JSPIO60XNrIRMwwt3BB7bxA2r0kpk9peJIC?= =?us-ascii?Q?RcUYNnnOTJYnX9OCpQFitHJHktpwPN7/LI8B6eghOsl7KA+VuG+sSH/+os5T?= =?us-ascii?Q?n5uaLLU+7C7eBuaS/6GfexRQcYwZIUUX+tlQGxIVirkJ2TkcXS6DNKUTeHp7?= =?us-ascii?Q?oK76LrRsG88BkZ5VRiaKGsC6ZKKK9bbmU8nJd99tu761HqKoH2cL+948kw4f?= =?us-ascii?Q?lsXEg3KmS/PyIwg2HXT2iA0fEM5iOXlO3TGcedtuHjDVYODU2irImW+RIJjo?= =?us-ascii?Q?m+8H1PrClr8IgjrJ4rOsm6ILPkW4nnJCz+DPYySDSV99O4+/F3fKHUcCysQt?= =?us-ascii?Q?lXnGNbwoOd4j+2YJ7w0cKwyDeqGG6AClOYNIzaZXMKOf45K7dUezCaTldxRU?= =?us-ascii?Q?fUA4Iqy0mpbkCS1Rqkhp/A5IDcaDgoOa7gLXe1DfM0vZfJA6YrXCtzIWLExi?= =?us-ascii?Q?+K7o8skNQj3ynmyCvNzK7QKhgrARdGjLA41LIfL?= X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1238; 6:HRGiLkM/SAkA/mv8+hToTuRJaMlCqfkrRrZJcEojyo4tCeHoIqC3EyHWf/A0Y5j0BpnixGgcFJ40/CHpBBbBxm/XYzobEB8hOtlwuLV2Isoj12OCorJ7ldZwnZBsIzzAkBmnAjCGqKjLcXN40vSGir7fNr2hDBts9taK7PDo2QppA3Fq0ZVzNp7nsDjCcpcHW4jWoq/Tzi0EMAepUUm2azBRVbRgWuyYhgB5HC9xi/HlYNeL3on0kHN3YiMX1w2+9AKC5cG58dyV1Zu0E0buAtXLRvLMHPgCXEJ78ZNsaco2tMaR29nvSHbtr+KeeoHsp1MkXxGg/ucLxv1LbZAT3PGm73ybRBVIZkcZTJ5+BNcljweILb2ITfsPJ2CTzCYr2bAA+rGg+kCS8esAvpBeIg==; 5:Yr1xCg9iRgDoFLG55t4hVwv4PbxjZ5yyAHusO3AiCu5n0T9jBz1UTQczc6g2fozJUSdZ+R1U6pHBTjAalL9ZhkKHgjwOC2B48Y+PKctbxTauQ0EiVK9VSk4ucAJVsTAZJWC36MDMY/J5+YEyZw0PXA==; 24:rKsdoKKzoxU62rfZpnpkbWnYT2KIda0lw7OHPFugkAWI0+PGNQ5KvHWVF3Ac5rC3USc24q9nYhGL6u+BLXyVOa0CsQWFnL9PlvtTnTCEBrg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1238; 7:Bg1VL5JoPuu6SQq3WMjXcDoflPOotRP0B6GbDsx1u17G6pDfgU8HMvuKnOIMs1Bi6IatUZ0tB9S2XBOerMhr1zXW7c5difLDbtE6uHWu8dVlYG0HWCuiuKYinqEZyAO/3gtg9PVoFaJtLeDSzlNigthupOxda474aFlI/nKil2uNXNi4aehcbNyqt6b4ydonj7FfRv0u4evX3ILIoOwGSt29jUPJ/eeFu4CD23p5+jE6Zd9crUOVupvcThs/r8jeqJQQdzaT6PFvPbBHptbgB7qiGuE2bOL8etg+Y8rDEYtEqaPlWVoJ3MjWCBWA0uWSQnGMfTss2tvmXsus+AwmzQ==; 20:3NTjlUn3k+Zk9FU7Im0PEi69paR6fg0ElardmolF/4eDlnVk89ULwzjdD5Xh+1Kz6Wpp4LsA7LUakVhRPi7GNLtjVVG5pFNcdzk7OJXbUw0cwDdYDy0UJoOoLWzhoLLJrzXHoDd2mE9LI9dkMJayUJuP+vSi9HHOxbHEMvVPqHqRh8fhsXE7YXfjL9RbXTxx9xRJcSFAnaUgNa1pRyAJzPjX+g1RXcZ5jIgppAh/UFDaIbXEQpvJ0EL/caSMSSdF X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2017 17:43:21.0688 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1238 Subject: [PATCH v4 5/6] MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe: Add support for PCD PcdPteMemoryEncryptionAddressOrMask 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: Sun, 26 Feb 2017 17:43:22 -0000 Content-Type: text/plain This PCD holds the address mask for page table entries when memory encryption is enabled on AMD processors supporting the Secure Encrypted Virtualization (SEV) feature. This module updates the under-4GB page tables configured by the S3-Resume code in UefiCpuPkg/Universal/Acpi/S3Resume2Pei. The mask is saved at module start (ScriptExecute.c), and applied when tables are expanded on-demand by page-faults above 4GB's (SetIdtEntry.c). CC: Jeff Fan Cc: Feng Tian Cc: Star Zeng Cc: Laszlo Ersek Cc: Brijesh Singh Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Leo Duran --- .../Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf | 2 ++ .../Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c | 7 +++++++ .../Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.h | 5 +++++ .../Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c | 15 +++++++++------ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf index 7cd38cf..29af7f5 100644 --- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf +++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf @@ -5,6 +5,7 @@ # depends on any PEI or DXE service. # # Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2017, AMD Incorporated. All rights reserved.
# # This program and the accompanying materials are # licensed and made available under the terms and conditions of the BSD License @@ -85,6 +86,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES [Depex] gEfiLockBoxProtocolGuid diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c index f67fbca..22d4349 100644 --- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c +++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c @@ -5,6 +5,7 @@ in the entry point. The functionality is to interpret and restore the S3 boot script Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -23,6 +24,7 @@ EFI_GUID mBootScriptExecutorImageGuid = { }; BOOLEAN mPage1GSupport = FALSE; +UINT64 mAddressEncMask = 0; /** Entry function of Boot script exector. This function will be executed in @@ -408,6 +410,11 @@ BootScriptExecutorEntryPoint ( } // + // Make sure AddressEncMask is contained to smallest supported address field. + // + mAddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64; + + // // Test if the gEfiCallerIdGuid of this image is already installed. if not, the entry // point is loaded by DXE code which is the first time loaded. or else, it is already // be reloaded be itself.This is a work-around diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.h b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.h index 772347a..7532756 100644 --- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.h +++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.h @@ -5,6 +5,7 @@ in the entry point. The functionality is to interpret and restore the S3 boot script Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -44,6 +45,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include + +#define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull + /** a ASM function to transfer control to OS. @@ -87,5 +91,6 @@ SetIdtEntry ( extern UINT32 AsmFixAddress16; extern UINT32 AsmJmpAddr32; extern BOOLEAN mPage1GSupport; +extern UINT64 mAddressEncMask; #endif //_BOOT_SCRIPT_EXECUTOR_H_ diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c index 6674560..d433cf1 100644 --- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c +++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c @@ -4,6 +4,8 @@ Set a IDT entry for interrupt vector 3 for debug purpose for x64 platform Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -200,14 +202,15 @@ AcquirePage ( // // Cut the previous uplink if it exists and wasn't overwritten. // - if ((mPageFaultUplink[mPageFaultIndex] != NULL) && ((*mPageFaultUplink[mPageFaultIndex] & mPhyMask) == Address)) { + if ((mPageFaultUplink[mPageFaultIndex] != NULL) && + ((*mPageFaultUplink[mPageFaultIndex] & ~mAddressEncMask & mPhyMask) == Address)) { *mPageFaultUplink[mPageFaultIndex] = 0; } // // Link & Record the current uplink. // - *Uplink = Address | IA32_PG_P | IA32_PG_RW; + *Uplink = Address | mAddressEncMask | IA32_PG_P | IA32_PG_RW; mPageFaultUplink[mPageFaultIndex] = Uplink; mPageFaultIndex = (mPageFaultIndex + 1) % EXTRA_PAGE_TABLE_PAGES; @@ -245,19 +248,19 @@ PageFaultHandler ( if ((PageTable[PTIndex] & IA32_PG_P) == 0) { AcquirePage (&PageTable[PTIndex]); } - PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & mPhyMask); + PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & mPhyMask); PTIndex = BitFieldRead64 (PFAddress, 30, 38); // PDPTE if (mPage1GSupport) { - PageTable[PTIndex] = (PFAddress & ~((1ull << 30) - 1)) | IA32_PG_P | IA32_PG_RW | IA32_PG_PS; + PageTable[PTIndex] = ((PFAddress | mAddressEncMask) & ~((1ull << 30) - 1)) | IA32_PG_P | IA32_PG_RW | IA32_PG_PS; } else { if ((PageTable[PTIndex] & IA32_PG_P) == 0) { AcquirePage (&PageTable[PTIndex]); } - PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & mPhyMask); + PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & mPhyMask); PTIndex = BitFieldRead64 (PFAddress, 21, 29); // PD - PageTable[PTIndex] = (PFAddress & ~((1ull << 21) - 1)) | IA32_PG_P | IA32_PG_RW | IA32_PG_PS; + PageTable[PTIndex] = ((PFAddress | mAddressEncMask) & ~((1ull << 21) - 1)) | IA32_PG_P | IA32_PG_RW | IA32_PG_PS; } return TRUE; -- 2.7.4