Testcase improvements for PowerNV
cover Testcase improvements for PowerNV
Overview
========
Add a testcase to detect regression in remote interrupts when XIVE changes, since such regression had occurred during Power11 XIVE changes:
https://lore.kernel.org/qemu-devel/[email protected]/
Also add Power11 chip and testcase in qtests, and fadump functional test
Testing
=======
* Gitlab Pipeline: https://gitlab.com/adi-g15-ibm/qemu/-/pipelines/2590337589
Aditya Gupta (4):
tests/functional: Add remote interrupts test for PowerNV tests/qtest: Add Power11 chip & machine to qtests tests/qtest/pnv_spi: Test Power11 PNV_SPI tests/functional: Use default powernv machine instead of power10
tests/functional/ppc64/test_fadump.py | 2 +- tests/functional/ppc64/test_powernv.py | 65 ++++++++++++++++++++++++++ tests/qtest/pnv-spi-seeprom-test.c | 25 +++++++--- tests/qtest/pnv-xscom-test.c | 7 ++- tests/qtest/pnv-xscom.h | 17 +++++-- 5 files changed, 105 insertions(+), 11 deletions(-)
base-commit: de5d8bfd6105d3dd3ae668df9762df244a6d1506
Signature · 1 line
2.54.0
PATCH 1/4 tests/functional: Add remote interrupts test for PowerNV
In the past there have been hard to recreate issues where XIVE changes cause qemu crashes due to multi-socket interrupts such as in [1].
Add a functional test explicitly to test whether remote interrupts work.
The test can also work as additional boot test for multi-socket boot, initrd boot test, as well as a check for e1000e to be working in powernv, though that's not a target goal, and are additional benefits.
From docs/system/devices/net.rst:
In order to check that the user mode network is working, you can ping the address 10.0.2.2 and verify that you got an address in the range 10.0.2.x from the QEMU virtual DHCP server.
Hence use 10.0.2.2 with ping.
[1]: https://lore.kernel.org/qemu-devel/[email protected]/
--- tests/functional/ppc64/test_powernv.py | 65 ++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
tests/functional/ppc64/test_powernv.py +65 -0
@@ -9,6 +9,7 @@ from qemu_test import LinuxKernelTest, Asset from qemu_test import wait_for_console_pattern +from qemu_test import exec_command_and_wait_for_pattern class PowernvMachine(LinuxKernelTest):
@@ -71,6 +72,70 @@ def test_linux_smt_boot(self): wait_for_console_pattern(self, console_pattern, self.panic_message) wait_for_console_pattern(self, self.good_message, self.panic_message) + def test_linux_remote_interrupts(self): + self.require_accelerator("tcg") + self.set_machine('powernv') + + # have more sockets with as few CPUs as possible, increasing the + # probability to have remote interrupts from one chip to another + # also have e1000e network device to generate interrupts + self.vm.add_args('-smp', '4,sockets=4,threads=1') + self.vm.add_args('-device', 'e1000e,netdev=net0') + self.vm.add_args('-netdev', 'user,id=net0') + + kernel_path = self.ASSET_KERNEL.fetch() + rootfs_path = self.ASSET_INITRD.fetch() + self.vm.set_console() + self.vm.add_args('-kernel', kernel_path, + '-drive', + f'file={rootfs_path},format=raw,if=none,id=drive0,readonly=on', + '-append', 'root=/dev/nvme0n1 console=hvc0', + '-device', 'nvme,drive=drive0,bus=pcie.2,addr=0x0,serial=1234') + self.vm.launch() + + # Wait for boot to complete + console_pattern = 'CPU maps initialized for 1 thread per core' + wait_for_console_pattern(self, console_pattern, self.panic_message) + console_pattern = 'smp: Brought up 4 nodes, 4 CPUs' + wait_for_console_pattern(self, console_pattern, self.panic_message) + wait_for_console_pattern(self, 'Run /sbin/init as init process', + self.panic_message) + + # Wait for login prompt and login as root (no password in buildroot) + wait_for_console_pattern(self, 'login:', self.panic_message) + exec_command_and_wait_for_pattern(self, 'root', '#', self.panic_message) + + # RX, TX, Control interrupts to chip 2, 3, 4 respectively + exec_command_and_wait_for_pattern(self, + "RX_IRQ=$(grep eth0-rx /proc/interrupts | awk '{print $1}' | tr -d ':')", + '#', self.panic_message) + exec_command_and_wait_for_pattern(self, + "TX_IRQ=$(grep eth0-tx /proc/interrupts | awk '{print $1}' | tr -d ':')", + '#', self.panic_message) + exec_command_and_wait_for_pattern(self, + "CTL_IRQ=$(grep 'eth0$' /proc/interrupts | awk '{print $1}' | tr -d ':')", + '#', self.panic_message) + exec_command_and_wait_for_pattern(self, + "echo 1 > /proc/irq/$RX_IRQ/smp_affinity_list", + '#', self.panic_message) + exec_command_and_wait_for_pattern(self, + "echo 2 > /proc/irq/$TX_IRQ/smp_affinity_list", + '#', self.panic_message) + exec_command_and_wait_for_pattern(self, + "echo 3 > /proc/irq/$CTL_IRQ/smp_affinity_list", + '#', self.panic_message) + + # Generate network traffic to trigger remote interrupts + # Ping QEMU's user-mode network gateway (10.0.2.2) + exec_command_and_wait_for_pattern(self, + "ping -W2 -c5 10.0.2.2", + '#', self.panic_message) + + # Show final interrupt counts to verify remote interrupts occurred + exec_command_and_wait_for_pattern(self, + "cat /proc/interrupts | grep eth0", + '#', self.panic_message) + def test_linux_big_boot(self): self.set_machine('powernv') self.vm.add_args('-smp', '16,threads=4,cores=2,sockets=2')
Signature · 1 line
2.54.0
Re: [PATCH 1/4] tests/functional: Add remote interrupts test for PowerNV
Quoted 13 lines · Aditya Gupta
+ '#', self.panic_message)
+ exec_command_and_wait_for_pattern(self,
+ "CTL_IRQ=$(grep 'eth0$'/proc/interrupts| awk '{print $1}' | tr -d ':')",
+ '#', self.panic_message)
+ exec_command_and_wait_for_pattern(self,
+ "echo 1 >/proc/irq/$RX_IRQ/smp_affinity_list", + '#', self.panic_message)
+ exec_command_and_wait_for_pattern(self,
+ "echo 2 >/proc/irq/$TX_IRQ/smp_affinity_list", + '#', self.panic_message)
+ exec_command_and_wait_for_pattern(self,
Quoted 8 lines
+ "echo 3 >
/proc/irq/$CTL_IRQ/smp_affinity_list", + '#', self.panic_message)
+
+ # Generate network traffic to trigger remote interrupts + # Ping QEMU's user-mode network gateway (10.0.2.2) + exec_command_and_wait_for_pattern(self,
+ "ping -W2 -c5 10.0.2.2",
+ '#', self.panic_message)
Hi Aditya,
Thanks for this amazing test. But when I was tinkering with this test case, Even if i changed command to "asdf" it seemed to pass. Also, in the logs, sometime ping sometime it might fail.
pasta:review-aditya-qtests$ ./build/run python3 ./tests/functional/ppc64/test_powernv.py PowernvMachine.test_linux_remote_interrupts -v
TAP version 13
ok 1 test_powernv.PowernvMachine.test_linux_remote_interrupts 1..1
pasta:review-aditya-qtests$ cat build/tests/functional/ppc64/test_powernv.PowernvMachine.test_linux_rem ote_interrupts/console.log | grep -C5 "ping"
...
2026-06-12 12:59:26,316: ping -W2 -c5 10.0.2.2 2026-06-12 12:59:26,340: PING 10.0.2.2 (10.0.2.2): 56 data bytes 2026-06-12 12:59:26,343: ping: sendto: Network is unreachable
...
pasta:review-aditya-qtests$
Also the interrupt counters, I think we need to verify the cpu where the intrrupt is actually triggering.
~Shivang.
Re: [PATCH 1/4] tests/functional: Add remote interrupts test for PowerNV
Quoted 21 lines · Shivang Upadhyay
Quoted 12 lines · Aditya Gupta
+ '#', self.panic_message)
+ exec_command_and_wait_for_pattern(self,
+ "CTL_IRQ=$(grep 'eth0$'/proc/interrupts| awk '{print $1}' | tr -d ':')",
+ '#', self.panic_message)
+ exec_command_and_wait_for_pattern(self,
+ "echo 1 >/proc/irq/$RX_IRQ/smp_affinity_list", + '#', self.panic_message)
+ exec_command_and_wait_for_pattern(self,
+ "echo 2 >/proc/irq/$TX_IRQ/smp_affinity_list", + '#', self.panic_message)
+ exec_command_and_wait_for_pattern(self,Quoted 8 lines
+ "echo 3 >
/proc/irq/$CTL_IRQ/smp_affinity_list", + '#', self.panic_message)
+
+ # Generate network traffic to trigger remote interrupts + # Ping QEMU's user-mode network gateway (10.0.2.2) + exec_command_and_wait_for_pattern(self,
+ "ping -W2 -c5 10.0.2.2",
+ '#', self.panic_message)
Quoted 5 lines
Hi Aditya,
Thanks for this amazing test. But when I was tinkering with this test case, Even if i changed command to "asdf" it seemed to pass. Also, in the logs, sometime ping sometime it might fail.
The testcase wasn't that good, I had explicitly written it to just see if qemu keeps running, and doesn't crash on remote interrupts, as has been seen in the past. But yes, it's better if we actually check if ping caused any remote interrupts at all, since it wasn't checking that hence the testcase was passing. Planning to have a check in v2.
Quoted 10 lines
pasta:review-aditya-qtests$ ./build/run python3
./tests/functional/ppc64/test_powernv.pyPowernvMachine.test_linux_remote_interrupts -v
TAP version 13
ok 1 test_powernv.PowernvMachine.test_linux_remote_interrupts 1..1
pasta:review-aditya-qtests$ cat build/tests/functional/ppc64/test_powernv.PowernvMachine.test_linux_rem ote_interrupts/console.log | grep -C5 "ping"
...
Quoted 5 lines
2026-06-12 12:59:26,316: ping -W2 -c5 10.0.2.2 2026-06-12 12:59:26,340: PING 10.0.2.2 (10.0.2.2): 56 data bytes 2026-06-12 12:59:26,343: ping: sendto: Network is unreachable...
pasta:review-aditya-qtests$
This can happen if eth0 is not up yet, will handle it.
Quoted 3 lines
Also the interrupt counters, I think we need to verify the cpu where the intrrupt is actually triggering.
Sure, will add it in v2.
Thanks for reviewing shivang !
- Aditya G
Quoted 1 line
~Shivang.
PATCH 2/4 tests/qtest: Add Power11 chip & machine to qtests
In reply to Aditya GuptaPreviously the machines/chips tested by qtest was till Power10, update the tests to also test PowerNV11 and Power11 PNV Chip
--- tests/qtest/pnv-xscom-test.c | 7 ++++++- tests/qtest/pnv-xscom.h | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-)
tests/qtest/pnv-xscom-test.c +6 -1
@@ -35,6 +35,8 @@ static void test_cfam_id(const void *data) machine ="powernv9" ; }else if (chip->chip_type ==PNV_CHIP_POWER10 ) { machine ="powernv10" ; + }else if (chip->chip_type ==PNV_CHIP_POWER11 ) { + machine ="powernv11" ; } qts = qtest_initf("-M %s -accel tcg -cpu %s",
@@ -57,7 +59,8 @@ static void test_cfam_id(const void *data)static void test_xscom_core (QTestState *qts,const PnvChip *chip) { -if (chip->chip_type ==PNV_CHIP_POWER10 ) { +if ((chip->chip_type ==PNV_CHIP_POWER10 ) || + (chip->chip_type ==PNV_CHIP_POWER11 )) {uint32_t first_core_thread_state =PNV_XSCOM_P10_EC_BASE (chip->first_core) +0x412 ;uint64_t thread_state;
@@ -91,6 +94,8 @@ static void test_core(const void *data) machine ="powernv9" ; }else if (chip->chip_type ==PNV_CHIP_POWER10 ) { machine ="powernv10" ; + }else if (chip->chip_type ==PNV_CHIP_POWER11 ) { + machine ="powernv11" ; } qts = qtest_initf("-M %s -accel tcg -cpu %s",
tests/qtest/pnv-xscom.h +14 -3
@@ -9,6 +9,8 @@ #ifndef PNV_XSCOM_H #define PNV_XSCOM_H +#include <stdint.h> + #define SMT 4 /* some tests will break if less than 4 */ typedef enum PnvChipType {
@@ -17,6 +19,7 @@ typedef enum PnvChipType {PNV_CHIP_POWER8NVL ,/* AKA Naples */ PNV_CHIP_POWER9 ,/* AKA Nimbus */ PNV_CHIP_POWER10 , +PNV_CHIP_POWER11 , } PnvChipType; typedef struct PnvChip {
@@ -60,15 +63,23 @@ static const PnvChip pnv_chips[] = { .first_core = 0x0, .num_i2c = 4, }, + { + .chip_type = PNV_CHIP_POWER11, + .cpu_model = "Power11", + .xscom_base = 0x000603fc00000000ull, + .cfam_id = 0x220da04980000000ull, + .first_core = 0x0, + .num_i2c = 0, + }, };static inline uint64_t pnv_xscom_addr (const PnvChip *chip,uint32_t pcba) {uint64_t addr = chip->xscom_base; -if (chip->chip_type ==PNV_CHIP_POWER10 ) { - addr |= ((uint64_t ) pcba <<3 ); - }else if (chip->chip_type ==PNV_CHIP_POWER9 ) { +if ((chip->chip_type ==PNV_CHIP_POWER11 ) || + (chip->chip_type ==PNV_CHIP_POWER10 ) || + (chip->chip_type ==PNV_CHIP_POWER9 )) { addr |= ((uint64_t ) pcba <<3 ); }else { addr |= (((uint64_t) pcba << 4) & ~0xffull) |
Signature · 1 line
2.54.0
PATCH 3/4 tests/qtest/pnv_spi: Test Power11 PNV_SPI
In reply to Aditya GuptaCurrently pnv-spi-seeprom-test was hardcoded to test the 4th chip in pnv_chips (power10 as of now).
Iterate over all the chips instead, similar to other tests in pnv-xscom-test.c and pnv-host-i2c-test.c, but skip older chips, since TYPE_PNV_SPI only exists from Power10 onwards, hence skip older machines
This has 2 advantages, of not needing to update that the hardcoded index 3 in pnv_chips matches the machine type used, and that it tests all the pnv_chips similar to other qtests
--- tests/qtest/pnv-spi-seeprom-test.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
tests/qtest/pnv-spi-seeprom-test.c +19 -6
@@ -77,9 +77,14 @@ static void test_spi_seeprom(const void *data)const PnvChip *chip = data;QTestState *qts =NULL ; g_autofree char *tmp_path = NULL; +const char *machine ="powernv10" ;int ret;int fd; +if (chip->chip_type ==PNV_CHIP_POWER11 ) { + machine ="powernv11" ; + } +/* Create a temporary raw image */ fd =g_file_open_tmp ("qtest-seeprom-XXXXXX" , &tmp_path,NULL );g_assert (fd >=0 );
@@ -87,11 +92,11 @@ static void test_spi_seeprom(const void *data)g_assert (ret ==0 );close (fd); - qts =qtest_initf ("-machine powernv10 -smp 2,cores=2," + qts =qtest_initf ("-machine %s -smp 2,cores=2," "threads=1 -accel tcg,thread=single -nographic " "-blockdev node-name=pib_spic2,driver=file," "filename=%s -device 25csm04,bus=chip0.spi.2,cs=0," -"drive=pib_spic2" , tmp_path); +"drive=pib_spic2" , machine, tmp_path);spi_seeprom_transaction (qts, chip);qtest_quit (qts);unlink (tmp_path);
@@ -100,9 +105,17 @@ static void test_spi_seeprom(const void *data)int main (int argc,char **argv) {g_test_init (&argc, &argv,NULL ); -char *tname =g_strdup_printf ("pnv-xscom/spi-seeprom/%s" , - pnv_chips[3 ].cpu_model); -qtest_add_data_func (tname, &pnv_chips[3 ], test_spi_seeprom); -g_free (tname); + +for (int i =0 ; i <ARRAY_SIZE (pnv_chips); i++) { +/* TYPE_PNV_SPI is not instantiated for older Power8/9 machines */ +if (pnv_chips[i].chip_type <PNV_CHIP_POWER10 ) { +continue ; + } + +char *tname =g_strdup_printf ("pnv-xscom/spi-seeprom/%s" , + pnv_chips[i].cpu_model); +qtest_add_data_func (tname, &pnv_chips[i], test_spi_seeprom); +g_free (tname); + }return g_test_run (); }
Signature · 1 line
2.54.0
PATCH 4/4 tests/functional: Use default powernv machine instead of power10
In reply to Aditya GuptaThe default powernv machine has been recently changed to powernv11, though fadump functional test used powernv10
Change it to use default 'powernv' machine for the tests instead of being fixed to powernv10
--- tests/functional/ppc64/test_fadump.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/functional/ppc64/test_fadump.py +1 -1
@@ -53,7 +53,7 @@ def do_test_fadump(self, is_kvm=False, is_powernv=False): self.require_accelerator("tcg") if is_powernv: - self.set_machine("powernv10") + self.set_machine("powernv") else: # SLOF takes upto >20s in startup time, use VOF self.set_machine("pseries")
Signature · 1 line
2.54.0