From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (NAM02-BL2-obe.outbound.protection.outlook.com [40.107.75.71]) by mx.groups.io with SMTP id smtpd.web12.10840.1591363676588816927 for ; Fri, 05 Jun 2020 06:27:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=WxbyDePh; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.75.71, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BqCAktmUijPCoVxtbaxu56j4FctC9lucpoyipmicnFWgps2Upzqr4Onfdt6knrwayXmCIBw+CLbNH+05yCjTgzb7goPkheMCemmRCtSqyENWoaV5nwKkW9sO3X8BBBa3rldwLBiJmD06ubHICO8PmSwIKwCNMWs3OCpStEU1+VU5uZTd1QKmUBofq4K3149O6uriE5kT7lNaINM8qI4tKO72GFZFq15m5yqSv+NXJRgoVskGV7ItMd/1MahOToAOJNnaE+ueNqWO1iY54R/noqW6u/1k6Ton4Ye4qJgRDWgnVbCvnUg/ec36IGqRpXmvadVh22qXn5CRJnHv6klAdg== 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=aN2kaqKBFUFiVO6yQM+FJKL4ueT1FTMXhOAlTOGp80A=; b=lNpLOjjIIV/6HcP9qtUgU48brRq43D09LeaaUtQejfRqYAjMyZSNphlkTAeZdm28nMsTA3gEG55Q/EadsBu8TkX9pDJL8T1ynrBO15Yz2UrLQhgzr+AZ5aBlb+eJmI9UGKTeqh7X7RPWY1+Q9g9E6IgGUdN5f0Oyqboqa7ut1/hzRwqSeblpL00AQDHDY/3Fvt5IsxZlX0E9xFcCqDEZFerpO3pfyPyywl5rwNw7t88mi2TxQi5F+dIEa6w+eafiy9AxH+MgeBAPoultmkMPBR/mPBq0/OkWaq6xD8189Hj3L85aMPW6OYcgYCWl1/20yHvYyPUp5An2NfvCpnzE3A== 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=aN2kaqKBFUFiVO6yQM+FJKL4ueT1FTMXhOAlTOGp80A=; b=WxbyDePh8HtOhkVOKWvKsLj5XZcEkVH43KPrEqHXnmLUCeB9gVXYaKuokxPuWshn0DBeZbLgXyLdlb1UZt1NT9ai5t/5/AleX7Q1HmANIdl+U61IQ9D7AHyLxWvDzhAJludlyMwYz31hSJ4LL8jz4uQqfzzqGhNB4NiFKZzkGB4= 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 DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) by DM5PR12MB1594.namprd12.prod.outlook.com (2603:10b6:4:e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Fri, 5 Jun 2020 13:27:53 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4ce1:9947:9681:c8b1]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4ce1:9947:9681:c8b1%10]) with mapi id 15.20.3066.019; Fri, 5 Jun 2020 13:27:53 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Cc: Brijesh Singh , Ard Biesheuvel , Eric Dong , Jordan Justen , Laszlo Ersek , Liming Gao , Michael D Kinney , Ray Ni Subject: [PATCH v9 04/46] MdePkg: Add a structure definition for the GHCB Date: Fri, 5 Jun 2020 08:26:55 -0500 Message-Id: <65a69fbf48a97b3224c91cd5a10c4eb2d5ef3537.1591363657.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM5PR19CA0060.namprd19.prod.outlook.com (2603:10b6:3:116::22) To DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) 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 DM5PR19CA0060.namprd19.prod.outlook.com (2603:10b6:3:116::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Fri, 5 Jun 2020 13:27:52 +0000 X-Mailer: git-send-email 2.27.0 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: cb9ffc28-2107-481a-3ab7-08d809544029 X-MS-TrafficTypeDiagnostic: DM5PR12MB1594: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 0425A67DEF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FtvaqbOgPOwFVrrB5omw5J/HKCRnqQL38ZYB9sYgDGMLWNqT3ObFcPmVnd3C/stxeLuxQSHVmuAFnPPFrICZMbqeRwTmVbShkA1oMcKS4oYoGafgGCo23A7NLl06L9WuaWGWibr8SpexuQ+yVMW1ssGYU9gxGccePbFzYtxxElhQ8EdfOK30ZiTUKGjVQ42W2Ydb2S0CqZrdgAfZf6Y9gWGRKEnLPvl3NsdPEqriiWYJVNeDopgcVi8Iwa9oauM3OVSLzKadhBQbHeqZFvt9zQ7ge53Efg4UZu7azZtkAdBk1aGlfgLcB67/48XrpMtFMCBn4uGABDrOodmbSAwfxtSEiozXBv/K+uNt1wiaVYm1K0CpKW5wmHBO5Um9s5534c2fy7v3otHE+1sURRTu/Nk81KF91fKfDOi2naBPNpMYemrE1tSbG43ICgLtHNFaMMnONcGNTbn5T4muUXL2BQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR12MB1355.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(39860400002)(366004)(346002)(376002)(396003)(136003)(83380400001)(6486002)(4326008)(16526019)(26005)(2906002)(2616005)(956004)(186003)(8936002)(7696005)(52116002)(8676002)(6916009)(36756003)(66476007)(66946007)(5660300002)(66556008)(966005)(316002)(478600001)(86362001)(54906003)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: K3JdIhdqe/IlqOZe/pJbLSRtPVXQICZf9ysV7OaBQnPp9tKTKrYV1ExVJy+vfDNFDben7+pPUoMB64G5D3wHaLb+XzkE8h2voscQ57gNSyCgAkbdE/J4bDzAhNliJAvcPP8QRrTyka2uvDONiKurFDbXuL+tDTsvub8VJe6tyWbcmHeg/y6QlzZayGcHK1iRSyhS9YJ9BUO6g3E9xGyb2E8pQia0IVS7YO4SNvRYT2TmyBx1wR/UQ+9p6l3Rzy9atGlVx0wftSKBPPFEO3YYSPJlYVJ2QRYxytx3KN+yBcoU5rp31Vnolu4AmVpaKrwHXk+lAyN5S1FjgK6GwpboIQooanh0oKuy/FTpXfKbc45E0Iv+AwhUtiw2Klp2O0OaGeEtGYqaRad/pUpZsaMvk7ukH7Cg2alpJYwrbD+yi+gV17dtbuPq9xQaPTSK0N9bthM1uGLW3zKdjpnXOwJb0uSwQe0M8ce4kNJsb+UTF08= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb9ffc28-2107-481a-3ab7-08d809544029 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2020 13:27:53.3790 (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: QcJaVO8gESOXVhBVGSpTPoY5EOuhR0Oe/cIs/nP6oEoIcID+WALIdbrfIdbeJr2USSiLVdJb6tGxs+x3VSvkWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1594 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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 | 166 ++++++++++++++++++++ 1 file changed, 166 insertions(+) diff --git a/MdePkg/Include/Register/Amd/Ghcb.h b/MdePkg/Include/Register/A= md/Ghcb.h new file mode 100644 index 000000000000..54a80da0f6d7 --- /dev/null +++ b/MdePkg/Include/Register/Amd/Ghcb.h @@ -0,0 +1,166 @@ +/** @file=0D + Guest-Hypervisor Communication Block (GHCB) Definition.=0D +=0D + Provides data types allowing an SEV-ES guest to interact with the hyperv= isor=0D + using the GHCB protocol.=0D +=0D + Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D + @par Specification Reference:=0D + SEV-ES Guest-Hypervisor Communication Block Standardization=0D +=0D +**/=0D +=0D +#ifndef __GHCB_H__=0D +#define __GHCB_H__=0D +=0D +#include =0D +#include =0D +#include =0D +=0D +#define UD_EXCEPTION 6=0D +#define GP_EXCEPTION 13=0D +#define VC_EXCEPTION 29=0D +=0D +#define GHCB_VERSION_MIN 1=0D +#define GHCB_VERSION_MAX 1=0D +=0D +#define GHCB_STANDARD_USAGE 0=0D +=0D +//=0D +// SVM Exit Codes=0D +//=0D +#define SVM_EXIT_DR7_READ 0x27ULL=0D +#define SVM_EXIT_DR7_WRITE 0x37ULL=0D +#define SVM_EXIT_RDTSC 0x6EULL=0D +#define SVM_EXIT_RDPMC 0x6FULL=0D +#define SVM_EXIT_CPUID 0x72ULL=0D +#define SVM_EXIT_INVD 0x76ULL=0D +#define SVM_EXIT_IOIO_PROT 0x7BULL=0D +#define SVM_EXIT_MSR 0x7CULL=0D +#define SVM_EXIT_VMMCALL 0x81ULL=0D +#define SVM_EXIT_RDTSCP 0x87ULL=0D +#define SVM_EXIT_WBINVD 0x89ULL=0D +#define SVM_EXIT_MONITOR 0x8AULL=0D +#define SVM_EXIT_MWAIT 0x8BULL=0D +#define SVM_EXIT_NPF 0x400ULL=0D +=0D +//=0D +// VMG Special Exit Codes=0D +//=0D +#define SVM_EXIT_MMIO_READ 0x80000001ULL=0D +#define SVM_EXIT_MMIO_WRITE 0x80000002ULL=0D +#define SVM_EXIT_NMI_COMPLETE 0x80000003ULL=0D +#define SVM_EXIT_AP_RESET_HOLD 0x80000004ULL=0D +#define SVM_EXIT_AP_JUMP_TABLE 0x80000005ULL=0D +#define SVM_EXIT_UNSUPPORTED 0x8000FFFFULL=0D +=0D +//=0D +// IOIO Exit Information=0D +//=0D +#define IOIO_TYPE_STR BIT2=0D +#define IOIO_TYPE_IN 1=0D +#define IOIO_TYPE_INS (IOIO_TYPE_IN | IOIO_TYPE_STR)=0D +#define IOIO_TYPE_OUT 0=0D +#define IOIO_TYPE_OUTS (IOIO_TYPE_OUT | IOIO_TYPE_STR)=0D +=0D +#define IOIO_REP BIT3=0D +=0D +#define IOIO_ADDR_64 BIT9=0D +#define IOIO_ADDR_32 BIT8=0D +#define IOIO_ADDR_16 BIT7=0D +=0D +#define IOIO_DATA_32 BIT6=0D +#define IOIO_DATA_16 BIT5=0D +#define IOIO_DATA_8 BIT4=0D +#define IOIO_DATA_MASK (BIT6 | BIT5 | BIT4)=0D +#define IOIO_DATA_OFFSET 4=0D +#define IOIO_DATA_BYTES(x) (((x) & IOIO_DATA_MASK) >> IOIO_DATA_OFFSET)=0D +=0D +#define IOIO_SEG_ES 0=0D +#define IOIO_SEG_DS (BIT11 | BIT10)=0D +=0D +=0D +typedef enum {=0D + GhcbCpl =3D 25,=0D + GhcbRflags =3D 46,=0D + GhcbRip,=0D + GhcbRsp =3D 59,=0D + GhcbRax =3D 63,=0D + GhcbRcx =3D 97,=0D + GhcbRdx,=0D + GhcbRbx,=0D + GhcbRbp =3D 101,=0D + GhcbRsi,=0D + GhcbRdi,=0D + GhcbR8,=0D + GhcbR9,=0D + GhcbR10,=0D + GhcbR11,=0D + GhcbR12,=0D + GhcbR13,=0D + GhcbR14,=0D + GhcbR15,=0D + GhcbXCr0 =3D 125,=0D +} GHCB_REGISTER;=0D +=0D +typedef PACKED struct {=0D + UINT8 Reserved1[203];=0D + UINT8 Cpl;=0D + UINT8 Reserved2[148];=0D + UINT64 Dr7;=0D + UINT8 Reserved3[144];=0D + UINT64 Rax;=0D + UINT8 Reserved4[264];=0D + UINT64 Rcx;=0D + UINT64 Rdx;=0D + UINT64 Rbx;=0D + UINT8 Reserved5[112];=0D + UINT64 SwExitCode;=0D + UINT64 SwExitInfo1;=0D + UINT64 SwExitInfo2;=0D + UINT64 SwScratch;=0D + UINT8 Reserved6[56];=0D + UINT64 XCr0;=0D + UINT8 ValidBitmap[16];=0D + UINT64 X87StateGpa;=0D + UINT8 Reserved7[1016];=0D +} GHCB_SAVE_AREA;=0D +=0D +typedef PACKED struct {=0D + GHCB_SAVE_AREA SaveArea;=0D + UINT8 SharedBuffer[2032];=0D + UINT8 Reserved1[10];=0D + UINT16 ProtocolVersion;=0D + UINT32 GhcbUsage;=0D +} GHCB;=0D +=0D +typedef union {=0D + struct {=0D + UINT32 Lower32Bits;=0D + UINT32 Upper32Bits;=0D + } Elements;=0D +=0D + UINT64 Uint64;=0D +} GHCB_EXIT_INFO;=0D +=0D +typedef union {=0D + struct {=0D + UINT32 Vector:8;=0D + UINT32 Type:3;=0D + UINT32 ErrorCodeValid:1;=0D + UINT32 Rsvd:19;=0D + UINT32 Valid:1;=0D + UINT32 ErrorCode;=0D + } Elements;=0D +=0D + UINT64 Uint64;=0D +} GHCB_EVENT_INJECTION;=0D +=0D +#define GHCB_EVENT_INJECTION_TYPE_INT 0=0D +#define GHCB_EVENT_INJECTION_TYPE_NMI 2=0D +#define GHCB_EVENT_INJECTION_TYPE_EXCEPTION 3=0D +#define GHCB_EVENT_INJECTION_TYPE_SOFT_INT 4=0D +=0D +#endif=0D --=20 2.27.0