From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.76]) by mx.groups.io with SMTP id smtpd.web10.6601.1628002881634597472 for ; Tue, 03 Aug 2021 08:01:21 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=kvyb+R00; 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.94.76, mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R5Ng2pQCXitymjkJoJ+noTfKTsH3mx8cWSJNu2kI8hEcPrQ2fgt8U9snZ4/5K3omgooUrZI2O/8W5XBinCUGAHsEEDwgnZM3s17OT5H0wfQEpxv9vjF2PDgyJtu9WpLeaFIDP32dPzQ2dhWlRrnyaamL4tQWkPdTnsIrJ4JCmPVJ5QHIbXEnlWltHT4nIxD8Z9Iv3OkACt4oXdXbe7f5FRAxejm6E9PNaeuc3rtuwMmUBVrTNd9j8IO3IiUS/t8aa0Bb4zdPeY3Brf3VT2RgFM+LGPQAqq3bQwl/gFPbpoHypB9vAmGS3EHNLjSIEfbluGfuD2MJJ+ZV4k7Z46qifQ== 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=g0FImpiMZhznKH7k5x/dj+h5aI0yL+1WV7vSaalvUrU=; b=MKy0PX8FeMyKd1J+oIWo/C1411hC/WTknnKGw62Ik07CFGY1pn20cd0V0uwX7uhLV4cpW04vwO6ngISiYUZjvV+Cdw115DuwscmrSKgsnts1nEWI/hXiDLcMiL0gaUYVrQFFNt4sxvrYMooO5jSqJLD11eYu2q988Sf5kNPLaQd6PZ1tQNbbhs6WWuMv2J50k+7Wg2MrSdYnlgjxaDd66HXoECUCeC2r6ZnNMcQMNZd+GboA7Ov3WVQJZJPvr628EOznA8I5aFCAIxoN20+OAEczA/2ODMETgK6qt8qW5byQ9Uf8xl7sMQYmgbir4A4Urf2HghSZB+HqDg8OWaohuQ== 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=g0FImpiMZhznKH7k5x/dj+h5aI0yL+1WV7vSaalvUrU=; b=kvyb+R000ERruGqdSrUI0FWYiuaMDxlmYmqbNFK1hv8Vs05SrgGbn/e0sp2oJj6lB3SBjejd+4Uz2NC6a9XLWF8UEUTG6st5Izoj7qQ7daUIqy2DiywTb/rJ0d//QmKEdk8inXo7let2/lFQHNb4LyH85IkXJf522J0u1At69ag= Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SN6PR12MB2640.namprd12.prod.outlook.com (2603:10b6:805:6c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Tue, 3 Aug 2021 15:01:19 +0000 Received: from SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::a8a9:2aac:4fd1:88fa]) by SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::a8a9:2aac:4fd1:88fa%3]) with mapi id 15.20.4373.026; Tue, 3 Aug 2021 15:01:19 +0000 Cc: brijesh.singh@amd.com, James Bottomley , "Xu, Min M" , Tom Lendacky , "Justen, Jordan L" , Ard Biesheuvel , Laszlo Ersek , Erdem Aktas , "Dong, Eric" , "Ni, Ray" , "Kumar, Rahul1" , "Kinney, Michael D" , Liming Gao , "Liu, Zhiguang" , Michael Roth Subject: Re: [edk2-devel] [RFC PATCH v4 00/27] Add AMD Secure Nested Paging (SEV-SNP) support To: "Yao, Jiewen" , "devel@edk2.groups.io" References: <20210628174223.1302-1-brijesh.singh@amd.com> <39b6b63f-4632-d654-a29a-80fc8a75e311@amd.com> From: "Brijesh Singh" Message-ID: <3ea6b4f8-80e2-2f70-2880-d0666246db4b@amd.com> Date: Tue, 3 Aug 2021 10:01:16 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 In-Reply-To: X-ClientProxiedBy: SN7PR04CA0233.namprd04.prod.outlook.com (2603:10b6:806:127::28) 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 [10.236.31.95] (165.204.77.1) by SN7PR04CA0233.namprd04.prod.outlook.com (2603:10b6:806:127::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.20 via Frontend Transport; Tue, 3 Aug 2021 15:01:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fcc312aa-28ea-4144-ba32-08d9568f8ce7 X-MS-TrafficTypeDiagnostic: SN6PR12MB2640: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pJyRGt3yt/J3230+y31rq9yG9KCsHs+MGNdGPLOON51Ihbw8trt5o1H1LeO7LGqktF6INeJJs3sBQAyPir4KIRC2V6iADUmjEQSBxhLo5a1aKmFrWLqzdhDA7WgoXJFpuM4O+WQIKGtGJ0AIgc7hkz3W4AJ5Kp5pFwP1Qhvlb+aXdHE9w9K6XThntzRy8Kov6doqBirPaUsVfiKrBjXFYnLgQRUZW2WSk0qLbz0qAKpG8P2FIaLUi3cMmEeSb1A1BwUQ/19BG5YeZMT/XlnfkaSt0bgWkPU7YSVA+doegnWIFmXrMxVScp7Mcwm5jBoDVD/ND3GTB7eKJCFDBr2NzqYhwLh8swt2FG5zjB9fG/pqCyAGUzw+0FePV3uSbpuK5Mym0SwrftuSFn1mPwAZD/1po2J5/vSqqGFHLDVPc9Itvfo609BX1mtmF0Og3YrR/MrOPh4Cvw8NW0gHTm/4J+y5x3WS2UuAxk/5xSH1NklMRutu9m3gqYLzwbv24y3y9Yca9rIc/j2wGLq/fYXm1ZqrjxQ8qYs3MlylRJb0UaaKIh/OfyzzfUdlzPx0NcGPMw+D4Iw5q7eL62kAJWwkEzCtbqi4UokLfHDWdTkEJwjiEnpDL8GcqZNzj58aio4q2LWuD3DawyWoRzxYeukNHE2yfLj3PgEh5crQFyEF/OmgMsQ1Q5n8UcWs5XPd1uhQ5AXwUb/L4qpzXYeS84526R4UCYybucRCkxXT5z9srF8b6Ay8mhNsah24BXJFF4+i0mkuZsyu/9YYFRXh4EdbQmxwfExWaeP41grTQtXy2/in4IBF5KVPsBnme6dj1Mip5F0KAaHifYSdAUD5s+bQIczjtGnVhzNBNCdISiep9rE= 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)(346002)(376002)(136003)(366004)(396003)(39860400002)(956004)(83380400001)(31686004)(44832011)(2616005)(16576012)(54906003)(6486002)(110136005)(66476007)(66556008)(4326008)(36756003)(966005)(31696002)(66946007)(2906002)(86362001)(478600001)(316002)(5660300002)(8676002)(8936002)(19627235002)(186003)(52116002)(38100700002)(38350700002)(7416002)(53546011)(26005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData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Q?VChqNQhXgghMNdBSPyFvrTPpCy3hHFnHBZXEARf?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: fcc312aa-28ea-4144-ba32-08d9568f8ce7 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2021 15:01:19.6423 (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: iHnnwqu+i/jFTKEQ22hH8teYyEc/31IuGBtWKpPlsq2RX3OzqN501H6I6dm/pIdE6YpS/zlldDqlV4+rfRyQVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2640 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 7/28/21 9:22 PM, Yao, Jiewen wrote: > Hi Brijesh > Thanks for the patient. > Most of my comment focus on the *common* part, and *interface* between SEV and common code. > I will leave you to decide the detailed SEV specific implementation. > Thank you Jiewen for your feedback. I will try to address the comments in next version. > > Patch-04: > Can we use consistent naming conversion? > We have PcdOvmfSecGhcbPageTableBase, PcdOvmfSecGhcbBase, PcdSevLaunchSecretBase. Now we are adding PcdOvmfSnpSecretsBase. > Can we change PcdOvmfSnpSecretsBase to PcdSevSnpSecretsBase? > Or we change PcdSevLaunchSecretBase to PcdOvmfSevLaunchSecretBase? I don't know why we choose "Ovmf" from the LaunchSecretsBase PCD. I thought PCD's specific the Uefi typically contains the Ovmf name. Maybe we can fix the LaunchSecretsBase to match with the name. I will do that as a separate patch. > > Patch-05: > Ditto. Naming convention. > > Patch-06: > I have recommendation to Min, to separate SEV stuff to a standalone file from ResetVectorVtf0.asm. > Intel can add TDX stuff to a standalone file, and make it included by ResetVectorVtf0.asm. > > I am not sure if you want to do it, or you leave Min to do it. > For the SEV stuff, I will do it myself so that I can test it as well :) > Patch-07: > Same naming convention issue. See #04 and #05. > > Patch-08: > I hope we can move all below code to AmdSev.asm, such as PostPageTableHookSev(). > Then the PageTable64.asm can be SEV/TDX agnostic. > > I am not sure if you want to do it, or you leave Min to do it. > > ============== > ; > ; Clear the encryption bit from the GHCB entry > ; > mov ecx, (GHCB_BASE & 0x1F_FFFF) >> 12 > mov [ecx * 8 + GHCB_PT_ADDR + 4], strict dword 0 > > mov ecx, GHCB_SIZE / 4 > xor eax, eax > clearGhcbMemoryLoop: > mov dword[ecx * 4 + GHCB_BASE - 4], eax > loop clearGhcbMemoryLoop > > ; > ; The page table built above cleared the memory encryption mask from the > ; GHCB_BASE (aka made it shared). When SEV-SNP is enabled, to maintain > ; the security guarantees, the page state transition from private to > ; shared must go through the page invalidation steps. Invalidate the > ; memory range before loading the page table below. > ; > ; NOTE: the invalidation must happen after zeroing the GHCB memory. This > ; is because, in the 32-bit mode all the access are considered private. > ; The invalidation before the zero'ing will cause a #VC. > ; > OneTimeCall InvalidateGHCBPage > ============== > I will try to see if I can move that out as well. > Patch-10: > I am not UEFI CPU package maintainer. But I do have a little concern to add more PcdXxxIsEnable style PCD, especially when they are mutual exclusive (like TDX v.s SEV). > If we follow this pattern, we will have PcdSevEsIsEnabled, PcdSevSnpIsEnabled, PcdSevFutureIsEnabled, PcdTdxIsEnabled, PcdTdxFutureIsEnabled, ... that will be an endless list. > > If possible, I suggest define one PcdConfidentialComputingType - indicate Legacy, SEV, TDX. > There are certain things which are applicable to SEV-ES and not for the SEV-SNP and vice versa. I am not oppose to create a generic helper e.g enum { AmdSev, AmdSevEs, AmdSevSnp, IntelTdx, IntelSgx, .. .. }; bool EncryptedGuestFeatureEnabled(enum type); But I think some of this can be done later as well. > Patch-12: > Can we move all SEV stuff to a standalone file, such as AmdSev.c? > > I am not sure if you want to do it, or you leave Min to do it. > Yes, I can do it. > Patch-18: > If we have a standalone AmdSev.c (#12), then we can move the function to that file, and only leave a hook call to SEV. > I will try to consolidate it in AmdSev.c > Patch-23: > This is UEFI CPU package update. I am thinking if we can follow same patter to move all SEV stuff to a standalone file, such as AmdSev.c, AmdSev.asm. > In the future, we may add TDX stuff as well. > > Patch-26: > Same comment as #23. > > Patch-27: > Can we move that function to a standalone AmdSev.c ? > > Patch-28: > Would you please describe more on what is ConfidentialComputingBlob ? While launching the SEV-SNP guests, the hypervisor may need to provide some additional information during the guest boot. When booting under the EFI based BIOS, the EFI configuration table contains an entry for the confidential computing blob that contains the required information. The Linux kernel will lookup for this EFI table during the boot to locate the secrets and cpuid page. > Is that generic concept? Or SEV specific thing? Its designed as a generic and the current only SEV-SNP provides it. > Who is consumer? Any guest kernel (window or Linux) > What is difference between ConfidentialComputingSecret and ConfidentialComputingBlob ? When to use which? > The confidentialComputingSecrets contains the secrets keys where the CCBlob contains the information which maybe used during the boot. You can see some more about it on my kernel patches: https://lore.kernel.org/lkml/20210707181506.30489-26-brijesh.singh@amd.com/ > I can understand how TDX use ConfidentialComputingSecret, but how do you expect TDX use ConfidentialComputingBlob (if it is a generic concept) ? I think in the case of TDX , the information needed during the boot is provided through the ACPI tables but in SEV-SNP those are provided throught the CCBlob. In the contianer environement there will be no EFI so in that case the Blob will be passed to the boot loader setup data. If required then TDX can use it to pass the boot information. thanks