From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web08.6093.1620863210224608460 for ; Wed, 12 May 2021 16:46:51 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=eT4haajX; 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=HT6S1KiGMMW65uaGoQfRgQoPG9SUho5uzM6Kmi2RvJG41lhv39rYeimpzzmnjHn0MZDTUguIf9IKd9oO0NTNDbb5az5gNDMFj82B5qP5cTdMzSsXs7oU/2mgs6qq19u6t71kEEH2OrNwouvML062c1vr98QpFtGodpCzz5OXT0g9GMxu7a8d0c2GIqVRU3rX/lnDshfxY9oRwv/DAFdzXQRKzArxnHgIakZi9BqcmevKua0zk2hjKRciAT68PUbcbfoSF/S2d2MM37tdL8VUyjKPStyLdUdnCEngvl6N75lu5DgCAlRoWbHaoUtDt9Urr1rIW4tjFEnsrDfp7K160g== 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=lkWLQKUHdlfQWykJ6vVPvb6vot2Pe9/7TYqS9K7uECs=; b=kxxbenCKv/PvOLlO+kNIS7m+N69N+zBb0nrYT94g7EY9SxfaNiWO6e+EwpR399LdQ6UQSRGRyK9fslp5qad3l2EybmLqq8P/ZwLtdg1Lu27Vf7LSjYxC23oi+9dZNi51C905Paiy/MoysadixQdmsZ9ZaQZzyboD59Hy121SF/mtXI3u7Hs2Qrkk206PdAnex4Xd73q+TGDZL6wMoOUtiCwrmiCimzyO5+bOGBMomd9Yf1xfpzC9W9ScObJMu2273MTwYS8kp5N8fQ43/QuYZQ6jlCB7mQyJEuXzN6ZFp0OD1HJBsUSNbCcXU9KqWB5JWRsscNUEROjTn/NnYj8vRw== 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=lkWLQKUHdlfQWykJ6vVPvb6vot2Pe9/7TYqS9K7uECs=; b=eT4haajX9LhUJUCl1uaZVS4amdLqEJPJ+1F8i45ecZvBE+Q6dgnlMBQnBdhgO9MwLRYp6XvqS3Cw6VBKFLtSAuim+gOshcAoiER2+Sj1q9TSCVTU1+Jk0HDGuvBVGu9FF7rM3l/rq6NDs+ulJ4NDBefRqwh3cyBl2X18dV0PE8o= 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 SN1PR12MB2445.namprd12.prod.outlook.com (2603:10b6:802:31::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Wed, 12 May 2021 23:46:45 +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.025; Wed, 12 May 2021 23:46:45 +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 v2 05/13] MdePkg/Register/Amd: define GHCB macro for the Page State Change Date: Wed, 12 May 2021 18:46:07 -0500 Message-ID: <20210512234615.1726-6-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512234615.1726-1-brijesh.singh@amd.com> References: <20210512234615.1726-1-brijesh.singh@amd.com> X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SA0PR13CA0003.namprd13.prod.outlook.com (2603:10b6:806:130::8) 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 SA0PR13CA0003.namprd13.prod.outlook.com (2603:10b6:806:130::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.11 via Frontend Transport; Wed, 12 May 2021 23:46:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8172817b-623e-47e9-3ea6-08d915a031f5 X-MS-TrafficTypeDiagnostic: SN1PR12MB2445: 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: 2fljVGEOZDFzr3AbJFUMASxPENqzZX+4nFmmhW4ywWXXflVWHXWWQNQiJu4w97zEP6vLrIHh0t9gjKHA306mAWEBwwuOcZUbXjvdTRiCncYqhqlNxUcxoh/KFXkhn2T59Ztw19LHqS60Qp99P2lZi2FrDp1hmOdknnBjuCg7qNv9yqmjgvn57Qz6nKNJRhE9WH28iMGkexclAKns9i0Rck25YsEIYtS3ReBBN7GoOVoj3AgNgUF8fxn1HC9O9SvBFDWtQhf0bajFcDlJtMJh+RH/SG2Qjr1XuC6nhAIj6oDNUENh74sPhFQ3ICIxwKTVwWBwQGzPZ7nQBrqPHILwbHuXPjEObLeqxUmCusF9JdbVNMpln7AZRMO1MfHUgBdfXnBEvBaf9mQC7BjrFFFdTby1D+aS4cgKRbt8r6MlJjISkc0uDSnp4VaUprdYepQezAR6n+5JmkfEloeY7EqXpdQbwXoeg2R2YKU2SCjke02Dm6tcZbkWHrFblckNxP15kCbrJG85RxjyRU+XAq2ucRmlnjfPMPTACZ/DUGDgq1CPzctfnGfqjI8HZEnnJ5L6hQAt9FIvNolZN0drwLL9VzdbCv2HqG2EZTLmvyGFX6Jb7jrIMB0izdrQlFjpzTMbUYNYYjfALke4zhr16Uj+G6fI6/TtulZzqI/jnsEXiqBc/bWdN1ikfaoxzoQH3B6sW8ApDLGPHoJx2dwwGZRwc4CeciR0mNps93a80QqxeVFN4J+phQZknjbed3HUikeY 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)(376002)(136003)(39850400004)(396003)(346002)(366004)(6486002)(54906003)(8936002)(2616005)(7696005)(478600001)(2906002)(966005)(8676002)(19627235002)(956004)(5660300002)(1076003)(44832011)(83380400001)(52116002)(186003)(66476007)(6666004)(66946007)(7416002)(36756003)(26005)(16526019)(86362001)(38350700002)(38100700002)(66556008)(316002)(6916009)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?vPsSEu5OC6Hxt5Ir4QYMViVvUT3Dnac7qSda0wrAe5irWgOTR+3m9DvNyoD2?= =?us-ascii?Q?9YXcvUm4DRCVQCemPvLl7gR48NlmgWkRy2S7EYFvh8Gl33MGhRsSFbJKGS+S?= =?us-ascii?Q?Qm3c+zkCf0yCmXt3QZjtslOzuqksUZyA0q+xtgIOboQX4U/RQ9pcnBsKbcbG?= =?us-ascii?Q?kAM7FbAq7PmzVRpHlhoKopfhYZsM2LS2AK3mtsJKJ3UXoD5tZ7KbyhsS1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CmnnknytZeLMV9dDFfpmaTyL9yamyXN7TmbTqnWQ?= =?us-ascii?Q?p1Kw04yFqcE1znPRdIuGUv6lU/rMDcS1g/g5uPKSgIKh3dxO+ae6TFXUX15/?= =?us-ascii?Q?oZ0R0ANVwr3T3mu+GQRT/4ZPSKpVJN13BpDW935nRQ2wbUNQRiiodenmiGEw?= =?us-ascii?Q?ueS54/OoDoJsglAtiXD8jkKzr7IPssxJYMZEeBY5H2NkY5mNKkz1C0sudyl5?= =?us-ascii?Q?R+SFTAKzvTbl7B41KyB6/jgg?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8172817b-623e-47e9-3ea6-08d915a031f5 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 23:46:42.8381 (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: Wd2iRZXyKYsoAAiLgUCW8Xy+kdqSUiBjCJQs3ULuYNqtuuBsJmPNNHYfVm1Tjp6Qzr2hxTngcMcCLfR21cvBWQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2445 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 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