From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EA101C54EAA for ; Mon, 30 Jan 2023 08:06:26 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE85E8578D; Mon, 30 Jan 2023 09:06:23 +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="cQmI3f4z"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A84B08578E; Mon, 30 Jan 2023 09:06:21 +0100 (CET) Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) (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 C164885316 for ; Mon, 30 Jan 2023 09:06:18 +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=ilias.apalodimas@linaro.org Received: by mail-lf1-x135.google.com with SMTP id cf42so17791503lfb.1 for ; Mon, 30 Jan 2023 00:06:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=C+SWF78WHKKmbIaGb0gpbsIsMTQ/XTYeWNdpVCmWYeQ=; b=cQmI3f4zYio1bYMqVQvx0AQYzyuGBCSXAZC8etv6Xkd7c3xUFC1FxiJXsEy4mcHG+A FC2z+swjXtNxO/PqQsXBoT8uoNN4ksenbmuL6LJDlKlgByzeK8qkuU1lCnTeS+g4eR1d w8VDReXVlxCeQlN5ImVb21a7N88GXjPFBRMf/zmct6G1WSs77oAwEV9VxRcdCUHn3F9D idqX6+ToQwR7shke66iLCPC1TkD/rEiqz0uCxUy79a9SacyVMxzeZ7FC9kDU5L5IdbzO JnR76M1btFZU9THhNQh7U/3JBGOPeprLr4cRkyasHEsiqutJ2r0uDtSiSN3XIPovEKyZ vUKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=C+SWF78WHKKmbIaGb0gpbsIsMTQ/XTYeWNdpVCmWYeQ=; b=0hmp3zcfSaaMkxotb9HFoVX16QfHnNOm+26isLlyZr5kQ4J5ZfmVl/zGLc0xr8um0Y TC2xeMV5sCuGyHXC2bHp86d/V9nWinaRxwFU2MZx14KMsX3V+Q60WpC9aypJpkblTc4Z VizDZwhkLvmkFrKiGHKYyg95R0fldN+GKmMa2SwbMOfyE14J00ly8356uzTjNUc95f8E BHXjvKtY4O5u7GFp5eRXV2hMP6JekLSwzQTAYc6UuTwLyYt4MG2brgp2eWCGCngSyjP9 Edf0YRHe3mciFoirGBUglSiSjgiJkTLPDZCy22Sqx0V3QCQaUBnfoxxEut00zsOVdEaf qBFg== X-Gm-Message-State: AO0yUKUfseK9IIRgGCKz7IdkvT2tmAZSMzNGLZ7C+FAkrbNqSi/Vbpnh W76mgDHG1w8Ta8Yof2CinezJwaUNifsn8f2E4DLmwQ== X-Google-Smtp-Source: AK7set+zlYAs7nh636KdP5Ivgur3+AISZ6qnBhB9A6IChFF6U8sos2yVw3rGkpqYkgBLzewPykyfZZygOCeisXZH0NA= X-Received: by 2002:a05:6512:3996:b0:4d8:70f1:9d3d with SMTP id j22-20020a056512399600b004d870f19d3dmr140874lfu.70.1675065978037; Mon, 30 Jan 2023 00:06:18 -0800 (PST) MIME-Version: 1.0 References: <20230128045615.8216-1-masahisa.kojima@linaro.org> In-Reply-To: <20230128045615.8216-1-masahisa.kojima@linaro.org> From: Ilias Apalodimas Date: Mon, 30 Jan 2023 10:05:41 +0200 Message-ID: Subject: Re: [PATCH v2] efi: use 32-bit alignment for efi_guid_t To: Masahisa Kojima Cc: u-boot@lists.denx.de, Heinrich Schuchardt Content-Type: text/plain; charset="UTF-8" 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 On Sat, 28 Jan 2023 at 06:56, Masahisa Kojima wrote: > > 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 > --- > 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) > > -- > 2.17.1 > Reviewed-by: Ilias Apalodimas