Skip to contentSkip to conversation

ppc: add QEMU ppce500 test in CI

PATCH Applied Ahmad Fatoum 2 participants 8 messages Feb 9 – Feb 11

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

cover ppc: add QEMU ppce500 test in CI

Add support for running barebox on the QEMU ppce500 virtual machine. This enables automated testing of PowerPC e500 support in CI.

The PowerPC support for this virtual machine has been AI generated. I have no interest in learning the PowerPC ISA, but it's beneficial to remaining users for CI to be able to catch some runtime regressions as we only did compile tests so far.

With this, kvx is the only remaining architecture that is not tested in CI, but that's on the TODO list as well.

Ahmad Fatoum (6):
include: array_size.h: make header self-contained
serial: ns16550: add "ns16550" compatible string
lib: stackprot: omit HAVE_STACKPROTECTOR for powerpc
gpio: mpc8xxx: allow build on MPC85xx platforms
mach-mpc85xx: speed: add fsl_set_timebase_clock() override
powerpc: add QEMU ppce500 board support with CI test infrastructure

 .github/workflows/test-labgrid-pytest.yml     |   4 +
 arch/Kconfig                                  |   6 +
 arch/arm/Kconfig                              |   1 +
 arch/kvx/Kconfig                              |   1 +
 arch/mips/Kconfig                             |   1 +
 arch/openrisc/Kconfig                         |   1 +
 arch/powerpc/Makefile                         |   1 +
 arch/powerpc/boards/qemu-e500/Makefile        |   5 +
 arch/powerpc/boards/qemu-e500/law.c           |  17 ++
 arch/powerpc/boards/qemu-e500/qemu-e500.c     |  92 ++++++++
 arch/powerpc/boards/qemu-e500/tlb.c           |  17 ++
 arch/powerpc/configs/qemu-ppce500_defconfig   |  69 ++++++
 arch/powerpc/cpu-85xx/Makefile                |   3 +
 arch/powerpc/cpu-85xx/start-qemu.S            | 211 ++++++++++++++++++
 arch/powerpc/include/asm/board-qemu-e500.h    |  39 ++++
 arch/powerpc/include/asm/config.h             |   2 +
 arch/powerpc/include/asm/debug_ll.h           |  52 +++++
 arch/powerpc/lib/board.c                      |   6 +
 arch/powerpc/mach-mpc85xx/Kconfig             |  13 ++
 arch/powerpc/mach-mpc85xx/barebox.lds.S       |  12 +
 .../powerpc/mach-mpc85xx/include/mach/clock.h |   1 +
 .../include/mach/config_mpc85xx.h             |   6 +
 arch/powerpc/mach-mpc85xx/speed.c             |  10 +
 arch/riscv/Kconfig                            |   1 +
 arch/sandbox/Kconfig                          |   1 +
 arch/x86/Kconfig                              |   1 +
 common/Kconfig.debug_ll                       |   7 +-
 drivers/gpio/Kconfig                          |   2 +-
 drivers/serial/serial_ns16550.c               |   2 +
 include/linux/array_size.h                    |   3 +-
 lib/Kconfig.hardening                         |   2 +
 test/powerpc/qemu-ppce500_defconfig.yaml      |  17 ++
 32 files changed, 603 insertions(+), 3 deletions(-)
 create mode 100644 arch/powerpc/boards/qemu-e500/Makefile
 create mode 100644 arch/powerpc/boards/qemu-e500/law.c
 create mode 100644 arch/powerpc/boards/qemu-e500/qemu-e500.c
 create mode 100644 arch/powerpc/boards/qemu-e500/tlb.c
 create mode 100644 arch/powerpc/configs/qemu-ppce500_defconfig
 create mode 100644 arch/powerpc/cpu-85xx/start-qemu.S
 create mode 100644 arch/powerpc/include/asm/board-qemu-e500.h
 create mode 100644 arch/powerpc/include/asm/debug_ll.h
 create mode 100644 test/powerpc/qemu-ppce500_defconfig.yaml
Signature · 1 line
2.47.3
#1 lore raw

PATCH 1/6 include: array_size.h: make header self-contained

