From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 204B12118FF2F for ; Mon, 10 Dec 2018 17:48:33 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2018 17:48:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,340,1539673200"; d="scan'208";a="106448454" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga007.fm.intel.com with ESMTP; 10 Dec 2018 17:48:33 -0800 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 10 Dec 2018 17:48:32 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 10 Dec 2018 17:48:32 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.203]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.201]) with mapi id 14.03.0415.000; Tue, 11 Dec 2018 09:48:30 +0800 From: "Wu, Hao A" To: Ard Biesheuvel , "edk2-devel@lists.01.org" CC: "Wang, Jian J" , "Ni, Ruiyu" , "Gao, Liming" , Leif Lindholm Thread-Topic: [PATCH] MdeModulePkg/FileExplorerLib: avoid packed struct for program data Thread-Index: AQHUjuA7ATjv6qwWeUi2rJiaJ6Urj6V4yTNw Date: Tue, 11 Dec 2018 01:48:29 +0000 Message-ID: References: <20181208102431.9185-1-ard.biesheuvel@linaro.org> In-Reply-To: <20181208102431.9185-1-ard.biesheuvel@linaro.org> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdeModulePkg/FileExplorerLib: avoid packed struct for program data X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Dec 2018 01:48:34 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > Sent: Saturday, December 08, 2018 6:25 PM > To: edk2-devel@lists.01.org > Cc: Wang, Jian J; Wu, Hao A; Ni, Ruiyu; Ard Biesheuvel > Subject: [PATCH] MdeModulePkg/FileExplorerLib: avoid packed struct for > program data >=20 > Struct packing is only necessary for data structures whose in-memory > representation is covered by the PI or UEFI specs, and may deviate > from the ordinary C rules for alignment. >=20 > So in case of FileExplorerLib, this applies to the device path struct > only, and other structures used to carry program data should not be > packed, or we may end up with alignment faults on architectures such > as ARM, which don't permit load/store double or multiple instructions > to access memory locations that are not 32-bit aligned. >=20 > E.g., the following call in FileExplorerLibConstructor() >=20 > InitializeListHead (&gFileExplorerPrivate.FsOptionMenu->Head); >=20 > which is emitted as follows for 32-bit ARM/Thumb2 by Clang-5.0 >=20 > 3de0: b510 push {r4, lr} > 3de2: 4604 mov r4, r0 > ... > 3de8: e9c4 4400 strd r4, r4, [r4] > 3dec: bd10 pop {r4, pc} >=20 > will perform a double-word store on the first argument, passed in > register r0, assuming that the pointer type of the argument is > enough to guarantee that the value is suitably aligned. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > MdeModulePkg/Library/FileExplorerLib/FileExplorer.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h > b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h > index bf1450dbd581..603185abe4b1 100644 > --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h > +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h > @@ -51,6 +51,8 @@ typedef struct { > EFI_DEVICE_PATH_PROTOCOL End; > } HII_VENDOR_DEVICE_PATH; >=20 > +#pragma pack() > + > typedef struct { > EFI_HANDLE DeviceHandle; > EFI_DEVICE_PATH_PROTOCOL *DevicePath; > @@ -100,8 +102,6 @@ typedef struct { >=20 > #define FILE_EXPLORER_PRIVATE_FROM_THIS(a) CR (a, > FILE_EXPLORER_CALLBACK_DATA, FeConfigAccess, > FILE_EXPLORER_CALLBACK_DATA_SIGNATURE) >=20 > -#pragma pack() > - Reviewed-by: Hao Wu Best Regards, Hao Wu > extern UINT8 FileExplorerVfrBin[]; >=20 > #define MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u') > -- > 2.19.2