From patchwork Fri Jan 27 11:51:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 647494 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp770520pvb; Fri, 27 Jan 2023 03:52:06 -0800 (PST) X-Google-Smtp-Source: AK7set+B5MXMoeRDf4gxsVAI0gih7vV+of9/mbnh6F/QbxbpB7tEvpWuva/BJFKzTyteDTAnFB8M X-Received: by 2002:a4a:88d3:0:b0:511:f3d2:bb8d with SMTP id q19-20020a4a88d3000000b00511f3d2bb8dmr4744686ooh.5.1674820325839; Fri, 27 Jan 2023 03:52:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674820325; cv=none; d=google.com; s=arc-20160816; b=PCimfn0IYLHB1NUl9qKur9GtMQasSN3eHoIclc2NRW191ple/ToC1Zt/889/pkbjOf YH1xDPScfLGKSqZip+TRa1YkrcnkEjsoNf3qviym7/Lhob5oU2jwR2JvEDRnj1J7DjVe iO8d1AVp7GxuJJBHAyvxvOEljPn9ataAwV8Cb8/iYCl0++AptkkTHul7vXU2d2JNpsnx q6qBoIv2RXl5TLYEju95sQcarH6iqybk9PACRyqrZ84JrJ0uFW2HxAw+9oWm6CXSbu6L ey1E1VVqtLUL5MlDTQeaXMIzK+SMAQwZm+tyWOZf/yKycBl12LKvAABFyosfBYICVW+X NH7g== 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=g9JZ0VeH/LtAi+5JScPU6E6AnAk6pNpaKwQr7y0tnqg=; b=b7D4pEbKW9yNsp4wKpHVOhiog41++s7dd5nBsRpvNsvuoGQ/umpC5J6s7Xs2HuQT1b jlnKCKzIsleiL+OHa5eEjvK2WIPNWseLjTODYYfFfS7bJDHcBhWGPIapGlcrNnZoDUhA azCUI3RDhzrM7taIL9pzZGxVRYZP7AoQncIWeL3eAkASq3zNgA6ugXoHRIyqoEYlVgxT YqAykrOeUKSo/kgj27kfkFaGUwYBOjb6/Jt+8q4qeZ51lB8M8Bwm0XZC5oGrEPUZQVP2 FYVtmPVMOThEDdxORwhQyq9WXgMfpqOp5p3S0Ve0XttHMYOb8AuhwA1uxQ1EzN349vjz lHYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VTq9EfhQ; 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 h2-20020a4a9402000000b00511fae4a698si4015962ooi.65.2023.01.27.03.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 03:52:05 -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=VTq9EfhQ; 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 51618851EB; Fri, 27 Jan 2023 12:52:00 +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="VTq9EfhQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D7684851E0; Fri, 27 Jan 2023 12:51:57 +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-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) (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 B46F5851EB for ; Fri, 27 Jan 2023 12:51:54 +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-x630.google.com with SMTP id jm10so4656646plb.13 for ; Fri, 27 Jan 2023 03:51:54 -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=g9JZ0VeH/LtAi+5JScPU6E6AnAk6pNpaKwQr7y0tnqg=; b=VTq9EfhQ0CDUp9i6Op8jR7iAHZP4q196/xdAx77XliYQfvRldoMFxdpjgaLFseG5sS oH5CIjqCDz60jNL+uDdA6lVaEu0d7g/ptJ3HA1m0MSULaY0AAMSTOXVNi3arQByxlZB4 PrUH4Zz6Sf7Ly6WtNrMEG95uxHMprG89JB8bctaGKqD32Xfj/NwXrIrJmtQq1mqakKOx ANw0DxZBsHrZ9CrLQUbJNubifu88WDmSp985/b1GD4ISXJxLLYslG0eqd4pZMRuT9dfZ oDJZcdh1+glFkZ4G5Y4D9eflQChEcP8CmbBkzjL3m+PPZDBpb+f9S9nLbDDEjSeiLbmy j87A== 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=g9JZ0VeH/LtAi+5JScPU6E6AnAk6pNpaKwQr7y0tnqg=; b=SlAozt84WRoXjumwU7hJQdsYWakelAobDX4Zo7f04UhFyGKYo7xFpbB+8j+djVYaMK eXSmTlsm4KWSxztfQTbrv+m0U84FG8sANTDARmUTV8QPm0t7tjkOAAuCBd8PkwipiCdu jS5TB9SH3eYXrpggYmw9HkrXwIT7v6oHyHuqu5DoJM2GSNJFXL4guiu6fdHDo3U0yvOH 0msR824oE0IpDvkJmq4aEC4kmdL+0HTKTswHmnpdffYJaU+87sE/Hod6At7yNyMePpc5 udXv/hwimr88vCkFMGYrJc5gfcq8LIEnyzskjogK7r2Ybu+9MOqhBhwfNdF+eqx/SFvR ditQ== X-Gm-Message-State: AFqh2krUNKX03mlIxMysOoS0nB4MB5hD2XNLu0KTaUv2rQ8rmWVQtoCi oJg+VYc70WPS9sx9vb1qCDok91VMjXq+/zEH X-Received: by 2002:a17:902:988f:b0:194:9b5d:2887 with SMTP id s15-20020a170902988f00b001949b5d2887mr35175957plp.64.1674820312830; Fri, 27 Jan 2023 03:51:52 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id h11-20020a170902f7cb00b001926392adf9sm2650006plw.271.2023.01.27.03.51.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 03:51:52 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH] efi: use 32-bit alignment for efi_guid_t Date: Fri, 27 Jan 2023 20:51:28 +0900 Message-Id: <20230127115128.5916-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 --- include/efi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/efi.h b/include/efi.h index 42f4e58a91..914a12967f 100644 --- a/include/efi.h +++ b/include/efi.h @@ -56,7 +56,7 @@ struct efi_device_path; 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)