The definition of __must_be_array is a bit hairy as it's defined in <linux/compiler-gcc.h>, which is included by <linux/compiler_types.h>, but has an implicit dependency on <linux/build_bug.h> for BUILD_BUG_ON_ZERO in the definition of __must_be_array, but <linux/build_bug.h> itself already includes <linux/compiler_types.h>.

Let's put a bandaid on this for users of ARRAY_SIZE, by including <linux/build_bug.h> explicitly for <linux/array_size.h>.

---
 include/linux/array_size.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/array_size.h +2 -1
index 5411d730c819..d1ad53d950d4 100644
@@ -2,7 +2,8 @@
 #ifndef _LINUX_ARRAY_SIZE_H
 #define _LINUX_ARRAY_SIZE_H
 
-#include <linux/compiler.h>
+#include <linux/compiler_types.h>
+#include <linux/build_bug.h>
 
 /**
  * ARRAY_SIZE - get the number of elements in array @arr
Signature · 1 line
2.47.3
#2 lore raw

PATCH 2/6 serial: ns16550: add "ns16550" compatible string

In reply to Ahmad Fatoum

The QEMU ppce500 machine generates device tree nodes with "ns16550" as the compatible string rather than "ns16550a".

Add it to the match table so the driver binds automatically on QEMU platforms.

---
 drivers/serial/serial_ns16550.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/serial/serial_ns16550.c +2 -0
index 1d0ee7dc08f8..61e294a38c4c 100644
@@ -583,6 +583,8 @@ static struct of_device_id ns16550_serial_dt_ids[] = {
 	{
 		.compatible = "ns16450",
 		.data = &ns16450_drvdata,
+	}, {
+		.compatible = "ns16550",
 	}, {
 		.compatible = "ns16550a",
 	}, {
Signature · 1 line
2.47.3
#3 lore raw

PATCH 3/6 lib: stackprot: omit HAVE_STACKPROTECTOR for powerpc

In reply to Ahmad Fatoum

gcc for PowerPC generates references to __stack_chk_guard_local and aliasing it to __stack_chk_guard doesn't lead to a bootable barebox, so let's disable stack protector on that architecture.

The other architectures are assumed to work, but this should be verified per CI test in future.

---
 arch/Kconfig          | 6 ++++++
 arch/arm/Kconfig      | 1 +
 arch/kvx/Kconfig      | 1 +
 arch/mips/Kconfig     | 1 +
 arch/openrisc/Kconfig | 1 +
 arch/riscv/Kconfig    | 1 +
 arch/sandbox/Kconfig  | 1 +
 arch/x86/Kconfig      | 1 +
 lib/Kconfig.hardening | 2 ++
 9 files changed, 15 insertions(+)
arch/Kconfig +6 -0
index ca9aa25a9c4b..ba9dd0e6f4df 100644
@@ -131,6 +131,12 @@ config HAVE_ARCH_KASAN
 config ARCH_HAS_UBSAN_SANITIZE_ALL
 	bool
 
+config HAVE_STACKPROTECTOR
+	bool
+	help
+	  An arch should select this symbol if:
+	  - it has implemented a stack canary (e.g. __stack_chk_guard)
+
 config ARCH_HAS_FORTIFY_SOURCE
 	bool
 	help
arch/arm/Kconfig +1 -0
index 65856977ab41..c7514acb775f 100644
@@ -3,6 +3,7 @@
 config ARM
 	bool
 	select HAS_KALLSYMS
+	select HAVE_STACKPROTECTOR
 	select HAVE_IMAGE_COMPRESSION
 	select HAVE_ARCH_KASAN
 	select ARCH_HAS_SJLJ
arch/kvx/Kconfig +1 -0
index 987fdb2e1e89..bbbec6471f06 100644
@@ -3,6 +3,7 @@
 config KVX
 	bool
 	select 64BIT
+	select HAVE_STACKPROTECTOR
 	select BOOTM
 	select HAVE_ARCH_BOOTM_OFTREE
 	select BOOTM_OFTREE
arch/mips/Kconfig +1 -0
index 44c4fc82ae5b..d34377a33d47 100644
@@ -3,6 +3,7 @@
 config MIPS
 	bool
 	select GENERIC_LIB_ASHLDI3
+	select HAVE_STACKPROTECTOR
 	select GENERIC_LIB_ASHRDI3
 	select GENERIC_LIB_LSHRDI3
 	select HAS_KALLSYMS
arch/openrisc/Kconfig +1 -0
index 10cbfa1ffbce..f82d160a3a15 100644
@@ -3,6 +3,7 @@
 config OPENRISC
 	bool
 	select OFTREE
+	select HAVE_STACKPROTECTOR
 	select HAVE_CONFIGURABLE_MEMORY_LAYOUT
 	select GENERIC_FIND_NEXT_BIT
 	select ARCH_HAS_SJLJ
arch/riscv/Kconfig +1 -0
index cc9b15ce6409..f1d98d1b33a5 100644
@@ -3,6 +3,7 @@
 config RISCV
 	def_bool y
 	select GENERIC_FIND_NEXT_BIT
+	select HAVE_STACKPROTECTOR
 	select GPIOLIB
 	select OFTREE
 	select OFDEVICE
arch/sandbox/Kconfig +1 -0
index 5c7948b215cf..504171809193 100644
@@ -5,6 +5,7 @@ source "scripts/Kconfig.include"
 config SANDBOX
 	bool
 	select OFTREE
+	select HAVE_STACKPROTECTOR
 	select GPIOLIB
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARCH_HAS_FORTIFY_SOURCE
arch/x86/Kconfig +1 -0
index b453890f022b..3426392bc463 100644
@@ -3,6 +3,7 @@
 config X86
 	bool
 	select HAS_KALLSYMS
+	select HAVE_STACKPROTECTOR
 	select HAS_DMA
 	select GENERIC_FIND_NEXT_BIT
 	select ARCH_DMA_DEFAULT_COHERENT
lib/Kconfig.hardening +2 -0
index 59dd02c9cfae..6374576f489c 100644
@@ -162,6 +162,7 @@ config STACKPROTECTOR
 
 choice
 	prompt "Stack Protector buffer overflow detection"
+	depends on HAVE_STACKPROTECTOR
 
 config STACKPROTECTOR_NONE
 	bool "None"
@@ -211,6 +212,7 @@ endchoice
 
 choice
 	prompt "Stack Protector buffer overflow detection for PBL" if PBL_IMAGE
+	depends on HAVE_STACKPROTECTOR
 
 config PBL_STACKPROTECTOR_NONE
 	bool "None"
Signature · 1 line
2.47.3
#4 lore raw

PATCH 4/6 gpio: mpc8xxx: allow build on MPC85xx platforms

In reply to Ahmad Fatoum

The fsl,qoriq-gpio controller is present on MPC85xx-based platforms (including QEMU ppce500). Add ARCH_MPC85XX to the depends list so the driver can be selected for these platforms.

---
 drivers/gpio/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/Kconfig +1 -1
index 17d5587ea8cf..988d08cf143c 100644
@@ -102,7 +102,7 @@ config GPIO_MALTA_FPGA_I2C
 
 config GPIO_MPC8XXX
 	bool "MPC512x/MPC8xxx/QorIQ GPIO support"
-	depends on ARCH_LAYERSCAPE || COMPILE_TEST
+	depends on ARCH_LAYERSCAPE || ARCH_MPC85XX || COMPILE_TEST
 	select GPIO_GENERIC
 	help
 	  Say Y here if you're going to use hardware that connects to the
Signature · 1 line
2.47.3
#5 lore raw

PATCH 5/6 mach-mpc85xx: speed: add fsl_set_timebase_clock() override

In reply to Ahmad Fatoum

Some platforms (e.g. QEMU) don't implement the GUTS PORPLLSR register, so the register-based timebase frequency calculation returns 0. Add fsl_set_timebase_clock() that allows board code to provide the correct timebase frequency before initcalls run, bypassing the register read.

---
 arch/powerpc/mach-mpc85xx/include/mach/clock.h |  1 +
 arch/powerpc/mach-mpc85xx/speed.c              | 10 ++++++++++
 2 files changed, 11 insertions(+)
arch/powerpc/mach-mpc85xx/include/mach/clock.h +1 -0
index bfd9cf4d8ecd..2d0f079f5c68 100644
@@ -14,6 +14,7 @@ struct sys_info {
 
 unsigned long fsl_get_bus_freq(ulong dummy);
 unsigned long fsl_get_ddr_freq(ulong dummy);
+void fsl_set_timebase_clock(unsigned long freq);
 unsigned long fsl_get_timebase_clock(void);
 unsigned long fsl_get_i2c_freq(void);
 void fsl_get_sys_info(struct sys_info *sysInfo);
arch/powerpc/mach-mpc85xx/speed.c +10 -0
index 4a69de3dc81a..8018132874ba 100644
@@ -104,10 +104,20 @@ unsigned long fsl_get_ddr_freq(ulong dummy)
 	return sys_info.freqDDRBus;
 }
 
+static unsigned long timebase_clock_override;
+
+void fsl_set_timebase_clock(unsigned long freq)
+{
+	timebase_clock_override = freq;
+}
+
 unsigned long fsl_get_timebase_clock(void)
 {
 	struct sys_info sysinfo;
 
+	if (timebase_clock_override)
+		return timebase_clock_override;
+
 	fsl_get_sys_info(&sysinfo);
 
 	return (sysinfo.freqSystemBus + 4UL)/8UL;
Signature · 1 line
2.47.3
#6 lore raw

PATCH 6/6 powerpc: add QEMU ppce500 board support with CI test infrastructure

In reply to Ahmad Fatoum

Add support for running barebox on the QEMU ppce500 virtual machine. This enables automated testing of PowerPC e500 support in CI.

The ppce500 machine places CCSRBAR at effective address 0xE0000000 (physical 0xF_E0000000 with 36-bit addressing). The assembly entry sets up TLB entries for RAM, CCSRBAR MMIO, and the boot page, then jumps to C code which parses the timebase-frequency from the QEMU- provided device tree to configure the clocksource correctly (QEMU does not implement the GUTS PORPLLSR register).

Poweroff is handled by the existing gpio-poweroff driver, which uses the fsl,qoriq-gpio controller exposed in QEMU's device tree.

---
 .github/workflows/test-labgrid-pytest.yml     |   4 +
 arch/powerpc/Makefile                         |   1 +
 arch/powerpc/boards/qemu-e500/Makefile        |   5 +
 arch/powerpc/boards/qemu-e500/law.c           |  17 ++
 arch/powerpc/boards/qemu-e500/qemu-e500.c     |  92 ++++++++
 arch/powerpc/boards/qemu-e500/tlb.c           |  17 ++
 arch/powerpc/configs/qemu-ppce500_defconfig   |  69 ++++++
 arch/powerpc/cpu-85xx/Makefile                |   3 +
 arch/powerpc/cpu-85xx/start-qemu.S            | 211 ++++++++++++++++++
 arch/powerpc/include/asm/board-qemu-e500.h    |  39 ++++
 arch/powerpc/include/asm/config.h             |   2 +
 arch/powerpc/include/asm/debug_ll.h           |  52 +++++
 arch/powerpc/lib/board.c                      |   6 +
 arch/powerpc/mach-mpc85xx/Kconfig             |  13 ++
 arch/powerpc/mach-mpc85xx/barebox.lds.S       |  12 +
 .../include/mach/config_mpc85xx.h             |   6 +
 common/Kconfig.debug_ll                       |   7 +-
 test/powerpc/qemu-ppce500_defconfig.yaml      |  17 ++
 18 files changed, 572 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/boards/qemu-e500/Makefile
 create mode 100644 arch/powerpc/boards/qemu-e500/law.c
 create mode 100644 arch/powerpc/boards/qemu-e500/qemu-e500.c
 create mode 100644 arch/powerpc/boards/qemu-e500/tlb.c
 create mode 100644 arch/powerpc/configs/qemu-ppce500_defconfig
 create mode 100644 arch/powerpc/cpu-85xx/start-qemu.S
 create mode 100644 arch/powerpc/include/asm/board-qemu-e500.h
 create mode 100644 arch/powerpc/include/asm/debug_ll.h
 create mode 100644 test/powerpc/qemu-ppce500_defconfig.yaml
.github/workflows/test-labgrid-pytest.yml +4 -0
index c06bc5f11faa..7e385af65245 100644
@@ -49,6 +49,10 @@ jobs:
             lgenv: test/openrisc/generic_defconfig.yaml
             defconfig: generic_defconfig
 
+          - ARCH: powerpc
+            lgenv: test/powerpc/qemu-ppce500_defconfig.yaml
+            defconfig: qemu-ppce500_defconfig
+
           - ARCH: x86
             lgenv: test/x86/efi_defconfig.yaml
             defconfig: efi_defconfig
arch/powerpc/Makefile +1 -0
index ebd8fe60d3f1..fa511c6c1295 100644
@@ -18,6 +18,7 @@ KBUILD_CPPFLAGS += -Wa,-me500x2 -msoft-float -mno-string
 endif
 
 board-$(CONFIG_MACH_PHYCORE_MPC5200B_TINY)	:= pcm030
+board-$(CONFIG_QEMU_PPCE500)			:= qemu-e500
 board-$(CONFIG_P1010RDB)			:= freescale-p1010rdb
 board-$(CONFIG_P2020RDB)			:= freescale-p2020rdb
 board-$(CONFIG_P1022DS)				:= freescale-p1022ds
arch/powerpc/boards/qemu-e500/Makefile new file +5 -0
new file mode 100644
index 000000000000..15add493eea8
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+obj-y += qemu-e500.o
+obj-y += tlb.o
+obj-y += law.o
arch/powerpc/boards/qemu-e500/law.c new file +17 -0
new file mode 100644
index 000000000000..97683b01a573
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * LAW configuration for QEMU ppce500
+ *
+ * QEMU virtual hardware doesn't require LAW (Local Access Window)
+ * configuration, so we provide an empty table.
+ */
+
+#include <linux/types.h>
+#include <linux/array_size.h>
+#include <asm/fsl_law.h>
+
+struct law_entry law_table[] = {
+	/* No LAW entries needed for QEMU virtual hardware */
+};
+
+int num_law_entries = ARRAY_SIZE(law_table);
arch/powerpc/boards/qemu-e500/qemu-e500.c new file +92 -0

