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.web11.1654.1580857323583857410 for ; Tue, 04 Feb 2020 15:02:05 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=rwjhrFfi; spf=none, err=SPF record not found (domain: amd.com, ip: , mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I3ElVi1wbK6C/YpdAZpTZ3EfVSWZxQ9SMtZs4+ftNzc8jXwTE3LF+buR3maZKSFMBepaNr/t1o9FtaZp826hVb8tkk5PnHlor053qeo1FxggSVbU1RF3mYiiWmDPMoEg1w4nCDKm9ojSBOPR+ZmgvB+8bmTC9QEPkgltWTpXf4xQ9S7K5Od2iRGY/EEPruCYnQ2Uditr1dNEOMgnyzfY/RObJ87Ohcfx6Lpf8j0/wAsBt++JNTDca567ogpU/2WSmb6zkgIWZ/HvT9rpZSoT4uhL1k7JLDcmc0qvhGv9avHqdVbI5XHmB+iqXu+IwaTkVFbaTtLOAMpUKmthKnv9Pw== 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=WoLMbk2O3UYc0MK+RGAz6OVA/8R8jF47V0Nj3Z9EZQU=; b=ctX21S1jKqCf/A5lvMg+6FRJr5+eNm9L6O3FkxHlFa6gY/m9BrMkT4s00AJsV7dvkzjGlK/n0Ip1E1xuRI99lnaMG8vjvCKw8zMO8VKvWD+LmTU5UBF9YQ2if22Upop2qMlnEAFj31b4Rk4/RrZBR00VIkf8Vv/dtHkyvuEqJVlCUh0JfJ0qAKfZ1zXWPCc18Rbr4UXfE0e9Ad7rLXY9nYSkpsC46LS6oV6xbhQoJUbwpXkSL73WdMdHB1Fj2UwUgCgcAeE1vkXNsImoosK5HJV5CuKpvAT4BM9AxfwoQYw0RSw82KBureLtwrXPIxwMFnHldcRXeT1qYEc0o5g1Lg== 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=WoLMbk2O3UYc0MK+RGAz6OVA/8R8jF47V0Nj3Z9EZQU=; b=rwjhrFfiwfQqoOXlPEe2VFL9cV/yRdmUcVpBhhJRwEksrcPb7FzSHPVC5dtmd2z2royNcfG77iQElw2DAVxjN6/hXl/tHWBwI5jcNUb+GeYlqcyBSIua6VJ4sD9caPwHihOmfqwpiRkw/pX0eRRv/cWsZ+BSw3q9ncJuMbhanNQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from DM6PR12MB3163.namprd12.prod.outlook.com (20.179.71.154) by DM6PR12MB3930.namprd12.prod.outlook.com (10.255.174.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.29; Tue, 4 Feb 2020 23:02:03 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::a0cd:463:f444:c270]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::a0cd:463:f444:c270%7]) with mapi id 15.20.2707.020; Tue, 4 Feb 2020 23:02:03 +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 , Brijesh Singh Subject: [PATCH v4 03/40] MdePkg: Add a structure definition for the GHCB Date: Tue, 4 Feb 2020 17:01:07 -0600 Message-Id: <257c109e6df1589f71a2d8d171af824fc8c6ea16.1580857303.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 Received: from tlendack-t1.amd.com (165.204.77.1) by SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.32 via Frontend Transport; Tue, 4 Feb 2020 23:02:02 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: dc5c358d-c38c-4bd7-d198-08d7a9c63f75 X-MS-TrafficTypeDiagnostic: DM6PR12MB3930:|DM6PR12MB3930: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 03030B9493 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(366004)(376002)(136003)(396003)(346002)(199004)(189003)(4326008)(478600001)(6916009)(81156014)(2616005)(956004)(81166006)(8676002)(966005)(316002)(54906003)(2906002)(6486002)(66476007)(66556008)(52116002)(7696005)(186003)(26005)(16526019)(5660300002)(86362001)(36756003)(66946007)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3930;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: btNNjWdpPhgDCK1z9l/Tlf28KfwXnZG354WkjY7C6hlT/wcQy6JOscjU3OVlsJP7gZyWJVDoB3d2CLca4DWFl5EL0O2UzdsMOquAcq1hHt2T08bae3GNYP+tQIa/NIjYa8ssL9CDQs03uSk4kir27KHlwssv4l5uXlnQ9YJs3L+rAfFd+XRZPnqGWi354kB7mTOQYjwVsRMGPmd2IGBxXDqKtjc3K4CRL6dqmDLslJ7Qvo+kUReuA8HFybdwU08SlsKT00W/hmxmrpZiO3VFel18Pstws2SBTXbF/9iUi+QysIl9G/uQQHpY51UjkMUTQqB7xw8+TaSoFzuLikyEfx4oVhg8KTpUK4nw4BVDutEPFUrod+O8+1zO9ugwDVf5xGpZBRk+OuBwS8xmulp1MR+xEqC1yelqRrcNvC/n9Cy0QAL2hmJeKBhALCHMjNku1Js1TOF16yneNDLXB9PhGMd52a8UnnMtgVbPGgETxGmSyIq/HuvngrEGmAHReQbB7dBE7oVKOUtjF99r73cwhg== X-MS-Exchange-AntiSpam-MessageData: X8MV60aw9g9L2Wk6d7dPEA90E0dLtFPFS6Vlh/yVE0NjmuKkZkiyCoRefYPqCM1RhoVB+PS1za44u9isbN9D3/IGZ6Ce+W94FBbKgfrft5OvfTDh/jUK76sCB3BAPiGM0maSkoXn8+RYmBIpDPtH7g== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc5c358d-c38c-4bd7-d198-08d7a9c63f75 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2020 23:02:03.2287 (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: mWTQRF1/zS9RrAKVHF23BwyMR+BgaDH0JOSMYDOslpj1IC49MsnaNGzUgEzDBdFbzZX/vsqMYVrnaDbAmLh4nQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3930 Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198 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 | 136 +++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 MdePkg/Include/Register/Amd/Ghcb.h diff --git a/MdePkg/Include/Register/Amd/Ghcb.h b/MdePkg/Include/Register/Amd/Ghcb.h new file mode 100644 index 000000000000..efe09bac9ea0 --- /dev/null +++ b/MdePkg/Include/Register/Amd/Ghcb.h @@ -0,0 +1,136 @@ +/** @file + Guest-Hypervisor Communication Block (GHCB) Definition. + + Provides data types allowing an SEV-ES guest to interact with the hypervisor + using the GHCB protocol. + + Copyright (c) 2019, Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Specification Reference: + SEV-ES Guest-Hypervisor Communication Block Standardization + +**/ + +#ifndef __GHCB_H__ +#define __GHCB_H__ + +#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 = 0x27, + SvmExitDr7Write = 0x37, + SvmExitRdtsc = 0x6E, + SvmExitRdpmc, + SvmExitCpuid = 0x72, + SvmExitInvd = 0x76, + SvmExitIoioProt = 0x7B, + SvmExitMsr, + SvmExitVmmCall = 0x81, + SvmExitRdtscp = 0x87, + SvmExitWbinvd = 0x89, + SvmExitMonitor, + SvmExitMwait, + SvmExitNpf = 0x400, + + // VMG special exits + SvmExitMmioRead = 0x80000001, + SvmExitMmioWrite, + SvmExitNmiComplete, + SvmExitApResetHold, + SvmExitApJumpTable, + + SvmExitUnsupported = 0x8000FFFF, +} SVM_EXITCODE; + +typedef enum { + GhcbCpl = 25, + GhcbRflags = 46, + GhcbRip, + GhcbRsp = 59, + GhcbRax = 63, + GhcbRcx = 97, + GhcbRdx, + GhcbRbx, + GhcbRbp = 101, + GhcbRsi, + GhcbRdi, + GhcbR8, + GhcbR9, + GhcbR10, + GhcbR11, + GhcbR12, + GhcbR13, + GhcbR14, + GhcbR15, + GhcbXCr0 = 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; + +typedef union { + struct { + UINT32 Vector:8; + UINT32 Type:3; + UINT32 ErrorCodeValid:1; + UINT32 Rsvd:19; + UINT32 Valid:1; + UINT32 ErrorCode; + } Elements; + + UINT64 Uint64; +} GHCB_EVENT_INJECTION; + +#define GHCB_EVENT_INJECTION_TYPE_INT 0 +#define GHCB_EVENT_INJECTION_TYPE_NMI 2 +#define GHCB_EVENT_INJECTION_TYPE_EXCEPTION 3 +#define GHCB_EVENT_INJECTION_TYPE_SOFT_INT 4 + +#endif -- 2.17.1