From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web09.1449.1612920315066407278 for ; Tue, 09 Feb 2021 17:25:15 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=goVWSqty; spf=softfail (domain: outlook.com, ip: , mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IVkobGW8ELTzRAf4sMkgVThHZU7dQSh7SKG+OLHqLjbORnccSTZOHK15vh5u6bRgZZS0RQpVxZvxrVm3sXrlGlQJsKhgRmEKIYi1xAeW9KDfinFcllsiBS2nx8ZQVBlzTZ930JRJWVcIVy3YVLJhVnNXrWZ+s0ChHzrLcQmTy80wges+PB5rKXIZJFmcoquURY6eOTHuw4rDmI9vnwpmjaKv+j7kDQ+99idYlStnwznIJ+KPa+9cKeZzMrBB5Bs4AETIcLicNDAlmkzQu0pt19S92cikCAFhCEkzaBVcxOOCDJ3ZTMxL8GF+318HPduFX4zMVVEEa6vCKuQDjCQG4w== 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=rzjeWJbDxr6kE5D3cAQ1qBVqwr0Ga0Mv6/hFhPUGT50=; b=jcMMken+jcpjmVAZiHY3fabjCl87Hd+Zg8B4hSSBRiR2OnAaIdAjwXr4a26KUgLO0rhqKge1HpvXRb47L3ggcAg3HZEmOPWqI7FPj/10FgTTX5w6/Ai4cee15UN87+CUBWJoHf0+puZ6SVfFlm6hoQHf9lu16gktOlE7vK5QnIi0JuLtA2z9etP9S1q/SG58utVpBFvshEuUw9BymFSjwMuZhme27GD2wpNvJEtYKiC2AGicLxMpSi4RYuJmT1zOJM/l0brAGysc+++lGEB0PPXC6qVn1IdkVWYuoaCADuCC/dU2R87OE5npOm5GsyU5lNlSVGGsFL5+UJT/5O1rig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rzjeWJbDxr6kE5D3cAQ1qBVqwr0Ga0Mv6/hFhPUGT50=; b=goVWSqtyBH+61YhHD7H3W/mfZEToaZ/ENzfryYpgKHD62c2yF29dFNinE3vAQnTmkO+BS4o66DBbru/+SxJ5M+1ZE/gwLqAXdzzLTI5WYG1MOZ8LjKMcUUThJIktozGJnMFb0Ilnm8t5hfOc1nlxkCp53rqifqfFWZS9DaCzWtmPSlkF8grFoM+L1qnV7xn6CoKD8f3OnEHRkH+NixxMGYWPjepUgXmlFPW6mzqqPnHXlfL9brXf1JrRACUt/jpsCcunUJsg3RQIsXjxG3dJji1Ug6YagWGC8N6zkHy+yFFW09YSz336EkTBfoNx6e6C77MY0kcPtK2w0DfcH3b15Q== Received: from MW2NAM12FT030.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::43) by MW2NAM12HT110.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.11; Wed, 10 Feb 2021 01:25:14 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:fc65::4b) by MW2NAM12FT030.mail.protection.outlook.com (2a01:111:e400:fc65::278) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Wed, 10 Feb 2021 01:25:14 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:ACF284392F3971DF0C685249DF948BA968318668CB79CCEE6CE0CB29D757F714;UpperCasedChecksum:5D91F6A162D5DFAA4AE4323F83BB2FBA7550B1D93F00B9CF68B0BE393CFD02BF;SizeAsReceived:7457;Count:47 Received: from MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::d4ee:1260:6f53:3f7b]) by MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::d4ee:1260:6f53:3f7b%7]) with mapi id 15.20.3825.024; Wed, 10 Feb 2021 01:25:14 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Jian J Wang , Hao A Wu , Liming Gao Subject: [PATCH v2 2/6] MdeModulePkg: VariableSmmRuntimeDxe: Added request unblock memory interface Date: Tue, 9 Feb 2021 17:24:53 -0800 Message-ID: X-Mailer: git-send-email 2.30.0.windows.1 In-Reply-To: <20210210012457.315-1-kun.q@outlook.com> References: <20210210012457.315-1-kun.q@outlook.com> X-TMN: [HUQX+kx7pBom/aVtKa7wZIXvhawmLPsY] X-ClientProxiedBy: MW4PR04CA0051.namprd04.prod.outlook.com (2603:10b6:303:6a::26) To MWHPR06MB3102.namprd06.prod.outlook.com (2603:10b6:301:3e::35) Return-Path: kun.q@outlook.com X-Microsoft-Original-Message-ID: <20210210012457.315-3-kun.q@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (50.35.88.161) by MW4PR04CA0051.namprd04.prod.outlook.com (2603:10b6:303:6a::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.20 via Frontend Transport; Wed, 10 Feb 2021 01:25:13 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 89fec3d3-d995-4b56-5e8a-08d8cd62b73e X-MS-TrafficTypeDiagnostic: MW2NAM12HT110: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uHK+q8iqPizB1lg7zcraZOJqgxn260COWs9fayM2HyXdc+NdFAvdrqapdIGUk52P7uc00ZNPVYOki3EcN/ldiflLtqWirVST7RRass0pUPkTd6Up/ISLiCnJRC+hhZE0zq3RroXJE3sdk/3ov1j4rJY/Uz7GkshkRckb+HOvKmRNdYdhWEzbGF3fK4D/0e6Gj30gAKkLibtP7sBZgR7TcPIVHYq4Q3jAch/1Wi0W9w0Rp7kYuhekXrcZeYNfbi+CFPbQbVHA1K8A22XdIa4fBBNJeiaJNYTXYzVYJJPYKizOi3jsNp9AR0mj1bGuR5nbIt/tUJTWi36HxxkUpkDh5TPg+CqMWdHWmqokDt2KQu55KfJqw2Xk0RHiIi28fxWc/UOtTB5OlN7FIWO5AasEjQ== X-MS-Exchange-AntiSpam-MessageData: sJxx0sasTGSUDN2nCE4aHOCqTPifoBlt3oNO0CRSh+8HMiczBWWFTsfrTGragkgp/cyfFrVXcKIcyN6H94ryW5LyllRzCqi/9NAEL9RJTECD1BJ1uqAIW92BET8OH6QVoIJfTOqtDhFVUEUBs2D54Q== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89fec3d3-d995-4b56-5e8a-08d8cd62b73e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 01:25:14.0996 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: MW2NAM12FT030.eop-nam12.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2NAM12HT110 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain This changes added usage of DxeMmUnblockMemoryLib to explicitly request runtime cache regions(and its indicators) to be accessible from MM environment when PcdEnableVariableRuntimeCache is enabled. It will bring in compatibility with architectures that supports full memory blockage inside MM. Cc: Jian J Wang Cc: Hao A Wu Cc: Liming Gao Signed-off-by: Kun Qin --- Notes: v2: - Newly added in v2. MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c | 42 = ++++++++++++++++++++ MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf | 1 = + 2 files changed, 43 insertions(+) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeD= xe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c index c47e614d81f4..b96ca4b89ee4 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c @@ -35,6 +35,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include =20 #include #include @@ -165,6 +166,7 @@ InitVariableCache ( ) { VARIABLE_STORE_HEADER *VariableCacheStorePtr; + EFI_STATUS Status; =20 if (TotalVariableCacheSize =3D=3D NULL) { return EFI_INVALID_PARAMETER; @@ -186,6 +188,18 @@ InitVariableCache ( if (*VariableCacheBuffer =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } + + // + // Request to unblock the newly allocated cache region to be accessible = from inside MM + // + Status =3D DxeMmUnblockMemoryRequest ( + (EFI_PHYSICAL_ADDRESS) (UINTN) *VariableCacheBuffer, + EFI_SIZE_TO_PAGES (*TotalVariableCacheSize) + ); + if (Status !=3D EFI_UNSUPPORTED && EFI_ERROR (Status)) { + return Status; + } + VariableCacheStorePtr =3D *VariableCacheBuffer; SetMem32 ((VOID *) VariableCacheStorePtr, *TotalVariableCacheSize, (UINT= 32) 0xFFFFFFFF); =20 @@ -1536,6 +1550,34 @@ SendRuntimeVariableCacheContextToSmm ( SmmRuntimeVarCacheContext->ReadLock =3D &mVariableRuntimeCacheReadLock; SmmRuntimeVarCacheContext->HobFlushComplete =3D &mHobFlushComplete; =20 + // + // Request to unblock this region to be accessible from inside MM enviro= nment + // These fields "should" be all on the same page, but just to be on the = safe side... + // + Status =3D DxeMmUnblockMemoryRequest ( + (EFI_PHYSICAL_ADDRESS) ALIGN_VALUE ((UINTN) SmmRuntimeVarCache= Context->PendingUpdate - EFI_PAGE_SIZE + 1, EFI_PAGE_SIZE), + EFI_SIZE_TO_PAGES (sizeof(mVariableRuntimeCachePendingUpdate)) + ); + if (Status !=3D EFI_UNSUPPORTED && EFI_ERROR (Status)) { + goto Done; + } + + Status =3D DxeMmUnblockMemoryRequest ( + (EFI_PHYSICAL_ADDRESS) ALIGN_VALUE ((UINTN) SmmRuntimeVarCache= Context->ReadLock - EFI_PAGE_SIZE + 1, EFI_PAGE_SIZE), + EFI_SIZE_TO_PAGES (sizeof(mVariableRuntimeCacheReadLock)) + ); + if (Status !=3D EFI_UNSUPPORTED && EFI_ERROR (Status)) { + goto Done; + } + + Status =3D DxeMmUnblockMemoryRequest ( + (EFI_PHYSICAL_ADDRESS) ALIGN_VALUE ((UINTN) SmmRuntimeVarCache= Context->HobFlushComplete - EFI_PAGE_SIZE + 1, EFI_PAGE_SIZE), + EFI_SIZE_TO_PAGES (sizeof(mHobFlushComplete)) + ); + if (Status !=3D EFI_UNSUPPORTED && EFI_ERROR (Status)) { + goto Done; + } + // // Send data to SMM. // diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeD= xe.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.i= nf index b6dbc839e023..b84a407833c2 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf @@ -60,6 +60,7 @@ [LibraryClasses] TpmMeasurementLib SafeIntLib PcdLib + DxeMmUnblockMemoryLib =20 [Protocols] gEfiVariableWriteArchProtocolGuid ## PRODUCES --=20 2.30.0.windows.1