92 lines not on this page · raw message

arch/powerpc/boards/qemu-e500/tlb.c new file +17 -0
new file mode 100644
index 000000000000..a0f31a6fa85d
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * TLB configuration for QEMU ppce500
+ *
+ * QEMU sets up TLB entries before jumping to firmware, so we
+ * provide a minimal table here just for the API.
+ */
+
+#include <linux/types.h>
+#include <linux/array_size.h>
+#include <mach/mmu.h>
+
+struct fsl_e_tlb_entry tlb_table[] = {
+	/* QEMU already configured TLB - empty table */
+};
+
+int num_tlb_entries = ARRAY_SIZE(tlb_table);
arch/powerpc/configs/qemu-ppce500_defconfig new file +69 -0

69 lines not on this page · raw message

arch/powerpc/cpu-85xx/Makefile +3 -0
index cc85eb759472..a902ecb9c659 100644
@@ -4,5 +4,8 @@ obj-y			+= traps.o
 obj-y			+= tlb.o
 obj-y			+= cache.o
 obj-$(CONFIG_MMU)	+= mmu.o
+extra-$(CONFIG_QEMU_PPCE500) += start-qemu.o
+ifndef CONFIG_QEMU_PPCE500
 extra-y			+= start.o
 extra-y			+= resetvec.o
