Skip to contentSkip to conversation

powerpc: Fix running the kvm-unit-tests with recent versions of QEMU

PATCH In review Thomas Huth 2 participants 2 messages Dec 6, 2022 KVM

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 powerpc: Fix running the kvm-unit-tests with recent versions of QEMU

Starting with version 7.0, QEMU starts the pseries guests in 32-bit mode instead of 64-bit (see QEMU commit 6e3f09c28a - "spapr: Force 32bit when resetting a core"). This causes our test_64bit() in powerpc/emulator.c to fail. Let's switch to 64-bit in our startup code instead to fix the issue.

---
 lib/powerpc/asm/ppc_asm.h | 3 +++
 powerpc/cstart64.S        | 6 ++++++
 2 files changed, 9 insertions(+)
lib/powerpc/asm/ppc_asm.h +3 -0
index 39620a39..1b85f6bb 100644
@@ -35,4 +35,7 @@
 
 #endif /* __BYTE_ORDER__ */
 
+/* Machine State Register definitions: */
+#define MSR_SF_BIT	63			/* 64-bit mode */
+
 #endif /* _ASMPOWERPC_PPC_ASM_H */
powerpc/cstart64.S +6 -0
index 972851f9..34e39341 100644
@@ -23,6 +23,12 @@
 .globl start
 start:
 	FIXUP_ENDIAN
+	/* Switch to 64-bit mode */
+	mfmsr	r1
+	li	r2,1
+	sldi	r2,r2,MSR_SF_BIT
+	or	r1,r1,r2
+	mtmsrd	r1
 	/*
 	 * We were loaded at QEMU's kernel load address, but we're not
 	 * allowed to link there due to how QEMU deals with linker VMAs,
Signature · 1 line
2.31.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Thomas Huth

Starting with version 7.0, QEMU starts the pseries guests in 32-bit mode instead of 64-bit (see QEMU commit 6e3f09c28a - "spapr: Force 32bit when resetting a core"). This causes our test_64bit() in powerpc/emulator.c to fail. Let's switch to 64-bit in our startup code instead to fix the issue.

Thanks,

C.

Quoted 34 lines
---
  lib/powerpc/asm/ppc_asm.h | 3 +++
  powerpc/cstart64.S        | 6 ++++++
  2 files changed, 9 insertions(+)
lib/powerpc/asm/ppc_asm.h +3 -0
index 39620a39..1b85f6bb 100644
@@ -35,4 +35,7 @@
 
  #endif /* __BYTE_ORDER__ */
 
+/* Machine State Register definitions: */
+#define MSR_SF_BIT	63			/* 64-bit mode */
+
  #endif /* _ASMPOWERPC_PPC_ASM_H */
powerpc/cstart64.S +6 -0
index 972851f9..34e39341 100644
@@ -23,6 +23,12 @@
  .globl start
  start:
  	FIXUP_ENDIAN
+	/* Switch to 64-bit mode */
+	mfmsr	r1
+	li	r2,1
+	sldi	r2,r2,MSR_SF_BIT
+	or	r1,r1,r2
+	mtmsrd	r1
  	/*
  	 * We were loaded at QEMU's kernel load address, but we're not
  	 * allowed to link there due to how QEMU deals with linker VMAs,