From patchwork Sat Jan 28 04:56:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 647971 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp100580pva; Fri, 27 Jan 2023 20:56:50 -0800 (PST) X-Google-Smtp-Source: AK7set9RTV7QN5Xmsb1kJ9dMhDQLpFEtW9TPniMUe5eJxDNEhsCwQ2uOT6IRPFJg2UWyfsPADlRr X-Received: by 2002:a05:6808:13c2:b0:36e:ae1c:3402 with SMTP id d2-20020a05680813c200b0036eae1c3402mr466268oiw.50.1674881810059; Fri, 27 Jan 2023 20:56:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674881810; cv=none; d=google.com; s=arc-20160816; b=ITJNeugyHp63By0Wv6tc6R74SqKn1psG6KjY78wTQDShQB9kBAY62jemKyHZL6id3d 31QY8TsWKTO2I1iaFnL6DeeXNc8bsIXEA23pykRBK1gJjryDbdeSTaVBBvj0ufeWj4nV dyRDNfc2fOTXA/k5HOEIeJJQ9kejnFEppkGl5CAWF92e7WfyfbtA3Dp/HYXOVjjL8vpP 6vXcpzUZGTaqgWIecJKB5itSXx+/Cvyhf4QEH7VtT/NxU4pEBy0WATkDrJ+4+UJRU4aN cdWhNfEk+6Z/NkYQCFGA/GPbFKyYLWqb8gY8LsSeTlZNIxgOdrU+RPc3UqRwF+eTgFz2 MBVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=WXaXRd5P5lI3DzFHxC0hIuN+20xBGVzDvM0THbHMViI=; b=VQmUuKlKL6+j+waIrBdIeHKGA/lvwiSQNsmnuaiSMBTowg0PD0MQIaNFfaD3LO0JAL g9QT8skAFf6mbM1BAO1h01vT2Ao7j1BwT8PhMDL/bDBf16jU3YI/2l6vc63EIFRztbtj jpozjkbl38fLoCrp5s7n1ZdnVhGjW8o1z4I+Y+BsLvuDpzScn5aQQDeRlpyXgO+UiSsx GiFn5wMmAJuWGhcxOdgG04d/ArJarj9ClbVWcFwG+6abMidfYlbfBdZr6BV3RNpUiQZM KlzgNSDKO6TtKTCxHc4eCq8sqCqZ6x2Iclywsd2Hee7YT8+0kLp1x8ifFNhYZM7D/Yot u5+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HP6ui4j8; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id m22-20020a05680806d600b0036a2285723esi5469389oih.266.2023.01.27.20.56.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 20:56:50 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HP6ui4j8; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A720385718; Sat, 28 Jan 2023 05:56:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="HP6ui4j8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 181B085718; Sat, 28 Jan 2023 05:56:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 06EFE8571D for ; Sat, 28 Jan 2023 05:56:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masahisa.kojima@linaro.org Received: by mail-pl1-x62e.google.com with SMTP id 5so6912080plo.3 for ; Fri, 27 Jan 2023 20:56:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WXaXRd5P5lI3DzFHxC0hIuN+20xBGVzDvM0THbHMViI=; b=HP6ui4j8uY8cu2tEcXLlGwruwgy4zLssLYsgrCO4XZW1BGTzELsyxZBZCwTOb3Tf2X GyzQyIXj7E5Z5VVMfTcj6GtFizznYhZSNui+W5e1Pq4lfxzseKiOFNCC0HIxXh6or1vz lq4qRyQli4HwHpkz3pJDdBa5VWTYtDncDRqR9LPPEdwoRNFQ245iKXS4OFLxOutDoOsx e9sH9OxMnXlNcYkPsQ8weMq3Z9nqpxTf16vlkXal3AWwFK82x/dtskUwQwGkQ8nWz2/f rWpjVtW4N3LC53HaeXX2WIwI9qofOy3gxRMac93e+GoASHf7XaYVbcSmmwL141pVlIGS r+Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WXaXRd5P5lI3DzFHxC0hIuN+20xBGVzDvM0THbHMViI=; b=w1xG0MZq5zL9JgwgQcQc0OGMfSfDXSwn7xt39NLUow2zCfgbVsozaDRqjffacKkTqP KFwYPANgRhS5z1TYhTnsHPzXfdEMAv2hA3XsKdwQS6NRsTPPRuXO619y0z121++oNkcH 2SOeDAV9+4dYZYGI59UwyIqXZ9MBnWnTVY0XtLsRayJTwKRFFqYqWRyjeptKpf3GJQ3t RTcXacPEmC6Isfbe8I5rYAXGoLUQOYuf1FC5cOoRueS91R6EZ0mbu0/i3yoXDeDm3fjs rtxH+fghhXl484lo6qOXWhR7TZfjFV0i3RfKEY1LNmHTa1s3Y5yYuVv+aHHCs6NHtuEE qNNQ== X-Gm-Message-State: AO0yUKV086QrRfG302Ot8Q5pLgbdGgp4UX6OVYClnB+U8WPrkhqS3NCZ D2oqt781MRoWuUNLHkjJp8cP1b/yVlhiFvZP X-Received: by 2002:a17:903:cd:b0:195:f097:d65b with SMTP id x13-20020a17090300cd00b00195f097d65bmr579041plc.49.1674881798961; Fri, 27 Jan 2023 20:56:38 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id u71-20020a63794a000000b0047781f8ac17sm3046038pgc.77.2023.01.27.20.56.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 20:56:38 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH v2] efi: use 32-bit alignment for efi_guid_t Date: Sat, 28 Jan 2023 13:56:14 +0900 Message-Id: <20230128045615.8216-1-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Current U-Boot implements 64-bit boundary for efi_guid_t structure. It follows the UEFI specification, page 21 of the UEFI Specification v2.10 says about EFI_GUID: 128-bit buffer containing a unique identifier value. Unless otherwise specified, aligned on a 64-bit boundary. On the other hand, page 163 of the UEFI specification v2.10 and EDK2 reference implementation both define EFI_GUID as struct { u32 a; u16; b; u16 c; u8 d[8]; }; and so the implied alignment is 32-bit not 64-bit like U-Boot efi_guid_t. Due to this alignment difference, EDK2 application "CapsuleApp.efi -P" does not work as expected. This calls EFI_FIRMWARE_MANAGEMENT_PROTOCOL.GetImageInfo() and dump the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure, offsetof(EFI_FIRMWARE_IMAGE_DESCRIPTOR, ImageTypeId) is different, 8 in U-Boot and 4 in EDK2(CapsuleApp.efi). Here is the wrong EFI_GUID dump. wrong dump : ImageTypeId - 00000000-7D83-058B-D550-474CA19560D8 expected : ImageTypeId - 058B7D83-50D5-4C47-A195-60D86AD341C4 EFI_FIRMWARE_IMAGE_DESCRIPTOR structure is defined in UEFI specification: typedef struct { UINT8 ImageIndex; EFI_GUID ImageTypeId; UINT64 ImageId } EFI_FIRMWARE_IMAGE_DESCRIPTOR; There was the relevant patch for linux kernel to use 32-bit alignment for efi_guid_t [1]. U-Boot should get aligned to EDK2 reference implementation and linux kernel. Due to this alignment change, efi_hii_ref structure in include/efi_api.h is affected, but it is not used in the current U-Boot code. [1] https://lore.kernel.org/all/20190202094119.13230-5-ard.biesheuvel@linaro.org/ Cc: Ilias Apalodimas Signed-off-by: Masahisa Kojima Reviewed-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- Changes in v2: - add source code comment to describe why the efi_guid_t structure is 4-byte aligned include/efi.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/efi.h b/include/efi.h index 42f4e58a91..c3087d3da2 100644 --- a/include/efi.h +++ b/include/efi.h @@ -54,9 +54,18 @@ struct efi_device_path; +/* + * The EFI spec defines the EFI_GUID as + * "128-bit buffer containing a unique identifier value. Unless otherwise specified, + * aligned on a 64-bit boundary". + * Page 163 of the UEFI specification v2.10 and + * EDK2 reference implementation both define EFI_GUID as + * struct { u32 a; u16; b; u16 c; u8 d[8]; }; which is 4-byte + * aligned. + */ typedef struct { u8 b[16]; -} efi_guid_t __attribute__((aligned(8))); +} efi_guid_t __attribute__((aligned(4))); #define EFI_BITS_PER_LONG (sizeof(long) * 8)