LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/3] powerpc: Remove MSR_PR check in interrupt_exit_{user/kernel}_prepare()
@ 2021-08-19  6:30 Christophe Leroy
  2021-08-19  6:30 ` [PATCH 2/3] powerpc: Refactor verification of MSR_RI Christophe Leroy
  2021-08-19  6:30 ` [PATCH 3/3] powerpc: Define and use MSR_RI only on non booke/40x Christophe Leroy
  0 siblings, 2 replies; 4+ messages in thread
From: Christophe Leroy @ 2021-08-19  6:30 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, npiggin
  Cc: linux-kernel, linuxppc-dev

In those hot functions that are called at every interrupt, any saved
cycle is worth it.

interrupt_exit_user_prepare() and interrupt_exit_kernel_prepare() are
called from three places:
- From entry_32.S
- From interrupt_64.S
- From interrupt_exit_user_restart() and interrupt_exit_kernel_restart()

In entry_32.S, there are inambiguously called based on MSR_PR:

	interrupt_return:
		lwz	r4,_MSR(r1)
		addi	r3,r1,STACK_FRAME_OVERHEAD
		andi.	r0,r4,MSR_PR
		beq	.Lkernel_interrupt_return
		bl	interrupt_exit_user_prepare
	...
	.Lkernel_interrupt_return:
		bl	interrupt_exit_kernel_prepare

In interrupt_64.S, that's similar:

	interrupt_return_\srr\():
		ld	r4,_MSR(r1)
		andi.	r0,r4,MSR_PR
		beq	interrupt_return_\srr\()_kernel
	interrupt_return_\srr\()_user: /* make backtraces match the _kernel variant */
		addi	r3,r1,STACK_FRAME_OVERHEAD
		bl	interrupt_exit_user_prepare
	...
	interrupt_return_\srr\()_kernel:
		addi	r3,r1,STACK_FRAME_OVERHEAD
		bl	interrupt_exit_kernel_prepare

In interrupt_exit_user_restart() and interrupt_exit_kernel_restart(),
MSR_PR is verified respectively by BUG_ON(!user_mode(regs)) and
BUG_ON(user_mode(regs)) prior to calling interrupt_exit_user_prepare()
and interrupt_exit_kernel_prepare().

The verification in interrupt_exit_user_prepare() and
interrupt_exit_kernel_prepare() are therefore useless and can be removed.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Acked-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/interrupt.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
index 21bbd615ca41..f26caf911ab5 100644
--- a/arch/powerpc/kernel/interrupt.c
+++ b/arch/powerpc/kernel/interrupt.c
@@ -465,7 +465,6 @@ notrace unsigned long interrupt_exit_user_prepare(struct pt_regs *regs)
 
 	if (!IS_ENABLED(CONFIG_BOOKE) && !IS_ENABLED(CONFIG_40x))
 		BUG_ON(!(regs->msr & MSR_RI));
-	BUG_ON(!(regs->msr & MSR_PR));
 	BUG_ON(arch_irq_disabled_regs(regs));
 	CT_WARN_ON(ct_state() == CONTEXT_USER);
 
@@ -499,7 +498,6 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs)
 	if (!IS_ENABLED(CONFIG_BOOKE) && !IS_ENABLED(CONFIG_40x) &&
 	    unlikely(!(regs->msr & MSR_RI)))
 		unrecoverable_exception(regs);
