* [PATCH 2/6] powerpc/pseries: Add a warning in the case of cross-cpu VPA registration
2013-08-15 5:22 [PATCH 1/6] powerpc: Update the 00-Index in Documentation/powerpc Michael Ellerman
@ 2013-08-15 5:22 ` Michael Ellerman
2013-08-15 5:22 ` [PATCH 3/6] powerpc: Add more trap names to xmon Michael Ellerman
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2013-08-15 5:22 UTC (permalink / raw)
To: linuxppc-dev
The spec says it "may be problematic" if CPU x registers the VPA of
CPU y. Add a warning in case we ever do that.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/platforms/pseries/lpar.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 8bad880..73d6c1b 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -68,6 +68,12 @@ void vpa_init(int cpu)
struct paca_struct *pp;
struct dtl_entry *dtl;
+ /*
+ * The spec says it "may be problematic" if CPU x registers the VPA of
+ * CPU y. We should never do that, but wail if we ever do.
+ */
+ WARN_ON(cpu != smp_processor_id());
+
if (cpu_has_feature(CPU_FTR_ALTIVEC))
lppaca_of(cpu).vmxregs_in_use = 1;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/6] powerpc: Add more trap names to xmon
2013-08-15 5:22 [PATCH 1/6] powerpc: Update the 00-Index in Documentation/powerpc Michael Ellerman
2013-08-15 5:22 ` [PATCH 2/6] powerpc/pseries: Add a warning in the case of cross-cpu VPA registration Michael Ellerman
@ 2013-08-15 5:22 ` Michael Ellerman
2013-08-20 10:52 ` Paul Mackerras
2013-08-15 5:22 ` [PATCH 4/6] powerpc: Fix location and rename exception trampolines Michael Ellerman
` (2 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Michael Ellerman @ 2013-08-15 5:22 UTC (permalink / raw)
To: linuxppc-dev
We haven't updated these for a while it seems, it's nice to have in the
oops output.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/xmon/xmon.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 96bf5bd..9f3655b 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -1256,11 +1256,18 @@ const char *getvecname(unsigned long vec)
case 0x700: ret = "(Program Check)"; break;
case 0x800: ret = "(FPU Unavailable)"; break;
case 0x900: ret = "(Decrementer)"; break;
+ case 0x980: ret = "(Hypervisor Decrementer)"; break;
+ case 0xa00: ret = "(Doorbell)"; break;
case 0xc00: ret = "(System Call)"; break;
case 0xd00: ret = "(Single Step)"; break;
+ case 0xe40: ret = "(Emulation Assist)"; break;
+ case 0xe60: ret = "(HMI)"; break;
+ case 0xe80: ret = "(Hypervisor Doorbell)"; break;
case 0xf00: ret = "(Performance Monitor)"; break;
case 0xf20: ret = "(Altivec Unavailable)"; break;
case 0x1300: ret = "(Instruction Breakpoint)"; break;
+ case 0x1500: ret = "(Denormalisation)"; break;
+ case 0x1700: ret = "(Altivec Assist)"; break;
default: ret = "";
}
return ret;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/6] powerpc: Fix location and rename exception trampolines
2013-08-15 5:22 [PATCH 1/6] powerpc: Update the 00-Index in Documentation/powerpc Michael Ellerman
2013-08-15 5:22 ` [PATCH 2/6] powerpc/pseries: Add a warning in the case of cross-cpu VPA registration Michael Ellerman
2013-08-15 5:22 ` [PATCH 3/6] powerpc: Add more trap names to xmon Michael Ellerman
@ 2013-08-15 5:22 ` Michael Ellerman
2013-08-15 5:22 ` [PATCH 5/6] powerpc: Add more exception trampolines for hypervisor exceptions Michael Ellerman
2013-08-15 5:22 ` [PATCH 6/6] powerpc: Skip emulating & leave interrupts off for kernel program checks Michael Ellerman
4 siblings, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2013-08-15 5:22 UTC (permalink / raw)
To: linuxppc-dev
The symbols that name some of our exception trampolines are ahead of the
location they name. In most cases this is OK because the code is tightly
packed, but in some cases it means the symbol floats ahead of the
correct location, eg:
c000000000000ea0 <performance_monitor_pSeries_1>:
...
c000000000000f00: 7d b2 43 a6 mtsprg 2,r13
Fix them all by moving the symbol after the set of the location.
While we're moving them anyway, rename them to loose the camelcase and
to make it clear that they are trampolines.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/kernel/exceptions-64s.S | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 902ca3c..ae902cae 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -323,32 +323,32 @@ hv_exception_trampoline:
* prolog code of the PerformanceMonitor one. A little
* trickery is thus necessary
*/
-performance_monitor_pSeries_1:
. = 0xf00
+performance_monitor_pseries_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b performance_monitor_pSeries
-altivec_unavailable_pSeries_1:
. = 0xf20
+altivec_unavailable_pseries_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b altivec_unavailable_pSeries
-vsx_unavailable_pSeries_1:
. = 0xf40
+vsx_unavailable_pseries_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b vsx_unavailable_pSeries
-facility_unavailable_trampoline:
. = 0xf60
+facility_unavailable_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b facility_unavailable_pSeries
-hv_facility_unavailable_trampoline:
. = 0xf80
+hv_facility_unavailable_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b facility_unavailable_hv
@@ -820,32 +820,32 @@ system_call_relon_pSeries:
EXCEPTION_PROLOG_0(PACA_EXGEN)
b h_doorbell_relon_hv
-performance_monitor_relon_pSeries_1:
. = 0x4f00
+performance_monitor_relon_pseries_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b performance_monitor_relon_pSeries
-altivec_unavailable_relon_pSeries_1:
. = 0x4f20
+altivec_unavailable_relon_pseries_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b altivec_unavailable_relon_pSeries
-vsx_unavailable_relon_pSeries_1:
. = 0x4f40
+vsx_unavailable_relon_pseries_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b vsx_unavailable_relon_pSeries
-facility_unavailable_relon_trampoline:
. = 0x4f60
+facility_unavailable_relon_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b facility_unavailable_relon_pSeries
-hv_facility_unavailable_relon_trampoline:
. = 0x4f80
+hv_facility_unavailable_relon_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b hv_facility_unavailable_relon_hv
--
1.8.1.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/6] powerpc: Add more exception trampolines for hypervisor exceptions
2013-08-15 5:22 [PATCH 1/6] powerpc: Update the 00-Index in Documentation/powerpc Michael Ellerman
` (2 preceding siblings ...)
2013-08-15 5:22 ` [PATCH 4/6] powerpc: Fix location and rename exception trampolines Michael Ellerman
@ 2013-08-15 5:22 ` Michael Ellerman
2013-08-15 5:22 ` [PATCH 6/6] powerpc: Skip emulating & leave interrupts off for kernel program checks Michael Ellerman
4 siblings, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2013-08-15 5:22 UTC (permalink / raw)
To: linuxppc-dev
This makes back traces and profiles easier to read.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/kernel/exceptions-64s.S | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index ae902cae..e41f066 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -293,27 +293,31 @@ system_call_pSeries:
* out of line to handle them
*/
. = 0xe00
-hv_exception_trampoline:
+hv_data_storage_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b h_data_storage_hv
. = 0xe20
+hv_instr_storage_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b h_instr_storage_hv
. = 0xe40
+emulation_assist_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b emulation_assist_hv
. = 0xe60
+hv_exception_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b hmi_exception_hv
. = 0xe80
+hv_doorbell_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b h_doorbell_hv
@@ -808,6 +812,7 @@ system_call_relon_pSeries:
b . /* Can't happen, see v2.07 Book III-S section 6.5 */
. = 0x4e40
+emulation_assist_relon_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b emulation_assist_relon_hv
@@ -816,6 +821,7 @@ system_call_relon_pSeries:
b . /* Can't happen, see v2.07 Book III-S section 6.5 */
. = 0x4e80
+h_doorbell_relon_trampoline:
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXGEN)
b h_doorbell_relon_hv
--
1.8.1.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6/6] powerpc: Skip emulating & leave interrupts off for kernel program checks
2013-08-15 5:22 [PATCH 1/6] powerpc: Update the 00-Index in Documentation/powerpc Michael Ellerman
` (3 preceding siblings ...)
2013-08-15 5:22 ` [PATCH 5/6] powerpc: Add more exception trampolines for hypervisor exceptions Michael Ellerman
@ 2013-08-15 5:22 ` Michael Ellerman
4 siblings, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2013-08-15 5:22 UTC (permalink / raw)
To: linuxppc-dev
In the program check handler we handle some causes with interrupts off
and others with interrupts on.
We need to enable interrupts to handle the emulation cases, because they
access userspace memory and might sleep.
For faults in the kernel we don't want to do any emulation, and
emulate_instruction() enforces that. do_mathemu() doesn't but probably
should.
The other disadvantage of enabling interrupts for kernel faults is that
we may take another interrupt, and recurse. As seen below:
--- Exception: e40 at c000000000004ee0 performance_monitor_relon_pSeries_1
[link register ] c00000000000f858 .arch_local_irq_restore+0x38/0x90
[c000000fb185dc10] 0000000000000000 (unreliable)
[c000000fb185dc80] c0000000007d8558 .program_check_exception+0x298/0x2d0
[c000000fb185dd00] c000000000002f40 emulation_assist_common+0x140/0x180
--- Exception: e40 at c000000000004ee0 performance_monitor_relon_pSeries_1
[link register ] c00000000000f858 .arch_local_irq_restore+0x38/0x90
[c000000fb185dff0] 00000000008b9190 (unreliable)
[c000000fb185e060] c0000000007d8558 .program_check_exception+0x298/0x2d0
So avoid both problems by checking if the fault was in the kernel and
skipping the enable of interrupts and the emulation. Go straight to
delivering the SIGILL, which for kernel faults calls die() and so on,
dropping us in the debugger etc.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/kernel/traps.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index e435bc0..9515bde 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -1116,6 +1116,16 @@ void __kprobes program_check_exception(struct pt_regs *regs)
}
#endif
+ /*
+ * If we took the program check in the kernel skip down to sending a
+ * SIGILL. The subsequent cases all relate to emulating instructions
+ * which we should only do for userspace. We also do not want to enable
+ * interrupts for kernel faults because that might lead to further
+ * faults, and loose the context of the original exception.
+ */
+ if (!user_mode(regs))
+ goto sigill;
+
/* We restore the interrupt state now */
if (!arch_irq_disabled_regs(regs))
local_irq_enable();
@@ -1168,6 +1178,7 @@ void __kprobes program_check_exception(struct pt_regs *regs)
}
}
+sigill:
if (reason & REASON_PRIVILEGED)
_exception(SIGILL, regs, ILL_PRVOPC, regs->nip);
else
--
1.8.1.2
^ permalink raw reply related [flat|nested] 7+ messages in thread