From patchwork Sat Dec 8 10:24:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 153227 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1495127ljp; Sat, 8 Dec 2018 02:24:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/X19IOFVC1Hq5dLzCVdylXsuTJFDtaFmu4QOLHHp4c6VYV7DWb9Mj8OQXwI/Eky2Vc4jwsL X-Received: by 2002:a17:902:7c0c:: with SMTP id x12mr5375766pll.265.1544264681577; Sat, 08 Dec 2018 02:24:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544264681; cv=none; d=google.com; s=arc-20160816; b=Gw9JHXd7wb5dsV+9haD4nDET2J0mePEfibYRVC4zk8DF2aRpphKsoRQwURvecLSldu nm8E/1vR7ZMQILYdtTgTT/vNYaDOO5ced8x1oog/CTeV9o05wbY/zm7vd2D58/vx797/ C7jl4LRaXcosfmGaXJraNWUV97OG0hM+CRen0OBXn6jgTSVypIOWxNNsXDNIv+Pu9EGf L6urNm5V/aTY7yWOIjaMxcQVpqE4YMZ1pvZpGTfIH5BtIaQISkwUihxZ/GfGpN924I3t toH8nu/yUZBeO68tqC5tkLFqPznwO/6NLPll8nu60H248B/BKpn77sbBMjRW2GAzDdhf moNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=7zBy4o9hGvo/OO+hhGd7jEjTt14GHuDKj73J9iheWKI=; b=iOGv1iYbp0ekFkJYIbF6xwudFRocL4lcEiHHduLv0b1pKb1VZGK0yfgBe9fzyBPAvf /g6BZHPeCwg9KQgh2uJMM5uP5cxSMl1aBqsef7oc2GQw2/WDuF+Dnu3WMhq2UxvYTc+U 51uEH57cePw5tFZB1Sv7cdmG8Pt2OfSksKb+e3gMb5ciQDZmN2OI6642Yua/B2N8P3G5 cfVfEfM+7yaAKmgEJDhMwSr9fbEeQ4Dc41r6NLnOApbmnHFHtLthVrcXB36HvaJktnJJ y9t8p9dL+sKSvRLuLoEH8/BvtwIo7I02/idUqIv76fLO9f9dVfOdVPuOjHtEqe1F8bbd sxAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jKybMVWs; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id h1si5040819plt.44.2018.12.08.02.24.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Dec 2018 02:24:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jKybMVWs; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 02BAF21199B1B; Sat, 8 Dec 2018 02:24:40 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org 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-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 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: [edk2] [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: , Cc: hao.a.wu@intel.com, ruiyu.ni@intel.com Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.19.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Hao Wu 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')