[PATCH v3 04/10] powerpc: kvm: allow flexible PAGE_OFFSET
Arnd Bergmann
arnd at kernel.org
Mon Nov 16 04:48:26 PST 2026
From: Arnd Bergmann <arnd at arndb.de>
As described by the Sashiko bot, the KVM code on powerpc has multiple
hardcoded PAGE_OFFSET values. In order to change the default, make these
compute the correct register values from configuration symbols.
Signed-off-by: Arnd Bergmann <arnd at arndb.de>
---
arch/powerpc/kvm/book3s_32_sr.S | 4 ++--
arch/powerpc/kvm/booke_interrupts.S | 4 ++--
arch/powerpc/kvm/e500_mmu_host.c | 3 ++-
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/kvm/book3s_32_sr.S b/arch/powerpc/kvm/book3s_32_sr.S
index 6cfcd20d4668..0d8a7857f2bd 100644
--- a/arch/powerpc/kvm/book3s_32_sr.S
+++ b/arch/powerpc/kvm/book3s_32_sr.S
@@ -113,8 +113,8 @@
li r0, 4
mtctr r0
- LOAD_REG_IMMEDIATE(r3, 0x20000000 | (0x111 * 0xc))
- lis r4, 0xc000
+ LOAD_REG_IMMEDIATE(r3, 0x20000000 | (0x111 * (PAGE_OFFSET >> 28)))
+ lis r4, (PAGE_OFFSET >> 16)
3: mtsrin r3, r4
addi r3, r3, 0x111 /* increment VSID */
addis r4, r4, 0x1000 /* address of next segment */
diff --git a/arch/powerpc/kvm/booke_interrupts.S b/arch/powerpc/kvm/booke_interrupts.S
index 205545d820a1..ede394f3f63f 100644
--- a/arch/powerpc/kvm/booke_interrupts.S
+++ b/arch/powerpc/kvm/booke_interrupts.S
@@ -230,8 +230,8 @@ _GLOBAL(kvmppc_resume_host)
#endif
/* Restore host IVPR before re-enabling interrupts. We cheat and know
- * that Linux IVPR is always 0xc0000000. */
- lis r3, 0xc000
+ * that Linux IVPR is always PAGE_OFFSET. */
+ lis r3, PAGE_OFFSET >> 16
mtspr SPRN_IVPR, r3
/* Switch to kernel stack and jump to handler. */
diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
index fa6128119874..9edad9bed589 100644
--- a/arch/powerpc/kvm/e500_mmu_host.c
+++ b/arch/powerpc/kvm/e500_mmu_host.c
@@ -115,7 +115,8 @@ static u32 get_host_mas0(unsigned long eaddr)
mtspr(SPRN_MAS6, 0);
mas4 = mfspr(SPRN_MAS4);
mtspr(SPRN_MAS4, mas4 & ~MAS4_TLBSEL_MASK);
- asm volatile("tlbsx 0, %0" : : "b" (eaddr & ~CONFIG_PAGE_OFFSET));
+ asm volatile("tlbsx 0, %0" :
+ : "b" (eaddr & (rounddown_pow_of_two(PAGE_OFFSET)-1)));
mas0 = mfspr(SPRN_MAS0);
mtspr(SPRN_MAS4, mas4);
local_irq_restore(flags);
--
2.53.0
More information about the linux-arm-kernel
mailing list