ia32_exception.S revision 220451
1114987Speter/*- 2114987Speter * Copyright (c) 2003 Peter Wemm 3114987Speter * All rights reserved. 4114987Speter * 5114987Speter * Redistribution and use in source and binary forms, with or without 6114987Speter * modification, are permitted provided that the following conditions 7114987Speter * are met: 8114987Speter * 1. Redistributions of source code must retain the above copyright 9114987Speter * notice, this list of conditions and the following disclaimer. 10114987Speter * 2. Redistributions in binary form must reproduce the above copyright 11114987Speter * notice, this list of conditions and the following disclaimer in the 12114987Speter * documentation and/or other materials provided with the distribution. 13114987Speter * 14114987Speter * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15114987Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16114987Speter * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17114987Speter * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18114987Speter * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19114987Speter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20114987Speter * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21114987Speter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22114987Speter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23114987Speter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24114987Speter * SUCH DAMAGE. 25114987Speter * 26114987Speter * $FreeBSD: head/sys/amd64/ia32/ia32_exception.S 220451 2011-04-08 13:30:48Z jhb $ 27114987Speter */ 28114987Speter 29114987Speter#include <machine/asmacros.h> 30114987Speter 31114987Speter#include "assym.s" 32114987Speter 33114987Speter .text 34114987Speter/* 35114987Speter * Call gate entry for FreeBSD ELF and Linux/NetBSD syscall (int 0x80) 36114987Speter * 37114987Speter * This is a SDT_SYSIDT entry point (unlike the i386 port) so that we 38114987Speter * can do a swapgs before enabling interrupts. This is critical because 39114987Speter * if we took an interrupt before swapgs, the interrupt code would see 40114987Speter * that it originated in supervisor mode and skip the swapgs. 41114987Speter */ 42114987Speter SUPERALIGN_TEXT 43114987SpeterIDTVEC(int0x80_syscall) 44114987Speter swapgs 45114987Speter pushq $2 /* sizeof "int 0x80" */ 46114987Speter subq $TF_ERR,%rsp /* skip over tf_trapno */ 47114987Speter movq %rdi,TF_RDI(%rsp) 48195486Skib movq PCPU(CURPCB),%rdi 49220451Sjhb andl $~PCB_FULL_IRET,PCB_FLAGS(%rdi) 50195486Skib movw %fs,TF_FS(%rsp) 51195486Skib movw %gs,TF_GS(%rsp) 52195486Skib movw %es,TF_ES(%rsp) 53195486Skib movw %ds,TF_DS(%rsp) 54195486Skib sti 55114987Speter movq %rsi,TF_RSI(%rsp) 56114987Speter movq %rdx,TF_RDX(%rsp) 57114987Speter movq %rcx,TF_RCX(%rsp) 58114987Speter movq %r8,TF_R8(%rsp) 59114987Speter movq %r9,TF_R9(%rsp) 60114987Speter movq %rax,TF_RAX(%rsp) 61114987Speter movq %rbx,TF_RBX(%rsp) 62114987Speter movq %rbp,TF_RBP(%rsp) 63114987Speter movq %r10,TF_R10(%rsp) 64114987Speter movq %r11,TF_R11(%rsp) 65114987Speter movq %r12,TF_R12(%rsp) 66114987Speter movq %r13,TF_R13(%rsp) 67114987Speter movq %r14,TF_R14(%rsp) 68114987Speter movq %r15,TF_R15(%rsp) 69190620Skib movl $TF_HASSEGS,TF_FLAGS(%rsp) 70209483Skib cld 71129630Sbde FAKE_MCOUNT(TF_RIP(%rsp)) 72165303Skmacy movq %rsp, %rdi 73114987Speter call ia32_syscall 74129630Sbde MEXITCOUNT 75114987Speter jmp doreti 76