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.76]) by mx.groups.io with SMTP id smtpd.web09.15155.1634672403426200105 for ; Tue, 19 Oct 2021 12:40:03 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=NkdZDUSn; 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.243.76, mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LT+ql1pW5qJ1bZ/okG8HzeEUBVSQOTIFLOFKF+EA+iQ9bi4ENsMYsnLNFUYbhdotXElP+0KZc+XMOgvhHp32IoohADNJawUZG5cUwkGdgPL9hQDAFedFdi61r3K6e8oArZdnsTOaVKlbYyQUoN4wmvNbYPLFbR2Gqfp+BUFyj3kwUyxnt9FX70AW2nkr9thHxeKm64Dc9cW8TI0drN6mK4XRVx4iiMOTSxek7FkRBAOeZYDyRIXfINtRb2X3yDh4rU3YskIAn0EuGR3JarFGkHnnQUGJLU8snrMSu+XyekFxaufHojS0iTUXzjRLMYWPl1doeY4hn+ugL3ZZCtwh/Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+BPM6gYGHSzS3ablLpNpJk39HG0bE8lnK5eaHbdH8bs=; b=fcIfcM832vrxRWIbRYliryzikDglvDoc03psBNaSgw8ulIyt8jYstrGpBYdKVHvy//tj9XgxTkvQmF3Qy5xxl+7qdk2j/ulyobldJu5DF6ytFMCiMYISWGIRl//eXofX1kqowRfR//1H5p4WzH68CcrO253yhWjmzonIQrjCBdBGIOQo1KO7QOEGZmnkVunotqQog48i+djYNc6Mkn9Be1uy1s/GhzvXTjmrUsRO7XMRCPGrt+2uDTdiDgnm4iaZ8pe3D6S5Cq2UvHe3ohP2OcE+jv678bof4h3PonQS6SbnEK74PC0qOpItblE6IDpjOGqYC0JP1GMqo9YjTW50Kw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=+BPM6gYGHSzS3ablLpNpJk39HG0bE8lnK5eaHbdH8bs=; b=NkdZDUSnSnb0pEoxqlf3JKt8mIe6jSRhVCUKjoQB6/JY1T+IfOATj0UxabJwwwHQsp+rxbA6HwzoihKoFNVM9blO1GLNhK8mSxRGbdpeolY08Z5x7yXxe8ZlL/GIeB1SDtBjgqefzEJUTLu3iW8ihyHedM8iCh0Dkrsj7af9OIY= Received: from MWHPR14CA0057.namprd14.prod.outlook.com (2603:10b6:300:81::19) by DM8PR12MB5399.namprd12.prod.outlook.com (2603:10b6:8:34::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.15; Tue, 19 Oct 2021 19:40:01 +0000 Received: from CO1NAM11FT004.eop-nam11.prod.protection.outlook.com (2603:10b6:300:81:cafe::9d) by MWHPR14CA0057.outlook.office365.com (2603:10b6:300:81::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Tue, 19 Oct 2021 19:40:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT004.mail.protection.outlook.com (10.13.175.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4608.15 via Frontend Transport; Tue, 19 Oct 2021 19:40:00 +0000 Received: from sbrijesh-desktop.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Tue, 19 Oct 2021 14:39:55 -0500 From: "Brijesh Singh" To: CC: James Bottomley , Min Xu , "Jiewen Yao" , Tom Lendacky , "Jordan Justen" , Ard Biesheuvel , Erdem Aktas , "Michael Roth" , Gerd Hoffmann , Brijesh Singh , Michael Roth , Jiewen Yao Subject: [PATCH v10 06/32] OvmfPkg: reserve CPUID page Date: Tue, 19 Oct 2021 14:39:08 -0500 Message-ID: <20211019193934.1052465-7-brijesh.singh@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211019193934.1052465-1-brijesh.singh@amd.com> References: <20211019193934.1052465-1-brijesh.singh@amd.com> MIME-Version: 1.0 Return-Path: brijesh.singh@amd.com X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3b14b8ae-e513-4fd3-4203-08d993383d5c X-MS-TrafficTypeDiagnostic: DM8PR12MB5399: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jCf52Nv2ej9wxS8H2jH0VcTkx3Ev/rSzG2ItJDMc07/3rcjFovbLH3J6sqY3Rh+Wxwfp7UlzN/5DjIYEdC5qJb7lz1hxokri6cZUWPI7UFsTFBU+QPMcbiKS+Om5XshhdtUd/mrLZI85abj0vUUT+KOsv1kO+1/n1/BQ1i563iwwAGOOHCnNY21oF/IGfXdogiuoVPvbsYkulafjb8/gP9ZcKnn3nUphurRskEFeUDPCbqQmiSjEjWhC/IHfcRNZ6DzX4+96nK4CcgSRlQWZWvaLHOZtawfA8Mi3m00RsrBtxDyy5cWeevYB450ppTglbvdOJ3KlZfreKKwMwC6EV79Rk5jxaHyhL/TB+yL33MYxi4lauCQ5WHjKp/hEwYx6Br/6iqVtXIKyb6J/tqR78Q+fArxuGrNgu6vdHW1UbqqPq2p+WKxj1oaUMWPEJq0A2den/DPgsxEjG0/acpZkiXimJzRkNc5u13iXtHdeYSDixIK27PyJnlU56uaouJwyFRsArzVYY2Gj2ri0qgJUaL+aCvdIo/Y6MwIXWUZYWuKd3ePRkHtMnT6j+5Eu/lDx5aDLiY0xKKmCKDEUmpqb8eqQr2hOdzKAUNbVWd9NUMCXz/UKaVPLMDQn++wvf4xGOgpx65RF7aQzDvshm0i4mY/ndIrWOHrgPWvbJI3F04kJFOK3maXlyDJRFL6SHF8RkgV5E7PPu/tAABf7bNODsgwLJ2YAN4P4Ipl37vUYKBdAjhNQQ08SqO08XhtlTR3erWbO2vDUs3J/FHC8hNgamOixItJ1QHCmZB4SIbDnxvBA6ERKl1RwVmrOPfB3irmR X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(2906002)(86362001)(4326008)(6666004)(36756003)(1076003)(82310400003)(8936002)(8676002)(19627235002)(5660300002)(70206006)(70586007)(2616005)(6916009)(83380400001)(16526019)(356005)(186003)(44832011)(966005)(508600001)(47076005)(336012)(36860700001)(81166007)(426003)(316002)(7696005)(54906003)(26005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2021 19:40:00.4994 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3b14b8ae-e513-4fd3-4203-08d993383d5c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT004.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5399 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3275 Platform features and capabilities are traditionally discovered via the CPUID instruction. Hypervisors typically trap and emulate the CPUID instruction for a variety of reasons. There are some cases where incorrect CPUID information can potentially lead to a security issue. The SEV-SNP firmware provides a feature to filter the CPUID results through the PSP. The filtered CPUID values are saved on a special page for the guest to consume. Reserve a page in MEMFD that will contain the results of filtered CPUID values. Cc: Michael Roth Cc: James Bottomley Cc: Min Xu Cc: Jiewen Yao Cc: Tom Lendacky Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Erdem Aktas Cc: Gerd Hoffmann Acked-by: Jiewen Yao Acked-by: Gerd Hoffmann Signed-off-by: Brijesh Singh --- OvmfPkg/OvmfPkg.dec | 7 +++++++ OvmfPkg/OvmfPkgX64.fdf | 3 +++ OvmfPkg/ResetVector/ResetVector.inf | 2 ++ OvmfPkg/ResetVector/ResetVector.nasmb | 2 ++ OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm | 16 ++++++++++++++++ 5 files changed, 30 insertions(+) diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 3e4e80a1e5a0..ef0f319938b9 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -347,6 +347,13 @@ [PcdsFixedAtBuild] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase|0|UINT32|0x52 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize|0|UINT32|0x53 =20 + ## The base address and size of a CPUID Area that contains the hyperviso= r + # provided CPUID results. In the case of SEV-SNP, the CPUID results are + # filtered by the SEV-SNP firmware. If this is set in the .fdf, the + # platform is responsible to reserve this area from DXE phase overwrite= s. + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidBase|0|UINT32|0x54 + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidSize|0|UINT32|0x55 + [PcdsDynamic, PcdsDynamicEx] gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x1= 0 diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf index 1313c7f016bf..e94b433e7b28 100644 --- a/OvmfPkg/OvmfPkgX64.fdf +++ b/OvmfPkg/OvmfPkgX64.fdf @@ -91,6 +91,9 @@ [FD.MEMFD] 0x00D000|0x001000 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase|gUefiOvmfPkgTokenSpaceGui= d.PcdOvmfSnpSecretsSize =20 +0x00E000|0x001000 +gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidBase|gUefiOvmfPkgTokenSpaceGuid.Pcd= OvmfCpuidSize + 0x010000|0x010000 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpace= Guid.PcdOvmfSecPeiTempRamSize =20 diff --git a/OvmfPkg/ResetVector/ResetVector.inf b/OvmfPkg/ResetVector/Rese= tVector.inf index 09454d0797e6..4cb81a3233f0 100644 --- a/OvmfPkg/ResetVector/ResetVector.inf +++ b/OvmfPkg/ResetVector/ResetVector.inf @@ -46,6 +46,8 @@ [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase =20 [FixedPcd] + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidSize gUefiOvmfPkgTokenSpaceGuid.PcdSevLaunchSecretBase gUefiOvmfPkgTokenSpaceGuid.PcdSevLaunchSecretSize gUefiOvmfPkgTokenSpaceGuid.PcdQemuHashTableBase diff --git a/OvmfPkg/ResetVector/ResetVector.nasmb b/OvmfPkg/ResetVector/Re= setVector.nasmb index e6a868730897..1c411a42f1b3 100644 --- a/OvmfPkg/ResetVector/ResetVector.nasmb +++ b/OvmfPkg/ResetVector/ResetVector.nasmb @@ -80,6 +80,8 @@ %define SEV_ES_VC_TOP_OF_STACK (FixedPcdGet32 (PcdOvmfSecPeiTempRamBase)= + FixedPcdGet32 (PcdOvmfSecPeiTempRamSize)) %define SEV_SNP_SECRETS_BASE (FixedPcdGet32 (PcdOvmfSnpSecretsBase)) %define SEV_SNP_SECRETS_SIZE (FixedPcdGet32 (PcdOvmfSnpSecretsSize)) + %define CPUID_BASE (FixedPcdGet32 (PcdOvmfCpuidBase)) + %define CPUID_SIZE (FixedPcdGet32 (PcdOvmfCpuidSize)) %include "Ia32/Flat32ToFlat64.asm" %include "Ia32/AmdSev.asm" %include "Ia32/PageTables64.asm" diff --git a/OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm b/OvmfPkg/ResetVec= tor/X64/OvmfSevMetadata.asm index eba861129333..38cc8809a7fb 100644 --- a/OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm +++ b/OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm @@ -17,6 +17,16 @@ BITS 64 ; AMD SEV-SNP specific sections %define OVMF_SECTION_TYPE_SNP_SECRETS 0x2 =20 +; +; The section contains the hypervisor pre-populated CPUID values. +; In the case of SEV-SNP, the CPUID values are filtered and measured by +; the SEV-SNP firmware. +; The CPUID format is documented in SEV-SNP firmware spec 0.9 section 7.1 +; (CPUID function structure). +; +%define OVMF_SECTION_TYPE_CPUID 0x3 + + ALIGN 16 =20 TIMES (15 - ((OvmfSevGuidedStructureEnd - OvmfSevGuidedStructureStart + 15= ) % 16)) DB 0 @@ -39,5 +49,11 @@ SevSnpSecrets: DD SEV_SNP_SECRETS_SIZE DD OVMF_SECTION_TYPE_SNP_SECRETS =20 +; CPUID values +CpuidSec: + DD CPUID_BASE + DD CPUID_SIZE + DD OVMF_SECTION_TYPE_CPUID + OvmfSevGuidedStructureEnd: ALIGN 16 --=20 2.25.1