* [PATCH 1/2] powerpc/book3s64/kexec: Clear CIABR on kexec
@ 2020-12-07 1:05 Jordan Niethe
2020-12-07 1:05 ` [PATCH 2/2] powerpc/powernv/idle: Restore CIABR after idle for Power9 Jordan Niethe
2020-12-10 11:30 ` [PATCH 1/2] powerpc/book3s64/kexec: Clear CIABR on kexec Michael Ellerman
0 siblings, 2 replies; 3+ messages in thread
From: Jordan Niethe @ 2020-12-07 1:05 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Jordan Niethe
The value in CIABR persists across kexec which can lead to unintended
results when the new kernel hits the old kernel's breakpoint. For
example:
0:mon> bi $loadavg_proc_show
0:mon> b
type address
1 inst c000000000519060 loadavg_proc_show+0x0/0x130
0:mon> x
$ kexec -l /mnt/vmlinux --initrd=/mnt/rootfs.cpio.gz --append='xmon=off'
$ kexec -e
$ cat /proc/loadavg
Trace/breakpoint trap
Make sure CIABR is cleared so this does not happen.
Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
---
arch/powerpc/include/asm/book3s/64/kexec.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/powerpc/include/asm/book3s/64/kexec.h b/arch/powerpc/include/asm/book3s/64/kexec.h
index 6b5c3a248ba2..d4b9d476ecba 100644
--- a/arch/powerpc/include/asm/book3s/64/kexec.h
+++ b/arch/powerpc/include/asm/book3s/64/kexec.h
@@ -3,6 +3,7 @@
#ifndef _ASM_POWERPC_BOOK3S_64_KEXEC_H_
#define _ASM_POWERPC_BOOK3S_64_KEXEC_H_
+#include <asm/plpar_wrappers.h>
#define reset_sprs reset_sprs
static inline void reset_sprs(void)
@@ -14,6 +15,10 @@ static inline void reset_sprs(void)
if (cpu_has_feature(CPU_FTR_ARCH_207S)) {
mtspr(SPRN_IAMR, 0);
+ if (cpu_has_feature(CPU_FTR_HVMODE))
+ mtspr(SPRN_CIABR, 0);
+ else
+ plpar_set_ciabr(0);
}
/* Do we need isync()? We are going via a kexec reset */
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] powerpc/powernv/idle: Restore CIABR after idle for Power9
2020-12-07 1:05 [PATCH 1/2] powerpc/book3s64/kexec: Clear CIABR on kexec Jordan Niethe
@ 2020-12-07 1:05 ` Jordan Niethe
2020-12-10 11:30 ` [PATCH 1/2] powerpc/book3s64/kexec: Clear CIABR on kexec Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Jordan Niethe @ 2020-12-07 1:05 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Jordan Niethe
On Power9, CIABR is lost after idle. This means that instruction
breakpoints set by xmon which use CIABR do not work. Fix this by
restoring CIABR after idle.
Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
---
arch/powerpc/platforms/powernv/idle.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c
index 1ed7c5286487..e6f461812856 100644
--- a/arch/powerpc/platforms/powernv/idle.c
+++ b/arch/powerpc/platforms/powernv/idle.c
@@ -589,6 +589,7 @@ struct p9_sprs {
u64 spurr;
u64 dscr;
u64 wort;
+ u64 ciabr;
u64 mmcra;
u32 mmcr0;
@@ -668,6 +669,7 @@ static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)
sprs.spurr = mfspr(SPRN_SPURR);
sprs.dscr = mfspr(SPRN_DSCR);
sprs.wort = mfspr(SPRN_WORT);
+ sprs.ciabr = mfspr(SPRN_CIABR);
sprs.mmcra = mfspr(SPRN_MMCRA);
sprs.mmcr0 = mfspr(SPRN_MMCR0);
@@ -785,6 +787,7 @@ static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)
mtspr(SPRN_SPURR, sprs.spurr);
mtspr(SPRN_DSCR, sprs.dscr);
mtspr(SPRN_WORT, sprs.wort);
+ mtspr(SPRN_CIABR, sprs.ciabr);
mtspr(SPRN_MMCRA, sprs.mmcra);
mtspr(SPRN_MMCR0, sprs.mmcr0);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] powerpc/book3s64/kexec: Clear CIABR on kexec
2020-12-07 1:05 [PATCH 1/2] powerpc/book3s64/kexec: Clear CIABR on kexec Jordan Niethe
2020-12-07 1:05 ` [PATCH 2/2] powerpc/powernv/idle: Restore CIABR after idle for Power9 Jordan Niethe
@ 2020-12-10 11:30 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2020-12-10 11:30 UTC (permalink / raw)
To: Jordan Niethe, linuxppc-dev
On Mon, 7 Dec 2020 12:05:18 +1100, Jordan Niethe wrote:
> The value in CIABR persists across kexec which can lead to unintended
> results when the new kernel hits the old kernel's breakpoint. For
> example:
>
> 0:mon> bi $loadavg_proc_show
> 0:mon> b
> type address
> 1 inst c000000000519060 loadavg_proc_show+0x0/0x130
> 0:mon> x
>
> [...]
Applied to powerpc/next.
[1/2] powerpc/book3s64/kexec: Clear CIABR on kexec
https://git.kernel.org/powerpc/c/4bb3219837a3dcf58bce96c27db6e0cd48f3d9b2
[2/2] powerpc/powernv/idle: Restore CIABR after idle for Power9
https://git.kernel.org/powerpc/c/250ad7a45b1e58d580decfb935fc063c4cf56f91
cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-10 13:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07 1:05 [PATCH 1/2] powerpc/book3s64/kexec: Clear CIABR on kexec Jordan Niethe
2020-12-07 1:05 ` [PATCH 2/2] powerpc/powernv/idle: Restore CIABR after idle for Power9 Jordan Niethe
2020-12-10 11:30 ` [PATCH 1/2] powerpc/book3s64/kexec: Clear CIABR on kexec Michael Ellerman
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.