From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.80]) by mx.groups.io with SMTP id smtpd.web09.6831.1617883158111209255 for ; Thu, 08 Apr 2021 04:59:18 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=tSf17okQ; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.223.80, mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h55V0ifNgDYCweszpPxNrQidoSlZkd/07gHU0UgO6/FUix+cp7bR1144LddXvLfOKVCfCiGK0hm5xDtmQQSX+0GsQo2Vq8/yC2AXzmLafSn/IP/3bSJq15cUouEWkzDb5Mkmn1ZCEh/KxNVXB3wN5XvUb+M22ypinZRCxDa8SNwG+qrSOtCOvTYDuoE7+mINhZxDY20dv9HOzzNmuF/u2qicxXdj94CueATHFVTsWi8jaaMRjls1IQGREPwueTaFe8zEu4h+i3n7VUl38p0HakaiBzWFkZUR2Wlhv33Td4JVwUmYtcNnwQov+Z+8VFtr7UIR2GXbUZinTmwx1CWdOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kg3XMJKpPQD/Xa2GjWizbq+iG025nxZIFz8uJnF9J3k=; b=kuNqMW+Kj2iEILtAZ1z+djUOfos0TzetCcN66E7I5/ZlWGWlUiTasOgnwcfR5lTFKYocSyW4vkx6azuFNVNNRuMRmJEmfDgpVN04Xe+pGgHu++Q/4BgacuNL58nMYkh3ofdu2KY89x4SoSbVrK3i6axEHP9ZZGhuQh6OWZMpjF0xWEHySayBwpTR+SgJrZpD8ovfqjmuDkgN6xMkKHCQ9X/PbZ0CxdtleLasMibJct9xBzgB4jzOQPViCP884nTfVsCc492QYT8bmAUpIzp9pf/lO7ig5m/CcJq/gAjZVC9raEGeE6kGY+kAepS29FR/idY7PzN6JTJwtXMANtMetw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kg3XMJKpPQD/Xa2GjWizbq+iG025nxZIFz8uJnF9J3k=; b=tSf17okQnbC0DFBlaSKOUH8Yw7Mfb0E4d2Jk7CsP+O96pNLBTWKCJTTI6o7sVNeBk5tYOeWcvvLiX82uVMeFFkpFVOfs8J8UNxozJYz8D9gPqjF/PLsrTAEf3BK0xpGQGE0OYmrfNK6hrN0fho5HbZoMwylumvCDNse8QkONLKo= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SN6PR12MB2638.namprd12.prod.outlook.com (2603:10b6:805:6f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.32; Thu, 8 Apr 2021 11:59:15 +0000 Received: from SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::9898:5b48:a062:db94]) by SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::9898:5b48:a062:db94%6]) with mapi id 15.20.4020.017; Thu, 8 Apr 2021 11:59:15 +0000 CC: brijesh.singh@amd.com, devel@edk2.groups.io, James Bottomley , Min Xu , Jiewen Yao , Tom Lendacky , Jordan Justen , Ard Biesheuvel Subject: Re: [edk2-devel] [RFC PATCH 00/19] Add AMD Secure Nested Paging (SEV-SNP) support To: Laszlo Ersek References: <20210324153215.17971-1-brijesh.singh@amd.com> <34a50603-32b9-1476-04a5-8476dd810fe4@redhat.com> From: "Brijesh Singh" Message-ID: <213ce382-0b04-16f4-dd77-f9bb2cc32698@amd.com> Date: Thu, 8 Apr 2021 06:59:12 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 In-Reply-To: <34a50603-32b9-1476-04a5-8476dd810fe4@redhat.com> X-Originating-IP: [70.112.153.56] X-ClientProxiedBy: SN6PR08CA0025.namprd08.prod.outlook.com (2603:10b6:805:66::38) To SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) Return-Path: brijesh.singh@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from Brijeshs-MacBook-Pro.local (70.112.153.56) by SN6PR08CA0025.namprd08.prod.outlook.com (2603:10b6:805:66::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Thu, 8 Apr 2021 11:59:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 44429812-eaca-4a99-07cc-08d8fa85bb61 X-MS-TrafficTypeDiagnostic: SN6PR12MB2638: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0m6bLDUVXtcSMuk0nmJoSmNkIJOyTUa6aEDz1fadV4i8nn1B78esZbz0d5vmMQTEo3rh7Sbvq3PbEzOOiaY9D431WhEBDKa6yliUlPSFkSGGkk9npU0uNp17S7zIGm0CaBew4zhpKkuMjOcRzx7aVW0lJS2vlfa9moHF02UNN5rJONMnsmJCjE2gFWgxiyh+tMgwkG9G/utiiwuZe3Wxi/281JbMB4edA+wx4FOGanAgL/P0zaO2XhyK9+PtggGypiMnKI1q28iCI7VwhW2L3ORbq9Rjgli+kPG1pFjUAy1khfv0bNI3rA1kvsQdD/whJ5zLYblB6YSmvgyyXPYnZo55Tv3dPi5i080nr2c/KVPEk8rUXt20UNwnJAoJz7HbMx5AEfR7IZjl8Y0LK2dZccvY332h1Ny5bdFuYgvEqwrlePtcmUJNHRfE5Wec0K6myWhz3II5WZSAR6c6/wDX0bTfi1ww8v1YNQvkLYe5XuS75otsfSqaBp1CLWYOOZhBco4JN7DaA9uVZG8ihcsEIYYGc05TFQdSSvW1Lanyzyw7S2LgVO1jqu5cuU8HnoDzITOs5TLck38UXm4qv8+VF21bjSOLyni3QX4l9HxYO7OO/ftdjVPd0FyzXOvflrgA7DXGv4VSPAXVo9P7+7B3fFIWXlPV90Z0Mc4FWJ1nNo9esycwfpsyfEqnq2DdNLFQR/4MIYroFQ88dqyt2JA+JDr89aeeveGqaUCjoViH12fC44A3mxqZmnHx5sKwW8VE3SC6wiXQv5gk/xhVxqGvdUw6+BP+RYotikyHkTzFyXvynwh7GQNGGdtcE/21zqWjhLB5Z7EdBboTM8E2I/CG8g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2718.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(346002)(396003)(136003)(376002)(366004)(45080400002)(6512007)(19627235002)(8676002)(8936002)(66476007)(38350700001)(6916009)(6486002)(2906002)(83380400001)(52116002)(478600001)(38100700001)(4326008)(2616005)(26005)(44832011)(66556008)(316002)(956004)(31696002)(66946007)(31686004)(53546011)(6506007)(16526019)(86362001)(5660300002)(54906003)(36756003)(30864003)(186003)(966005)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?thPFixjrVuUvyNvdc7dEfb52W+On+ZT3NahZeQaJQW3oBA+QnMTAu3VE6Wjc?= =?us-ascii?Q?h6nPJ5TVyDpBhOv3Ge+solDZkaee5qTNId3LQyQxdZG5dYomFsj3T9mKX1BS?= =?us-ascii?Q?26ilD/Fcxle0xT41geRliVfJlvP/Otu7AnyYuDrsPC6W6Oe8iUiSHWERD0E3?= =?us-ascii?Q?RQCrR9u9fswezn1JoKZLhvcIMwVosIX8FdxzAmY3reAc4ifyp/M94j92tcXP?= =?us-ascii?Q?MJAzFUnFx70qQExodLDlQpg8CE4JXLhx8tezJhnvw7NkZaNOiEHI4Gi7Kniy?= =?us-ascii?Q?OOGOeMUaBL6P+VafL/Aos8BKOhjykY7aGRuS0W0vPkos3Rf9yf4Y/vSRPXCg?= =?us-ascii?Q?e8BUl65Ku1wZ6P28/CcgDuqD5dymzISfLkHZJZ4lmBqbJjIB3SrbGw7ySWYX?= =?us-ascii?Q?XuRMQSaP+usBtgCFrEL0CujDbhmbLkjGOXJ9JkVALksrqE5ZYMwrIRHfeOh+?= =?us-ascii?Q?YitBfhnaVaoWXsiveSXIhohHiI+FTEmVXUZ7Yyi0MTYXL3riwlb+pOMyqmvb?= =?us-ascii?Q?IEtLo/V5kHa8oClekDKcIZ/7fpkYAJIhZSSBNWurCAa0WHr4m+dQiJt+Y4Ix?= =?us-ascii?Q?5v5Rlt8k47lntQ737xRnNhuR6kdiiT5xOeGyWXcmB7J19RyU2AdRUhKMdzEf?= =?us-ascii?Q?Vm+jdOPeRW2IOHDBo+pH/TG2uXN9zjPw3xLDb/SsaSIUeK86Xo3fviVgnAld?= =?us-ascii?Q?b13/cOKKTmvXrVbC0aRF9WhM7coZRu1h+JLWp2gMiC0DIVZPduVAOmQmhLOR?= =?us-ascii?Q?5X8TpH1P1+GAXRr5mk3wsxT4NUy1Wqb5Sze1cD8uwDpj5m9rNrJKKDEA+Rfc?= =?us-ascii?Q?JHgU2wfGRcno6/H81mJ9vbGUdI5uaLb75gE5fS7r5Jd704gAckOhS6pSJ4gn?= =?us-ascii?Q?7GhD+03uiFo2r75QKzzFt0s5CVzEgn8NZLhVtoB0RdNSi1JGT4Ke70kr2Q6f?= =?us-ascii?Q?oPIkHCvoqRnpium9nzLQ/arPZpdKSxdXBoBKnzpFRly+1EYdXBwVQ+Y9PkCT?= =?us-ascii?Q?OQ6bZC3xjkdUV2eYr97To6ASbTN5+QkKwnLi/pVbsOAO3HCWBYpwEYbqNvdO?= =?us-ascii?Q?W99qq9NXrsGDZgzvni5hn1xJXAlick17PaCO8Fi4YhlEIsfVfwOvbZTYHJj4?= =?us-ascii?Q?tuAbJBsQpMKWEc9PmiWvKah9HikYhkbMkIXN57QUXIMi/bcLXy28DZv6/XSs?= =?us-ascii?Q?rtsJWeXeMhrTsAhmZdb8E8NngnoyFElcKkGfOAwqBTJ6KWbHzl4fLC1c5mBF?= =?us-ascii?Q?y7qNKeZA7NXW6zWTsUquiYc8NfgnnGx6ewRNe6mxZJtlWMsVEy4OIUok6KJB?= =?us-ascii?Q?dBzmt3QrKZP5Uro9hxu+i5dh?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44429812-eaca-4a99-07cc-08d8fa85bb61 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2021 11:59:15.6676 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EJVa58sLlm/61pSjzSvIKhbsXEYnI9yDBrlZuwg/V5KQ2oINBR8WOP7YvAv/ht6dFDMUJV8woNbt2LN/Q4qk5g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2638 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-US Hi Laszlo, On 4/8/21 4:58 AM, Laszlo Ersek wrote: > Hi Brijesh, > > On 03/24/21 16:31, Brijesh Singh wrote: >> BZ: https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2F= bugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D3275&data=3D04%7C01%7Cbrij= esh.singh%40amd.com%7Cb8ee3abf81aa4e5b1e6008d8fa74dbbc%7C3dd8961fe4884e608e= 11a82d994e183d%7C0%7C0%7C637534728122143364%7CUnknown%7CTWFpbGZsb3d8eyJWIjo= iMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdat= a=3DG2AQ%2FCks3%2BbczHJXMwqlqpWpoBJmb0pmxb1VNLw6t%2BA%3D&reserved=3D0 >> >> SEV-SNP builds upon existing SEV and SEV-ES functionality while adding >> new hardware-based memory protections. SEV-SNP adds strong memory integr= ity >> protection to help prevent malicious hypervisor-based attacks like data >> replay, memory re-mapping and more in order to create an isolated memory >> encryption environment. >> =20 >> This series provides the basic building blocks to support booting the SE= V-SNP >> VMs, it does not cover all the security enhancement introduced by the SE= V-SNP >> such as interrupt protection. >> >> Many of the integrity guarantees of SEV-SNP are enforced through a new >> structure called the Reverse Map Table (RMP). Adding a new page to SEV-S= NP >> VM requires a 2-step process. First, the hypervisor assigns a page to th= e >> guest using the new RMPUPDATE instruction. This transitions the page to >> guest-invalid. Second, the guest validates the page using the new PVALID= ATE >> instruction. The SEV-SNP VMs can use the new "Page State Change Request = NAE" >> defined in the GHCB specification to ask hypervisor to add or remove pag= e >> from the RMP table. >> =20 >> Each page assigned to the SEV-SNP VM can either be validated or unvalida= ted, >> as indicated by the Validated flag in the page's RMP entry. There are tw= o >> approaches that can be taken for the page validation: Pre-validation and >> Lazy Validation. >> =20 >> Under pre-validation, the pages are validated prior to first use. And un= der >> lazy validation, pages are validated when first accessed. An access to a >> unvalidated page results in a #VC exception, at which time the exception >> handler may validate the page. Lazy validation requires careful tracking= of >> the validated pages to avoid validating the same GPA more than once. The >> recently introduced "Unaccepted" memory type can be used to communicate = the >> unvalidated memory ranges to the Guest OS. >> >> At this time we only support the pre-validation. OVMF detects all the av= ailable >> system RAM in the PEI phase. When SEV-SNP is enabled, the memory is vali= dated >> before it is made available to the EDK2 core. > Can you describe this in a bit more detail, before I look at the > individual patches? Specifically, what existing logic in the PEI phase > was taken, and extended, and how? One of the key requirement is that the guest private pages much be validated before the access. If guest tries to access the pages before the validation then it will result in #VC (page-not-validated) exception. To avoid the #VC, we propose the validating the memory before the access. We will incrementally add the support to lazy validate (i.e validate on access). Let me try explaining a bit, the page validation process consist of two steps: 1. Add the pages in the RMP table -- must be done by the hypervisor using the RMPUPDATE instruction. The guest can use VMGEXIT NAEs to ask hypervisor to add or remove pages from the RMP table. 2. Guest issue the PVALIDATE instruction -- this sets the validate bit in the RMP table. Similar to SEV, the OVMF_CODE.fd is encrypted through the SNP firmware before the launch. The SNP firmware also validates the memory page after encrypting. This allows us to boot the initial entry code without guest going through the validation process. The OVMF reset vector uses few data pages (e.g page table, early Sec stack). Access to these data pages will result in #VC. There are two approaches we can take to validate these data pages: 1. Ask SNP firmware to pre-validate it -- SNP firmware provides an special command that can be used to pre-validate the pages without affecting the measurement. 2. Enhance the reset vector code to validate the pages. For now I choose #1. The pre-validation performed by the SNP firmware is sufficient to boot through the SEC phase. The SEC phase later decompress the Fv to a new memory location. Now we need the OVMF to take over the validation procedure.=C2=A0 The series extends the MemEncryptSevLib to add a new helpe= r MemEncryptSevSnpValidateRam(). The helper is used to validate the system RAM. See patch #12. SEC phase calls the MemEncryptSevSnpValidateRam() to validate the output buffer used for the decompression. This was sufficient to boot into the PEI phase, see patch #13. The PEI detects all the available system RAM. After the memory detection is completed the PlatformPei calls the AmdSevSnpInitialize(). The initialization routine iterate through the HOB and calls the MemEncryptSevSnpValidateRam() to validate all the system RAM. Is it possible the more system ram can be detected after the PlatformPei is completed ? One of the important thing is we should *never* validate the pages twice. The MemEncryptSevSnpValidateRam() uses a interval search tree to keep the record of what has been validated. Before validating the range, it lookup in its tree and if it finds that range is already validated then do nothing. If it detects an overlap then it will validate only non overlapping regions -- see patch #14. The patch #18 extend the MemEncrypt{Set,Clear}PageEncMask() to call the SNP page state change during the C-bit toggle. Please let me know if you have any questions. We can hash out the design here before you taking a closure look at the code. > > If there is a particular patch whose commit message is closely related > to my question, can you point it out? Patch#15 perhaps? (Doesn't seem > like a big patch; for some reason I'd expect something more complex, but > perhaps that's only because it builds upon the many earlier patches.) > > Thanks, > Laszlo > >> This series does not implements the following SEV-SNP features yet: >> >> * CPUID filtering >> * AP bring up using the new SEV-SNP NAE >> * Lazy validation >> * Interrupt security >> >> The series is based on commit: >> e542e05d4f UefiCpuPkg/SmmCpuFeaturesLib: Abstract PcdCpuMaxLogicalProces= sorNumber >> >> Additional resources >> --------------------- >> SEV-SNP whitepaper >> https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fwww.= amd.com%2Fsystem%2Ffiles%2FTechDocs%2FSEV-SNP-strengthening-vm-isolation-wi= th-integrity-protection-and-more.pdf&data=3D04%7C01%7Cbrijesh.singh%40a= md.com%7Cb8ee3abf81aa4e5b1e6008d8fa74dbbc%7C3dd8961fe4884e608e11a82d994e183= d%7C0%7C0%7C637534728122143364%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAi= LCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=3DuUqlVHhWQ= 6geGDaNHwxGMpoSpIamB%2F1vHH69h%2FEGUro%3D&reserved=3D0 >> =20 >> APM 2: https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F= %2Fwww.amd.com%2Fsystem%2Ffiles%2FTechDocs%2F24593.pdf&data=3D04%7C01%7= Cbrijesh.singh%40amd.com%7Cb8ee3abf81aa4e5b1e6008d8fa74dbbc%7C3dd8961fe4884= e608e11a82d994e183d%7C0%7C0%7C637534728122143364%7CUnknown%7CTWFpbGZsb3d8ey= JWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&= ;sdata=3DR2kU42jvCDZat8kGZ5gDDz2nFXIawHfXdRW1aovhNK8%3D&reserved=3D0 (s= ection 15.36) >> >> The complete source is available at >> https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fgith= ub.com%2FAMDESE%2Fovmf%2Ftree%2Fsev-snp-rfc-1&data=3D04%7C01%7Cbrijesh.= singh%40amd.com%7Cb8ee3abf81aa4e5b1e6008d8fa74dbbc%7C3dd8961fe4884e608e11a8= 2d994e183d%7C0%7C0%7C637534728122143364%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4= wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=3D= yreFg2hr%2F82WYEjxqCmb7pXUdtrRCJRYPrPHgfrWjM8%3D&reserved=3D0 >> >> GHCB spec v2: >> The draft specification is posted on AMD-SEV-SNP mailing list: >> https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fl= ists.suse.com%2Fmailman%2Fprivate%2Famd-sev-snp%2F&data=3D04%7C01%7Cbri= jesh.singh%40amd.com%7Cb8ee3abf81aa4e5b1e6008d8fa74dbbc%7C3dd8961fe4884e608= e11a82d994e183d%7C0%7C0%7C637534728122143364%7CUnknown%7CTWFpbGZsb3d8eyJWIj= oiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sda= ta=3DPFV2mA7T%2Fbl2zP5j52kNdT%2FavDMRLWDEDqz6JGusEFg%3D&reserved=3D0 >> >> Copy of the spec is also available at=20 >> https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fgi= thub.com%2FAMDESE%2FAMDSEV%2Fblob%2Fsev-snp-devel%2Fdocs%2F56421-Guest_Hype= rvisor_Communication_Block_Standardization.pdf&data=3D04%7C01%7Cbrijesh= .singh%40amd.com%7Cb8ee3abf81aa4e5b1e6008d8fa74dbbc%7C3dd8961fe4884e608e11a= 82d994e183d%7C0%7C0%7C637534728122143364%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC= 4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata= =3DU3oKRe5m0NxI0xqv1gBoyh%2BEEX1LVeCWR42rvPh6XZ8%3D&reserved=3D0 >> >> GHCB spec v1: >> SEV-SNP firmware specification: >> https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fdev= eloper.amd.com%2Fsev%2F&data=3D04%7C01%7Cbrijesh.singh%40amd.com%7Cb8ee= 3abf81aa4e5b1e6008d8fa74dbbc%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C6= 37534728122143364%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luM= zIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=3DG%2BttkORsTJchJ1Fy1iNl= D%2B%2BqiQZuwI8md5vhJjEb%2Fn4%3D&reserved=3D0 >> =20 >> Cc: James Bottomley >> Cc: Min Xu >> Cc: Jiewen Yao >> Cc: Tom Lendacky >> Cc: Jordan Justen >> Cc: Ard Biesheuvel >> Cc: Laszlo Ersek >> >> Brijesh Singh (19): >> OvmfPkg: Reserve the Secrets and Cpuid page for the SEV-SNP guest >> OvmfPkg: validate the data pages used in the SEC phase >> MdePkg: Expand the SEV MSR to include the SNP definition >> OvmfPkg/MemEncryptSevLib: add MemEncryptSevSnpEnabled() >> MdePkg: Define the GHCB GPA structure >> UefiCpuPkg/MpLib: add support to register GHCB GPA when SEV-SNP is >> enabled >> OvmfPkg: Add a library to support registering GHCB GPA >> OvmfPkg: register GHCB gpa for the SEV-SNP guest >> MdePkg: Add AsmPvalidate() support >> OvmfPkg: Define the Page State Change VMGEXIT structures >> OvmfPkg/ResetVector: Invalidate the GHCB page >> OvmfPkg/MemEncryptSevLib: Add support to validate system RAM >> OvmfPkg/SecMain: Validate the data/code pages used for the PEI phase >> OvmfPkg/MemEncryptSevLib: Add support to validate RAM in PEI phase >> OvmfPkg/PlatformPei: Validate the system RAM when SNP is active >> OvmfPkg/MemEncryptSevLib: Add support to validate > 4GB memory in PEI >> phase >> OvmfPkg/VmgExitLib: Allow PMBASE register access in Dxe phase >> OvmfPkg/MemEncryptSevLib: Validate the memory during set or clear enc >> attribute >> OvmfPkg/MemEncryptSevLib: Skip page state change for non RAM region >> >> MdePkg/Include/Library/BaseLib.h | 37 +++ >> MdePkg/Include/Register/Amd/Fam17Msr.h | 31 ++- >> MdePkg/Include/Register/Amd/Ghcb.h | 39 ++- >> MdePkg/Library/BaseLib/BaseLib.inf | 1 + >> MdePkg/Library/BaseLib/X64/Pvalidate.nasm | 43 +++ >> OvmfPkg/Include/Library/GhcbRegisterLib.h | 27 ++ >> OvmfPkg/Include/Library/MemEncryptSevLib.h | 30 +++ >> .../DxeMemEncryptSevLib.inf | 7 + >> .../DxeMemEncryptSevLibInternal.c | 27 ++ >> .../Ia32/SnpPageStateChange.c | 17 ++ >> .../PeiMemEncryptSevLib.inf | 9 + >> .../PeiMemEncryptSevLibInternal.c | 47 ++++ >> .../SecMemEncryptSevLib.inf | 4 + >> .../SecMemEncryptSevLibInternal.c | 39 +++ >> .../BaseMemEncryptSevLib/SnpPageStateChange.h | 37 +++ >> .../X64/PeiDxeSnpSetPageState.c | 63 +++++ >> .../X64/PeiDxeVirtualMemory.c | 151 ++++++++++- >> .../X64/PeiSnpSystemRamValidate.c | 129 +++++++++ >> .../X64/SecSnpSystemRamValidate.c | 23 ++ >> .../X64/SnpPageStateChangeInternal.c | 254 ++++++++++++++++++ >> .../X64/SnpPageStateTrack.c | 119 ++++++++ >> .../X64/SnpPageStateTrack.h | 36 +++ >> .../X64/SnpSetPageState.h | 27 ++ >> .../BaseMemEncryptSevLib/X64/VirtualMemory.h | 19 ++ >> .../Library/GhcbRegisterLib/GhcbRegisterLib.c | 97 +++++++ >> .../GhcbRegisterLib/GhcbRegisterLib.inf | 33 +++ >> OvmfPkg/Library/VmgExitLib/SecVmgExitLib.inf | 4 + >> OvmfPkg/Library/VmgExitLib/VmgExitLib.inf | 7 + >> OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c | 45 ++++ >> OvmfPkg/OvmfPkg.dec | 12 + >> OvmfPkg/OvmfPkgX64.dsc | 1 + >> OvmfPkg/OvmfPkgX64.fdf | 33 ++- >> OvmfPkg/PlatformPei/AmdSev.c | 52 ++++ >> OvmfPkg/PlatformPei/PlatformPei.inf | 2 + >> OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm | 24 ++ >> OvmfPkg/ResetVector/Ia32/PageTables64.asm | 106 ++++++++ >> OvmfPkg/ResetVector/ResetVector.inf | 5 + >> OvmfPkg/ResetVector/ResetVector.nasmb | 4 + >> OvmfPkg/Sec/SecMain.c | 102 +++++++ >> OvmfPkg/Sec/SecMain.inf | 2 + >> UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf | 1 + >> UefiCpuPkg/Library/MpInitLib/MpEqu.inc | 1 + >> UefiCpuPkg/Library/MpInitLib/MpLib.c | 2 + >> UefiCpuPkg/Library/MpInitLib/MpLib.h | 2 + >> UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf | 1 + >> UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 51 ++++ >> UefiCpuPkg/UefiCpuPkg.dec | 6 + >> 47 files changed, 1790 insertions(+), 19 deletions(-) >> create mode 100644 MdePkg/Library/BaseLib/X64/Pvalidate.nasm >> create mode 100644 OvmfPkg/Include/Library/GhcbRegisterLib.h >> create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/SnpPageSta= teChange.c >> create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/SnpPageStateCha= nge.h >> create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeSnpSe= tPageState.c >> create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiSnpSyste= mRamValidate.c >> create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecSnpSyste= mRamValidate.c >> create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStat= eChangeInternal.c >> create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStat= eTrack.c >> create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStat= eTrack.h >> create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpSetPageS= tate.h >> create mode 100644 OvmfPkg/Library/GhcbRegisterLib/GhcbRegisterLib.c >> create mode 100644 OvmfPkg/Library/GhcbRegisterLib/GhcbRegisterLib.inf >>