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.web10.21189.1591972388687588207 for ; Fri, 12 Jun 2020 07:33:09 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=ay7XS3JU; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: liming.gao@intel.com) IronPort-SDR: 09jPUaGjm2U7izOBOaVWWom3edbbCQ+q/eLycyHiMkzok5XfU8vDFjLYYCOJzZQ9m3cU7lc7mt +9wsJMcE/uSw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2020 07:33:07 -0700 IronPort-SDR: rrhhuJOnK+F/GyYGLirBDCXNGevnDG73XlA24CDOVoMmcei2B+E13EYxBOL8KP9Xud9GhIvJV+ taOchdiBPZCA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,503,1583222400"; d="scan'208";a="260843533" Received: from orsmsx104.amr.corp.intel.com ([10.22.225.131]) by orsmga007.jf.intel.com with ESMTP; 12 Jun 2020 07:33:07 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX104.amr.corp.intel.com (10.22.225.131) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 12 Jun 2020 07:33:07 -0700 Received: from orsmsx605.amr.corp.intel.com (10.22.229.18) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 12 Jun 2020 07:33:06 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by orsmsx605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 12 Jun 2020 07:33:06 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.41) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 12 Jun 2020 07:33:04 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gRTHxqp8rthbWtqBCY6aGkAsup9ToxCA3E//B77IfQYjDiBY2IQ2uJOQB3wLMnGvLsFDCSVCN2s+OvY4u6lsRPmM16AZxX+5uBqoRFjw1QMXQyuMKnS+OVoFvt34iaTxJnBTRHn93DKClRYC/yxtQpxxwNjzuM+8XLadQQipjS6VRyQn5O6RKVYjqZKg2c4G5DeVKvRIl2dZH45DlJLaSJitZbkx0Ftr+mCBN7gNgA4aVr0TIpjUhdAcEHDYYmT1zQb/JScRr6/8SGFNMGKDcCtspURJKMZNorob+ZS/nXDQHoP/M75a5ls6Gzn1qQU5E4788bcysZqhJIUqY0xAlQ== 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=yawHwurJHWKQLtyfeg3cU67kSCndaIreyQrQwgLs3RI=; b=FkaebvYlcEsGTIfSJ9d6QL3QlnUOsXVcPzqjXgegKpmfT8LPUGNYR3fg0Y9QSapITcPFDEhaJc/MiDugSK/8T8bH7UEYLaRv+CQtQ1J88vjORlstVCJEeuma1TxrQnsHY8SN29VP1hVI7zV8sr2a6YCR3xgfNzASHa4Pcvaf/WjxUusijaqb434mo7+WUmaL+4a0ybRyeeQOJrkg/grU5CIQYBnXwjEQSe+rIbdTXgzGiUVEZ/wf3jdX4jtLroMizYN4HnKb9wmZw9ir73NtpO/3n9DKfnMy2Nx9lbgT8Dk0XwML5xUSD/CB+oLxuKloRdIrIn06coTzMjKk33sLVA== 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=yawHwurJHWKQLtyfeg3cU67kSCndaIreyQrQwgLs3RI=; b=ay7XS3JUyqQuuuClZ7AkzYIPQx1ByaOyTQWZD4g53hZOM6u3SDLXwV/sW/OjiD7cMJxvWHLzVcJRDNfcK+rtyyqj+9PylU/Ot9sbW5C4kfIWa9OPygXqGym9wzZx2bOZj2MMQ3R9RQNTNJtie9oNAyJSWHXikUNeEufTKa9RqHI= Received: from MWHPR11MB1630.namprd11.prod.outlook.com (2603:10b6:301:e::7) by MWHPR11MB1631.namprd11.prod.outlook.com (2603:10b6:301:10::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.23; Fri, 12 Jun 2020 14:33:03 +0000 Received: from MWHPR11MB1630.namprd11.prod.outlook.com ([fe80::50fb:d63c:5958:a67e]) by MWHPR11MB1630.namprd11.prod.outlook.com ([fe80::50fb:d63c:5958:a67e%7]) with mapi id 15.20.3088.023; Fri, 12 Jun 2020 14:33:03 +0000 From: "Liming Gao" To: "devel@edk2.groups.io" , "ard.biesheuvel@arm.com" CC: "Kinney, Michael D" , "Liu, Zhiguang" Subject: Re: [edk2-devel] [PATCH v3] MdePkg/BasePrintLib: avoid absolute addresses for error strings Thread-Topic: [edk2-devel] [PATCH v3] MdePkg/BasePrintLib: avoid absolute addresses for error strings Thread-Index: AQHWQEChfU2AZfmXSUiYpDrzZ+VXRqjVDBYA Date: Fri, 12 Jun 2020 14:33:03 +0000 Message-ID: References: <20200611223509.344290-1-ard.biesheuvel@arm.com> In-Reply-To: <20200611223509.344290-1-ard.biesheuvel@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.207] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 63329a7a-92c8-43e3-5940-08d80edd83ed x-ms-traffictypediagnostic: MWHPR11MB1631: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1468; x-forefront-prvs: 0432A04947 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: NaCRCnfJzv5q5JgCvlGPbt7hVYmVBgS5d0TafINk1P/AoAqmm+iUsmvCLCaQMNCKgphlAwxK/spOfhuCcMyyEXE1af6JNqvobdyJiusK5n4Wb1HvtoGbC2DX/pPDQr//3YreCW8vqfLKSEWvNcWgqVEZPrWTn5J/Auj6UsR1pfLSMIxv1mWNXtSRIu4loM0iGCVNl+F2j30fBckYmW9lRVfSvi4ADCky3XQ15HgUdK0BtCknUIlB3XJZWpzYwrw1PnN+xO7TWCtkVfTBC+E2XcS187nKDvpv5oabJ9DHtub5lsSjSq7aad3zoB5aIkxZ01Yyr6xeK4u8v29l63PSUzlqNSZaspQzgMN4Inkjh2XT68JI/j01mSd9uJFZZkMHGVHqOqwVGjADKL2ZQHlAgQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR11MB1630.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(366004)(396003)(376002)(346002)(136003)(39860400002)(7696005)(26005)(55016002)(71200400001)(6506007)(53546011)(966005)(316002)(54906003)(66476007)(76116006)(66946007)(9686003)(66556008)(66446008)(86362001)(64756008)(8936002)(5660300002)(478600001)(8676002)(2906002)(52536014)(83380400001)(107886003)(33656002)(186003)(4326008)(110136005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: iiqxz0B2G8/9Gj3oQCkl1iwBpO8ZQHvPcdCYKsc2tRhC0o7IAGnGc/oEshzGJPbNcAu/zW4j940J2oTQ4PfFhIbIUDqVfWycrn2WhmP23YAOk7X2uldAZJu7t0uVOFBlv3ruvOwEJfxTX/xDzfNyzSWYr9XZuiQPZoXSVXNyAubfhDhpi6pZZCvxP5Y799car84hQ1Qt/8oe9zibslubhBBWni8Qbixklhgp67WuJVH8EdUB4jTn9EE5ulKkWOmVJhWx9Ll4e5bOb5+LU7ERLUQRoy3EBzV9hW5GRGEXWu1nVy3dYBycK3Wy2Np7a3WycwF4zqiZ6sMjjs8Atb9juGDC1a9hjBhnY3EiZFvOIG7w0Zt+OfSLRSEBkayPQoSLregrggra+oCbaFVtmkymPOmQZOzr+XgZIl8w3MwwO58qAnPnZ98vYwaotG2iMfjOMRXCwb3HltzHm5CpWLxJZErfeD52zx5fhY3o92E7th7t4jUGOKmUNsym1mNAauVF MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 63329a7a-92c8-43e3-5940-08d80edd83ed X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Jun 2020 14:33:03.5547 (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: XYag8SKV7RHhe+ddlplUWuVf1L898PzeayAfaPy9tO0sGIuYgobecVMiu4Zb23rZF14gey0nOE0ZnYa/PPHulA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1631 Return-Path: liming.gao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Ard: I will collect the image size on OVMF X64 platform with this patch.=20 Thanks Liming > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Ard Bieshe= uvel > Sent: Friday, June 12, 2020 6:35 AM > To: devel@edk2.groups.io > Cc: Ard Biesheuvel ; Kinney, Michael D ; Gao, Liming > Subject: [edk2-devel] [PATCH v3] MdePkg/BasePrintLib: avoid absolute addr= esses for error strings >=20 > The mStatusString[] array is constructed as an array of pointer-to-char, > which means that on X64 or AARCH64, it is emitted as a single linear list > of 64-bit quantities, each containing the absolute address of one of the > string literals in memory. >=20 > This means that each string takes up 8 bytes of additional space, along > with 2 bytes of relocation data. It also means that extra work needs to > be done at runtime to process these relocations, every time a module is > loaded that incorporates this library. >=20 > So fix both issues, by splitting mStatusString into two arrays of char > arrays. The memory footprint decreases from 955 to 843 bytes, and given > that in the latter case, the overhead consists of 278 NUL characters rath= er > than 390 bytes worth of absolute addresses and relocation records, the si= ze > of a compressed image is reduced even further. For example, when building > ArmVirtQemu.dsc in RELEASE mode for AARCH64 with the GCC5 profile, I get: >=20 > Before >=20 > FV Space Information > FVMAIN [100%Full] 5329920 total, 5329920 used, 0 free > FVMAIN_COMPACT [38%Full] 2093056 total, 811840 used, 1281216 free >=20 > After >=20 > FV Space Information > FVMAIN [100%Full] 5321728 total, 5321728 used, 0 free > FVMAIN_COMPACT [38%Full] 2093056 total, 809696 used, 1283360 free >=20 > So the uncompressed contents of the compressed image are 8 KB smaller, > whereas the resulting flash image (consisting of the compressed image > along with SEC, PEI_CORE and a set of PEIMs that execute in place) is > 2 KB smaller. >=20 > Cc: "Kinney, Michael D" > Cc: "Gao, Liming" > Signed-off-by: Ard Biesheuvel > --- > v3: > - add code comments to explain what the inner dimension of each array is > based on >=20 > v2: > - split off this patch from the StandaloneMmPkg series, since they are no= t > interdependent anyway, and so they can be discussed separately > - remove mention of StandaloneMmPkg from the commit log - the space savin= gs > by themselves are sufficient justification > - update the before/after numbers with the current results > - split the warnings and errors into a separate array, so that the latter > can use smaller entries > - clarify the commit log to explain the effect on compressed as well as > XIP images (which both get smaller) >=20 > MdePkg/Library/BasePrintLib/PrintLibInternal.c | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) >=20 > diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Libr= ary/BasePrintLib/PrintLibInternal.c > index b6ec5ac4fbb9..50c6e8559c43 100644 > --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c > +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c > @@ -27,13 +27,22 @@ >=20 >=20 > GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexStr[] =3D {'0','1','2','3'= ,'4','5','6','7','8','9','A','B','C','D','E','F'}; >=20 >=20 >=20 > -GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 * CONST mStatusString[] =3D { >=20 > +// >=20 > +// Longest string: RETURN_WARN_BUFFER_TOO_SMALL =3D> 24 characters plus = NUL byte >=20 > +// >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mWarningString[][24+1] =3D { >=20 > "Success", // RETURN_SUCCESS =3D = 0 >=20 > "Warning Unknown Glyph", // RETURN_WARN_UNKNOWN_GLYPH =3D = 1 >=20 > "Warning Delete Failure", // RETURN_WARN_DELETE_FAILURE =3D = 2 >=20 > "Warning Write Failure", // RETURN_WARN_WRITE_FAILURE =3D = 3 >=20 > "Warning Buffer Too Small", // RETURN_WARN_BUFFER_TOO_SMALL =3D = 4 >=20 > "Warning Stale Data", // RETURN_WARN_STALE_DATA =3D = 5 >=20 > +}; >=20 > + >=20 > +// >=20 > +// Longest string: RETURN_INCOMPATIBLE_VERSION =3D> 20 characters plus N= UL byte >=20 > +// >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mErrorString[][20+1] =3D { >=20 > "Load Error", // RETURN_LOAD_ERROR =3D = 1 | MAX_BIT >=20 > "Invalid Parameter", // RETURN_INVALID_PARAMETER =3D = 2 | MAX_BIT >=20 > "Unsupported", // RETURN_UNSUPPORTED =3D = 3 | MAX_BIT >=20 > @@ -996,12 +1005,12 @@ BasePrintLibSPrintMarker ( > // >=20 > Index =3D Status & ~MAX_BIT; >=20 > if (Index > 0 && Index <=3D ERROR_STATUS_NUMBER) { >=20 > - ArgumentString =3D mStatusString [Index + WARNING_STATUS_NUM= BER]; >=20 > + ArgumentString =3D mErrorString [Index - 1]; >=20 > } >=20 > } else { >=20 > Index =3D Status; >=20 > if (Index <=3D WARNING_STATUS_NUMBER) { >=20 > - ArgumentString =3D mStatusString [Index]; >=20 > + ArgumentString =3D mWarningString [Index]; >=20 > } >=20 > } >=20 > if (ArgumentString =3D=3D ValueBuffer) { >=20 > -- > 2.26.2 >=20 >=20 > -=3D-=3D-=3D-=3D-=3D-=3D > Groups.io Links: You receive all messages sent to this group. >=20 > View/Reply Online (#61170): https://edk2.groups.io/g/devel/message/61170 > Mute This Topic: https://groups.io/mt/74829004/1759384 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [liming.gao@intel.com] > -=3D-=3D-=3D-=3D-=3D-=3D