1/* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11/* This file is dual-licensed; see usr/src/contrib/bhyve/LICENSE */ 12 13/* 14 * Copyright 2019 Joyent, Inc. 15 */ 16 17#include <sys/asm_linkage.h> 18#include <sys/segments.h> 19 20/* 21 * %rdi = trapno 22 * 23 * This variant is for any explicit exception injection that we need: in this 24 * case, we can't just, for example, do a direct "int $2", as that will then 25 * trash our %cr3 via tr_nmiint due to KPTI, so we have to fake a trap frame. 26 * Both NMIs and MCEs don't push an 'err' into the frame. 27 */ 28ENTRY_NP(vmm_call_trap) 29 pushq %rbp 30 movq %rsp, %rbp 31 movq %rsp, %r11 32 andq $~0xf, %rsp /* align stack */ 33 pushq $KDS_SEL /* %ss */ 34 pushq %r11 /* %rsp */ 35 pushfq /* %rflags */ 36 pushq $KCS_SEL /* %cs */ 37 leaq .trap_iret_dest(%rip), %rcx 38 pushq %rcx /* %rip */ 39 cli 40 cmpq $T_NMIFLT, %rdi 41 je nmiint 42 cmpq $T_MCE, %rdi 43 je mcetrap 44 45 pushq %rdi /* save our bad trapno... */ 46 leaq __vmm_call_bad_trap(%rip), %rdi 47 xorl %eax, %eax 48 call panic 49 /*NOTREACHED*/ 50 51.trap_iret_dest: 52 popq %rbp 53 ret 54SET_SIZE(vmm_call_trap) 55 56__vmm_call_bad_trap: 57 .string "bad trapno for vmm_call_trap()" 58