aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64/kernel/hvtramp.S
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2007-07-13 19:03:42 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-07-16 07:04:40 -0400
commit4f0234f4f9da485ecb9729af1b88567700fd4767 (patch)
tree7073115c86dbf4e691ddac12f5c9ce1c58ce53be /arch/sparc64/kernel/hvtramp.S
parentb3e13fbeb9ac1eb8e7b0791bf56e1775c692972b (diff)
[SPARC64]: Initial LDOM cpu hotplug support.
Only adding cpus is supports at the moment, removal will come next. When new cpus are configured, the machine description is updated. When we get the configure request we pass in a cpu mask of to-be-added cpus to the mdesc CPU node parser so it only fetches information for those cpus. That code also proceeds to update the SMT/multi-core scheduling bitmaps. cpu_up() does all the work and we return the status back over the DS channel. CPUs via dr-cpu need to be booted straight out of the hypervisor, and this requires: 1) A new trampoline mechanism. CPUs are booted straight out of the hypervisor with MMU disabled and running in physical addresses with no mappings installed in the TLB. The new hvtramp.S code sets up the critical cpu state, installs the locked TLB mappings for the kernel, and turns the MMU on. It then proceeds to follow the logic of the existing trampoline.S SMP cpu bringup code. 2) All calls into OBP have to be disallowed when domaining is enabled. Since cpus boot straight into the kernel from the hypervisor, OBP has no state about that cpu and therefore cannot handle being invoked on that cpu. Luckily it's only a handful of interfaces which can be called after the OBP device tree is obtained. For example, rebooting, halting, powering-off, and setting options node variables. CPU removal support will require some infrastructure changes here. Namely we'll have to process the requests via a true kernel thread instead of in a workqueue. workqueues run on a per-cpu thread, but when unconfiguring we might need to force the thread to execute on another cpu if the current cpu is the one being removed. Removal of a cpu also causes the kernel to destroy that cpu's workqueue running thread. Another issue on removal is that we may have interrupts still pointing to the cpu-to-be-removed. So new code will be needed to walk the active INO list and retarget those cpus as-needed. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel/hvtramp.S')
-rw-r--r--arch/sparc64/kernel/hvtramp.S139
1 files changed, 139 insertions, 0 deletions
diff --git a/arch/sparc64/kernel/hvtramp.S b/arch/sparc64/kernel/hvtramp.S
new file mode 100644
index 00000000000..76a090e2c2a
--- /dev/null
+++ b/arch/sparc64/kernel/hvtramp.S
@@ -0,0 +1,139 @@
1/* hvtramp.S: Hypervisor start-cpu trampoline code.
2 *
3 * Copyright (C) 2007 David S. Miller <davem@davemloft.net>
4 */
5
6#include <asm/thread_info.h>
7#include <asm/hypervisor.h>
8#include <asm/scratchpad.h>
9#include <asm/spitfire.h>
10#include <asm/hvtramp.h>
11#include <asm/pstate.h>
12#include <asm/ptrace.h>
13#include <asm/asi.h>
14
15 .text
16 .align 8
17 .globl hv_cpu_startup, hv_cpu_startup_end
18
19 /* This code executes directly out of the hypervisor
20 * with physical addressing (va==pa). %o0 contains
21 * our client argument which for Linux points to
22 * a descriptor data structure which defines the
23 * MMU entries we need to load up.
24 *
25 * After we set things up we enable the MMU and call
26 * into the kernel.
27 *
28 * First setup basic privileged cpu state.
29 */
30hv_cpu_startup:
31 wrpr %g0, 0, %gl
32 wrpr %g0, 15, %pil
33 wrpr %g0, 0, %canrestore
34 wrpr %g0, 0, %otherwin
35 wrpr %g0, 6, %cansave
36 wrpr %g0, 6, %cleanwin
37 wrpr %g0, 0, %cwp
38 wrpr %g0, 0, %wstate
39 wrpr %g0, 0, %tl
40
41 sethi %hi(sparc64_ttable_tl0), %g1
42 wrpr %g1, %tba
43
44 mov %o0, %l0
45
46 lduw [%l0 + HVTRAMP_DESCR_CPU], %g1
47 mov SCRATCHPAD_CPUID, %g2
48 stxa %g1, [%g2] ASI_SCRATCHPAD
49
50 ldx [%l0 + HVTRAMP_DESCR_FAULT_INFO_VA], %g2
51 stxa %g2, [%g0] ASI_SCRATCHPAD
52
53 mov 0, %l1
54 lduw [%l0 + HVTRAMP_DESCR_NUM_MAPPINGS], %l2
55 add %l0, HVTRAMP_DESCR_MAPS, %l3
56
571: ldx [%l3 + HVTRAMP_MAPPING_VADDR], %o0
58 clr %o1
59 ldx [%l3 + HVTRAMP_MAPPING_TTE], %o2
60 mov HV_MMU_IMMU | HV_MMU_DMMU, %o3
61 mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
62 ta HV_FAST_TRAP
63
64 brnz,pn %o0, 80f
65 nop
66
67 add %l1, 1, %l1
68 cmp %l1, %l2
69 blt,a,pt %xcc, 1b
70 add %l3, HVTRAMP_MAPPING_SIZE, %l3
71
72 ldx [%l0 + HVTRAMP_DESCR_FAULT_INFO_PA], %o0
73 mov HV_FAST_MMU_FAULT_AREA_CONF, %o5
74 ta HV_FAST_TRAP
75
76 brnz,pn %o0, 80f
77 nop
78
79 wrpr %g0, (PSTATE_PRIV | PSTATE_PEF), %pstate
80
81 ldx [%l0 + HVTRAMP_DESCR_THREAD_REG], %l6
82
83 mov 1, %o0
84 set 1f, %o1
85 mov HV_FAST_MMU_ENABLE, %o5
86 ta HV_FAST_TRAP
87
88 ba,pt %xcc, 80f
89 nop
90
911:
92 wr %g0, 0, %fprs
93 wr %g0, ASI_P, %asi
94
95 mov PRIMARY_CONTEXT, %g7
96 stxa %g0, [%g7] ASI_MMU
97 membar #Sync
98
99 mov SECONDARY_CONTEXT, %g7
100 stxa %g0, [%g7] ASI_MMU
101 membar #Sync
102
103 mov %l6, %g6
104 ldx [%g6 + TI_TASK], %g4
105
106 mov 1, %g5
107 sllx %g5, THREAD_SHIFT, %g5
108 sub %g5, (STACKFRAME_SZ + STACK_BIAS), %g5
109 add %g6, %g5, %sp
110 mov 0, %fp
111
112 call init_irqwork_curcpu
113 nop
114 call hard_smp_processor_id
115 nop
116
117 mov %o0, %o1
118 mov 0, %o0
119 mov 0, %o2
120 call sun4v_init_mondo_queues
121 mov 1, %o3
122
123 call init_cur_cpu_trap
124 mov %g6, %o0
125
126 wrpr %g0, (PSTATE_PRIV | PSTATE_PEF | PSTATE_IE), %pstate
127
128 call smp_callin
129 nop
130 call cpu_idle
131 mov 0, %o0
132 call cpu_panic
133 nop
134
13580: ba,pt %xcc, 80b
136 nop
137
138 .align 8
139hv_cpu_startup_end: