From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (NAM02-DM3-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web10.15905.1621448410666870008 for ; Wed, 19 May 2021 11:20:11 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=QpQY026i; 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=G4WXiNluegJa++6OVVP1VZz3wTdjCqbzk04TXGL8Eu94JCrFk4lDPh573Pw8f92hvAB3zZn1IhjIm4hGcyx43AFtvumKCLgFb8lVkZ9zl2vo6zYmKwIJWJv75bVesk5KW+80c7kTYKYC9pLaAIJIx/Nsp3g4PfiTZSX7/60l8q9qj7j2mSDRprgf3Wtsi+YeieJWAm5CpwEOwYt637fr0o/aDS0VmDuWrpF03ohw86kudHGjH+/ZOz1mecbhk60cDxKl2ly+5JGDZSVGmuSonwBVvnvHrOQru56bOYPhgpdzqBOBXbpTggrj6ekevbB18WFguAyxTpd/dTprCvjBBA== 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=lVOEtRY1adYx87Yl+ActXP+rxwiCAvWfkRSRczrhFO0=; b=AwoFqOFu2jgGqMOL+4CB+LX2395Z2eeB/rbSwaDzzclBPBo+gK90piXps99XYLNZVQJLG1xSkpr8Tz1LoJv/dwOU7mnNXfr3e3SxnZoxvx9DD8OizNZWYzj9XCEcVCRI85Z09xTH43WRX/fw9rrnZV3bG6Cic4d7ZH4sUSEYA2B0dYXd/ZXDY+UZ7tqyUCTbzTGmLH9FVS++qFqAjW4QuUlzWkjsot60meIZnCN+seL5y6seV1lJ7i4eW4sN6l6DDzNTPwnJUsAWUNOBaZoRJGEeqgUsWR5g+vieUzKMjDq7jv5ptf5mUsifz1ddS8N1RYT3gj6E+PdcnfkfG+ZzKw== 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=lVOEtRY1adYx87Yl+ActXP+rxwiCAvWfkRSRczrhFO0=; b=QpQY026iYcHwSxH0+gSVUP+UyjAJvi3szgwSq97Go0uNntdmUAbQo9z/5U03OjsooodutgC+XyvZe/v79ZcWC1Z0TKeBOaRi64butwWM7h+T+bx+ilRzWBaPD+dJUmmjpEqDAQIda2GAuxQr2qtO0Py+JGhgLTYztwgw8Awxn3c= 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 SN1PR12MB2365.namprd12.prod.outlook.com (2603:10b6:802:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Wed, 19 May 2021 18:20:09 +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.4129.032; Wed, 19 May 2021 18:20:09 +0000 From: "Brijesh Singh" To: devel@edk2.groups.io CC: Brijesh Singh , James Bottomley , Min Xu , Jiewen Yao , Tom Lendacky , Jordan Justen , Ard Biesheuvel , Laszlo Ersek , Erdem Aktas , Michael D Kinney , Liming Gao , Zhiguang Liu Subject: [PATCH v3 05/13] MdePkg/Register/Amd: define GHCB macro for the Page State Change Date: Wed, 19 May 2021 13:19:41 -0500 Message-ID: <20210519181949.6574-6-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210519181949.6574-1-brijesh.singh@amd.com> References: <20210519181949.6574-1-brijesh.singh@amd.com> X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN7PR04CA0212.namprd04.prod.outlook.com (2603:10b6:806:127::7) 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 SN7PR04CA0212.namprd04.prod.outlook.com (2603:10b6:806:127::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Wed, 19 May 2021 18:20:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dfe19f1f-3757-44dc-eacb-08d91af2bc6a X-MS-TrafficTypeDiagnostic: SN1PR12MB2365: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: px1ThYgKHbYPrL+qTQEKQoS27f9BzjA+swygUy+Q+AdZXRwQUFXYp+PTzfap+6kFZNN8BmJ4bEiuyqCpj06vxXP3w422zB8k2MSxQxg9PdTLyxjPJupG/O1XVa82nyk04p/YR4j9RwqMmE4aCifnpr8VRcOG6Qd6WHqp7qhd1GxA6INCJzpZRT7szbdFnmjJZQQ4iGXvI0BdoAh0iZe19oGICKEpCasCYzh7U7OSg5wo2IKw//i/rQIQsaRWLYaSmQoS+wlFmEnPeck1pONCv6kG8CbiZNl3BSNT09dy1kyP+9JaHfYjGI0JZ/BO7NjVA6u/FqtN496TF307SQrz0bf5vfeNYOfiohLAhcwHX3NqjAmJ0/ie+2UPpYRW4hki/7Hyrgv11LCSXzNyy99pQrOazfW7XKBXGsmJp4121NRHeWp6o65pSyhN8IJznWzH7p+hYOHWnYRn6B1Yrs8Ax/vixR6b5J31xLj2tFiec+G3dAiAdBeHDjJ4veWHCnVaSgfQGqpdBIfDzwGiwyTACqrIHs82xjnllsKMMzzAOYEGDW0y2k8XJE67Qk/JtHwM1+x2o5IBrJqRVdfHX/YW/7V0adcl3wwpszyKQp4R2/JxsXnJRNpAbncGI/5/h5WaH2pAeby3XxGqNj62NIcyrvDi6NvPoF8KN/74/osoi/PKEckXMuXQRWpUoGlnP2BShyljPVEIOQysuVfTCP4a/IFuAEo35+khW7+zbuMie6g= 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)(136003)(346002)(396003)(366004)(376002)(39840400004)(16526019)(4326008)(6916009)(956004)(2616005)(478600001)(1076003)(2906002)(5660300002)(6486002)(19627235002)(966005)(54906003)(66946007)(66476007)(316002)(7416002)(8676002)(66556008)(8936002)(83380400001)(36756003)(38100700002)(38350700002)(86362001)(26005)(7696005)(52116002)(186003)(44832011)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?EBM6Ucm0yT5M+hR7v+XoQdDc7FfENmqvQPPqeqio9etcg0o83hgwjmWpNXnP?= =?us-ascii?Q?sTWMlSbJlDsT3RlbezLEq0KKQ3ahE8fTTDNY0r8HSA2L9WDpDV0wOIEDQvDk?= =?us-ascii?Q?0hJnCNhAcj2vJK7Mu9OqOIPByoV7WJs69TvTay1dCvutvDvk10lo+TrUMKt4?= =?us-ascii?Q?iQvfa2mssncrr63pvyvr3xC3UeGa7L4dDZa5+WKnCBi27Kv71iuiSGeQh5Q0?= =?us-ascii?Q?Y1qr9vbwQTblk2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UcbI+Qnja+yMq?= =?us-ascii?Q?0OixpDqghhGF3HQgqYiH3yepuQ1otFq7EkMkTrVsEcwqqtIxXfsZ4H203AVC?= =?us-ascii?Q?dpK53c6HUEuiqvbZMZrpOR8/Fjdk6ESYCSYEx0pLGdI9LeVyve04+/Oawzy5?= =?us-ascii?Q?1YhWiZFicpk4K6+1Svdlg3Nha5ZYiV4aodN3Gfti1Rd2nXUjH9CgoFfeQ6Nq?= =?us-ascii?Q?Q2Riv6RAbq5XrDAbzZvpdQxe?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: dfe19f1f-3757-44dc-eacb-08d91af2bc6a X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2021 18:20:09.6326 (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: 4eS1jEhjZkhvmseDRco6VI/sulUnDuxbQOVkrccPrDX600rCA/IP+gwGfe6UdR2lKDsxzGFIRvQFqCELAP+BtA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2365 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3275 The Page State Change NAE exit will be used by the SEV-SNP guest to request a page state change using the GHCB protocol. See the GHCB spec section 4.1.6 and 2.3.1 for more detail on the structure definitions. 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 Reviewed-by: Laszlo Ersek Reviewed-by: Liming Gao Reviewed-by: Erdem Aktas Signed-off-by: Brijesh Singh --- MdePkg/Include/Register/Amd/Fam17Msr.h | 15 ++++++++++++ MdePkg/Include/Register/Amd/Ghcb.h | 33 ++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/MdePkg/Include/Register/Amd/Fam17Msr.h b/MdePkg/Include/Regist= er/Amd/Fam17Msr.h index 542e4cdf4782..62014854d9b7 100644 --- a/MdePkg/Include/Register/Amd/Fam17Msr.h +++ b/MdePkg/Include/Register/Amd/Fam17Msr.h @@ -58,6 +58,19 @@ typedef union { UINT64 GuestFrameNumber:52; } GhcbGpaRegister; =20 + struct { + UINT64 Function:12; + UINT64 GuestFrameNumber:40; + UINT64 Operation:4; + UINT64 Reserved:8; + } SnpPageStateChangeRequest; + + struct { + UINT32 Function:12; + UINT32 Reserved:20; + UINT32 ErrorCode; + } SnpPageStateChangeResponse; + VOID *Ghcb; =20 UINT64 GhcbPhysicalAddress; @@ -69,6 +82,8 @@ typedef union { #define GHCB_INFO_CPUID_RESPONSE 5 #define GHCB_INFO_GHCB_GPA_REGISTER_REQUEST 18 #define GHCB_INFO_GHCB_GPA_REGISTER_RESPONSE 19 +#define GHCB_INFO_SNP_PAGE_STATE_CHANGE_REQUEST 20 +#define GHCB_INFO_SNP_PAGE_STATE_CHANGE_RESPONSE 21 #define GHCB_HYPERVISOR_FEATURES_REQUEST 128 #define GHCB_HYPERVISOR_FEATURES_RESPONSE 129 #define GHCB_INFO_TERMINATE_REQUEST 256 diff --git a/MdePkg/Include/Register/Amd/Ghcb.h b/MdePkg/Include/Register/A= md/Ghcb.h index ec232ebd3807..029904b1c63a 100644 --- a/MdePkg/Include/Register/Amd/Ghcb.h +++ b/MdePkg/Include/Register/Amd/Ghcb.h @@ -54,6 +54,7 @@ #define SVM_EXIT_NMI_COMPLETE 0x80000003ULL #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_HYPERVISOR_FEATURES 0x8000FFFDULL #define SVM_EXIT_UNSUPPORTED 0x8000FFFFULL =20 @@ -162,4 +163,36 @@ typedef union { #define GHCB_HV_FEATURES_SNP_AP_CREATE (GHCB_HV_FEATURE= S_SNP | BIT1) #define GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION (GHCB_HV_FEATURE= S_SNP_AP_CREATE | BIT2) #define GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION_TIMER (GHCB_HV_FEATURE= S_SNP_RESTRICTED_INJECTION | BIT3) + +// +// SNP Page State Change. +// +// Note that the PSMASH and UNSMASH operations are not supported when usin= g the MSR protocol. +// +#define SNP_PAGE_STATE_PRIVATE 1 +#define SNP_PAGE_STATE_SHARED 2 +#define SNP_PAGE_STATE_PSMASH 3 +#define SNP_PAGE_STATE_UNSMASH 4 + +typedef struct { + UINT64 CurrentPage:12; + UINT64 GuestFrameNumber:40; + UINT64 Operation:4; + UINT64 PageSize:1; + UINT64 Reserved:7; +} SNP_PAGE_STATE_ENTRY; + +typedef struct { + UINT16 CurrentEntry; + UINT16 EndEntry; + UINT32 Reserved; +} SNP_PAGE_STATE_HEADER; + +#define SNP_PAGE_STATE_MAX_ENTRY 253 + +typedef struct { + SNP_PAGE_STATE_HEADER Header; + SNP_PAGE_STATE_ENTRY Entry[SNP_PAGE_STATE_MAX_ENTRY]; +} SNP_PAGE_STATE_CHANGE_INFO; + #endif --=20 2.17.1