Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * Hypervisor Software File: heartbeat.s | |
5 | * | |
6 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
7 | * | |
8 | * - Do no alter or remove copyright notices | |
9 | * | |
10 | * - Redistribution and use of this software in source and binary forms, with | |
11 | * or without modification, are permitted provided that the following | |
12 | * conditions are met: | |
13 | * | |
14 | * - Redistribution of source code must retain the above copyright notice, | |
15 | * this list of conditions and the following disclaimer. | |
16 | * | |
17 | * - Redistribution in binary form must reproduce the above copyright notice, | |
18 | * this list of conditions and the following disclaimer in the | |
19 | * documentation and/or other materials provided with the distribution. | |
20 | * | |
21 | * Neither the name of Sun Microsystems, Inc. or the names of contributors | |
22 | * may be used to endorse or promote products derived from this software | |
23 | * without specific prior written permission. | |
24 | * | |
25 | * This software is provided "AS IS," without a warranty of any kind. | |
26 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
27 | * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
28 | * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
29 | * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
30 | * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
31 | * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
32 | * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
33 | * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
34 | * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
35 | * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
36 | * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
37 | * | |
38 | * You acknowledge that this software is not designed, licensed or | |
39 | * intended for use in the design, construction, operation or maintenance of | |
40 | * any nuclear facility. | |
41 | * | |
42 | * ========== Copyright Header End ============================================ | |
43 | */ | |
44 | /* | |
45 | * Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
46 | * Use is subject to license terms. | |
47 | */ | |
48 | ||
49 | .ident "@(#)heartbeat.s 1.6 07/05/03 SMI" | |
50 | ||
51 | #include <sys/asm_linkage.h> | |
52 | #include <sys/htypes.h> | |
53 | #include <hprivregs.h> | |
54 | #include <asi.h> | |
55 | #include <fpga.h> | |
56 | #include <mmu.h> | |
57 | #include <sun4v/traps.h> | |
58 | #include <sun4v/mmu.h> | |
59 | #include <sun4v/asi.h> | |
60 | #include <config.h> | |
61 | #include <guest.h> | |
62 | #include <strand.h> | |
63 | #include <offsets.h> | |
64 | #include <util.h> | |
65 | #include <abort.h> | |
66 | #include <debug.h> | |
67 | ||
68 | ||
69 | /* | |
70 | * heartbeat - recurring hypervisor heartbeat | |
71 | * | |
72 | * %g7: return address | |
73 | */ | |
74 | ENTRY(heartbeat) | |
75 | CPU_PUSH(%g7, %g2, %g3, %g4) | |
76 | ||
77 | CONFIG_STRUCT(%g2) | |
78 | ldx [%g2 + CONFIG_HEARTBEAT_CPU], %g3 | |
79 | cmp %g3, -1 | |
80 | be,pn %xcc, .heartbeat_exit | |
81 | nop | |
82 | ||
83 | /* | |
84 | * Worker routines | |
85 | */ | |
86 | HVCALL(heartbeat_watchdog) | |
87 | ||
88 | /* | |
89 | * Schedule the next timeout | |
90 | */ | |
91 | HVCALL(heartbeat_enable) | |
92 | ||
93 | .heartbeat_exit: | |
94 | CPU_POP(%g7, %g2, %g3, %g4) | |
95 | HVRET | |
96 | SET_SIZE(heartbeat) | |
97 | ||
98 | ||
99 | /* | |
100 | * heartbeat_watchdog - check for guest watchdog timer expirations | |
101 | */ | |
102 | ENTRY_NP(heartbeat_watchdog) | |
103 | /* | |
104 | * FIXME: Only update the watchdog timer for the control | |
105 | * domain. Eventually, this will need to be made aware | |
106 | * of multiple guests. | |
107 | */ | |
108 | CTRL_DOMAIN(%g1, %g2, %g3) | |
109 | brz,pn %g1, 1f | |
110 | nop | |
111 | !! %g1 = control domain guestp | |
112 | ||
113 | set GUEST_WATCHDOG + WATCHDOG_TICKS, %g2 | |
114 | add %g1, %g2, %g2 | |
115 | ||
116 | ldx [%g2], %g3 | |
117 | brz,pt %g3, 1f ! zero value is disabled | |
118 | nop | |
119 | ||
120 | /* Decrement counter, new value of zero is watchdog expiry */ | |
121 | ATOMIC_ADD_64(%g2, -1, %g3, %g4) | |
122 | !! %g3 new value | |
123 | brnz,pt %g3, 1f | |
124 | nop | |
125 | ||
126 | /* | |
127 | * Timeout expired | |
128 | */ | |
129 | #ifdef DEBUG | |
130 | mov %g7, %g5 ! %g7 holds the %pc for HVRET | |
131 | mov %g1, %g6 | |
132 | PRINT_NOTRAP("guest watchdog timer expiry\r\n") | |
133 | mov %g6, %g1 | |
134 | mov %g5, %g7 ! restore %g7 for HVRET | |
135 | #endif | |
136 | #if defined(CONFIG_VBSC_SVC) | |
137 | !! %g1 - target guestp | |
138 | ba,pt %xcc, vbsc_guest_wdexpire ! tail call returns to caller | |
139 | nop | |
140 | #endif | |
141 | /* only get here when no CONFIG_VBSC_SVC or no expiration */ | |
142 | ||
143 | 1: HVRET | |
144 | SET_SIZE(heartbeat_watchdog) | |
145 | ||
146 | ||
147 | /* | |
148 | * heartbeat_enable - schedule the next heartbeat | |
149 | */ | |
150 | ENTRY_NP(heartbeat_enable) | |
151 | STRAND_STRUCT(%g6) | |
152 | STRAND2CONFIG_STRUCT(%g6, %g5) | |
153 | ||
154 | ldub [%g6 + STRAND_ID], %g3 | |
155 | stx %g3, [%g5 + CONFIG_HEARTBEAT_CPU] | |
156 | ||
157 | ldx [%g5 + CONFIG_STICKFREQUENCY], %g1 ! interval: 1sec | |
158 | ldx [%g5 + CONFIG_RELOC], %g4 | |
159 | setx heartbeat, %g5, %g2 | |
160 | sub %g2, %g4, %g2 ! handler: guest_watchdog_handler | |
161 | ba,a cyclic_add_rel ! (void), tail call | |
162 | SET_SIZE(heartbeat_enable) | |
163 | ||
164 | ||
165 | /* | |
166 | * heartbeat_disable - cancel pending heartbeats | |
167 | */ | |
168 | ENTRY_NP(heartbeat_disable) | |
169 | STRAND_STRUCT(%g1) | |
170 | STRAND2CONFIG_STRUCT(%g1, %g2) | |
171 | ||
172 | /* | |
173 | * We can only disable the heartbeat on the cpu it's running on. | |
174 | */ | |
175 | ldub [%g1 + STRAND_ID], %g3 | |
176 | ldx [%g2 + CONFIG_HEARTBEAT_CPU], %g4 | |
177 | cmp %g3, %g4 | |
178 | be,pt %xcc, 1f | |
179 | nop | |
180 | HVRET | |
181 | 1: | |
182 | ||
183 | /* | |
184 | * Mark that there is no heartbeat cpu | |
185 | */ | |
186 | mov -1, %g3 | |
187 | stx %g3, [%g2 + CONFIG_HEARTBEAT_CPU] | |
188 | ||
189 | /* | |
190 | * Cancel future heartbeats | |
191 | */ | |
192 | ldx [%g2 + CONFIG_RELOC], %g1 | |
193 | setx heartbeat, %g3, %g2 | |
194 | sub %g2, %g1, %g2 ! handler: guest_watchdog_handler | |
195 | ba,a cyclic_remove ! tail-call | |
196 | SET_SIZE(heartbeat_disable) |