-	BUG_ON(regs->msr & MSR_PR);
 	/*
 	 * CT_WARN_ON comes here via program_check_exception,
 	 * so avoid recursion.
-- 
2.25.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] powerpc: Refactor verification of MSR_RI
  2021-08-19  6:30 [PATCH 1/3] powerpc: Remove MSR_PR check in interrupt_exit_{user/kernel}_prepare() Christophe Leroy
@ 2021-08-19  6:30 ` Christophe Leroy
  2021-08-19 13:23   ` kernel test robot
  2021-08-19  6:30 ` [PATCH 3/3] powerpc: Define and use MSR_RI only on non booke/40x Christophe Leroy
  1 sibling, 1 reply; 4+ messages in thread
From: Christophe Leroy @ 2021-08-19  6:30 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, npiggin
  Cc: linux-kernel, linuxppc-dev

40x and BOOKE don't have MSR_RI therefore all tests involving
MSR_RI may be problematic on those plateforms.

Create helpers to check or set MSR_RI in regs, and use them
in common code.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/include/asm/ptrace.h             | 23 +++++++++++++++++++
 arch/powerpc/kernel/interrupt.c               |  9 +++-----
 arch/powerpc/kernel/traps.c                   |  8 +++----
 arch/powerpc/mm/book3s64/slb.c                |  2 +-
 arch/powerpc/platforms/embedded6xx/holly.c    |  2 +-
 .../platforms/embedded6xx/mpc7448_hpc2.c      |  2 +-
 arch/powerpc/platforms/pasemi/idle.c          |  2 +-
 arch/powerpc/platforms/powernv/opal.c         |  2 +-
 arch/powerpc/platforms/pseries/ras.c          |  2 +-
 arch/powerpc/sysdev/fsl_rio.c                 |  2 +-
 arch/powerpc/xmon/xmon.c                      | 16 +++----------
 11 files changed, 40 insertions(+), 30 deletions(-)

diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
index fd60538737a0..0cdb7b9c2c9c 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -22,6 +22,7 @@
 #include <linux/err.h>
 #include <uapi/asm/ptrace.h>
 #include <asm/asm-const.h>
+#include <asm/reg.h>
 
 #ifndef __ASSEMBLY__
 struct pt_regs
@@ -282,6 +283,28 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc)
 	regs->gpr[3] = rc;
 }
 
+static inline bool cpu_has_msr_ri(void)
+{
+	return !IS_ENABLED(CONFIG_BOOKE) && !IS_ENABLED(CONFIG_40x);
+}
+
+static inline bool regs_is_unrecoverable(struct pt_regs *regs)
+{
+	return unlikely(cpu_has_msr_ri() && !(regs->msr & MSR_RI));
+}
+
+static inline void regs_set_recoverable(struct pt_regs *regs)
+{
+	if (cpu_has_msr_ri())
+		regs_set_return_msr(regs, regs->msr | MSR_RI);
+}
+
+static inline void regs_set_unrecoverable(struct pt_regs *regs)
+{
+	if (cpu_has_msr_ri())
+		regs_set_return_msr(regs, regs->msr & ~MSR_RI);
+}
+
 #define arch_has_single_step()	(1)
 #define arch_has_block_step()	(true)
 #define ARCH_HAS_USER_SINGLE_STEP_REPORT
diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
index f26caf911ab5..f06c38e8fe36 100644
--- a/arch/powerpc/kernel/interrupt.c
+++ b/arch/powerpc/kernel/interrupt.c
@@ -93,8 +93,7 @@ notrace long system_call_exception(long r3, long r4, long r5,
 	CT_WARN_ON(ct_state() == CONTEXT_KERNEL);
 	user_exit_irqoff();
 
-	if (!IS_ENABLED(CONFIG_BOOKE) && !IS_ENABLED(CONFIG_40x))
-		BUG_ON(!(regs->msr & MSR_RI));
+	BUG_ON(regs_is_unrecoverable(regs));
 	BUG_ON(!(regs->msr & MSR_PR));
 	BUG_ON(arch_irq_disabled_regs(regs));
 
@@ -463,8 +462,7 @@ notrace unsigned long interrupt_exit_user_prepare(struct pt_regs *regs)
 {
 	unsigned long ret;
 
-	if (!IS_ENABLED(CONFIG_BOOKE) && !IS_ENABLED(CONFIG_40x))
-		BUG_ON(!(regs->msr & MSR_RI));
+	BUG_ON(regs_is_unrecoverable(regs));
 	BUG_ON(arch_irq_disabled_regs(regs));
 	CT_WARN_ON(ct_state() == CONTEXT_USER);
 
@@ -495,8 +493,7 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs)
 	bool stack_store = current_thread_info()->flags &
 						_TIF_EMULATE_STACK_STORE;
 
-	if (!IS_ENABLED(CONFIG_BOOKE) && !IS_ENABLED(CONFIG_40x) &&
-	    unlikely(!(regs->msr & MSR_RI)))
+	if (regs_is_unrecoverable(regs))
 		unrecoverable_exception(regs);
 	/*
 	 * CT_WARN_ON comes here via program_check_exception,
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 3e2adb3487e7..8310147b5e7b 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -428,7 +428,7 @@ void hv_nmi_check_nonrecoverable(struct pt_regs *regs)
 	return;
 
 nonrecoverable:
-	regs_set_return_msr(regs, regs->msr & ~MSR_RI);
+	regs_set_unrecoverable(regs);
 #endif
 }
 DEFINE_INTERRUPT_HANDLER_NMI(system_reset_exception)
@@ -498,7 +498,7 @@ DEFINE_INTERRUPT_HANDLER_NMI(system_reset_exception)
 		die("Unrecoverable nested System Reset", regs, SIGABRT);
 #endif
 	/* Must die if the interrupt is not recoverable */