+endif
arch/powerpc/cpu-85xx/start-qemu.S new file +211 -0

211 lines not on this page · raw message

arch/powerpc/include/asm/board-qemu-e500.h new file +39 -0
new file mode 100644
index 000000000000..625d27b5185d
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * QEMU ppce500 virtual machine configuration
+ *
+ * CCSRBAR effective address is 0xE0000000, physical 0xF_E0000000
+ * (36-bit, MAS7 = 0xF).
+ */
+
+#ifndef __ASM_BOARD_QEMU_E500_H
+#define __ASM_BOARD_QEMU_E500_H
+
+/*
+ * Serial clock - QEMU's ns16550 baudbase is 399193, but we use
+ * 1843200 (standard 16550 crystal) so the divisor calculation
+ * produces a reasonable value. QEMU ignores the actual baud rate.
+ */
+#define CFG_SYS_CLK_FREQ	1843200
+
+/*
+ * DDR configuration - QEMU doesn't have a real DDR controller,
+ * but the define is needed for compilation.
+ */
+#define CFG_CHIP_SELECTS_PER_CTRL	1
+
+#define CFG_SDRAM_BASE		0x00000000
+
+/*
+ * CCSR (CCSRBAR) - SoC register space
+ *
+ * QEMU ppce500 maps CCSRBAR at effective address 0xE0000000,
+ * physical address 0xF_E0000000 (36-bit, MAS7 = 0xF).
+ */
+#define CFG_CCSRBAR_DEFAULT	0xE0000000
+#define CFG_CCSRBAR		0xE0000000
+#define CFG_CCSRBAR_PHYS	CFG_CCSRBAR
+#define CFG_CCSRBAR_PHYS_HIGH	0xF
+#define CFG_IMMR		CFG_CCSRBAR
+
+#endif /* __ASM_BOARD_QEMU_E500_H */
arch/powerpc/include/asm/config.h +2 -0
index 727daa872f20..59965095b92e 100644
@@ -39,6 +39,8 @@
 
 #ifdef CONFIG_MACH_PHYCORE_MPC5200B_TINY
 #include <asm/board-pcm030.h>
