/*-1* Copyright (c) 2003 Peter Wemm2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*/2526#include <machine/asmacros.h>2728#include "assym.inc"2930.text31/*32* Call gate entry for FreeBSD ELF and Linux/NetBSD syscall (int 0x80)33*34* This is a SDT_SYSIDT entry point (unlike the i386 port) so that we35* can do a swapgs before enabling interrupts. This is critical because36* if we took an interrupt before swapgs, the interrupt code would see37* that it originated in supervisor mode and skip the swapgs.38*/39SUPERALIGN_TEXT40IDTVEC(int0x80_syscall_pti)41PTI_UENTRY has_err=042jmp int0x80_syscall_common43SUPERALIGN_TEXT44IDTVEC(int0x80_syscall)45swapgs46int0x80_syscall_common:47pushq $2 /* sizeof "int 0x80" */48subq $TF_ERR,%rsp /* skip over tf_trapno */49movq %rdi,TF_RDI(%rsp)50movq PCPU(CURPCB),%rdi51andl $~PCB_FULL_IRET,PCB_FLAGS(%rdi)52SAVE_SEGS53movq %rax,TF_RAX(%rsp)54movq %rdx,TF_RDX(%rsp)55movq %rcx,TF_RCX(%rsp)56call handle_ibrs_entry57sti58movq %rsi,TF_RSI(%rsp)59movq %r8,TF_R8(%rsp)60movq %r9,TF_R9(%rsp)61movq %rbx,TF_RBX(%rsp)62movq %rbp,TF_RBP(%rsp)63movq %r10,TF_R10(%rsp)64movq %r11,TF_R11(%rsp)65movq %r12,TF_R12(%rsp)66movq %r13,TF_R13(%rsp)67movq %r14,TF_R14(%rsp)68movq %r15,TF_R15(%rsp)69movl $TF_HASSEGS,TF_FLAGS(%rsp)70pushfq71andq $~(PSL_D | PSL_AC),(%rsp)72popfq73movq %rsp, %rdi74call ia32_syscall75jmp doreti767778