From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web08.16264.1620419953315168995 for ; Fri, 07 May 2021 13:39:13 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=XTOHn3Fy; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: , mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gW/roDXkeXeJzyXQl4hbUOTCKzkah2Sotl4YK+6FWTnh6sFXcNdxFll39o0KknRihrguJsC1X40hNzIfmryTiMHM9dw6gzbQP501x8IYdIYF3GhRL9FlSBU4burb78TKQl4ulOz0vS1eewrFlFkaTEDXhnu1H3ojb8bp/2bDEb51x8uJjEO+b4L312W8diiA+BJSvF1nfH9n3Pj4rizg1X8QFswuPl9NSYVpvtTiG46nJNJfTPZntxL9KlayL3ygStXsHcOWpSi36jU9OIenO7K0t3zJy6Aqla9pXbUF2fCRZrkNp2Z+mdFYKo+ENEiwwe/nqFOHIYzKdLMyLx+WQQ== 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=o6p3M6HqSrvyXEOFkhLXVQIRtNXzULF0qxBqy3x9l78=; b=V4t3sfUYD3Wl+/INDNApWpjRY0NTBx6IruhSR7rPqL0gxqqOFwkxwnQmzvtKsBoTjvk6uljREOA3rzPtrtafxV9asYsFsO/3Ar0lCkJCG9aNqPZ4IouyItfyqeCe1I1jpUxeYCgmZa9/Xmbsm2HkHa9F7kQC3ofAuv14iHdxShgVu+e+CidrxH9A/nFa5ztFqdisX9tlBt/zX9rWPu+p8BV2617illSHyeH/yzZUH/LCnjwAwkbyOmBbNRFAdo0geGro8/pdysr0dFlywDOtNcWv1yRr/SxK8/Xvnwf5CIM0yBlFNMcOhGleFO4+XvPGNrjNgNJWaFZq85vgtWgRlQ== 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=o6p3M6HqSrvyXEOFkhLXVQIRtNXzULF0qxBqy3x9l78=; b=XTOHn3FytDGF0IxL0vmg/KOy2bJa1kdx7iFTz9kiXBuKVgI6g/4iEXIywMmX0ivvMbgawe7NWtkOFf9w/jl3MUZpFRU45Ib6KefSFR6sLAsKXeaXf9agQ/3HSGzSCH/lqUxem6rr7reUoZi60UkuqqPIB8zhdFbX/MSKpJqv/tY= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SN6PR12MB2829.namprd12.prod.outlook.com (2603:10b6:805:e8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.27; Fri, 7 May 2021 20:39:12 +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.4108.029; Fri, 7 May 2021 20:39:12 +0000 From: "Brijesh Singh" To: devel@edk2.groups.io CC: Tom Lendacky , James Bottomley , Min Xu , Jiewen Yao , Jordan Justen , Ard Biesheuvel , Laszlo Ersek , Erdem Aktas , Michael D Kinney , Liming Gao , Zhiguang Liu , Brijesh Singh Subject: [PATCH 06/13] MdePkg/Register/Amd: define GHCB macros for SNP AP creation Date: Fri, 7 May 2021 15:38:31 -0500 Message-ID: <20210507203838.23706-7-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210507203838.23706-1-brijesh.singh@amd.com> References: <20210507203838.23706-1-brijesh.singh@amd.com> X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN7PR04CA0020.namprd04.prod.outlook.com (2603:10b6:806:f2::25) 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 sbrijesh-desktop.amd.com (165.204.77.1) by SN7PR04CA0020.namprd04.prod.outlook.com (2603:10b6:806:f2::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Fri, 7 May 2021 20:39:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a6113fbf-2c4f-4844-2b26-08d911982bfd X-MS-TrafficTypeDiagnostic: SN6PR12MB2829: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RSYSfPyl2Ei4ouogkol7Ct2q3mMTSrHzKfE3AJTzkY+/8UKG4Pze2OVgxlY2N9wvp2al7N9Tm5aVM0yYpOXA+5DxS7fH4aPiY8+r28qP7O/ZE7rmLt7erpwLsTEzL+MQDnUIaQen6I6I/Li9vj1GlH5RpJZGQgO3Bla1JRGqMUoxbakrXyc+ojGvyoOwt0wske080cXWWjsPP9YxCwe2gLXo6LSECcOFYvB13KQ+1GhmkLTaFSInAuJa5auOSDgG6GN48CTxm06+2EM2stEt+fp8w2FOakCFGpqLPzfUS6IHz9o8CsH0qMux++t5tQBf0oli8Mpz5E9cpJQP2O80DyGMPfR+TfR4CItZd4h38dre0m923PldtgGkzDUPPTpzDcYWvHsAv0eA9xY7TJWesHQE4J3aNDwBjEhbETMXYF6OYDK3LmNxhtiFtmvkM0us2TwgI4R1S+MHbacTfImVt0UYmPBL1CHv6k3UOoRD1daCfn+1df0ZI4ifLISEo0LmfuMCMPrRuxunUg21KI7/Gx8mBpGRwJ8CV1JoUB1cC8mhg2bXaaOZfno5DD6p/wKaLbyaulfMSUL3WNMRLz//fnLTXMv2MRO1Muo27+yjOvEjfhcalUfU3quPxI5mHXBjxOzmJWNmoqUU8ySe5zoql+xl15HDLpj8oDrDYvtgyL4lsdx/eyJRbDCOarj9P4VJMTj+FVuUf7B1QdOJH1x/+D40nAvw3VbAyHRZZM9lgOY= 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)(396003)(376002)(366004)(136003)(346002)(39860400002)(2906002)(1076003)(86362001)(44832011)(8936002)(6916009)(186003)(8676002)(6666004)(956004)(478600001)(26005)(7696005)(2616005)(83380400001)(16526019)(52116002)(316002)(36756003)(66946007)(66476007)(54906003)(38100700002)(66556008)(38350700002)(4326008)(7416002)(966005)(6486002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?AAkFw7aWa8pa5zIeli4Nbn0pL5jXXzioKeSMWLr1/jIUok7tItd4/QXOsq/Z?= =?us-ascii?Q?78mXWKO3/ObBPY5N8zWCIX6yARBNCaB1LX0Oz35fg7r9eswlP6oqIPaD+cdz?= =?us-ascii?Q?s6scnmVuhxdaSCk7xxiZenTgmd7wYYgCU0g0XyisZojVsqtM6trkbqllzIxH?= =?us-ascii?Q?QN0n3i21rP527ucFakCZQyXP3QV2BjnnFVwsb/VYVZbXgRoCrCHdS0oR+rc8?= =?us-ascii?Q?NipWoE56Fv80Q5xL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0FYs0j1HpqbA+kpF5VscscZsuQY/u210p0fcplWUu3jwoBTAMR/h6yNht0?= =?us-ascii?Q?zzhK5F/AGK5aN+ymJ53em3yv6w0ZJ1Adq1FXZf83qUc4BiB8s0Ub2cZe1CiF?= =?us-ascii?Q?N7axgkLn1pdvUoxf9HXbcilJmasIC48rTrkPg3k+wzhQObAGUZXEj8Kdd315?= =?us-ascii?Q?QqJzV5JhZ1/JJpad3awmc9SW?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6113fbf-2c4f-4844-2b26-08d911982bfd X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 20:39:12.2727 (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: OtCQILYhic/7m5K7vB+u5K7nuGiO7H3JOF9nr3HLnl7mo5AU8Ikxc2epy9gh7hwUJan7C6MTz6mfmept2Lfvxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2829 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Tom Lendacky BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3275 Version 2 of GHCB introduces NAE for creating AP when SEV-SNP is enabled in the guest VM. See the GHCB spec section for additional details. While at it, define the VMSA state save area that are required for creating the AP. The save area format is defined in AMD APM volume 2 (Table B-4). Cc: James Bottomley Cc: Min Xu Cc: Jiewen Yao Cc: Tom Lendacky Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Laszlo Ersek Cc: Erdem Aktas Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Tom Lendacky Signed-off-by: Brijesh Singh --- MdePkg/Include/Register/Amd/Ghcb.h | 70 ++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/MdePkg/Include/Register/Amd/Ghcb.h b/MdePkg/Include/Register/A= md/Ghcb.h index a15b4b7e2760..956cefbc003c 100644 --- a/MdePkg/Include/Register/Amd/Ghcb.h +++ b/MdePkg/Include/Register/Amd/Ghcb.h @@ -55,6 +55,7 @@ #define SVM_EXIT_AP_RESET_HOLD 0x80000004ULL #define SVM_EXIT_AP_JUMP_TABLE 0x80000005ULL #define SVM_EXIT_SNP_PAGE_STATE_CHANGE 0x80000010ULL +#define SVM_EXIT_SNP_AP_CREATION 0x80000013ULL #define SVM_EXIT_HYPERVISOR_FEATURES 0x8000FFFDULL #define SVM_EXIT_UNSUPPORTED 0x8000FFFFULL =20 @@ -83,6 +84,12 @@ #define IOIO_SEG_ES 0 #define IOIO_SEG_DS (BIT11 | BIT10) =20 +// +// AP Creation Information +// +#define SVM_VMGEXIT_SNP_AP_CREATE_ON_INIT 0 +#define SVM_VMGEXIT_SNP_AP_CREATE 1 +#define SVM_VMGEXIT_SNP_AP_DESTROY 2 =20 typedef PACKED struct { UINT8 Reserved1[203]; @@ -195,4 +202,67 @@ typedef struct { SNP_PAGE_STATE_ENTRY Entry[SNP_PAGE_STATE_MAX_ENTRY]; } SNP_PAGE_STATE_CHANGE_INFO; =20 +// +// SEV-ES save area mapping structures used for SEV-SNP AP Creation. +// Only the fields required to be set to a non-zero value are defined. +// +#pragma pack(1) +typedef struct { + UINT16 Selector; + UINT16 Attributes; + UINT32 Limit; + UINT64 Base; +} SEV_ES_SEGMENT_REGISTER; +#pragma pack() + +#define SEV_ES_RESET_CS_ATTRIBUTES (BIT7 | BIT4 | BIT3 | BIT1) +#define SEV_ES_RESET_DS_ATTRIBUTES (BIT7 | BIT4 | BIT1) +#define SEV_ES_RESET_ES_ATTRIBUTES SEV_ES_RESET_DS_ATTRIBUTES +#define SEV_ES_RESET_FS_ATTRIBUTES SEV_ES_RESET_DS_ATTRIBUTES +#define SEV_ES_RESET_GS_ATTRIBUTES SEV_ES_RESET_DS_ATTRIBUTES +#define SEV_ES_RESET_SS_ATTRIBUTES SEV_ES_RESET_DS_ATTRIBUTES + +#define SEV_ES_RESET_GDTR_ATTRIBUTES 0 +#define SEV_ES_RESET_LDTR_ATTRIBUTES (BIT7 | 2) +#define SEV_ES_RESET_IDTR_ATTRIBUTES 0 +#define SEV_ES_RESET_TR_ATTRIBUTES (BIT7 | 3) + +#pragma pack(1) +typedef struct { + SEV_ES_SEGMENT_REGISTER Es; + SEV_ES_SEGMENT_REGISTER Cs; + SEV_ES_SEGMENT_REGISTER Ss; + SEV_ES_SEGMENT_REGISTER Ds; + SEV_ES_SEGMENT_REGISTER Fs; + SEV_ES_SEGMENT_REGISTER Gs; + SEV_ES_SEGMENT_REGISTER Gdtr; + SEV_ES_SEGMENT_REGISTER Ldtr; + SEV_ES_SEGMENT_REGISTER Idtr; + SEV_ES_SEGMENT_REGISTER Tr; + UINT8 Reserved1[42]; + UINT8 Vmpl; + UINT8 Reserved2[5]; + UINT64 Efer; + UINT8 Reserved3[112]; + UINT64 Cr4; + UINT8 Reserved4[8]; + UINT64 Cr0; + UINT64 Dr7; + UINT64 Dr6; + UINT64 Rflags; + UINT64 Rip; + UINT8 Reserved5[232]; + UINT64 GPat; + UINT8 Reserved6[320]; + UINT64 SevFeatures; + UINT8 Reserved7[48]; + UINT64 XCr0; + UINT8 Reserved8[24]; + UINT32 Mxcsr; + UINT64 X87Ftw; + UINT64 Reserved9[8]; + UINT64 X87Fcw; +} SEV_ES_SAVE_AREA; +#pragma pack() + #endif --=20 2.17.1