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.66]) by mx.groups.io with SMTP id smtpd.web11.7425.1628163082243688478 for ; Thu, 05 Aug 2021 04:31:22 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=B8ScMQjq; 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.66, mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k+BG64kSZxeL920ERLC4rXufCArWRglng8AZrzB51315tTkkQrHEAc7fkUfr1F+uc83werjdAPQweRK+I5LUIjsW/gQbI2gkr0peXhBtqpn1ac2EslzCsU1F1lSOAcARSSYAj8ZAns/yMfQ27u44Rk1WDkGSb0AIIXByYVZHOLZ+K47DX2kQc/KTFeSBoIeCN0DQSL5Q0Zhjhh+RlhTHUsOLIqx8yMtO6Je8rF5H2vejrI+XKaBYEoGYTmFui71ZoNI0vf45sRPFJlUWeFeA0gpIcRq2sAmF9xCQuY5TafA2grm+6xXwVia4QRVvOyTHVmZrnmxkSMJ1zLJm8MvG6Q== 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=MZ6+hkHvVU7gkr35SHZY//mLXpUTdNyH+2HlZ4cTuG8=; b=L6tZHSiP1pFJkxGzUXPajqPEN4d4OVfR1cCQsY+VAZ8/EaHWV+HRZaT2kYuzgCHkU33WS6ejcrRzGIjGK/rlSiGFj/FBP7DYmyW0MAq7RP6cemTOWOuIH4dCMQoEzk7cfa9tkDQl8FowGSuAK3i4hcOpyRzRAsZVsqkBy6kcdf6BAUqi3kAlruTENMeTtvcyJtph99LM+9wnxnPP8uVtaFATnm8EDClHfFKwSiAaxR/ai8j9kvHM4E523Tkg4YvGr30jpmwhS8LMofxwh3ql0BPAyH128gefpmbgltwdtxxqpKdB3Tb4PDgiHRQzxxkoGAQ+AyPaudhzjoltTfGp/A== 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=MZ6+hkHvVU7gkr35SHZY//mLXpUTdNyH+2HlZ4cTuG8=; b=B8ScMQjqWi6d9n3bt16HDoW3s8yKi4KuJYNXPyEIiWGefTRaNkF0gJxyPq1yjMu6l/f5aB5h4RsU6G4ph8MKmhfuqpwDHRKDtVnttyXZYNTye75JgS1cXNKXfETpNPlkDk+RIqFa9Z3zRbAynFDyKgRc+6wAXCggW7X0V97BJ1w= 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 SA0PR12MB4384.namprd12.prod.outlook.com (2603:10b6:806:9f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Thu, 5 Aug 2021 11:31:20 +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.4394.017; Thu, 5 Aug 2021 11:31:20 +0000 Subject: Re: [edk2-devel] [PATCH 0/3] reuse the SevEsWork area To: "Yao, Jiewen" , "devel@edk2.groups.io" Cc: James Bottomley , "Xu, Min M" , Tom Lendacky , "Justen, Jordan L" , Ard Biesheuvel , Erdem Aktas , Michael Roth References: <20210804202003.17543-1-brijesh.singh@amd.com> From: "Brijesh Singh" Message-ID: <252b556d-d7f9-27a3-1faa-5ff78ce1b9d9@amd.com> Date: Thu, 5 Aug 2021 06:31:14 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 In-Reply-To: X-ClientProxiedBy: SA0PR11CA0025.namprd11.prod.outlook.com (2603:10b6:806:d3::30) 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 SA0PR11CA0025.namprd11.prod.outlook.com (2603:10b6:806:d3::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15 via Frontend Transport; Thu, 5 Aug 2021 11:31:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f19ab046-261c-480b-4ae9-08d958048bd1 X-MS-TrafficTypeDiagnostic: SA0PR12MB4384: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Mm9njTxZnsHTEJT5jMqq3iq/zu3fPvnqxzEEfRVsN9ofQ09u+aLX2XlbY/1ejNATBRAn8F32nSzCA53TYOJaxFk3hLVfXOoRWdX9+WKoS1SvQCEseb/Xtop+A684qVImDf350bPrjEs7IR+D/PYEGTd3ib39kXgm+gog8eUufEExoiMS8I6xzEKe6lXb+kp3/Dz1PVfzJ1D2bnDlbkbweJEIJ8PqlzYWr0EjBCu0BWSWrBOxYT2+ng9lBvyikyRRaDiSX1ELTzUBn0yNKfrXclcJ7UMKKHRToK52TpT9WdHkJpi351v9QdZNhgHqIMfoVx5qfq76veKcyHHHiPsZblGIpO+HPLurErTfqlS8mj8PZYhiZGq/cgYwHBbuJEoQkxy0dURT3gTj9dM9MpcFm+FZi7zzWSE1j4928fOkMWlt5eNxOwEFMBZbZ2LGXBj6ouZobY8Y3e4Q/rLYPkC760audg2l7dhspuEs0L4PDNu7h43ZMjEhfHSHd+xVl7Vr3t8atpDr5au4h0ZPNLJQMDbUJWR32i+bIpGAJajFSXiFKrU5wVsFdl2R2oMdHbCyzdmY3BnSR94HyZvfL7luEukcgNS6BUvjav40aWSbltv4tWr+Os3wObpGZkoiJAWqrr/Qsyw5YcCkAqwfrV//WqECTFHch33Kk5IPuSFDHLbFAmE8/bYj+9dzR/23lSqnLytI8OEMIU4rhJ4oH7jYoS9G9X9GFoKR89O6XHsxjuHdrxWeS5KKFkX37JPr355fVw57escdP9V7aSemkK4FrTuBddCVplyGbEbHXYXcWle6Lr76XXzP/uahrCjG50rG5LtExGJzmiigy6z7yUMP806ptwL08mNcFCfOxFSRn20aLfz2a/RftCpa6ZB9kz6v 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:(6029001)(4636009)(346002)(376002)(39860400002)(366004)(136003)(396003)(6486002)(8676002)(6666004)(66946007)(66476007)(66556008)(19627235002)(2906002)(38350700002)(38100700002)(44832011)(956004)(966005)(8936002)(5660300002)(2616005)(26005)(86362001)(53546011)(6506007)(478600001)(45080400002)(52116002)(186003)(316002)(4326008)(31686004)(36756003)(6512007)(83380400001)(110136005)(54906003)(31696002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZUxIUXI1Z2ZkdzZYdWhhZGM2TkxjMUMwMnRuRkV0Y2tHVFdmNDNhY0NHe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4ae9-08d958048bd1 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2021 11:31:20.0117 (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: 2hklxMJnmgF+7FwkJyt7osnAdQ/H78BewENIIh9II5dwaoakKyktmmsXF1ktIiQ1Zd7DdAsroePvNbJGyfIl+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4384 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Hi Jiewen, Thanks for the quick feedback. I will make the recommended change and send the updated patch. I was under assumption that union will be done when Min adds the SGX support because that's when we start reusing the WorkArea for SEV and TDX. But I guess its good idea for me to do it now so that Min does not have to touch the SEV code in his series. thanks On 8/4/21 9:18 PM, Yao, Jiewen wrote: > HI Brijesh > Thanks for the startup. Feedback below: > > 1) I don't think we need a PCD to indicate the header. > gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaHeaderSize|4|UINT32|0x51 > > Instead, if we define a HEADER structure, we can use sizeof() naturally. Otherwise, when we update this header, we need update 2 different places, which is not preferred. > > typedef struct { > UINT8 GuestType; > UINT8 Reserved1[3]; > } CONFIDENTIAL_COMPUTING_WORK_AREA_HEADER; > > 2) I don't think we can define a common structure OVMF_WORK_AREA to contain SEV specific field. > > typedef struct _OVMF_WORK_AREA { > UINT8 GuestType; > UINT8 Reserved1[3]; > > SEC_SEV_ES_WORK_AREA SevEsWorkArea; > } OVMF_WORK_AREA; > > A common patter is to define each individual structure, then use UNION. > > For example, > > typedef struct { > UINT8 GuestType; > UINT8 Reserved1[3]; > > SEC_SEV_ES_WORK_AREA SevEsWorkArea; > } SEV_WORK_AREA; > > typedef union { > CONFIDENTIAL_COMPUTING_WORK_AREA_HEADER Header; > SEV_WORK_AREA Sev; > } OVMF_WORK_AREA; > > > >> -----Original Message----- >> From: devel@edk2.groups.io On Behalf Of Brijesh >> Singh via groups.io >> Sent: Thursday, August 5, 2021 4:20 AM >> To: devel@edk2.groups.io >> Cc: James Bottomley ; Xu, Min M ; >> Yao, Jiewen ; Tom Lendacky >> ; Justen, Jordan L ; >> Ard Biesheuvel ; Erdem Aktas >> ; Michael Roth ; Brijesh >> Singh >> Subject: [edk2-devel] [PATCH 0/3] reuse the SevEsWork area >> >> Based on the discussion on the mailing list, we agreed that instead >> of wasting extra page in the MEMFD, we can reuse the SevEsWorkArea >> buffer for the TDX. To avoid any confusion, lets introduce a OvmfWorkArea >> that will contains 32 bytes of header followed by the actual workarea. >> >> While at it, move the code to clear the GHCB page from PageTable build >> to AmdSev.asm. >> >> I have used the existing TDX BZ for it because the request came >> during the TDX patch review. if anyone have concern please let me know >> and I will happily create a new BZ. >> >> Full tree is at: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAMDESE%2Fovmf%2Ftree%2Fsev-new-work-area&data=04%7C01%7Cbrijesh.singh%40amd.com%7C4c55a642f1804a803c4e08d957b75e61%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637637267367225365%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=NSsUVfQodJMDUcpLCsHSpTaRDHM8et%2BWZJOS8lCS3Kw%3D&reserved=0 >> >> Brijesh Singh (3): >> OvmfPkg: introduce a common work area >> OvmfPkg/ResetVector: update SEV support to use new work area format >> OvmfPkg/ResetVector: move the GHCB page setup in AmdSev.asm >> >> Cc: James Bottomley >> Cc: Min Xu >> Cc: Jiewen Yao >> Cc: Tom Lendacky >> Cc: Jordan Justen >> Cc: Ard Biesheuvel >> Cc: Erdem Aktas >> >> OvmfPkg/OvmfPkg.dec | 6 ++ >> OvmfPkg/OvmfPkgX64.fdf | 9 +- >> OvmfPkg/PlatformPei/PlatformPei.inf | 4 +- >> OvmfPkg/ResetVector/ResetVector.inf | 1 + >> OvmfPkg/Sec/SecMain.inf | 1 + >> OvmfPkg/Include/Library/MemEncryptSevLib.h | 21 +--- >> OvmfPkg/Include/WorkArea.h | 53 ++++++++++ >> OvmfPkg/PlatformPei/MemDetect.c | 32 +++--- >> OvmfPkg/Sec/SecMain.c | 25 ++++- >> OvmfPkg/ResetVector/Ia32/AmdSev.asm | 111 +++++++++++++++++---- >> OvmfPkg/ResetVector/Ia32/PageTables64.asm | 57 ++--------- >> OvmfPkg/ResetVector/ResetVector.nasmb | 1 + >> 12 files changed, 213 insertions(+), 108 deletions(-) >> create mode 100644 OvmfPkg/Include/WorkArea.h >> >> -- >> 2.17.1 >> >> >> >> >>