1b2b3ffcdSSimon Schubert /*- 2b2b3ffcdSSimon Schubert * Copyright (c) 2003 Peter Wemm. 3b2b3ffcdSSimon Schubert * Copyright (c) 1990 The Regents of the University of California. 485b33048SMatthew Dillon * Copyright (c) 2008-2018 The DragonFly Project. 5b2b3ffcdSSimon Schubert * All rights reserved. 6b2b3ffcdSSimon Schubert * 7b2b3ffcdSSimon Schubert * This code is derived from software contributed to Berkeley by 8b2b3ffcdSSimon Schubert * William Jolitz. 9b2b3ffcdSSimon Schubert * 10b2b3ffcdSSimon Schubert * Redistribution and use in source and binary forms, with or without 11b2b3ffcdSSimon Schubert * modification, are permitted provided that the following conditions 12b2b3ffcdSSimon Schubert * are met: 13b2b3ffcdSSimon Schubert * 1. Redistributions of source code must retain the above copyright 14b2b3ffcdSSimon Schubert * notice, this list of conditions and the following disclaimer. 15b2b3ffcdSSimon Schubert * 2. Redistributions in binary form must reproduce the above copyright 16b2b3ffcdSSimon Schubert * notice, this list of conditions and the following disclaimer in the 17b2b3ffcdSSimon Schubert * documentation and/or other materials provided with the distribution. 182c64e990Szrj * 3. Neither the name of the University nor the names of its contributors 19b2b3ffcdSSimon Schubert * may be used to endorse or promote products derived from this software 20b2b3ffcdSSimon Schubert * without specific prior written permission. 21b2b3ffcdSSimon Schubert * 22b2b3ffcdSSimon Schubert * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23b2b3ffcdSSimon Schubert * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24b2b3ffcdSSimon Schubert * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25b2b3ffcdSSimon Schubert * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26b2b3ffcdSSimon Schubert * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27b2b3ffcdSSimon Schubert * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28b2b3ffcdSSimon Schubert * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29b2b3ffcdSSimon Schubert * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30b2b3ffcdSSimon Schubert * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31b2b3ffcdSSimon Schubert * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32b2b3ffcdSSimon Schubert * SUCH DAMAGE. 33b2b3ffcdSSimon Schubert * 34b2b3ffcdSSimon Schubert * from: @(#)frame.h 5.2 (Berkeley) 1/18/91 35b2b3ffcdSSimon Schubert * $FreeBSD: src/sys/amd64/include/frame.h,v 1.26 2003/11/08 04:39:22 peter Exp $ 36b2b3ffcdSSimon Schubert */ 37b2b3ffcdSSimon Schubert 38b2b3ffcdSSimon Schubert #ifndef _CPU_FRAME_H_ 39b2b3ffcdSSimon Schubert #define _CPU_FRAME_H_ 40b2b3ffcdSSimon Schubert 41b2b3ffcdSSimon Schubert /* JG? */ 42b2b3ffcdSSimon Schubert #include <sys/types.h> 43b2b3ffcdSSimon Schubert 44b2b3ffcdSSimon Schubert /* 45b2b3ffcdSSimon Schubert * System stack frames. 46b2b3ffcdSSimon Schubert */ 47b2b3ffcdSSimon Schubert 48b2b3ffcdSSimon Schubert /* 49b2b3ffcdSSimon Schubert * Exception/Trap Stack Frame 50b2b3ffcdSSimon Schubert * 51b2b3ffcdSSimon Schubert * The ordering of this is specifically so that we can take first 6 52b2b3ffcdSSimon Schubert * the syscall arguments directly from the beginning of the frame. 53b2b3ffcdSSimon Schubert */ 54b2b3ffcdSSimon Schubert 55b2b3ffcdSSimon Schubert struct trapframe { 56b2b3ffcdSSimon Schubert /* note: tf_rdi matches mc_rdi in mcontext */ 57b2b3ffcdSSimon Schubert register_t tf_rdi; 58b2b3ffcdSSimon Schubert register_t tf_rsi; 59b2b3ffcdSSimon Schubert register_t tf_rdx; 60b2b3ffcdSSimon Schubert register_t tf_rcx; 61b2b3ffcdSSimon Schubert register_t tf_r8; 62b2b3ffcdSSimon Schubert register_t tf_r9; 63b2b3ffcdSSimon Schubert register_t tf_rax; 64b2b3ffcdSSimon Schubert register_t tf_rbx; 65b2b3ffcdSSimon Schubert register_t tf_rbp; 66b2b3ffcdSSimon Schubert register_t tf_r10; 67b2b3ffcdSSimon Schubert register_t tf_r11; 68b2b3ffcdSSimon Schubert register_t tf_r12; 69b2b3ffcdSSimon Schubert register_t tf_r13; 70b2b3ffcdSSimon Schubert register_t tf_r14; 71b2b3ffcdSSimon Schubert register_t tf_r15; 72b2b3ffcdSSimon Schubert register_t tf_xflags; 73b2b3ffcdSSimon Schubert register_t tf_trapno; 74b2b3ffcdSSimon Schubert register_t tf_addr; 75b2b3ffcdSSimon Schubert register_t tf_flags; 76b2b3ffcdSSimon Schubert /* below portion defined in hardware */ 77b2b3ffcdSSimon Schubert register_t tf_err; 78b2b3ffcdSSimon Schubert register_t tf_rip; 79b2b3ffcdSSimon Schubert register_t tf_cs; 80b2b3ffcdSSimon Schubert register_t tf_rflags; 81a86ce0cdSMatthew Dillon #define tf_sp tf_rsp 82b2b3ffcdSSimon Schubert register_t tf_rsp; 83b2b3ffcdSSimon Schubert register_t tf_ss; 84*c1a0c940SMatthew Dillon } __packed; 85b2b3ffcdSSimon Schubert 86b2b3ffcdSSimon Schubert /* Interrupt stack frame */ 87b2b3ffcdSSimon Schubert 88b2b3ffcdSSimon Schubert struct intrframe { 89b2b3ffcdSSimon Schubert register_t if_vec; /* vec */ 90b2b3ffcdSSimon Schubert /* fs XXX */ 91b2b3ffcdSSimon Schubert /* es XXX */ 92b2b3ffcdSSimon Schubert /* ds XXX */ 93b2b3ffcdSSimon Schubert register_t if_rdi; 94b2b3ffcdSSimon Schubert register_t if_rsi; 95b2b3ffcdSSimon Schubert register_t if_rdx; 96b2b3ffcdSSimon Schubert register_t if_rcx; 97b2b3ffcdSSimon Schubert register_t if_r8; 98b2b3ffcdSSimon Schubert register_t if_r9; 99b2b3ffcdSSimon Schubert register_t if_rax; 100b2b3ffcdSSimon Schubert register_t if_rbx; 101b2b3ffcdSSimon Schubert register_t if_rbp; 102b2b3ffcdSSimon Schubert register_t if_r10; 103b2b3ffcdSSimon Schubert register_t if_r11; 104b2b3ffcdSSimon Schubert register_t if_r12; 105b2b3ffcdSSimon Schubert register_t if_r13; 106b2b3ffcdSSimon Schubert register_t if_r14; 107b2b3ffcdSSimon Schubert register_t if_r15; 108a293ac08SJordan Gordeev register_t if_xflags; /* compat with trap frame - xflags */ 109b2b3ffcdSSimon Schubert register_t :64; /* compat with trap frame - trapno */ 110b2b3ffcdSSimon Schubert register_t :64; /* compat with trap frame - addr */ 111b2b3ffcdSSimon Schubert register_t :64; /* compat with trap frame - flags */ 112b2b3ffcdSSimon Schubert register_t :64; /* compat with trap frame - err */ 113b2b3ffcdSSimon Schubert /* below portion defined in hardware */ 114b2b3ffcdSSimon Schubert register_t if_rip; 115b2b3ffcdSSimon Schubert register_t if_cs; 116b2b3ffcdSSimon Schubert register_t if_rflags; 117b2b3ffcdSSimon Schubert register_t if_rsp; 118b2b3ffcdSSimon Schubert register_t if_ss; 119*c1a0c940SMatthew Dillon } __packed; 120b2b3ffcdSSimon Schubert 121fc921477SMatthew Dillon /* 122fc921477SMatthew Dillon * The trampframe is placed at the top of the trampoline page and 123fc921477SMatthew Dillon * contains all the information needed to trampoline into and out 124fc921477SMatthew Dillon * of the isolated user pmap. 125fc921477SMatthew Dillon */ 1264611d87fSMatthew Dillon struct trampframe { 1274611d87fSMatthew Dillon register_t tr_cr2; 1288ed06571SMatthew Dillon register_t tr_rax; 1298ed06571SMatthew Dillon register_t tr_rcx; 1308ed06571SMatthew Dillon register_t tr_rdx; 1314611d87fSMatthew Dillon register_t tr_err; 1324611d87fSMatthew Dillon register_t tr_rip; 1334611d87fSMatthew Dillon register_t tr_cs; 1344611d87fSMatthew Dillon register_t tr_rflags; 1354611d87fSMatthew Dillon register_t tr_rsp; 1364611d87fSMatthew Dillon register_t tr_ss; 137fc921477SMatthew Dillon 138fc921477SMatthew Dillon /* 139fc921477SMatthew Dillon * Top of hw stack in TSS is &tr_pcb_rsp (first push is tr_ss). 140fc921477SMatthew Dillon * Make sure this is at least 16-byte aligned, so be sure the 141fc921477SMatthew Dillon * fields below are in multiples of 16 bytes. 142fc921477SMatthew Dillon */ 143fc921477SMatthew Dillon register_t tr_pcb_rsp; /* hw frame tramp top of stack */ 144fc921477SMatthew Dillon register_t tr_pcb_flags; /* copy of pcb control flags */ 145fc921477SMatthew Dillon register_t tr_pcb_cr3_iso; /* copy of isolated pml4e */ 146fc921477SMatthew Dillon register_t tr_pcb_cr3; /* copy of primary pml4e */ 147375bb03eSMatthew Dillon uint32_t tr_pcb_spec_ctrl[2];/* SPEC_CTRL + ficticious flags */ 14885b33048SMatthew Dillon register_t tr_pcb_gs_kernel; /* (used by nmi, dbg) */ 14985b33048SMatthew Dillon register_t tr_pcb_gs_saved; /* (used by nmi) */ 15085b33048SMatthew Dillon register_t tr_pcb_cr3_saved; /* (used by nmi) */ 151*c1a0c940SMatthew Dillon } __packed; 1524611d87fSMatthew Dillon 153b2b3ffcdSSimon Schubert int kdb_trap(int, int, struct trapframe *); 154b2b3ffcdSSimon Schubert 155b2b3ffcdSSimon Schubert #endif /* _CPU_FRAME_H_ */ 156