All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/pseries/mce: Avoid instrumentation in realmode
@ 2022-08-29  7:45 Ganesh Goudar
  2022-08-29 11:32 ` Sachin Sant
  0 siblings, 1 reply; 3+ messages in thread
From: Ganesh Goudar @ 2022-08-29  7:45 UTC (permalink / raw)
  To: linuxppc-dev, mpe; +Cc: Ganesh Goudar, mahesh, sachinp

Part of machine check error handling is done in realmode,
As of now instrumentation is not possible for any code that
runs in realmode.
When MCE is injected on KASAN enabled kernel, crash is
observed, Hence force inline or mark no instrumentation
for functions which can run in realmode to avoid KASAN
instrumentation.

Signed-off-by: Ganesh Goudar <ganeshgr@linux.ibm.com>
---
 arch/powerpc/include/asm/interrupt.h | 2 +-
 arch/powerpc/include/asm/rtas.h      | 4 ++--
 arch/powerpc/kernel/rtas.c           | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/include/asm/interrupt.h b/arch/powerpc/include/asm/interrupt.h
index 8069dbc4b8d1..090895051712 100644
--- a/arch/powerpc/include/asm/interrupt.h
+++ b/arch/powerpc/include/asm/interrupt.h
@@ -92,7 +92,7 @@ static inline bool is_implicit_soft_masked(struct pt_regs *regs)
 	return search_kernel_soft_mask_table(regs->nip);
 }
 
-static inline void srr_regs_clobbered(void)
+static __always_inline void srr_regs_clobbered(void)
 {
 	local_paca->srr_valid = 0;
 	local_paca->hsrr_valid = 0;
diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index 00531af17ce0..52d29d664fdf 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -201,13 +201,13 @@ inline uint32_t rtas_ext_event_company_id(struct rtas_ext_event_log_v6 *ext_log)
 #define PSERIES_ELOG_SECT_ID_MCE		(('M' << 8) | 'C')
 
 static
-inline uint16_t pseries_errorlog_id(struct pseries_errorlog *sect)
+__always_inline uint16_t pseries_errorlog_id(struct pseries_errorlog *sect)
 {
 	return be16_to_cpu(sect->id);
 }
 
 static
-inline uint16_t pseries_errorlog_length(struct pseries_errorlog *sect)
+__always_inline uint16_t pseries_errorlog_length(struct pseries_errorlog *sect)
 {
 	return be16_to_cpu(sect->length);
 }
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 693133972294..f9d78245c0e8 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -48,7 +48,7 @@
 /* This is here deliberately so it's only used in this file */
 void enter_rtas(unsigned long);
 
-static inline void do_enter_rtas(unsigned long args)
+static __always_inline void do_enter_rtas(unsigned long args)
 {
 	unsigned long msr;
 
@@ -435,7 +435,7 @@ static char *__fetch_rtas_last_error(char *altbuf)
 #endif
 
 
-static void
+noinstr static void
 va_rtas_call_unlocked(struct rtas_args *args, int token, int nargs, int nret,
 		      va_list list)
 {
-- 
2.37.1


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

* Re: [PATCH] powerpc/pseries/mce: Avoid instrumentation in realmode
  2022-08-29  7:45 [PATCH] powerpc/pseries/mce: Avoid instrumentation in realmode Ganesh Goudar
@ 2022-08-29 11:32 ` Sachin Sant
  2022-08-29 12:44   ` Sachin Sant
  0 siblings, 1 reply; 3+ messages in thread
From: Sachin Sant @ 2022-08-29 11:32 UTC (permalink / raw)
  To: Ganesh Goudar; +Cc: linuxppc-dev, mahesh



> On 29-Aug-2022, at 1:15 PM, Ganesh Goudar <ganeshgr@linux.ibm.com> wrote:
> 
> Part of machine check error handling is done in realmode,
> As of now instrumentation is not possible for any code that
> runs in realmode.
> When MCE is injected on KASAN enabled kernel, crash is
> observed, Hence force inline or mark no instrumentation
> for functions which can run in realmode to avoid KASAN
> instrumentation.
> 
> Signed-off-by: Ganesh Goudar <ganeshgr@linux.ibm.com>
> ---
> arch/powerpc/include/asm/interrupt.h | 2 +-
> arch/powerpc/include/asm/rtas.h      | 4 ++--
> arch/powerpc/kernel/rtas.c           | 4 ++--
> 3 files changed, 5 insertions(+), 5 deletions(-)

Thanks for the patch. I tested it on top of 6.0.0-rc3. It proceeds further but
eventually crashes after arch_local_save_flags


# selftests: powerpc/mce: inject-ra-err
[  111.183705] BUG: Unable to handle kernel data access on read at 0xc00e00027fffe706
[  111.183735] Faulting instruction address: 0xc0000000006b724c
[  111.183744] Oops: Kernel access of bad area, sig: 11 [#1]
[  111.183750] LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries
[  111.183761] Modules linked in: rpadlpar_io(E) rpaphp(E) dm_mod(E) xsk_diag(E) nft_fib_inet(E) nft_fib_ipv4(E) nft_fib_ipv6(E) nft_fib(E) nft_reject_inet(E) nf_reject_ipv4(E) nf_reject_ipv6(E) nft_reject(E) nft_ct(E) nft_chain_nat(E) nf_nat(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) bonding(E) rfkill(E) ip_set(E) tls(E) nf_tables(E) nfnetlink(E) sunrpc(E) binfmt_misc(E) pseries_rng(E) drm(E) drm_panel_orientation_quirks(E) xfs(E) libcrc32c(E) sd_mod(E) t10_pi(E) sr_mod(E) crc64_rocksoft_generic(E) cdrom(E) crc64_rocksoft(E) crc64(E) sg(E) ibmvscsi(E) ibmveth(E) scsi_transport_srp(E) vmx_crypto(E) fuse(E)
[  111.183872] CPU: 16 PID: 6290 Comm: inject-ra-err Tainted: G            E      6.0.0-rc3-dirty #1
[  111.183883] NIP:  c0000000006b724c LR: c00000000004f674 CTR: 0000000000000000
[  111.183890] REGS: c0000000ff7f7880 TRAP: 0300   Tainted: G            E       (6.0.0-rc3-dirty)
[  111.183899] MSR:  8000000000001003 <SF,ME,RI,LE>  CR: 48002828  XER: 00000000
[  111.183916] CFAR: c00000000004f670 DAR: c00e00027fffe706 DSISR: 40000000 IRQMASK: 3 
[  111.183916] GPR00: c00000000004f674 c0000000ff7f7b20 c0000000034ad200 c0000013ffff3832 
[  111.183916] GPR04: 0000000000000031 0000000000000000 c00000000004f674 000000000000000c 
[  111.183916] GPR08: 0000000000000000 a80e000000000000 180000027fffe706 0000000000000000 
[  111.183916] GPR12: c0000013ffff2f00 c0000013ffff2f00 0000000000000000 0000000000000000 
[  111.183916] GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 
[  111.183916] GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000010000b30 
[  111.183916] GPR24: 00007fffbc8b0000 00007fffbc8af6d8 00007fffc0604158 000000001001fce8 
[  111.183916] GPR28: c00000116aae0868 0000000000000002 00000000ff7f7c20 c0000013ffff2f00 
[  111.184008] NIP [c0000000006b724c] __asan_load1+0x4c/0xa0
[  111.184023] LR [c00000000004f674] arch_local_save_flags+0x24/0x40
[  111.184033] Call Trace:
[  111.184037] [c0000000ff7f7b40] [c00000000004f674] arch_local_save_flags+0x24/0x40
[  111.184048] [c0000000ff7f7b70] [c0000000014d42ac] va_rtas_call_unlocked+0x13c/0x1d0
[  111.184062] [c0000000ff7f7ba0] [c000000000051c54] rtas_call_unlocked+0x34/0x50
[  111.184072] [c0000000ff7f7bc0] [c00000000012edc8] pseries_machine_check_realmode+0x188/0x2c0
[  111.184085] [c0000000ff7f7ca0] [c00000000004b128] machine_check_early+0x68/0xc0
[  111.184095] [c0000000ff7f7cf0] [c000000000008364] machine_check_early_common+0x134/0x1f8
[  111.184107] --- interrupt: 200 at 0x10000e48
[  111.184115] NIP:  0000000010000e48 LR: 0000000010000e40 CTR: 0000000000000000
[  111.184121] REGS: c0000000ff7f7d60 TRAP: 0200   Tainted: G            E       (6.0.0-rc3-dirty)
[  111.184129] MSR:  8000000002a0f033 <SF,VEC,VSX,EE,PR,FP,ME,IR,DR,RI,LE>  CR: 82002822  XER: 00000000
[  111.184152] CFAR: 000000000000021c DAR: 00007fffbc810000 DSISR: 02000008 IRQMASK: 0 
[  111.184152] GPR00: 0000000010000e40 00007fffc0603a70 0000000010027f00 00007fffbc810000 
[  111.184152] GPR04: 0000000000001000 0000000000000003 0000000000000001 0000000000000005 
[  111.184152] GPR08: 0000000000000000 fffffffffffff000 0000000000000000 0000000000000000 
[  111.184152] GPR12: 0000000000000000 00007fffbc8ba5e0 0000000000000000 0000000000000000 
[  111.184152] GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 
[  111.184152] GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000010000b30 
[  111.184152] GPR24: 00007fffbc8b0000 00007fffbc8af6d8 00007fffc0604158 000000001001fce8 
[  111.184152] GPR28: 00007fffc06042e0 0000000000000001 0000000000000005 0000000000000000 
[  111.184241] NIP [0000000010000e48] 0x10000e48
[  111.184247] LR [0000000010000e40] 0x10000e40
[  111.184252] --- interrupt: 200
[  111.184256] Instruction dump:
[  111.184261] 7cc802a6 4182005c 3d20bfff 6129ffff 792907c6 6529ffff 6129ffff 7c234840 
[  111.184278] 40810040 3d20a80e 786ae8c2 792907c6 <7d2a48ae> 7d290775 4082001c 38210020 
[  111.184297] ---[ end trace 0000000000000000 ]—

- Sachin


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

* Re: [PATCH] powerpc/pseries/mce: Avoid instrumentation in realmode
  2022-08-29 11:32 ` Sachin Sant
