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 [40.107.220.85]) 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=FTiSOtH6; 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.220.85, mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EvKmGGfmHx+MvW78qL6jjL2dw7BXOyCZufFkE7VNYn1gcInuVEvjag7I3JP8FDh6uU8bcCzOZSqQCVlBWnlAupI4sZZf5QAYsqLK0qWKEF9bXl67abVhfaYLzo+Ea6DbjggitOm68zBcEjfP23GZ3nNnjVlFrw6hVu6YhVrULKycVzvSRZ9H/CS5BRAhT7+ghDQzF11ckxKvER3LtQ98T9dN6KZDjgmYOljJb1b7CiHxJycFGg655W2+/ktSBOYjSfUMXDAL5St0iRo4lPPXkcXvM/nTmn1jFSDQ9e3l25ACAv1DDVAiujADkeouNP3sqQFemZYgulxKC3trfxyyBg== 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=FjgmwKSOBHp+Zb1QHXoIlUhzD4Bw88yez9FDt5i4ccQ=; b=afwADJl77WOdHx8dbKnulaaAxdi5RV63MwI4olwji/56D0yivqdYOHgJXvdEQEegShjWq8y+UyG4N0wgA8g9oNQ5p5XobHZuAM5omtHjOk91akuwv4EKsLH1Gi+Q56hVGvPN4FHSLGpr4d/Z5hhwWsOKAqrC+mokouIeciFpWkJkFxf/mTeozQjV87UV2dlk64GV9hq4gjh/iSnNQIRCXn3NbyHIhFAaqdmrJGhswSXBOuTm3QRFSxoayHBwLesTQ2NO0+AMyAj88vnZ99V07MnS54pobbK/eif6z5yujBuds3093zevMGSiSTzVVZDX1NumRudlMN43aa9d7nsTNg== 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=FjgmwKSOBHp+Zb1QHXoIlUhzD4Bw88yez9FDt5i4ccQ=; b=FTiSOtH6NWeoPbvHOJSfL9sujsVlO0QhE3brAvIzI8Kf40aakVA22o0Q6WfJoMKBwadhP+BEpbY1MEC5om2+n41OQooKtw0NmLKTYAE0d7lv4Dn10G3IqPRjXkHiQbaPg8mW3CXt25Vk4fAccYsphHGT7HwLl3YE0PpNR0HNRzY= 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:11 +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:11 +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 05/13] MdePkg/Register/Amd: define GHCB macro for the Page State Change Date: Fri, 7 May 2021 15:38:30 -0500 Message-ID: <20210507203838.23706-6-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:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c88da2ab-a70c-4b82-a0d3-08d911982b7a X-MS-TrafficTypeDiagnostic: SN6PR12MB2829: 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: aUZ8Nopt1A1Uaj++8XA+jk3YWvYLfcAb/wDGOKQh3SnDZqRq2Xd/n+AveDmyJZY5JI7dZk7iYYB6LWeTNt1jU3Eb2bCI/+6HS3FMlfOPSeyUc0RNUiWmhycffFxsd2YOsOs67Pii6+Ee7Se8Jl/6lEGZe9rwAKLIqA3Ifh5ngZ5E/7SkBWiQz2l96e3Lcp4SL+ZHxI9e3E9zdrkauiTzpHNKco8nNrdWH2bU5SdnjH96AT9wREoj0xJNwZbDznj1bIM6/2pJvh3QXZuopAU9sCzVkO63Qf0l+oR8mIpuouPlLRYilOmFfrf3pqUs/MCROyurtcokCO8aKDITI5PzGLMuTYOR4e9Z+lu8neKELeO9tQaSMfYLtpBfLNOgaYdrnBJApRds8sDKHPvnr7JWX6Q6/95swr0uXFxFxq1IIvEF+lyIU9yI9GqTvx1jw1pyVJ3w40iJ2mbjCUCQK1NPeys0Lqyd6yqcii7QsCYL5DfeNtEFDh1dw/pd8CGwVJcAfzXSMyZNGBoQ6pog6dZjQV9pTxWrA1Xkzg2GEjzF6C1w3aHSiNB1U/f1dZBS5aHiL/iEJ17UB/et4yrtK2rZguQk9LNZ6vQZvMkMKCwtYXQxLhSJjSQ6AmsXRVKksa0aBO5gtulm6ye6g0MPfRovEe9OfiO2lCf/A3sZBePulcaCubBONhVr5jsn7wy2/w38qlH+vtC1/kSVR2DXjBFThnqUOx2c/2fXF6EslrW+UOI= 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)(19627235002)(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?/9Md2mi+R8oGh8XA+zMOG8PorAOmGWHvi2nJRbTgXEB1VXCbjx0VuxL9EHDF?= =?us-ascii?Q?EckEIc5xXdTIKB+lAPHYqWySd3ejLXGK+XTMUOfaLb+dSMz0J+zdOyJGkcAK?= =?us-ascii?Q?oUkYIJT0W1fz5vpa/2T68eSjxzYyJzn9VW5v3B/dSH5eCRPGrxDEl0FGrnZ6?= =?us-ascii?Q?89JJ1zioBZB+cNZtZ8kcBtTpU/BfL3gLKAgtKPC5R3vuCXR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zOsdjdJmYHadUkTqTBLhF5efcEQXRai5ZrGANDJoOkt52TTDX?= =?us-ascii?Q?SdqujJeD5HRj/n2D1JQA42v9sl2VjghJ+jQpF7MKsAHP3JVtJCNP35cfLVOM?= =?us-ascii?Q?s2rv39S9iVR6m5jWfJkNAqlmS66XDRY+VcbpC2YlnSx4VoLsfPrylere6OhR?= =?us-ascii?Q?1jVddnsEYCkolmboHOgnZqLigNQ6/bNOutsyEOPVRZVgGkjsTQKmRv2P1JC6?= =?us-ascii?Q?yf3CYNA08dWtnKM/EISKtaLm?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c88da2ab-a70c-4b82-a0d3-08d911982b7a 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:11.4072 (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: 9GRZiaXvkwK7aMjX0BCsMP0DCKaa97W8Y8Zob1VxGg/dC/SgUcf25W+z2Np3DZ97jJ9638j5/fM/ImY+a2rc/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2829 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 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 326b11479779..a15b4b7e2760 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