From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.46]) by mx.groups.io with SMTP id smtpd.web10.2414.1682493806273198370 for ; Wed, 26 Apr 2023 00:23:26 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=lFqujZGf; 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.93.46, mailfrom: abdullateef.attar@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Iu5h8eXugrwE2QztDnpfIE0vF5oeNLHfgvxv6Jz8mwkR6I3IYMyNsKg/QFRNUyth1DgcUPvjTFas7kiTd2C1TDXeKA9z+hMx01vvfy+QA1pq6Wsgj3FmNUet4EPFpdFfnJgIhBYb4CBFWxESHTK/dHE6ERngOSRFVPGUTmmWrP6QueUmsuskwAVKdEYh+bPjRgvgRup7hRsR0xCGs1raSMCy8nsNJ4mnCZ4375Q2Fm3pfRbjymLqigEhnd0py3czlche8IOyhxtYnan/qczGj7Wb9N8CAc8MgRM09jX/Qn1JmsaSDhA0DOBiYkke/AfjEHmR4+iJa2u+1BgwvKxxYg== 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=IsOkiUfah9AXX0CRk2NZRZM7ACNM7pTduRpdLJRQceI=; b=lTjrCmV0/N4NTN5ORw4rR35UwkbmfDF7hM5JXezEulkn5iL218WU5icVTZPtN9TNaM/Nt87giUo/8KaedLEle9q9Lch09/AtklY6bsaol/TUV4FHe57Ch5x+VB93F29DpQ5QY0xhw+iJYeJEAg/HLhuDNW2slYvUk1n9wp1AIjlLc0WINHT2hVw10bex3vpTdCC5UWADuOEgYyES/9TtvjZcdFFz015c5I/+wwN7AQDvgwXzN+K+kXfs4hnj37NTPQQAYdwnU8cLRGmEFXota+aJwLGWk0TH3o2vtr7oAIZIcQaJtmror6dgmm6PmNgIbpZS6e40SRXSN7O4Qo8Etw== 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=IsOkiUfah9AXX0CRk2NZRZM7ACNM7pTduRpdLJRQceI=; b=lFqujZGfxZuPo1D3gtmcyhL8P8eyQoD1uG3cw70eSl+vPKt+ikP8OzsquR+DPnpIZBzTK4xKRBnbjexZ6WacEsQyLXO4TS1pq1tAwokafFG0Rjaf9qr+d0jxP+ohtGYz3Y64lpGdaXMGIGwR9y+7iwMdepsQoMwLkaUBwByRhko= Received: from DS7PR03CA0150.namprd03.prod.outlook.com (2603:10b6:5:3b4::35) by BN9PR12MB5382.namprd12.prod.outlook.com (2603:10b6:408:103::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.21; Wed, 26 Apr 2023 07:23:22 +0000 Received: from DM6NAM11FT110.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b4:cafe::d3) by DS7PR03CA0150.outlook.office365.com (2603:10b6:5:3b4::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.21 via Frontend Transport; Wed, 26 Apr 2023 07:23:21 +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 DM6NAM11FT110.mail.protection.outlook.com (10.13.173.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.21 via Frontend Transport; Wed, 26 Apr 2023 07:23:21 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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; Wed, 26 Apr 2023 02:22:50 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 26 Apr 2023 02:22:42 -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; Wed, 26 Apr 2023 02:22:39 -0500 From: "Abdul Lateef Attar" To: CC: Abdul Lateef Attar , Paul Grimes , Garrett Kirkendall , Abner Chang , Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [PATCH v9 2/9] UefiCpuPkg: Adds MmSaveStateLib library class Date: Wed, 26 Apr 2023 12:52:20 +0530 Message-ID: <5adc61dc8b14eaa0faff89104bf677bb4d3edb90.1682493282.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: DM6NAM11FT110:EE_|BN9PR12MB5382:EE_ X-MS-Office365-Filtering-Correlation-Id: b1f85507-fe41-4c19-0ab9-08db46271dae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I6dg5xgQYfs8CbxjhwkLgXPP7aZU1ik0eximA91vSt1DCHhyUnbgNlhInO+lpX+bICdcG+3NGcMy6RFeYZlrECQFnzkglWC7Rp8EQpRSGvQC/p6r3UEojtQmVqoBQysQXDG15hbyu2s3U2X5obljXUowGSA+Iv186ixO/RmqDcXLzn/KcckMCCtChfYgbyOsegO94YA/zlpAHOGEWfLJBxuyDXCsZeN8K6eX2C8fDWMGmqT0UcK2P0ZqDwynX48TuQDgKHO5vhqKULsH6pXO5oUaZPSrs6r+c/kGwPuKaNmJcJnUwdB/ihF0F1hjMtn6YjEnFMWMQx/xdfvA9hKcD5F0WLS1tlyRmke/nI/V9XXfLB15sLg8PA23EMCrJl31l91ueS26Dh+4/gwbt/Nbr58C8lmom4KFDaUFVbIjeOD5nfGb3s/4yAuQQ8eeH5SgHNfqYzUdebE2Y38lgn4Lbfa3uvzAikYO9MOc6K1UKkK1BOnPeY5dwfXCnT4Wx3bEffqS5rFxECbeBKp5aeAg1nGE66s9nSVUtOpaaCHf4z0JIUp3WPFmmEQYC+TFjh/nY3nDjOpUntdQQ1lTtVpesMqvS/rFddYFbXxmHsnjkFMAsHxCUzZ41pkFbvMt3EeIa8g6sZX2eyLwEA8LHPRO9sstykQU5ns/EA1q1+qgMOneyCIkJnPwJHNvyUP4D4UNFisyRHla7S/QKeN/dxGROrHo1JcpMDXPNTxPjaQ+/Ko= 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)(39860400002)(346002)(376002)(136003)(451199021)(46966006)(40470700004)(36840700001)(26005)(40460700003)(186003)(478600001)(54906003)(966005)(82310400005)(36756003)(7696005)(6666004)(5660300002)(8936002)(8676002)(2906002)(316002)(82740400003)(4326008)(6916009)(70206006)(70586007)(41300700001)(356005)(81166007)(40480700001)(2616005)(336012)(426003)(36860700001)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2023 07:23:21.7733 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1f85507-fe41-4c19-0ab9-08db46271dae 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: DM6NAM11FT110.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5382 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: Garrett Kirkendall 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 --- UefiCpuPkg/UefiCpuPkg.dec | 4 ++ UefiCpuPkg/Include/Library/MmSaveStateLib.h | 70 +++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 UefiCpuPkg/Include/Library/MmSaveStateLib.h diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec index a5528277ffb5..7218b59ecbe7 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..1c82facb6841 --- /dev/null +++ b/UefiCpuPkg/Include/Library/MmSaveStateLib.h @@ -0,0 +1,70 @@ +/** @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.
+ +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