From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (NAM02-BN1-obe.outbound.protection.outlook.com [40.107.212.84]) by mx.groups.io with SMTP id smtpd.web11.41292.1681125002541238413 for ; Mon, 10 Apr 2023 04:10:02 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=l5MwnaDu; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.212.84, mailfrom: abdullateef.attar@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Km2jNGdlf0ztk+7YjuvPAfklmYeNmHV1GPHpsQ5f1LYqfR4XI4os9e7ffTO5M0QLG0jgAnItRMnqP0Ek9S4FlBxruMgk8tpcetF2JGeOyCTijMIXgAxyJJll7fN+lV6UDNdZNXKrcvwRJmPxQHdNMiQtia83unYCjY9tB4jpUfi9rQDj4vrqUh5rMAzT/NjLwbVdr3487/qIyis2E0kfa3P2in3wXMn/AsHdx/CV6as3yOAqlfB4w07nrF3ftGz/dYbjNOtFnZNgduVWYvrDRwFoAgMQ6wMZ3U1Ro6fLzGbMb7k+UrcxE7xYUAoDhzBPIk3gdwxCsgUykEG+jZVgBA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7MHv8Guk/K4Qz8IzY06sLtdJunqLa9gdRvB84PcfIO0=; b=Il+vApvwdIvK4lPJkAFqClziGjWdgvCEBWLQ5sICFyL+jxp7AysPShE3pFTF/qpFOoYsfHOrx6k7yrUd84Sj6q05t4hgFlh7iExLNdAXz2RK+xHi6jPPXPXckGRJkqfbkBPzF/zYe598vYqqZgilNOb9P3M6hTC4jnv/oR6oxUENZaguS0wQ7orcOY40NcxvuK1gr/0Q3PYZ12KvZRm/l+V4KbAhqAdL/pMczpdX4103l7H5rYzMDoZ25QvhlTjRuL4jqJfnboG7vF/UkuE1d9UJafgdBsiHa7t3TrY1tg1cHQ4YVKmX3LOdtbhpghmJvmGzYcy4KgWtGpVuqyNuaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7MHv8Guk/K4Qz8IzY06sLtdJunqLa9gdRvB84PcfIO0=; b=l5MwnaDuGykuJ3Sgn+Nlit4l5bt/2jkS/AZhNQt6TKq8ULATUU7gKqij57fuxGgePYZCwxsV1EEePcaaGdN2n9mlyjEkM9KV8bVVqOlBmtGSi3LLg+SmzfzR0iMMBTHETm0VoONC1tDVnSfeVmhCGPypGIzX9sjisJr6F/Etjsg= Received: from BN9PR03CA0305.namprd03.prod.outlook.com (2603:10b6:408:112::10) by CH3PR12MB8459.namprd12.prod.outlook.com (2603:10b6:610:139::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.31; Mon, 10 Apr 2023 11:10:00 +0000 Received: from BN8NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:408:112::4) by BN9PR03CA0305.outlook.office365.com (2603:10b6:408:112::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38 via Frontend Transport; Mon, 10 Apr 2023 11:09:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT023.mail.protection.outlook.com (10.13.177.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.20 via Frontend Transport; Mon, 10 Apr 2023 11:09:59 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 10 Apr 2023 06:09:59 -0500 Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 10 Apr 2023 06:09:56 -0500 From: "Abdul Lateef Attar" To: CC: Abdul Lateef Attar , Paul Grimes , Garrett Kirkendall , Abner Chang , Michael D Kinney , "Liming Gao" , Zhiguang Liu Subject: [PATCH v8 1/9] MdePkg: Adds AMD SMRAM save state map Date: Mon, 10 Apr 2023 16:39:40 +0530 Message-ID: <665ff9065d1aae3f0c5a6026effa65601ba2bc04.1681121324.git.abdattar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Return-Path: AbdulLateef.Attar@amd.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT023:EE_|CH3PR12MB8459:EE_ X-MS-Office365-Filtering-Correlation-Id: a3b85427-049a-4488-645d-08db39b42022 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y5GaS6WxJluyKd8BJk/5G96H5M9R/19MsEaTn9FD1G+h6UGgCd94JjZDJVEXHLwzAZSs5HMXGYh3WcyJqSwHu1K8JFMpgK72sARMElodHqpnmvXPCd+OZa9orSLKWarjsv2KS+yB1dTE6wCNSFbJB3dc+ZDfM+RExhW5D6STSeKyBds8KRzuZFBkQF8kBt4XwcgYhblcO56E0mqVgLhw6LLJlB0PP8Zjc2S4dOGAAWXysQ+/iY3wK8JcaZcRHrWjftMmpmcmgFRdx8TBHJdOYLnhz/E9zGN8u+nOcbp1fFLhYH+3YOYNd27vODEbIdt/CEEn1advECzpB9tJDDXVUhFTGXhbQgnrTI1bvjEBwvsJpRuzqZYzjUlyCDt3zc23dGq2UfAWBUA0Y2gRzstiUnqMcwrsebAzdOYvmg9quuQ73v8ycTG/judfXgo59G+8Tqbg5/w/v5suSzAWKTlXp4OhSht2eJGtGRlplWHUyIqRi+QoQoTF9dmLYx57Xx9KVesjqXRfirdjFP8f+SgFdFDPss540Y04+mTPDwZ/kWHEKRDlusUymTPAVVDWa4xDCFsoypW63fqpYOOq/K0kJ0NKQ7raGtJxuZ0wkJb7+XjmHbgU38DvHc/C0aMlvWTTvl+TjTc7mTIGpjnTz4JyiYA/AYGKfoyM6GLs8ac9ufAlIF0EMrmmsotQrjFFmha245enDS5SXND3lxpjxiLbDkWOfXoKkP5wlQVkP7zFF5o= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(39860400002)(376002)(396003)(346002)(451199021)(36840700001)(46966006)(40470700004)(36860700001)(81166007)(36756003)(40460700003)(2906002)(5660300002)(8936002)(40480700001)(82310400005)(356005)(70206006)(41300700001)(8676002)(6916009)(70586007)(4326008)(426003)(2616005)(83380400001)(966005)(82740400003)(47076005)(336012)(316002)(26005)(54906003)(478600001)(6666004)(7696005)(186003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2023 11:09:59.8609 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a3b85427-049a-4488-645d-08db39b42022 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8459 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4182 Adds an SMM SMRAM save-state map for AMD processors. SMRAM save state maps for the AMD processor family are now supported. Save state map structure is added based on AMD64 Architecture Programmer's Manual, Volume 2, Section 10.2. The AMD legacy save state map for 32-bit architecture is defined. The AMD64 save state map for 64-bit architecture is defined.=C2=A0 Also added Amd/SmramSaveStateMap.h to IgnoreFiles of EccCheck, because structures defined in this file are derived from Intel/SmramSaveStateMap.h. Cc: Paul Grimes Cc: Garrett Kirkendall Cc: Abner Chang Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Abdul Lateef Attar Reviewed-by: Abner Chang Reviewed-by: Michael D Kinney --- .../Include/Register/Amd/SmramSaveStateMap.h | 194 ++++++++++++++++++ MdePkg/MdePkg.ci.yaml | 4 +- 2 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 MdePkg/Include/Register/Amd/SmramSaveStateMap.h diff --git a/MdePkg/Include/Register/Amd/SmramSaveStateMap.h b/MdePkg/Inclu= de/Register/Amd/SmramSaveStateMap.h new file mode 100644 index 000000000000..0607d2a19145 --- /dev/null +++ b/MdePkg/Include/Register/Amd/SmramSaveStateMap.h @@ -0,0 +1,194 @@ +/** @file + AMD SMRAM Save State Map Definitions. + + SMRAM Save State Map definitions based on contents of the + AMD64 Architecture Programmer Manual: + Volume 2, System Programming, Section 10.2 SMM Resources + + Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+ Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved . + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef AMD_SMRAM_SAVE_STATE_MAP_H_ +#define AMD_SMRAM_SAVE_STATE_MAP_H_ + +/// +/// Default SMBASE address +/// +#define SMM_DEFAULT_SMBASE 0x30000 + +/// +/// Offset of SMM handler from SMBASE +/// +#define SMM_HANDLER_OFFSET 0x8000 + +// SMM-Revision Identifier for AMD64 Architecture. +#define AMD_SMM_MIN_REV_ID_X64 0x30064 + +#pragma pack (1) + +/// +/// 32-bit SMRAM Save State Map +/// +typedef struct { + // Padded an extra 0x200 bytes to match Intel/EDK2 + UINT8 Reserved[0x200]; // fc00h + // AMD Save State area starts @ 0xfe00 + UINT8 Reserved1[0xf8]; // fe00h + UINT32 SMBASE; // fef8h + UINT32 SMMRevId; // fefch + UINT16 IORestart; // ff00h + UINT16 AutoHALTRestart; // ff02h + UINT8 Reserved2[0x84]; // ff04h + UINT32 GDTBase; // ff88h + UINT64 Reserved3; // ff8ch + UINT32 IDTBase; // ff94h + UINT8 Reserved4[0x10]; // ff98h + UINT32 _ES; // ffa8h + UINT32 _CS; // ffach + UINT32 _SS; // ffb0h + UINT32 _DS; // ffb4h + UINT32 _FS; // ffb8h + UINT32 _GS; // ffbch + UINT32 LDTBase; // ffc0h + UINT32 _TR; // ffc4h + UINT32 _DR7; // ffc8h + UINT32 _DR6; // ffcch + UINT32 _EAX; // ffd0h + UINT32 _ECX; // ffd4h + UINT32 _EDX; // ffd8h + UINT32 _EBX; // ffdch + UINT32 _ESP; // ffe0h + UINT32 _EBP; // ffe4h + UINT32 _ESI; // ffe8h + UINT32 _EDI; // ffech + UINT32 _EIP; // fff0h + UINT32 _EFLAGS; // fff4h + UINT32 _CR3; // fff8h + UINT32 _CR0; // fffch +} AMD_SMRAM_SAVE_STATE_MAP32; + +/// +/// 64-bit SMRAM Save State Map +/// +typedef struct { + // Padded an extra 0x200 bytes to match Intel/EDK2 + UINT8 Reserved[0x200]; // fc00h + // AMD Save State area starts @ 0xfe00 + UINT16 _ES; // fe00h + UINT16 _ESAttributes; // fe02h + UINT32 _ESLimit; // fe04h + UINT64 _ESBase; // fe08h + + UINT16 _CS; // fe10h + UINT16 _CSAttributes; // fe12h + UINT32 _CSLimit; // fe14h + UINT64 _CSBase; // fe18h + + UINT16 _SS; // fe20h + UINT16 _SSAttributes; // fe22h + UINT32 _SSLimit; // fe24h + UINT64 _SSBase; // fe28h + + UINT16 _DS; // fe30h + UINT16 _DSAttributes; // fe32h + UINT32 _DSLimit; // fe34h + UINT64 _DSBase; // fe38h + + UINT16 _FS; // fe40h + UINT16 _FSAttributes; // fe42h + UINT32 _FSLimit; // fe44h + UINT64 _FSBase; // fe48h + + UINT16 _GS; // fe50h + UINT16 _GSAttributes; // fe52h + UINT32 _GSLimit; // fe54h + UINT64 _GSBase; // fe58h + + UINT32 _GDTRReserved1; // fe60h + UINT16 _GDTRLimit; // fe64h + UINT16 _GDTRReserved2; // fe66h + // UINT64 _GDTRBase; // fe68h + UINT32 _GDTRBaseLoDword; + UINT32 _GDTRBaseHiDword; + + UINT16 _LDTR; // fe70h + UINT16 _LDTRAttributes; // fe72h + UINT32 _LDTRLimit; // fe74h + // UINT64 _LDTRBase; // fe78h + UINT32 _LDTRBaseLoDword; + UINT32 _LDTRBaseHiDword; + + UINT32 _IDTRReserved1; // fe80h + UINT16 _IDTRLimit; // fe84h + UINT16 _IDTRReserved2; // fe86h + // UINT64 _IDTRBase; // fe88h + UINT32 _IDTRBaseLoDword; + UINT32 _IDTRBaseHiDword; + + UINT16 _TR; // fe90h + UINT16 _TRAttributes; // fe92h + UINT32 _TRLimit; // fe94h + UINT64 _TRBase; // fe98h + + UINT64 IO_RIP; // fea0h + UINT64 IO_RCX; // fea8h + UINT64 IO_RSI; // feb0h + UINT64 IO_RDI; // feb8h + UINT32 IO_DWord; // fec0h + UINT8 Reserved1[0x04]; // fec4h + UINT8 IORestart; // fec8h + UINT8 AutoHALTRestart; // fec9h + UINT8 Reserved2[0x06]; // fecah + UINT64 EFER; // fed0h + UINT64 SVM_Guest; // fed8h + UINT64 SVM_GuestVMCB; // fee0h + UINT64 SVM_GuestVIntr; // fee8h + UINT8 Reserved3[0x0c]; // fef0h + UINT32 SMMRevId; // fefch + UINT32 SMBASE; // ff00h + UINT8 Reserved4[0x14]; // ff04h + UINT64 SSP; // ff18h + UINT64 SVM_GuestPAT; // ff20h + UINT64 SVM_HostEFER; // ff28h + UINT64 SVM_HostCR4; // ff30h + UINT64 SVM_HostCR3; // ff38h + UINT64 SVM_HostCR0; // ff40h + UINT64 _CR4; // ff48h + UINT64 _CR3; // ff50h + UINT64 _CR0; // ff58h + UINT64 _DR7; // ff60h + UINT64 _DR6; // ff68h + UINT64 _RFLAGS; // ff70h + UINT64 _RIP; // ff78h + UINT64 _R15; // ff80h + UINT64 _R14; // ff88h + UINT64 _R13; // ff90h + UINT64 _R12; // ff98h + UINT64 _R11; // ffa0h + UINT64 _R10; // ffa8h + UINT64 _R9; // ffb0h + UINT64 _R8; // ffb8h + UINT64 _RDI; // ffc0h + UINT64 _RSI; // ffc8h + UINT64 _RBP; // ffd0h + UINT64 _RSP; // ffd8h + UINT64 _RBX; // ffe0h + UINT64 _RDX; // ffe8h + UINT64 _RCX; // fff0h + UINT64 _RAX; // fff8h +} AMD_SMRAM_SAVE_STATE_MAP64; + +/// +/// Union of 32-bit and 64-bit SMRAM Save State Maps +/// +typedef union { + AMD_SMRAM_SAVE_STATE_MAP32 x86; + AMD_SMRAM_SAVE_STATE_MAP64 x64; +} AMD_SMRAM_SAVE_STATE_MAP; + +#pragma pack () + +#endif diff --git a/MdePkg/MdePkg.ci.yaml b/MdePkg/MdePkg.ci.yaml index 6ba85ebe6186..27772ab3be0a 100644 --- a/MdePkg/MdePkg.ci.yaml +++ b/MdePkg/MdePkg.ci.yaml @@ -5,6 +5,7 @@ # Copyright (c) 2020, Intel Corporation. All rights reserved.
# Copyright (c) 2021, Arm Limited. All rights reserved.
# Copyright (c) 2023, Loongson Technology Corporation Limited. All rights = reserved.
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent ## { @@ -67,7 +68,8 @@ "Include/Library/PcdLib.h", "Include/Library/SafeIntLib.h", "Include/Protocol/DebugSupport.h", - "Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.c" + "Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.c", + "Include/Register/Amd/SmramSaveStateMap.h" ] }, ## options defined ci/Plugin/CompilerPlugin --=20 2.25.1