diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2006-02-09 19:12:22 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-03-20 04:12:05 -0500 |
commit | aa9143b9719c07fb6f1f6207790c9c5086ae07e7 (patch) | |
tree | 74d56ecc53ed0542f200d6c6257c8f051095111c | |
parent | 12816ab38adddc9d7e9b3315d1739655dedc7c9f (diff) |
[SPARC64]: Implement sun4v TSB miss handlers.
When we register a TSB with the hypervisor, so that it or hardware can
handle TLB misses and do the TSB walk for us, the hypervisor traps
down to these trap when it incurs a TSB miss.
Processing is simple, we load the missing virtual address and context,
and do a full page table walk.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | arch/sparc64/kernel/sun4v_tlb_miss.S | 51 | ||||
-rw-r--r-- | arch/sparc64/kernel/tsb.S | 7 | ||||
-rw-r--r-- | arch/sparc64/kernel/ttable.S | 15 | ||||
-rw-r--r-- | include/asm-sparc64/ttable.h | 20 |
4 files changed, 84 insertions, 9 deletions
diff --git a/arch/sparc64/kernel/sun4v_tlb_miss.S b/arch/sparc64/kernel/sun4v_tlb_miss.S index 58ea5dd8573c..b8678b5557aa 100644 --- a/arch/sparc64/kernel/sun4v_tlb_miss.S +++ b/arch/sparc64/kernel/sun4v_tlb_miss.S | |||
@@ -187,6 +187,57 @@ sun4v_dtlb_prot: | |||
187 | ba,pt %xcc, sparc64_realfault_common | 187 | ba,pt %xcc, sparc64_realfault_common |
188 | mov FAULT_CODE_DTLB | FAULT_CODE_WRITE, %g4 | 188 | mov FAULT_CODE_DTLB | FAULT_CODE_WRITE, %g4 |
189 | 189 | ||
190 | /* Called from trap table with &trap_block[smp_processor_id()] in | ||
191 | * %g5 and SCRATCHPAD_UTSBREG1 contents in %g1. | ||
192 | */ | ||
193 | sun4v_itsb_miss: | ||
194 | ldx [%g5 + TRAP_PER_CPU_FAULT_INFO + HV_FAULT_I_ADDR_OFFSET], %g4 | ||
195 | ldx [%g5 + TRAP_PER_CPU_FAULT_INFO + HV_FAULT_I_CTX_OFFSET], %g5 | ||
196 | |||
197 | srlx %g4, 22, %g7 | ||
198 | sllx %g5, 48, %g6 | ||
199 | or %g6, %g7, %g6 | ||
200 | brz,pn %g5, kvmap_itlb_4v | ||
201 | nop | ||
202 | |||
203 | ba,pt %xcc, sun4v_tsb_miss_common | ||
204 | mov FAULT_CODE_ITLB, %g3 | ||
205 | |||
206 | /* Called from trap table with &trap_block[smp_processor_id()] in | ||
207 | * %g5 and SCRATCHPAD_UTSBREG1 contents in %g1. | ||
208 | */ | ||
209 | sun4v_dtsb_miss: | ||
210 | ldx [%g5 + TRAP_PER_CPU_FAULT_INFO + HV_FAULT_D_ADDR_OFFSET], %g4 | ||
211 | ldx [%g5 + TRAP_PER_CPU_FAULT_INFO + HV_FAULT_D_CTX_OFFSET], %g5 | ||
212 | |||
213 | srlx %g4, 22, %g7 | ||
214 | sllx %g5, 48, %g6 | ||
215 | or %g6, %g7, %g6 | ||
216 | brz,pn %g5, kvmap_dtlb_4v | ||
217 | nop | ||
218 | |||
219 | mov FAULT_CODE_DTLB, %g3 | ||
220 | |||
221 | /* Create TSB pointer into %g1. This is something like: | ||
222 | * | ||
223 | * index_mask = (512 << (tsb_reg & 0x7UL)) - 1UL; | ||
224 | * tsb_base = tsb_reg & ~0x7UL; | ||
225 | * tsb_index = ((vaddr >> PAGE_SHIFT) & tsb_mask); | ||
226 | * tsb_ptr = tsb_base + (tsb_index * 16); | ||
227 | */ | ||
228 | sun4v_tsb_miss_common: | ||
229 | and %g1, 0x7, %g2 | ||
230 | andn %g1, 0x7, %g1 | ||
231 | mov 512, %g7 | ||
232 | sllx %g7, %g2, %g7 | ||
233 | sub %g7, 1, %g7 | ||
234 | srlx %g4, PAGE_SHIFT, %g2 | ||
235 | and %g2, %g7, %g2 | ||
236 | sllx %g2, 4, %g2 | ||
237 | ba,pt %xcc, tsb_miss_page_table_walk | ||
238 | add %g1, %g2, %g1 | ||
239 | |||
240 | |||
190 | #define BRANCH_ALWAYS 0x10680000 | 241 | #define BRANCH_ALWAYS 0x10680000 |
191 | #define NOP 0x01000000 | 242 | #define NOP 0x01000000 |
192 | #define SUN4V_DO_PATCH(OLD, NEW) \ | 243 | #define SUN4V_DO_PATCH(OLD, NEW) \ |
diff --git a/arch/sparc64/kernel/tsb.S b/arch/sparc64/kernel/tsb.S index 819a6ef9799f..c848c8847cdc 100644 --- a/arch/sparc64/kernel/tsb.S +++ b/arch/sparc64/kernel/tsb.S | |||
@@ -35,8 +35,11 @@ tsb_miss_itlb: | |||
35 | nop | 35 | nop |
36 | 36 | ||
37 | /* The sun4v TLB miss handlers jump directly here instead | 37 | /* The sun4v TLB miss handlers jump directly here instead |
38 | * of tsb_miss_{d,i}tlb with the missing virtual address | 38 | * of tsb_miss_{d,i}tlb with registers setup as follows: |
39 | * already loaded into %g4. | 39 | * |
40 | * %g4: missing virtual address | ||
41 | * %g1: TSB entry address loaded | ||
42 | * %g6: TAG TARGET ((vaddr >> 22) | (ctx << 48)) | ||
40 | */ | 43 | */ |
41 | tsb_miss_page_table_walk: | 44 | tsb_miss_page_table_walk: |
42 | TRAP_LOAD_PGD_PHYS(%g7, %g5) | 45 | TRAP_LOAD_PGD_PHYS(%g7, %g5) |
diff --git a/arch/sparc64/kernel/ttable.S b/arch/sparc64/kernel/ttable.S index 1608ba4bf1c1..a9d210e11eb3 100644 --- a/arch/sparc64/kernel/ttable.S +++ b/arch/sparc64/kernel/ttable.S | |||
@@ -1,7 +1,6 @@ | |||
1 | /* $Id: ttable.S,v 1.38 2002/02/09 19:49:30 davem Exp $ | 1 | /* ttable.S: Sparc V9 Trap Table(s) with SpitFire/Cheetah/SUN4V extensions. |
2 | * ttable.S: Sparc V9 Trap Table(s) with SpitFire/Cheetah extensions. | ||
3 | * | 2 | * |
4 | * Copyright (C) 1996, 2001 David S. Miller (davem@caip.rutgers.edu) | 3 | * Copyright (C) 1996, 2001, 2006 David S. Miller (davem@davemloft.net) |
5 | */ | 4 | */ |
6 | 5 | ||
7 | #include <linux/config.h> | 6 | #include <linux/config.h> |
@@ -22,7 +21,8 @@ tl0_iax: membar #Sync | |||
22 | tl0_resv009: BTRAP(0x9) | 21 | tl0_resv009: BTRAP(0x9) |
23 | tl0_iae: membar #Sync | 22 | tl0_iae: membar #Sync |
24 | TRAP_NOSAVE_7INSNS(__spitfire_access_error) | 23 | TRAP_NOSAVE_7INSNS(__spitfire_access_error) |
25 | tl0_resv00b: BTRAP(0xb) BTRAP(0xc) BTRAP(0xd) BTRAP(0xe) BTRAP(0xf) | 24 | tl0_itsb_4v: SUN4V_ITSB_MISS |
25 | tl0_resv00c: BTRAP(0xc) BTRAP(0xd) BTRAP(0xe) BTRAP(0xf) | ||
26 | tl0_ill: membar #Sync | 26 | tl0_ill: membar #Sync |
27 | TRAP_7INSNS(do_illegal_instruction) | 27 | TRAP_7INSNS(do_illegal_instruction) |
28 | tl0_privop: TRAP(do_privop) | 28 | tl0_privop: TRAP(do_privop) |
@@ -38,7 +38,7 @@ tl0_div0: TRAP(do_div0) | |||
38 | tl0_resv029: BTRAP(0x29) BTRAP(0x2a) BTRAP(0x2b) BTRAP(0x2c) BTRAP(0x2d) BTRAP(0x2e) | 38 | tl0_resv029: BTRAP(0x29) BTRAP(0x2a) BTRAP(0x2b) BTRAP(0x2c) BTRAP(0x2d) BTRAP(0x2e) |
39 | tl0_resv02f: BTRAP(0x2f) | 39 | tl0_resv02f: BTRAP(0x2f) |
40 | tl0_dax: TRAP_NOSAVE(__spitfire_data_access_exception) | 40 | tl0_dax: TRAP_NOSAVE(__spitfire_data_access_exception) |
41 | tl0_resv031: BTRAP(0x31) | 41 | tl0_dtsb_4v: SUN4V_DTSB_MISS |
42 | tl0_dae: membar #Sync | 42 | tl0_dae: membar #Sync |
43 | TRAP_NOSAVE_7INSNS(__spitfire_access_error) | 43 | TRAP_NOSAVE_7INSNS(__spitfire_access_error) |
44 | tl0_resv033: BTRAP(0x33) | 44 | tl0_resv033: BTRAP(0x33) |
@@ -185,7 +185,8 @@ tl1_iax: TRAP_NOSAVE(__spitfire_insn_access_exception_tl1) | |||
185 | tl1_resv009: BTRAPTL1(0x9) | 185 | tl1_resv009: BTRAPTL1(0x9) |
186 | tl1_iae: membar #Sync | 186 | tl1_iae: membar #Sync |
187 | TRAP_NOSAVE_7INSNS(__spitfire_access_error) | 187 | TRAP_NOSAVE_7INSNS(__spitfire_access_error) |
188 | tl1_resv00b: BTRAPTL1(0xb) BTRAPTL1(0xc) BTRAPTL1(0xd) BTRAPTL1(0xe) BTRAPTL1(0xf) | 188 | tl1_itsb_4v: SUN4V_ITSB_MISS |
189 | tl1_resv00c: BTRAPTL1(0xc) BTRAPTL1(0xd) BTRAPTL1(0xe) BTRAPTL1(0xf) | ||
189 | tl1_ill: TRAPTL1(do_ill_tl1) | 190 | tl1_ill: TRAPTL1(do_ill_tl1) |
190 | tl1_privop: BTRAPTL1(0x11) | 191 | tl1_privop: BTRAPTL1(0x11) |
191 | tl1_resv012: BTRAPTL1(0x12) BTRAPTL1(0x13) BTRAPTL1(0x14) BTRAPTL1(0x15) | 192 | tl1_resv012: BTRAPTL1(0x12) BTRAPTL1(0x13) BTRAPTL1(0x14) BTRAPTL1(0x15) |
@@ -201,7 +202,7 @@ tl1_div0: TRAPTL1(do_div0_tl1) | |||
201 | tl1_resv029: BTRAPTL1(0x29) BTRAPTL1(0x2a) BTRAPTL1(0x2b) BTRAPTL1(0x2c) | 202 | tl1_resv029: BTRAPTL1(0x29) BTRAPTL1(0x2a) BTRAPTL1(0x2b) BTRAPTL1(0x2c) |
202 | tl1_resv02d: BTRAPTL1(0x2d) BTRAPTL1(0x2e) BTRAPTL1(0x2f) | 203 | tl1_resv02d: BTRAPTL1(0x2d) BTRAPTL1(0x2e) BTRAPTL1(0x2f) |
203 | tl1_dax: TRAP_NOSAVE(__spitfire_data_access_exception_tl1) | 204 | tl1_dax: TRAP_NOSAVE(__spitfire_data_access_exception_tl1) |
204 | tl1_resv031: BTRAPTL1(0x31) | 205 | tl1_dtsb_4v: SUN4V_DTSB_MISS |
205 | tl1_dae: membar #Sync | 206 | tl1_dae: membar #Sync |
206 | TRAP_NOSAVE_7INSNS(__spitfire_access_error) | 207 | TRAP_NOSAVE_7INSNS(__spitfire_access_error) |
207 | tl1_resv033: BTRAPTL1(0x33) | 208 | tl1_resv033: BTRAPTL1(0x33) |
diff --git a/include/asm-sparc64/ttable.h b/include/asm-sparc64/ttable.h index f912f52c0c7f..972f913709a3 100644 --- a/include/asm-sparc64/ttable.h +++ b/include/asm-sparc64/ttable.h | |||
@@ -180,6 +180,26 @@ | |||
180 | #define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl) | 180 | #define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl) |
181 | #endif | 181 | #endif |
182 | 182 | ||
183 | #define SUN4V_ITSB_MISS \ | ||
184 | mov SCRATCHPAD_CPUID, %g1; \ | ||
185 | ldxa [%g1] ASI_SCRATCHPAD, %g2; \ | ||
186 | ldxa [%g1 + %g1] ASI_SCRATCHPAD, %g1;\ | ||
187 | sethi %hi(trap_block), %g5; \ | ||
188 | sllx %g2, TRAP_BLOCK_SZ_SHIFT, %g2; \ | ||
189 | or %g5, %lo(trap_block), %g5; \ | ||
190 | ba,pt %xcc, sun4v_itsb_miss; \ | ||
191 | add %g5, %g2, %g5; | ||
192 | |||
193 | #define SUN4V_DTSB_MISS \ | ||
194 | mov SCRATCHPAD_CPUID, %g1; \ | ||
195 | ldxa [%g1] ASI_SCRATCHPAD, %g2; \ | ||
196 | ldxa [%g1 + %g1] ASI_SCRATCHPAD, %g1;\ | ||
197 | sethi %hi(trap_block), %g5; \ | ||
198 | sllx %g2, TRAP_BLOCK_SZ_SHIFT, %g2; \ | ||
199 | or %g5, %lo(trap_block), %g5; \ | ||
200 | ba,pt %xcc, sun4v_dtsb_miss; \ | ||
201 | add %g5, %g2, %g5; | ||
202 | |||
183 | /* Before touching these macros, you owe it to yourself to go and | 203 | /* Before touching these macros, you owe it to yourself to go and |
184 | * see how arch/sparc64/kernel/winfixup.S works... -DaveM | 204 | * see how arch/sparc64/kernel/winfixup.S works... -DaveM |
185 | * | 205 | * |