powerpc improvements
Subsystems (6)
v10 cover powerpc improvements
Tree here
https://gitlab.com/npiggin/kvm-unit-tests/-/tree/powerpc
Since v9:
- Rebase after a good chunk of patches were merged.
- Review from Thomas:
- TCG/KVM host query is moved to the start of the series.
- Changelog for atomics test.
- Dropped spinlock patch change for now.
- Fixed tlbie assembly long lines in mmu patch.
- Use fdt64 accessor for 64-bit dt value.
- Upgrade powerpc gitlab CI to Fedora 40 and enable more tests
- Several other improvements.
- Reduced some long lines.
- Fixed some SPDX headers.
- New patch for adding a panic test. s390x is the only other panic test user but it requires KVM so I couldn't see if run_tests.sh looks sane there, but the harness needed a fix to work on powerpc.
Thanks,
Nick
Nicholas Piggin (15):
powerpc: Add facility to query TCG or KVM host
powerpc: Add atomics tests
powerpc: Add timebase tests
powerpc: Add MMU support
common/sieve: Support machines without MMU
powerpc: Add sieve.c common test
powerpc: add usermode support
powerpc: add pmu tests
configure: Make arch_libdir a first-class entity
powerpc: Remove remnants of ppc64 directory and build structure
powerpc: gitlab CI update
scripts/arch-run.bash: Fix run_panic() success exit status
powerpc: Add a panic test
powerpc/gitlab-ci: Upgrade powerpc to Fedora 40 powerpc/gitlab-ci: Enable more tests with Fedora 40
.gitlab-ci.yml | 36 +-
MAINTAINERS | 1 -
Makefile | 2 +-
common/sieve.c | 14 +-
configure | 63 ++-
lib/{ppc64 => powerpc}/asm-offsets.c | 0
lib/{ppc64 => powerpc}/asm/asm-offsets.h | 0
lib/{ppc64 => powerpc}/asm/atomic.h | 0
lib/{ppc64 => powerpc}/asm/barrier.h | 4 +-
lib/{ppc64 => powerpc}/asm/bitops.h | 4 +-
lib/powerpc/asm/hcall.h | 6 +
lib/{ppc64 => powerpc}/asm/io.h | 4 +-
lib/powerpc/asm/mmu.h | 86 ++++
lib/{ppc64 => powerpc}/asm/opal.h | 4 +-
lib/powerpc/asm/page.h | 65 +++
lib/powerpc/asm/pgtable-hwdef.h | 66 +++
lib/powerpc/asm/pgtable.h | 125 +++++
lib/powerpc/asm/processor.h | 15 +
lib/{ppc64 => powerpc}/asm/ptrace.h | 6 +-
lib/powerpc/asm/reg.h | 14 +
lib/powerpc/asm/rtas.h | 1 +
lib/powerpc/asm/setup.h | 1 +
lib/powerpc/asm/smp.h | 3 +
lib/powerpc/asm/spinlock.h | 6 +
lib/powerpc/asm/stack.h | 3 +
lib/{ppc64 => powerpc}/asm/vpa.h | 0
lib/powerpc/io.c | 7 +
lib/powerpc/mmu.c | 260 +++++++++++
lib/{ppc64 => powerpc}/opal-calls.S | 4 +-
lib/{ppc64 => powerpc}/opal.c | 0
lib/powerpc/processor.c | 47 ++
lib/powerpc/rtas.c | 19 +
lib/powerpc/setup.c | 61 ++-
lib/{ppc64 => powerpc}/stack.c | 0
lib/ppc64/.gitignore | 1 -
lib/ppc64/asm/handlers.h | 1 -
lib/ppc64/asm/hcall.h | 1 -
lib/ppc64/asm/memory_areas.h | 6 -
lib/ppc64/asm/page.h | 1 -
lib/ppc64/asm/ppc_asm.h | 1 -
lib/ppc64/asm/processor.h | 1 -
lib/ppc64/asm/reg.h | 1 -
lib/ppc64/asm/rtas.h | 1 -
lib/ppc64/asm/setup.h | 1 -
lib/ppc64/asm/smp.h | 1 -
lib/ppc64/asm/spinlock.h | 6 -
lib/ppc64/asm/stack.h | 11 -
lib/vmalloc.c | 7 +
lib/vmalloc.h | 2 +
powerpc/Makefile | 111 ++++-
powerpc/Makefile.common | 89 ----
powerpc/Makefile.ppc64 | 30 --
powerpc/atomics.c | 386 ++++++++++++++++
powerpc/interrupts.c | 129 +++++-
powerpc/mmu.c | 225 +++++++++
powerpc/pmu.c | 562 +++++++++++++++++++++++
powerpc/run | 2 +-
powerpc/selftest.c | 18 +-
powerpc/sieve.c | 1 +
powerpc/sprs.c | 2 +-
powerpc/timebase.c | 350 ++++++++++++++
powerpc/tm.c | 2 +-
powerpc/unittests.cfg | 64 ++-
scripts/arch-run.bash | 1 +
64 files changed, 2696 insertions(+), 245 deletions(-)
rename lib/{ppc64 => powerpc}/asm-offsets.c (100%)
rename lib/{ppc64 => powerpc}/asm/asm-offsets.h (100%)
rename lib/{ppc64 => powerpc}/asm/atomic.h (100%)
rename lib/{ppc64 => powerpc}/asm/barrier.h (83%)
rename lib/{ppc64 => powerpc}/asm/bitops.h (69%)
rename lib/{ppc64 => powerpc}/asm/io.h (50%)
create mode 100644 lib/powerpc/asm/mmu.h
rename lib/{ppc64 => powerpc}/asm/opal.h (90%)
create mode 100644 lib/powerpc/asm/page.h
create mode 100644 lib/powerpc/asm/pgtable-hwdef.h
create mode 100644 lib/powerpc/asm/pgtable.h
rename lib/{ppc64 => powerpc}/asm/ptrace.h (89%)
create mode 100644 lib/powerpc/asm/spinlock.h
rename lib/{ppc64 => powerpc}/asm/vpa.h (100%)
create mode 100644 lib/powerpc/mmu.c
rename lib/{ppc64 => powerpc}/opal-calls.S (88%)
rename lib/{ppc64 => powerpc}/opal.c (100%)
rename lib/{ppc64 => powerpc}/stack.c (100%)
delete mode 100644 lib/ppc64/.gitignore
delete mode 100644 lib/ppc64/asm/handlers.h
delete mode 100644 lib/ppc64/asm/hcall.h
delete mode 100644 lib/ppc64/asm/memory_areas.h
delete mode 100644 lib/ppc64/asm/page.h
delete mode 100644 lib/ppc64/asm/ppc_asm.h
delete mode 100644 lib/ppc64/asm/processor.h
delete mode 100644 lib/ppc64/asm/reg.h
delete mode 100644 lib/ppc64/asm/rtas.h
delete mode 100644 lib/ppc64/asm/setup.h
delete mode 100644 lib/ppc64/asm/smp.h
delete mode 100644 lib/ppc64/asm/spinlock.h
delete mode 100644 lib/ppc64/asm/stack.h
delete mode 100644 powerpc/Makefile.common
delete mode 100644 powerpc/Makefile.ppc64
create mode 100644 powerpc/atomics.c
create mode 100644 powerpc/mmu.c
create mode 100644 powerpc/pmu.c
create mode 120000 powerpc/sieve.c
create mode 100644 powerpc/timebase.cSignature · 1 line
2.45.1
PATCH v10 1/15 powerpc: Add facility to query TCG or KVM host
Use device tree properties to determine whether KVM or TCG is in use.
Logically these are not the inverse of one another, because KVM can run on a TCG processor (if TCG is emulating HV mode, or it is using the nested hypervisor APIs in pseries / spapr). And kvm-unit-tests can run on that KVM.
This can be a problem because some issues relate to TCG CPU emulation some to the spapr hypervisor implementation, some to KVM, some to real hardware, so the TCG test is best-effort for now and is set to the opposite of KVM. The two independent variables are added because we may be able to more accurately determine this in future.
Use this facility to restrict some of the known test failures to TCG.
--- lib/powerpc/asm/processor.h | 3 +++ lib/powerpc/setup.c | 26 ++++++++++++++++++++++++++ powerpc/interrupts.c | 6 ++++-- powerpc/sprs.c | 2 +- powerpc/tm.c | 2 +- 5 files changed, 35 insertions(+), 4 deletions(-)
lib/powerpc/asm/processor.h +3 -0
@@ -10,6 +10,9 @@ void handle_exception(int trap, void (*func)(struct pt_regs *, void *), void *);void do_handle_exception (struct pt_regs *regs);#endif /* __ASSEMBLY__ */ +extern bool host_is_tcg; +extern bool host_is_kvm; +extern bool cpu_has_hv;extern bool cpu_has_power_mce;extern bool cpu_has_siar;
lib/powerpc/setup.c +26 -0
@@ -208,6 +208,9 @@ void cpu_init(struct cpu *cpu, int cpu_id) cpu->exception_stack +=SZ_64K -64 ; } +bool host_is_tcg; +bool host_is_kvm; +void setup (const void *fdt) {void *freemem = &stacktop;
@@ -259,6 +262,29 @@ void setup(const void *fdt)assert (ret ==0 ); freemem += fdt_size; +if (!fdt_node_check_compatible (fdt,0 ,"qemu,pseries" )) { +assert (!cpu_has_hv); + +/* +* host_is_tcg incorrectly does not get set when running +* KVM on a TCG host (using powernv HV emulation or spapr +* nested HV). +*/ + ret =fdt_subnode_offset (fdt,0 ,"hypervisor" ); +if (ret <0 ) { + host_is_tcg = true; + host_is_kvm = false; + }else { +/* KVM is the only supported hypervisor */ +assert (!fdt_node_check_compatible (fdt, ret,"linux,kvm" )); + host_is_tcg = false; + host_is_kvm = true; + } + }else { +assert (cpu_has_hv); + host_is_tcg = true; + host_is_kvm = false; + } ret =dt_get_initrd (&tmp, &initrd_size);assert (ret ==0 || ret == -FDT_ERR_NOTFOUND );if (ret ==0 ) {
powerpc/interrupts.c +4 -2
@@ -72,7 +72,8 @@ static void test_mce(void) is_fetch = false; asmvolatile ("lbz %0,0(%1)" :"=r" (tmp) :"r" (addr)); -report (got_interrupt,"MCE on access to invalid real address" ); +/* KVM does not MCE on access outside partition scope */ +report_kfail (host_is_kvm, got_interrupt,"MCE on access to invalid real address" );if (got_interrupt) {report (mfspr (SPR_DAR ) == addr,"MCE sets DAR correctly" );if (cpu_has_power_mce)
@@ -82,7 +83,8 @@ static void test_mce(void) is_fetch = true; asmvolatile ("mtctr %0 ; bctrl" ::"r" (addr) :"ctr" ,"lr" ); -report (got_interrupt,"MCE on fetch from invalid real address" ); +/* KVM does not MCE on access outside partition scope */ +report_kfail (host_is_kvm, got_interrupt,"MCE on fetch from invalid real address" );if (got_interrupt) {report (recorded_regs.nip == addr,"MCE sets SRR0 correctly" );if (cpu_has_power_mce)
powerpc/sprs.c +1 -1
@@ -590,7 +590,7 @@ int main(int argc, char **argv)if (sprs[i].width ==32 && !(before[i] >>32 ) && !(after[i] >>32 )) {/* known failure KVM migration of CTRL */ -report_kfail (i ==136 , pass, +report_kfail (host_is_kvm && i ==136 , pass,"%-10s(%4d):\t 0x%08lx <==> 0x%08lx" , sprs[i].name, i, before[i], after[i]);
powerpc/tm.c +1 -1
@@ -135,7 +135,7 @@ int main(int argc, char **argv) }/* kvm-unit-tests can limit number of CPUs present */ /* KVM does not report TM in secondary threads in POWER9 */ -report_kfail (true, cpus_with_tm >= nr_cpus_present, +report_kfail (host_is_kvm, cpus_with_tm >= nr_cpus_present,"TM available in all 'ibm,pa-features' properties" ); all = argc ==1 || !strcmp (argv[1 ],"all" );
Signature · 1 line
2.45.1
PATCH v10 2/15 powerpc: Add atomics tests
In reply to Nicholas PigginAdd some tests for larx/stcx. operations for certain edge cases including migration, as well as some simple performance tests.
--- powerpc/Makefile.common | 1 + powerpc/atomics.c | 386 ++++++++++++++++++++++++++++++++++++++++ powerpc/unittests.cfg | 10 ++ 3 files changed, 397 insertions(+) create mode 100644 powerpc/atomics.c
powerpc/Makefile.common +1 -0
@@ -11,6 +11,7 @@ tests-common = \ $(TEST_DIR)/spapr_hcall.elf \ $(TEST_DIR)/rtas.elf \ $(TEST_DIR)/emulator.elf \ + $(TEST_DIR)/atomics.elf \ $(TEST_DIR)/tm.elf \ $(TEST_DIR)/smp.elf \ $(TEST_DIR)/sprs.elf \
powerpc/atomics.c new file +386 -0
386 lines not on this page · raw message
powerpc/unittests.cfg +10 -0
@@ -83,6 +83,16 @@ file = smp.elf smp = 8,threads=4 accel = tcg,thread=single +[atomics] +file = atomics.elf +smp = 2 + +[atomics-migration] +file = atomics.elf +machine = pseries +extra_params = -append "migration -m" +groups = migration + [h_cede_tm] file = tm.elf machine = pseries
Signature · 1 line
2.45.1
PATCH v10 3/15 powerpc: Add timebase tests
In reply to Nicholas PigginThis has a known failure on QEMU TCG machines where the decrementer interrupt is not lowered when the DEC wraps from -ve to +ve.
--- lib/powerpc/asm/reg.h | 1 + powerpc/Makefile.common | 1 + powerpc/timebase.c | 350 ++++++++++++++++++++++++++++++++++++++++ powerpc/unittests.cfg | 8 + 4 files changed, 360 insertions(+) create mode 100644 powerpc/timebase.c
lib/powerpc/asm/reg.h +1 -0
@@ -35,6 +35,7 @@#define SPR_HSRR1 0x13b#define SPR_LPCR 0x13e#define LPCR_HDICE UL(0x1) +#define LPCR_LD UL(0x20000)#define SPR_HEIR 0x153#define SPR_MMCR0 0x31b#define MMCR0_FC UL(0x80000000)
powerpc/Makefile.common +1 -0
@@ -15,6 +15,7 @@ tests-common = \ $(TEST_DIR)/tm.elf \ $(TEST_DIR)/smp.elf \ $(TEST_DIR)/sprs.elf \ + $(TEST_DIR)/timebase.elf \ $(TEST_DIR)/interrupts.elf tests-all = $(tests-common) $(tests)
powerpc/timebase.c new file +350 -0
350 lines not on this page · raw message
powerpc/unittests.cfg +8 -0
@@ -93,6 +93,14 @@ machine = pseries extra_params = -append "migration -m" groups = migration +[timebase] +file = timebase.elf + +[timebase-icount] +file = timebase.elf +accel = tcg +extra_params = -icount shift=5 + [h_cede_tm] file = tm.elf machine = pseries
Signature · 1 line
2.45.1
PATCH v10 4/15 powerpc: Add MMU support
In reply to Nicholas PigginAdd support for radix MMU, 4kB and 64kB pages.
This also adds MMU interrupt test cases, and runs the interrupts test entirely with MMU enabled if it is available (aside from machine check tests).
--- configure | 44 ++++-- lib/powerpc/asm/hcall.h | 6 + lib/powerpc/asm/processor.h | 1 + lib/powerpc/asm/reg.h | 3 + lib/powerpc/asm/smp.h | 2 + lib/powerpc/processor.c | 9 ++ lib/powerpc/setup.c | 8 +- lib/ppc64/asm/mmu.h | 87 ++++++++++++ lib/ppc64/asm/page.h | 66 ++++++++- lib/ppc64/asm/pgtable-hwdef.h | 66 +++++++++ lib/ppc64/asm/pgtable.h | 125 ++++++++++++++++ lib/ppc64/mmu.c | 258 ++++++++++++++++++++++++++++++++++ lib/ppc64/opal-calls.S | 4 +- powerpc/Makefile.common | 4 +- powerpc/Makefile.ppc64 | 1 + powerpc/interrupts.c | 95 +++++++++++-- powerpc/mmu.c | 225 +++++++++++++++++++++++++++++ powerpc/unittests.cfg | 4 + 18 files changed, 978 insertions(+), 30 deletions(-) create mode 100644 lib/ppc64/asm/mmu.h create mode 100644 lib/ppc64/asm/pgtable-hwdef.h create mode 100644 lib/ppc64/asm/pgtable.h create mode 100644 lib/ppc64/mmu.c create mode 100644 powerpc/mmu.c
configure +30 -14
@@ -74,8 +74,9 @@ usage() { Allow PV guests to be dumped. Requires at least z16. (s390x only) --page-size=PAGE_SIZE - Specify the page size (translation granule) (4k, 16k or - 64k, default is 4k, arm64 only) + Specify the page size (translation granule). PAGE_SIZE can be + 4k [default], 16k, 64k for arm64. + 4k [default], 64k for ppc64. --earlycon=EARLYCON Specify the UART name, type and address (optional, arm and arm64 only). The specified address will overwrite the UART
@@ -245,25 +246,33 @@ fi if [ -z "$page_size" ]; then if [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then page_size="4096" + elif [ "$arch" = "ppc64" ]; then + page_size="65536" fi else - if [ "$arch" != "arm64" ]; then - echo "--page-size is not supported for $arch" - usage - fi - if [ "${page_size: -1}" = "K" ] || [ "${page_size: -1}" = "k" ]; then page_size=$(( ${page_size%?} * 1024 )) fi - if [ "$page_size" != "4096" ] && [ "$page_size" != "16384" ] && - [ "$page_size" != "65536" ]; then - echo "arm64 doesn't support page size of $page_size" + + if [ "$arch" = "arm64" ]; then + if [ "$page_size" != "4096" ] && [ "$page_size" != "16384" ] && + [ "$page_size" != "65536" ]; then + echo "arm64 doesn't support page size of $page_size" + usage + fi + if [ "$efi" = 'y' ] && [ "$page_size" != "4096" ]; then + echo "efi must use 4K pages" + exit 1 + fi + elif [ "$arch" = "ppc64" ]; then + if [ "$page_size" != "4096" ] && [ "$page_size" != "65536" ]; then + echo "ppc64 doesn't support page size of $page_size" + usage + fi + else + echo "--page-size is not supported for $arch" usage fi - if [ "$efi" = 'y' ] && [ "$page_size" != "4096" ]; then - echo "efi must use 4K pages" - exit 1 - fi fi [ -z "$processor" ] && processor="$arch"
@@ -472,6 +481,13 @@ cat <<EOF >> lib/config.h #define CONFIG_UART_EARLY_BASE ${arm_uart_early_addr} #define CONFIG_ERRATA_FORCE ${errata_force} + +EOF +fi + +if [ "$arch" = "arm" ] || [ "$arch" = "arm64" ] || [ "$arch" = "ppc64" ]; then +cat <<EOF >> lib/config.h + #define CONFIG_PAGE_SIZE _AC(${page_size}, UL) EOF
lib/powerpc/asm/hcall.h +6 -0
@@ -24,6 +24,12 @@#define H_PUT_TERM_CHAR 0x58#define H_RANDOM 0x300#define H_SET_MODE 0x31C +#define H_REGISTER_PROCESS_TABLE 0x37C + +#define PTBL_NEW 0x18 +#define PTBL_UNREGISTER 0x10 +#define PTBL_RADIX 0x04 +#define PTBL_GTSE 0x01#define KVMPPC_HCALL_BASE 0xf000#define KVMPPC_H_RTAS (KVMPPC_HCALL_BASE + 0x0)
lib/powerpc/asm/processor.h +1 -0
@@ -17,6 +17,7 @@ extern bool cpu_has_hv;extern bool cpu_has_power_mce;extern bool cpu_has_siar;extern bool cpu_has_heai; +extern bool cpu_has_radix;extern bool cpu_has_prefix;extern bool cpu_has_sc_lev;extern bool cpu_has_pause_short;
lib/powerpc/asm/reg.h +3 -0
@@ -11,6 +11,7 @@#define SPR_SRR0 0x01a#define SPR_SRR1 0x01b#define SRR1_PREFIX UL(0x20000000) +#define SPR_PIDR 0x030#define SPR_FSCR 0x099#define FSCR_PREFIX UL(0x2000)#define SPR_HFSCR 0x0be
@@ -36,7 +37,9 @@#define SPR_LPCR 0x13e#define LPCR_HDICE UL(0x1)#define LPCR_LD UL(0x20000) +#define SPR_LPIDR 0x13f#define SPR_HEIR 0x153 +#define SPR_PTCR 0x1d0#define SPR_MMCR0 0x31b#define MMCR0_FC UL(0x80000000)#define MMCR0_PMAE UL(0x04000000)
lib/powerpc/asm/smp.h +2 -0
@@ -3,6 +3,7 @@#include <libcflat.h> #include <asm/processor.h> +#include <asm/page.h> typedef void (*secondary_entry_fn )(int cpu_id);
@@ -11,6 +12,7 @@ struct cpu {unsigned long stack;unsigned long exception_stack;secondary_entry_fn entry; +pgd_t *pgtable; };extern int nr_cpus_present;
lib/powerpc/processor.c +9 -0
@@ -13,6 +13,7 @@#include <asm/barrier.h> #include <asm/hcall.h> #include <asm/handlers.h> +#include <asm/mmu.h> #include <asm/smp.h> static struct {
@@ -47,6 +48,14 @@ void do_handle_exception(struct pt_regs *regs) __current_cpu = (struct cpu *)mfspr (SPR_SPRG0 ); +/* +* We run with AIL=0, so interrupts taken with MMU disabled. +* Enable here. +*/ +assert (!(mfmsr () & (MSR_IR |MSR_DR ))); +if (mmu_enabled ()) +mtmsr (mfmsr () | (MSR_IR |MSR_DR )); + v = regs->trap >>5 ;if (v <128 && handlers[v].func) {
lib/powerpc/setup.c +6 -2
@@ -103,6 +103,7 @@ bool cpu_has_hv;bool cpu_has_power_mce;/* POWER CPU machine checks */ bool cpu_has_siar;bool cpu_has_heai; +bool cpu_has_radix;bool cpu_has_prefix;bool cpu_has_sc_lev;/* sc interrupt has LEV field in SRR1 */ bool cpu_has_pause_short;
@@ -125,6 +126,7 @@ static void cpu_init_params(void) cpu_has_sc_lev = true; cpu_has_pause_short = true;case PVR_VER_POWER9 : + cpu_has_radix = true;case PVR_VER_POWER8E :case PVR_VER_POWER8NVL :case PVR_VER_POWER8 :
@@ -202,10 +204,11 @@ void cpu_init(struct cpu *cpu, int cpu_id) { cpu->server_no = cpu_id; - cpu->stack = (unsigned long )memalign (SZ_4K ,SZ_64K ); + cpu->stack = (unsigned long )memalign_pages (SZ_4K ,SZ_64K ); cpu->stack +=SZ_64K -64 ; - cpu->exception_stack = (unsigned long )memalign (SZ_4K ,SZ_64K ); + cpu->exception_stack = (unsigned long )memalign_pages (SZ_4K ,SZ_64K ); cpu->exception_stack +=SZ_64K -64 ; + cpu->pgtable =NULL ; }bool host_is_tcg;
@@ -227,6 +230,7 @@ void setup(const void *fdt) cpu->server_no =fdt_boot_cpuid_phys (fdt); cpu->exception_stack = (unsigned long )boot_exception_stack; cpu->exception_stack +=EXCEPTION_STACK_SIZE -64 ; + cpu->pgtable =NULL ;mtspr (SPR_SPRG0 , (unsigned long )cpu); __current_cpu = cpu;
lib/ppc64/asm/mmu.h new file +87 -0
87 lines not on this page · raw message
lib/ppc64/asm/page.h +65 -1
66 lines not on this page · raw message
lib/ppc64/asm/pgtable-hwdef.h new file +66 -0
66 lines not on this page · raw message
lib/ppc64/asm/pgtable.h new file +125 -0
125 lines not on this page · raw message
lib/ppc64/mmu.c new file +258 -0
258 lines not on this page · raw message
lib/ppc64/opal-calls.S +2 -2
@@ -25,8 +25,8 @@ opal_call: mfmsr r12 std r12,-16(r1) /* use redzone */ - /* switch to BE when we enter OPAL */ - li r11,(1 << MSR_LE_BIT) + /* switch to BE and real-mode when we enter OPAL */ + li r11,(1 << MSR_LE_BIT) | MSR_IR | MSR_DR ori r11,r11,(1 << MSR_EE_BIT) andc r12,r12,r11 mtspr SPR_HSRR1,r12
powerpc/Makefile.common +3 -1
@@ -16,7 +16,8 @@ tests-common = \ $(TEST_DIR)/smp.elf \ $(TEST_DIR)/sprs.elf \ $(TEST_DIR)/timebase.elf \ - $(TEST_DIR)/interrupts.elf + $(TEST_DIR)/interrupts.elf \ + $(TEST_DIR)/mmu.elf tests-all = $(tests-common) $(tests) all: directories $(TEST_DIR)/boot_rom.bin $(tests-all)
@@ -42,6 +43,7 @@ cflatobjs += lib/getchar.o cflatobjs += lib/alloc_phys.o cflatobjs += lib/alloc.o cflatobjs += lib/alloc_page.o +cflatobjs += lib/vmalloc.o cflatobjs += lib/devicetree.o cflatobjs += lib/migrate.o cflatobjs += lib/powerpc/io.o
powerpc/Makefile.ppc64 +1 -0
@@ -18,6 +18,7 @@ reloc.o = $(TEST_DIR)/reloc64.o OBJDIRS += lib/ppc64 cflatobjs += lib/ppc64/stack.o +cflatobjs += lib/ppc64/mmu.o cflatobjs += lib/ppc64/opal.o cflatobjs += lib/ppc64/opal-calls.o
powerpc/interrupts.c +85 -10
153 lines not on this page · raw message
powerpc/mmu.c new file +225 -0
225 lines not on this page · raw message
powerpc/unittests.cfg +4 -0
@@ -69,6 +69,10 @@ file = emulator.elf [interrupts] file = interrupts.elf +[mmu] +file = mmu.elf +smp = 2 + [smp] file = smp.elf smp = 2
Signature · 1 line
2.45.1
PATCH v10 5/15 common/sieve: Support machines without MMU
In reply to Nicholas PigginNot all powerpc CPUs provide MMU support. Define vm_available() that is true by default but archs can override it. Use this to run VM tests.
--- common/sieve.c | 14 ++++++++------ lib/ppc64/asm/mmu.h | 1 - lib/ppc64/mmu.c | 2 +- lib/vmalloc.c | 7 +++++++ lib/vmalloc.h | 2 ++ 5 files changed, 18 insertions(+), 8 deletions(-)
common/sieve.c +8 -6
@@ -40,12 +40,14 @@ int main(void)printf ("starting sieve\n" );test_sieve ("static" , static_data,STATIC_SIZE ); -setup_vm (); -test_sieve ("mapped" , static_data,STATIC_SIZE ); -for (i =0 ; i <3 ; ++i) { - v =malloc (VSIZE ); -test_sieve ("virtual" , v,VSIZE ); -free (v); +if (vm_available ()) { +setup_vm (); +test_sieve ("mapped" , static_data,STATIC_SIZE ); +for (i =0 ; i <3 ; ++i) { + v =malloc (VSIZE ); +test_sieve ("virtual" , v,VSIZE ); +free (v); + } }return 0 ;
lib/ppc64/asm/mmu.h +0 -1
@@ -4,7 +4,6 @@#include <asm/pgtable.h> -bool vm_available (void );bool mmu_enabled (void );void mmu_enable (pgd_t *pgtable);void mmu_disable (void );
lib/ppc64/mmu.c +1 -1
@@ -23,7 +23,7 @@static pgd_t *identity_pgd; -bool vm_available (void ) +bool vm_available (void )/* weak override */ {return cpu_has_radix; }
lib/vmalloc.c +7 -0
@@ -206,10 +206,17 @@ void init_alloc_vpage(void *top)spin_unlock (&lock); } +bool __attribute__((__weak__))vm_available (void ) +{ +return true; +} +void __setup_vm (void *opaque) {phys_addr_t base, top; +assert_msg (vm_available (),"Virtual memory not available. Must check vm_available() before calling setup_vm()" ); +if (alloc_ops == &vmalloc_ops)return ;
lib/vmalloc.h +2 -0
@@ -17,6 +17,8 @@ extern void setup_vm(void);/* As above, plus passes an opaque value to setup_mmu(). */ extern void __setup_vm (void *opaque); +/* common/ tests must check availability before calling setup_vm() */ +extern bool vm_available (void );/* Set up paging */ extern void *setup_mmu (phys_addr_t top,void *opaque);/* Walk the page table and resolve the virtual address to a physical address */
Signature · 1 line
2.45.1
PATCH v10 6/15 powerpc: Add sieve.c common test
In reply to Nicholas PigginNow that sieve copes with lack of MMU support, it can be run by powerpc.
--- powerpc/Makefile.common | 1 + powerpc/sieve.c | 1 + powerpc/unittests.cfg | 3 +++ 3 files changed, 5 insertions(+) create mode 120000 powerpc/sieve.c
powerpc/Makefile.common +1 -0
@@ -8,6 +8,7 @@ tests-common = \ $(TEST_DIR)/selftest.elf \ $(TEST_DIR)/selftest-migration.elf \ $(TEST_DIR)/memory-verify.elf \ + $(TEST_DIR)/sieve.elf \ $(TEST_DIR)/spapr_hcall.elf \ $(TEST_DIR)/rtas.elf \ $(TEST_DIR)/emulator.elf \
powerpc/sieve.c new file +1 -0
@@ -0,0 +1 @@ +../common/sieve.c
powerpc/unittests.cfg +3 -0
@@ -121,3 +121,6 @@ file = sprs.elf machine = pseries extra_params = -append '-w' groups = migration + +[sieve] +file = sieve.elf
Signature · 1 line
2.45.1
PATCH v10 7/15 powerpc: add usermode support
In reply to Nicholas PigginThe biggest difficulty for user mode is MMU support. Otherwise it is a simple matter of setting and clearing MSR[PR] with rfid and sc respectively.
Some common harness operations will fail in usermode, so some workarounds are reqiured (e.g., puts() can't be used directly).
A usermode privileged instruction interrupt test is added.
--- lib/powerpc/asm/processor.h | 9 +++++++++ lib/powerpc/asm/reg.h | 1 + lib/powerpc/asm/smp.h | 1 + lib/powerpc/io.c | 7 +++++++ lib/powerpc/processor.c | 38 +++++++++++++++++++++++++++++++++++++ lib/powerpc/rtas.c | 3 +++ lib/powerpc/setup.c | 7 +++++-- lib/ppc64/mmu.c | 2 ++ powerpc/interrupts.c | 28 +++++++++++++++++++++++++++ 9 files changed, 94 insertions(+), 2 deletions(-)
lib/powerpc/asm/processor.h +9 -0
@@ -22,6 +22,8 @@ extern bool cpu_has_prefix;extern bool cpu_has_sc_lev;extern bool cpu_has_pause_short; +bool in_usermode (void ); +static inline uint64_t mfspr (int nr) {uint64_t ret;
@@ -54,6 +56,8 @@ static inline void local_irq_enable(void) {unsigned long msr; +assert (!in_usermode ()); + asm volatile( " mfmsr %0 \n \ ori %0,%0,%1 \n \
@@ -65,6 +69,8 @@ static inline void local_irq_disable(void) {unsigned long msr; +assert (!in_usermode ()); + asm volatile( " mfmsr %0 \n \ andc %0,%0,%1 \n \
@@ -93,4 +99,7 @@ static inline bool machine_is_pseries(void)void enable_mcheck (void );void disable_mcheck (void ); +void enter_usermode (void ); +void exit_usermode (void ); +#endif /* _ASMPOWERPC_PROCESSOR_H_ */
lib/powerpc/asm/reg.h +1 -0
@@ -58,5 +58,6 @@#define MSR_SE UL(0x0400)/* Single Step Enable */ #define MSR_EE UL(0x8000)#define MSR_ME UL(0x1000) +#define MSR_PR UL(0x4000)#endif
lib/powerpc/asm/smp.h +1 -0
@@ -11,6 +11,7 @@ struct cpu {unsigned long server_no;unsigned long stack;unsigned long exception_stack; +bool in_user;secondary_entry_fn entry;pgd_t *pgtable; };
lib/powerpc/io.c +7 -0
@@ -11,6 +11,7 @@#include <asm/setup.h> #include <asm/processor.h> #include <asm/atomic.h> +#include <asm/smp.h> #include "io.h" static struct spinlock print_lock;
@@ -41,10 +42,16 @@ void io_init(void)void puts (const char *s) { +bool user =in_usermode (); + +if (user) +exit_usermode ();spin_lock (&print_lock);while (*s)putchar (*s++);spin_unlock (&print_lock); +if (user) +enter_usermode (); }/*
lib/powerpc/processor.c +38 -0
@@ -47,6 +47,8 @@ void do_handle_exception(struct pt_regs *regs)unsigned char v; __current_cpu = (struct cpu *)mfspr (SPR_SPRG0 ); +if (in_usermode ()) +current_cpu ()->in_user = false;/* * We run with AIL=0, so interrupts taken with MMU disabled.
@@ -60,6 +62,8 @@ void do_handle_exception(struct pt_regs *regs)if (v <128 && handlers[v].func) { handlers[v].func (regs, handlers[v].data); +if (regs->msr &MSR_PR ) +current_cpu ()->in_user = true;return ; }
@@ -169,3 +173,37 @@ void disable_mcheck(void) {rfid_msr (mfmsr () & ~MSR_ME ); } + +bool in_usermode (void ) +{ +return current_cpu ()->in_user; +} + +static void usermode_sc_handler (struct pt_regs *regs,void *data) +{ + regs->msr &= ~(MSR_PR |MSR_EE ); +/* Interrupt return handler will keep in_user clear */ +} + +void enter_usermode (void ) +{ +assert_msg (!in_usermode (),"enter_usermode called with in_usermode" ); +/* mfmsr would fault in usermode anyway */ +assert_msg (!(mfmsr () &MSR_PR ),"enter_usermode called from user mode" ); +assert_msg (!(mfmsr () &MSR_EE ),"enter_usermode called with interrupts enabled" ); +assert_msg ((mfmsr () & (MSR_IR |MSR_DR )) == (MSR_IR |MSR_DR ), +"enter_usermode called with virtual memory disabled" ); + +handle_exception (0xc00 , usermode_sc_handler,NULL ); +rfid_msr (mfmsr () | (MSR_PR |MSR_IR |MSR_DR |MSR_EE )); +current_cpu ()->in_user = true; +} + +void exit_usermode (void ) +{ +assert_msg (in_usermode (),"enter_usermode called with !in_usermode" ); + asmvolatile ("sc 0" :::"memory" ); +handle_exception (0xc00 ,NULL ,NULL ); +assert (!in_usermode ()); +assert (!(mfmsr () &MSR_PR )); +}
lib/powerpc/rtas.c +3 -0
@@ -9,6 +9,7 @@#include <libfdt/libfdt.h> #include <devicetree.h> #include <asm/spinlock.h> +#include <asm/smp.h> #include <asm/hcall.h> #include <asm/io.h> #include <asm/rtas.h>
@@ -137,6 +138,8 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)va_list list;int ret; +assert_msg (!in_usermode (),"May not make RTAS call from user mode\n" ); +spin_lock (&rtas_lock);va_start (list, outputs);
lib/powerpc/setup.c +5 -2
@@ -209,10 +209,12 @@ void cpu_init(struct cpu *cpu, int cpu_id) cpu->exception_stack = (unsigned long )memalign_pages (SZ_4K ,SZ_64K ); cpu->exception_stack +=SZ_64K -64 ; cpu->pgtable =NULL ; + cpu->in_user = false; }bool host_is_tcg;bool host_is_kvm; +bool is_hvmode;void setup (const void *fdt) {
@@ -222,8 +224,6 @@ void setup(const void *fdt)u32 fdt_size;int ret; - cpu_has_hv = !!(mfmsr () & (1ULL <<MSR_HV_BIT )); -memset (cpus,0xff ,sizeof (cpus)); cpu = &cpus[0 ];
@@ -231,10 +231,13 @@ void setup(const void *fdt) cpu->exception_stack = (unsigned long )boot_exception_stack; cpu->exception_stack +=EXCEPTION_STACK_SIZE -64 ; cpu->pgtable =NULL ; + cpu->in_user = false;mtspr (SPR_SPRG0 , (unsigned long )cpu); __current_cpu = cpu; + cpu_has_hv = !!(mfmsr () & (1ULL <<MSR_HV_BIT )); +enable_mcheck ();/*
lib/ppc64/mmu.c +2 -0
@@ -42,6 +42,7 @@ void mmu_enable(pgd_t *pgtable) cpu->pgtable = pgtable; +assert (!in_usermode ());mtmsr (mfmsr () | (MSR_IR |MSR_DR )); }
@@ -51,6 +52,7 @@ void mmu_disable(void) cpu->pgtable =NULL ; +assert (!in_usermode ());mtmsr (mfmsr () & ~(MSR_IR |MSR_DR )); }
powerpc/interrupts.c +28 -0
@@ -329,6 +329,33 @@ static void test_illegal(void)report_prefix_pop (); } +static void dec_ignore_handler (struct pt_regs *regs,void *data) +{ +mtspr (SPR_DEC ,0x7fffffff ); +} + +static void test_privileged (void ) +{ +unsigned long msr; + +if (!mmu_enabled ()) +return ; + +report_prefix_push ("privileged instruction" ); + +handle_exception (0x700 , &program_handler,NULL ); +handle_exception (0x900 , &dec_ignore_handler,NULL ); +enter_usermode (); + asmvolatile ("mfmsr %0" :"=r" (msr) ::"memory" ); +exit_usermode (); +report (got_interrupt,"interrupt on privileged instruction" ); + got_interrupt = false; +handle_exception (0x900 ,NULL ,NULL ); +handle_exception (0x700 ,NULL ,NULL ); + +report_prefix_pop (); +} +static void sc_handler (struct pt_regs *regs,void *data) { got_interrupt = true;
@@ -481,6 +508,7 @@ int main(int argc, char **argv)test_mce ();test_mmu ();test_illegal (); +test_privileged ();test_dec ();test_sc ();test_trace ();
Signature · 1 line
2.45.1
PATCH v10 8/15 powerpc: add pmu tests
In reply to Nicholas PigginAdd some initial PMU testing.
- PMC5/6 tests
- PMAE / PMI test
- BHRB basic tests
--- lib/powerpc/asm/processor.h | 2 + lib/powerpc/asm/reg.h | 9 + lib/powerpc/asm/setup.h | 1 + lib/powerpc/setup.c | 20 ++ powerpc/Makefile.common | 3 +- powerpc/pmu.c | 562 ++++++++++++++++++++++++++++++++++++ powerpc/unittests.cfg | 3 + 7 files changed, 599 insertions(+), 1 deletion(-) create mode 100644 powerpc/pmu.c
lib/powerpc/asm/processor.h +2 -0
@@ -17,6 +17,8 @@ extern bool cpu_has_hv;extern bool cpu_has_power_mce;extern bool cpu_has_siar;extern bool cpu_has_heai; +extern bool cpu_has_bhrb; +extern bool cpu_has_p10_bhrb;extern bool cpu_has_radix;extern bool cpu_has_prefix;extern bool cpu_has_sc_lev;
lib/powerpc/asm/reg.h +9 -0
@@ -40,10 +40,19 @@#define SPR_LPIDR 0x13f#define SPR_HEIR 0x153#define SPR_PTCR 0x1d0 +#define SPR_MMCRA 0x312 +#define MMCRA_BHRBRD UL(0x0000002000000000) +#define MMCRA_IFM_MASK UL(0x00000000c0000000) +#define SPR_PMC5 0x317 +#define SPR_PMC6 0x318#define SPR_MMCR0 0x31b#define MMCR0_FC UL(0x80000000) +#define MMCR0_FCP UL(0x20000000)#define MMCR0_PMAE UL(0x04000000) +#define MMCR0_BHRBA UL(0x00200000) +#define MMCR0_FCPC UL(0x00001000)#define MMCR0_PMAO UL(0x00000080) +#define MMCR0_FC56 UL(0x00000010)#define SPR_SIAR 0x31c/* Machine State Register definitions: */
lib/powerpc/asm/setup.h +1 -0
@@ -10,6 +10,7 @@#define NR_CPUS 8/* arbitrarily set for now */ extern uint64_t tb_hz; +extern uint64_t cpu_hz;#define NR_MEM_REGIONS 8#define MR_F_PRIMARY (1U << 0)
lib/powerpc/setup.c +20 -0
@@ -33,6 +33,7 @@ u32 initrd_size;u32 cpu_to_hwid[NR_CPUS ] = { [0 ...NR_CPUS -1 ] = (~0U ) };int nr_cpus_present;uint64_t tb_hz; +uint64_t cpu_hz;struct mem_region mem_regions[NR_MEM_REGIONS ];phys_addr_t __physical_start, __physical_end;
@@ -42,6 +43,7 @@ struct cpu_set_params {unsigned icache_bytes;unsigned dcache_bytes;uint64_t tb_hz; +uint64_t cpu_hz; };static void cpu_set (int fdtnode,u64 regval,void *info)
@@ -95,6 +97,19 @@ static void cpu_set(int fdtnode, u64 regval, void *info) data = (u32 *)prop->data; params->tb_hz =fdt32_to_cpu (*data); + prop =fdt_get_property (dt_fdt (), fdtnode, +"ibm,extended-clock-frequency" ,NULL ); +if (prop) { +u64 *data64 = (u64 *)prop->data; + params->cpu_hz =fdt64_to_cpu (*data64); + }else { + prop =fdt_get_property (dt_fdt (), fdtnode, +"clock-frequency" ,NULL ); +assert (prop !=NULL ); + data = (u32 *)prop->data; + params->cpu_hz =fdt32_to_cpu (*data); + } + read_common_info = true; } }
@@ -103,6 +118,8 @@ bool cpu_has_hv;bool cpu_has_power_mce;/* POWER CPU machine checks */ bool cpu_has_siar;bool cpu_has_heai; +bool cpu_has_bhrb; +bool cpu_has_p10_bhrb;bool cpu_has_radix;bool cpu_has_prefix;bool cpu_has_sc_lev;/* sc interrupt has LEV field in SRR1 */
@@ -119,12 +136,14 @@ static void cpu_init_params(void) __icache_bytes = params.icache_bytes; __dcache_bytes = params.dcache_bytes; tb_hz = params.tb_hz; + cpu_hz = params.cpu_hz;switch (mfspr (SPR_PVR ) &PVR_VERSION_MASK ) {case PVR_VER_POWER10 : cpu_has_prefix = true; cpu_has_sc_lev = true; cpu_has_pause_short = true; + cpu_has_p10_bhrb = true;case PVR_VER_POWER9 : cpu_has_radix = true;case PVR_VER_POWER8E :
@@ -133,6 +152,7 @@ static void cpu_init_params(void) cpu_has_power_mce = true; cpu_has_heai = true; cpu_has_siar = true; + cpu_has_bhrb = true;break ;default :break ;
powerpc/Makefile.common +2 -1
@@ -18,7 +18,8 @@ tests-common = \ $(TEST_DIR)/sprs.elf \ $(TEST_DIR)/timebase.elf \ $(TEST_DIR)/interrupts.elf \ - $(TEST_DIR)/mmu.elf + $(TEST_DIR)/mmu.elf \ + $(TEST_DIR)/pmu.elf tests-all = $(tests-common) $(tests) all: directories $(TEST_DIR)/boot_rom.bin $(tests-all)
powerpc/pmu.c new file +562 -0
562 lines not on this page · raw message
powerpc/unittests.cfg +3 -0
@@ -73,6 +73,9 @@ file = interrupts.elf file = mmu.elf smp = 2 +[pmu] +file = pmu.elf + [smp] file = smp.elf smp = 2
Signature · 1 line
2.45.1
Re: [kvm-unit-tests PATCH v10 08/15] powerpc: add pmu tests
Quoted 16 lines · Nicholas Piggin
Add some initial PMU testing.
- PMC5/6 tests
- PMAE / PMI test
- BHRB basic testsSigned-off-by Nicholas Piggin <[email protected]>--- lib/powerpc/asm/processor.h | 2 + lib/powerpc/asm/reg.h | 9 + lib/powerpc/asm/setup.h | 1 + lib/powerpc/setup.c | 20 ++ powerpc/Makefile.common | 3 +- powerpc/pmu.c | 562 ++++++++++++++++++++++++++++++++++++ powerpc/unittests.cfg | 3 + 7 files changed, 599 insertions(+), 1 deletion(-)
Quoted 1 line
create mode 100644
powerpc/pmu.c
Hi Nicholas!
Something in this patch breaks compiling with Clang in the Travis-CI:
https://app.travis-ci.com/github/huth/kvm-unit-tests/builds/271013764
Not sure what exactly it is, the log is not very helpful. Do you have a ppc64 host where you could test your patches with Clang?
Thomas
Re: [kvm-unit-tests PATCH v10 08/15] powerpc: add pmu tests
In reply to Nicholas PigginQuoted 8 lines · Nicholas Piggin
Add some initial PMU testing.
- PMC5/6 tests
- PMAE / PMI test
- BHRB basic testsSigned-off-by Nicholas Piggin <[email protected]>---
...
Quoted 6 lines
powerpc/pmu.c new file +0
-0@@ -0,0 +1,562 @@
...
Quoted 13 lines
powerpc/pmu.c new file +13
-0+static void test_pmc5_with_ldat (void ) +{ +unsigned long pmc5_1, pmc5_2; + registerunsigned long r4 asm("r4" ); + registerunsigned long r5 asm("r5" ); + registerunsigned long r6 asm("r6" ); +uint64_t val; + +reset_mmcr0 (); +mtspr (SPR_PMC5 ,0 ); +mtspr (SPR_MMCR0 ,mfspr (SPR_MMCR0 ) & ~(MMCR0_FC |MMCR0_FC56 )); + asmvolatile (".rep 20 ; nop ; .endr" :::"memory" ); +mtspr (SPR_MMCR0 ,mfspr (SPR_MMCR0 ) | (MMCR0_FC |MMCR0_FC56 ));
powerpc/pmu.c
Quoted 10 lines
powerpc/pmu.c new file +10
-0+ pmc5_1 =mfspr (SPR_PMC5 ); + + val =0xdeadbeef ; + r4 =0 ; + r5 =0xdeadbeef ; + r6 =100 ; +reset_mmcr0 (); +mtspr (SPR_PMC5 ,0 ); +mtspr (SPR_MMCR0 ,mfspr (SPR_MMCR0 ) & ~(MMCR0_FC |MMCR0_FC56 )); + asmvolatile (".rep 10 ; nop ; .endr ; ldat %0,%3,0x10 ; .rep 10 ; nop ; .endr" :"=r" (r4),"+r" (r5),"+r" (r6) :"r" (&val) :"memory" );
Looks like older versions of Clang do not like this instruction:
/tmp/pmu-4fda98.s: Assembler messages:
/tmp/pmu-4fda98.s:1685: Error: unrecognized opcode: `ldat'
clang-13: error: assembler command failed with exit code 1 (use -v to see
invocation)
Could you please work-around that issue?
Also, please break the very long line here. Thanks!
powerpc/pmu.c line 263
Quoted 9 lines
powerpc/pmu.c new file +9
-0+mtspr (SPR_MMCR0 ,mfspr (SPR_MMCR0 ) | (MMCR0_FC |MMCR0_FC56 )); + pmc5_2 =mfspr (SPR_PMC5 ); +assert (r4 ==0xdeadbeef ); +assert (val ==0xdeadbeef ); + +/* TCG does not count instructions around syscalls correctly */ +report_kfail (host_is_tcg, pmc5_1 != pmc5_2 +1 , +"PMC5 counts instructions with ldat" ); +}
Thomas
Re: [kvm-unit-tests PATCH v10 08/15] powerpc: add pmu tests
Quoted 43 lines · Thomas Huth
Quoted 8 lines · Nicholas Piggin
Add some initial PMU testing.
- PMC5/6 tests
- PMAE / PMI test
- BHRB basic testsSigned-off-by Nicholas Piggin <[email protected]>---
...
Quoted 6 lines
powerpc/pmu.c new file +0
-0@@ -0,0 +1,562 @@...
Quoted 13 lines
powerpc/pmu.c new file +13
-0+static void test_pmc5_with_ldat (void ) +{ +unsigned long pmc5_1, pmc5_2; + registerunsigned long r4 asm("r4" ); + registerunsigned long r5 asm("r5" ); + registerunsigned long r6 asm("r6" ); +uint64_t val; + +reset_mmcr0 (); +mtspr (SPR_PMC5 ,0 ); +mtspr (SPR_MMCR0 ,mfspr (SPR_MMCR0 ) & ~(MMCR0_FC |MMCR0_FC56 )); + asmvolatile (".rep 20 ; nop ; .endr" :::"memory" ); +mtspr (SPR_MMCR0 ,mfspr (SPR_MMCR0 ) | (MMCR0_FC |MMCR0_FC56 ));powerpc/pmu.c
Quoted 10 lines
powerpc/pmu.c new file +10
-0+ pmc5_1 =mfspr (SPR_PMC5 ); + + val =0xdeadbeef ; + r4 =0 ; + r5 =0xdeadbeef ; + r6 =100 ; +reset_mmcr0 (); +mtspr (SPR_PMC5 ,0 ); +mtspr (SPR_MMCR0 ,mfspr (SPR_MMCR0 ) & ~(MMCR0_FC |MMCR0_FC56 )); + asmvolatile (".rep 10 ; nop ; .endr ; ldat %0,%3,0x10 ; .rep 10 ; nop ; .endr" :"=r" (r4),"+r" (r5),"+r" (r6) :"r" (&val) :"memory" );Looks like older versions of Clang do not like this instruction:
Quoted 6 lines
/tmp/pmu-4fda98.s: Assembler messages:
/tmp/pmu-4fda98.s:1685: Error: unrecognized opcode: `ldat'
clang-13: error: assembler command failed with exit code 1 (use -v to see
invocation)Could you please work-around that issue?
Ah, just catching up with this -- thanks for working it out.
I will fix.
Quoted 2 lines
Also, please break the very long line here. Thanks!
Sure.
Thanks,
Nick
Quoted 12 lines
powerpc/pmu.c line 263
Quoted 10 lines
powerpc/pmu.c new file +9
-0+mtspr (SPR_MMCR0 ,mfspr (SPR_MMCR0 ) | (MMCR0_FC |MMCR0_FC56 )); + pmc5_2 =mfspr (SPR_PMC5 ); +assert (r4 ==0xdeadbeef ); +assert (val ==0xdeadbeef ); + +/* TCG does not count instructions around syscalls correctly */ +report_kfail (host_is_tcg, pmc5_1 != pmc5_2 +1 , +"PMC5 counts instructions with ldat" ); +}Thomas
PATCH v10 9/15 configure: Make arch_libdir a first-class entity
In reply to Nicholas Pigginarch_libdir was brought in to improve the heuristic determination of the lib/ directory based on arch and testdir names, but it did not entirely clean that mess up.
Remove the arch_libdir->arch->testdir heuristic and just require everybody sets arch_libdir correctly. Fail if the lib/arch or lib/arch/asm directories can not be found.
--- Makefile | 2 +- configure | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-)
Makefile +1 -1
@@ -10,7 +10,7 @@ include config.mak VPATH = $(SRCDIR) libdirs-get = $(shell [ -d "lib/$(1)" ] && echo "lib/$(1) lib/$(1)/asm") -ARCH_LIBDIRS := $(call libdirs-get,$(ARCH_LIBDIR)) $(call libdirs-get,$(TEST_DIR)) +ARCH_LIBDIRS := $(call libdirs-get,$(ARCH_LIBDIR)) OBJDIRS := $(ARCH_LIBDIRS) DESTDIR := $(PREFIX)/share/kvm-unit-tests/
configure +13 -5
@@ -217,7 +217,6 @@ fi arch_name=$arch [ "$arch" = "aarch64" ] && arch="arm64" [ "$arch_name" = "arm64" ] && arch_name="aarch64" -arch_libdir=$arch if [ "$arch" = "riscv" ]; then echo "riscv32 or riscv64 must be specified"
@@ -285,8 +284,10 @@ fi if [ "$arch" = "i386" ] || [ "$arch" = "x86_64" ]; then testdir=x86 + arch_libdir=x86 elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then testdir=arm + arch_libdir=$arch if [ "$target" = "qemu" ]; then arm_uart_early_addr=0x09000000 elif [ "$target" = "kvmtool" ]; then
@@ -335,6 +336,7 @@ elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then fi elif [ "$arch" = "ppc64" ]; then testdir=powerpc + arch_libdir=ppc64 firmware="$testdir/boot_rom.bin" if [ "$endian" != "little" ] && [ "$endian" != "big" ]; then echo "You must provide endianness (big or little)!"
@@ -345,6 +347,7 @@ elif [ "$arch" = "riscv32" ] || [ "$arch" = "riscv64" ]; then arch_libdir=riscv elif [ "$arch" = "s390x" ]; then testdir=s390x + arch_libdir=s390x else echo "arch $arch is not supported!" arch=
@@ -354,6 +357,10 @@ if [ ! -d "$srcdir/$testdir" ]; then echo "$srcdir/$testdir does not exist!" exit 1 fi +if [ ! -d "$srcdir/lib/$arch_libdir" ]; then + echo "$srcdir/lib/$arch_libdir does not exist!" + exit 1 +fi if [ "$efi" = "y" ] && [ -f "$srcdir/$testdir/efi/run" ]; then ln -fs "$srcdir/$testdir/efi/run" $testdir-run
@@ -416,10 +423,11 @@ fi # link lib/asm for the architecture rm -f lib/asm asm="asm-generic" -if [ -d "$srcdir/lib/$arch/asm" ]; then - asm="$srcdir/lib/$arch/asm" -elif [ -d "$srcdir/lib/$testdir/asm" ]; then - asm="$srcdir/lib/$testdir/asm" +if [ -d "$srcdir/lib/$arch_libdir/asm" ]; then + asm="$srcdir/lib/$arch_libdir/asm" +else + echo "$srcdir/lib/$arch_libdir/asm does not exist" + exit 1 fi mkdir -p lib ln -sf "$asm" lib/asm
Signature · 1 line
2.45.1
PATCH v10 10/15 powerpc: Remove remnants of ppc64 directory and build structure
In reply to Nicholas PigginThis moves merges ppc64 directories and files into powerpc, and merges the 3 makefiles into one.
The configure --arch=powerpc option is aliased to ppc64 for good measure.
---
MAINTAINERS | 1 -
configure | 3 +-
lib/{ppc64 => powerpc}/asm-offsets.c | 0
lib/{ppc64 => powerpc}/asm/asm-offsets.h | 0
lib/{ppc64 => powerpc}/asm/atomic.h | 0
lib/{ppc64 => powerpc}/asm/barrier.h | 4 +-
lib/{ppc64 => powerpc}/asm/bitops.h | 4 +-
lib/{ppc64 => powerpc}/asm/io.h | 4 +-
lib/{ppc64 => powerpc}/asm/mmu.h | 0
lib/{ppc64 => powerpc}/asm/opal.h | 4 +-
lib/{ppc64 => powerpc}/asm/page.h | 6 +-
lib/{ppc64 => powerpc}/asm/pgtable-hwdef.h | 6 +-
lib/{ppc64 => powerpc}/asm/pgtable.h | 2 +-
lib/{ppc64 => powerpc}/asm/ptrace.h | 6 +-
lib/powerpc/asm/spinlock.h | 6 ++
lib/powerpc/asm/stack.h | 3 +
lib/{ppc64 => powerpc}/asm/vpa.h | 0
lib/{ppc64 => powerpc}/mmu.c | 0
lib/{ppc64 => powerpc}/opal-calls.S | 0
lib/{ppc64 => powerpc}/opal.c | 0
lib/{ppc64 => powerpc}/stack.c | 0
lib/ppc64/.gitignore | 1 -
lib/ppc64/asm/handlers.h | 1 -
lib/ppc64/asm/hcall.h | 1 -
lib/ppc64/asm/memory_areas.h | 6 --
lib/ppc64/asm/ppc_asm.h | 1 -
lib/ppc64/asm/processor.h | 1 -
lib/ppc64/asm/reg.h | 1 -
lib/ppc64/asm/rtas.h | 1 -
lib/ppc64/asm/setup.h | 1 -
lib/ppc64/asm/smp.h | 1 -
lib/ppc64/asm/spinlock.h | 6 --
lib/ppc64/asm/stack.h | 11 --
powerpc/Makefile | 111 ++++++++++++++++++++-
powerpc/Makefile.common | 95 ------------------
powerpc/Makefile.ppc64 | 31 ------
36 files changed, 139 insertions(+), 179 deletions(-)
rename lib/{ppc64 => powerpc}/asm-offsets.c (100%)
rename lib/{ppc64 => powerpc}/asm/asm-offsets.h (100%)
rename lib/{ppc64 => powerpc}/asm/atomic.h (100%)
rename lib/{ppc64 => powerpc}/asm/barrier.h (83%)
rename lib/{ppc64 => powerpc}/asm/bitops.h (69%)
rename lib/{ppc64 => powerpc}/asm/io.h (50%)
rename lib/{ppc64 => powerpc}/asm/mmu.h (100%)
rename lib/{ppc64 => powerpc}/asm/opal.h (90%)
rename lib/{ppc64 => powerpc}/asm/page.h (94%)
rename lib/{ppc64 => powerpc}/asm/pgtable-hwdef.h (93%)
rename lib/{ppc64 => powerpc}/asm/pgtable.h (99%)
rename lib/{ppc64 => powerpc}/asm/ptrace.h (89%)
create mode 100644 lib/powerpc/asm/spinlock.h
rename lib/{ppc64 => powerpc}/asm/vpa.h (100%)
rename lib/{ppc64 => powerpc}/mmu.c (100%)
rename lib/{ppc64 => powerpc}/opal-calls.S (100%)
rename lib/{ppc64 => powerpc}/opal.c (100%)
rename lib/{ppc64 => powerpc}/stack.c (100%)
delete mode 100644 lib/ppc64/.gitignore
delete mode 100644 lib/ppc64/asm/handlers.h
delete mode 100644 lib/ppc64/asm/hcall.h
delete mode 100644 lib/ppc64/asm/memory_areas.h
delete mode 100644 lib/ppc64/asm/ppc_asm.h
delete mode 100644 lib/ppc64/asm/processor.h
delete mode 100644 lib/ppc64/asm/reg.h
delete mode 100644 lib/ppc64/asm/rtas.h
delete mode 100644 lib/ppc64/asm/setup.h
delete mode 100644 lib/ppc64/asm/smp.h
delete mode 100644 lib/ppc64/asm/spinlock.h
delete mode 100644 lib/ppc64/asm/stack.h
delete mode 100644 powerpc/Makefile.common
delete mode 100644 powerpc/Makefile.ppc64MAINTAINERS +0 -1
@@ -92,7 +92,6 @@ S: Maintained L: [email protected] F: powerpc/ F: lib/powerpc/ -F: lib/ppc64/ RISCV M: Andrew Jones <[email protected]>
configure +2 -1
@@ -216,6 +216,7 @@ fi arch_name=$arch [ "$arch" = "aarch64" ] && arch="arm64" +[ "$arch" = "powerpc" ] && arch="ppc64" [ "$arch_name" = "arm64" ] && arch_name="aarch64" if [ "$arch" = "riscv" ]; then
@@ -336,7 +337,7 @@ elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then fi elif [ "$arch" = "ppc64" ]; then testdir=powerpc - arch_libdir=ppc64 + arch_libdir=powerpc firmware="$testdir/boot_rom.bin" if [ "$endian" != "little" ] && [ "$endian" != "big" ]; then echo "You must provide endianness (big or little)!"
lib/powerpc/asm-offsets.c renamed from lib/ppc64/asm-offsets.c +0 -0
lib/powerpc/asm/asm-offsets.h renamed from lib/ppc64/asm/asm-offsets.h +0 -0
lib/powerpc/asm/atomic.h renamed from lib/ppc64/asm/atomic.h +0 -0
lib/powerpc/asm/barrier.h renamed from lib/ppc64/asm/barrier.h +2 -2
@@ -1,5 +1,5 @@ -#ifndef _ASMPPC64_BARRIER_H_ -#define _ASMPPC64_BARRIER_H_ +#ifndef _ASMPOWERPC_BARRIER_H_ +#define _ASMPOWERPC_BARRIER_H_#define cpu_relax () asm volatile("or 1,1,1 ; or 2,2,2" ::: "memory")#define pause_short () asm volatile(".long 0x7c40003c" ::: "memory")
lib/powerpc/asm/bitops.h renamed from lib/ppc64/asm/bitops.h +2 -2
@@ -1,5 +1,5 @@ -#ifndef _ASMPPC64_BITOPS_H_ -#define _ASMPPC64_BITOPS_H_ +#ifndef _ASMPOWERPC_BITOPS_H_ +#define _ASMPOWERPC_BITOPS_H_#ifndef _BITOPS_H_#error only <bitops.h> can be included directly
lib/powerpc/asm/io.h renamed from lib/ppc64/asm/io.h +2 -2
@@ -1,5 +1,5 @@ -#ifndef _ASMPPC64_IO_H_ -#define _ASMPPC64_IO_H_ +#ifndef _ASMPOWERPC_IO_H_ +#define _ASMPOWERPC_IO_H_#define __iomem
lib/powerpc/asm/mmu.h renamed from lib/ppc64/asm/mmu.h +0 -0
lib/powerpc/asm/opal.h renamed from lib/ppc64/asm/opal.h +2 -2
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _ASMPPC64_OPAL_H_ -#define _ASMPPC64_OPAL_H_ +#ifndef _ASMPOWERPC_OPAL_H_ +#define _ASMPOWERPC_OPAL_H_#include <stdint.h>
lib/powerpc/asm/page.h renamed from lib/ppc64/asm/page.h +3 -3
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ -#ifndef _ASMPPC64_PAGE_H_ -#define _ASMPPC64_PAGE_H_ +#ifndef _ASMPOWERPC_PAGE_H_ +#define _ASMPOWERPC_PAGE_H_/* * Adapted from * lib/arm64/asm/page.h and Linux kernel defines.
@@ -62,4 +62,4 @@ extern unsigned long __phys_to_virt(phys_addr_t addr);extern void *__ioremap (phys_addr_t phys_addr,size_t size);#endif /* !__ASSEMBLY__ */ -#endif /* _ASMPPC64_PAGE_H_ */ +#endif /* _ASMPOWERPC_PAGE_H_ */
lib/powerpc/asm/pgtable-hwdef.h renamed from lib/ppc64/asm/pgtable-hwdef.h +3 -3
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ -#ifndef _ASMPPC64_PGTABLE_HWDEF_H_ -#define _ASMPPC64_PGTABLE_HWDEF_H_ +#ifndef _ASMPOWERPC_PGTABLE_HWDEF_H_ +#define _ASMPOWERPC_PGTABLE_HWDEF_H_/* * Copyright (C) 2024, IBM Inc, Nicholas Piggin <[email protected]> *
@@ -63,4 +63,4 @@#define PHYS_MASK_SHIFT (48)#define PHYS_MASK ((UL(1) << PHYS_MASK_SHIFT) - 1) -#endif /* _ASMPPC64_PGTABLE_HWDEF_H_ */ +#endif /* _ASMPOWERPC_PGTABLE_HWDEF_H_ */
lib/powerpc/asm/pgtable.h renamed from lib/ppc64/asm/pgtable.h +1 -1
@@ -122,4 +122,4 @@ static inline pte_t *pte_alloc(pmd_t *pmd, unsigned long addr) return pte_offset(pmd, addr); } -#endif /* _ASMPPC64_PGTABLE_H_ */ +#endif /* _ASMPOWERPC_PGTABLE_H_ */
lib/powerpc/asm/ptrace.h renamed from lib/ppc64/asm/ptrace.h +3 -3
@@ -1,5 +1,5 @@ -#ifndef _ASMPPC64_PTRACE_H_ -#define _ASMPPC64_PTRACE_H_ +#ifndef _ASMPOWERPC_PTRACE_H_ +#define _ASMPOWERPC_PTRACE_H_#define KERNEL_REDZONE_SIZE 288#define STACK_FRAME_OVERHEAD 112/* size of minimum stack frame */
@@ -38,4 +38,4 @@ static inline void regs_advance_insn(struct pt_regs *regs)#endif /* __ASSEMBLY__ */ -#endif /* _ASMPPC64_PTRACE_H_ */ +#endif /* _ASMPOWERPC_PTRACE_H_ */
lib/powerpc/asm/spinlock.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef _ASMPOWERPC_SPINLOCK_H_ +#define _ASMPOWERPC_SPINLOCK_H_ + +#include <asm-generic/spinlock.h> + +#endif /* _ASMPOWERPC_SPINLOCK_H_ */
lib/powerpc/asm/stack.h +3 -0
@@ -5,4 +5,7 @@#error Do not directly include <asm/stack.h>. Just use <stack.h>.#endif +#define HAVE_ARCH_BACKTRACE +#define HAVE_ARCH_BACKTRACE_FRAME +#endif
lib/powerpc/asm/vpa.h renamed from lib/ppc64/asm/vpa.h +0 -0
lib/powerpc/mmu.c renamed from lib/ppc64/mmu.c +0 -0
lib/powerpc/opal-calls.S renamed from lib/ppc64/opal-calls.S +0 -0
lib/powerpc/opal.c renamed from lib/ppc64/opal.c +0 -0
lib/powerpc/stack.c renamed from lib/ppc64/stack.c +0 -0
lib/ppc64/.gitignore deleted +0 -1
@@ -1 +0,0 @@ -asm-offsets.[hs]
lib/ppc64/asm/handlers.h deleted +0 -1
@@ -1 +0,0 @@ -#include "../../powerpc/asm/handlers.h"
lib/ppc64/asm/hcall.h deleted +0 -1
@@ -1 +0,0 @@ -#include "../../powerpc/asm/hcall.h"
lib/ppc64/asm/memory_areas.h deleted +0 -6
@@ -1,6 +0,0 @@ -#ifndef _ASMPPC64_MEMORY_AREAS_H_ -#define _ASMPPC64_MEMORY_AREAS_H_ - -#include <asm-generic/memory_areas.h> - -#endif
lib/ppc64/asm/ppc_asm.h deleted +0 -1
@@ -1 +0,0 @@ -#include "../../powerpc/asm/ppc_asm.h"
lib/ppc64/asm/processor.h deleted +0 -1
@@ -1 +0,0 @@ -#include "../../powerpc/asm/processor.h"
lib/ppc64/asm/reg.h deleted +0 -1
@@ -1 +0,0 @@ -#include "../../powerpc/asm/reg.h"
lib/ppc64/asm/rtas.h deleted +0 -1
@@ -1 +0,0 @@ -#include "../../powerpc/asm/rtas.h"
lib/ppc64/asm/setup.h deleted +0 -1
@@ -1 +0,0 @@ -#include "../../powerpc/asm/setup.h"
lib/ppc64/asm/smp.h deleted +0 -1
@@ -1 +0,0 @@ -#include "../../powerpc/asm/smp.h"
lib/ppc64/asm/spinlock.h deleted +0 -6
@@ -1,6 +0,0 @@ -#ifndef _ASMPPC64_SPINLOCK_H_ -#define _ASMPPC64_SPINLOCK_H_ - -#include <asm-generic/spinlock.h> - -#endif /* _ASMPPC64_SPINLOCK_H_ */
lib/ppc64/asm/stack.h deleted +0 -11
@@ -1,11 +0,0 @@ -#ifndef _ASMPPC64_STACK_H_ -#define _ASMPPC64_STACK_H_ - -#ifndef _STACK_H_ -#error Do not directly include <asm/stack.h>. Just use <stack.h>. -#endif - -#define HAVE_ARCH_BACKTRACE -#define HAVE_ARCH_BACKTRACE_FRAME - -#endif
powerpc/Makefile +110 -1
111 lines not on this page · raw message
powerpc/Makefile.common deleted +0 -95
95 lines not on this page · raw message
powerpc/Makefile.ppc64 deleted +0 -31
@@ -1,31 +0,0 @@ -# -# ppc64 makefile -# -# Authors: Andrew Jones <[email protected]> -# -bits = 64 - -ifeq ($(ENDIAN),little) - arch_CFLAGS = -mlittle-endian - arch_LDFLAGS = -EL -else - arch_CFLAGS = -mbig-endian - arch_LDFLAGS = -EB -endif - -cstart.o = $(TEST_DIR)/cstart64.o -reloc.o = $(TEST_DIR)/reloc64.o - -OBJDIRS += lib/ppc64 -cflatobjs += lib/ppc64/stack.o -cflatobjs += lib/ppc64/mmu.o -cflatobjs += lib/ppc64/opal.o -cflatobjs += lib/ppc64/opal-calls.o - -# ppc64 specific tests -tests = $(TEST_DIR)/spapr_vpa.elf - -include $(SRCDIR)/$(TEST_DIR)/Makefile.common - -arch_clean: powerpc_clean - $(RM) lib/ppc64/.*.d
Signature · 1 line
2.45.1
Re: [kvm-unit-tests PATCH v10 10/15] powerpc: Remove remnants of ppc64 directory and build structure
Quoted 9 lines · Nicholas Piggin
This moves merges ppc64 directories and files into powerpc, and merges the 3 makefiles into one.
The configure --arch=powerpc option is aliased to ppc64 for good measure.
Acked-by Thomas Huth <[email protected]>Signed-off-by Nicholas Piggin <[email protected]>---
Seems like this patch does not apply cleanly anymore, could you please rebase?
Thanks,
Thomas
PATCH v10 11/15 powerpc: gitlab CI update
In reply to Nicholas PigginThis adds testing for the powernv machine. To control overhead, ppc64be is used to test powernv and 64k page size, ppc64le is used to test pseries and 4k page size.
Change to using a gitlab-ci test group instead of specifying all tests in .gitlab-ci.yml, and adds a few additional tests (smp, atomics) that are known to work in CI.
--- .gitlab-ci.yml | 32 ++++++++------------------------ powerpc/unittests.cfg | 34 +++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 31 deletions(-)
.gitlab-ci.yml +8 -24
@@ -96,22 +96,14 @@ build-arm: build-ppc64be: extends: .outoftree_template script: - - dnf install -y qemu-system-ppc gcc-powerpc64-linux-gnu nmap-ncat + - dnf install -y qemu-system-ppc gcc-powerpc64-linux-gnu - mkdir build - cd build - - ../configure --arch=ppc64 --endian=big --cross-prefix=powerpc64-linux-gnu- + - ../configure --arch=ppc64 --endian=big --page-size=64k --cross-prefix=powerpc64-linux-gnu- - make -j2 - - ACCEL=tcg ./run_tests.sh - selftest-setup - selftest-migration - selftest-migration-skip - spapr_hcall - rtas-get-time-of-day - rtas-get-time-of-day-base - rtas-set-time-of-day - emulator - | tee results.txt - - if grep -q FAIL results.txt ; then exit 1 ; fi + - ACCEL=tcg MAX_SMP=8 MACHINE=powernv ./run_tests.sh -g gitlab-ci + | tee results.txt + - grep -q PASS results.txt && ! grep -q FAIL results.txt build-ppc64le: extends: .intree_template
@@ -119,17 +111,9 @@ build-ppc64le: - dnf install -y qemu-system-ppc gcc-powerpc64-linux-gnu nmap-ncat - ./configure --arch=ppc64 --endian=little --cross-prefix=powerpc64-linux-gnu- - make -j2 - - ACCEL=tcg ./run_tests.sh - selftest-setup - selftest-migration - selftest-migration-skip - spapr_hcall - rtas-get-time-of-day - rtas-get-time-of-day-base - rtas-set-time-of-day - emulator - | tee results.txt - - if grep -q FAIL results.txt ; then exit 1 ; fi + - ACCEL=tcg MAX_SMP=8 ./run_tests.sh -g gitlab-ci + | tee results.txt + - grep -q PASS results.txt && ! grep -q FAIL results.txt # build-riscv32: # Fedora doesn't package a riscv32 compiler for QEMU. Oh, well.
powerpc/unittests.cfg +27 -7
@@ -16,17 +16,25 @@ file = selftest.elf smp = 2 extra_params = -m 1g -append 'setup smp=2 mem=1024' -groups = selftest +groups = selftest gitlab-ci [selftest-migration] file = selftest-migration.elf machine = pseries groups = selftest migration +# QEMU 7.0 (Fedora 37) in gitlab CI has known migration bugs in TCG, so +# make a kvm-only version for CI +[selftest-migration-ci] +file = selftest-migration.elf +machine = pseries +groups = nodefault selftest migration gitlab-ci +accel = kvm + [selftest-migration-skip] file = selftest-migration.elf machine = pseries -groups = selftest migration +groups = selftest migration gitlab-ci extra_params = -append "skip" [migration-memory]
@@ -37,6 +45,7 @@ groups = migration [spapr_hcall] file = spapr_hcall.elf machine = pseries +groups = gitlab-ci [spapr_vpa] file = spapr_vpa.elf
@@ -47,38 +56,43 @@ file = rtas.elf machine = pseries timeout = 5 extra_params = -append "get-time-of-day date=$(date +%s)" -groups = rtas +groups = rtas gitlab-ci [rtas-get-time-of-day-base] file = rtas.elf machine = pseries timeout = 5 extra_params = -rtc base="2006-06-17" -append "get-time-of-day date=$(date --date="2006-06-17 UTC" +%s)" -groups = rtas +groups = rtas gitlab-ci [rtas-set-time-of-day] file = rtas.elf machine = pseries extra_params = -append "set-time-of-day" timeout = 5 -groups = rtas +groups = rtas gitlab-ci [emulator] file = emulator.elf +groups = gitlab-ci +# QEMU 7.0 (Fedora 37) in gitlab CI fails this [interrupts] file = interrupts.elf +# QEMU 7.0 (Fedora 37) in gitlab CI fails this [mmu] file = mmu.elf smp = 2 +# QEMU 7.0 (Fedora 37) in gitlab CI fails this [pmu] file = pmu.elf [smp] file = smp.elf smp = 2 +groups = gitlab-ci [smp-smt] file = smp.elf
@@ -90,19 +104,22 @@ file = smp.elf smp = 8,threads=4 accel = tcg,thread=single +# QEMU 7.0 (Fedora 37) in gitlab CI does not do well with SMP atomics [atomics] file = atomics.elf -smp = 2 +groups = gitlab-ci [atomics-migration] file = atomics.elf machine = pseries extra_params = -append "migration -m" -groups = migration +groups = migration gitlab-ci +# QEMU 7.0 (Fedora 37) in gitlab CI fails this [timebase] file = timebase.elf +# QEMU 7.0 (Fedora 37) in gitlab CI fails this [timebase-icount] file = timebase.elf accel = tcg
@@ -116,14 +133,17 @@ smp = 2,threads=2 extra_params = -machine cap-htm=on -append "h_cede_tm" groups = h_cede_tm +# QEMU 7.0 (Fedora 37) in gitlab CI fails this [sprs] file = sprs.elf +# QEMU 7.0 (Fedora 37) in gitlab CI fails this [sprs-migration] file = sprs.elf machine = pseries extra_params = -append '-w' groups = migration +# Too costly to run in CI [sieve] file = sieve.elf
Signature · 1 line
2.45.1
PATCH v10 12/15 scripts/arch-run.bash: Fix run_panic() success exit status
In reply to Nicholas Pigginrun_qemu_status() looks for "EXIT: STATUS=%d" if the harness command returned 1, to determine the final status of the test. In the case of panic tests, QEMU should terminate before successful exit status is known, so the run_panic() command must produce the "EXIT: STATUS" line.
With this change, running a panic test returns 0 on success (panic), and the run_test.sh unit test correctly displays it as PASS rather than FAIL.
--- scripts/arch-run.bash | 1 + 1 file changed, 1 insertion(+)
scripts/arch-run.bash +1 -0
@@ -378,6 +378,7 @@ run_panic () else # some QEMU versions report multiple panic events echo "PASS: guest panicked" + echo "EXIT: STATUS=1" ret=1 fi
Signature · 1 line
2.45.1
Re: [kvm-unit-tests PATCH v10 12/15] scripts/arch-run.bash: Fix run_panic() success exit status
Quoted 29 lines · Nicholas Piggin
run_qemu_status()looks for "EXIT: STATUS=%d" if the harness command returned 1, to determine the final status of the test. In the case of panic tests, QEMU should terminate before successful exit status is known, so therun_panic()command must produce the "EXIT: STATUS" line.With this change, running a panic test returns 0 on success (panic), and the
run_test.shunit test correctly displays it as PASS rather than FAIL.Signed-off-by Nicholas Piggin <[email protected]>--- scripts/arch-run.bash | 1 + 1 file changed, 1 insertion(+)scripts/arch-run.bash +1
-0@@ -378,6 +378,7 @@ run_panic () else # some QEMU versions report multiple panic events echo "PASS: guest panicked" + echo "EXIT: STATUS=1" ret=1 fiSignature · 1 line
2.45.1
Do we also need an 'echo "EXIT: STATUS=3"' in the if-arm of this if-else?
Thanks,
drew
Re: [kvm-unit-tests PATCH v10 12/15] scripts/arch-run.bash: Fix run_panic() success exit status
Quoted 27 lines · Andrew Jones
Quoted 26 lines · Nicholas Piggin
run_qemu_status()looks for "EXIT: STATUS=%d" if the harness command returned 1, to determine the final status of the test. In the case of panic tests, QEMU should terminate before successful exit status is known, so therun_panic()command must produce the "EXIT: STATUS" line.With this change, running a panic test returns 0 on success (panic), and the
run_test.shunit test correctly displays it as PASS rather than FAIL.Signed-off-by Nicholas Piggin <[email protected]>--- scripts/arch-run.bash | 1 + 1 file changed, 1 insertion(+)scripts/arch-run.bash +1
-0@@ -378,6 +378,7 @@ run_panic () else # some QEMU versions report multiple panic events echo "PASS: guest panicked" + echo "EXIT: STATUS=1" ret=1 fi
Quoted 5 lines
Quoted 3 lines
Signature · 1 line
2.45.1Do we also need an 'echo "EXIT: STATUS=3"' in the if-arm of this if-else?
In that case we don't need it because run_panic() returns 3 in that case. run_qemu_status() only checks guest status if harness said QEMU ran successfully.
Arguably this is a bit hacky because "EXIT: STATUS" should really be a guest-printed status, and we would have a different success code for expected-QEMU-crash type of tests where guest can't provide status. I can do that incrementally after this if you like, but it's a bit more code.
Thanks,
Nick
Re: [kvm-unit-tests PATCH v10 12/15] scripts/arch-run.bash: Fix run_panic() success exit status
Quoted 34 lines · Nicholas Piggin
Quoted 27 lines · Andrew Jones
Quoted 26 lines · Nicholas Piggin
run_qemu_status()looks for "EXIT: STATUS=%d" if the harness command returned 1, to determine the final status of the test. In the case of panic tests, QEMU should terminate before successful exit status is known, so therun_panic()command must produce the "EXIT: STATUS" line.With this change, running a panic test returns 0 on success (panic), and the
run_test.shunit test correctly displays it as PASS rather than FAIL.Signed-off-by Nicholas Piggin <[email protected]>--- scripts/arch-run.bash | 1 + 1 file changed, 1 insertion(+)scripts/arch-run.bash +1
-0@@ -378,6 +378,7 @@ run_panic () else # some QEMU versions report multiple panic events echo "PASS: guest panicked" + echo "EXIT: STATUS=1" ret=1 fiQuoted 5 lines
Quoted 3 lines
Signature · 1 line
2.45.1Do we also need an 'echo "EXIT: STATUS=3"' in the if-arm of this if-else?
Quoted 3 lines
In that case we don't need it because
run_panic()returns 3 in that case.run_qemu_status()only checks guest status if harness said QEMU ran successfully.
Ah, yes.
Quoted 6 lines
Arguably this is a bit hacky because "EXIT: STATUS" should really be a guest-printed status, and we would have a different success code for expected-QEMU-crash type of tests where guest can't provide status. I can do that incrementally after this if you like, but it's a bit more code.
Just this patch for now works for me.
Thanks,
drew
Re: [kvm-unit-tests PATCH v10 12/15] scripts/arch-run.bash: Fix run_panic() success exit status
In reply to Nicholas PigginQuoted 29 lines · Nicholas Piggin
run_qemu_status()looks for "EXIT: STATUS=%d" if the harness command returned 1, to determine the final status of the test. In the case of panic tests, QEMU should terminate before successful exit status is known, so therun_panic()command must produce the "EXIT: STATUS" line.With this change, running a panic test returns 0 on success (panic), and the
run_test.shunit test correctly displays it as PASS rather than FAIL.Signed-off-by Nicholas Piggin <[email protected]>--- scripts/arch-run.bash | 1 + 1 file changed, 1 insertion(+)scripts/arch-run.bash +1
-0@@ -378,6 +378,7 @@ run_panic () else # some QEMU versions report multiple panic events echo "PASS: guest panicked" + echo "EXIT: STATUS=1" ret=1 fiSignature · 1 line
2.45.1
PATCH v10 13/15 powerpc: Add a panic test
In reply to Nicholas PigginThis adds a simple panic test for pseries and powernv that works with TCG (unlike the s390x panic tests), making it easier to test this part of the harness code.
--- lib/powerpc/asm/rtas.h | 1 + lib/powerpc/rtas.c | 16 ++++++++++++++++ powerpc/run | 2 +- powerpc/selftest.c | 18 ++++++++++++++++-- powerpc/unittests.cfg | 5 +++++ 5 files changed, 39 insertions(+), 3 deletions(-)
lib/powerpc/asm/rtas.h +1 -0
@@ -26,6 +26,7 @@ extern int rtas_call(int token, int nargs, int nret, int *outputs, ...);extern int rtas_call_unlocked (struct rtas_args *args,int token,int nargs,int nret,int *outputs, ...);extern void rtas_power_off (void ); +extern void rtas_os_panic (void );extern void rtas_stop_self (void );#endif /* __ASSEMBLY__ */
lib/powerpc/rtas.c +16 -0
@@ -182,3 +182,19 @@ void rtas_power_off(void) ret =rtas_call_unlocked (&args, token,2 ,1 ,NULL ,-1 ,-1 );printf ("RTAS power-off returned %d\n" , ret); } + +void rtas_os_panic (void ) +{ +struct rtas_args args; +uint32_t token; +int ret; + + ret =rtas_token ("ibm,os-term" , &token); +if (ret) { +puts ("RTAS ibm,os-term not available\n" ); +return ; + } + + ret =rtas_call_unlocked (&args, token,1 ,1 ,NULL ,"rtas_os_panic" ); +printf ("RTAS ibm,os-term returned %d\n" , ret); +}
powerpc/run +1 -1
@@ -56,7 +56,7 @@ fi command="$qemu -nodefaults $A $M $B $D" command+=" -display none -serial stdio -kernel" -command="$(migration_cmd) $(timeout_cmd) $command" +command="$(panic_cmd) $(migration_cmd) $(timeout_cmd) $command" # powerpc tests currently exit with rtas-poweroff, which exits with 0. # run_qemu treats that as a failure exit and returns 1, so we need
powerpc/selftest.c +16 -2
@@ -7,6 +7,7 @@*/ #include <libcflat.h> #include <util.h> +#include <asm/rtas.h> #include <asm/setup.h> #include <asm/smp.h>
@@ -47,6 +48,17 @@ static void check_setup(int argc, char **argv)report_abort ("missing input" ); } +static void do_panic (void ) +{ +if (machine_is_pseries ()) { +rtas_os_panic (); + }else { +/* Cause a checkstop with MSR[ME] disabled */ + *((char *)0x10000000000 ) =0 ; + } +report_fail ("survived panic" ); +} +int main (int argc,char **argv) {report_prefix_push ("selftest" );
@@ -57,9 +69,11 @@ int main(int argc, char **argv)report_prefix_push (argv[1 ]);if (strcmp (argv[1 ],"setup" ) ==0 ) { -check_setup (argc-2 , &argv[2 ]); - + }else if (strcmp (argv[1 ],"panic" ) ==0 ) { +do_panic (); + }else { +report_abort ("unknown test %s" , argv[1 ]); }return report_summary ();
powerpc/unittests.cfg +5 -0
@@ -18,6 +18,11 @@ smp = 2 extra_params = -m 1g -append 'setup smp=2 mem=1024' groups = selftest gitlab-ci +[selftest-panic] +file = selftest.elf +extra_params = -append 'panic' +groups = selftest panic gitlab-ci + [selftest-migration] file = selftest-migration.elf machine = pseries
Signature · 1 line
2.45.1
Re: [kvm-unit-tests PATCH v10 13/15] powerpc: Add a panic test
Quoted 4 lines · Nicholas Piggin
This adds a simple panic test for pseries and powernv that works with TCG (unlike the s390x panic tests), making it easier to test this part of the harness code.
Quoted 8 lines
Signed-off-by Nicholas Piggin <[email protected]>--- lib/powerpc/asm/rtas.h | 1 + lib/powerpc/rtas.c | 16 ++++++++++++++++ powerpc/run | 2 +- powerpc/selftest.c | 18 ++++++++++++++++-- powerpc/unittests.cfg | 5 +++++ 5 files changed, 39 insertions(+), 3 deletions(-)
PATCH v10 14/15 powerpc/gitlab-ci: Upgrade powerpc to Fedora 40
In reply to Nicholas PigginQEMU has fixed a number of powerpc test fails in Fedora 40, so upgrade to that image.
Other architectures seem to be okay with Fedora 40 except for x86-64, which fails some xsave and realmode tests, so only change powerpc to start with.
--- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+)
.gitlab-ci.yml +2 -0
@@ -95,6 +95,7 @@ build-arm: build-ppc64be: extends: .outoftree_template + image: fedora:40 script: - dnf install -y qemu-system-ppc gcc-powerpc64-linux-gnu - mkdir build
@@ -107,6 +108,7 @@ build-ppc64be: build-ppc64le: extends: .intree_template + image: fedora:40 script: - dnf install -y qemu-system-ppc gcc-powerpc64-linux-gnu nmap-ncat - ./configure --arch=ppc64 --endian=little --cross-prefix=powerpc64-linux-gnu-
Signature · 1 line
2.45.1
Re: [kvm-unit-tests PATCH v10 14/15] powerpc/gitlab-ci: Upgrade powerpc to Fedora 40
Quoted 11 lines · Nicholas Piggin
QEMU has fixed a number of powerpc test fails in Fedora 40, so upgrade to that image.
Other architectures seem to be okay with Fedora 40 except for x86-64, which fails some xsave and realmode tests, so only change powerpc to start with.
Signed-off-by Nicholas Piggin <[email protected]>--- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+)
FYI, I've pushed now the generic patch to bump all jobs to F40, so I think you can drop this one here from your queue now.
Thomas
PATCH v10 15/15 powerpc/gitlab-ci: Enable more tests with Fedora 40
In reply to Nicholas PigginWith Fedora 40 (QEMU 8.2), more tests can be enabled.
--- .gitlab-ci.yml | 2 +- powerpc/unittests.cfg | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-)
.gitlab-ci.yml +1 -1
@@ -110,7 +110,7 @@ build-ppc64le: extends: .intree_template image: fedora:40 script: - - dnf install -y qemu-system-ppc gcc-powerpc64-linux-gnu nmap-ncat + - dnf install -y qemu-system-ppc gcc-powerpc64-linux-gnu nmap-ncat jq - ./configure --arch=ppc64 --endian=little --cross-prefix=powerpc64-linux-gnu- - make -j2 - ACCEL=tcg MAX_SMP=8 ./run_tests.sh -g gitlab-ci
powerpc/unittests.cfg +8 -9
@@ -28,7 +28,7 @@ file = selftest-migration.elf machine = pseries groups = selftest migration -# QEMU 7.0 (Fedora 37) in gitlab CI has known migration bugs in TCG, so +# QEMU 8.2 (Fedora 40) in gitlab CI has known migration bugs in TCG, so # make a kvm-only version for CI [selftest-migration-ci] file = selftest-migration.elf
@@ -81,18 +81,18 @@ groups = rtas gitlab-ci file = emulator.elf groups = gitlab-ci -# QEMU 7.0 (Fedora 37) in gitlab CI fails this +# QEMU 8.2 in Fedora 40 fails because it allows supervisor to change MSR[ME] [interrupts] file = interrupts.elf -# QEMU 7.0 (Fedora 37) in gitlab CI fails this [mmu] file = mmu.elf smp = 2 +groups = gitlab-ci -# QEMU 7.0 (Fedora 37) in gitlab CI fails this [pmu] file = pmu.elf +groups = gitlab-ci [smp] file = smp.elf
@@ -120,15 +120,15 @@ machine = pseries extra_params = -append "migration -m" groups = migration gitlab-ci -# QEMU 7.0 (Fedora 37) in gitlab CI fails this [timebase] file = timebase.elf +groups = gitlab-ci -# QEMU 7.0 (Fedora 37) in gitlab CI fails this [timebase-icount] file = timebase.elf accel = tcg extra_params = -icount shift=5 +groups = gitlab-ci [h_cede_tm] file = tm.elf
@@ -138,16 +138,15 @@ smp = 2,threads=2 extra_params = -machine cap-htm=on -append "h_cede_tm" groups = h_cede_tm -# QEMU 7.0 (Fedora 37) in gitlab CI fails this [sprs] file = sprs.elf +groups = gitlab-ci -# QEMU 7.0 (Fedora 37) in gitlab CI fails this [sprs-migration] file = sprs.elf machine = pseries extra_params = -append '-w' -groups = migration +groups = migration gitlab-ci # Too costly to run in CI [sieve]
Signature · 1 line
2.45.1
Re: [kvm-unit-tests PATCH v10 15/15] powerpc/gitlab-ci: Enable more tests with Fedora 40
Quoted 13 lines · Nicholas Piggin
With Fedora 40 (QEMU 8.2), more tests can be enabled.
Signed-off-by Nicholas Piggin <[email protected]>--- .gitlab-ci.yml | 2 +- powerpc/unittests.cfg | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-).gitlab-ci.yml +0
-0
.gitlab-ci.yml build-ppc64le: · line 113
Quoted 5 lines
.gitlab-ci.yml +1
-1@@ -110,7 +110,7 @@ build-ppc64le: extends: .intree_template image: fedora:40 script: - - dnf install -y qemu-system-ppc gcc-powerpc64-linux-gnu nmap-ncat + - dnf install -y qemu-system-ppc gcc-powerpc64-linux-gnu nmap-ncat jq
Please mention the addition of jq in the patch description (why it is needed).
Thanks,
Thomas