@ 2022-08-29 12:44   ` Sachin Sant
  0 siblings, 0 replies; 3+ messages in thread
From: Sachin Sant @ 2022-08-29 12:44 UTC (permalink / raw)
  To: Ganesh Goudar; +Cc: linuxppc-dev, mahesh



> On 29-Aug-2022, at 5:02 PM, Sachin Sant <sachinp@linux.ibm.com> wrote:
> 
> 
> 
>> On 29-Aug-2022, at 1:15 PM, Ganesh Goudar <ganeshgr@linux.ibm.com> wrote:
>> 
>> Part of machine check error handling is done in realmode,
>> As of now instrumentation is not possible for any code that
>> runs in realmode.
>> When MCE is injected on KASAN enabled kernel, crash is
>> observed, Hence force inline or mark no instrumentation
>> for functions which can run in realmode to avoid KASAN
>> instrumentation.
>> 
>> Signed-off-by: Ganesh Goudar <ganeshgr@linux.ibm.com>
>> ---
>> arch/powerpc/include/asm/interrupt.h | 2 +-
>> arch/powerpc/include/asm/rtas.h      | 4 ++--
>> arch/powerpc/kernel/rtas.c           | 4 ++--
>> 3 files changed, 5 insertions(+), 5 deletions(-)
> 
> Thanks for the patch. I tested it on top of 6.0.0-rc3. It proceeds further but
> eventually crashes after arch_local_save_flags
> 

Seems like following functions also should be marked as __always_inline

arch_local_save_flags
irq_soft_mask_return
irq_soft_mask_set_return
irq_soft_mask_set

With these additional changes the test successfully runs to completion.

- Sachin

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

end of thread, other threads:[~2022-08-29 12:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-29  7:45 [PATCH] powerpc/pseries/mce: Avoid instrumentation in realmode Ganesh Goudar
2022-08-29 11:32 ` Sachin Sant
2022-08-29 12:44   ` Sachin Sant

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.