From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (NAM04-MW2-obe.outbound.protection.outlook.com [40.107.101.40]) by mx.groups.io with SMTP id smtpd.web10.2519.1686031686065729651 for ; Mon, 05 Jun 2023 23:08:06 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=o1CKGU7W; 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.101.40, mailfrom: abdullateef.attar@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I/wWgcsl27vqW5GDSRtFQu3SaRHVavnv88vN1FUGEkzoFrUJ3ndhgOplq+ghqEfs8kn29mdXwCeZO968lJUP5eU7wgkG3GMMKvmdhBF1b+rsvx7slMkxW1HpBwDisIrwKU7dqTAVDs6zLFfkPbZyKJ/+Q2BML+5X41yEOW7HcOl6TF6Zf2F44Gt/4t0ooe3j5cU8AnZnrz27kslLDyBrxxe/malhBj/RZYaULMZD1FxV3Uc16JE/yqI8oQubq1eg1NC3xXYXHPhcZ0lnWKdcm1L2akR89NtMk8b2ThWR3PR6VMHlEZVhLy+mQgtyeAhnPMf0nvcMbKictjpnlqsu0A== 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=QDXgL6MHNoNt7wAXPNBPz+euTUg2vW6RY3LtIry1kuM=; b=IRIGCmXCq7USiPqI/2RjHjB75xJYrmXXITChvyp9Nz5qyGoOJLV0C7WmGrVJVHTnrAjMnyp5XN8UFczVLR0KiqYXEEVWg08CMGdmasKLgCuJmRNUuxTVvfOTpEkH+tzdhNHR/PkzXbz+FSZ3Osyf44AEbMQaggbmwuRB14uBHB5Af2kjdsKk7IpoKE6STITB+cvKq7UDQtxl+0ZkhEJVMCoxk1oeSHBtuo8ebBSMXtce3xGolXCrbTcO1xaV+ZYNZaLiuD6vPBZ8imeuHy5lhCg9I0IYnfZN6baUX9fZpptd/cmnvpzOAaZf34rAHeVzV2ZhFnGYO/PV/AfvDRiqJA== 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=QDXgL6MHNoNt7wAXPNBPz+euTUg2vW6RY3LtIry1kuM=; b=o1CKGU7Wts3MLNveCo/v8YVrx35oedtxsk3R1f1RgUM999uN7yRb54vvN3qLyEg4Zwdq/uWCKOoA9lFNdHET2fQiaUBqqIw7XXZ52rf8xzSJX/KM7VEEtBiHi4YEouHwP03svwOKBnXILTN2m73EkE6WH6blrfHh/ptD02XZtSg= Received: from CY5PR19CA0044.namprd19.prod.outlook.com (2603:10b6:930:1a::24) by SJ1PR12MB6145.namprd12.prod.outlook.com (2603:10b6:a03:45c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.27; Tue, 6 Jun 2023 06:08:03 +0000 Received: from CY4PEPF0000EE38.namprd03.prod.outlook.com (2603:10b6:930:1a:cafe::b7) by CY5PR19CA0044.outlook.office365.com (2603:10b6:930:1a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33 via Frontend Transport; Tue, 6 Jun 2023 06:08:02 +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 CY4PEPF0000EE38.mail.protection.outlook.com (10.167.242.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6477.13 via Frontend Transport; Tue, 6 Jun 2023 06:08:02 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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; Tue, 6 Jun 2023 01:08:00 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 6 Jun 2023 01:07:59 -0500 Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 6 Jun 2023 01:07:39 -0500 From: "Abdul Lateef Attar" To: CC: Abdul Lateef Attar , Paul Grimes , Abner Chang , Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [PATCH v14 2/8] UefiCpuPkg: Adds MmSaveStateLib library class Date: Tue, 6 Jun 2023 11:37:22 +0530 Message-ID: <442cd1545e038e71730c760d3df0560e921a4d2a.1686030945.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: CY4PEPF0000EE38:EE_|SJ1PR12MB6145:EE_ X-MS-Office365-Filtering-Correlation-Id: 887a7aad-e657-40c3-259c-08db665462ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rjO0uR1cRAmZ+c20vefny2GYBtXr0uPbKo//d3AzyM61ag85IZD3lzUEkDhmWRrHROoJhD12s6KuQIeyD6K6rtt/9bxeI0FYNKxac/3CqArsS+EgmgV4jCYfbXyL0O7F9UKuxbQVrLqehTPyEq3CF8r0KcXCr6ZklU39zvdE0A1Pd8pE3pPhnuH9F5c4tDngv56g0Dc0I/9fUniLtRmzIF5fAt/5/fCzK88/0wnLx7qodkdh6zG8ZxsirWDsa/BHPkAzyGguRHVQSdnl5tsro+4A8B8YXGsJHP23gFAaqzkJg3ZUzzkyzLX59g6oAyHGVHcXza4tG8mUnDnmCGqMfVLV3puWtfnKND+ZrMMHPuiFa5WcGEgt17a6k/2Fx5XwaBCb9szB276ucMWvrez0BZgNyEUhzQHvstMQ/i+glSxcMqHpyLjn1kR31EFpSzqhuy60kd0IPqLkkPPmABDoSnmUa2vPOMkQvA+p1ga/zjf2Pjuphh2pNNxztGP2JRmGjGnLIvweCr8NKD6UtiWVte2P+PqV55StQd0k5wxQgHM+JBB///pUT9byOi86JGlaUHYxUn15JPkPkFWqqXkS+VEj+/W1vpz7kGMCGHTVQlFd4/76yw6KOPDkuqLzERunHVd5XAxLJJvOA6t9Pxe+HMqfOW6EjpBU/yMA9c7Lvq2ymabrYbak0mQhULiK1yJPsB31Cl4ZFILkd9vF53me+kocmkiRzi8kJ3by0KCiGvUE8ViKKnJkj2C83M3RqETt 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)(6029001)(4636009)(396003)(346002)(376002)(39860400002)(136003)(451199021)(46966006)(40470700004)(36840700001)(47076005)(2616005)(26005)(41300700001)(966005)(7696005)(6666004)(336012)(186003)(426003)(36860700001)(40460700003)(478600001)(2906002)(54906003)(40480700001)(6916009)(81166007)(82310400005)(82740400003)(356005)(70206006)(316002)(70586007)(5660300002)(8936002)(4326008)(8676002)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 06:08:02.0829 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 887a7aad-e657-40c3-259c-08db665462ae 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: CY4PEPF0000EE38.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6145 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4182 Adds MmSaveStateLib Library class in UefiCpuPkg.dec. Adds function declaration header file. Cc: Paul Grimes Cc: Abner Chang Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Signed-off-by: Abdul Lateef Attar Reviewed-by: Abner Chang Reviewed-by: Ray Ni --- UefiCpuPkg/UefiCpuPkg.dec | 4 ++ UefiCpuPkg/Include/Library/MmSaveStateLib.h | 74 +++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 UefiCpuPkg/Include/Library/MmSaveStateLib.h diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec index d31c3b127c0b..1f1b10e702bf 100644 --- a/UefiCpuPkg/UefiCpuPkg.dec +++ b/UefiCpuPkg/UefiCpuPkg.dec @@ -2,6 +2,7 @@ # This Package provides UEFI compatible CPU modules and libraries. # # Copyright (c) 2007 - 2023, Intel Corporation. All rights reserved.
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -60,6 +61,9 @@ [LibraryClasses.IA32, LibraryClasses.X64] ## @libraryclass Provides function for manipulating x86 paging structu= res. CpuPageTableLib|Include/Library/CpuPageTableLib.h =20 + ## @libraryclass Provides functions for manipulating smram savestate r= egisters. + MmSaveStateLib|Include/Library/MmSaveStateLib.h + [Guids] gUefiCpuPkgTokenSpaceGuid =3D { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa,= 0xb8, 0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }} gMsegSmramGuid =3D { 0x5802bce4, 0xeeee, 0x4e33, { 0xa1,= 0x30, 0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }} diff --git a/UefiCpuPkg/Include/Library/MmSaveStateLib.h b/UefiCpuPkg/Inclu= de/Library/MmSaveStateLib.h new file mode 100644 index 000000000000..db4552e4a809 --- /dev/null +++ b/UefiCpuPkg/Include/Library/MmSaveStateLib.h @@ -0,0 +1,74 @@ +/** @file +Library that provides service to read/write CPU specific smram save state = registers. + +Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+ +@note + SaveState(Read/Write) of EFI_SMM_SAVE_STATE_REGISTER_PROCESSOR_ID/EFI_MM= _SAVE_STATE_REGISTER_PROCESSOR_ID + is handled by PiSmmCpuDxeSmm driver. + +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef MM_SAVE_STATE_LIB_H_ +#define MM_SAVE_STATE_LIB_H_ + +#include +#include + +/** + Read a save state register on the target processor. If this function + returns EFI_UNSUPPORTED, then the caller is responsible for reading the + MM Save State register. + + @param[in] CpuIndex The index of the CPU to read the Save State regist= er. + The value must be between 0 and the NumberOfCpus f= ield in + the System Management System Table (SMST). + @param[in] Register The MM Save State register to read. + @param[in] Width The number of bytes to read from the CPU save stat= e. + @param[out] Buffer Upon return, this holds the CPU register value rea= d + from the save state. + + @retval EFI_SUCCESS The register was read from Save State. + @retval EFI_INVALID_PARAMTER Buffer is NULL. + @retval EFI_UNSUPPORTED This function does not support reading Reg= ister. + @retval EFI_NOT_FOUND If desired Register not found. +**/ +EFI_STATUS +EFIAPI +MmSaveStateReadRegister ( + IN UINTN CpuIndex, + IN EFI_MM_SAVE_STATE_REGISTER Register, + IN UINTN Width, + OUT VOID *Buffer + ); + +/** + Writes a save state register on the target processor. If this function + returns EFI_UNSUPPORTED, then the caller is responsible for writing the + MM save state register. + + @param[in] CpuIndex The index of the CPU to write the MM Save State. T= he + value must be between 0 and the NumberOfCpus field = in + the System Management System Table (SMST). + @param[in] Register The MM Save State register to write. + @param[in] Width The number of bytes to write to the CPU save state. + @param[in] Buffer Upon entry, this holds the new CPU register value. + + @retval EFI_SUCCESS The register was written to Save State. + @retval EFI_INVALID_PARAMTER Buffer is NULL. + @retval EFI_UNSUPPORTED This function does not support writing Reg= ister. + @retval EFI_NOT_FOUND If desired Register not found. +**/ +EFI_STATUS +EFIAPI +MmSaveStateWriteRegister ( + IN UINTN CpuIndex, + IN EFI_MM_SAVE_STATE_REGISTER Register, + IN UINTN Width, + IN CONST VOID *Buffer + ); + +#endif --=20 2.25.1