aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2011-04-04 23:59:58 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-04-19 21:03:23 -0400
commit673b189a2e3353061fa8c49515d1014dab6ad9b9 (patch)
tree71d5842f2dcfcd24370ef25f35c97f0f81ebae87 /arch/powerpc/include
parentb3e6b5dfcf0974069a8ddcce7dd071120d20d79c (diff)
powerpc: Always use SPRN_SPRG_HSCRATCH0 when running in HV mode
This uses feature sections to arrange that we always use HSPRG1 as the scratch register in the interrupt entry code rather than SPRG2 when we're running in hypervisor mode on POWER7. This will ensure that we don't trash the guest's SPRG2 when we are running KVM guests. To simplify the code, we define GET_SCRATCH0() and SET_SCRATCH0() macros like the GET_PACA/SET_PACA macros. Signed-off-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/include')
-rw-r--r--arch/powerpc/include/asm/exception-64s.h15
-rw-r--r--arch/powerpc/include/asm/reg.h14
2 files changed, 21 insertions, 8 deletions
diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h
index fb5b0af30fcf..d6b4849df9b1 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -60,16 +60,15 @@
60#define EXC_HV H 60#define EXC_HV H
61#define EXC_STD 61#define EXC_STD
62 62
63#define __EXCEPTION_PROLOG_1(area, h) \ 63#define EXCEPTION_PROLOG_1(area) \
64 GET_PACA(r13); \ 64 GET_PACA(r13); \
65 std r9,area+EX_R9(r13); /* save r9 - r12 */ \ 65 std r9,area+EX_R9(r13); /* save r9 - r12 */ \
66 std r10,area+EX_R10(r13); \ 66 std r10,area+EX_R10(r13); \
67 std r11,area+EX_R11(r13); \ 67 std r11,area+EX_R11(r13); \
68 std r12,area+EX_R12(r13); \ 68 std r12,area+EX_R12(r13); \
69 mfspr r9,SPRN_SPRG_##h##SCRATCH0; \ 69 GET_SCRATCH0(r9); \
70 std r9,area+EX_R13(r13); \ 70 std r9,area+EX_R13(r13); \
71 mfcr r9 71 mfcr r9
72#define EXCEPTION_PROLOG_1(area, h) __EXCEPTION_PROLOG_1(area, h)
73 72
74#define __EXCEPTION_PROLOG_PSERIES_1(label, h) \ 73#define __EXCEPTION_PROLOG_PSERIES_1(label, h) \
75 ld r12,PACAKBASE(r13); /* get high part of &label */ \ 74 ld r12,PACAKBASE(r13); /* get high part of &label */ \
@@ -85,7 +84,7 @@
85 __EXCEPTION_PROLOG_PSERIES_1(label, h) 84 __EXCEPTION_PROLOG_PSERIES_1(label, h)
86 85
87#define EXCEPTION_PROLOG_PSERIES(area, label, h) \ 86#define EXCEPTION_PROLOG_PSERIES(area, label, h) \
88 EXCEPTION_PROLOG_1(area, h); \ 87 EXCEPTION_PROLOG_1(area); \
89 EXCEPTION_PROLOG_PSERIES_1(label, h); 88 EXCEPTION_PROLOG_PSERIES_1(label, h);
90 89
91/* 90/*
@@ -156,7 +155,7 @@
156label##_pSeries: \ 155label##_pSeries: \
157 HMT_MEDIUM; \ 156 HMT_MEDIUM; \
158 DO_KVM vec; \ 157 DO_KVM vec; \
159 mtspr SPRN_SPRG_SCRATCH0,r13; /* save r13 */ \ 158 SET_SCRATCH0(r13); /* save r13 */ \
160 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common, EXC_STD) 159 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common, EXC_STD)
161 160
162#define STD_EXCEPTION_HV(loc, vec, label) \ 161#define STD_EXCEPTION_HV(loc, vec, label) \
@@ -165,13 +164,13 @@ label##_pSeries: \
165label##_hv: \ 164label##_hv: \
166 HMT_MEDIUM; \ 165 HMT_MEDIUM; \
167 DO_KVM vec; \ 166 DO_KVM vec; \
168 mtspr SPRN_SPRG_HSCRATCH0,r13;/* save r13 */ \ 167 SET_SCRATCH0(r13); /* save r13 */ \
169 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common, EXC_HV) 168 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common, EXC_HV)
170 169
171#define __MASKABLE_EXCEPTION_PSERIES(vec, label, h) \ 170#define __MASKABLE_EXCEPTION_PSERIES(vec, label, h) \
172 HMT_MEDIUM; \ 171 HMT_MEDIUM; \
173 DO_KVM vec; \ 172 DO_KVM vec; \
174 mtspr SPRN_SPRG_##h##SCRATCH0,r13; /* save r13 */ \ 173 SET_SCRATCH0(r13); /* save r13 */ \
175 GET_PACA(r13); \ 174 GET_PACA(r13); \
176 std r9,PACA_EXGEN+EX_R9(r13); /* save r9, r10 */ \ 175 std r9,PACA_EXGEN+EX_R9(r13); /* save r9, r10 */ \
177 std r10,PACA_EXGEN+EX_R10(r13); \ 176 std r10,PACA_EXGEN+EX_R10(r13); \
@@ -179,7 +178,7 @@ label##_hv: \
179 mfcr r9; \ 178 mfcr r9; \
180 cmpwi r10,0; \ 179 cmpwi r10,0; \
181 beq masked_##h##interrupt; \ 180 beq masked_##h##interrupt; \
182 mfspr r10,SPRN_SPRG_##h##SCRATCH0; \ 181 GET_SCRATCH0(r10); \
183 std r10,PACA_EXGEN+EX_R13(r13); \ 182 std r10,PACA_EXGEN+EX_R13(r13); \
184 std r11,PACA_EXGEN+EX_R11(r13); \ 183 std r11,PACA_EXGEN+EX_R11(r13); \
185 std r12,PACA_EXGEN+EX_R12(r13); \ 184 std r12,PACA_EXGEN+EX_R12(r13); \
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 13429a0eba09..76d7d5fea5be 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -802,6 +802,20 @@
802 FTR_SECTION_ELSE_NESTED(66); \ 802 FTR_SECTION_ELSE_NESTED(66); \
803 mtspr SPRN_SPRG_HPACA,rX; \ 803 mtspr SPRN_SPRG_HPACA,rX; \
804 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE_206, 66) 804 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE_206, 66)
805
806#define GET_SCRATCH0(rX) \
807 BEGIN_FTR_SECTION_NESTED(66); \
808 mfspr rX,SPRN_SPRG_SCRATCH0; \
809 FTR_SECTION_ELSE_NESTED(66); \
810 mfspr rX,SPRN_SPRG_HSCRATCH0; \
811 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE_206, 66)
812
813#define SET_SCRATCH0(rX) \
814 BEGIN_FTR_SECTION_NESTED(66); \
815 mtspr SPRN_SPRG_SCRATCH0,rX; \
816 FTR_SECTION_ELSE_NESTED(66); \
817 mtspr SPRN_SPRG_HSCRATCH0,rX; \
818 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE_206, 66)
805#endif 819#endif
806 820
807#ifdef CONFIG_PPC_BOOK3E_64 821#ifdef CONFIG_PPC_BOOK3E_64