[PATCH 09/14] powerpc/rtas: Leave MSR[RI] enabled over RTAS call
Nicholas Piggin
npiggin at gmail.com
Wed Mar 9 00:50:42 AEDT 2022
PAPR specifies that RTAS may be called with MSR[RI] enabled if the
calling context is recoverable, and RTAS will manage RI as necessary.
Call the rtas entry point with RI enabled, and add a check to ensure
the caller has RI enabled.
Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
arch/powerpc/kernel/rtas.c | 1 +
arch/powerpc/kernel/rtas_entry.S | 13 +++----------
2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 87ede1877816..fece066115f0 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -57,6 +57,7 @@ static noinline void do_enter_rtas(unsigned long args)
hard_irq_disable();
msr = mfmsr();
+ BUG_ON(!(msr & MSR_RI));
mtmsr(msr & ~(MSR_IR|MSR_DR));
enter_rtas(args);
mtmsr(msr);
diff --git a/arch/powerpc/kernel/rtas_entry.S b/arch/powerpc/kernel/rtas_entry.S
index 292551684bbd..72b27b14ccc9 100644
--- a/arch/powerpc/kernel/rtas_entry.S
+++ b/arch/powerpc/kernel/rtas_entry.S
@@ -95,7 +95,7 @@ _GLOBAL(enter_rtas)
clrldi r4,r4,2 /* convert to realmode address */
mtlr r4
- LOAD_REG_IMMEDIATE(r6, MSR_ME)
+ LOAD_REG_IMMEDIATE(r6, MSR_ME|MSR_RI)
LOAD_REG_ADDR(r4, rtas)
ld r5,RTASENTRY(r4) /* get the rtas->entry value */
@@ -113,15 +113,8 @@ _ASM_NOKPROBE_SYMBOL(enter_rtas)
rtas_return_loc:
FIXUP_ENDIAN
- /*
- * Clear RI and set SF before anything.
- */
- mfmsr r6
- li r0,MSR_RI
- andc r6,r6,r0
- sldi r0,r0,(MSR_SF_LG - MSR_RI_LG)
- or r6,r6,r0
- sync
+ /* Set SF before anything. */
+ LOAD_REG_IMMEDIATE(r6, MSR_KERNEL & ~(MSR_IR|MSR_DR))
mtmsrd r6
GET_PACA(r13)
--
2.23.0
More information about the Linuxppc-dev
mailing list