-	if (!(regs->msr & MSR_RI)) {
+	if (regs_is_unrecoverable(regs)) {
 		/* For the reason explained in die_mce, nmi_exit before die */
 		nmi_exit();
 		die("Unrecoverable System Reset", regs, SIGABRT);
@@ -550,7 +550,7 @@ static inline int check_io_access(struct pt_regs *regs)
 			printk(KERN_DEBUG "%s bad port %lx at %p\n",
 			       (*nip & 0x100)? "OUT to": "IN from",
 			       regs->gpr[rb] - _IO_BASE, nip);
-			regs_set_return_msr(regs, regs->msr | MSR_RI);
+			regs_set_recoverable(regs);
 			regs_set_return_ip(regs, extable_fixup(entry));
 			return 1;
 		}
@@ -840,7 +840,7 @@ DEFINE_INTERRUPT_HANDLER_NMI(machine_check_exception)
 
 bail:
 	/* Must die if the interrupt is not recoverable */
-	if (!(regs->msr & MSR_RI))
+	if (regs_is_unrecoverable(regs))
 		die_mce("Unrecoverable Machine check", regs, SIGBUS);
 
 #ifdef CONFIG_PPC_BOOK3S_64
diff --git a/arch/powerpc/mm/book3s64/slb.c b/arch/powerpc/mm/book3s64/slb.c
index c91bd85eb90e..48a142d66fc9 100644
--- a/arch/powerpc/mm/book3s64/slb.c
+++ b/arch/powerpc/mm/book3s64/slb.c
@@ -822,7 +822,7 @@ DEFINE_INTERRUPT_HANDLER_RAW(do_slb_fault)
 	/* IRQs are not reconciled here, so can't check irqs_disabled */
 	VM_WARN_ON(mfmsr() & MSR_EE);
 
-	if (unlikely(!(regs->msr & MSR_RI)))
+	if (regs_is_unrecoverable(regs)) {
 		return -EINVAL;
 
 	/*
diff --git a/arch/powerpc/platforms/embedded6xx/holly.c b/arch/powerpc/platforms/embedded6xx/holly.c
index 85521b3e7098..7a85b117f7a4 100644
--- a/arch/powerpc/platforms/embedded6xx/holly.c
+++ b/arch/powerpc/platforms/embedded6xx/holly.c
@@ -251,7 +251,7 @@ static int ppc750_machine_check_exception(struct pt_regs *regs)
 	/* Are we prepared to handle this fault */
 	if ((entry = search_exception_tables(regs->nip)) != NULL) {
 		tsi108_clear_pci_cfg_error();
-		regs_set_return_msr(regs, regs->msr | MSR_RI);
+		regs_set_recoverable(regs);
 		regs_set_return_ip(regs, extable_fixup(entry));
 		return 1;
 	}
diff --git a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
index d8da6a483e59..9eb9abb5bce2 100644
--- a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
+++ b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
@@ -173,7 +173,7 @@ static int mpc7448_machine_check_exception(struct pt_regs *regs)
 	/* Are we prepared to handle this fault */
 	if ((entry = search_exception_tables(regs->nip)) != NULL) {
 		tsi108_clear_pci_cfg_error();
-		regs_set_return_msr(regs, regs->msr | MSR_RI);
+		regs_set_recoverable(regs);
 		regs_set_return_ip(regs, extable_fixup(entry));
 		return 1;
 	}
diff --git a/arch/powerpc/platforms/pasemi/idle.c b/arch/powerpc/platforms/pasemi/idle.c
index 534b0317fc15..6087c70ed2ef 100644
--- a/arch/powerpc/platforms/pasemi/idle.c
+++ b/arch/powerpc/platforms/pasemi/idle.c
@@ -59,7 +59,7 @@ static int pasemi_system_reset_exception(struct pt_regs *regs)
 	restore_astate(hard_smp_processor_id());
 
 	/* everything handled */
-	regs_set_return_msr(regs, regs->msr | MSR_RI);
+	regs_set_recoverable(regs);
 	return 1;
 }
 
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index 2835376e61a4..e9d18519e650 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -588,7 +588,7 @@ static int opal_recover_mce(struct pt_regs *regs,
 {
 	int recovered = 0;
 
-	if (!(regs->msr & MSR_RI)) {
+	if (regs_is_unrecoverable(regs)) {
 		/* If MSR_RI isn't set, we cannot recover */
 		pr_err("Machine check interrupt unrecoverable: MSR(RI=0)\n");
 		recovered = 0;
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index 167f2e1b8d39..56092dccfdb8 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -783,7 +783,7 @@ static int recover_mce(struct pt_regs *regs, struct machine_check_event *evt)
 {
 	int recovered = 0;
 
-	if (!(regs->msr & MSR_RI)) {
+	if (regs_is_unrecoverable(regs)) {
 		/* If MSR_RI isn't set, we cannot recover */
 		pr_err("Machine check interrupt unrecoverable: MSR(RI=0)\n");
 		recovered = 0;
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 5a95b8ea23d8..ff7906b48ca1 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -108,7 +108,7 @@ int fsl_rio_mcheck_exception(struct pt_regs *regs)
 				 __func__);
 			out_be32((u32 *)(rio_regs_win + RIO_LTLEDCSR),
 				 0);
-			regs_set_return_msr(regs, regs->msr | MSR_RI);
+			regs_set_recoverable(regs);
 			regs_set_return_ip(regs, extable_fixup(entry));
 			return 1;
 		}
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index ead460b80905..dd8241c009e5 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -482,16 +482,6 @@ static inline void get_output_lock(void) {}
 static inline void release_output_lock(void) {}
 #endif
 
-static inline int unrecoverable_excp(struct pt_regs *regs)
-{
-#if defined(CONFIG_4xx) || defined(CONFIG_PPC_BOOK3E)
-	/* We have no MSR_RI bit on 4xx or Book3e, so we simply return false */
-	return 0;
-#else
-	return ((regs->msr & MSR_RI) == 0);
-#endif
-}
-
 static void xmon_touch_watchdogs(void)
 {
 	touch_softlockup_watchdog_sync();
@@ -565,7 +555,7 @@ static int xmon_core(struct pt_regs *regs, volatile int fromipi)
 	bp = NULL;
 	if ((regs->msr & (MSR_IR|MSR_PR|MSR_64BIT)) == (MSR_IR|MSR_64BIT))
 		bp = at_breakpoint(regs->nip);
-	if (bp || unrecoverable_excp(regs))
+	if (bp || regs_is_unrecoverable(regs))
 		fromipi = 0;
 
 	if (!fromipi) {
@@ -577,7 +567,7 @@ static int xmon_core(struct pt_regs *regs, volatile int fromipi)
 			       cpu, BP_NUM(bp));
 			xmon_print_symbol(regs->nip, " ", ")\n");
 		}
-		if (unrecoverable_excp(regs))
+		if (regs_is_unrecoverable(regs))
 			printf("WARNING: exception is not recoverable, "
 			       "can't continue\n");
 		release_output_lock();
@@ -693,7 +683,7 @@ static int xmon_core(struct pt_regs *regs, volatile int fromipi)
 			printf("Stopped at breakpoint %tx (", BP_NUM(bp));
 			xmon_print_symbol(regs->nip, " ", ")\n");
 		}
-		if (unrecoverable_excp(regs))
+		if (regs_is_unrecoverable(regs))
 			printf("WARNING: exception is not recoverable, "
 			       "can't continue\n");
 		remove_bpts();
-- 
2.25.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] powerpc: Define and use MSR_RI only on non booke/40x
  2021-08-19  6:30 [PATCH 1/3] powerpc: Remove MSR_PR check in interrupt_exit_{user/kernel}_prepare() Christophe Leroy
  2021-08-19  6:30 ` [PATCH 2/3] powerpc: Refactor verification of MSR_RI Christophe Leroy
@ 2021-08-19  6:30 ` Christophe Leroy
  1 sibling, 0 replies; 4+ messages in thread
From: Christophe Leroy @ 2021-08-19  6:30 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, npiggin
  Cc: linux-kernel, linuxppc-dev

40x and BOOKE don't have MSR_RI.

Define MSR_RI only for platforms where it exists. For the other ones,
defines it as BUILD_BUG for C and do not define it for ASM.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/include/asm/reg.h       | 4 ++++
 arch/powerpc/include/asm/reg_booke.h | 6 +++---
 arch/powerpc/kernel/head_32.h        | 4 ++++
 arch/powerpc/kernel/process.c        | 2 +-
 arch/powerpc/lib/sstep.c             | 2 +-
 5 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index be85cf156a1f..656a9aaa1e8e 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -109,7 +109,11 @@
 #ifndef MSR_PMM
 #define MSR_PMM		__MASK(MSR_PMM_LG)	/* Performance monitor */
 #endif
+#if !defined(CONFIG_BOOKE) && !defined(CONFIG_40x)
 #define MSR_RI		__MASK(MSR_RI_LG)	/* Recoverable Exception */
+#elif !defined(__ASSEMBLY__)
+#define MSR_RI		({BUILD_BUG(); 0; })
+#endif
 #define MSR_LE		__MASK(MSR_LE_LG)	/* Little Endian */
 
 #define MSR_TM		__MASK(MSR_TM_LG)	/* Transactional Mem Available */
diff --git a/arch/powerpc/include/asm/reg_booke.h b/arch/powerpc/include/asm/reg_booke.h
index 17b8dcd9a40d..6f40a8420ad0 100644
--- a/arch/powerpc/include/asm/reg_booke.h
+++ b/arch/powerpc/include/asm/reg_booke.h
@@ -38,15 +38,15 @@
 #if defined(CONFIG_PPC_BOOK3E_64)
 #define MSR_64BIT	MSR_CM
 
-#define MSR_		(MSR_ME | MSR_RI | MSR_CE)
+#define MSR_		(MSR_ME | MSR_CE)
 #define MSR_KERNEL	(MSR_ | MSR_64BIT)
 #define MSR_USER32	(MSR_ | MSR_PR | MSR_EE)
 #define MSR_USER64	(MSR_USER32 | MSR_64BIT)
 #elif defined (CONFIG_40x)
-#define MSR_KERNEL	(MSR_ME|MSR_RI|MSR_IR|MSR_DR|MSR_CE)
+#define MSR_KERNEL	(MSR_ME|MSR_IR|MSR_DR|MSR_CE)
 #define MSR_USER	(MSR_KERNEL|MSR_PR|MSR_EE)
 #else
-#define MSR_KERNEL	(MSR_ME|MSR_RI|MSR_CE)
+#define MSR_KERNEL	(MSR_ME|MSR_CE)
 #define MSR_USER	(MSR_KERNEL|MSR_PR|MSR_EE)
 #endif
 
diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h
index 6b1ec9e3541b..6c5f4183dc8e 100644
--- a/arch/powerpc/kernel/head_32.h
+++ b/arch/powerpc/kernel/head_32.h
@@ -63,7 +63,11 @@
 	mtspr	SPRN_DAR, r11	/* Tag DAR, to be used in DTLB Error */
 	.endif
 #endif
+#ifdef CONFIG_40x
+	LOAD_REG_IMMEDIATE(r11, MSR_KERNEL) /* re-enable MMU */
+#else
 	LOAD_REG_IMMEDIATE(r11, MSR_KERNEL & ~MSR_RI) /* re-enable MMU */
+#endif
 	mtspr	SPRN_SRR1, r11
 	lis	r11, 1f@h
 	ori	r11, r11, 1f@l
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 185beb290580..5ba72e31de28 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1420,7 +1420,7 @@ static struct regbit msr_bits[] = {
 	{MSR_IR,	"IR"},
 	{MSR_DR,	"DR"},
 	{MSR_PMM,	"PMM"},
-#ifndef CONFIG_BOOKE
+#if !defined(CONFIG_BOOKE) && !defined(CONFIG_40x)
 	{MSR_RI,	"RI"},
 	{MSR_LE,	"LE"},
 #endif
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index d8d5f901cee1..357cc1fb4f67 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -3559,7 +3559,7 @@ int emulate_step(struct pt_regs *regs, struct ppc_inst instr)
 
 	case MTMSR:
 		val = regs->gpr[op.reg];
-		if ((val & MSR_RI) == 0)
+		if (cpu_has_msr_ri() && (val & MSR_RI) == 0)
 			/* can't step mtmsr[d] that would clear MSR_RI */
 			return -1;
 		/* here op.val is the mask of bits to change */
-- 
2.25.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/3] powerpc: Refactor verification of MSR_RI
  2021-08-19  6:30 ` [PATCH 2/3] powerpc: Refactor verification of MSR_RI Christophe Leroy
@ 2021-08-19 13:23   ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-08-19 13:23 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, npiggin
  Cc: kbuild-all, linux-kernel, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 8484 bytes --]

Hi Christophe,

I love your patch! Perhaps something to improve:

[auto build test WARNING on powerpc/next]
[also build test WARNING on v5.14-rc6 next-20210819]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Christophe-Leroy/powerpc-Remove-MSR_PR-check-in-interrupt_exit_-user-kernel-_prepare/20210819-143251
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-allyesconfig (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/797b527549df3f1f8e4d9f2bafeb5fe5ec810409
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Christophe-Leroy/powerpc-Remove-MSR_PR-check-in-interrupt_exit_-user-kernel-_prepare/20210819-143251
        git checkout 797b527549df3f1f8e4d9f2bafeb5fe5ec810409
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from arch/powerpc/mm/book3s64/slb.c:13:
   arch/powerpc/mm/book3s64/slb.c: In function '____do_slb_fault':
   arch/powerpc/include/asm/interrupt.h:398:29: error: invalid storage class for function '____do_bad_slb_fault'
     398 | static __always_inline void ____##func(struct pt_regs *regs);           \
         |                             ^~~~
   arch/powerpc/mm/book3s64/slb.c:872:1: note: in expansion of macro 'DEFINE_INTERRUPT_HANDLER'
     872 | DEFINE_INTERRUPT_HANDLER(do_bad_slb_fault)
         | ^~~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/interrupt.h:398:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     398 | static __always_inline void ____##func(struct pt_regs *regs);           \
         | ^~~~~~
   arch/powerpc/mm/book3s64/slb.c:872:1: note: in expansion of macro 'DEFINE_INTERRUPT_HANDLER'
     872 | DEFINE_INTERRUPT_HANDLER(do_bad_slb_fault)
         | ^~~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/interrupt.h:400:36: warning: 'externally_visible' attribute have effect only on public objects [-Wattributes]
     400 | interrupt_handler void func(struct pt_regs *regs)                       \
         |                                    ^~~~~~~
   arch/powerpc/mm/book3s64/slb.c:872:1: note: in expansion of macro 'DEFINE_INTERRUPT_HANDLER'
     872 | DEFINE_INTERRUPT_HANDLER(do_bad_slb_fault)
         | ^~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/mm/book3s64/slb.c: In function 'do_bad_slb_fault':
   arch/powerpc/include/asm/interrupt.h:406:9: error: implicit declaration of function '____do_bad_slb_fault'; did you mean 'do_bad_slb_fault'? [-Werror=implicit-function-declaration]
     406 |         ____##func (regs);                                              \
         |         ^~~~
   arch/powerpc/mm/book3s64/slb.c:872:1: note: in expansion of macro 'DEFINE_INTERRUPT_HANDLER'
     872 | DEFINE_INTERRUPT_HANDLER(do_bad_slb_fault)
         | ^~~~~~~~~~~~~~~~~~~~~~~~
   In file included from arch/powerpc/include/asm/kprobes.h:5,
                    from arch/powerpc/include/asm/interrupt.h:73,
                    from arch/powerpc/mm/book3s64/slb.c:13:
   arch/powerpc/mm/book3s64/slb.c: In function '____do_slb_fault':
   include/asm-generic/kprobes.h:14:29: error: initializer element is not constant
      14 |         _kbl_addr_##fname = (unsigned long)fname;
         |                             ^
   include/asm-generic/kprobes.h:15:33: note: in expansion of macro '__NOKPROBE_SYMBOL'
      15 | # define NOKPROBE_SYMBOL(fname) __NOKPROBE_SYMBOL(fname)
         |                                 ^~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/interrupt.h:410:1: note: in expansion of macro 'NOKPROBE_SYMBOL'
     410 | NOKPROBE_SYMBOL(func);                                                  \
         | ^~~~~~~~~~~~~~~
   arch/powerpc/mm/book3s64/slb.c:872:1: note: in expansion of macro 'DEFINE_INTERRUPT_HANDLER'
     872 | DEFINE_INTERRUPT_HANDLER(do_bad_slb_fault)
         | ^~~~~~~~~~~~~~~~~~~~~~~~
   In file included from arch/powerpc/mm/book3s64/slb.c:13:
   arch/powerpc/include/asm/interrupt.h:412:29: error: invalid storage class for function '____do_bad_slb_fault'
     412 | static __always_inline void ____##func(struct pt_regs *regs)
         |                             ^~~~
   arch/powerpc/mm/book3s64/slb.c:872:1: note: in expansion of macro 'DEFINE_INTERRUPT_HANDLER'
     872 | DEFINE_INTERRUPT_HANDLER(do_bad_slb_fault)
         | ^~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/interrupt.h:412:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     412 | static __always_inline void ____##func(struct pt_regs *regs)
         | ^~~~~~
   arch/powerpc/mm/book3s64/slb.c:872:1: note: in expansion of macro 'DEFINE_INTERRUPT_HANDLER'
     872 | DEFINE_INTERRUPT_HANDLER(do_bad_slb_fault)
         | ^~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/mm/book3s64/slb.c:886:1: error: expected declaration or statement at end of input
     886 | }
         | ^
   arch/powerpc/mm/book3s64/slb.c:887: error: control reaches end of non-void function [-Werror=return-type]
   cc1: some warnings being treated as errors


vim +398 arch/powerpc/include/asm/interrupt.h

8d41fc618ab804 Nicholas Piggin 2021-01-30  380  
8d41fc618ab804 Nicholas Piggin 2021-01-30  381  /**
8d41fc618ab804 Nicholas Piggin 2021-01-30  382   * DECLARE_INTERRUPT_HANDLER - Declare synchronous interrupt handler function
8d41fc618ab804 Nicholas Piggin 2021-01-30  383   * @func:	Function name of the entry point
8d41fc618ab804 Nicholas Piggin 2021-01-30  384   */
8d41fc618ab804 Nicholas Piggin 2021-01-30  385  #define DECLARE_INTERRUPT_HANDLER(func)					\
8d41fc618ab804 Nicholas Piggin 2021-01-30  386  	__visible void func(struct pt_regs *regs)
8d41fc618ab804 Nicholas Piggin 2021-01-30  387  
8d41fc618ab804 Nicholas Piggin 2021-01-30  388  /**
8d41fc618ab804 Nicholas Piggin 2021-01-30  389   * DEFINE_INTERRUPT_HANDLER - Define synchronous interrupt handler function
8d41fc618ab804 Nicholas Piggin 2021-01-30  390   * @func:	Function name of the entry point
8d41fc618ab804 Nicholas Piggin 2021-01-30  391   *
8d41fc618ab804 Nicholas Piggin 2021-01-30  392   * @func is called from ASM entry code.
8d41fc618ab804 Nicholas Piggin 2021-01-30  393   *
8d41fc618ab804 Nicholas Piggin 2021-01-30  394   * The macro is written so it acts as function definition. Append the
8d41fc618ab804 Nicholas Piggin 2021-01-30  395   * body with a pair of curly brackets.
8d41fc618ab804 Nicholas Piggin 2021-01-30  396   */
8d41fc618ab804 Nicholas Piggin 2021-01-30  397  #define DEFINE_INTERRUPT_HANDLER(func)					\
8d41fc618ab804 Nicholas Piggin 2021-01-30 @398  static __always_inline void ____##func(struct pt_regs *regs);		\
8d41fc618ab804 Nicholas Piggin 2021-01-30  399  									\
e4bb64c7a42e61 Nicholas Piggin 2021-02-11 @400  interrupt_handler void func(struct pt_regs *regs)			\
8d41fc618ab804 Nicholas Piggin 2021-01-30  401  {									\
25b7e6bb743ca5 Nicholas Piggin 2021-01-30  402  	struct interrupt_state state;					\
25b7e6bb743ca5 Nicholas Piggin 2021-01-30  403  									\
25b7e6bb743ca5 Nicholas Piggin 2021-01-30  404  	interrupt_enter_prepare(regs, &state);				\
25b7e6bb743ca5 Nicholas Piggin 2021-01-30  405  									\
8d41fc618ab804 Nicholas Piggin 2021-01-30  406  	____##func (regs);						\
25b7e6bb743ca5 Nicholas Piggin 2021-01-30  407  									\
25b7e6bb743ca5 Nicholas Piggin 2021-01-30  408  	interrupt_exit_prepare(regs, &state);				\
8d41fc618ab804 Nicholas Piggin 2021-01-30  409  }									\
e4bb64c7a42e61 Nicholas Piggin 2021-02-11  410  NOKPROBE_SYMBOL(func);							\
8d41fc618ab804 Nicholas Piggin 2021-01-30  411  									\
8d41fc618ab804 Nicholas Piggin 2021-01-30  412  static __always_inline void ____##func(struct pt_regs *regs)
8d41fc618ab804 Nicholas Piggin 2021-01-30  413  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 73369 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-19 13:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19  6:30 [PATCH 1/3] powerpc: Remove MSR_PR check in interrupt_exit_{user/kernel}_prepare() Christophe Leroy
2021-08-19  6:30 ` [PATCH 2/3] powerpc: Refactor verification of MSR_RI Christophe Leroy
2021-08-19 13:23   ` kernel test robot
2021-08-19  6:30 ` [PATCH 3/3] powerpc: Define and use MSR_RI only on non booke/40x Christophe Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).