1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27#include <sys/asm_linkage.h> 28#include <sys/hypervisor.h> 29#include <sys/privregs.h> 30#include <sys/segments.h> 31#include <sys/traptrace.h> 32#include <sys/trap.h> 33#include <sys/psw.h> 34#include <sys/x86_archext.h> 35#include <sys/asm_misc.h> 36#include <sys/panic.h> 37 38#include "assym.h" 39 40 ENTRY_NP(xpv_panic_getcr3) 41 movq %cr3, %rax 42 ret 43 SET_SIZE(xpv_panic_getcr3) 44 45 ENTRY_NP(xpv_panic_setcr3) 46 movq %rdi, %cr3 47 ret 48 SET_SIZE(xpv_panic_setcr3) 49 50 ENTRY(xpv_panic_reload_cr3) 51 movq %cr3, %rdi 52 movq %rdi, %cr3 53 ret 54 SET_SIZE(xpv_panic_reload_cr3) 55 56 ENTRY_NP(xpv_panic_prep) 57 pushq %rbp 58 movq %rsp, %rbp 59 60 subq $REGSIZE, %rsp 61 movq %rax, REGOFF_RAX(%rsp) 62 movq %rbx, REGOFF_RBX(%rsp) 63 movq %rsp, %rax 64 addq $REGSIZE, %rax 65 movq (%rax), %rbx 66 movq %rbx, REGOFF_RBP(%rsp) 67 movq 8(%rax), %rbx 68 movq %rbx, REGOFF_TRAPNO(%rsp) 69 movq 16(%rax), %rbx 70 movq %rbx, REGOFF_ERR(%rsp) 71 movq 24(%rax), %rbx 72 movq %rbx, REGOFF_RIP(%rsp) 73 movq 32(%rax), %rbx 74 movq %rbx, REGOFF_CS(%rsp) 75 movq 40(%rax), %rbx 76 movq %rbx, REGOFF_RFL(%rsp) 77 addq $56, %rax 78 movq %rax, REGOFF_RSP(%rsp) 79 xorl %eax, %eax 80 movw %gs, %ax 81 mov %rax, REGOFF_GS(%rsp) 82 movw %fs, %ax 83 mov %rax, REGOFF_FS(%rsp) 84 movw %es, %ax 85 mov %rax, REGOFF_ES(%rsp) 86 movw %ds, %ax 87 mov %rax, REGOFF_DS(%rsp) 88 movw %ss, %ax 89 mov %rax, REGOFF_SS(%rsp) 90 movq %rcx, REGOFF_RCX(%rsp) 91 movq %rdx, REGOFF_RDX(%rsp) 92 movq %rdi, REGOFF_RDI(%rsp) 93 movq %rsi, REGOFF_RSI(%rsp) 94 movq %r8, REGOFF_R8(%rsp) 95 movq %r9, REGOFF_R9(%rsp) 96 movq %r10, REGOFF_R10(%rsp) 97 movq %r11, REGOFF_R11(%rsp) 98 movq %r12, REGOFF_R12(%rsp) 99 movq %r13, REGOFF_R13(%rsp) 100 movq %r14, REGOFF_R14(%rsp) 101 movq %r15, REGOFF_R15(%rsp) 102 103 movq %rsp, %rdi 104 call xpv_die 105 SET_SIZE(xpv_panic_prep) 106 107 /* 108 * Switch to the Solaris panic stack and jump into the Xen panic 109 * handling code. 110 */ 111 ENTRY_NP(xpv_panic_hdlr) 112 leaq panic_stack(%rip), %rsp 113 addq $PANICSTKSIZE, %rsp 114 call xpv_do_panic 115 SET_SIZE(xpv_panic_hdlr) 116 117 ENTRY_NP(xpv_surprise_intr) 118 pushq %rbp 119 movq %rsp, %rbp 120 subq $REGOFF_TRAPNO, %rsp 121 __SAVE_REGS 122 movq %rsp, %rdi 123 addq $REGOFF_TRAPNO, %rdi 124 call xpv_interrupt 125 __RESTORE_REGS 126 addq $REGOFF_TRAPNO, %rsp 127 popq %rbp 128 iretq 129 SET_SIZE(xpv_surprise_intr) 130 131 ENTRY_NP(xpv_timer_trap) 132 pushq %rbp 133 movq %rsp, %rbp 134 subq $REGOFF_TRAPNO, %rsp 135 __SAVE_REGS 136 movq %rsp, %rdi 137 addq $REGOFF_TRAPNO, %rdi 138 call xpv_timer_tick 139 __RESTORE_REGS 140 addq $REGOFF_TRAPNO, %rsp 141 popq %rbp 142 iretq 143 SET_SIZE(xpv_timer_trap) 144 145 ENTRY_NP(xpv_panic_sti) 146 sti 147 ret 148 SET_SIZE(xpv_panic_sti) 149 150 ENTRY_NP(xpv_panic_halt) 151 sti 152 hlt 153 ret 154 SET_SIZE(xpv_panic_halt) 155 156 ENTRY_NP(xpv_panic_resetgs) 157 movl $KGS_SEL, %eax 158 movw %ax, %gs 159 ret 160 SET_SIZE(xpv_panic_resetgs) 161 162 ENTRY_NP(xpv_invaltrap) 163 push $0xbad0 164 push $0x0bad 165 jmp xpv_panic_prep 166 SET_SIZE(xpv_invaltrap) 167 168 ENTRY_NP(xpv_div0trap) 169 push $0 170 push $T_ZERODIV 171 jmp xpv_panic_prep 172 SET_SIZE(xpv_div0trap) 173 174 ENTRY_NP(xpv_dbgtrap) 175 push $0 176 push $T_SGLSTP 177 jmp xpv_panic_prep 178 SET_SIZE(xpv_dbgtrap) 179 180 ENTRY_NP(xpv_nmiint) 181 push $0 182 push $T_NMIFLT 183 jmp xpv_panic_prep 184 SET_SIZE(xpv_nmiint) 185 186 ENTRY_NP(xpv_brktrap) 187 /* XXX: check for error */ 188 push $T_BPTFLT 189 jmp xpv_panic_prep 190 SET_SIZE(xpv_brktrap) 191 192 ENTRY_NP(xpv_ovflotrap) 193 push $0 194 push $T_OVFLW 195 jmp xpv_panic_prep 196 SET_SIZE(xpv_ovflotrap) 197 198 ENTRY_NP(xpv_boundstrap) 199 push $0 200 push $T_BOUNDFLT 201 jmp xpv_panic_prep 202 SET_SIZE(xpv_boundstrap) 203 204 ENTRY_NP(xpv_invoptrap) 205 push $T_ILLINST 206 jmp xpv_panic_prep 207 SET_SIZE(xpv_invoptrap) 208 209 ENTRY_NP(xpv_ndptrap) 210 push $0 211 push $T_NOEXTFLT 212 jmp xpv_panic_prep 213 SET_SIZE(xpv_ndptrap) 214 215 ENTRY_NP(xpv_syserrtrap) 216 /* XXX: check for error */ 217 push $T_DBLFLT 218 jmp xpv_panic_prep 219 SET_SIZE(xpv_syserrtrap) 220 221 ENTRY_NP(xpv_invtsstrap) 222 push $T_TSSFLT 223 jmp xpv_panic_prep 224 SET_SIZE(xpv_invtsstrap) 225 226 ENTRY_NP(xpv_segnptrap) 227 push $T_SEGFLT 228 jmp xpv_panic_prep 229 SET_SIZE(xpv_segnptrap) 230 231 ENTRY_NP(xpv_stktrap) 232 push $T_STKFLT 233 jmp xpv_panic_prep 234 SET_SIZE(xpv_stktrap) 235 236 ENTRY_NP(xpv_gptrap) 237 push $T_GPFLT 238 jmp xpv_panic_prep 239 SET_SIZE(xpv_gptrap) 240 241 ENTRY_NP(xpv_pftrap) 242 push $T_PGFLT 243 jmp xpv_panic_prep 244 SET_SIZE(xpv_pftrap) 245 246 ENTRY_NP(xpv_ndperr) 247 push $0 248 push $T_EXTERRFLT 249 jmp xpv_panic_prep 250 SET_SIZE(xpv_ndperr) 251 252 ENTRY_NP(xpv_achktrap) 253 push $T_ALIGNMENT 254 jmp xpv_panic_prep 255 SET_SIZE(xpv_achktrap) 256 257 ENTRY_NP(xpv_mcetrap) 258 push $0 259 push $T_MCE 260 jmp xpv_panic_prep 261 SET_SIZE(xpv_mcetrap) 262 263 ENTRY_NP(xpv_xmtrap) 264 push $0 265 push $T_SIMDFPE 266 jmp xpv_panic_prep 267 SET_SIZE(xpv_xmtrap) 268