From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (NAM02-CY1-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web10.13506.1574280439944511918 for ; Wed, 20 Nov 2019 12:07:21 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=jDxZM0Bg; 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=U4yII4q+ACW/rDn1xnmwImcQ5eSamQwpXmwfNtXU2aphBzi8p94qwaWvMNi4pbodw/UGHJrEGN6NBAcWgPxNJqpCzPj4mtFR9SgH5O1iyKMKvq5YfAmS0Kh/318STYb62i1d/0XrMi0rzCcspg3JAjSCmNbQ/cP4MQ3DzRm15YQgN+je89Ev0qeqZ4Pf0B0uKb2uYQaxpHymDBD452agjsv6t4QCBc++p/jcD7GBd1wI3Z94h/44PLiv9gB0K6vN6bp3kOjZgH7nlqyh4l0TwsVYXFxEcnmEpB2mRmEYsaGlknJ0mAEJJS33bS/t9py/gCm8+eugYDO7vQfJvQyP8g== 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=xNx6Fj9kHusZ7wugu1GQKtfF/sjMdfx0SrzWYZSFx7k=; b=NdwQCWpuRHhyFNoUu6BAAR0lC6ltxf/QMHUIdnHjumH4jz1M95fV+YJx4YmGWLEBzbhZhcau3/YG6ocOXI5yqcMtCZQt45LJhyoBNnq404KqzVP15yXx/ilgwNRxs64yZ3sNF/z+hmckXMJ+8U7c1UkVTBbiJ3/qk6Wc/BsU05TRRzV2g6Ntg2+Yo/WD3P1C7EV3dU/jSkrnOarYiTceAFjw6b4sy6To7nHNy5Ua/k/uoZIBfjcD9Vvh0Qil+BwqZYBOAvddt/4e2t8oTsD9xO3hFqmz4SWuuUyKGkzIDFTFaB4RVEpXkbRWmyQ2VhEm0k0dgS8o6h2Np2Jhb+ok5Q== 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=xNx6Fj9kHusZ7wugu1GQKtfF/sjMdfx0SrzWYZSFx7k=; b=jDxZM0BgHqBV4ICSGjI9dlzUmOtlsH5pAb0UxR+H3COJdW3xpyD1iqJ/fViYIjCQi/0Uxab3Z6T9ttA6rI7eDARfOFT5VLzK85CbmbsoRPiZrpBQUwX0ahfnO24IMfY9h6s09Qjww8nUTAwrbS6ROyNrU2NxMOtFbVIl/bJi8mM= 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 DM6PR12MB3675.namprd12.prod.outlook.com (10.255.76.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.28; Wed, 20 Nov 2019 20:07:20 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::dd0c:8e53:4913:8ef4]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::dd0c:8e53:4913:8ef4%5]) with mapi id 15.20.2451.031; Wed, 20 Nov 2019 20:07:20 +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: [RFC PATCH v3 03/43] MdePkg: Add a structure definition for the GHCB Date: Wed, 20 Nov 2019 14:06:25 -0600 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: DM3PR12CA0087.namprd12.prod.outlook.com (2603:10b6:0:57::31) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 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: 189aa111-159f-46b7-6939-08d76df53f93 X-MS-TrafficTypeDiagnostic: DM6PR12MB3675: X-MS-Exchange-PUrlCount: 1 X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 02272225C5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(376002)(346002)(396003)(39860400002)(366004)(136003)(189003)(199004)(2361001)(50226002)(81156014)(81166006)(8676002)(2906002)(6486002)(99286004)(66476007)(486006)(47776003)(66556008)(25786009)(2616005)(476003)(54906003)(11346002)(118296001)(8936002)(316002)(2351001)(7736002)(305945005)(66066001)(6916009)(86362001)(16586007)(3846002)(6116002)(48376002)(14454004)(478600001)(966005)(5660300002)(66946007)(446003)(76176011)(36756003)(51416003)(6506007)(386003)(50466002)(52116002)(4326008)(6436002)(6306002)(6512007)(26005)(186003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3675;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: BCL:0; X-Microsoft-Antispam-Message-Info: b5bAu9qOBE/0k11tDkzLxk04WZx7jEne8WHsAkLynk9u0aajwLv7b/UIwtF5vvHdDtBZXymVPI5XOPMuZQMGV2GLhf4psBRdJx/q2E9L4whOjLcAt84Nvs0a86CpdmPKu91rh3s+u19g4eCgDTQSWNcITjttU6zq8z3u9utXCXsDi58tvw/tjfRdGjkGQ5vjbAZ2AbE8/okCwE8+O7LjIfOFOF9K8hQT9MklNfBSbZwJIsK2piauBVB29W3gJO/Osqpq1N/lRbUNvYoeNl4mba38X/DYNCzmbhZdrWQXdIsUbuQ603kFwQkmERRWx92UrKicTDZ8+Chl/Wyv9s2PWefBDMj2adEnpgcsxqrkIJebJnSkzhaJloInGKxwLmql03tqEaZK+doHQ5RG1KqypmwLa8zO8IETbHkH3aalIRij0odLU6aQcSmFtVgYnQU/dOZ3bxc0I2ugI274YH+WIiwzA2QYJ7nJJ8IwU+5TlDk= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 189aa111-159f-46b7-6939-08d76df53f93 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2019 20:07:19.8834 (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: Bbba7tMFkogkeheETNl46yPrplW2OE8nroIJpdYKeRiC8A4Lp/xnzrBF/G+Mh9oCP41kPkKdi5U/+KuprnV9Wg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3675 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 | 117 +++++++++++++++++++++++++++++ 1 file changed, 117 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..e7ccca91f93d --- /dev/null +++ b/MdePkg/Include/Register/Amd/Ghcb.h @@ -0,0 +1,117 @@ +/** @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, + + 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; + +#endif -- 2.17.1