+#elif defined(CONFIG_QEMU_PPCE500)
+#include <asm/board-qemu-e500.h>
 #elif defined(CONFIG_P1010RDB)
 #include <asm/board-p1010rdb.h>
 #elif defined(CONFIG_P2020RDB)
arch/powerpc/include/asm/debug_ll.h new file +52 -0

52 lines not on this page · raw message

arch/powerpc/lib/board.c +6 -0
index a6111606b68c..3781345926a4 100644
@@ -43,7 +43,13 @@ void board_init_r (ulong end_of_ram)
 	asm ("sync ; isync");
 
 #ifdef CONFIG_MPC85xx
+#ifndef CONFIG_QEMU_PPCE500
+	/* Traditional boards relocate to end of RAM */
 	_text_base = end_of_ram;
+#else
+	/* QEMU: no relocation, stay at link address */
+	_text_base = TEXT_BASE;
+#endif
 #endif
 
 	malloc_end = (_text_base - STACK_SIZE) & ~(4095);
arch/powerpc/mach-mpc85xx/Kconfig +13 -0
index 550c554286d7..7f184babbee1 100644
@@ -11,11 +11,13 @@ config BTB
 
 config TEXT_BASE
 	hex
+	default 0x00f00000 if QEMU_PPCE500
 	default 0xeff80000 if P1010RDB || P2020RDB || P1022DS
 	default 0xfff80000 if DA923RC
 
 config RESET_VECTOR_ADDRESS
 	hex
