aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMihai Caraman <mihai.caraman@freescale.com>2012-08-05 23:27:07 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2012-09-05 01:35:52 -0400
commit8b64a9dfb091f1eca8b7e58da82f1e7d1d5fe0ad (patch)
tree9d0bfd7ecd07c02fef68e7b198a0560340bf0846 /arch
parent79b5c8dbaa4528a6fd03a4d9d8a6d56a46293a3a (diff)
powerpc/booke64: Use SPRG0/3 scratch for bolted TLB miss & crit int
Embedded.Hypervisor category defines GSPRG0..3 physical registers for guests. Avoid SPRG4-7 usage as scratch in host exception handlers, otherwise guest SPRG4-7 registers will be clobbered. For bolted TLB miss exception handlers, which is the version currently supported by KVM, use SPRN_SPRG_GEN_SCRATCH aka SPRG0 instead of SPRN_SPRG_TLB_SCRATCH aka SPRG6. Keep using TLB PACA slots to fit in one 64-byte cache line. For critical exception handlers use SPRG3 instead of SPRG7. Provide a routine to store and restore user-visible SPRGs. This will be subsequently used to restore VDSO information in SPRG3. Add EX_R13 to paca slots to free up SPRG3 and change the critical exception epilog to use it. Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/include/asm/exception-64e.h5
-rw-r--r--arch/powerpc/include/asm/reg.h5
-rw-r--r--arch/powerpc/kernel/exceptions-64e.S17
-rw-r--r--arch/powerpc/mm/tlb_low_64e.S4
4 files changed, 23 insertions, 8 deletions
diff --git a/arch/powerpc/include/asm/exception-64e.h b/arch/powerpc/include/asm/exception-64e.h
index e73452f09019..51fa43e536b9 100644
--- a/arch/powerpc/include/asm/exception-64e.h
+++ b/arch/powerpc/include/asm/exception-64e.h
@@ -46,8 +46,9 @@
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_R14 (4 * 8) 49#define EX_R13 (4 * 8)
50#define EX_R15 (5 * 8) 50#define EX_R14 (5 * 8)
51#define EX_R15 (6 * 8)
51 52
52/* 53/*
53 * The TLB miss exception uses different slots. 54 * The TLB miss exception uses different slots.
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index c195bf0e6241..a391244c18e1 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -761,7 +761,8 @@
761 * 64-bit embedded 761 * 64-bit embedded
762 * - SPRG0 generic exception scratch 762 * - SPRG0 generic exception scratch
763 * - SPRG2 TLB exception stack 763 * - SPRG2 TLB exception stack
764 * - SPRG3 CPU and NUMA node for VDSO getcpu (user visible) 764 * - SPRG3 critical exception scratch and
765 * CPU and NUMA node for VDSO getcpu (user visible)
765 * - SPRG4 unused (user visible) 766 * - SPRG4 unused (user visible)
766 * - SPRG6 TLB miss scratch (user visible, sorry !) 767 * - SPRG6 TLB miss scratch (user visible, sorry !)
767 * - SPRG7 critical exception scratch 768 * - SPRG7 critical exception scratch
@@ -858,7 +859,7 @@
858 859
859#ifdef CONFIG_PPC_BOOK3E_64 860#ifdef CONFIG_PPC_BOOK3E_64
860#define SPRN_SPRG_MC_SCRATCH SPRN_SPRG8 861#define SPRN_SPRG_MC_SCRATCH SPRN_SPRG8
861#define SPRN_SPRG_CRIT_SCRATCH SPRN_SPRG7 862#define SPRN_SPRG_CRIT_SCRATCH SPRN_SPRG3
862#define SPRN_SPRG_DBG_SCRATCH SPRN_SPRG9 863#define SPRN_SPRG_DBG_SCRATCH SPRN_SPRG9
863#define SPRN_SPRG_TLB_EXFRAME SPRN_SPRG2 864#define SPRN_SPRG_TLB_EXFRAME SPRN_SPRG2
864#define SPRN_SPRG_TLB_SCRATCH SPRN_SPRG6 865#define SPRN_SPRG_TLB_SCRATCH SPRN_SPRG6
diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
index 83c20e84a4fb..7476b0ae09fb 100644
--- a/arch/powerpc/kernel/exceptions-64e.S
+++ b/arch/powerpc/kernel/exceptions-64e.S
@@ -42,6 +42,7 @@
42 mfspr r13,SPRN_SPRG_PACA; /* get PACA */ \ 42 mfspr r13,SPRN_SPRG_PACA; /* get PACA */ \
43 std r10,PACA_EX##type+EX_R10(r13); \ 43 std r10,PACA_EX##type+EX_R10(r13); \
44 std r11,PACA_EX##type+EX_R11(r13); \ 44 std r11,PACA_EX##type+EX_R11(r13); \
45 PROLOG_STORE_RESTORE_SCRATCH_##type; \
45 mfcr r10; /* save CR */ \ 46 mfcr r10; /* save CR */ \
46 mfspr r11,SPRN_##type##_SRR1;/* what are we coming from */ \ 47 mfspr r11,SPRN_##type##_SRR1;/* what are we coming from */ \
47 DO_KVM intnum,SPRN_##type##_SRR1; /* KVM hook */ \ 48 DO_KVM intnum,SPRN_##type##_SRR1; /* KVM hook */ \
@@ -99,6 +100,18 @@
99#define GDBELL_EXCEPTION_PROLOG(n, intnum, addition) \ 100#define GDBELL_EXCEPTION_PROLOG(n, intnum, addition) \
100 EXCEPTION_PROLOG(n, intnum, GDBELL, addition##_GDBELL(n)) 101 EXCEPTION_PROLOG(n, intnum, GDBELL, addition##_GDBELL(n))
101 102
103/*
104 * Store user-visible scratch in PACA exception slots and restore proper value
105 */
106#define PROLOG_STORE_RESTORE_SCRATCH_GEN
107#define PROLOG_STORE_RESTORE_SCRATCH_GDBELL
108#define PROLOG_STORE_RESTORE_SCRATCH_DBG
109#define PROLOG_STORE_RESTORE_SCRATCH_MC
110
111#define PROLOG_STORE_RESTORE_SCRATCH_CRIT \
112 mfspr r10,SPRN_SPRG_CRIT_SCRATCH; /* get r13 */ \
113 std r10,PACA_EXCRIT+EX_R13(r13)
114
102/* Variants of the "addition" argument for the prolog 115/* Variants of the "addition" argument for the prolog
103 */ 116 */
104#define PROLOG_ADDITION_NONE_GEN(n) 117#define PROLOG_ADDITION_NONE_GEN(n)
@@ -454,7 +467,7 @@ interrupt_end_book3e:
454 mtcr r10 467 mtcr r10
455 ld r10,PACA_EXCRIT+EX_R10(r13) /* restore registers */ 468 ld r10,PACA_EXCRIT+EX_R10(r13) /* restore registers */
456 ld r11,PACA_EXCRIT+EX_R11(r13) 469 ld r11,PACA_EXCRIT+EX_R11(r13)
457 mfspr r13,SPRN_SPRG_CRIT_SCRATCH 470 ld r13,PACA_EXCRIT+EX_R13(r13)
458 rfci 471 rfci
459 472
460 /* Normal debug exception */ 473 /* Normal debug exception */
@@ -467,7 +480,7 @@ interrupt_end_book3e:
467 /* Now we mash up things to make it look like we are coming on a 480 /* Now we mash up things to make it look like we are coming on a
468 * normal exception 481 * normal exception
469 */ 482 */
470 mfspr r15,SPRN_SPRG_CRIT_SCRATCH 483 ld r15,PACA_EXCRIT+EX_R13(r13)
471 mtspr SPRN_SPRG_GEN_SCRATCH,r15 484 mtspr SPRN_SPRG_GEN_SCRATCH,r15
472 mfspr r14,SPRN_DBSR 485 mfspr r14,SPRN_DBSR
473 EXCEPTION_COMMON(0xd00, PACA_EXCRIT, INTS_DISABLE) 486 EXCEPTION_COMMON(0xd00, PACA_EXCRIT, INTS_DISABLE)
diff --git a/arch/powerpc/mm/tlb_low_64e.S b/arch/powerpc/mm/tlb_low_64e.S
index d884fa44d34f..b4113bf86353 100644
--- a/arch/powerpc/mm/tlb_low_64e.S
+++ b/arch/powerpc/mm/tlb_low_64e.S
@@ -40,7 +40,7 @@
40 **********************************************************************/ 40 **********************************************************************/
41 41
42.macro tlb_prolog_bolted intnum addr 42.macro tlb_prolog_bolted intnum addr
43 mtspr SPRN_SPRG_TLB_SCRATCH,r13 43 mtspr SPRN_SPRG_GEN_SCRATCH,r13
44 mfspr r13,SPRN_SPRG_PACA 44 mfspr r13,SPRN_SPRG_PACA
45 std r10,PACA_EXTLB+EX_TLB_R10(r13) 45 std r10,PACA_EXTLB+EX_TLB_R10(r13)
46 mfcr r10 46 mfcr r10
@@ -69,7 +69,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV)
69 ld r15,PACA_EXTLB+EX_TLB_R15(r13) 69 ld r15,PACA_EXTLB+EX_TLB_R15(r13)
70 TLB_MISS_RESTORE_STATS_BOLTED 70 TLB_MISS_RESTORE_STATS_BOLTED
71 ld r16,PACA_EXTLB+EX_TLB_R16(r13) 71 ld r16,PACA_EXTLB+EX_TLB_R16(r13)
72 mfspr r13,SPRN_SPRG_TLB_SCRATCH 72 mfspr r13,SPRN_SPRG_GEN_SCRATCH
73.endm 73.endm
74 74
75/* Data TLB miss */ 75/* Data TLB miss */