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 BC5A0C54EAA for ; Fri, 27 Jan 2023 14:18:38 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 38E8C856B9; Fri, 27 Jan 2023 15:18:36 +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="Xl+BzpIB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EA831856D3; Fri, 27 Jan 2023 15:18:34 +0100 (CET) Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) (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 0BE4D855D3 for ; Fri, 27 Jan 2023 15:18:32 +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-ej1-x62d.google.com with SMTP id m2so13627056ejb.8 for ; Fri, 27 Jan 2023 06:18:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Uo0yxHYwcq0UBR2sjklbS4NB9UHNt+V1S2rYFhbQaow=; b=Xl+BzpIBbCMlXe7BzEhG0nNhtTlGgw64du5ECQ/fEHlJictdUfqSXIBdPiR0mcqmNO rsb/+BhSMdEJrdZpPK/9ZbYIzDCVc/6JrpwaBOTHxufy/PrGyYCnsj1iHxKLpIIuWdfw y/O/V56VKpnNsGIlfnavdxgpqFXQ1x2ac6lxmd+fBAN3GALVvKm1op2IgAPIftczJvhy B75LtCMK6byicv9yW/Oh3QzWUjVKhnGUevnNBZP8cfNVSCw3i/0KaO13xvt+Om8E+daJ GPY3Z7kWlhpQ9znYK0mA/L910K5fw+6yze1TKQX8HF1/tQMCPvdbsF3wnPsKUgP77OKH S00g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Uo0yxHYwcq0UBR2sjklbS4NB9UHNt+V1S2rYFhbQaow=; b=Pf6pKPew80Q8+PMped3O9XVMhlzEKLZV2nh/J4dcFbaWI7AKZe25aeomgTHFJ1FvHl RebIPrEQhjVrFwlOblwjzfznXPSi335gFENcjV0c6ftkDXSFeDGTX+8LGYAmFMWs68gW aw/uaC24Xf+WkvICe5+lN1UiNaKxuT/oeluXOIYs69WGS0iPPfE5mL85JZ8gStVIVK37 o+aJXdSutPWX/ACG9CYDTOhZe3522doQLt1eTuP406ipMpFKcbvcJeYc4fiawcv9wzSk hNqETE0QmhhifjEw/sFglHFYd7iXpdE3EgZ3r0yWtK+Fch3OccBk8YeJftnfxdoQc7Xs tFuQ== X-Gm-Message-State: AFqh2krS6aABPX0phk2Lg8ehAB5PP1RPelGiRuM920wz2eHjMugANtdR UF5lK12xI9E/Yvl5OwzZFqyawQ== X-Google-Smtp-Source: AMrXdXum5TRK/h9FZ5lompBXkRAI4JmMG8Mw01P7yNMErRTrbPlx2iie+HSzLkRxnJBo3p/f5R73ZA== X-Received: by 2002:a17:907:6f07:b0:7c0:f90f:163d with SMTP id sy7-20020a1709076f0700b007c0f90f163dmr47962353ejc.11.1674829111580; Fri, 27 Jan 2023 06:18:31 -0800 (PST) Received: from hera (ppp079167090036.access.hol.gr. [79.167.90.36]) by smtp.gmail.com with ESMTPSA id um8-20020a170907cb0800b0087d04f41c27sm382571ejc.100.2023.01.27.06.18.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 06:18:31 -0800 (PST) Date: Fri, 27 Jan 2023 16:18:29 +0200 From: Ilias Apalodimas To: Masahisa Kojima Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: Re: [PATCH] efi: use 32-bit alignment for efi_guid_t Message-ID: References: <20230127115128.5916-1-masahisa.kojima@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230127115128.5916-1-masahisa.kojima@linaro.org> 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 Hi Kojima-san On Fri, Jan 27, 2023 at 08:51:28PM +0900, 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 > --- > 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; > Thanks for fixing this. Can you add a comment similar to the commit log here as well? /* 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 > Thanks /Ilias