+	default 0x00000000 if QEMU_PPCE500
 	default 0xfffffffc if DA923RC
 	default 0xeffffffc if P1010RDB || P2020RDB || P1022DS
 
@@ -33,6 +35,7 @@ config E500
 
 choice
 	prompt "Select your board"
+
 config P1010RDB
 	bool "P1010RDB"
     select P1010
@@ -64,6 +67,16 @@ config DA923RC
     select FSL_DDR2
 	help
 	Say Y here if you are using the GE Intelligent Platforms DA923RC
+
+config QEMU_PPCE500
+	bool "QEMU ppce500"
+	select HAS_DEBUG_LL
+	select LIBFDT
+	select GPIOLIB
+	help
+	  Say Y here for QEMU ppce500 generic paravirt e500 support.
+	  CCSRBAR is at 36-bit physical address 0xFE0000000.
+
 endchoice
 endif
 
arch/powerpc/mach-mpc85xx/barebox.lds.S +12 -0
index 5407ecc7e295..989fec7f1def 100644
@@ -22,7 +22,11 @@
 #endif
 
 OUTPUT_ARCH(BAREBOX_OUTPUT_ARCH)
+#ifdef CONFIG_QEMU_PPCE500
+ENTRY(_start_qemu_e500)
+#else
 ENTRY(_start_e500)
