From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::344; helo=mail-wm1-x344.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8708821962301 for ; Sat, 8 Dec 2018 02:24:37 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id a18so6772803wmj.1 for ; Sat, 08 Dec 2018 02:24:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=B0NiilHyD8AQpJt2AjUUL3pYWJ37TrqqJ3Hr5+GFZo8=; b=jKybMVWsDUCaBqNiv5cDRGc720IzKlamxedAJ5EuMfQXiA4vY6ZTbTGhK7CwlifUgO AqXZhrgwWEZQPtpxt1njG/y9q/M0odQDQPbxak+M69mLWK18qpzsTg/V8hPOUdq1X1CZ H09YnNNxZvlHgUDEFflOo0nlmb8eTdqajsnWw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=B0NiilHyD8AQpJt2AjUUL3pYWJ37TrqqJ3Hr5+GFZo8=; b=VSOjYS2q5C1hxBayAvVAV8ceHChI9Hzdx+S1uQplPQz8oYw0fJQ+3Z9xJmgZWbuWeH xe1POTLy/WP0USku7X14sik/Q65XZpe2fio6aFoSKGL/nYo+wewHYO10uFuuAo2mwJuT 0SIBIcKO41tiBUyzcbaZe1YEvMnCOeYG5PU5KmfYxMnnEJS7YsxHCLGgT+D6Q34uhfTs 7CcmVQBXLh/Ydd0r2e9HWdBVhzQPIXIPOEg3Rqa2Pv20jYyc3PPSDXs3zI4noOT4L9QD gOMpzaFI8/Wb7Gy+n1hS0h871tTvzb9Qnbh5DCt8aaDawguCuJYWP5jIstjp8dmBMH3G dC9Q== X-Gm-Message-State: AA+aEWah8ixBCi+jvFr9xHjcAP0yUbbrFl7JfHIE2kzXV7t0QsYNWnwt WY0VQvCnekauG+rZWdssz3OgFOhUs3w9Gw== X-Google-Smtp-Source: AFSGD/UNDA3tRuGj9ZxZgee4SYaj5nCaFM/sJD4Wy+yfFTwJGIBIr2ALnLNXR9OXbHHQDJVcz9XJ5Q== X-Received: by 2002:a1c:848c:: with SMTP id g134mr4438145wmd.93.1544264675285; Sat, 08 Dec 2018 02:24:35 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:4978:e9aa:84ec:cb4]) by smtp.gmail.com with ESMTPSA id l202sm14819049wma.33.2018.12.08.02.24.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Dec 2018 02:24:34 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Cc: jian.j.wang@intel.com, hao.a.wu@intel.com, ruiyu.ni@intel.com, Ard Biesheuvel Date: Sat, 8 Dec 2018 11:24:31 +0100 Message-Id: <20181208102431.9185-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Subject: [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: Sat, 08 Dec 2018 10:24:37 -0000 Content-Transfer-Encoding: 8bit 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. 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. E.g., the following call in FileExplorerLibConstructor() InitializeListHead (&gFileExplorerPrivate.FsOptionMenu->Head); which is emitted as follows for 32-bit ARM/Thumb2 by Clang-5.0 3de0: b510 push {r4, lr} 3de2: 4604 mov r4, r0 ... 3de8: e9c4 4400 strd r4, r4, [r4] 3dec: bd10 pop {r4, pc} 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. 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(-) 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; +#pragma pack() + typedef struct { EFI_HANDLE DeviceHandle; EFI_DEVICE_PATH_PROTOCOL *DevicePath; @@ -100,8 +102,6 @@ typedef struct { #define FILE_EXPLORER_PRIVATE_FROM_THIS(a) CR (a, FILE_EXPLORER_CALLBACK_DATA, FeConfigAccess, FILE_EXPLORER_CALLBACK_DATA_SIGNATURE) -#pragma pack() - extern UINT8 FileExplorerVfrBin[]; #define MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u') -- 2.19.2