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 3E11482127 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=4DtuCFuMxAG3tRhvhEqLYzYoxuH7+tUpJmzgyAkOmxA=; b=cinbnOwx4DiowiyGFUA8VYKYpi7uNATWR4Azi64b8KiA/8DFWSAk9CXaVhl72ZYENPvCMqAqXyuQDilDXCvfTJ+zBqvLflRRPQmYGv+A1BeeuRmetxIx9JQG20wo6a4nqtWSsmwT8QPUi0oJol2WHtAIszMYRUwwms9/wY3oR8o= 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:20 +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:05 -0600 Message-ID: <1488130987-2544-5-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: a0cba31a-bc9d-4d01-6b5a-08d45e6ef472 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:Fycj51RpjtETRuc0HE5GtFX9yyIta24Ce7cnx+CdzvvE5PAAgiL2WpFKvS3V4C1Gzs3KB0p1q0lp0ORCSU2dd+RGVdLb9D0eojwd565Phf5QgyccjzSz09I307B5g8y6pkmxp0a8QDy0QzjP6FvGErseeCa+RiS57w83sxh5OSxKzDUR0MyfkUqNw28bxquh9AhgbbxoiM1eR49rgF4wyGGVGOrOS3u4EVES0sjpONWPHxz4YTr1n0Ckr2g3ztxlaKAGGkyVPf+FUjAxRPFcd3tjHz+ftkC4sjNd2ZLEtks=; 25:LoO18dEYZZh/8d9bE4Cy8ArFmJa8qc8O/qT4sQqs5Q4wbfWutFxrj3e68GN7eZd9UigSNEbkDUpRmbOnmHGIEXZ0EwTzzC4efH+wdoPOsYDwK+hM/4KsWaPGTOJy9wSGk79fjjMqAF/gMdfn9O6H2bxcUFVrMBAH1H6TzC43PdhmiQdqAtpgiN4AeAF14DSZ0Vl1emecZDLzQmiJMl4ONpGC6tT9zZsPDrUu7QRmkXyUwEOUIEfWbLjFPjWJf7rF0LWs1wjGSqylDWMo5Mf/IUuy29dVBtSDPrRrIQ63SCLoIvbua4ASNf4aoQHhSDIuXfLdWg1IcE4f/RsU/kbWbgVUFytaDC9cfPo5C4PTZVF8GidLAJUnTWIWjwgzhheEG6q24FQzKzql2OIaRAJYyrL85yd2reOxaW9LQQbGAmKeWat3/9CSFkIMtPX/e0HYi795YCq8dm5ztbhXFmJe/g== X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1238; 31:UES/kcxfc3IGJ07F9px+8gjehlstNLh57diYMzCSSW9vOOP1iWxnPuXl1/XYNeTrWK9e5CkJNKsUUFQFkzqO55i21Leab3T3fcESmhxwtKBlF5eKU3s5msmnne4Mde7RNeVBHv4qAEtP2/UUmmMPo3Te6Q8UVmJuyhp7A8CL8sRjydkKOWoC6qlhFQbBSI9/eYAf9Jk73BwzHoFhJG7mosI8ek964kiMUBbeXcDzYrMN3xWpiFnuK9WP2EAOPyH9; 20:Kp1jEP9TQIDBzzJvoWGBrrwFn5N7hzwWP7abU2GRYlDOZ9ig8TAZPbfMpamCDC3jUfe47eW0/dyQjb7+WzLVnzt0EiyuTDt/Yuyix4r0cUTnGiFe9iD0YR3AfO3xdSvIDyi1iekj4wJY9agREyaggwoZn/S4NHygtJ0lKBCFJPL+VWzqh6sgbDorvTTCvZhN77sFAAdQBLn8cP+skraOZC8ZoXPUST+Wi7nF/V/1pwyLUg0Ixjt3IqKLd1UwxmhrPbqjeWRB7vXitwOdCl8ppjngdkdxSZgjVYY8c9eFO9htduyWlhLM/CPB7xR1gW1fNsL9FLpqhmk8JLP+42clak60B3FRxyw24ALVxTeW4jEsF5jygreWrjmJeQ2Wt4LVzzI24Vrp4EJfRKP5KZsTlaTCdny+SCyoC1O0W37Vxh1PvR762WIDywU73IYVWTdcSs4dcGTirEY5VDOnu1a2dj4UvSSP4H4gseatCqjR7gfT1jubL4E5sFczaaMTHGdr 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:b30n8XzWSb4CJXIFYjRS++U77s9R2R4qCq1oSA+Pu2Sq5P6jquCC0XUMldRyciKLE3JGbGGVVmqCRC6tNc2jQ46TMa7YQvImyGFylO+dhO6ufWS9l5y4lhxCBG7dmd5l7AOd/LeFLo93jdFvr1kjXrIWmcd2XyqAgJvDS1xl8z4+G8efj0jjHni8S9/Cnr/ZF2EDba82CbMGXifcvCMfY/zDZrzrNQDe50n7EyjY9MGnAbhJxa1zy346Rii7nsZJu6hZY+CtDrjFveCCEoT7/S5JAUGdfyK+JeQY+s8PaBgYsN8O+wjH0gdltYZobkTIFCdyUV2fjGReZnvQinS/U8rLEGoOeGVwum7nenoB8cR1nwmUo30lSVt+gyxE0h3mbPnszts8r9d92mzOkdTgAkItPCXd/YMTqVRhV1+/Jv654H2Ol3uxZuSB+SJIvKsFkGkCN5BGA+qXXiS7rrmfmDHClG1E1mHJ+gnxUEQqxHxQHZftupvREVvnfqL7GFQsWQKb6h76LzGbBxiLL+35Z9CU2fEujnRj9DEotTeh4Kf25bqxzMpDkjfB4Hs5QjIjYZHjSYdKIf+ZgHB4DF4VSDIzYHIniLPmb6eVhijLWj+MbIB+xa5egFopPhO8sBbIt9JpsQywZmxUpuh+9lV4Dljn3DTKbMxHJBpOowVCYYOOXGgF8l1mtXINtVNZ77ly 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:KmaFrbgAKMTuWmAyGbH2/0EBUke5HU2tVWH5jpSst?= =?us-ascii?Q?pTYYIMLK+X5+oY8HcymXvqdkn4zS/OCHo9m8EmzDXK7zbbF2OyyzJHzlsR4u?= =?us-ascii?Q?y/Aaci7pHrHXyPd1WOgLxO9FldsEgOzrKPXC96IWGWUxiA2AktR7DaWbPZjv?= =?us-ascii?Q?pmxcZLi2tZQ/5wAr2Kwn0ONeWcS8JSGjswhh1aaTPvMpUvbe+omdI+HX2qyS?= =?us-ascii?Q?uo4f1B+zGXTs9tpK5vd6uTsECW8MRE/to0Ixtn+I7MeX/zpwM1FU+7dmF1DJ?= =?us-ascii?Q?KsAliME5NOUy+ZQ+L/agf4qGD142T5yR5iaiiISRGd0wErAFHjtsdVx6umFC?= =?us-ascii?Q?RHo4NjfFFclErVe07k8KXZeWyUJ703j8btkNgnCAXXCILt1CHxSwjRbldppS?= =?us-ascii?Q?Hn7PmLNlTZUBGTkOCUSH4i6T+1/wOcKZe/RNMYe4KHepqpbyR2gwmIXz4rbR?= =?us-ascii?Q?BxTUz7tQVv9gEMSXkTFJTUhmYZdGVJ2YuJRxnSiHyEVuclHB/SdemvrBpp4p?= =?us-ascii?Q?BQxFvPnnSNzXZpHU+zjDBxsfuFOS3PZRUbTtbqioS+doq3dysTwPagyfgo+F?= =?us-ascii?Q?tsl/8ZMOVpfqnwXSH4ohg/EQ6OV5yYpEEvspvRwYP6nQVTsGdKVoZYLmIo4V?= =?us-ascii?Q?goaYr80By1GqFasUZK0c9/kBp63HDY7F2CO09hNVnlaLzE0jnC4nQi+tooAk?= =?us-ascii?Q?dNIb7/8u56s0mGUsDTTR/ojnUKaEFCGttDf0Qmns+ntvrxIq1xnoKfciUuQo?= =?us-ascii?Q?GY4XC4SjYbB4yYtVauNV5Git0xouN0lNXtqHe+aUJW7VKMx41Az32VMsOGsM?= =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YnB5ZPRZDqlw7NcalYVHwCBwWn0UMJGl+A1/fCZjNw3DzFNmzN9DxrhOumdPipBiQ9TwshrXJHn4ccRr6SK/zCB7giVoqeBl0Wag++y16gcC0YNZpw==; 24:0Q1z493KqErGkwYxD/5myiZn0kB8ExXEYs8UIcs/KaNcsIqB+afvfZ+Hqohepdp72V5HYMgHLTOm7CxE4ebcMvSbY3WcR0C3pwsoBWqL/Tk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1238; 7:ZM+ExVcKUVHiuebHYXXa6WvfmK+TZ4W4pFKxR/JeOG90zD85jHysH1zgBWLIz2wVIThTztScVWwOL2SOq5V3qMmEFgQYhX0gWhX25mYRz7f4oAbe3Vqkz+i2Hlcdna4U+6VKG7/j9MfZaVIdesbc2c7lkDdPcJDg2Njx9/21ccSX6w02FEb/OKv5Ut2EeJ6Ptukgzr45QvSMZCVPwvczx6/0xhR3Ty9BEAAThiAalQ9Zop/srwvqirhMVALzBmhaH7pIAFhc01qjoFuz5Uo9uE0yGGWlxBIlfbt50BRNe6OnQ8u9G0Yi9LwpbzS49A7mIEDzkSgjWBfzEGnjMa9kCg==; 20:yJdDrivOLcG8vnJ7fL+nL2zahoJAsjRtqjwBeh7EERSFFIVFvr5W4l9TOhHURkXFWmro7z1bTtxAKnouP2UOiu3f4+1O7qLNOo4oDnX+UhUmol0QXaLf/wpXUUmx4rOmM4qDxJc7+8z1tsYDFwWcQcRs7C3Snfr6hXq2M4b+9LEIkrY5COjRaA5w8gTPVHWk0zJbYTmifa4A/zBbKRgcUYcMiw0w/GfI8ERN2/DFNSthcR/lYoLKsV1XZUuvl1kU X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2017 17:43:20.3382 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1238 Subject: [PATCH v4 4/6] UefiCpuPkg/Universal/Acpi/S3Resume2Pei: 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. The mask is applied when page tables are created (S3Resume.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 Reviewed-by: Star Zeng --- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 17 +++++++++++++---- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 2 ++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c index d306fba..a9d1042 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c @@ -5,6 +5,7 @@ control is passed to OS waking up handler. 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 @@ -58,6 +59,8 @@ #define STACK_ALIGN_DOWN(Ptr) \ ((UINTN)(Ptr) & ~(UINTN)(CPU_STACK_ALIGNMENT - 1)) +#define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull + #pragma pack(1) typedef union { struct { @@ -614,6 +617,12 @@ RestoreS3PageTables ( VOID *Hob; BOOLEAN Page1GSupport; PAGE_TABLE_1G_ENTRY *PageDirectory1GEntry; + UINT64 AddressEncMask; + + // + // Make sure AddressEncMask is contained to smallest supported address field + // + AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64; // // NOTE: We have to ASSUME the page table generation format, because we do not know whole page table information. @@ -696,7 +705,7 @@ RestoreS3PageTables ( // // Make a PML4 Entry // - PageMapLevel4Entry->Uint64 = (UINT64)(UINTN)PageDirectoryPointerEntry; + PageMapLevel4Entry->Uint64 = (UINT64)(UINTN)PageDirectoryPointerEntry | AddressEncMask; PageMapLevel4Entry->Bits.ReadWrite = 1; PageMapLevel4Entry->Bits.Present = 1; @@ -707,7 +716,7 @@ RestoreS3PageTables ( // // Fill in the Page Directory entries // - PageDirectory1GEntry->Uint64 = (UINT64)PageAddress; + PageDirectory1GEntry->Uint64 = (UINT64)PageAddress | AddressEncMask; PageDirectory1GEntry->Bits.ReadWrite = 1; PageDirectory1GEntry->Bits.Present = 1; PageDirectory1GEntry->Bits.MustBe1 = 1; @@ -724,7 +733,7 @@ RestoreS3PageTables ( // // Fill in a Page Directory Pointer Entries // - PageDirectoryPointerEntry->Uint64 = (UINT64)(UINTN)PageDirectoryEntry; + PageDirectoryPointerEntry->Uint64 = (UINT64)(UINTN)PageDirectoryEntry | AddressEncMask; PageDirectoryPointerEntry->Bits.ReadWrite = 1; PageDirectoryPointerEntry->Bits.Present = 1; @@ -732,7 +741,7 @@ RestoreS3PageTables ( // // Fill in the Page Directory entries // - PageDirectoryEntry->Uint64 = (UINT64)PageAddress; + PageDirectoryEntry->Uint64 = (UINT64)PageAddress | AddressEncMask; PageDirectoryEntry->Bits.ReadWrite = 1; PageDirectoryEntry->Bits.Present = 1; PageDirectoryEntry->Bits.MustBe1 = 1; diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf index 73aeca3..d514523 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf @@ -6,6 +6,7 @@ # control is passed to OS waking up handler. # # Copyright (c) 2010 - 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 @@ -91,6 +92,7 @@ [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES [Depex] TRUE -- 2.7.4