Skip to contentSkip to conversation

lib/acpi: Enable QEMU special cases for ARM

PATCH In review Alexander Graf 3 participants 4 messages Feb 27, 2022 – Mar 14, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/acpi: Enable QEMU special cases for ARM

With QEMU, we receive ACPI tables from the hypervisor rather than build them ourselves in U-Boot. That logic however hard codes the target to the x86 QEMU target, leaving ARM out on the fun.

Let's add the ARM QEMU config as well to the ifdefs so that we can consume QEMU provided firmware tables there as well.

---
 lib/acpi/Makefile      | 2 ++
 lib/acpi/acpi_writer.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
lib/acpi/Makefile +2 -0
index 956b5a0d72..66ba0e94ac 100644
@@ -9,6 +9,7 @@ obj-y += acpi_writer.o
 
 # With QEMU the ACPI tables come from there, not from U-Boot
 ifndef CONFIG_QEMU
+ifndef CONFIG_ARCH_QEMU
 obj-y += base.o
 obj-y += csrt.o
 obj-y += mcfg.o
@@ -21,3 +22,4 @@ endif
 obj-y += facs.o
 obj-y += ssdt.o
 endif
+endif
lib/acpi/acpi_writer.c +1 -1
index 946f90e8e7..9c252aa58d 100644
@@ -48,7 +48,7 @@ int acpi_write_one(struct acpi_ctx *ctx, const struct acpi_writer *entry)
 	return 0;
 }
 
-#ifndef CONFIG_QEMU
+#if !defined(CONFIG_QEMU) && !defined(CONFIG_ARCH_QEMU)
 static int acpi_write_all(struct acpi_ctx *ctx)
 {
 	const struct acpi_writer *writer =
Signature · 1 line
2.32.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Alexander Graf

With QEMU, we receive ACPI tables from the hypervisor rather than build them ourselves in U-Boot. That logic however hard codes the target to the x86 QEMU target, leaving ARM out on the fun.

Quoted 8 lines

Let's add the ARM QEMU config as well to the ifdefs so that we can consume QEMU provided firmware tables there as well.

---
 lib/acpi/Makefile      | 2 ++
 lib/acpi/acpi_writer.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
#2 lore raw
In reply to Alexander Graf
Quoted 35 lines · Alexander Graf

With QEMU, we receive ACPI tables from the hypervisor rather than build them ourselves in U-Boot. That logic however hard codes the target to the x86 QEMU target, leaving ARM out on the fun.

Let's add the ARM QEMU config as well to the ifdefs so that we can consume QEMU provided firmware tables there as well.

---
  lib/acpi/Makefile      | 2 ++
  lib/acpi/acpi_writer.c | 2 +-
  2 files changed, 3 insertions(+), 1 deletion(-)
lib/acpi/Makefile +2 -0
index 956b5a0d72..66ba0e94ac 100644
@@ -9,6 +9,7 @@ obj-y += acpi_writer.o
 
  # With QEMU the ACPI tables come from there, not from U-Boot
  ifndef CONFIG_QEMU
+ifndef CONFIG_ARCH_QEMU
  obj-y += base.o
  obj-y += csrt.o
  obj-y += mcfg.o
@@ -21,3 +22,4 @@ endif
  obj-y += facs.o
  obj-y += ssdt.o
  endif
+endif
lib/acpi/acpi_writer.c +0 -0
index 946f90e8e7..9c252aa58d 100644

lib/acpi/acpi_writer.c int acpi_write_one(struct acpi_ctx *ctx, const struct acpi_writer *entry) · line 51

Quoted 5 lines
lib/acpi/acpi_writer.c +1 -1
@@ -48,7 +48,7 @@ int acpi_write_one(struct acpi_ctx *ctx, const struct acpi_writer *entry)
  	return 0;
  }
 
-#ifndef CONFIG_QEMU
+#if !defined(CONFIG_QEMU) && !defined(CONFIG_ARCH_QEMU)

Why would you treat RISC-V QEMU differently?

Why should a symbol called CONFIG_QEMU relate to x86 and not to any QEMU? Why should a symbol called CONFIG_ARCH_QEMU relate to ARM?

It is preferable to clean up the chaotic naming of QEMU related symbols and to ensure that CONFIG_QEMU means any QEMU:

