mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2] acpi: fix compilation for 32-bit
@ 2024-08-15 11:44 Ahmad Fatoum
  2024-08-20 12:07 ` Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2024-08-15 11:44 UTC (permalink / raw)
  To: barebox

From: Ahmad Fatoum <ahmad@a3f.at>

Build test on x86 fails due to pointer cast and because of forcing the
bigger alignment on the flexible array.

The problematic pointer cast is for the XSDT, which is 64-bit-only, so
let's fix the cast and return an error if we somehow see an XSDT on
32-bit.

For the flexible array, let's use the size of the pointer for the
alignment.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
v1 -> v2: 
  - fix CI x86_64 breakage, by keeping the packed/aligned specifiction
    as is, but changing it to 32-bit on 32-bit systems.
---
 drivers/bus/acpi.c | 6 ++++--
 include/acpi.h     | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/bus/acpi.c b/drivers/bus/acpi.c
index 593617073345..61178db0c8db 100644
--- a/drivers/bus/acpi.c
+++ b/drivers/bus/acpi.c
@@ -174,10 +174,12 @@ static int acpi_register_devices(struct bus_type *bus)
 		sig = "RSDT";
 		root = (struct acpi_rsdt *)(unsigned long)rsdp->rsdt_addr;
 		entry_count = (root->sdt.len - sizeof(struct acpi_rsdt)) / sizeof(u32);
-	} else {
+	} else if (sizeof(void *) == 8) {
 		sig = "XSDT";
-		root = (struct acpi_rsdt *)((struct acpi2_rsdp *)rsdp)->xsdt_addr;
+		root = (struct acpi_rsdt *)(uintptr_t)((struct acpi2_rsdp *)rsdp)->xsdt_addr;
 		entry_count = (root->sdt.len - sizeof(struct acpi_rsdt)) / sizeof(u64);
+	} else {
+		return -EIO;
 	}
 
 	if (acpi_sigcmp(sig, root->sdt.signature)) {
diff --git a/include/acpi.h b/include/acpi.h
index 0756f94501cc..fc0da30610a6 100644
--- a/include/acpi.h
+++ b/include/acpi.h
@@ -115,7 +115,7 @@ struct __packed acpi_sdt { /* system description table header */
 
 struct __packed acpi_rsdt { /* system description table header */
 	struct acpi_sdt	sdt;
-	struct acpi_sdt	* __aligned(8) entries[];
+	struct acpi_sdt	*__aligned(sizeof(void *)) entries[];
 };
 
 struct acpi_driver {
-- 
2.39.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] acpi: fix compilation for 32-bit
  2024-08-15 11:44 [PATCH v2] acpi: fix compilation for 32-bit Ahmad Fatoum
@ 2024-08-20 12:07 ` Sascha Hauer
  2024-08-20 12:13 ` Sascha Hauer
  2024-08-22 10:52 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2024-08-20 12:07 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Thu, 15 Aug 2024 13:44:55 +0200, Ahmad Fatoum wrote:
> Build test on x86 fails due to pointer cast and because of forcing the
> bigger alignment on the flexible array.
> 
> The problematic pointer cast is for the XSDT, which is 64-bit-only, so
> let's fix the cast and return an error if we somehow see an XSDT on
> 32-bit.
> 
> [...]

Applied, thanks!

[1/1] acpi: fix compilation for 32-bit
      https://git.pengutronix.de/cgit/barebox/commit/?id=4fa3b9d2b64b (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] acpi: fix compilation for 32-bit
  2024-08-15 11:44 [PATCH v2] acpi: fix compilation for 32-bit Ahmad Fatoum
  2024-08-20 12:07 ` Sascha Hauer
@ 2024-08-20 12:13 ` Sascha Hauer
  2024-08-22 10:52 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2024-08-20 12:13 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Thu, Aug 15, 2024 at 01:44:55PM +0200, Ahmad Fatoum wrote:
> From: Ahmad Fatoum <ahmad@a3f.at>
> 
> Build test on x86 fails due to pointer cast and because of forcing the
> bigger alignment on the flexible array.
> 
> The problematic pointer cast is for the XSDT, which is 64-bit-only, so
> let's fix the cast and return an error if we somehow see an XSDT on
> 32-bit.
> 
> For the flexible array, let's use the size of the pointer for the
> alignment.
> 
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
> v1 -> v2: 
>   - fix CI x86_64 breakage, by keeping the packed/aligned specifiction
>     as is, but changing it to 32-bit on 32-bit systems.
> ---
>  drivers/bus/acpi.c | 6 ++++--
>  include/acpi.h     | 2 +-
>  2 files changed, 5 insertions(+), 3 deletions(-)

I seem to have applied v1 of this patch. Can you send a fixup?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] acpi: fix compilation for 32-bit
  2024-08-15 11:44 [PATCH v2] acpi: fix compilation for 32-bit Ahmad Fatoum
  2024-08-20 12:07 ` Sascha Hauer
  2024-08-20 12:13 ` Sascha Hauer
@ 2024-08-22 10:52 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2024-08-22 10:52 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Thu, 15 Aug 2024 13:44:55 +0200, Ahmad Fatoum wrote:
> Build test on x86 fails due to pointer cast and because of forcing the
> bigger alignment on the flexible array.
> 
> The problematic pointer cast is for the XSDT, which is 64-bit-only, so
> let's fix the cast and return an error if we somehow see an XSDT on
> 32-bit.
> 
> [...]

Applied, thanks!

[1/1] acpi: fix compilation for 32-bit
      https://git.pengutronix.de/cgit/barebox/commit/?id=cd20189cd18b (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-22 10:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-15 11:44 [PATCH v2] acpi: fix compilation for 32-bit Ahmad Fatoum
2024-08-20 12:07 ` Sascha Hauer
2024-08-20 12:13 ` Sascha Hauer
2024-08-22 10:52 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox