From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=4jYxp5J0; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.78.58, mailfrom: thomas.lendacky@amd.com) Received: from NAM03-BY2-obe.outbound.protection.outlook.com (NAM03-BY2-obe.outbound.protection.outlook.com [40.107.78.58]) by groups.io with SMTP; Thu, 19 Sep 2019 12:52:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jwmTewN0p9QPK7TbaMVmhIgrI5T0sbsHwDpivXi83fWlpALl5AOomjg/KmYq0Mm0p2StryYWVDuiDvYNu6RUx0R6LkipGoiMUEFNYmR4zzcf3Kbt3HAqnt+R7hnh7Fh+0wZ2Hr00+AV4o/BjNKG5N8JWwqyc8bXztSddnkzhudfaRraw3BsIsfcbsIn7FKMdc0ikte47EatxPbWo2PU9xEwDXC1Yh24wRvw/HTAWTYFt9xZwqnlmfn9E2/atXe69icjuZGyJUNal0eJMS1TKaqH7Lk0sRmS41lBO+0GYD6xzQJVYYdaXIlQMHqLnPrJF/o0MkWGPaLMGIsXXgPdD3A== 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=zw+dUE8Eant4qRdFyxcb47OEGx/u2Xo9Fx6zDAl42is=; b=VDc/vElZKeKrXfP/zusYR0ylpQsVr0DHcuNmmezrafg93H1TTO+DqMLLN2mLyp72BiEXk8SRFycB+xtuapxAfr2YqWPwOQYbxtHZz7oqkc1YYU4Zd7QCiKXshT4Ym6F51zOM2UM1G4O0A/OX0dg4LR6bOmdbKWULE/NVmWu2r9/Hrz6fHcSAQZqb58oFSkyoqlc2ilCNa7FZdNDF+BKbYEzNjkrG3mL+iw57APc5IgfeYpaWg8zmiuFNOdFhxA64nF6fs3AsVW4Y3/x3DLpXKxlU0fLsRJUbTxmqOnav+l2mduDeCGRZnI93DJU7VEe6BLwDXKMWkDk4a8Ne8vsFGA== 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=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zw+dUE8Eant4qRdFyxcb47OEGx/u2Xo9Fx6zDAl42is=; b=4jYxp5J0Dq1tLt47tp6LGvbSS8Sa2nnfEoOaXUm6mO65HQkFcnjUgZCy0SfCr+PPPTuZneZNzrPc4snTF2Z965EEnQLyCl/GGceeIE9IeFBiGYMWJWQBzkvOU2HQJ6Ss0fHZUwPCIJ44ZVs/5MvZK30hFn4Nn3iKyJpLPOFrQes= Received: from DM6PR12MB3163.namprd12.prod.outlook.com (20.179.104.150) by DM6PR12MB3228.namprd12.prod.outlook.com (20.179.105.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.13; Thu, 19 Sep 2019 19:52:38 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::400e:f0c3:7ca:2fcc]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::400e:f0c3:7ca:2fcc%6]) with mapi id 15.20.2284.009; Thu, 19 Sep 2019 19:52:38 +0000 From: "Lendacky, Thomas" To: "devel@edk2.groups.io" CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Michael D Kinney , Liming Gao , Eric Dong , Ray Ni , "Singh, Brijesh" Subject: [RFC PATCH v2 12/44] MdePkg: Add a structure definition for the GHCB Thread-Topic: [RFC PATCH v2 12/44] MdePkg: Add a structure definition for the GHCB Thread-Index: AQHVbyPJ3pUdb40AxEmPfOx32J+GpQ== Date: Thu, 19 Sep 2019 19:52:37 +0000 Message-ID: <815a3ab86510d001bc7efc3ec660d060afa631b6.1568922728.git.thomas.lendacky@amd.com> References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-clientproxiedby: SN4PR0501CA0146.namprd05.prod.outlook.com (2603:10b6:803:2c::24) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:182::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.78.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: fb0f59fd-a4ac-4be9-dae6-08d73d3aec33 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020);SRVR:DM6PR12MB3228; x-ms-traffictypediagnostic: DM6PR12MB3228: x-ms-exchange-purlcount: 1 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 016572D96D x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(366004)(376002)(396003)(136003)(39860400002)(346002)(189003)(199004)(4326008)(26005)(446003)(25786009)(52116002)(71200400001)(71190400001)(8936002)(81156014)(81166006)(256004)(8676002)(186003)(50226002)(2351001)(2616005)(102836004)(486006)(11346002)(476003)(66066001)(386003)(6506007)(66446008)(14454004)(76176011)(99286004)(6486002)(36756003)(5640700003)(66556008)(118296001)(3846002)(316002)(7736002)(2501003)(1730700003)(6116002)(5660300002)(478600001)(54906003)(6916009)(966005)(6436002)(2906002)(64756008)(305945005)(86362001)(6512007)(6306002)(66476007)(66946007);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3228;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: blvbnK1YUOrPYHkrzHkn1e39dPrEqLmW0DYRCa/xUylYi3r2WB5YI/9+jk7NWy2CDyOxytsBzpmghJGGTpRLjJSYPtyXsPl1AuHpoH1n7F574URv2wkB1geoNNKMbLqDfIP/rWYmc0FbzgsYqHDmjlAZMaVQNfYLIeKJBaE+fYxH2VoeTkn0sKTIL0tzvmDoae77YKcshS+Kf9E6m4geNpYv6ODsXe1po4hZAF88S4q0yMWcInJEZRz1yPYzOuLRU9oU3whYFvTcc8egrDhxqG+5+jfDtcSba4GcOAqvvTH/9VvMKB2oBVLKQDmhmAkXDgL1vtXsirI1VCOKbKDs+EfmFoSPSMBUL/AfcguORt3xAXdXXZT98b9LHecdVaFQ763yuuo8QsFKcgV64RUbvHr2+Zqd+3RNdEwZxgWMnuM= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb0f59fd-a4ac-4be9-dae6-08d73d3aec33 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Sep 2019 19:52:38.0361 (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: VQO3WF0gF4XTBzis0fhdKQ6pSGXzXndel974XnvngtzmRM7f4iQWXJskNHB7rOu9ddu0YJMMmwYq9WMF2il/ZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3228 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-ID: <0250EBF7C314B74E8DB26AFA9C68C6C9@namprd12.prod.outlook.com> Content-Transfer-Encoding: quoted-printable From: Tom Lendacky BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2198 The GHCB is used by an SEV-ES guest for communicating between the guest and the hypervisor. Create the GHCB definition as defined by the GHCB protocol definition. Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Tom Lendacky --- MdePkg/Include/Register/Amd/Ghcb.h | 105 +++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 MdePkg/Include/Register/Amd/Ghcb.h diff --git a/MdePkg/Include/Register/Amd/Ghcb.h b/MdePkg/Include/Register/A= md/Ghcb.h new file mode 100644 index 000000000000..cd3c98091208 --- /dev/null +++ b/MdePkg/Include/Register/Amd/Ghcb.h @@ -0,0 +1,105 @@ + +#ifndef __GHCB_H__ +#define __GHCB_H__ + +#include +#include +#include + +#define UD_EXCEPTION 6 +#define GP_EXCEPTION 13 + +#define GHCB_VERSION_MIN 1 +#define GHCB_VERSION_MAX 1 + +#define GHCB_STANDARD_USAGE 0 + +typedef enum { + SvmExitDr7Read =3D 0x27, + SvmExitDr7Write =3D 0x37, + SvmExitRdtsc =3D 0x6E, + SvmExitRdpmc, + SvmExitCpuid =3D 0x72, + SvmExitInvd =3D 0x76, + SvmExitIoioProt =3D 0x7B, + SvmExitMsr, + SvmExitVmmCall =3D 0x81, + SvmExitRdtscp =3D 0x87, + SvmExitWbinvd =3D 0x89, + SvmExitMonitor, + SvmExitMwait, + SvmExitNpf =3D 0x400, + + // VMG special exits + SvmExitMmioRead =3D 0x80000001, + SvmExitMmioWrite, + SvmExitNmiComplete, + SvmExitApResetHold, + + SvmExitUnsupported =3D 0x8000FFFF, +} SVM_EXITCODE; + +typedef enum { + GhcbCpl =3D 25, + GhcbRflags =3D 46, + GhcbRip, + GhcbRsp =3D 59, + GhcbRax =3D 63, + GhcbRcx =3D 97, + GhcbRdx, + GhcbRbx, + GhcbRbp =3D 101, + GhcbRsi, + GhcbRdi, + GhcbR8, + GhcbR9, + GhcbR10, + GhcbR11, + GhcbR12, + GhcbR13, + GhcbR14, + GhcbR15, + GhcbXCr0 =3D 125, +} GHCB_REGISTER; + +typedef struct { + UINT8 Reserved1[203]; + UINT8 Cpl; + UINT8 Reserved2[148]; + UINT64 Dr7; + UINT8 Reserved3[144]; + UINT64 Rax; + UINT8 Reserved4[264]; + UINT64 Rcx; + UINT64 Rdx; + UINT64 Rbx; + UINT8 Reserved5[112]; + UINT64 SwExitCode; + UINT64 SwExitInfo1; + UINT64 SwExitInfo2; + UINT64 SwScratch; + UINT8 Reserved6[56]; + UINT64 XCr0; + UINT8 ValidBitmap[16]; + UINT64 X87StateGpa; + UINT8 Reserved7[1016]; +} __attribute__ ((__packed__)) GHCB_SAVE_AREA; + +typedef struct { + GHCB_SAVE_AREA SaveArea; + UINT8 SharedBuffer[2032]; + UINT8 Reserved1[10]; + UINT16 ProtocolVersion; + UINT32 GhcbUsage; +} __attribute__ ((__packed__)) __attribute__ ((aligned(SIZE_4KB))) GHCB; + +typedef union { + struct { + UINT32 Lower32Bits; + UINT32 Upper32Bits; + } Elements; + + UINT64 Uint64; +} GHCB_EXIT_INFO; + +#endif --=20 2.17.1