/*-1* Copyright (c) 2003 Peter Wemm2* All rights reserved.3*4* Copyright (c) 2021 The FreeBSD Foundation5*6* Portions of this software were developed by Konstantin Belousov7* under sponsorship from the FreeBSD Foundation.8*9* Redistribution and use in source and binary forms, with or without10* modification, are permitted provided that the following conditions11* are met:12* 1. Redistributions of source code must retain the above copyright13* notice, this list of conditions and the following disclaimer.14* 2. Redistributions in binary form must reproduce the above copyright15* notice, this list of conditions and the following disclaimer in the16* documentation and/or other materials provided with the distribution.17*18* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND19* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE20* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE21* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE22* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL23* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS24* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)25* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT26* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF28* SUCH DAMAGE.29*/3031#include <machine/asmacros.h>32#include <sys/syscall.h>3334#include "ia32_assym.h"3536.text37/*38* Signal trampoline, mapped as vdso into shared page, or copied to39* top of user stack for old binaries.40*/41ALIGN_TEXT42.globl __vdso_ia32_sigcode43__vdso_ia32_sigcode:44.cfi_startproc45.cfi_signal_frame46.cfi_def_cfa %esp, 047#if 048.cfi_offset %gs, IA32_SIGF_UC + IA32_UC_GS49.cfi_offset %fs, IA32_SIGF_UC + IA32_UC_FS50.cfi_offset %es, IA32_SIGF_UC + IA32_UC_ES51.cfi_offset %ds, IA32_SIGF_UC + IA32_UC_DS52#endif53.cfi_offset %edi, IA32_SIGF_UC + IA32_UC_EDI54.cfi_offset %esi, IA32_SIGF_UC + IA32_UC_ESI55.cfi_offset %ebp, IA32_SIGF_UC + IA32_UC_EBP56.cfi_offset %ebx, IA32_SIGF_UC + IA32_UC_EBX57.cfi_offset %edx, IA32_SIGF_UC + IA32_UC_EDX58.cfi_offset %ecx, IA32_SIGF_UC + IA32_UC_ECX59.cfi_offset %eax, IA32_SIGF_UC + IA32_UC_EAX60.cfi_offset %eip, IA32_SIGF_UC + IA32_UC_EIP61#if 062.cfi_offset %cs, IA32_SIGF_UC + IA32_UC_CS63.cfi_offset %flags, IA32_SIGF_UC + IA32_UC_EFLAGS64#endif65.cfi_offset %esp, IA32_SIGF_UC + IA32_UC_ESP66#if 067.cfi_offset %ss, IA32_SIGF_UC + IA32_UC_SS68.cfi_offset 93 /* %fs.base */, IA32_SIGF_UC + IA32_UC_FSBASE69.cfi_offset 94 /* %gs.base */, IA32_SIGF_UC + IA32_UC_GSBASE70#endif71calll *IA32_SIGF_HANDLER(%esp)72leal IA32_SIGF_UC(%esp),%eax /* get ucontext */73pushl %eax74.cfi_def_cfa %esp, 475movl $SYS_sigreturn,%eax76pushl %eax /* junk to fake return addr. */77.cfi_def_cfa %esp, 878int $0x80 /* enter kernel with args */79/* on stack */801:81jmp 1b82.cfi_endproc8384ALIGN_TEXT85.globl __vdso_freebsd4_ia32_sigcode86__vdso_freebsd4_ia32_sigcode:87#ifdef COMPAT_FREEBSD488calll *IA32_SIGF_HANDLER(%esp)89leal IA32_SIGF_UC4(%esp),%eax/* get ucontext */90pushl %eax91movl $344,%eax /* 4.x SYS_sigreturn */92pushl %eax /* junk to fake return addr. */93int $0x80 /* enter kernel with args */94/* on stack */951:96jmp 1b97#else98ud299#endif100101ALIGN_TEXT102.globl __vdso_ia32_osigcode103__vdso_ia32_osigcode:104#ifdef COMPAT_43105calll *IA32_SIGF_HANDLER(%esp)/* call signal handler */106leal IA32_SIGF_SC(%esp),%eax /* get sigcontext */107pushl %eax108movl $103,%eax /* 3.x SYS_sigreturn */109pushl %eax /* junk to fake return addr. */110int $0x80 /* enter kernel with args */1111:112jmp 1b113#else114ud2115#endif116117/*118* Our lcall $7,$0 handler remains in user mode (ring 3), since lcalls119* don't change the interrupt mask, so if this one went directly to the120* kernel then there would be a window with interrupts enabled in kernel121* mode, and all interrupt handlers would have to be almost as complicated122* as the NMI handler to support this.123*124* Instead, convert the lcall to an int0x80 call. The kernel does most125* of the conversion by popping the lcall return values off the user126* stack and returning to them instead of to here, except when the127* conversion itself fails. Adjusting the stack here is impossible for128* vfork() and harder for other syscalls.129*/130ALIGN_TEXT131.globl __vdso_lcall_tramp132__vdso_lcall_tramp:133#ifdef COMPAT_43134int $0x801351: jmp 1b136#else137ud2138#endif139.p2align 1140141142