aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2014-03-10 18:29:38 -0400
committerScott Wood <scottwood@freescale.com>2014-03-19 20:57:14 -0400
commit9d378dfac885f72b8b369d08fc61bef36e2f2dd1 (patch)
tree8790aa68cd0944e031b35eb63f5be14ec678be2d /arch
parent82d86de25b9c99db546e17c6f7ebf9a691da557e (diff)
powerpc/booke64: Use SPRG7 for VDSO
Previously SPRG3 was marked for use by both VDSO and critical interrupts (though critical interrupts were not fully implemented). In commit 8b64a9dfb091f1eca8b7e58da82f1e7d1d5fe0ad ("powerpc/booke64: Use SPRG0/3 scratch for bolted TLB miss & crit int"), Mihai Caraman made an attempt to resolve this conflict by restoring the VDSO value early in the critical interrupt, but this has some issues: - It's incompatible with EXCEPTION_COMMON which restores r13 from the by-then-overwritten scratch (this cost me some debugging time). - It forces critical exceptions to be a special case handled differently from even machine check and debug level exceptions. - It didn't occur to me that it was possible to make this work at all (by doing a final "ld r13, PACA_EXCRIT+EX_R13(r13)") until after I made (most of) this patch. :-) It might be worth investigating using a load rather than SPRG on return from all exceptions (except TLB misses where the scratch never leaves the SPRG) -- it could save a few cycles. Until then, let's stick with SPRG for all exceptions. Since we cannot use SPRG4-7 for scratch without corrupting the state of a KVM guest, move VDSO to SPRG7 on book3e. Since neither SPRG4-7 nor critical interrupts exist on book3s, SPRG3 is still used for VDSO there. Signed-off-by: Scott Wood <scottwood@freescale.com> Cc: Mihai Caraman <mihai.caraman@freescale.com> Cc: Anton Blanchard <anton@samba.org> Cc: Paul Mackerras <paulus@samba.org> Cc: kvm-ppc@vger.kernel.org
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/include/asm/exception-64e.h5
-rw-r--r--arch/powerpc/include/asm/kvm_booke_hv_asm.h9
-rw-r--r--arch/powerpc/include/asm/paca.h2
-rw-r--r--arch/powerpc/include/asm/reg.h13
-rw-r--r--arch/powerpc/kernel/asm-offsets.c2
-rw-r--r--arch/powerpc/kernel/exceptions-64e.S19
-rw-r--r--arch/powerpc/kernel/vdso.c8
-rw-r--r--arch/powerpc/kernel/vdso32/getcpu.S2
-rw-r--r--arch/powerpc/kernel/vdso64/getcpu.S2
-rw-r--r--arch/powerpc/kvm/book3s_hv_rmhandlers.S4
-rw-r--r--arch/powerpc/kvm/book3s_interrupts.S4
-rw-r--r--arch/powerpc/kvm/bookehv_interrupts.S10
12 files changed, 33 insertions, 47 deletions
diff --git a/arch/powerpc/include/asm/exception-64e.h b/arch/powerpc/include/asm/exception-64e.h
index 51fa43e536b9..e73452f09019 100644
--- a/arch/powerpc/include/asm/exception-64e.h
+++ b/arch/powerpc/include/asm/exception-64e.h
@@ -46,9 +46,8 @@
46#define EX_CR (1 * 8) 46#define EX_CR (1 * 8)
47#define EX_R10 (2 * 8) 47#define EX_R10 (2 * 8)
48#define EX_R11 (3 * 8) 48#define EX_R11 (3 * 8)
49#define EX_R13 (4 * 8) 49#define EX_R14 (4 * 8)
50#define EX_R14 (5 * 8) 50#define EX_R15 (5 * 8)
51#define EX_R15 (6 * 8)
52 51
53/* 52/*
54 * The TLB miss exception uses different slots. 53 * The TLB miss exception uses different slots.
diff --git a/arch/powerpc/include/asm/kvm_booke_hv_asm.h b/arch/powerpc/include/asm/kvm_booke_hv_asm.h
index 3a79f5325712..c3e3fd53a3a9 100644
--- a/arch/powerpc/include/asm/kvm_booke_hv_asm.h
+++ b/arch/powerpc/include/asm/kvm_booke_hv_asm.h
@@ -36,20 +36,13 @@
36 * *(r8 + GPR11) = saved r11 36 * *(r8 + GPR11) = saved r11
37 * 37 *
38 * 64-bit host 38 * 64-bit host
39 * Expected inputs (GEN/GDBELL/DBG/MC exception types): 39 * Expected inputs (GEN/GDBELL/DBG/CRIT/MC exception types):
40 * r10 = saved CR 40 * r10 = saved CR
41 * r13 = PACA_POINTER 41 * r13 = PACA_POINTER
42 * *(r13 + PACA_EX##type + EX_R10) = saved r10 42 * *(r13 + PACA_EX##type + EX_R10) = saved r10
43 * *(r13 + PACA_EX##type + EX_R11) = saved r11 43 * *(r13 + PACA_EX##type + EX_R11) = saved r11
44 * SPRN_SPRG_##type##_SCRATCH = saved r13 44 * SPRN_SPRG_##type##_SCRATCH = saved r13
45 * 45 *
46 * Expected inputs (CRIT exception type):
47 * r10 = saved CR
48 * r13 = PACA_POINTER
49 * *(r13 + PACA_EX##type + EX_R10) = saved r10
50 * *(r13 + PACA_EX##type + EX_R11) = saved r11
51 * *(r13 + PACA_EX##type + EX_R13) = saved r13
52 *
53 * Expected inputs (TLB exception type): 46 * Expected inputs (TLB exception type):
54 * r10 = saved CR 47 * r10 = saved CR
55 * r13 = PACA_POINTER 48 * r13 = PACA_POINTER
diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
index 9c5dbc3833fb..948f01a04cc3 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -146,7 +146,7 @@ struct paca_struct {
146 u8 io_sync; /* writel() needs spin_unlock sync */ 146 u8 io_sync; /* writel() needs spin_unlock sync */
147 u8 irq_work_pending; /* IRQ_WORK interrupt while soft-disable */ 147 u8 irq_work_pending; /* IRQ_WORK interrupt while soft-disable */
148 u8 nap_state_lost; /* NV GPR values lost in power7_idle */ 148 u8 nap_state_lost; /* NV GPR values lost in power7_idle */
149 u64 sprg3; /* Saved user-visible sprg */ 149 u64 sprg_vdso; /* Saved user-visible sprg */
150#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 150#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
151 u64 tm_scratch; /* TM scratch area for reclaim */ 151 u64 tm_scratch; /* TM scratch area for reclaim */
152#endif 152#endif
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index bf0fb4db0855..f7251c2dc049 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -577,9 +577,13 @@
577#define SPRN_SPRG3 0x113 /* Special Purpose Register General 3 */ 577#define SPRN_SPRG3 0x113 /* Special Purpose Register General 3 */
578#define SPRN_USPRG3 0x103 /* SPRG3 userspace read */ 578#define SPRN_USPRG3 0x103 /* SPRG3 userspace read */
579#define SPRN_SPRG4 0x114 /* Special Purpose Register General 4 */ 579#define SPRN_SPRG4 0x114 /* Special Purpose Register General 4 */
580#define SPRN_USPRG4 0x104 /* SPRG4 userspace read */
580#define SPRN_SPRG5 0x115 /* Special Purpose Register General 5 */ 581#define SPRN_SPRG5 0x115 /* Special Purpose Register General 5 */
582#define SPRN_USPRG5 0x105 /* SPRG5 userspace read */
581#define SPRN_SPRG6 0x116 /* Special Purpose Register General 6 */ 583#define SPRN_SPRG6 0x116 /* Special Purpose Register General 6 */
584#define SPRN_USPRG6 0x106 /* SPRG6 userspace read */
582#define SPRN_SPRG7 0x117 /* Special Purpose Register General 7 */ 585#define SPRN_SPRG7 0x117 /* Special Purpose Register General 7 */
586#define SPRN_USPRG7 0x107 /* SPRG7 userspace read */
583#define SPRN_SRR0 0x01A /* Save/Restore Register 0 */ 587#define SPRN_SRR0 0x01A /* Save/Restore Register 0 */
584#define SPRN_SRR1 0x01B /* Save/Restore Register 1 */ 588#define SPRN_SRR1 0x01B /* Save/Restore Register 1 */
585#define SRR1_ISI_NOPT 0x40000000 /* ISI: Not found in hash */ 589#define SRR1_ISI_NOPT 0x40000000 /* ISI: Not found in hash */
@@ -879,11 +883,10 @@
879 * 64-bit embedded 883 * 64-bit embedded
880 * - SPRG0 generic exception scratch 884 * - SPRG0 generic exception scratch
881 * - SPRG2 TLB exception stack 885 * - SPRG2 TLB exception stack
882 * - SPRG3 critical exception scratch and 886 * - SPRG3 critical exception scratch (user visible, sorry!)
883 * CPU and NUMA node for VDSO getcpu (user visible)
884 * - SPRG4 unused (user visible) 887 * - SPRG4 unused (user visible)
885 * - SPRG6 TLB miss scratch (user visible, sorry !) 888 * - SPRG6 TLB miss scratch (user visible, sorry !)
886 * - SPRG7 critical exception scratch 889 * - SPRG7 CPU and NUMA node for VDSO getcpu (user visible)
887 * - SPRG8 machine check exception scratch 890 * - SPRG8 machine check exception scratch
888 * - SPRG9 debug exception scratch 891 * - SPRG9 debug exception scratch
889 * 892 *
@@ -940,6 +943,8 @@
940#define SPRN_SPRG_SCRATCH0 SPRN_SPRG2 943#define SPRN_SPRG_SCRATCH0 SPRN_SPRG2
941#define SPRN_SPRG_HPACA SPRN_HSPRG0 944#define SPRN_SPRG_HPACA SPRN_HSPRG0
942#define SPRN_SPRG_HSCRATCH0 SPRN_HSPRG1 945#define SPRN_SPRG_HSCRATCH0 SPRN_HSPRG1
946#define SPRN_SPRG_VDSO_READ SPRN_USPRG3
947#define SPRN_SPRG_VDSO_WRITE SPRN_SPRG3
943 948
944#define GET_PACA(rX) \ 949#define GET_PACA(rX) \
945 BEGIN_FTR_SECTION_NESTED(66); \ 950 BEGIN_FTR_SECTION_NESTED(66); \
@@ -983,6 +988,8 @@
983#define SPRN_SPRG_TLB_SCRATCH SPRN_SPRG6 988#define SPRN_SPRG_TLB_SCRATCH SPRN_SPRG6
984#define SPRN_SPRG_GEN_SCRATCH SPRN_SPRG0 989#define SPRN_SPRG_GEN_SCRATCH SPRN_SPRG0
985#define SPRN_SPRG_GDBELL_SCRATCH SPRN_SPRG_GEN_SCRATCH 990#define SPRN_SPRG_GDBELL_SCRATCH SPRN_SPRG_GEN_SCRATCH
991#define SPRN_SPRG_VDSO_READ SPRN_USPRG7
992#define SPRN_SPRG_VDSO_WRITE SPRN_SPRG7
986 993
987#define SET_PACA(rX) mtspr SPRN_SPRG_PACA,rX 994#define SET_PACA(rX) mtspr SPRN_SPRG_PACA,rX
988#define GET_PACA(rX) mfspr rX,SPRN_SPRG_PACA 995#define GET_PACA(rX) mfspr rX,SPRN_SPRG_PACA
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index b5aacf72ae6f..dba8140ebc20 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -253,7 +253,7 @@ int main(void)
253 DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time)); 253 DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time));
254 DEFINE(PACA_TRAP_SAVE, offsetof(struct paca_struct, trap_save)); 254 DEFINE(PACA_TRAP_SAVE, offsetof(struct paca_struct, trap_save));
255 DEFINE(PACA_NAPSTATELOST, offsetof(struct paca_struct, nap_state_lost)); 255 DEFINE(PACA_NAPSTATELOST, offsetof(struct paca_struct, nap_state_lost));
256 DEFINE(PACA_SPRG3, offsetof(struct paca_struct, sprg3)); 256 DEFINE(PACA_SPRG_VDSO, offsetof(struct paca_struct, sprg_vdso));
257#endif /* CONFIG_PPC64 */ 257#endif /* CONFIG_PPC64 */
258 258
259 /* RTAS */ 259 /* RTAS */
diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
index 41380a424108..89e1133b0185 100644
--- a/arch/powerpc/kernel/exceptions-64e.S
+++ b/arch/powerpc/kernel/exceptions-64e.S
@@ -55,7 +55,6 @@
55 mfspr r13,SPRN_SPRG_PACA; /* get PACA */ \ 55 mfspr r13,SPRN_SPRG_PACA; /* get PACA */ \
56 std r10,PACA_EX##type+EX_R10(r13); \ 56 std r10,PACA_EX##type+EX_R10(r13); \
57 std r11,PACA_EX##type+EX_R11(r13); \ 57 std r11,PACA_EX##type+EX_R11(r13); \
58 PROLOG_STORE_RESTORE_SCRATCH_##type; \
59 mfcr r10; /* save CR */ \ 58 mfcr r10; /* save CR */ \
60 mfspr r11,SPRN_##type##_SRR1;/* what are we coming from */ \ 59 mfspr r11,SPRN_##type##_SRR1;/* what are we coming from */ \
61 DO_KVM intnum,SPRN_##type##_SRR1; /* KVM hook */ \ 60 DO_KVM intnum,SPRN_##type##_SRR1; /* KVM hook */ \
@@ -116,20 +115,6 @@
116#define GDBELL_EXCEPTION_PROLOG(n, intnum, addition) \ 115#define GDBELL_EXCEPTION_PROLOG(n, intnum, addition) \
117 EXCEPTION_PROLOG(n, intnum, GDBELL, addition##_GDBELL(n)) 116 EXCEPTION_PROLOG(n, intnum, GDBELL, addition##_GDBELL(n))
118 117
119/*
120 * Store user-visible scratch in PACA exception slots and restore proper value
121 */
122#define PROLOG_STORE_RESTORE_SCRATCH_GEN
123#define PROLOG_STORE_RESTORE_SCRATCH_GDBELL
124#define PROLOG_STORE_RESTORE