+#endif
 
 PHDRS
 {
@@ -122,6 +126,8 @@ SECTIONS
 
   __init_size = __init_end - _start;
 
+#ifndef CONFIG_QEMU_PPCE500
+  /* Boot page and reset vector for flash boot */
   .bootpg RESET_VECTOR_ADDRESS - 0xffc :
   {
     _text = .;
@@ -140,6 +146,12 @@ SECTIONS
   /* This avoids wrapping around to offset 0 */
   . |= 0x10;
 #endif
+#else
+  /* QEMU entry point: simpler, no boot page or reset vector needed */
+  .text_entry : {
+    arch/powerpc/cpu-85xx/start-qemu.o (.text_entry)
+  } :text
+#endif
 
   __bss_start = .;
   .bss        :
arch/powerpc/mach-mpc85xx/include/mach/config_mpc85xx.h +6 -0
index fad2c47d110f..0a53282c623c 100644
@@ -57,6 +57,12 @@
 #define PPC_E500_DEBUG_TLB	2
 #define FSL_TSECV2
 
+#elif defined(CONFIG_QEMU_PPCE500)
+#define MAX_CPUS		1
+#define FSL_NUM_LAWS		12
+#define PPC_E500_DEBUG_TLB	0
+/* QEMU e500: generic e500v2 platform, minimal configuration */
+
 #else
 #error Processor type not defined for this platform
 #endif
common/Kconfig.debug_ll +6 -1
index a08d29859d27..b11df2b79925 100644
@@ -311,6 +311,11 @@ config DEBUG_ZYNQMP_UART
 	  Say Y here if you want kernel low-level debugging support
 	  on Zynqmp.
 
+config DEBUG_QEMU_PPCE500
+	bool "Qemu ppce500 PowerPC ns16550 port"
+	depends on QEMU_PPCE500
+	select DEBUG_LL_NS16550
+
 config DEBUG_ERIZO
 	bool "Erizo ns16550 port"
 	depends on SOC_ERIZO
@@ -382,7 +387,7 @@ endchoice
 config DEBUG_LL_NS16550
 	bool
 	help
-	  Selected by RISC-V platforms that use ns16550 for debug_ll
+	  Selected by RISC-V and PowerPC platforms that use ns16550 for debug_ll
 
 config DEBUG_IMX_UART_PORT
 	int "i.MX Debug UART Port Selection" if DEBUG_IMX1_UART || \
test/powerpc/qemu-ppce500_defconfig.yaml new file +17 -0
new file mode 100644
index 000000000000..d64f42fc6eca
@@ -0,0 +1,17 @@
+targets:
+  main:
+    drivers:
+      QEMUDriver:
+        qemu_bin: qemu-system-ppc
+        machine: ppce500
+        cpu: e500
+        memory: 256M
+        kernel: barebox
+        display: qemu-default
+      BareboxDriver:
+        prompt: 'barebox:[^ ]+ '
+      BareboxTestStrategy: {}
+images:
+  barebox: !template "$LG_BUILDDIR/barebox"
+imports:
+  - ../strategy.py
Signature · 1 line
2.47.3
Applied
#7 lore raw
In reply to Ahmad Fatoum
Quoted 9 lines · Ahmad Fatoum

Add support for running barebox on the QEMU ppce500 virtual machine. This enables automated testing of PowerPC e500 support in CI.

The PowerPC support for this virtual machine has been AI generated. I have no interest in learning the PowerPC ISA, but it's beneficial to remaining users for CI to be able to catch some runtime regressions as we only did compile tests so far.

[...]

Applied, thanks!

[1/6] include: array_size.h: make header self-contained
https://git.pengutronix.de/cgit/barebox/commit/?id=e15799eb76e1 (link may not be stable)
[2/6] serial: ns16550: add "ns16550" compatible string
https://git.pengutronix.de/cgit/barebox/commit/?id=330ebc95133f (link may not be stable)
[3/6] lib: stackprot: omit HAVE_STACKPROTECTOR for powerpc
https://git.pengutronix.de/cgit/barebox/commit/?id=03c499b5733e (link may not be stable)
[4/6] gpio: mpc8xxx: allow build on MPC85xx platforms

      https://git.pengutronix.de/cgit/barebox/commit/?id=558b09065975 (link may not be stable)

[5/6] mach-mpc85xx: speed: add fsl_set_timebase_clock() override
https://git.pengutronix.de/cgit/barebox/commit/?id=1bb0e5326eed (link may not be stable)
[6/6] powerpc: add QEMU ppce500 board support with CI test infrastructure
https://git.pengutronix.de/cgit/barebox/commit/?id=91e209fa4e55 (link may not be stable)

Best regards,

Signature · 1 line
Sascha Hauer <[email protected]>