arch/arm/Kconfig:971:config ARCH_QEMU arch/arm/mach-qemu/Kconfig:16:config TARGET_QEMU_ARM_32BIT arch/arm/mach-qemu/Kconfig:23:config TARGET_QEMU_ARM_64BIT arch/powerpc/cpu/mpc85xx/Kconfig:108:config TARGET_QEMU_PPCE500 arch/powerpc/cpu/mpc85xx/Kconfig:638:config ARCH_QEMU_E500 arch/riscv/Kconfig:17:config TARGET_QEMU_VIRT arch/x86/cpu/qemu/Kconfig:5:config QEMU board/emulation/Kconfig:10:config TARGET_QEMU_X86 board/emulation/Kconfig:19:config TARGET_QEMU_X86_64

board/emulation/common/qemu_dfu.c and drivers/timer/tsc_timer.c are other instances where one QEMU architecture is treated differently to others without reason.

Best regards

Heinrich

Quoted 3 lines
lib/acpi/acpi_writer.c +0 -0
  static int acpi_write_all(struct acpi_ctx *ctx)
  {
  	const struct acpi_writer *writer =
#3 lore raw

Hi,

Quoted 51 lines · Heinrich Schuchardt
Quoted 35 lines · Alexander Graf

With QEMU, we receive ACPI tables from the hypervisor rather than build them ourselves in U-Boot. That logic however hard codes the target to the x86 QEMU target, leaving ARM out on the fun.

Let's add the ARM QEMU config as well to the ifdefs so that we can consume QEMU provided firmware tables there as well.

---
  lib/acpi/Makefile      | 2 ++
  lib/acpi/acpi_writer.c | 2 +-
  2 files changed, 3 insertions(+), 1 deletion(-)
lib/acpi/Makefile +2 -0
index 956b5a0d72..66ba0e94ac 100644
@@ -9,6 +9,7 @@ obj-y += acpi_writer.o
 
  # With QEMU the ACPI tables come from there, not from U-Boot
  ifndef CONFIG_QEMU
+ifndef CONFIG_ARCH_QEMU
  obj-y += base.o
  obj-y += csrt.o
  obj-y += mcfg.o
@@ -21,3 +22,4 @@ endif
  obj-y += facs.o
  obj-y += ssdt.o
  endif
+endif
lib/acpi/acpi_writer.c +0 -0
index 946f90e8e7..9c252aa58d 100644

lib/acpi/acpi_writer.c int acpi_write_one(struct acpi_ctx *ctx, const struct acpi_writer *entry) · line 51

Quoted 5 lines
lib/acpi/acpi_writer.c +1 -1
@@ -48,7 +48,7 @@ int acpi_write_one(struct acpi_ctx *ctx, const struct acpi_writer *entry)
      return 0;
  }
 
-#ifndef CONFIG_QEMU
+#if !defined(CONFIG_QEMU) && !defined(CONFIG_ARCH_QEMU)

Why would you treat RISC-V QEMU differently?

Why should a symbol called CONFIG_QEMU relate to x86 and not to any QEMU? Why should a symbol called CONFIG_ARCH_QEMU relate to ARM?

It is preferable to clean up the chaotic naming of QEMU related symbols and to ensure that CONFIG_QEMU means any QEMU:

Quoted 9 lines

arch/arm/Kconfig:971:config ARCH_QEMU arch/arm/mach-qemu/Kconfig:16:config TARGET_QEMU_ARM_32BIT arch/arm/mach-qemu/Kconfig:23:config TARGET_QEMU_ARM_64BIT arch/powerpc/cpu/mpc85xx/Kconfig:108:config TARGET_QEMU_PPCE500 arch/powerpc/cpu/mpc85xx/Kconfig:638:config ARCH_QEMU_E500 arch/riscv/Kconfig:17:config TARGET_QEMU_VIRT arch/x86/cpu/qemu/Kconfig:5:config QEMU board/emulation/Kconfig:10:config TARGET_QEMU_X86 board/emulation/Kconfig:19:config TARGET_QEMU_X86_64

Yes that would be good!

Quoted 13 lines

board/emulation/common/qemu_dfu.c and drivers/timer/tsc_timer.c are other instances where one QEMU architecture is treated differently to others without reason.

Best regards

Heinrich

Quoted 3 lines
lib/acpi/acpi_writer.c +0 -0
  static int acpi_write_all(struct acpi_ctx *ctx)
  {
      const struct acpi_writer *writer =

Regards,
SImon