From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.88]) by mx.groups.io with SMTP id smtpd.web12.1276.1585071674285817421 for ; Tue, 24 Mar 2020 10:41:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=JL6/05wL; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.244.88, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eUijhsF9aQ4dIuzDmofyTdz7GK5lMinCvE7021lZI1i1a1jq7CHoiBx1qhbccOlYdowuKnh7g2MKTfZNRW+llsdVbMk/A0jsgmvZALNhjKG68DndGo347dsumhINYj07Fh3st8T9ZtjtZ0jIqejTHSoYQeoDraaLiJluJ3qsJiT8xsVdo11Mpsx85U+qj1E19EVRu0esA8yGznOhAiWpbQgNcpHHpSKrih2So29ntQ6pmCZ3v7g6ma/7bAEtInkeY2AVcupsSe9TIH5G0RYzGYOKHYwH62+L57/x1uWqP/eHi/uxfkeR+ZSTi8tHd0oyr4q+/ONiT9ZrwuZyVHBg1w== 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=wgVt17dH62d9cOX7RWnvdxrmjiQ6zm7Fd2siy5FVn+4=; b=npjNXXkesK5OD7xHFOlbfIzZzq+2F+3ivczWOeEYgba8+MdZFziQN9yhmMsu02dDkvybmah6Ao0Ir25gBMqXzQgHWUz+mACUUSyUBL9832wxBVtfhez3UxvzL8qzZhOsSu9QN4kUW+OzLrSdtqdEOmyqjafvQ3U2iJPA9S+UW9xAPfY2lJXybUfhCMpd6gp0VJ4ChK5YUtw6ZlsDA02puwFB2ms44CbrqrcJP3wZtD1aiU598QQBUMlaUzn2NcT65FbZIBTX084yt1sKDFPp5p09q6WIJg1l+lNAQVHp979DSOXaNAaEv8Y7K5K7UvriG24SehIO2xLBNemWGvWlNg== 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=wgVt17dH62d9cOX7RWnvdxrmjiQ6zm7Fd2siy5FVn+4=; b=JL6/05wLlbqpZh41Qr1EQVXW7pS/pTsgyCAH1q6iSQ0M0/yieK+ckrb7fcYVhPbU9sy6SGcuLFlb9pTQLr9o9+9re/Kayh966x7tkbJL2GUo54bbLHKZ31W/636XSR+E/sJ5jvCSYizZsAl/XfD3F+BUhcWKJZR0VL7KfCeEwu4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) by DM6PR12MB3915.namprd12.prod.outlook.com (2603:10b6:5:1c4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.22; Tue, 24 Mar 2020 17:41:13 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::f0f9:a88f:f840:2733]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::f0f9:a88f:f840:2733%7]) with mapi id 15.20.2835.023; Tue, 24 Mar 2020 17:41:13 +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 v6 03/42] MdePkg: Add a structure definition for the GHCB Date: Tue, 24 Mar 2020 12:40:17 -0500 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: DM5PR06CA0025.namprd06.prod.outlook.com (2603:10b6:3:5d::11) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tlendack-t1.amd.com (165.204.77.1) by DM5PR06CA0025.namprd06.prod.outlook.com (2603:10b6:3:5d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.19 via Frontend Transport; Tue, 24 Mar 2020 17:41:12 +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: 7e0f532b-d527-4b54-f9d1-08d7d01a8bb4 X-MS-TrafficTypeDiagnostic: DM6PR12MB3915:|DM6PR12MB3915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 03524FBD26 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(376002)(366004)(346002)(136003)(396003)(39860400002)(8676002)(8936002)(186003)(316002)(54906003)(16526019)(956004)(66476007)(36756003)(6486002)(66946007)(6916009)(66556008)(2616005)(26005)(4326008)(966005)(81156014)(478600001)(81166006)(5660300002)(2906002)(7696005)(52116002)(86362001)(136400200001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3915;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords; 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: epiQeTfl6qpFbU7UfOz/47yjBpye4wc0NwGdGoRR4cs0DVgrEqNXNj+J8rS246X/6fwyfpv02zLX4nV5w84T3TSkxtqqBGPNyHYrfb8e+YUJJRG0V3bbWVStfIzkVu07Z4Nk7tx4JYHAco8ktFiMgb0eHy/B55U1I93iLVsxzC8q3w+KizVED+kovUaZS1wEmOMiqykM1h6zjL9l9VcZX3kV/lykx7a61+/xq3L/skDHR51HJwl/TZhevHyERaCypWTm16qMCya/excJ7CmbHQKwZUZjMYg0QR7gDv+5v7VpnBU0fJWEhWioIWCDurtZD+kDzXUakb654hn3k4ainlly12ip11WGU4HIPn1ib4BYfPI+4ugDLfvZ038zHrdeZz6mD215Bjsh2EBpipgIxJGweNVNmF0AmBKYnWAADEAmBiOUBRln9mZODi+mwitfzrSQ3kk2SBMuXm4rlNXHz2dYiNcEO2/8uqeI0HsoFw9sZnhZI+mHVlQWFzfXsdFo4xWYhEpFMeDWEV5ZyVoTKTA5LlFSqajotYaGwkIQAkzHWBITby9W6aqTmOnE0uGfPf2JrpWvKMgWsnKNFPu9Cw== X-MS-Exchange-AntiSpam-MessageData: mv2UJ6rykHS0qDsypy/8FfNqHTtcK4wc+Y4606dwI5vV2gH1/QiJEUZRtsP82SajA+cHmaVt5tqU8qy0fkkQfj0Fwm5a53RACZnHcMBjXFe87phErxvHZrVpFr6rk/rKR4cyQ0fLHXUWG66611dRKw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e0f532b-d527-4b54-f9d1-08d7d01a8bb4 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2020 17:41:13.0233 (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: c32cokIboaULoyyRIcigAsnXKD7gNtrQnY9EjK0xcoEgrc5RDDkUcYXlykLdadrGlgtcZbBRbbwQhuzVRYM/nw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3915 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..ffad7efd82d9 --- /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) 2020, 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