From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.6954.1614564188148654180 for ; Sun, 28 Feb 2021 18:03:08 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=WTOIqwph; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: hao.a.wu@intel.com) IronPort-SDR: n6XTNX7cwpRG2iSfSPOfePAM+Va+QgEZ9wNrnkVZpRWGUKqge0UxzRc+P7oZ8zjmfslICZC4zK 1iEujBhr836g== X-IronPort-AV: E=McAfee;i="6000,8403,9909"; a="186446717" X-IronPort-AV: E=Sophos;i="5.81,214,1610438400"; d="scan'208";a="186446717" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2021 18:03:06 -0800 IronPort-SDR: r6vAv3lvycpmfyR235iN3tAdnCPyvCy4l31saQ7jq8iDOhW6Ve/77XPc1w3995WDxtpGKUlHj5 wFJIlnx5Ujfg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,214,1610438400"; d="scan'208";a="372772305" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by fmsmga007.fm.intel.com with ESMTP; 28 Feb 2021 18:03:06 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Sun, 28 Feb 2021 18:03:06 -0800 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Sun, 28 Feb 2021 18:03:05 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Sun, 28 Feb 2021 18:03:05 -0800 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.102) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Sun, 28 Feb 2021 18:03:05 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h1lD4vWqrQOI54FumRCbBm+Oz/uyaSyDNn2HI6J+v1IvRNtv0dw0kuom1D1LqXBs5NXlg3zwuiCYbcq1d96lAPMrggFmpUqMaUJ0O+MeAqdradpEmtzeZyXB5KGkhMaXtt8Jv4l6lVI2/v+hGGCCfHDTRgQZMUeEePsY+/MAfVnhDui5Lc5eo8pxBzMlhzh4f/gS+iAqzEkQWOlNelk2WbW9f1O3jFO8wbtfZO5eGZo7lLkMDfA5KnQNMFHyLKHXwYamXs/Yw41TVk8oJJaraxZoEY1qhuaNNHKfFHB5GsR9Z8fbHWu4N+SWXefGGuUBH7KjFnRxfBRwO04iphjnRA== 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=GYJFhmWsFlLdUNGV/l8wll07muXwWoW1ElDcuAwcw88=; b=JLzIDh21V0AK30usHhsvETcdRGnUI5kMel/vxXuPE0TA4Q0MMNxKXwZW9adCUw4SSasicD8GjfIUtmVOSH+TylQQFYPEZ/XB4dZUiAMerQrmF3oIEzCgeMw4mHewwp/PLjBTtXXJKkU3cP74sDnbGnM4OFgw6gxMigMJfVO4xUXahV1CELAl4fH9COFBwNVLaBjlanK8ey70NiJSu+SiqASdBGuRl4UsSisohXOqIWIHIvLAf5AIf5K/3YbqCU5HlVA2oIlmdAheEvTzosYVLxGZ/KZs6oeGx+u2u5nQkvECovFlipl+fZ/RE/SK0xJnstkpKqMowj9DjzaiNuDxvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GYJFhmWsFlLdUNGV/l8wll07muXwWoW1ElDcuAwcw88=; b=WTOIqwphEAXpIZ9yDqZw1Lz+gJDf+fV4ITe6DZMk9jrQcfzjV6ERku5Z905TxpvdMoqRaqsTgrUWrZTrElqtzOpHuwDqPaJ9IkmFRgUf/ggUzZ4pG3HVvPQTjSWGlPHdue7CLskV5vuM0PQjHwH5HP7yUGd+YIIVUNnFIoTxC5o= Received: from BN8PR11MB3666.namprd11.prod.outlook.com (2603:10b6:408:8c::19) by BN6PR11MB4018.namprd11.prod.outlook.com (2603:10b6:405:7a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Mon, 1 Mar 2021 02:03:04 +0000 Received: from BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::9d91:6348:53a9:cb20]) by BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::9d91:6348:53a9:cb20%7]) with mapi id 15.20.3890.023; Mon, 1 Mar 2021 02:03:04 +0000 From: "Wu, Hao A" To: Kun Qin , "devel@edk2.groups.io" CC: "Wang, Jian J" , Liming Gao Subject: Re: [PATCH v3 2/7] MdeModulePkg: VariableSmmRuntimeDxe: Added request unblock memory interface Thread-Topic: [PATCH v3 2/7] MdeModulePkg: VariableSmmRuntimeDxe: Added request unblock memory interface Thread-Index: AQHXDJIbbsky1fjHz0WrZHYjbJ4FGKpuZMOw Date: Mon, 1 Mar 2021 02:03:04 +0000 Message-ID: References: <20210226225158.1378-1-kun.q@outlook.com> In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: outlook.com; dkim=none (message not signed) header.d=none;outlook.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.218] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4ebffaef-6812-4c16-2d2c-08d8dc562650 x-ms-traffictypediagnostic: BN6PR11MB4018: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2733; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PR0qle6pwpOvPr4Paqq4sBUUZVo0SgPffye/TVgDL+HWq4JPTFlnekt1YxP/dqN8BAXwVAM+LfdgkmxiPorALnJTS0v2YqTjqp4T5LBH/fhKMhb+J/VTQZkRT+DRTxlgXx95zXSKYf0FnhFiuVdbTN7shHIKNYguV4Ag4Yz9/1IQ/uxYUCIzsfGR0dTMnYEMk9Vgi9FsMuSuy5bRTuf1QVeHPoHPyOdmPmzjnwZoUpINOA2eGR3KUeghNQGTuDkMP01EVlafe4972UH+9FvFcvk4e+2UO1xvoU25jexeMgy3c3fAKtE/BIWw8wp6f5aN+zbBbwNoZIoDlQ+SLv5SQ7dFtzoHHNk1Hj/+IxzpscYRJ2GDj0ul+MBfsjL2/GWqu595MU0eXfjhw0psU+/CeGOMxdiJthJGXmq/w+pDeOtpJwj7zwmdlepncjdFYPXtgTz9138Bww5UR0hGTvnrgndkcJwLn5MqrSi9ABt5b3jqQAlOka3rhLsN1zTQflBYWgEJ0bwXnto4GUdfTO0JBA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR11MB3666.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(376002)(346002)(39860400002)(396003)(136003)(6506007)(53546011)(76116006)(8936002)(26005)(71200400001)(66556008)(66476007)(66446008)(186003)(8676002)(55016002)(66946007)(64756008)(5660300002)(86362001)(4326008)(54906003)(7696005)(110136005)(316002)(9686003)(83380400001)(52536014)(2906002)(33656002)(478600001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?IW6aU5RxhMmDb9qDVO+7dVIk+lHme73rky67g6kfmkbxkQy84BPe/GGkxjdK?= =?us-ascii?Q?O2/d0czZ5A5I7lDo9Is41/LSXv8YpLthyddVWUakPTpQ8XxmMdnDpgCv4OUg?= =?us-ascii?Q?VJGsePnPb6piVpPO8XsTA8rAxNUJQsMzEG85ZIaeYW2x6O9ixXLBRGLFC+vb?= =?us-ascii?Q?FaxJwscDGUtciTUZqcmFQbkw8KIsZfYu4htFsKKObbM3BQy/7tRX+NzRoaWd?= =?us-ascii?Q?/XRFyO+lu51wGIEdD2taBDwnsW6NOp55Fr+Sf/DDsILMi/fcZ8G8wSnnc/Aw?= =?us-ascii?Q?XshmEK2UkUBb1ApgEsNmpFk61c91tcCWF4kHD5APnAGCeyJFPF8iitfe6ju2?= =?us-ascii?Q?PriTjw5lgywUnazRsYKTfomPccH6JJVTIGmHO/U3ApozW95Rx5kwn40oi/Lq?= =?us-ascii?Q?tUGWe00NdsjwApXVCbJYSCIT9AkCcx7fa+o+2pZrf+6AsMaGssXb0z0gapJj?= =?us-ascii?Q?nn3fZxP0zfLNQTDxxmfMNrycfz28dPrAUZHr83HBtuQQN08wQsUJtShq4qNV?= =?us-ascii?Q?aRx+RteG3P0W2Rw9jYU8hGqsR2B2nrby3qzjvfpLv6d28M6pKCfKP+vIcTpV?= =?us-ascii?Q?AjVGO89LOWAsvWljuq6vGWW8882Np6CHloY6lleBNTiwzJMTxUmGxdlV3QfP?= =?us-ascii?Q?HlWt0oicdWmP7rIev/NBg1DCSIufOg1nJ/cpBNWQgF6oxRj1gmUA2ee2dMXA?= =?us-ascii?Q?oqVvwV7aB3wQrNmajCJIY6pQv1zqpODS1Q4QDEH4Q3AFqJK+Njndq8S9Fsc+?= =?us-ascii?Q?zJsYvVi+UZ1hpHWkLWnyHMt0QPZ7vq9QQ+qVewm40QxsQN9Li6rpVVQ0F79g?= =?us-ascii?Q?UrIKV8n/XRx+65doMyPh4y6HuYqel5XS6kORm+9yets4qNgTL/8cPP2QniIV?= =?us-ascii?Q?HntcRNTWbFmYzF5rQWExsQxWpqUjGphwPxPYbUjS5b0QUII7eyr4Frewb+g8?= =?us-ascii?Q?E0Sx/DtABIZ7Sfmox7L3nY8DL2e6r5ednTMErMA/YRkQ/5Z/7vsP/1JFUSxo?= =?us-ascii?Q?dMczmhmU8sahLs7APzfXErovpeyr/ak1b0sSDcH7AdH/BoLf/ZTXNuuLlcNL?= =?us-ascii?Q?JalTYGlGVG51GZTIwzfRmCZMI+OASY9c1HptKIo7DfXuMrzGVsk4J99lkz+6?= =?us-ascii?Q?p40R6AQCYJLed5G97SQaC6a/XllhouhfW8G15MTjbqY0vlLV/U4okN7j7mZk?= =?us-ascii?Q?8amPsme8+rbK42A6HmhXI/tQtFYGstZYFrQWjEvD5tiPWIrG/isQB6Rr/VL2?= =?us-ascii?Q?7OiYqxyjxciQJprfdXAeLiyOIECzMSN9xJXEqB41/G240KG045K60F+2WF+E?= =?us-ascii?Q?z44GUT7Lc3Usmbhsq48m1UDA?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN8PR11MB3666.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ebffaef-6812-4c16-2d2c-08d8dc562650 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Mar 2021 02:03:04.0522 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Sj/00ZxRF/wqdSAwDweFp6ctyPj69rL0YFLDtZ2X0q35uorsNYj1M90PZYdTpvhNNHXMYwz0k/l2XzDx+/xUnA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB4018 Return-Path: hao.a.wu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Kun Qin > Sent: Saturday, February 27, 2021 6:52 AM > To: devel@edk2.groups.io > Cc: Wang, Jian J ; Wu, Hao A ; > Liming Gao > Subject: [PATCH v3 2/7] MdeModulePkg: VariableSmmRuntimeDxe: Added > request unblock memory interface >=20 > This changes added usage of MmUnblockMemoryLib 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 in= side > MM. >=20 > Cc: Jian J Wang > Cc: Hao A Wu > Cc: Liming Gao >=20 > Signed-off-by: Kun Qin > --- >=20 > Notes: > v3: > - Removed Dxe prefix to match interface change. [Jiewen] >=20 > v2: > - Newly added in v2. >=20 >=20 > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe. > c | 42 ++++++++++++++++++++ > MdeModulePkg/MdeModulePkg.dsc | = 1 + >=20 > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.i > nf | 1 + > 3 files changed, 44 insertions(+) >=20 > diff --git > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > e.c > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > e.c > index c47e614d81f4..a166d284dfe4 100644 > --- > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > e.c > +++ > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > e.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 MmUnblockMemoryRequest ( > + (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, > (UINT32) 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 > + environment // These fields "should" be all on the same page, but just= to > be on the safe side... > + // > + Status =3D MmUnblockMemoryRequest ( > + (EFI_PHYSICAL_ADDRESS) ALIGN_VALUE ((UINTN) > SmmRuntimeVarCacheContext->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 MmUnblockMemoryRequest ( > + (EFI_PHYSICAL_ADDRESS) ALIGN_VALUE ((UINTN) > SmmRuntimeVarCacheContext->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 MmUnblockMemoryRequest ( > + (EFI_PHYSICAL_ADDRESS) ALIGN_VALUE ((UINTN) > SmmRuntimeVarCacheContext->HobFlushComplete - EFI_PAGE_SIZE + 1, > EFI_PAGE_SIZE), > + EFI_SIZE_TO_PAGES (sizeof(mHobFlushComplete)) > + ); > + if (Status !=3D EFI_UNSUPPORTED && EFI_ERROR (Status)) { > + goto Done; > + } > + Reviewed-by: Hao A Wu Best Regards, Hao Wu > // > // Send data to SMM. > // > diff --git a/MdeModulePkg/MdeModulePkg.dsc > b/MdeModulePkg/MdeModulePkg.dsc index 7ca4a1bb3080..9272da89a998 > 100644 > --- a/MdeModulePkg/MdeModulePkg.dsc > +++ b/MdeModulePkg/MdeModulePkg.dsc > @@ -100,6 +100,7 @@ [LibraryClasses] > SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf >=20 > DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLi > bGraphics/DisplayUpdateProgressLibGraphics.inf >=20 > VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/Va > riablePolicyHelperLib.inf > + > + > MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblo > ckMemoryLi > + bNull.inf >=20 > [LibraryClasses.EBC.PEIM] > IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf > diff --git > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > e.inf > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > e.inf > index b6dbc839e023..a0d8b2267e92 100644 > --- > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > e.inf > +++ > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > e.i > +++ nf > @@ -60,6 +60,7 @@ [LibraryClasses] > TpmMeasurementLib > SafeIntLib > PcdLib > + MmUnblockMemoryLib >=20 > [Protocols] > gEfiVariableWriteArchProtocolGuid ## PRODUCES > -- > 2.30.0.windows.1