From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 2E053780453 for ; Thu, 21 Mar 2024 08:39:20 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=bmgyfBS6oqwnzzRZ7jlDyDBbHHEedDCwzGObrki7JbE=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1711010358; v=1; b=BcPBo3NmDS94K2QB7RNLHryLt4kR8cXVs/JhllxeTzgh04YInm6lya5yLitKYNpEo9DJHl+q mxgqrHb9FosnHKzOsgX7Z1VP/WrvlJ45uG8Dp5MAik72f+NSDvwPfcDKVNogZQ0zURrd1hETtBH zCi03r3geUUyxsCqFd9JFXQYskyNCzxTJhdVz9TfiRLhAH0uaEVG9hs2xZFMYbN0vC6oqT3HoQM O4LysbKHf18BFvKUw0NNVdkqJYMLWLJWuRSnl8ZR9zGzcBvhl8gKjsX3gVO4LBFVklSiy2En7Op PTZ7xAZ0894kmiRAXfamKVgCcrZTaJdocHQREUq6G6iwA== X-Received: by 127.0.0.2 with SMTP id 06L3YY7687511xMjYfHn80GK; Thu, 21 Mar 2024 01:39:18 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by mx.groups.io with SMTP id smtpd.web10.2521.1711010357922671161 for ; Thu, 21 Mar 2024 01:39:18 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,11019"; a="6593559" X-IronPort-AV: E=Sophos;i="6.07,142,1708416000"; d="scan'208";a="6593559" X-Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2024 01:39:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,142,1708416000"; d="scan'208";a="19152339" X-Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orviesa003.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 21 Mar 2024 01:39:18 -0700 X-Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 21 Mar 2024 01:39:16 -0700 X-Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 21 Mar 2024 01:39:16 -0700 X-Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Thu, 21 Mar 2024 01:39:16 -0700 X-Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.41) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 21 Mar 2024 01:39:16 -0700 X-Received: from IA0PR11MB8355.namprd11.prod.outlook.com (2603:10b6:208:480::14) by PH7PR11MB6649.namprd11.prod.outlook.com (2603:10b6:510:1a7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.11; Thu, 21 Mar 2024 08:39:13 +0000 X-Received: from IA0PR11MB8355.namprd11.prod.outlook.com ([fe80::d2f:72a5:6a4f:d7a8]) by IA0PR11MB8355.namprd11.prod.outlook.com ([fe80::d2f:72a5:6a4f:d7a8%3]) with mapi id 15.20.7409.010; Thu, 21 Mar 2024 08:39:13 +0000 From: "sunceping" To: "devel@edk2.groups.io" , "kraxel@redhat.com" CC: "Aktas, Erdem" , "Yao, Jiewen" , "Xu, Min M" , "Reshetova, Elena" , "Sun, CepingX" Subject: Re: [edk2-devel] [PATCH V1 1/1] OvmfPkg/QemuBootOrderLib: Measure the etc/boot-menu-wait Thread-Topic: [edk2-devel] [PATCH V1 1/1] OvmfPkg/QemuBootOrderLib: Measure the etc/boot-menu-wait Thread-Index: AQHadFI2hTrvbrZBC0u8PfZjHflJorEz8V0AgAFlYtCAAaUlgIAJRAbQgAAzcQCAAXE1oA== Date: Thu, 21 Mar 2024 08:39:13 +0000 Message-ID: References: <20240312235146.3777997-1-cepingx.sun@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: IA0PR11MB8355:EE_|PH7PR11MB6649:EE_ x-ms-office365-filtering-correlation-id: e21057ea-85cc-4729-8ff0-08dc49826324 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 9kOi4TGtMTx//Jyh8YkZQ2O5NNW2y887JDJRAFgaSqAgG3MXDwoxcscQIcA+QVtZZCQ7htuQiM6cySW1LozURgKsHKhNfMNltpLz9lGNBhf6q3jCxtKJZK14/vCgZcSoQkfb0puUGVhI2MhEq2KxBTvNcGy16quR+fgoDNzNEO1s1ZO47ZN+7sLqlPUGXda+Jlx95BhBXtuCfdocpXgFp6FaWXO0lzQD25kzjanrgLN4WSj8Zt3xR34cz9sTZoOVV2hhBP2kY05OHfDfbqUwaNO/Pfci64hIjqx/zAbgPLzZAD8nG6Yxv4QkNDqS59gD4IDyBxa4j8H395M3yI3kmY8smNtRT9aL41miJziKdk+Vjb4GHVTOpty2QrrS1TayNlUs5ROzkrb3oSKow5gDTgQ92CH3zhPNQyLN/oOp80XLYoXmYA75aHPfeSfLhCVYL9cbywRJegVK1P4iX+8bagnYjuFIp+87Lcb4WwAf+0C9guOIuMY+KFax8Z0UgjSECj3HA+7IIGC+TgWnSmx9f+x8nNI9vVzZopAODRK0Pgt/Kx01RHgbk1vFby18KTihxm8FK4CGm5I0I/E+7N7iA7Mr1KUhHhR8eFLoLkpnqLWvSsTPCX46EyAB0YeOFZZ+mTIpkVPrQq1hHZwNwUpK9RAieEWQsmOsRReT+/NRpiv420p7uu/i4pg2B2TKe016+g+XZU5IZWjpSe8tLLaG87/bBx/JiyzR8mOqQck86C8= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Upub44W9ID0onkJMuui/MDnR6MM2lo992WhvFy1b0088XdyGRwcLDAO7bZXI?= =?us-ascii?Q?rFKioL759rwxwLzoxJtuutYZPkkgw1Sj5EjVB7p3HX7pIGG44P92jt4rThrP?= =?us-ascii?Q?xRYSZDlr/Nz/BcWGGhvZSCdz3gySpbCd/aSPhk+NwtUn3VqkgDseGewjaQUO?= =?us-ascii?Q?q4MpYeQ5PQHPKw+170VPpbrWd0H8eoQ5Nnubyx6XiU9UNfhtyrzlN7UHxgSp?= =?us-ascii?Q?OIrha+fsuG+wVNUWUZtVzd1xsqlYAiJ3oQXA6pmwIqV2kzSSXw3QCet+lfUH?= =?us-ascii?Q?FNokh8ArCf0GyOfcp2AfeRF60c3jkur3A1kudX2gvNn8CH3JYdA1zEfBIBOt?= =?us-ascii?Q?p64OZrkgDJTUV5biA8OlqMxy0k9rfjHAbge33b8Lsl7qIwa1cCCxhn6pjqQU?= =?us-ascii?Q?V/l5sIDAWLrnkAlt8x33NThXG1YArPIojeuYAoNNsjP6EfienquaC8353ISy?= =?us-ascii?Q?bO2dYVimtAg6buSiVsi/RlayrbPS3f4Cmfc8nTAbr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q?kTiE5CLUDxSWqZTaIF3BSXOYF7WiTCh+F2xmyzWvxd2tnAQ+xYUmbLn7huOO?= =?us-ascii?Q?UHM/GCmyZ6N6768ADqn/tL7tZ+6D/yk8k0gE22QNVtORV+ilpAsgLxC701zd?= =?us-ascii?Q?m4hpARCEz8VZambAtZAyA1UE9z2FsYmXuE6jPQz/C+zi1puoa0Jr6/284E+3?= =?us-ascii?Q?Ch0MgEVYSkDOyOQ5S4wJVTQSSDHHk8P67Vb/uD21?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: IA0PR11MB8355.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e21057ea-85cc-4729-8ff0-08dc49826324 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Mar 2024 08:39:13.7545 (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: oYFDvjPxgYccf54Srd7ryNhXhGHjbwkWdXGkGCVptOqkOsIVnDUXgheziJDWPUncz5Us+eWpe+EYujveP0G3PQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6649 X-OriginatorOrg: intel.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Thu, 21 Mar 2024 01:39:18 -0700 Reply-To: devel@edk2.groups.io,cepingx.sun@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 9fRdE0XWB4PG9MqmpKywq8I6x7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=BcPBo3Nm; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On Wednesday, March 20, 2024 6:05 PM Gerd Hoffmann wrote: >=20 > We don't need to read + cache all fw_cfg data. We only need to cache the > entries which (a) must be measured, and (b) will not be measured in some > other way. >=20 I am afraid that it is difficult to determine which fw_cfg items=20 are need to be cached and measured, since there are some fw_cfg items are optional with special qemu cmd. Example :=20 fw_cfg item: opt/ovmf/X-PciMmio64Mb =20 depends on qemu command: "-fw_cfg name=3Dopt/ovmf/X-PciMmio64Mb,string=3DN" > The big entries I'm aware of are: > (1) kernel for direct boot (no fw_cfg measurement needed, binary > will be measured before launch). > (2) ACPI tables (no fw_cfg measurement needed, acpi tables are > measured when installed). > (3) smbios tables (to be decided, could be handled similar to ACPI). >=20 > Anything else where you have size concerns? So far I don't find other big entries. >=20 > > Further more this is not a lazy mode which means some fw_cfg data may > > be read but it is not to be consumed later. >=20 > The problem with lazy mode is that the measurement order is not fixed. We'd better define what's the "fixed measurement order". Think about such scenario: There are 5 fw_cfg items ("A-B-C-D-E"), and C is an optional one which depe= nds on special qemu cmd (example : etc/boot-menu-wait depends on qemu command: " -boot menu=3Don,s= plash-time=3DN"). =09 So, there are two measurement orders in different qemu command: 1, "A-B-C-D-E" (with qemu command "-boot menu=3Don,splash-time=3DN ") 2, "A-B-D-E" (without qemu command "-boot menu=3Don,splash-time=3DN ")=20 Is the "A-B-C-D-E" or "A-B-D-E" fixed order ?=20 What's your thoughts ? >=20 > > We propose below solution : > > > > Add a new API in QemuFwCfgLib, > > RETURN_STATUS QemuFwCfgGetData(fw_cfg_name, *size, *value, > FW_CFG_GET_DATA_FLAG flag). >=20 > I'd suggest to *not* touch the existing interfaces for reading entries. > Instead change the existing functions to first check the cache, in case t= here is > no cache entry go read from fw_cfg. Actually we don't touch the existing interface for reading entries. The API is newly added. > > Add a new interface for adding fw_cfg entries to the cache, with optional > measurement. Do you mean to add a new API (example : QemuFwCfgReadBytes2(*size, *buffer,= Flag)) with optional measurement to cache fw_cfg data? >=20 > > And it can reduce the code complexity because it pack 3 fw_cfg call > > (QemuFwCfgFindFile/QemuFwCfgSelectItem/QemuFwCfgReadBytes) into one > call. >=20 > There are a few places in the code which expect they can read fw_cfg file= s in > multiple chunks (i.e. call QemuFwCfgReadBytes multiple times). >=20 Actually we can handle the case with the new API. For example, etc/e820 is read in chunks.=20 Current code like below: QemuFwCfgSelectItem (FwCfgItem); for (Processed =3D 0; Processed < FwCfgSize; Processed +=3D sizeof E820En= try) { QemuFwCfgReadBytes (sizeof E820Entry, &E820Entry); Callback (&E820Entry, PlatformInfoHob); } We can update it like below: QemuFwCfgGetData("etc/e820", &FwCfgSize, Buffer, Flag); for (Processed =3D 0; Processed < FwCfgSize; Processed +=3D sizeof E820En= try) {=20 EFI_E820_ENTRY64 *E820Entry =3D (EFI_E820_ENTRY64 *)(Buffer + Processed= ); Callback (E820Entry, PlatformInfoHob); } > Also note that not all fw_cfg entries are (pseudo-)files. I am not sure what you mean about (pseudo-)files. Could you give some instructions? Base on your comments, does this mean there are other fw_cfg data=20 which are read from QEMU via different method (not QemuFwCfgFindFile/QemuFw= CfgSelectItem/QemuFwCfgReadBytes) ? If it is the case, could you please give an example?=20 Thanks=20 Ceping -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116950): https://edk2.groups.io/g/devel/message/116950 Mute This Topic: https://groups.io/mt/104880546/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-