From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.61]) by mx.groups.io with SMTP id smtpd.web09.9405.1603981108448866000 for ; Thu, 29 Oct 2020 07:18:28 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=fITg51/v; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.236.61, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WDLFL8gc8EupVo0tlq1L30kBBihlcFrXO8gGdebPR872V1rNalnRoWGF491xuKq8tGlCz0XHELXQIq6lQyYZ2hn26zCJilYewfKynjlPnc8WNSThFUb44qs6eW2qtUM9It6xmFscLKo6YiHeuCX5llfJOU515G+Bd2y/UXycoAlr+aIgAmLehpJlp4kV3wovk8aB6f4AtchbF4+9SSruorNrL0Rt98hdeyH/5m8DewY4k+k1HBqZ14yIUheXOsI0Qi1bXfjWBPKtyXTIxqYIV7CSXtVfkbDXm0uahahC3x3jttzmJ7MrG0BzrIgsu1pRyiJNv9maymxdkMUFGbU/7w== 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=27z00h2amcGLVyvGSXkua/4UQf6K5QChGaE8Mh9kIe8=; b=DGknWyD8j7UhymcI1M0WeZSTimbmikUOZk4UMGDyV9XaTjq4D8xh57kyHAQ5ZhI11XlmWzJB5ECVWpMNGS9DhqEB7wY/ylx3bezxtxHsTRFC5hDJ1t1IeecRnvTthgRgNh0Om+10awFgBtLr76XNtvn7HJ6s9PEj+nqA5LF8vXsjyZ17v803hz2YAPn6AWsOEwxmQ4Jm/1CD2/FwP0h0sFqTT6XBGaXPxDnSjMNjxSU6CFWcgx6ykxeZ5yvP0blfxEMyNgdXxhXGhnSyDcWz1Cj56VHe3/9lSy9KUsXvOVPMrnkEEm4x4N7+i67WDNbyRJDUozw8cUa6AHCbYSeqjQ== 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=27z00h2amcGLVyvGSXkua/4UQf6K5QChGaE8Mh9kIe8=; b=fITg51/vZgqOu+QD307Z22d0Oo1y9R6sXXSHUKMImPpV377JPGoD1IB+PH9ucd0AhlGKk9MGi5Hicbs6L7e4ngl9vxv24AlAlvTxfqMy4iCHEI/+RJoNjXamli/oa/ktoJpfNiTlJ3allJi7k9OjsjCJv0le+RDjB0qFMhrBS0Y= 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 DM6PR12MB3276.namprd12.prod.outlook.com (2603:10b6:5:15e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.24; Thu, 29 Oct 2020 14:18:26 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::e442:c052:8a2c:5fba]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::e442:c052:8a2c:5fba%6]) with mapi id 15.20.3499.027; Thu, 29 Oct 2020 14:18:26 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io CC: Brijesh Singh , Michael D Kinney , Liming Gao , Zhiguang Liu Subject: [PATCH v3 01/11] MdePkg: Clean up GHCB field offsets and save area Date: Thu, 29 Oct 2020 09:17:52 -0500 Message-ID: <11164899a8f43cfb79beb98e113141c14f0c2240.1603981082.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR07CA0113.namprd07.prod.outlook.com (2603:10b6:4:ae::42) 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 DM5PR07CA0113.namprd07.prod.outlook.com (2603:10b6:4:ae::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Thu, 29 Oct 2020 14:18:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 099012ac-d1c2-4742-3dac-08d87c15804b X-MS-TrafficTypeDiagnostic: DM6PR12MB3276: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GkU9G0m20iQnxWSUjMUQqSNE6TF1/1iBXZaLISlbHgVan0yhvWJDf5ZFYwyZMoO0JYG7V9xt9+NzmHSnwxP4AwgTRcTL1Aq4dObB0EUNhRfqWpWhZml4wWjPMDlFNna1P8cos6wQXnjIttwKSBItIG8L0uZ/NDJhh4iQ1qSPHs+KV8ZhaNLCZzlg38do+QPSCl7Iab74KJINeNMjwyDBIrDBsV0o6BTu64TXPrzVLrZgk+o19g6RgZO6Nt6ySf5gyYyp2fGiVqqHW3b0YTEnLcTP/Mw+nrW9H5OMU+ZR+HxyKTfgpIL5LmnZkO9oXIneKfiJJH9WqoEiegKIqb1fvk9YcrYI8zLgWQ05oWUxEz6eqMe40jc0ml8/4XOCW/BFJ6Igu+SWfWAUXAE7OHeo3w== 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;SFS:(4636009)(39860400002)(396003)(376002)(136003)(346002)(366004)(26005)(8676002)(186003)(16526019)(4326008)(86362001)(6486002)(83380400001)(7696005)(52116002)(54906003)(66556008)(5660300002)(2906002)(6666004)(966005)(36756003)(2616005)(478600001)(316002)(6916009)(956004)(8936002)(66476007)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: FnK9wIJX6QOaAGJuHbYb5sgdLXTxk2rrk78vnP7tYqrX6URwpFa/h5jDaXq/KjNZOTXNTsxQoqWV7zYLE5CRPzKSxsa7rR+ClAKABoV3cT4F4MIeLHaLKYfISSK9J+Dw9HfPlzjbN6mSnlBRASsfe49aZM6OX0TVtQ0Hf5le3tmOocaRHKW/PuvyTDqMQBNvadsEUx+3DMMczXQYbCFTLkhmgrkvaZrJOjaZ+CcZGT17kZ+VnjEB3CV9PgQ1aIjqCqZ+YZYl1uxBH+2XLdbSA2Z8KBCO5Y47/En1uzlwhaCumvRlTwaSRbvmtw14s2x7qq76cCknqFiByLPaRrdi/Fi4zFSS+xQBbY2Ek2HXlrWh61/tqjD3IVtmtdw84OYUwcaTaW1U0Oj1Y53t3LUc2Vsv92A2mwe8TvIwHMY7Hc02ixVWpnVvgfddHtysLQh/JUwUk2iQ+EO0uIXKw0XLkfwMnMPY+cHkj+pUvh+7z3LZEe1kwUW9WIcJ3EBBgmlyb7RoVK+ctKUHl54UP9kyG8eTZZJeQma1WtKlviY1JRyYh4tZChiHi/9QrITK2HwywMgNyztl7D4+lcNWHjlgKoi5A3hyp+89OvBVcq3mpTOIUvrbEF3lFefm9Skuu7ynqLFHssFKPc3oh/opokIQNA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 099012ac-d1c2-4742-3dac-08d87c15804b X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2020 14:18:26.3016 (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: VvIkqIQ4iJsekGYbHv6hD01EvyfA5YExkd7cwX3svz2M8Px2As5C7sGg245DH1EmXzY+P91I/KXfpwWMBzOV+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3276 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable From: Tom Lendacky BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3008 Use OFFSET_OF () and sizeof () to calculate the GHCB register field offsets instead of hardcoding the values in the GHCB_REGISTER enum. Define only fields that are used per the GHCB specification, which will result in removing some fields and adding others. Also, remove the DR7 field from the GHCB_SAVE_AREA structure since it is not used/defined in the GHCB specification and then rename the reserved fields as appropriate. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Tom Lendacky --- MdePkg/Include/Register/Amd/Ghcb.h | 40 +++++++------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/MdePkg/Include/Register/Amd/Ghcb.h b/MdePkg/Include/Register/A= md/Ghcb.h index 54a80da0f6d7..1fce64d5b7cd 100644 --- a/MdePkg/Include/Register/Amd/Ghcb.h +++ b/MdePkg/Include/Register/Amd/Ghcb.h @@ -82,35 +82,10 @@ #define IOIO_SEG_DS (BIT11 | BIT10) =20 =20 -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 PACKED struct { UINT8 Reserved1[203]; UINT8 Cpl; - UINT8 Reserved2[148]; - UINT64 Dr7; - UINT8 Reserved3[144]; + UINT8 Reserved8[300]; UINT64 Rax; UINT8 Reserved4[264]; UINT64 Rcx; @@ -136,6 +111,19 @@ typedef PACKED struct { UINT32 GhcbUsage; } GHCB; =20 +typedef enum { + GhcbCpl =3D OFFSET_OF (GHCB, SaveArea.Cpl) / sizeof (UINT64), + GhcbRax =3D OFFSET_OF (GHCB, SaveArea.Rax) / sizeof (UINT64), + GhcbRbx =3D OFFSET_OF (GHCB, SaveArea.Rbx) / sizeof (UINT64), + GhcbRcx =3D OFFSET_OF (GHCB, SaveArea.Rcx) / sizeof (UINT64), + GhcbRdx =3D OFFSET_OF (GHCB, SaveArea.Rdx) / sizeof (UINT64), + GhcbXCr0 =3D OFFSET_OF (GHCB, SaveArea.XCr0) / sizeof (UINT64), + GhcbSwExitCode =3D OFFSET_OF (GHCB, SaveArea.SwExitCode) / sizeof (UIN= T64), + GhcbSwExitInfo1 =3D OFFSET_OF (GHCB, SaveArea.SwExitInfo1) / sizeof (UI= NT64), + GhcbSwExitInfo2 =3D OFFSET_OF (GHCB, SaveArea.SwExitInfo2) / sizeof (UI= NT64), + GhcbSwScratch =3D OFFSET_OF (GHCB, SaveArea.SwScratch) / sizeof (UINT= 64), +} GHCB_REGISTER; + typedef union { struct { UINT32 Lower32Bits; --=20 2.28.0