[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [for-4.20][PATCH 1/2] device-tree: bootfdt: Fix build issue when CONFIG_PHYS_ADDR_T_32=y


  • To: Julien Grall <julien.grall.oss@xxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Mon, 27 Jan 2025 18:15:47 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gmail.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2694W2IEQGxBUAVjQpa2LCHnNyhkJXWrTNvmVZV6HDo=; b=wStzFALxuVx/7s22RTBtW6r9GFwoeAPE/86xWU+NVglw/OVu2LGuggzcMX4S27kF3twvLbz2vnBC5te0a666bMNww0OBPuuupQ2h9jn6fLHW+2UCvtlEaEPs4deIvSxAJkdaD7L+U5PqfU/LsQPHjl8pazvayluguynTfy1cED+PCh4NOQdTGNRoXRvBsclJV7PbrlgShB2p8Ks6qtkwW83NPyiPfrI0TcMiFCEtN4wuNXKBEprHTSzfnnJlTiUSxDFXtha4B99EHmUJIsIdnfDiY5AY+k0cccjfoRV0xDlQvd7p/3fBKTs/ns8NNP1AAQbwQ19gokl/JnJpLIBwUw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cRZ7yu2WchctWAq6/z/2GpqhYtrotjrhOo2n6f+p+uudES7+d6KI9uBUZchp6f8oRh/HpHoW5LbwWqfdGSNxWzNGOVChu4J5quRwLUe4tLJLJU54Q0AMuCOyyPw2kSKs9dgH7TGP6gHjgRFAFvXFX3tn8/zMWXASsnQ6Y2/jCjRZnPzHUqVKjI7riztRm5A2ELUN/VRvQYUbmNvtMCm3vrhaiRrBHvG33bBiOJQ5oHn6L/HFNE9j5xJnO5hY+QePuiFIbKyAdRD3150CE2A1gIu572S7OiK1PJCTojhEai3nakETGR9RuqhRAAuLAtXabVruvVtLLGT6gDToR6F1PA==
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, <oleksii.kurochko@xxxxxxxxx>
  • Delivery-date: Mon, 27 Jan 2025 17:16:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 27/01/2025 17:27, Julien Grall wrote:
>       
> 
> 
> 
> 
> On Mon, 27 Jan 2025 at 09:52, Michal Orzel <michal.orzel@xxxxxxx 
> <mailto:michal.orzel@xxxxxxx>> wrote:
> 
> 
> 
>     On 27/01/2025 12:19, Julien Grall wrote:
>     >       
>     >
>     >
>     >
>     >
>     > On Mon, 27 Jan 2025 at 07:46, Michal Orzel <michal.orzel@xxxxxxx 
> <mailto:michal.orzel@xxxxxxx> <mailto:michal.orzel@xxxxxxx 
> <mailto:michal.orzel@xxxxxxx>>> wrote:
>     >
>     >     On Arm32, when CONFIG_PHYS_ADDR_T_32 is set, a build failure is 
> observed:
>     >     common/device-tree/bootfdt.c: In function 'build_assertions':
>     >     ./include/xen/macros.h:47:31: error: static assertion failed: 
> "!(alignof(struct membanks) != 8)"
>     >        47 | #define BUILD_BUG_ON(cond) ({ _Static_assert(!(cond), "!(" 
> #cond ")"); })
>     >           |                               ^~~~~~~~~~~~~~
>     >     common/device-tree/bootfdt.c:31:5: note: in expansion of macro 
> 'BUILD_BUG_ON'
>     >        31 |     BUILD_BUG_ON(alignof(struct membanks) != 8);
>     >
>     >     When CONFIG_PHYS_ADDR_T_32 is set, paddr_t is defined as unsigned 
> long,
>     >     therefore the struct membanks alignment is 4B. Fix it.
>     >
>     >
>     > Usually, we add a BUILD_BUG_ON when other parts of the code rely on a 
> specific property (in this case alignment). Can you explain in the commit 
> message why the new check is still ok?
>     Well, the change itself reflects the change in alignment requirement.
>     When paddr_t is 64b (Arm64, Arm32 with PA=40b) the alignment is 8B.
>     On Arm32 with PA=32b, the alignment is 4B because paddr_t is 4B.
> 
>     AFAICT you requested this check back then, because struct membanks 
> contains flexible array member 'bank' of type struct membank.
>     The alignment requirement of struct membanks becomes the requirement of 
> struct membank whose largest type is paddr_t.
> 
> 
> Reading this, it sounds like you want to check against the alignment of « 
> struct membank ». This is because the structure could gain a 64-bit field in 
> the future and this would not be caught by the BUILD_BUG_ON.
> 
> 
>     Let me know how you would like to have this written in commit msg.
> 
> 
> I think it needs to be rephrased to make clear the alignment of  struct 
> membanks should be the same as struct membank.
Shouldn't this check therefore be changed to:
BUILD_BUG_ON(alignof(struct membanks) != alignof(struct membank));

~Michal



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.