From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.47]) by mx.groups.io with SMTP id smtpd.web12.2197.1576184600191301045 for ; Thu, 12 Dec 2019 13:03:20 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=bX2B0641; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.243.47, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gqcklLx436bVnbz0JXaqt3qG8UCtym7HqJL0VwdWVOk++iu3w5A2IZ3NVlZ+WRxTElJI1XeyvAhax7x3d2T90bFL2yCVZX88Dsvq2xWaw4hHzdFBm9l0qrpNkqiZdMaykhodz/7O3UYDhxSafJ0HCdEnDuXEWEw4E/RsjttMiXp4d/rbXQXqWWEBi/fm7euYN3/3zVD8y9+p6i+OWfUqxGjPzQo8BPnNsVASmhhVeUYXcLGSym/N5h2KxUWqGLvLr4Zok94fiMPIVqd+XFFSL6Hnyv0yGW1MoJbXMccWQUADAI/tsguTfa1hAu23bG5yuwzCgx2gsiQ6S4UocYYNDg== 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=SVZlWyZe+LSVtoiItI06r+zJfhR0HvgqIW2XBif/GLI=; b=g8KpHtifHOf/sRZzhF5++prSGkOJg9MjFdqXaiu+vRo21QiRH3FkWIhDB4uVucwXu8VxXj7/N1L9gPov6D8h++JjL0vKE8Aaz065mrUJfwGYfBmu/AtYjUPATCu7yNiOSGNyhEhz5FPdjzH2bzNRmubbkKQ7V+hnFc1I3abQaNyXTFLs2+N5sgX+hSshLPay3vA1oOr/3ERG0Jw+G14TS+1pQtZp/4NzFxS7GRhU31iDq+i07k9lrpB9GHJFOhDUcQ3NkuZFoXjPpUNLv14WYqzPIZa5cVtTo1B5loZ9fQ4FJYyFvJ+KIKe5jv32jXXXM7FUT13abFlqr01e9uNIyQ== 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=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SVZlWyZe+LSVtoiItI06r+zJfhR0HvgqIW2XBif/GLI=; b=bX2B0641zwThrWjKABejodNlo3RLA/wBvxRsSUunmd7Xv9J3uaGlmZiVnKWCkDMzzLgrMAANMc9Ou+5gczJrTAf0DNyy6qcRe6xvFKspuypmXnTg3YYt3PasNtWrds8V0DG4Kn3uMxTgEzQJ2h6E+HC4QnTlT/O3onElvyba89Y= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from DM6PR12MB3163.namprd12.prod.outlook.com (20.179.71.154) by DM6PR12MB3129.namprd12.prod.outlook.com (20.178.198.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2538.15; Thu, 12 Dec 2019 21:03:19 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::c16f:b437:4266:dbc1]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::c16f:b437:4266:dbc1%4]) with mapi id 15.20.2516.020; Thu, 12 Dec 2019 21:03:19 +0000 Subject: Re: [RFC PATCH v3 28/43] OvmfPkg: Create GHCB pages for use during Pei and Dxe phase To: "Ni, Ray" , "devel@edk2.groups.io" Cc: "Justen, Jordan L" , Laszlo Ersek , Ard Biesheuvel , "Kinney, Michael D" , "Gao, Liming" , "Dong, Eric" , Brijesh Singh References: <274fae2f1eb0e6036dd893c621f3c89b906db8d9.1574280425.git.thomas.lendacky@amd.com> <734D49CCEBEEF84792F5B80ED585239D5C399A65@SHSMSX104.ccr.corp.intel.com> From: "Lendacky, Thomas" Message-ID: Date: Thu, 12 Dec 2019 15:03:17 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5C399A65@SHSMSX104.ccr.corp.intel.com> X-ClientProxiedBy: DM5PR19CA0035.namprd19.prod.outlook.com (2603:10b6:3:9a::21) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: eacc82d9-6556-4f3b-ffc1-08d77f46b6d7 X-MS-TrafficTypeDiagnostic: DM6PR12MB3129:|DM6PR12MB3129: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-Forefront-PRVS: 0249EFCB0B X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(376002)(396003)(346002)(366004)(39850400004)(136003)(199004)(189003)(2906002)(6512007)(6486002)(31686004)(2616005)(4326008)(478600001)(52116002)(6506007)(66946007)(54906003)(31696002)(316002)(26005)(110136005)(86362001)(81156014)(66476007)(81166006)(186003)(66556008)(8676002)(5660300002)(53546011)(36756003)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3129;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aLXtnlR6RKOx0dU/Vrj0zo3kIUkGKq/LLBCO410GINeBkJ9jN8B43UmzKCvYX4Fcfk0m+/kA9ZHzoNhEdInGDxBjxPbIQCmIvVGgCx2J7Jcs9Vm0R4KBDgNyWgMT1xLa5IH6grXY7g0Ied0F14GrNb9y8yXFe31P8RrF9s4fBpt7RzJ27mQkH0prQ7xbR64kuRG1zA0yU3ojLwGom2cmtVK4PvXMGasuCt1tZ3HiOHyVCRd/Zb164JTk/AXMiSaFwC4FPv8Kj1lDr5Dw5Xs8XMwMQwUVEzu7SQz6JDcxhLhgw7LSdCKhbR4X4dzhUN4MLNuvGvdqoOvhFGr4FOrERvX66bETVH+k/9gbUIrcMQ1An9qWunoi4cWXSLI0UL34vYrBGHnUs/I8qE/0DTqcWBa0P/p1idnkADfLOm6wZNa7jNFwSI457cTkRkjyvBB6 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: eacc82d9-6556-4f3b-ffc1-08d77f46b6d7 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2019 21:03:18.9770 (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: l5zEfWxfn2ybc6nghDDi8Tt4G93xHkfBmb/32TGBBxekw/OAXcCTkRRNPbjvw3+jn2cSK1belFRbSsmAnyWu3w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3129 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 12/12/19 12:54 AM, Ni, Ray wrote: >> + // Allocate GHCB and per-CPU variable pages. >> + // >> + GhcbPageCount = mMaxCpuCount * 2; >> + GhcbBase = AllocatePages (GhcbPageCount); >> + ASSERT (GhcbBase != NULL); >> + >> + GhcbBasePa = (PHYSICAL_ADDRESS)(UINTN) GhcbBase; >> + >> + DecryptStatus = MemEncryptSevClearPageEncMask ( >> + 0, >> + GhcbBasePa, >> + GhcbPageCount, >> + TRUE >> + ); >> + ASSERT_RETURN_ERROR (DecryptStatus); >> + >> + ZeroMem (GhcbBase, EFI_PAGES_TO_SIZE (GhcbPageCount)); >> + >> + PcdStatus = PcdSet64S (PcdGhcbBase, GhcbBasePa); >> + ASSERT_RETURN_ERROR (PcdStatus); >> + PcdStatus = PcdSet64S (PcdGhcbSize, EFI_PAGES_TO_SIZE (GhcbPageCount)); >> + ASSERT_RETURN_ERROR (PcdStatus); >> + >> + DEBUG ((DEBUG_INFO, >> + "SEV-ES is enabled, %lu GHCB pages allocated starting at 0x%p\n", >> + (UINT64)GhcbPageCount, GhcbBase)); >> + >> + AsmWriteMsr64 (MSR_SEV_ES_GHCB, GhcbBasePa); > > As I said in the comments to PcdGhcbBase/Size, can all PCD consumers read the GHCB MSR instead? > > Does the GHCB buffer contains size information? If no, how does CPU know the GHCB buffer size? > I am asking this because I want to see a way to remove the PcdGhcbSize. The GHCB is one page in size and is a defined structure. The PcdGhcbSize represents the total size of the allocation, which is one GHCB page per CPU and one page per CPU to hold per-CPU data (currently the DR7 value). Thanks, Tom > > Thanks, > Ray >