From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web09.10434.1619783538721945423 for ; Fri, 30 Apr 2021 04:52:20 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=hOzfCkFJ; 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=EZOpxZ+neb8wO9FnMRDt4lmiGEbQ9YbReL+zwfABGB49CIC4wDkY6GVuLi82qz9xEdMA/OMtT3I5jqKLdmq/aT1zWtoBijR6M8CV1U+5Ja0HLGC6+eb3M1hUukVucU0zjfZzIq7UVTNUdCEx2/jq73KH7jKxAAm20slLDEDOm0wXfmpIfpzuREhTw/kdsF3rkYrHvbW5KVEujSjNmvUXEb3ZMhbY87JBaX7jjCaP4CGkFj8Mey7BWqIDFJn1TyG3PvINpzGPaOLkPtScIqARd1saZ3Kgm1Cg9Sxwb8+7aWKw3MvhpiD3sH8vRdr/cIJ95qexGIf8AhXnMPRxPdG0AA== 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=UL7nLvQbdnJPoynuSAy9xS+iUPJ00dLWqAQAMHhOxiY=; b=P6qneAK/BDqqrC+EuX1dcQjmyFubZsYaCWMNjtP4IpWb7di96ApaLnypH7VUOvaZJvNSnSeK0062APN3yfLYsG6a0xJE97AtfgKm/9VkiS7Yot3cKqCvPBZOhhU442DuQiUzKAw4DLHOwuCTnv0ZIR5jhh60jJ79r7EokvNZOUptNZNsvsijAIV8jSNUmpZiswGdl+2XsUr+NZeQaI2+0Vuur7jJdPgvVCt3SkE0b6x+rb8z9pwjNjwQdzOB/sKDwk7hho1kGd4Y3KZYqOPp4wUrQQoN9gTeL+slhpDN4kLXKFExDC+VeptC7cfq4DmMFBXCPuXMsPDMzx8lNVkBMA== 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=UL7nLvQbdnJPoynuSAy9xS+iUPJ00dLWqAQAMHhOxiY=; b=hOzfCkFJmi+f2zwuD274iG7PQLHiJUvzyaTfwKXQ3fHjc78jsIaPk24gO0qzVah8dzZCAtZrGQJUFxRHDTUqKiStQSj0+iURD1dExGkrCAQBQI+iyhEx6UZb9tFRQZF9wKY6/kDqzokWA5GfufpURPs7oAcOThnl1aM9e7URGPs= 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 SA0PR12MB4349.namprd12.prod.outlook.com (2603:10b6:806:98::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.23; Fri, 30 Apr 2021 11:52:17 +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.4065.027; Fri, 30 Apr 2021 11:52:17 +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 Subject: [PATCH RFC v2 04/28] MdePkg: Define the Page State Change VMGEXIT structures Date: Fri, 30 Apr 2021 06:51:24 -0500 Message-Id: <20210430115148.22267-5-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210430115148.22267-1-brijesh.singh@amd.com> References: <20210430115148.22267-1-brijesh.singh@amd.com> X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SA0PR12CA0006.namprd12.prod.outlook.com (2603:10b6:806:6f::11) 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 SA0PR12CA0006.namprd12.prod.outlook.com (2603:10b6:806:6f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.27 via Frontend Transport; Fri, 30 Apr 2021 11:52:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 634b5807-e1c2-42e6-4c49-08d90bce6755 X-MS-TrafficTypeDiagnostic: SA0PR12MB4349: 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: 6iKkJ2yYpya4IcOApP+MI2MmWvu5Yw8kQii5D4mEWBtHq2ynyDMrUMIWmFbKhIaKgqR3EgIX+QGM1myVwtp0y+STbNcdV72NUZw5JLjQNAaxk63CqVE1pCjWIxUwBR0peh7GuDT1Wblt9D8KqAEtJcos6po6XV+9Fbu72iKiSRvP/SyniCWgwLXt+3shCsD88PxbHNydHC48Lrvs+cLLguU8C1GyJjH4V/8OqAPYsq4rCpi5tulaeuYw1IBBhOQF7BX9pIZaO0nb81uqWAth4JQ2zSxjW4p4STEgO3p63EuA/pNZAJ+cuQqGNFoftiCD9ljjao29hU/DTjFvbKEgc6uo7opelk6FWmDu6b/ZtfCat4232DMS/WgSAZwIQ48PZzu0+kpRNNEnTZ7k82uXgGA8U+sWul2NcXPRafSmOJa4OlEgRMKyNhN+VdhOTHdoReJjBY38iXwMnLdZ5X6bnExwCJ34uzggYDqmpdNi0bUOjqNTMoJ/nAhIisXsW6Xy+rKjDh151u7q2+stDHBke5Nn2kcf+FGRB+E0AZHgjZRSq1uGOPR6oFd5PYzfKOwZmuzQG/iwtO6caXdHD3id9RgILZST0fAoO4QJxsai7uaG44uj1Is8r7LFlIyEK/80Sc74nq85UCgFLuDRs8hmIoCqk9uIRG0jwza1ZjpmkljH+wDGtgw/g+PDI0YJLVM+VZr3BXZ/zT7pdYjdp/3kSTseMfIt7emoOn4umQ1322g= 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)(39860400002)(366004)(396003)(346002)(136003)(376002)(966005)(38100700002)(2616005)(26005)(1076003)(86362001)(316002)(6916009)(8936002)(6666004)(2906002)(4326008)(52116002)(66946007)(5660300002)(186003)(54906003)(44832011)(36756003)(66556008)(8676002)(66476007)(16526019)(19627235002)(83380400001)(478600001)(956004)(7696005)(38350700002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?Am+ZsUQ2sdhhig4AhPKkccii8/C0Oe9ci9Hh2XkL8Ion3VdmpGxAkLjWqlrq?= =?us-ascii?Q?3l+pAI1NBn7ypOkKt9j6oP3msXkz+VkCr1B7elFTtYJtcCBFxQg+RfwQXnD/?= =?us-ascii?Q?6aTR6iOuX6XGOM3MIUuk5X5j5n4nsyRzWMvAK0acRHBixHLA3ohKJqWPYSVg?= =?us-ascii?Q?r8TcpKHiCHuDHrYF/Mo6gTaPjNtKgIvY3v9zOSnPTwFJE0V31tIFmtGVVitB?= =?us-ascii?Q?r96CG9n1bBHEj6FIDKgmBu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ii?Q?R/waKSDdqclsB8Gib/hRKwcw57n2JPuiQ9I9wgtRNWj7JfDlClHMtkvjhIK3?= =?us-ascii?Q?zgJ0/nPqLXP2drE+nqsYS73NiPKuXWktPQYonE0YZZfN8LSxMDEcc9Ua1S2F?= =?us-ascii?Q?3xcu4ov0NHObxVn3bSMOi4VwGGEtLLP4jx+Hy+nukeBfOeTdL9U/yg0s/s1c?= =?us-ascii?Q?SRcYqjUT+qflkmbfGYQtzp+Z?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 634b5807-e1c2-42e6-4c49-08d90bce6755 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2021 11:52:17.5876 (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: /hxM0hmQJNZwPWHJiuHATZRfayvU/Q0YPm88EgS0VZWiqVq4Fyv2uHspvpJJSTscjbszSoq0g6qBzPXTjTWKPQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4349 Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3275 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 Signed-off-by: Brijesh Singh --- MdePkg/Include/Register/Amd/Fam17Msr.h | 15 ++++++++++ MdePkg/Include/Register/Amd/Ghcb.h | 29 ++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/MdePkg/Include/Register/Amd/Fam17Msr.h b/MdePkg/Include/Register/Amd/Fam17Msr.h index e19bd04b6c..432cee2feb 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; + 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; 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/Amd/Ghcb.h index 2d64a4c28f..1e7c0daed3 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 @@ -160,4 +161,32 @@ typedef union { #define GHCB_HV_FEATURES_SNP_AP_CREATE (GHCB_HV_FEATURES_SNP | BIT1) #define GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION (GHCB_HV_FEATURES_SNP_AP_CREATE | BIT2) #define GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION_TIMER (GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION | BIT3) + +// SNP Page State Change +#define SNP_PAGE_STATE_MAX_NPAGES 4095 +#define SNP_PAGE_STATE_MAX_ENTRY 253 +#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 PACKED struct { + UINT64 CurrentPage:12; + UINT64 GuestFrameNumber:40; + UINT64 Op:4; + UINT64 PageSize:1; + UINT64 Rsvd: 7; +} SNP_PAGE_STATE_ENTRY; + +typedef PACKED struct { + UINT16 CurrentEntry; + UINT16 EndEntry; + UINT32 Rsvd; +} SNP_PAGE_STATE_HEADER; + +typedef struct { + SNP_PAGE_STATE_HEADER Header; + SNP_PAGE_STATE_ENTRY Entry[SNP_PAGE_STATE_MAX_ENTRY]; +} SNP_PAGE_STATE_CHANGE_INFO; + #endif -- 2.17.1