Index: sys/amd64/linux/linux_support.s =================================================================== --- /dev/null +++ sys/amd64/linux/linux_support.s @@ -1,231 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2007 Konstantin Belousov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include "linux_assym.h" /* system definitions */ -#include /* miscellaneous asm macros */ -#include - -#include "assym.inc" - -futex_fault: - testl $CPUID_STDEXT_SMAP,cpu_stdext_feature(%rip) - je 1f - clac -1: movq $0,PCB_ONFAULT(%r8) - movl $EFAULT,%eax - ret - -ENTRY(futex_xchgl_nosmap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - xchgl %edi,(%rsi) - movl %edi,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_xchgl_nosmap) - -ENTRY(futex_xchgl_smap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - stac - xchgl %edi,(%rsi) - clac - movl %edi,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_xchgl_smap) - -ENTRY(futex_addl_nosmap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault -#ifdef SMP - lock -#endif - xaddl %edi,(%rsi) - movl %edi,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_addl_nosmap) - -ENTRY(futex_addl_smap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - stac -#ifdef SMP - lock -#endif - xaddl %edi,(%rsi) - clac - movl %edi,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_addl_smap) - -ENTRY(futex_orl_nosmap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - movl (%rsi),%eax -1: movl %eax,%ecx - orl %edi,%ecx -#ifdef SMP - lock -#endif - cmpxchgl %ecx,(%rsi) - jnz 1b - movl %eax,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_orl_nosmap) - -ENTRY(futex_orl_smap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - stac - movl (%rsi),%eax -1: movl %eax,%ecx - orl %edi,%ecx -#ifdef SMP - lock -#endif - cmpxchgl %ecx,(%rsi) - jnz 1b - clac - movl %eax,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_orl_smap) - -ENTRY(futex_andl_nosmap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - movl (%rsi),%eax -1: movl %eax,%ecx - andl %edi,%ecx -#ifdef SMP - lock -#endif - cmpxchgl %ecx,(%rsi) - jnz 1b - movl %eax,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_andl_nosmap) - -ENTRY(futex_andl_smap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - stac - movl (%rsi),%eax -1: movl %eax,%ecx - andl %edi,%ecx -#ifdef SMP - lock -#endif - cmpxchgl %ecx,(%rsi) - jnz 1b - clac - movl %eax,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_andl_smap) - -ENTRY(futex_xorl_nosmap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - movl (%rsi),%eax -1: movl %eax,%ecx - xorl %edi,%ecx -#ifdef SMP - lock -#endif - cmpxchgl %ecx,(%rsi) - jnz 1b - movl %eax,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_xorl_nosmap) - -ENTRY(futex_xorl_smap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - stac - movl (%rsi),%eax -1: movl %eax,%ecx - xorl %edi,%ecx -#ifdef SMP - lock -#endif - cmpxchgl %ecx,(%rsi) - jnz 1b - clac - movl %eax,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_xorl_smap) Index: sys/amd64/linux/linux_vdso.lds.s =================================================================== --- /dev/null +++ sys/amd64/linux/linux_vdso.lds.s @@ -1,74 +0,0 @@ -/* - * Linker script for 64-bit vDSO. - * Copied from Linux kernel arch/x86/vdso/vdso-layout.lds.S - * - * $FreeBSD$ - */ - -SECTIONS -{ - . = . + SIZEOF_HEADERS; - - .hash : { *(.hash) } :text - .gnu.hash : { *(.gnu.hash) } - .dynsym : { *(.dynsym) } - .dynstr : { *(.dynstr) } - .gnu.version : { *(.gnu.version) } - .gnu.version_d : { *(.gnu.version_d) } - .gnu.version_r : { *(.gnu.version_r) } - - .note : { *(.note.*) } :text :note - - .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr - .eh_frame : { KEEP (*(.eh_frame)) } :text - - .dynamic : { *(.dynamic) } :text :dynamic - - .rodata : { *(.rodata*) } :text - .data : { - *(.data*) - *(.sdata*) - *(.got.plt) *(.got) - *(.gnu.linkonce.d.*) - *(.bss*) - *(.dynbss*) - *(.gnu.linkonce.b.*) - } - - .altinstructions : { *(.altinstructions) } - .altinstr_replacement : { *(.altinstr_replacement) } - - . = ALIGN(0x100); - .text : { *(.test .text*) } :text =0x90909090 -} - -PHDRS -{ - text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */ - dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ - note PT_NOTE FLAGS(4); /* PF_R */ - eh_frame_hdr PT_GNU_EH_FRAME; -} - -VERSION -{ - LINUX_2.6 { - global: - __vdso_time; - __vdso_gettimeofday; - __vdso_getcpu; - __vdso_clock_gettime; - __vdso_clock_getres; - local: *; - }; - - LINUX_0.0 { - global: - linux_rt_sigcode; - linux_platform; - kern_timekeep_base; - kern_tsc_selector; - kern_cpu_selector; - local: *; - }; -} Index: sys/amd64/linux32/linux32_support.s =================================================================== --- /dev/null +++ sys/amd64/linux32/linux32_support.s @@ -1,231 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2007 Konstantin Belousov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include "linux32_assym.h" /* system definitions */ -#include /* miscellaneous asm macros */ -#include - -#include "assym.inc" - -futex_fault: - testl $CPUID_STDEXT_SMAP,cpu_stdext_feature(%rip) - je 1f - clac -1: movq $0,PCB_ONFAULT(%r8) - movl $EFAULT,%eax - ret - -ENTRY(futex_xchgl_nosmap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - xchgl %edi,(%rsi) - movl %edi,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_xchgl_nosmap) - -ENTRY(futex_xchgl_smap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - stac - xchgl %edi,(%rsi) - clac - movl %edi,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_xchgl_smap) - -ENTRY(futex_addl_nosmap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault -#ifdef SMP - lock -#endif - xaddl %edi,(%rsi) - movl %edi,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_addl_nosmap) - -ENTRY(futex_addl_smap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - stac -#ifdef SMP - lock -#endif - xaddl %edi,(%rsi) - clac - movl %edi,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_addl_smap) - -ENTRY(futex_orl_nosmap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - movl (%rsi),%eax -1: movl %eax,%ecx - orl %edi,%ecx -#ifdef SMP - lock -#endif - cmpxchgl %ecx,(%rsi) - jnz 1b - movl %eax,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_orl_nosmap) - -ENTRY(futex_orl_smap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - stac - movl (%rsi),%eax -1: movl %eax,%ecx - orl %edi,%ecx -#ifdef SMP - lock -#endif - cmpxchgl %ecx,(%rsi) - jnz 1b - clac - movl %eax,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_orl_smap) - -ENTRY(futex_andl_nosmap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - movl (%rsi),%eax -1: movl %eax,%ecx - andl %edi,%ecx -#ifdef SMP - lock -#endif - cmpxchgl %ecx,(%rsi) - jnz 1b - movl %eax,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_andl_nosmap) - -ENTRY(futex_andl_smap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - stac - movl (%rsi),%eax -1: movl %eax,%ecx - andl %edi,%ecx -#ifdef SMP - lock -#endif - cmpxchgl %ecx,(%rsi) - jnz 1b - clac - movl %eax,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_andl_smap) - -ENTRY(futex_xorl_nosmap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - movl (%rsi),%eax -1: movl %eax,%ecx - xorl %edi,%ecx -#ifdef SMP - lock -#endif - cmpxchgl %ecx,(%rsi) - jnz 1b - movl %eax,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_xorl_nosmap) - -ENTRY(futex_xorl_smap) - movq PCPU(CURPCB),%r8 - movq $futex_fault,PCB_ONFAULT(%r8) - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - stac - movl (%rsi),%eax -1: movl %eax,%ecx - xorl %edi,%ecx -#ifdef SMP - lock -#endif - cmpxchgl %ecx,(%rsi) - jnz 1b - clac - movl %eax,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%r8) - ret -END(futex_xorl_smap) Index: sys/amd64/linux32/linux32_vdso.lds.s =================================================================== --- /dev/null +++ sys/amd64/linux32/linux32_vdso.lds.s @@ -1,84 +0,0 @@ -/* - * Linker script for 32-bit vDSO. - * Copied from Linux kernel arch/x86/vdso/vdso-layout.lds.S - * and arch/x86/vdso/vdso32/vdso32.lds.S - * - * $FreeBSD$ - */ - -SECTIONS -{ - . = . + SIZEOF_HEADERS; - - .hash : { *(.hash) } :text - .gnu.hash : { *(.gnu.hash) } - .dynsym : { *(.dynsym) } - .dynstr : { *(.dynstr) } - .gnu.version : { *(.gnu.version) } - .gnu.version_d : { *(.gnu.version_d) } - .gnu.version_r : { *(.gnu.version_r) } - - .note : { *(.note.*) } :text :note - - .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr - .eh_frame : { KEEP (*(.eh_frame)) } :text - - .dynamic : { *(.dynamic) } :text :dynamic - - .rodata : { *(.rodata*) } :text - .data : { - *(.data*) - *(.sdata*) - *(.got.plt) *(.got) - *(.gnu.linkonce.d.*) - *(.bss*) - *(.dynbss*) - *(.gnu.linkonce.b.*) - } - - .altinstructions : { *(.altinstructions) } - .altinstr_replacement : { *(.altinstr_replacement) } - - . = ALIGN(0x100); - .text : { *(.text*) } :text =0x90909090 -} - -PHDRS -{ - text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */ - dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ - note PT_NOTE FLAGS(4); /* PF_R */ - eh_frame_hdr PT_GNU_EH_FRAME; -} - -VERSION -{ - LINUX_2.6 { - global: - __vdso_clock_gettime; - __vdso_gettimeofday; - __vdso_time; - __vdso_getcpu; - __vdso_clock_getres; - __vdso_clock_gettime64; - }; - - LINUX_2.5 { - global: - __kernel_vsyscall; - __kernel_sigreturn; - __kernel_rt_sigreturn; - local: *; - }; - - LINUX_0.0 { - global: - linux_platform; - kern_timekeep_base; - kern_tsc_selector; - kern_cpu_selector; - linux32_vdso_sigcode; - linux32_vdso_rt_sigcode; - local: *; - }; -} Index: sys/arm/arm/setstack.s =================================================================== --- /dev/null +++ sys/arm/arm/setstack.s @@ -1,95 +0,0 @@ -/* $NetBSD: setstack.S,v 1.1 2001/07/28 13:28:03 chris Exp $ */ - -/*- - * Copyright (c) 1994 Mark Brinicombe. - * Copyright (c) 1994 Brini. - * All rights reserved. - * - * This code is derived from software written for Brini by Mark Brinicombe - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Brini. - * 4. The name of the company nor the name of the author may be used to - * endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * RiscBSD kernel project - * - * setstack.S - * - * Miscellaneous routine to play with the stack pointer in different CPU modes - * - * Eventually this routine can be inline assembly. - * - * Created : 17/09/94 - * - * Based of kate/display/setstack.s - * - */ - -#include -__FBSDID("$FreeBSD$"); - -#include - -/* To set the stack pointer for a particular mode we must switch - * to that mode update the banked r13 and then switch back. - * This routine provides an easy way of doing this for any mode - * - * r0 = CPU mode - * r1 = stackptr - */ - -ENTRY(set_stackptr) - mrs r3, cpsr /* Switch to the appropriate mode */ - bic r2, r3, #(PSR_MODE) - orr r2, r2, r0 - msr cpsr_fsxc, r2 - - mov sp, r1 /* Set the stack pointer */ - - msr cpsr_fsxc, r3 /* Restore the old mode */ - - mov pc, lr /* Exit */ -END(set_stackptr) -/* To get the stack pointer for a particular mode we must switch - * to that mode copy the banked r13 and then switch back. - * This routine provides an easy way of doing this for any mode - * - * r0 = CPU mode - */ - -ENTRY(get_stackptr) - mrs r3, cpsr /* Switch to the appropriate mode */ - bic r2, r3, #(PSR_MODE) - orr r2, r2, r0 - msr cpsr_fsxc, r2 - - mov r0, sp /* Set the stack pointer */ - - msr cpsr_fsxc, r3 /* Restore the old mode */ - - mov pc, lr /* Exit */ -END(get_stackptr) -/* End of setstack.S */ Index: sys/arm64/linux/linux_support.s =================================================================== --- /dev/null +++ sys/arm64/linux/linux_support.s @@ -1,178 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (C) 2018 Turing Robotic Industries Inc. - * Copyright (C) 2022 Dmitry Chagin - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include - -#include - -#include "assym.inc" - -.macro check_user_access user_arg, limit, bad_addr_func - ldr x7, =(\limit) - cmp x\user_arg, x7 - b.cs \bad_addr_func -.endm - -futex_fault: - SET_FAULT_HANDLER(xzr, x1) - EXIT_USER_ACCESS_CHECK(w0, x1) -futex_fault_nopcb: - mov x0, #EFAULT - ret - -#define LINUX_FUTEX_MAX_LOOPS 128 - -/* - * int oparg, uint32_t *uaddr, int *oldval - * - * Return 0 on success, errno on failure, - * EAGAIN is returned if LL/SC operation fails. - * - * XXX. VM_MAXUSER_ADDRESS is not applicable here, should be replaced - * by something like LINUX_SHAREDPAGE. - */ - -/* (int *)uaddr2 = oparg */ -ENTRY(futex_xchgl) - check_user_access 1, (VM_MAXUSER_ADDRESS-3), futex_fault_nopcb - adr x9, futex_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x9, x4) /* And set it */ - ENTER_USER_ACCESS(w9, x4) - mov w5, #LINUX_FUTEX_MAX_LOOPS - prfm pstl1strm, [x1] - mov w6, w0 /* Save oparg */ -1: ldxr w4, [x1] /* Load oldval from uaddr */ - stlxr w0, w6, [x1] /* Store oparg to uaddr */ - cbz w0, 3f /* Exit on success */ - sub w5, w5, w0 /* Dec loop counter, w0 is 1 */ - cbnz w5, 1b /* Loop */ - mov x0, #EAGAIN /* Store of newval failed */ -3: dmb ish - EXIT_USER_ACCESS(w9) - SET_FAULT_HANDLER(xzr, x9) /* Reset the fault handler */ - str w4, [x2] /* Store oldval */ - ret -END(futex_xchgl) - -/* (int *)uaddr2 += oparg */ -ENTRY(futex_addl) - check_user_access 1, (VM_MAXUSER_ADDRESS-3), futex_fault_nopcb - adr x9, futex_fault - SET_FAULT_HANDLER(x9, x4) - ENTER_USER_ACCESS(w9, x4) - mov w5, #LINUX_FUTEX_MAX_LOOPS - prfm pstl1strm, [x1] - mov w6, w0 -1: ldxr w4, [x1] - add w3, w4, w6 /* oldval + oparg */ - stlxr w0, w3, [x1] - cbz w0, 3f - sub w5, w5, w0 - cbnz w5, 1b - mov x0, #EAGAIN -3: dmb ish - EXIT_USER_ACCESS(w9) - SET_FAULT_HANDLER(xzr, x9) - str w4, [x2] - ret -END(futex_addl) - -/* (int *)uaddr2 |= oparg */ -ENTRY(futex_orl) - check_user_access 1, (VM_MAXUSER_ADDRESS-3), futex_fault_nopcb - adr x9, futex_fault - SET_FAULT_HANDLER(x9, x4) - ENTER_USER_ACCESS(w9, x4) - mov w5, #LINUX_FUTEX_MAX_LOOPS - prfm pstl1strm, [x1] - mov w6, w0 -1: ldxr w4, [x1] - orr w3, w4, w6 /* oldavl |= oparg */ - stlxr w0, w3, [x1] - cbz w0, 3f - sub w5, w5, w0 - cbnz w5, 1b - mov x0, #EAGAIN -3: dmb ish - EXIT_USER_ACCESS(w9) - SET_FAULT_HANDLER(xzr, x9) - str w4, [x2] - ret -END(futex_orl) - -/* (int *)uaddr2 &= oparg */ -ENTRY(futex_andl) - check_user_access 1, (VM_MAXUSER_ADDRESS-3), futex_fault_nopcb - adr x9, futex_fault - SET_FAULT_HANDLER(x9, x4) - ENTER_USER_ACCESS(w9, x4) - mov w5, #LINUX_FUTEX_MAX_LOOPS - prfm pstl1strm, [x1] - mov w6, w0 -1: ldxr w4, [x1] - and w3, w4, w6 /* oldval &= oparg */ - stlxr w0, w3, [x1] - cbz w0, 3f - sub w5, w5, w0 - cbnz w5, 1b - mov x0, #EAGAIN -3: dmb ish - EXIT_USER_ACCESS(w9) - SET_FAULT_HANDLER(xzr, x9) - str w4, [x2] - ret -END(futex_andl) - -/* (int *)uaddr2 ^= oparg */ -ENTRY(futex_xorl) - check_user_access 1, (VM_MAXUSER_ADDRESS-3), futex_fault_nopcb - adr x9, futex_fault - SET_FAULT_HANDLER(x9, x4) - ENTER_USER_ACCESS(w9, x4) - mov w5, #LINUX_FUTEX_MAX_LOOPS - prfm pstl1strm, [x1] - mov w6, w0 -1: ldxr w4, [x1] - eor w3, w4, w6 /* oldval ^= oparg */ - stlxr w0, w3, [x1] - cbz w0, 3f - sub w5, w5, w0 - cbnz w5, 1b - mov x0, #EAGAIN -3: dmb ish - EXIT_USER_ACCESS(w9) - SET_FAULT_HANDLER(xzr, x9) - str w4, [x2] - ret -END(futex_xorl) Index: sys/arm64/linux/linux_vdso.lds.s =================================================================== --- /dev/null +++ sys/arm64/linux/linux_vdso.lds.s @@ -1,76 +0,0 @@ -/* - * Linker script for 64-bit vDSO. - * Copied from Linux kernel arch/arm64/kernel/vdso/vdso.lds.S - * - * $FreeBSD$ - */ - -SECTIONS -{ - . = . + SIZEOF_HEADERS; - - .hash : { *(.hash) } :text - .gnu.hash : { *(.gnu.hash) } - .dynsym : { *(.dynsym) } - .dynstr : { *(.dynstr) } - .gnu.version : { *(.gnu.version) } - .gnu.version_d : { *(.gnu.version_d) } - .gnu.version_r : { *(.gnu.version_r) } - - /DISCARD/ : { - *(.note.GNU-stack .note.gnu.property) - } - - .note : { *(.note.*) } :text :note - - . = ALIGN(0x100); - - .text : { *(.text*) } :text =0x90909090 - PROVIDE (__etext = .); - PROVIDE (_etext = .); - PROVIDE (etext = .); - - .dynamic : { *(.dynamic) } :text :dynamic - - .rodata : { *(.rodata*) } :text - .data : { - *(.data*) - } - - _end = .; - PROVIDE(end = .); - - /DISCARD/ : { - *(.eh_frame .eh_frame_hdr) - } -} - -PHDRS -{ - text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */ - dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ - note PT_NOTE FLAGS(4); /* PF_R */ -} - -/* - * This controls what symbols we export from the DSO. - */ -VERSION -{ - LINUX_2.6.39 { - global: - __kernel_rt_sigreturn; - __kernel_gettimeofday; - __kernel_clock_gettime; - __kernel_clock_getres; - local: *; - }; - - LINUX_0.0 { - global: - linux_platform; - kern_timekeep_base; - linux_vdso_sigcode; - local: *; - }; -} Index: sys/conf/files.arm =================================================================== --- sys/conf/files.arm +++ sys/conf/files.arm @@ -62,7 +62,7 @@ arm/arm/ptrace_machdep.c standard arm/arm/sc_machdep.c optional sc arm/arm/setcpsr.S standard -arm/arm/setstack.s standard +arm/arm/setstack.S standard arm/arm/stack_machdep.c optional ddb | stack arm/arm/stdatomic.c standard \ compile-with "${NORMAL_C:N-Wmissing-prototypes}" Index: sys/conf/files.i386 =================================================================== --- sys/conf/files.i386 +++ sys/conf/files.i386 @@ -94,9 +94,9 @@ # i386/bios/smapi.c optional smapi i386/bios/smapi_bios.S optional smapi -#i386/i386/apic_vector.s optional apic +#i386/i386/apic_vector.S optional apic i386/i386/bios.c standard -i386/i386/bioscall.s standard +i386/i386/bioscall.S standard i386/i386/bpf_jit_machdep.c optional bpf_jitter i386/i386/copyout.c standard i386/i386/db_disasm.c optional ddb @@ -105,14 +105,14 @@ i386/i386/exec_machdep.c standard i386/i386/elan-mmcr.c optional cpu_elan | cpu_soekris i386/i386/elf_machdep.c standard -i386/i386/exception.s standard +i386/i386/exception.S standard i386/i386/gdb_machdep.c optional gdb i386/i386/geode.c optional cpu_geode i386/i386/in_cksum_machdep.c optional inet | inet6 i386/i386/initcpu.c standard i386/i386/io.c optional io i386/i386/k6_mem.c optional mem -i386/i386/locore.s standard no-obj +i386/i386/locore.S standard no-obj i386/i386/longrun.c optional cpu_enable_longrun i386/i386/machdep.c standard i386/i386/mem.c optional mem @@ -121,16 +121,16 @@ i386/i386/minidump_machdep_nopae.c standard i386/i386/mp_clock.c optional smp i386/i386/mp_machdep.c optional smp -i386/i386/mpboot.s optional smp +i386/i386/mpboot.S optional smp i386/i386/npx.c standard i386/i386/perfmon.c optional perfmon i386/i386/pmap_base.c standard i386/i386/pmap_nopae.c standard i386/i386/pmap_pae.c standard i386/i386/ptrace_machdep.c standard -i386/i386/sigtramp.s standard -i386/i386/support.s standard -i386/i386/swtch.s standard +i386/i386/sigtramp.S standard +i386/i386/support.S standard +i386/i386/swtch.S standard i386/i386/sys_machdep.c standard i386/i386/trap.c standard i386/i386/uio_machdep.c standard Index: sys/i386/i386/apic_vector.s =================================================================== --- /dev/null +++ sys/i386/i386/apic_vector.s @@ -1,336 +0,0 @@ -/*- - * Copyright (c) 1989, 1990 William F. Jolitz. - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: vector.s, 386BSD 0.1 unknown origin - * $FreeBSD$ - */ - -/* - * Interrupt entry points for external interrupts triggered by I/O APICs - * as well as IPI handlers. - */ - -#include "opt_smp.h" - -#include -#include -#include -#include - -#include "assym.inc" - - .text - SUPERALIGN_TEXT - /* End Of Interrupt to APIC */ -as_lapic_eoi: - cmpl $0,x2apic_mode - jne 1f - movl lapic_map,%eax - movl $0,LA_EOI(%eax) - ret -1: - movl $MSR_APIC_EOI,%ecx - xorl %eax,%eax - xorl %edx,%edx - wrmsr - ret - -/* - * I/O Interrupt Entry Point. Rather than having one entry point for - * each interrupt source, we use one entry point for each 32-bit word - * in the ISR. The handler determines the highest bit set in the ISR, - * translates that into a vector, and passes the vector to the - * lapic_handle_intr() function. - */ - .macro ISR_VEC index, vec_name - .text - SUPERALIGN_TEXT - .globl X\()\vec_name\()_pti, X\()\vec_name - -X\()\vec_name\()_pti: -X\()\vec_name: - PUSH_FRAME - SET_KERNEL_SREGS - cld - KENTER - cmpl $0,x2apic_mode - je 2f - movl $(MSR_APIC_ISR0 + \index),%ecx - rdmsr - jmp 3f -2: - movl lapic_map, %edx /* pointer to local APIC */ - movl LA_ISR + 16 * \index(%edx), %eax /* load ISR */ -3: - bsrl %eax, %eax /* index of highest set bit in ISR */ - jz 4f - addl $(32 * \index),%eax - pushl %esp - pushl %eax /* pass the IRQ */ - movl $lapic_handle_intr, %eax - call *%eax - addl $8, %esp /* discard parameter */ -4: - jmp doreti - .endm - -/* - * Handle "spurious INTerrupts". - * Notes: - * This is different than the "spurious INTerrupt" generated by an - * 8259 PIC for missing INTs. See the APIC documentation for details. - * This routine should NOT do an 'EOI' cycle. - */ - .text - SUPERALIGN_TEXT -IDTVEC(spuriousint) - - /* No EOI cycle used here */ - - iret - - ISR_VEC 1, apic_isr1 - ISR_VEC 2, apic_isr2 - ISR_VEC 3, apic_isr3 - ISR_VEC 4, apic_isr4 - ISR_VEC 5, apic_isr5 - ISR_VEC 6, apic_isr6 - ISR_VEC 7, apic_isr7 - -/* - * Local APIC periodic timer handler. - */ - .text - SUPERALIGN_TEXT -IDTVEC(timerint_pti) -IDTVEC(timerint) - PUSH_FRAME - SET_KERNEL_SREGS - cld - KENTER - pushl %esp - movl $lapic_handle_timer, %eax - call *%eax - add $4, %esp - jmp doreti - -/* - * Local APIC CMCI handler. - */ - .text - SUPERALIGN_TEXT -IDTVEC(cmcint_pti) -IDTVEC(cmcint) - PUSH_FRAME - SET_KERNEL_SREGS - cld - KENTER - movl $lapic_handle_cmc, %eax - call *%eax - jmp doreti - -/* - * Local APIC error interrupt handler. - */ - .text - SUPERALIGN_TEXT -IDTVEC(errorint_pti) -IDTVEC(errorint) - PUSH_FRAME - SET_KERNEL_SREGS - cld - KENTER - movl $lapic_handle_error, %eax - call *%eax - jmp doreti - -#ifdef XENHVM -/* - * Xen event channel upcall interrupt handler. - * Only used when the hypervisor supports direct vector callbacks. - */ - .text - SUPERALIGN_TEXT -IDTVEC(xen_intr_upcall) - PUSH_FRAME - SET_KERNEL_SREGS - cld - KENTER - pushl %esp - movl $xen_arch_intr_handle_upcall, %eax - call *%eax - add $4, %esp - jmp doreti -#endif - -#ifdef SMP -/* - * Global address space TLB shootdown. - */ - .text - SUPERALIGN_TEXT -invltlb_ret: - call as_lapic_eoi - jmp doreti - - SUPERALIGN_TEXT -IDTVEC(invltlb) - PUSH_FRAME - SET_KERNEL_SREGS - cld - KENTER - movl $invltlb_handler, %eax - call *%eax - jmp invltlb_ret - -/* - * Single page TLB shootdown - */ - .text - SUPERALIGN_TEXT -IDTVEC(invlpg) - PUSH_FRAME - SET_KERNEL_SREGS - cld - KENTER - movl $invlpg_handler, %eax - call *%eax - jmp invltlb_ret - -/* - * Page range TLB shootdown. - */ - .text - SUPERALIGN_TEXT -IDTVEC(invlrng) - PUSH_FRAME - SET_KERNEL_SREGS - cld - KENTER - movl $invlrng_handler, %eax - call *%eax - jmp invltlb_ret - -/* - * Invalidate cache. - */ - .text - SUPERALIGN_TEXT -IDTVEC(invlcache) - PUSH_FRAME - SET_KERNEL_SREGS - cld - KENTER - movl $invlcache_handler, %eax - call *%eax - jmp invltlb_ret - -/* - * Handler for IPIs sent via the per-cpu IPI bitmap. - */ - .text - SUPERALIGN_TEXT -IDTVEC(ipi_intr_bitmap_handler) - PUSH_FRAME - SET_KERNEL_SREGS - cld - KENTER - call as_lapic_eoi - movl $ipi_bitmap_handler, %eax - call *%eax - jmp doreti - -/* - * Executed by a CPU when it receives an IPI_STOP from another CPU. - */ - .text - SUPERALIGN_TEXT -IDTVEC(cpustop) - PUSH_FRAME - SET_KERNEL_SREGS - cld - KENTER - call as_lapic_eoi - movl $cpustop_handler, %eax - call *%eax - jmp doreti - -/* - * Executed by a CPU when it receives an IPI_SUSPEND from another CPU. - */ - .text - SUPERALIGN_TEXT -IDTVEC(cpususpend) - PUSH_FRAME - SET_KERNEL_SREGS - cld - KENTER - call as_lapic_eoi - movl $cpususpend_handler, %eax - call *%eax - jmp doreti - -/* - * Executed by a CPU when it receives an IPI_SWI. - */ - .text - SUPERALIGN_TEXT -IDTVEC(ipi_swi) - PUSH_FRAME - SET_KERNEL_SREGS - cld - KENTER - call as_lapic_eoi - movl $ipi_swi_handler, %eax - call *%eax - jmp doreti - -/* - * Executed by a CPU when it receives a RENDEZVOUS IPI from another CPU. - * - * - Calls the generic rendezvous action function. - */ - .text - SUPERALIGN_TEXT -IDTVEC(rendezvous) - PUSH_FRAME - SET_KERNEL_SREGS - cld - KENTER -#ifdef COUNT_IPIS - movl PCPU(CPUID), %eax - movl ipi_rendezvous_counts(,%eax,4), %eax - incl (%eax) -#endif - movl $smp_rendezvous_action, %eax - call *%eax - call as_lapic_eoi - jmp doreti - -#endif /* SMP */ Index: sys/i386/i386/atpic_vector.s =================================================================== --- /dev/null +++ sys/i386/i386/atpic_vector.s @@ -1,82 +0,0 @@ -/*- - * Copyright (c) 1989, 1990 William F. Jolitz. - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: vector.s, 386BSD 0.1 unknown origin - * $FreeBSD$ - */ - -/* - * Interrupt entry points for external interrupts triggered by the 8259A - * master and slave interrupt controllers. - */ - -#include -#include - -#include "assym.inc" - -/* - * Macros for interrupt entry, call to handler, and exit. - */ - .macro INTR irq_num, vec_name - .text - SUPERALIGN_TEXT - .globl X\()\vec_name\()_pti, X\()\vec_name - -X\()\vec_name\()_pti: -X\()\vec_name: - PUSH_FRAME - SET_KERNEL_SREGS - cld - KENTER - pushl %esp - pushl $\irq_num /* pass the IRQ */ - movl $atpic_handle_intr, %eax - call *%eax - addl $8, %esp /* discard the parameters */ - - jmp doreti - .endm - - INTR 0, atpic_intr0 - INTR 1, atpic_intr1 - INTR 2, atpic_intr2 - INTR 3, atpic_intr3 - INTR 4, atpic_intr4 - INTR 5, atpic_intr5 - INTR 6, atpic_intr6 - INTR 7, atpic_intr7 - INTR 8, atpic_intr8 - INTR 9, atpic_intr9 - INTR 10, atpic_intr10 - INTR 11, atpic_intr11 - INTR 12, atpic_intr12 - INTR 13, atpic_intr13 - INTR 14, atpic_intr14 - INTR 15, atpic_intr15 Index: sys/i386/i386/bioscall.s =================================================================== --- /dev/null +++ sys/i386/i386/bioscall.s @@ -1,160 +0,0 @@ -/*- - * Copyright (c) 1997 Jonathan Lemon - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -/* - * Functions for calling x86 BIOS functions from the BSD kernel - */ - -#include - -#include "assym.inc" - - .data - ALIGN_DATA -bioscall_frame: .long 0 -bioscall_stack: .long 0 - - .text -/* - * bios32(regs, offset, segment) - * struct bios_regs *regs; - * u_int offset; - * u_short segment; - */ -ENTRY(bios32) - pushl %ebp - movl 16(%esp),%ebp - mov %bp,bioscall_vector+4 - movl 12(%esp),%ebp - movl %ebp,bioscall_vector - movl 8(%esp),%ebp - pushl %ebx - pushl %esi - pushl %edi - movl 0(%ebp),%eax - movl 4(%ebp),%ebx - movl 8(%ebp),%ecx - movl 12(%ebp),%edx - movl 16(%ebp),%esi - movl 20(%ebp),%edi - pushl %ebp - lcall *bioscall_vector - popl %ebp - movl %eax,0(%ebp) - movl %ebx,4(%ebp) - movl %ecx,8(%ebp) - movl %edx,12(%ebp) - movl %esi,16(%ebp) - movl %edi,20(%ebp) - movl $0,%eax /* presume success */ - jnc 1f - movl $1,%eax /* nope */ -1: - popl %edi - popl %esi - popl %ebx - popl %ebp - ret - - -/* - * bios16_call(regs, stack) - * struct bios_regs *regs; - * char *stack; - */ -ENTRY(bios16_call) - pushl %ebp - movl %esp,%ebp - addl $4,%ebp /* frame pointer */ - movl %ebp,bioscall_frame /* ... save it */ - pushl %ebx - pushl %esi - pushl %edi -/* - * the problem with a full 32-bit stack segment is that 16-bit code - * tends to do a pushf, which only pushes %sp, not %esp. This value - * is then popped off (into %esp) which causes a page fault because - * it is the wrong address. - * - * the reverse problem happens for 16-bit stack addresses; the kernel - * code attempts to get the address of something on the stack, and the - * value returned is the address relative to %ss, not %ds. - * - * we fix this by installing a temporary stack at page 0, so the - * addresses are always valid in both 32 bit and 16 bit modes. - */ - movl %esp,bioscall_stack /* save current stack location */ - movl 8(%ebp),%esp /* switch to page 0 stack */ - - movl 4(%ebp),%ebp /* regs */ - - movl 0(%ebp),%eax - movl 4(%ebp),%ebx - movl 8(%ebp),%ecx - movl 12(%ebp),%edx - movl 16(%ebp),%esi - movl 20(%ebp),%edi - - pushl $BC32SEL - leal CNAME(bios16_jmp),%ebp - andl $PAGE_MASK,%ebp - pushl %ebp /* reload %cs and */ - lret /* ...continue below */ - .globl CNAME(bios16_jmp) -CNAME(bios16_jmp): - lcallw *bioscall_vector /* 16-bit call */ - - jc 1f - pushl $0 /* success */ - jmp 2f -1: - pushl $1 /* failure */ -2: - movl bioscall_frame,%ebp - - movl 4(%ebp),%ebp /* regs */ - - movl %eax,0(%ebp) - movl %ebx,4(%ebp) - movl %ecx,8(%ebp) - movl %edx,12(%ebp) - movl %esi,16(%ebp) - movl %edi,20(%ebp) - - popl %eax /* recover return value */ - movl bioscall_stack,%esp /* return to normal stack */ - - popl %edi - popl %esi - popl %ebx - popl %ebp - - movl (%esp),%ecx - pushl %ecx /* return address */ - movl $KCSEL,4(%esp) - lret /* reload %cs on the way out */ Index: sys/i386/i386/copyout_fast.s =================================================================== --- /dev/null +++ sys/i386/i386/copyout_fast.s @@ -1,361 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2018 The FreeBSD Foundation - * - * This software was developed by Konstantin Belousov - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include - -#include "assym.inc" - - .text - -ENTRY(copyout_fast) - pushl %ebp - movl %esp, %ebp - pushl %esi - pushl %edi - pushl %ebx - - movl $copyout_fault,%edx - movl 20(%ebp),%ebx /* KCR3 */ - - movl PCPU(CURPCB),%eax - movl PCB_CR3(%eax),%edi - - cli - movl PCPU(TRAMPSTK),%esi - movl PCPU(COPYOUT_BUF),%eax - subl $4,%esi - movl %eax,(%esi) - movl 12(%ebp),%eax /* udaddr */ - subl $4,%esi - movl %eax,(%esi) - movl 16(%ebp),%eax /* len */ - subl $4,%esi - movl %eax,(%esi) - - subl $4, %esi - movl %edi, (%esi) - - movl 8(%ebp),%eax /* kaddr */ - subl $4,%esi - movl %eax,(%esi) - movl PCPU(COPYOUT_BUF),%eax - subl $4,%esi - movl %eax,(%esi) - movl 16(%ebp),%eax /* len */ - subl $4,%esi - movl %eax,(%esi) - - movl %esp,%eax - movl %esi,%esp - - /* bcopy(%esi = kaddr, %edi = PCPU(copyout_buf), %ecx = len) */ - popl %ecx - popl %edi - popl %esi - rep; movsb - - popl %edi - movl %edi,%cr3 - - /* bcopy(%esi = PCPU(copyout_buf), %edi = udaddr, %ecx = len) */ - popl %ecx - popl %edi - popl %esi - rep; movsb - - movl %ebx,%cr3 - movl %eax,%esp - sti - - xorl %eax,%eax - popl %ebx - popl %edi - popl %esi - leave - ret -END(copyout_fast) - -ENTRY(copyin_fast) - pushl %ebp - movl %esp, %ebp - pushl %esi - pushl %edi - pushl %ebx - - movl $copyout_fault,%edx - movl 20(%ebp),%ebx /* KCR3 */ - - movl PCPU(CURPCB),%eax - movl PCB_CR3(%eax),%edi - - cli - movl PCPU(TRAMPSTK),%esi - movl PCPU(COPYOUT_BUF),%eax - subl $4,%esi - movl %eax,(%esi) - movl 12(%ebp),%eax /* kaddr */ - subl $4,%esi - movl %eax,(%esi) - movl 16(%ebp),%eax /* len */ - subl $4,%esi - movl %eax,(%esi) - - movl 8(%ebp),%eax /* udaddr */ - subl $4,%esi - movl %eax,(%esi) - movl PCPU(COPYOUT_BUF),%eax - subl $4,%esi - movl %eax,(%esi) - movl 16(%ebp),%eax /* len */ - subl $4,%esi - movl %eax,(%esi) - - movl %esp,%eax - movl %esi,%esp - movl %edi,%cr3 - - /* bcopy(%esi = udaddr, %edi = PCPU(copyout_buf), %ecx = len) */ - popl %ecx - popl %edi - popl %esi - rep; movsb - - movl %ebx,%cr3 - - /* bcopy(%esi = PCPU(copyout_buf), %edi = kaddr, %ecx = len) */ - popl %ecx - popl %edi - popl %esi - rep; movsb - - movl %eax,%esp - sti - - xorl %eax,%eax - popl %ebx - popl %edi - popl %esi - leave - ret -END(copyin_fast) - - ALIGN_TEXT -copyout_fault: - movl %eax,%esp - sti - movl $EFAULT,%eax - popl %ebx - popl %edi - popl %esi - leave - ret - -ENTRY(fueword_fast) - pushl %ebp - movl %esp,%ebp - pushl %ebx - pushl %esi - pushl %edi - movl 8(%ebp),%ecx /* from */ - movl PCPU(CURPCB),%eax - movl PCB_CR3(%eax),%eax - movl $fusufault,%edx - movl 16(%ebp),%ebx - movl %esp,%esi - cli - movl PCPU(TRAMPSTK),%esp - movl %eax,%cr3 - movl (%ecx),%eax - movl %ebx,%cr3 - movl %esi,%esp - sti - movl 12(%ebp),%edx - movl %eax,(%edx) - xorl %eax,%eax - popl %edi - popl %esi - popl %ebx - leave - ret -END(fueword_fast) - -ENTRY(fuword16_fast) - pushl %ebp - movl %esp,%ebp - pushl %ebx - pushl %esi - pushl %edi - movl 8(%ebp),%ecx /* from */ - movl PCPU(CURPCB),%eax - movl PCB_CR3(%eax),%eax - movl $fusufault,%edx - movl 12(%ebp),%ebx - movl %esp,%esi - cli - movl PCPU(TRAMPSTK),%esp - movl %eax,%cr3 - movzwl (%ecx),%eax - movl %ebx,%cr3 - movl %esi,%esp - sti - popl %edi - popl %esi - popl %ebx - leave - ret -END(fuword16_fast) - -ENTRY(fubyte_fast) - pushl %ebp - movl %esp,%ebp - pushl %ebx - pushl %esi - pushl %edi - movl 8(%ebp),%ecx /* from */ - movl PCPU(CURPCB),%eax - movl PCB_CR3(%eax),%eax - movl $fusufault,%edx - movl 12(%ebp),%ebx - movl %esp,%esi - cli - movl PCPU(TRAMPSTK),%esp - movl %eax,%cr3 - movzbl (%ecx),%eax - movl %ebx,%cr3 - movl %esi,%esp - sti - popl %edi - popl %esi - popl %ebx - leave - ret -END(fubyte_fast) - - ALIGN_TEXT -fusufault: - movl %esi,%esp - sti - xorl %eax,%eax - decl %eax - popl %edi - popl %esi - popl %ebx - leave - ret - -ENTRY(suword_fast) - pushl %ebp - movl %esp,%ebp - pushl %ebx - pushl %esi - pushl %edi - movl PCPU(CURPCB),%eax - movl PCB_CR3(%eax),%eax - movl $fusufault,%edx - movl 8(%ebp),%ecx /* to */ - movl 12(%ebp),%edi /* val */ - movl 16(%ebp),%ebx - movl %esp,%esi - cli - movl PCPU(TRAMPSTK),%esp - movl %eax,%cr3 - movl %edi,(%ecx) - movl %ebx,%cr3 - movl %esi,%esp - sti - xorl %eax,%eax - popl %edi - popl %esi - popl %ebx - leave - ret -END(suword_fast) - -ENTRY(suword16_fast) - pushl %ebp - movl %esp,%ebp - pushl %ebx - pushl %esi - pushl %edi - movl PCPU(CURPCB),%eax - movl PCB_CR3(%eax),%eax - movl $fusufault,%edx - movl 8(%ebp),%ecx /* to */ - movl 12(%ebp),%edi /* val */ - movl 16(%ebp),%ebx - movl %esp,%esi - cli - movl PCPU(TRAMPSTK),%esp - movl %eax,%cr3 - movw %di,(%ecx) - movl %ebx,%cr3 - movl %esi,%esp - sti - xorl %eax,%eax - popl %edi - popl %esi - popl %ebx - leave - ret -END(suword16_fast) - -ENTRY(subyte_fast) - pushl %ebp - movl %esp,%ebp - pushl %ebx - pushl %esi - pushl %edi - movl PCPU(CURPCB),%eax - movl PCB_CR3(%eax),%eax - movl $fusufault,%edx - movl 8(%ebp),%ecx /* to */ - movl 12(%ebp),%edi /* val */ - movl 16(%ebp),%ebx - movl %esp,%esi - cli - movl PCPU(TRAMPSTK),%esp - movl %eax,%cr3 - movl %edi,%eax - movb %al,(%ecx) - movl %ebx,%cr3 - movl %esi,%esp - sti - xorl %eax,%eax - popl %edi - popl %esi - popl %ebx - leave - ret -END(subyte_fast) Index: sys/i386/i386/exception.S =================================================================== --- sys/i386/i386/exception.S +++ sys/i386/i386/exception.S @@ -393,7 +393,7 @@ SUPERALIGN_TEXT #ifdef DEV_ATPIC -#include +#include #endif #if defined(DEV_APIC) && defined(DEV_ATPIC) @@ -404,7 +404,7 @@ #endif #ifdef DEV_APIC -#include +#include #endif #ifdef HYPERV @@ -419,11 +419,11 @@ .p2align 4 .text SUPERALIGN_TEXT -#include +#include .text -#include +#include /* * void doreti(struct trapframe) Index: sys/i386/i386/locore.s =================================================================== --- /dev/null +++ sys/i386/i386/locore.s @@ -1,456 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 - * $FreeBSD$ - * - * originally from: locore.s, by William F. Jolitz - * - * Substantially rewritten by David Greenman, Rod Grimes, - * Bruce Evans, Wolfgang Solfrank, Poul-Henning Kamp - * and many others. - */ - -#include "opt_bootp.h" -#include "opt_nfsroot.h" -#include "opt_pmap.h" - -#include - -#include -#include -#include -#include -#include - -#include "assym.inc" - -/* - * Compiled KERNBASE location and the kernel load address, now identical. - */ - .globl kernbase - .set kernbase,KERNBASE - .globl kernload - .set kernload,KERNLOAD - -/* - * Globals - */ - .data - ALIGN_DATA /* just to be sure */ - - .space 0x2000 /* space for tmpstk - temporary stack */ -tmpstk: - - .globl bootinfo -bootinfo: .space BOOTINFO_SIZE /* bootinfo that we can handle */ - - .text -/********************************************************************** - * - * This is where the bootblocks start us, set the ball rolling... - * - */ -ENTRY(btext) - -/* Tell the bios to warmboot next time */ - movw $0x1234,0x472 - -/* Set up a real frame in case the double return in newboot is executed. */ - xorl %ebp,%ebp - pushl %ebp - movl %esp, %ebp - -/* Don't trust what the BIOS gives for eflags. */ - pushl $PSL_KERNEL - popfl - -/* - * Don't trust what the BIOS gives for %fs and %gs. Trust the bootstrap - * to set %cs, %ds, %es and %ss. - */ - mov %ds, %ax - mov %ax, %fs - mov %ax, %gs - -/* - * Clear the bss. Not all boot programs do it, and it is our job anyway. - * - * XXX we don't check that there is memory for our bss and page tables - * before using it. - * - * Note: we must be careful to not overwrite an active gdt or idt. They - * inactive from now until we switch to new ones, since we don't load any - * more segment registers or permit interrupts until after the switch. - */ - movl $__bss_end,%ecx - movl $__bss_start,%edi - subl %edi,%ecx - xorl %eax,%eax - cld - rep - stosb - - call recover_bootinfo - -/* Get onto a stack that we can trust. */ -/* - * XXX this step is delayed in case recover_bootinfo needs to return via - * the old stack, but it need not be, since recover_bootinfo actually - * returns via the old frame. - */ - movl $tmpstk,%esp - - call identify_cpu - call pmap_cold - - /* set up bootstrap stack */ - movl proc0kstack,%eax /* location of in-kernel stack */ - - /* - * Only use bottom page for init386(). init386() calculates the - * PCB + FPU save area size and returns the true top of stack. - */ - leal PAGE_SIZE(%eax),%esp - - xorl %ebp,%ebp /* mark end of frames */ - - pushl physfree /* value of first for init386(first) */ - call init386 /* wire 386 chip for unix operation */ - - /* - * Clean up the stack in a way that db_numargs() understands, so - * that backtraces in ddb don't underrun the stack. Traps for - * inaccessible memory are more fatal than usual this early. - */ - addl $4,%esp - - /* Switch to true top of stack. */ - movl %eax,%esp - - call mi_startup /* autoconfiguration, mountroot etc */ - /* NOTREACHED */ - addl $0,%esp /* for db_numargs() again */ - -/********************************************************************** - * - * Recover the bootinfo passed to us from the boot program - * - */ -recover_bootinfo: - /* - * This code is called in different ways depending on what loaded - * and started the kernel. This is used to detect how we get the - * arguments from the other code and what we do with them. - * - * Old disk boot blocks: - * (*btext)(howto, bootdev, cyloffset, esym); - * [return address == 0, and can NOT be returned to] - * [cyloffset was not supported by the FreeBSD boot code - * and always passed in as 0] - * [esym is also known as total in the boot code, and - * was never properly supported by the FreeBSD boot code] - * - * Old diskless netboot code: - * (*btext)(0,0,0,0,&nfsdiskless,0,0,0); - * [return address != 0, and can NOT be returned to] - * If we are being booted by this code it will NOT work, - * so we are just going to halt if we find this case. - * - * New uniform boot code: - * (*btext)(howto, bootdev, 0, 0, 0, &bootinfo) - * [return address != 0, and can be returned to] - * - * There may seem to be a lot of wasted arguments in here, but - * that is so the newer boot code can still load very old kernels - * and old boot code can load new kernels. - */ - - /* - * The old style disk boot blocks fake a frame on the stack and - * did an lret to get here. The frame on the stack has a return - * address of 0. - */ - cmpl $0,4(%ebp) - je olddiskboot - - /* - * We have some form of return address, so this is either the - * old diskless netboot code, or the new uniform code. That can - * be detected by looking at the 5th argument, if it is 0 - * we are being booted by the new uniform boot code. - */ - cmpl $0,24(%ebp) - je newboot - - /* - * Seems we have been loaded by the old diskless boot code, we - * don't stand a chance of running as the diskless structure - * changed considerably between the two, so just halt. - */ - hlt - - /* - * We have been loaded by the new uniform boot code. - * Let's check the bootinfo version, and if we do not understand - * it we return to the loader with a status of 1 to indicate this error - */ -newboot: - movl 28(%ebp),%ebx /* &bootinfo.version */ - movl BI_VERSION(%ebx),%eax - cmpl $1,%eax /* We only understand version 1 */ - je 1f - movl $1,%eax /* Return status */ - leave - /* - * XXX this returns to our caller's caller (as is required) since - * we didn't set up a frame and our caller did. - */ - ret - -1: - /* - * If we have a kernelname copy it in - */ - movl BI_KERNELNAME(%ebx),%esi - cmpl $0,%esi - je 2f /* No kernelname */ - movl $MAXPATHLEN,%ecx /* Brute force!!! */ - movl $kernelname,%edi - cmpb $'/',(%esi) /* Make sure it starts with a slash */ - je 1f - movb $'/',(%edi) - incl %edi - decl %ecx -1: - cld - rep - movsb - -2: - /* - * Determine the size of the boot loader's copy of the bootinfo - * struct. This is impossible to do properly because old versions - * of the struct don't contain a size field and there are 2 old - * versions with the same version number. - */ - movl $BI_ENDCOMMON,%ecx /* prepare for sizeless version */ - testl $RB_BOOTINFO,8(%ebp) /* bi_size (and bootinfo) valid? */ - je got_bi_size /* no, sizeless version */ - movl BI_SIZE(%ebx),%ecx -got_bi_size: - - /* - * Copy the common part of the bootinfo struct - */ - movl %ebx,%esi - movl $bootinfo,%edi - cmpl $BOOTINFO_SIZE,%ecx - jbe got_common_bi_size - movl $BOOTINFO_SIZE,%ecx -got_common_bi_size: - cld - rep - movsb - -#ifdef NFS_ROOT -#ifndef BOOTP_NFSV3 - /* - * If we have a nfs_diskless structure copy it in - */ - movl BI_NFS_DISKLESS(%ebx),%esi - cmpl $0,%esi - je olddiskboot - movl $nfs_diskless,%edi - movl $NFSDISKLESS_SIZE,%ecx - cld - rep - movsb - movl $nfs_diskless_valid,%edi - movl $1,(%edi) -#endif -#endif - - /* - * The old style disk boot. - * (*btext)(howto, bootdev, cyloffset, esym); - * Note that the newer boot code just falls into here to pick - * up howto and bootdev, cyloffset and esym are no longer used - */ -olddiskboot: - movl 8(%ebp),%eax - movl %eax,boothowto - movl 12(%ebp),%eax - movl %eax,bootdev - - ret - - -/********************************************************************** - * - * Identify the CPU and initialize anything special about it - * - */ -ENTRY(identify_cpu) - - pushl %ebx - - /* Try to toggle alignment check flag; does not exist on 386. */ - pushfl - popl %eax - movl %eax,%ecx - orl $PSL_AC,%eax - pushl %eax - popfl - pushfl - popl %eax - xorl %ecx,%eax - andl $PSL_AC,%eax - pushl %ecx - popfl - - testl %eax,%eax - jnz try486 - - /* NexGen CPU does not have alignment check flag. */ - pushfl - movl $0x5555, %eax - xorl %edx, %edx - movl $2, %ecx - clc - divl %ecx - jz trynexgen - popfl - movl $CPU_386,cpu - jmp 3f - -trynexgen: - popfl - movl $CPU_NX586,cpu - movl $0x4778654e,cpu_vendor # store vendor string - movl $0x72446e65,cpu_vendor+4 - movl $0x6e657669,cpu_vendor+8 - movl $0,cpu_vendor+12 - jmp 3f - -try486: /* Try to toggle identification flag; does not exist on early 486s. */ - pushfl - popl %eax - movl %eax,%ecx - xorl $PSL_ID,%eax - pushl %eax - popfl - pushfl - popl %eax - xorl %ecx,%eax - andl $PSL_ID,%eax - pushl %ecx - popfl - - testl %eax,%eax - jnz trycpuid - movl $CPU_486,cpu - - /* - * Check Cyrix CPU - * Cyrix CPUs do not change the undefined flags following - * execution of the divide instruction which divides 5 by 2. - * - * Note: CPUID is enabled on M2, so it passes another way. - */ - pushfl - movl $0x5555, %eax - xorl %edx, %edx - movl $2, %ecx - clc - divl %ecx - jnc trycyrix - popfl - jmp 3f /* You may use Intel CPU. */ - -trycyrix: - popfl - /* - * IBM Bluelighting CPU also doesn't change the undefined flags. - * Because IBM doesn't disclose the information for Bluelighting - * CPU, we couldn't distinguish it from Cyrix's (including IBM - * brand of Cyrix CPUs). - */ - movl $0x69727943,cpu_vendor # store vendor string - movl $0x736e4978,cpu_vendor+4 - movl $0x64616574,cpu_vendor+8 - jmp 3f - -trycpuid: /* Use the `cpuid' instruction. */ - xorl %eax,%eax - cpuid # cpuid 0 - movl %eax,cpu_high # highest capability - movl %ebx,cpu_vendor # store vendor string - movl %edx,cpu_vendor+4 - movl %ecx,cpu_vendor+8 - movb $0,cpu_vendor+12 - - movl $1,%eax - cpuid # cpuid 1 - movl %eax,cpu_id # store cpu_id - movl %ebx,cpu_procinfo # store cpu_procinfo - movl %edx,cpu_feature # store cpu_feature - movl %ecx,cpu_feature2 # store cpu_feature2 - rorl $8,%eax # extract family type - andl $15,%eax - cmpl $5,%eax - jae 1f - - /* less than Pentium; must be 486 */ - movl $CPU_486,cpu - jmp 3f -1: - /* a Pentium? */ - cmpl $5,%eax - jne 2f - movl $CPU_586,cpu - jmp 3f -2: - /* Greater than Pentium...call it a Pentium Pro */ - movl $CPU_686,cpu -3: - popl %ebx - ret -END(identify_cpu) - -#ifdef XENHVM -/* Xen Hypercall page */ - .text -.p2align PAGE_SHIFT, 0x90 /* Hypercall_page needs to be PAGE aligned */ - -ENTRY(hypercall_page) - .skip 0x1000, 0x90 /* Fill with "nop"s */ -#endif Index: sys/i386/i386/mpboot.s =================================================================== --- /dev/null +++ sys/i386/i386/mpboot.s @@ -1,283 +0,0 @@ -/*- - * Copyright (c) 1995 Jack F. Vogel - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * mpboot.s: FreeBSD machine support for the Intel MP Spec - * multiprocessor systems. - * - * $FreeBSD$ - */ - -#include "opt_pmap.h" - -#include /* miscellaneous asm macros */ -#include -#include - -#include "assym.inc" - -/* - * this code MUST be enabled here and in mp_machdep.c - * it follows the very early stages of AP boot by placing values in CMOS ram. - * it NORMALLY will never be needed and thus the primitive method for enabling. - * -#define CHECK_POINTS - */ - -#if defined(CHECK_POINTS) - -#define CMOS_REG (0x70) -#define CMOS_DATA (0x71) - -#define CHECKPOINT(A,D) \ - movb $(A),%al ; \ - outb %al,$CMOS_REG ; \ - movb $(D),%al ; \ - outb %al,$CMOS_DATA - -#else - -#define CHECKPOINT(A,D) - -#endif /* CHECK_POINTS */ - - -/* - * the APs enter here from their trampoline code (bootMP, below) - */ - .p2align 4 - -ENTRY(MPentry) - CHECKPOINT(0x36, 3) - /* - * Enable features on this processor. We don't support SMP on - * CPUs older than a Pentium, so we know that we can use the cpuid - * instruction. - */ - movl $1,%eax - cpuid /* Retrieve features */ - movl %cr4,%eax - testl $CPUID_PSE,%edx - jz 1f - orl $CR4_PSE,%eax /* Enable PSE */ -1: testl $CPUID_PGE,%edx - jz 2f - orl $CR4_PGE,%eax /* Enable PGE */ -2: testl $CPUID_VME,%edx - jz 3f - orl $CR4_VME,%eax /* Enable VME */ -3: movl %eax,%cr4 - - /* Now enable paging mode */ - cmpl $0, pae_mode - je 4f - movl IdlePDPT, %eax - movl %eax, %cr3 - movl %cr4, %eax - orl $CR4_PAE, %eax - movl %eax, %cr4 - movl $0x80000000, %eax - cpuid - movl $0x80000001, %ebx - cmpl %ebx, %eax - jb 5f - movl %ebx, %eax - cpuid - testl $AMDID_NX, %edx - je 5f - movl $MSR_EFER, %ecx - rdmsr - orl $EFER_NXE,%eax - wrmsr - jmp 5f -4: movl IdlePTD_nopae, %eax - movl %eax,%cr3 -5: movl %cr0,%eax - orl $CR0_PE|CR0_PG,%eax /* enable paging */ - movl %eax,%cr0 /* let the games begin! */ - movl bootSTK,%esp /* boot stack end loc. */ - - pushl $mp_begin /* jump to high mem */ - ret - - /* - * Wait for the booting CPU to signal startup - */ -mp_begin: /* now running relocated at KERNBASE */ - CHECKPOINT(0x37, 4) - call init_secondary /* load i386 tables */ - -/* - * This is the embedded trampoline or bootstrap that is - * copied into 'real-mode' low memory, it is where the - * secondary processor "wakes up". When it is executed - * the processor will eventually jump into the routine - * MPentry, which resides in normal kernel text above - * 1Meg. -jackv - */ - - .data - ALIGN_DATA /* just to be sure */ - -BOOTMP1: - -ENTRY(bootMP) - .code16 - cli - CHECKPOINT(0x34, 1) - /* First guarantee a 'clean slate' */ - xorl %eax, %eax - movl %eax, %ebx - movl %eax, %ecx - movl %eax, %edx - movl %eax, %esi - movl %eax, %edi - - /* set up data segments */ - mov %cs, %ax - mov %ax, %ds - mov %ax, %es - mov %ax, %fs - mov %ax, %gs - mov %ax, %ss - mov $(boot_stk-bootMP), %esp - - /* Now load the global descriptor table */ - lgdt MP_GDTptr-bootMP - - /* Enable protected mode */ - movl %cr0, %eax - orl $CR0_PE, %eax - movl %eax, %cr0 - - /* - * make intrasegment jump to flush the processor pipeline and - * reload CS register - */ - pushl $0x18 - pushl $(protmode-bootMP) - lretl - - .code32 -protmode: - CHECKPOINT(0x35, 2) - - /* - * we are NOW running for the first time with %eip - * having the full physical address, BUT we still - * are using a segment descriptor with the origin - * not matching the booting kernel. - * - * SO NOW... for the BIG Jump into kernel's segment - * and physical text above 1 Meg. - */ - mov $0x10, %ebx - movw %bx, %ds - movw %bx, %es - movw %bx, %fs - movw %bx, %gs - movw %bx, %ss - - .globl bigJump -bigJump: - /* this will be modified by mpInstallTramp() */ - ljmp $0x08, $0 /* far jmp to MPentry() */ - -dead: hlt /* We should never get here */ - jmp dead - -/* - * MP boot strap Global Descriptor Table - */ - .p2align 4 - .globl MP_GDT - .globl bootCodeSeg - .globl bootDataSeg -MP_GDT: - -nulldesc: /* offset = 0x0 */ - - .word 0x0 - .word 0x0 - .byte 0x0 - .byte 0x0 - .byte 0x0 - .byte 0x0 - -kernelcode: /* offset = 0x08 */ - - .word 0xffff /* segment limit 0..15 */ - .word 0x0000 /* segment base 0..15 */ - .byte 0x0 /* segment base 16..23; set for 0K */ - .byte 0x9f /* flags; Type */ - .byte 0xcf /* flags; Limit */ - .byte 0x0 /* segment base 24..32 */ - -kerneldata: /* offset = 0x10 */ - - .word 0xffff /* segment limit 0..15 */ - .word 0x0000 /* segment base 0..15 */ - .byte 0x0 /* segment base 16..23; set for 0k */ - .byte 0x93 /* flags; Type */ - .byte 0xcf /* flags; Limit */ - .byte 0x0 /* segment base 24..32 */ - -bootcode: /* offset = 0x18 */ - - .word 0xffff /* segment limit 0..15 */ -bootCodeSeg: /* this will be modified by mpInstallTramp() */ - .word 0x0000 /* segment base 0..15 */ - .byte 0x00 /* segment base 16...23; set for 0x000xx000 */ - .byte 0x9e /* flags; Type */ - .byte 0xcf /* flags; Limit */ - .byte 0x0 /*segment base 24..32 */ - -bootdata: /* offset = 0x20 */ - - .word 0xffff -bootDataSeg: /* this will be modified by mpInstallTramp() */ - .word 0x0000 /* segment base 0..15 */ - .byte 0x00 /* segment base 16...23; set for 0x000xx000 */ - .byte 0x92 - .byte 0xcf - .byte 0x0 - -/* - * GDT pointer for the lgdt call - */ - .globl mp_gdtbase - -MP_GDTptr: -mp_gdtlimit: - .word 0x0028 -mp_gdtbase: /* this will be modified by mpInstallTramp() */ - .long 0 - - .space 0x100 /* space for boot_stk - 1st temporary stack */ -boot_stk: - -BOOTMP2: - .globl bootMP_size -bootMP_size: - .long BOOTMP2 - BOOTMP1 Index: sys/i386/i386/sigtramp.s =================================================================== --- /dev/null +++ sys/i386/i386/sigtramp.s @@ -1,138 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 - * $FreeBSD$ - * - * originally from: locore.s, by William F. Jolitz - * - * Substantially rewritten by David Greenman, Rod Grimes, - * Bruce Evans, Wolfgang Solfrank, Poul-Henning Kamp - * and many others. - */ - -#include -#include -#include - -#include "assym.inc" - -/* - * Signal trampoline, copied to top of user stack - */ -ENTRY(sigcode) - calll *SIGF_HANDLER(%esp) - leal SIGF_UC(%esp),%eax /* get ucontext */ - pushl %eax - testl $PSL_VM,UC_EFLAGS(%eax) - jne 1f - mov UC_GS(%eax),%gs /* restore %gs */ -1: - movl $SYS_sigreturn,%eax - pushl %eax /* junk to fake return addr. */ - int $0x80 /* enter kernel with args */ - /* on stack */ -1: - jmp 1b - -#ifdef COMPAT_FREEBSD4 - ALIGN_TEXT -freebsd4_sigcode: - calll *SIGF_HANDLER(%esp) - leal SIGF_UC4(%esp),%eax /* get ucontext */ - pushl %eax - testl $PSL_VM,UC4_EFLAGS(%eax) - jne 1f - mov UC4_GS(%eax),%gs /* restore %gs */ -1: - movl $344,%eax /* 4.x SYS_sigreturn */ - pushl %eax /* junk to fake return addr. */ - int $0x80 /* enter kernel with args */ - /* on stack */ -1: - jmp 1b -#endif - -#ifdef COMPAT_43 - ALIGN_TEXT -osigcode: - call *SIGF_HANDLER(%esp) /* call signal handler */ - lea SIGF_SC(%esp),%eax /* get sigcontext */ - pushl %eax - testl $PSL_VM,SC_PS(%eax) - jne 9f - mov SC_GS(%eax),%gs /* restore %gs */ -9: - movl $103,%eax /* 3.x SYS_sigreturn */ - pushl %eax /* junk to fake return addr. */ - int $0x80 /* enter kernel with args */ -0: jmp 0b - -/* - * Our lcall $7,$0 handler remains in user mode (ring 3), since lcalls - * don't change the interrupt mask, so if this one went directly to the - * kernel then there would be a window with interrupts enabled in kernel - * mode, and all interrupt handlers would have to be almost as complicated - * as the NMI handler to support this. - * - * Instead, convert the lcall to an int0x80 call. The kernel does most - * of the conversion by popping the lcall return values off the user - * stack and returning to them instead of to here, except when the - * conversion itself fails. Adjusting the stack here is impossible for - * vfork() and harder for other syscalls. - */ - ALIGN_TEXT -lcall_tramp: - int $0x80 -1: jmp 1b - -#endif /* COMPAT_43 */ - - ALIGN_TEXT -esigcode: - - .data - .globl szsigcode -szsigcode: - .long esigcode-sigcode -#ifdef COMPAT_FREEBSD4 - .globl szfreebsd4_sigcode -szfreebsd4_sigcode: - .long esigcode-freebsd4_sigcode -#endif -#ifdef COMPAT_43 - .globl szosigcode -szosigcode: - .long esigcode-osigcode - .globl sz_lcall_tramp -sz_lcall_tramp: - .long esigcode-lcall_tramp -#endif Index: sys/i386/i386/support.s =================================================================== --- /dev/null +++ sys/i386/i386/support.s @@ -1,582 +0,0 @@ -/*- - * Copyright (c) 1993 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include - -#include "assym.inc" - -#define IDXSHIFT 10 - - .text - -ENTRY(sse2_pagezero) - pushl %ebx - movl 8(%esp),%ecx - movl %ecx,%eax - addl $4096,%eax - xor %ebx,%ebx - jmp 1f - /* - * The loop takes 14 bytes. Ensure that it doesn't cross a 16-byte - * cache line. - */ - .p2align 4,0x90 -1: - movnti %ebx,(%ecx) - movnti %ebx,4(%ecx) - addl $8,%ecx - cmpl %ecx,%eax - jne 1b - sfence - popl %ebx - ret -END(sse2_pagezero) - -ENTRY(i686_pagezero) - pushl %edi - pushl %ebx - - movl 12(%esp),%edi - movl $1024,%ecx - - ALIGN_TEXT -1: - xorl %eax,%eax - repe - scasl - jnz 2f - - popl %ebx - popl %edi - ret - - ALIGN_TEXT - -2: - incl %ecx - subl $4,%edi - - movl %ecx,%edx - cmpl $16,%ecx - - jge 3f - - movl %edi,%ebx - andl $0x3f,%ebx - shrl %ebx - shrl %ebx - movl $16,%ecx - subl %ebx,%ecx - -3: - subl %ecx,%edx - rep - stosl - - movl %edx,%ecx - testl %edx,%edx - jnz 1b - - popl %ebx - popl %edi - ret -END(i686_pagezero) - -/* fillw(pat, base, cnt) */ -ENTRY(fillw) - pushl %edi - movl 8(%esp),%eax - movl 12(%esp),%edi - movl 16(%esp),%ecx - rep - stosw - popl %edi - ret -END(fillw) - -/* - * memmove(dst, src, cnt) (return dst) - * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 - */ -ENTRY(memmove) - pushl %ebp - movl %esp,%ebp - pushl %esi - pushl %edi - movl 8(%ebp),%edi - movl 12(%ebp),%esi -1: - movl 16(%ebp),%ecx - - movl %edi,%eax - subl %esi,%eax - cmpl %ecx,%eax /* overlapping && src < dst? */ - jb 1f - - shrl $2,%ecx /* copy by 32-bit words */ - rep - movsl - movl 16(%ebp),%ecx - andl $3,%ecx /* any bytes left? */ - rep - movsb - popl %edi - popl %esi - movl 8(%ebp),%eax /* return dst for memmove */ - popl %ebp - ret - - ALIGN_TEXT -1: - addl %ecx,%edi /* copy backwards */ - addl %ecx,%esi - decl %edi - decl %esi - andl $3,%ecx /* any fractional bytes? */ - std - rep - movsb - movl 16(%ebp),%ecx /* copy remainder by 32-bit words */ - shrl $2,%ecx - subl $3,%esi - subl $3,%edi - rep - movsl - popl %edi - popl %esi - cld - movl 8(%ebp),%eax /* return dst for memmove */ - popl %ebp - ret -END(memmove) - -/* - * Note: memcpy does not support overlapping copies - */ -ENTRY(memcpy) - pushl %edi - pushl %esi - movl 12(%esp),%edi - movl 16(%esp),%esi - movl 20(%esp),%ecx - movl %edi,%eax - shrl $2,%ecx /* copy by 32-bit words */ - rep - movsl - movl 20(%esp),%ecx - andl $3,%ecx /* any bytes left? */ - rep - movsb - popl %esi - popl %edi - ret -END(memcpy) - -/* - * Handling of special 386 registers and descriptor tables etc - */ -/* void lgdt(struct region_descriptor *rdp); */ -ENTRY(lgdt) - /* reload the descriptor table */ - movl 4(%esp),%eax - lgdt (%eax) - - /* flush the prefetch q */ - jmp 1f - nop -1: - /* reload "stale" selectors */ - movl $KDSEL,%eax - movl %eax,%ds - movl %eax,%es - movl %eax,%gs - movl %eax,%ss - movl $KPSEL,%eax - movl %eax,%fs - - /* reload code selector by turning return into intersegmental return */ - movl (%esp),%eax - pushl %eax - movl $KCSEL,4(%esp) - lret -END(lgdt) - -/* ssdtosd(*ssdp,*sdp) */ -ENTRY(ssdtosd) - pushl %ebx - movl 8(%esp),%ecx - movl 8(%ecx),%ebx - shll $16,%ebx - movl (%ecx),%edx - roll $16,%edx - movb %dh,%bl - movb %dl,%bh - rorl $8,%ebx - movl 4(%ecx),%eax - movw %ax,%dx - andl $0xf0000,%eax - orl %eax,%ebx - movl 12(%esp),%ecx - movl %edx,(%ecx) - movl %ebx,4(%ecx) - popl %ebx - ret -END(ssdtosd) - -/* void reset_dbregs() */ -ENTRY(reset_dbregs) - movl $0,%eax - movl %eax,%dr7 /* disable all breakpoints first */ - movl %eax,%dr0 - movl %eax,%dr1 - movl %eax,%dr2 - movl %eax,%dr3 - movl %eax,%dr6 - ret -END(reset_dbregs) - -/*****************************************************************************/ -/* setjump, longjump */ -/*****************************************************************************/ - -ENTRY(setjmp) - movl 4(%esp),%eax - movl %ebx,(%eax) /* save ebx */ - movl %esp,4(%eax) /* save esp */ - movl %ebp,8(%eax) /* save ebp */ - movl %esi,12(%eax) /* save esi */ - movl %edi,16(%eax) /* save edi */ - movl (%esp),%edx /* get rta */ - movl %edx,20(%eax) /* save eip */ - xorl %eax,%eax /* return(0); */ - ret -END(setjmp) - -ENTRY(longjmp) - movl 4(%esp),%eax - movl (%eax),%ebx /* restore ebx */ - movl 4(%eax),%esp /* restore esp */ - movl 8(%eax),%ebp /* restore ebp */ - movl 12(%eax),%esi /* restore esi */ - movl 16(%eax),%edi /* restore edi */ - movl 20(%eax),%edx /* get rta */ - movl %edx,(%esp) /* put in return frame */ - xorl %eax,%eax /* return(1); */ - incl %eax - ret -END(longjmp) - -/* - * Support for reading MSRs in the safe manner. (Instead of panic on #gp, - * return an error.) - */ -ENTRY(rdmsr_safe) -/* int rdmsr_safe(u_int msr, uint64_t *data) */ - movl PCPU(CURPCB),%ecx - movl $msr_onfault,PCB_ONFAULT(%ecx) - - movl 4(%esp),%ecx - rdmsr - movl 8(%esp),%ecx - movl %eax,(%ecx) - movl %edx,4(%ecx) - xorl %eax,%eax - - movl PCPU(CURPCB),%ecx - movl %eax,PCB_ONFAULT(%ecx) - - ret - -/* - * Support for writing MSRs in the safe manner. (Instead of panic on #gp, - * return an error.) - */ -ENTRY(wrmsr_safe) -/* int wrmsr_safe(u_int msr, uint64_t data) */ - movl PCPU(CURPCB),%ecx - movl $msr_onfault,PCB_ONFAULT(%ecx) - - movl 4(%esp),%ecx - movl 8(%esp),%eax - movl 12(%esp),%edx - wrmsr - xorl %eax,%eax - - movl PCPU(CURPCB),%ecx - movl %eax,PCB_ONFAULT(%ecx) - - ret - -/* - * MSR operations fault handler - */ - ALIGN_TEXT -msr_onfault: - movl PCPU(CURPCB),%ecx - movl $0,PCB_ONFAULT(%ecx) - movl $EFAULT,%eax - ret - - .altmacro - .macro rsb_seq_label l -rsb_seq_\l: - .endm - .macro rsb_call_label l - call rsb_seq_\l - .endm - .macro rsb_seq count - ll=1 - .rept \count - rsb_call_label %(ll) - nop - rsb_seq_label %(ll) - addl $4,%esp - ll=ll+1 - .endr - .endm - -ENTRY(rsb_flush) - rsb_seq 32 - ret - -ENTRY(handle_ibrs_entry) - cmpb $0,hw_ibrs_ibpb_active - je 1f - movl $MSR_IA32_SPEC_CTRL,%ecx - rdmsr - orl $(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax - orl $(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32,%edx - wrmsr - movb $1,PCPU(IBPB_SET) - /* - * i386 does not implement SMEP. - */ -1: jmp rsb_flush -END(handle_ibrs_entry) - -ENTRY(handle_ibrs_exit) - cmpb $0,PCPU(IBPB_SET) - je 1f - movl $MSR_IA32_SPEC_CTRL,%ecx - rdmsr - andl $~(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax - andl $~((IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32),%edx - wrmsr - movb $0,PCPU(IBPB_SET) -1: ret -END(handle_ibrs_exit) - -ENTRY(mds_handler_void) - ret -END(mds_handler_void) - -ENTRY(mds_handler_verw) - subl $4, %esp - movw %ds, (%esp) - verw (%esp) - addl $4, %esp - ret -END(mds_handler_verw) - -ENTRY(mds_handler_ivb) - movl %cr0, %eax - testb $CR0_TS, %al - je 1f - clts -1: movl PCPU(MDS_BUF), %edx - movdqa %xmm0, PCPU(MDS_TMP) - pxor %xmm0, %xmm0 - - lfence - orpd (%edx), %xmm0 - orpd (%edx), %xmm0 - mfence - movl $40, %ecx - addl $16, %edx -2: movntdq %xmm0, (%edx) - addl $16, %edx - decl %ecx - jnz 2b - mfence - - movdqa PCPU(MDS_TMP),%xmm0 - testb $CR0_TS, %al - je 3f - movl %eax, %cr0 -3: ret -END(mds_handler_ivb) - -ENTRY(mds_handler_bdw) - movl %cr0, %eax - testb $CR0_TS, %al - je 1f - clts -1: movl PCPU(MDS_BUF), %ebx - movdqa %xmm0, PCPU(MDS_TMP) - pxor %xmm0, %xmm0 - - movl %ebx, %edi - movl %ebx, %esi - movl $40, %ecx -2: movntdq %xmm0, (%ebx) - addl $16, %ebx - decl %ecx - jnz 2b - mfence - movl $1536, %ecx - rep; movsb - lfence - - movdqa PCPU(MDS_TMP),%xmm0 - testb $CR0_TS, %al - je 3f - movl %eax, %cr0 -3: ret -END(mds_handler_bdw) - -ENTRY(mds_handler_skl_sse) - movl %cr0, %eax - testb $CR0_TS, %al - je 1f - clts -1: movl PCPU(MDS_BUF), %edi - movl PCPU(MDS_BUF64), %edx - movdqa %xmm0, PCPU(MDS_TMP) - pxor %xmm0, %xmm0 - - lfence - orpd (%edx), %xmm0 - orpd (%edx), %xmm0 - xorl %eax, %eax -2: clflushopt 5376(%edi, %eax, 8) - addl $8, %eax - cmpl $8 * 12, %eax - jb 2b - sfence - movl $6144, %ecx - xorl %eax, %eax - rep; stosb - mfence - - movdqa PCPU(MDS_TMP), %xmm0 - testb $CR0_TS, %al - je 3f - movl %eax, %cr0 -3: ret -END(mds_handler_skl_sse) - -ENTRY(mds_handler_skl_avx) - movl %cr0, %eax - testb $CR0_TS, %al - je 1f - clts -1: movl PCPU(MDS_BUF), %edi - movl PCPU(MDS_BUF64), %edx - vmovdqa %ymm0, PCPU(MDS_TMP) - vpxor %ymm0, %ymm0, %ymm0 - - lfence - vorpd (%edx), %ymm0, %ymm0 - vorpd (%edx), %ymm0, %ymm0 - xorl %eax, %eax -2: clflushopt 5376(%edi, %eax, 8) - addl $8, %eax - cmpl $8 * 12, %eax - jb 2b - sfence - movl $6144, %ecx - xorl %eax, %eax - rep; stosb - mfence - - vmovdqa PCPU(MDS_TMP), %ymm0 - testb $CR0_TS, %al - je 3f - movl %eax, %cr0 -3: ret -END(mds_handler_skl_avx) - -ENTRY(mds_handler_skl_avx512) - movl %cr0, %eax - testb $CR0_TS, %al - je 1f - clts -1: movl PCPU(MDS_BUF), %edi - movl PCPU(MDS_BUF64), %edx - vmovdqa64 %zmm0, PCPU(MDS_TMP) - vpxord %zmm0, %zmm0, %zmm0 - - lfence - vorpd (%edx), %zmm0, %zmm0 - vorpd (%edx), %zmm0, %zmm0 - xorl %eax, %eax -2: clflushopt 5376(%edi, %eax, 8) - addl $8, %eax - cmpl $8 * 12, %eax - jb 2b - sfence - movl $6144, %ecx - xorl %eax, %eax - rep; stosb - mfence - - vmovdqa64 PCPU(MDS_TMP), %zmm0 - testb $CR0_TS, %al - je 3f - movl %eax, %cr0 -3: ret -END(mds_handler_skl_avx512) - -ENTRY(mds_handler_silvermont) - movl %cr0, %eax - testb $CR0_TS, %al - je 1f - clts -1: movl PCPU(MDS_BUF), %edx - movdqa %xmm0, PCPU(MDS_TMP) - pxor %xmm0, %xmm0 - - movl $16, %ecx -2: movntdq %xmm0, (%edx) - addl $16, %edx - decl %ecx - jnz 2b - mfence - - movdqa PCPU(MDS_TMP),%xmm0 - testb $CR0_TS, %al - je 3f - movl %eax, %cr0 -3: ret -END(mds_handler_silvermont) Index: sys/i386/i386/swtch.s =================================================================== --- /dev/null +++ sys/i386/i386/swtch.s @@ -1,464 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include "opt_sched.h" - -#include - -#include "assym.inc" - -#if defined(SMP) && defined(SCHED_ULE) -#define SETOP xchgl -#define BLOCK_SPIN(reg) \ - movl $blocked_lock,%eax ; \ - 100: ; \ - lock ; \ - cmpxchgl %eax,TD_LOCK(reg) ; \ - jne 101f ; \ - pause ; \ - jmp 100b ; \ - 101: -#else -#define SETOP movl -#define BLOCK_SPIN(reg) -#endif - -/*****************************************************************************/ -/* Scheduling */ -/*****************************************************************************/ - - .text - -/* - * cpu_throw() - * - * This is the second half of cpu_switch(). It is used when the current - * thread is either a dummy or slated to die, and we no longer care - * about its state. This is only a slight optimization and is probably - * not worth it anymore. Note that we need to clear the pm_active bits so - * we do need the old proc if it still exists. - * 0(%esp) = ret - * 4(%esp) = oldtd - * 8(%esp) = newtd - */ -ENTRY(cpu_throw) - movl PCPU(CPUID), %esi - /* release bit from old pm_active */ - movl PCPU(CURPMAP), %ebx -#ifdef SMP - lock -#endif - btrl %esi, PM_ACTIVE(%ebx) /* clear old */ - movl 8(%esp),%ecx /* New thread */ - movl TD_PCB(%ecx),%edx - /* set bit in new pm_active */ - movl TD_PROC(%ecx),%eax - movl P_VMSPACE(%eax), %ebx - addl $VM_PMAP, %ebx - movl %ebx, PCPU(CURPMAP) -#ifdef SMP - lock -#endif - btsl %esi, PM_ACTIVE(%ebx) /* set new */ - jmp sw1 -END(cpu_throw) - -/* - * cpu_switch(old, new) - * - * Save the current thread state, then select the next thread to run - * and load its state. - * 0(%esp) = ret - * 4(%esp) = oldtd - * 8(%esp) = newtd - * 12(%esp) = newlock - */ -ENTRY(cpu_switch) - - /* Switch to new thread. First, save context. */ - movl 4(%esp),%ecx - -#ifdef INVARIANTS - testl %ecx,%ecx /* no thread? */ - jz badsw2 /* no, panic */ -#endif - - movl TD_PCB(%ecx),%edx - - movl (%esp),%eax /* Hardware registers */ - movl %eax,PCB_EIP(%edx) - movl %ebx,PCB_EBX(%edx) - movl %esp,PCB_ESP(%edx) - movl %ebp,PCB_EBP(%edx) - movl %esi,PCB_ESI(%edx) - movl %edi,PCB_EDI(%edx) - mov %gs,PCB_GS(%edx) - /* Test if debug registers should be saved. */ - testl $PCB_DBREGS,PCB_FLAGS(%edx) - jz 1f /* no, skip over */ - movl %dr7,%eax /* yes, do the save */ - movl %eax,PCB_DR7(%edx) - andl $0x0000fc00, %eax /* disable all watchpoints */ - movl %eax,%dr7 - movl %dr6,%eax - movl %eax,PCB_DR6(%edx) - movl %dr3,%eax - movl %eax,PCB_DR3(%edx) - movl %dr2,%eax - movl %eax,PCB_DR2(%edx) - movl %dr1,%eax - movl %eax,PCB_DR1(%edx) - movl %dr0,%eax - movl %eax,PCB_DR0(%edx) -1: - - /* have we used fp, and need a save? */ - cmpl %ecx,PCPU(FPCURTHREAD) - jne 1f - pushl PCB_SAVEFPU(%edx) /* h/w bugs make saving complicated */ - call npxsave /* do it in a big C function */ - popl %eax -1: - - /* Save is done. Now fire up new thread. */ - movl 4(%esp),%edi - movl 8(%esp),%ecx /* New thread */ - movl 12(%esp),%esi /* New lock */ -#ifdef INVARIANTS - testl %ecx,%ecx /* no thread? */ - jz badsw3 /* no, panic */ -#endif - movl TD_PCB(%ecx),%edx - - /* Switchout td_lock */ - movl %esi,%eax - movl PCPU(CPUID),%esi - SETOP %eax,TD_LOCK(%edi) - - /* Release bit from old pmap->pm_active */ - movl PCPU(CURPMAP), %ebx -#ifdef SMP - lock -#endif - btrl %esi, PM_ACTIVE(%ebx) /* clear old */ - - /* Set bit in new pmap->pm_active */ - movl TD_PROC(%ecx),%eax /* newproc */ - movl P_VMSPACE(%eax), %ebx - addl $VM_PMAP, %ebx - movl %ebx, PCPU(CURPMAP) -#ifdef SMP - lock -#endif - btsl %esi, PM_ACTIVE(%ebx) /* set new */ -sw1: - BLOCK_SPIN(%ecx) - /* - * At this point, we have managed thread locks and are ready - * to load up the rest of the next context. - */ - - /* Load a pointer to the thread kernel stack into PCPU. */ - leal -VM86_STACK_SPACE(%edx), %eax /* leave space for vm86 */ - movl %eax, PCPU(KESP0) - - cmpl $0, PCB_EXT(%edx) /* has pcb extension? */ - je 1f /* If not, use the default */ - movl $1, PCPU(PRIVATE_TSS) /* mark use of private tss */ - movl PCB_EXT(%edx), %edi /* new tss descriptor */ - movl PCPU(TRAMPSTK), %ebx - movl %ebx, PCB_EXT_TSS+TSS_ESP0(%edi) - jmp 2f /* Load it up */ - -1: /* - * Use the common default TSS instead of our own. - * Stack pointer in the common TSS points to the trampoline stack - * already and should be not changed. - * - * Test this CPU's flag to see if this CPU was using a private TSS. - */ - cmpl $0, PCPU(PRIVATE_TSS) /* Already using the common? */ - je 3f /* if so, skip reloading */ - movl $0, PCPU(PRIVATE_TSS) - PCPU_ADDR(COMMON_TSSD, %edi) -2: - /* Move correct tss descriptor into GDT slot, then reload tr. */ - movl PCPU(TSS_GDT), %ebx /* entry in GDT */ - movl 0(%edi), %eax - movl 4(%edi), %esi - movl %eax, 0(%ebx) - movl %esi, 4(%ebx) - movl $GPROC0_SEL*8, %esi /* GSEL(GPROC0_SEL, SEL_KPL) */ - ltr %si -3: - - /* Copy the %fs and %gs selectors into this pcpu gdt */ - leal PCB_FSD(%edx), %esi - movl PCPU(FSGS_GDT), %edi - movl 0(%esi), %eax /* %fs selector */ - movl 4(%esi), %ebx - movl %eax, 0(%edi) - movl %ebx, 4(%edi) - movl 8(%esi), %eax /* %gs selector, comes straight after */ - movl 12(%esi), %ebx - movl %eax, 8(%edi) - movl %ebx, 12(%edi) - - /* Restore context. */ - movl PCB_EBX(%edx),%ebx - movl PCB_ESP(%edx),%esp - movl PCB_EBP(%edx),%ebp - movl PCB_ESI(%edx),%esi - movl PCB_EDI(%edx),%edi - movl PCB_EIP(%edx),%eax - movl %eax,(%esp) - - movl %edx, PCPU(CURPCB) - movl %ecx, PCPU(CURTHREAD) /* into next thread */ - - /* - * Determine the LDT to use and load it if is the default one and - * that is not the current one. - */ - movl TD_PROC(%ecx),%eax - cmpl $0,P_MD+MD_LDT(%eax) - jnz 1f - movl _default_ldt,%eax - cmpl PCPU(CURRENTLDT),%eax - je 2f - lldt _default_ldt - movl %eax,PCPU(CURRENTLDT) - jmp 2f -1: - /* Load the LDT when it is not the default one. */ - pushl %edx /* Preserve pointer to pcb. */ - addl $P_MD,%eax /* Pointer to mdproc is arg. */ - pushl %eax - /* - * Holding dt_lock prevents context switches, so dt_lock cannot - * be held now and set_user_ldt() will not deadlock acquiring it. - */ - call set_user_ldt - addl $4,%esp - popl %edx -2: - - /* This must be done after loading the user LDT. */ - .globl cpu_switch_load_gs -cpu_switch_load_gs: - mov PCB_GS(%edx),%gs - - pushl %edx - pushl PCPU(CURTHREAD) - call npxswitch - popl %edx - popl %edx - - /* Test if debug registers should be restored. */ - testl $PCB_DBREGS,PCB_FLAGS(%edx) - jz 1f - - /* - * Restore debug registers. The special code for dr7 is to - * preserve the current values of its reserved bits. - */ - movl PCB_DR6(%edx),%eax - movl %eax,%dr6 - movl PCB_DR3(%edx),%eax - movl %eax,%dr3 - movl PCB_DR2(%edx),%eax - movl %eax,%dr2 - movl PCB_DR1(%edx),%eax - movl %eax,%dr1 - movl PCB_DR0(%edx),%eax - movl %eax,%dr0 - movl %dr7,%eax - andl $0x0000fc00,%eax - movl PCB_DR7(%edx),%ecx - andl $~0x0000fc00,%ecx - orl %ecx,%eax - movl %eax,%dr7 -1: - ret - -#ifdef INVARIANTS -badsw1: - pushal - pushl $sw0_1 - call panic -sw0_1: .asciz "cpu_throw: no newthread supplied" - -badsw2: - pushal - pushl $sw0_2 - call panic -sw0_2: .asciz "cpu_switch: no curthread supplied" - -badsw3: - pushal - pushl $sw0_3 - call panic -sw0_3: .asciz "cpu_switch: no newthread supplied" -#endif -END(cpu_switch) - -/* - * savectx(pcb) - * Update pcb, saving current processor state. - */ -ENTRY(savectx) - /* Fetch PCB. */ - movl 4(%esp),%ecx - - /* Save caller's return address. Child won't execute this routine. */ - movl (%esp),%eax - movl %eax,PCB_EIP(%ecx) - - movl %cr3,%eax - movl %eax,PCB_CR3(%ecx) - - movl %ebx,PCB_EBX(%ecx) - movl %esp,PCB_ESP(%ecx) - movl %ebp,PCB_EBP(%ecx) - movl %esi,PCB_ESI(%ecx) - movl %edi,PCB_EDI(%ecx) - mov %gs,PCB_GS(%ecx) - - movl %cr0,%eax - movl %eax,PCB_CR0(%ecx) - movl %cr2,%eax - movl %eax,PCB_CR2(%ecx) - movl %cr4,%eax - movl %eax,PCB_CR4(%ecx) - - movl %dr0,%eax - movl %eax,PCB_DR0(%ecx) - movl %dr1,%eax - movl %eax,PCB_DR1(%ecx) - movl %dr2,%eax - movl %eax,PCB_DR2(%ecx) - movl %dr3,%eax - movl %eax,PCB_DR3(%ecx) - movl %dr6,%eax - movl %eax,PCB_DR6(%ecx) - movl %dr7,%eax - movl %eax,PCB_DR7(%ecx) - - mov %ds,PCB_DS(%ecx) - mov %es,PCB_ES(%ecx) - mov %fs,PCB_FS(%ecx) - mov %ss,PCB_SS(%ecx) - - sgdt PCB_GDT(%ecx) - sidt PCB_IDT(%ecx) - sldt PCB_LDT(%ecx) - str PCB_TR(%ecx) - - movl $1,%eax - ret -END(savectx) - -/* - * resumectx(pcb) __fastcall - * Resuming processor state from pcb. - */ -ENTRY(resumectx) - /* Restore GDT. */ - lgdt PCB_GDT(%ecx) - - /* Restore segment registers */ - movzwl PCB_DS(%ecx),%eax - mov %ax,%ds - movzwl PCB_ES(%ecx),%eax - mov %ax,%es - movzwl PCB_FS(%ecx),%eax - mov %ax,%fs - movzwl PCB_GS(%ecx),%eax - movw %ax,%gs - movzwl PCB_SS(%ecx),%eax - mov %ax,%ss - - /* Restore CR2, CR4, CR3 and CR0 */ - movl PCB_CR2(%ecx),%eax - movl %eax,%cr2 - movl PCB_CR4(%ecx),%eax - movl %eax,%cr4 - movl PCB_CR3(%ecx),%eax - movl %eax,%cr3 - movl PCB_CR0(%ecx),%eax - movl %eax,%cr0 - jmp 1f -1: - - /* Restore descriptor tables */ - lidt PCB_IDT(%ecx) - lldt PCB_LDT(%ecx) - -#define SDT_SYS386TSS 9 -#define SDT_SYS386BSY 11 - /* Clear "task busy" bit and reload TR */ - movl PCPU(TSS_GDT),%eax - andb $(~SDT_SYS386BSY | SDT_SYS386TSS),5(%eax) - movzwl PCB_TR(%ecx),%eax - ltr %ax -#undef SDT_SYS386TSS -#undef SDT_SYS386BSY - - /* Restore debug registers */ - movl PCB_DR0(%ecx),%eax - movl %eax,%dr0 - movl PCB_DR1(%ecx),%eax - movl %eax,%dr1 - movl PCB_DR2(%ecx),%eax - movl %eax,%dr2 - movl PCB_DR3(%ecx),%eax - movl %eax,%dr3 - movl PCB_DR6(%ecx),%eax - movl %eax,%dr6 - movl PCB_DR7(%ecx),%eax - movl %eax,%dr7 - - /* Restore other registers */ - movl PCB_EDI(%ecx),%edi - movl PCB_ESI(%ecx),%esi - movl PCB_EBP(%ecx),%ebp - movl PCB_ESP(%ecx),%esp - movl PCB_EBX(%ecx),%ebx - - /* reload code selector by turning return into intersegmental return */ - pushl PCB_EIP(%ecx) - movl $KCSEL,4(%esp) - xorl %eax,%eax - lret -END(resumectx) Index: sys/i386/i386/vm86bios.s =================================================================== --- /dev/null +++ sys/i386/i386/vm86bios.s @@ -1,173 +0,0 @@ -/*- - * Copyright (c) 1998 Jonathan Lemon - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include /* miscellaneous asm macros */ -#include - -#include "assym.inc" - -#define SCR_NEWPTD PCB_ESI /* readability macros */ -#define SCR_VMFRAME PCB_EBP /* see vm86.c for explanation */ -#define SCR_STACK PCB_ESP -#define SCR_PGTABLE PCB_EBX -#define SCR_ARGFRAME PCB_EIP -#define SCR_TSS0 PCB_VM86 -#define SCR_TSS1 (PCB_VM86+4) - - .data - ALIGN_DATA - - .globl vm86pcb - -vm86pcb: .long 0 - - .text - -/* - * vm86_bioscall(struct trapframe_vm86 *vm86) - */ -ENTRY(vm86_bioscall) - movl vm86pcb,%edx /* scratch data area */ - movl 4(%esp),%eax - movl %eax,SCR_ARGFRAME(%edx) /* save argument pointer */ - pushl %ebx - pushl %ebp - pushl %esi - pushl %edi - pushl %gs - - movl PCPU(CURTHREAD),%ecx - cmpl %ecx,PCPU(FPCURTHREAD) /* do we need to save fp? */ - jne 1f - pushl %edx - movl TD_PCB(%ecx),%ecx - pushl PCB_SAVEFPU(%ecx) - movl $npxsave,%eax - call *%eax - addl $4,%esp - popl %edx /* recover our pcb */ -1: - movl SCR_VMFRAME(%edx),%ebx /* target frame location */ - movl %ebx,%edi /* destination */ - movl SCR_ARGFRAME(%edx),%esi /* source (set on entry) */ - movl $VM86_FRAMESIZE/4,%ecx /* sizeof(struct vm86frame)/4 */ - cld - rep - movsl /* copy frame to new stack */ - - movl PCPU(CURPCB),%eax - pushl %eax /* save curpcb */ - movl %edx,PCPU(CURPCB) /* set curpcb to vm86pcb */ - - movl PCPU(TSS_GDT),%ebx /* entry in GDT */ - movl 0(%ebx),%eax - movl %eax,SCR_TSS0(%edx) /* save first word */ - movl 4(%ebx),%eax - andl $~0x200, %eax /* flip 386BSY -> 386TSS */ - movl %eax,SCR_TSS1(%edx) /* save second word */ - - movl PCB_EXT(%edx),%edi /* vm86 tssd entry */ - movl 0(%edi),%eax - movl %eax,0(%ebx) - movl 4(%edi),%eax - movl %eax,4(%ebx) - movl $GPROC0_SEL*8,%esi /* GSEL(entry, SEL_KPL) */ - ltr %si - - movl %cr3,%eax - pushl %eax /* save address space */ - cmpb $0,pae_mode - jne 2f - movl IdlePTD_nopae,%ecx /* va (and pa) of Idle PTD */ - jmp 3f -2: movl IdlePTD_pae,%ecx -3: movl %ecx,%ebx - movl 0(%ebx),%eax - pushl %eax /* old ptde != 0 when booting */ - pushl %ebx /* keep for reuse */ - - movl %esp,SCR_STACK(%edx) /* save current stack location */ - - movl SCR_NEWPTD(%edx),%eax /* mapping for vm86 page table */ - movl %eax,0(%ebx) /* ... install as PTD entry 0 */ - - cmpb $0,pae_mode - je 4f - movl IdlePDPT,%ecx -4: movl %ecx,%cr3 /* new page tables */ - movl SCR_VMFRAME(%edx),%esp /* switch to new stack */ - - pushl %esp - movl $vm86_prepcall, %eax - call *%eax /* finish setup */ - add $4, %esp - - /* - * Return via doreti - */ - jmp doreti - - -/* - * vm86_biosret(struct trapframe_vm86 *vm86) - */ -ENTRY(vm86_biosret) - movl vm86pcb,%edx /* data area */ - - movl 4(%esp),%esi /* source */ - movl SCR_ARGFRAME(%edx),%edi /* destination */ - movl $VM86_FRAMESIZE/4,%ecx /* size */ - cld - rep - movsl /* copy frame to original frame */ - - movl SCR_STACK(%edx),%esp /* back to old stack */ - popl %ebx /* saved va of Idle PTD */ - popl %eax - movl %eax,0(%ebx) /* restore old pte */ - popl %eax - movl %eax,%cr3 /* install old page table */ - - movl PCPU(TSS_GDT),%ebx /* entry in GDT */ - movl SCR_TSS0(%edx),%eax - movl %eax,0(%ebx) /* restore first word */ - movl SCR_TSS1(%edx),%eax - movl %eax,4(%ebx) /* restore second word */ - movl $GPROC0_SEL*8,%esi /* GSEL(entry, SEL_KPL) */ - ltr %si - - popl PCPU(CURPCB) /* restore curpcb/curproc */ - movl SCR_ARGFRAME(%edx),%edx /* original stack frame */ - movl TF_TRAPNO(%edx),%eax /* return (trapno) */ - - popl %gs - popl %edi - popl %esi - popl %ebp - popl %ebx - ret /* back to our normal program */ Index: sys/i386/linux/linux_vdso.lds.s =================================================================== --- /dev/null +++ sys/i386/linux/linux_vdso.lds.s @@ -1,84 +0,0 @@ -/* - * Linker script for 32-bit vDSO. - * Copied from Linux kernel arch/x86/vdso/vdso-layout.lds.S - * and arch/x86/vdso/vdso32/vdso32.lds.S - * - * $FreeBSD$ - */ - -SECTIONS -{ - . = . + SIZEOF_HEADERS; - - .hash : { *(.hash) } :text - .gnu.hash : { *(.gnu.hash) } - .dynsym : { *(.dynsym) } - .dynstr : { *(.dynstr) } - .gnu.version : { *(.gnu.version) } - .gnu.version_d : { *(.gnu.version_d) } - .gnu.version_r : { *(.gnu.version_r) } - - .note : { *(.note.*) } :text :note - - .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr - .eh_frame : { KEEP (*(.eh_frame)) } :text - - .dynamic : { *(.dynamic) } :text :dynamic - - .rodata : { *(.rodata*) } :text - .data : { - *(.data*) - *(.sdata*) - *(.got.plt) *(.got) - *(.gnu.linkonce.d.*) - *(.bss*) - *(.dynbss*) - *(.gnu.linkonce.b.*) - } - - .altinstructions : { *(.altinstructions) } - .altinstr_replacement : { *(.altinstr_replacement) } - - . = ALIGN(0x100); - .text : { *(.text*) } :text =0x90909090 -} - -PHDRS -{ - text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */ - dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ - note PT_NOTE FLAGS(4); /* PF_R */ - eh_frame_hdr PT_GNU_EH_FRAME; -} - -VERSION -{ - LINUX_2.6 { - global: - __vdso_clock_gettime; - __vdso_gettimeofday; - __vdso_time; - __vdso_getcpu; - __vdso_clock_getres; - __vdso_clock_gettime64; - }; - - LINUX_2.5 { - global: - __kernel_vsyscall; - __kernel_sigreturn; - __kernel_rt_sigreturn; - local: *; - }; - - LINUX_0.0 { - global: - linux_platform; - kern_timekeep_base; - kern_tsc_selector; - kern_cpu_selector; - linux_vdso_sigcode; - linux_vdso_rt_sigcode; - local: *; - }; -} Index: sys/modules/linux/Makefile =================================================================== --- sys/modules/linux/Makefile +++ sys/modules/linux/Makefile @@ -24,7 +24,7 @@ VDSODEPS=linux_vdso_gettc_x86.inc .endif .if ${MACHINE_CPUARCH} == "amd64" -SRCS+= linux${SFX}_support.s +SRCS+= linux${SFX}_support.S SRCS+= linux_elf32.c .else SRCS+= linux_copyout.c @@ -85,7 +85,7 @@ ${LD} -m elf_i386 --shared --eh-frame-hdr -soname=linux-gate.so.1 \ --no-undefined --hash-style=both -warn-common -nostdlib \ --strip-debug -s --build-id=sha1 --Bsymbolic \ - -T${SRCTOP}/sys/${MACHINE}/linux${SFX}/linux${SFX}_vdso.lds.s \ + -T${SRCTOP}/sys/${MACHINE}/linux${SFX}/linux${SFX}_vdso.lds.S \ -o ${.TARGET} ${.ALLSRC:M*.o} .if ${MACHINE_CPUARCH} == "amd64" Index: sys/modules/linux64/Makefile =================================================================== --- sys/modules/linux64/Makefile +++ sys/modules/linux64/Makefile @@ -13,7 +13,7 @@ linux_sysvec.c linux_time.c linux_vdso.c linux_timer.c linux_rseq.c \ opt_compat.h opt_inet6.h opt_posix.h opt_usb.h \ vnode_if.h device_if.h bus_if.h \ - linux_support.s + linux_support.S .if ${MACHINE_CPUARCH} == "amd64" SRCS+= linux_dummy_x86.c .endif @@ -58,7 +58,7 @@ ${LD} --shared --eh-frame-hdr -soname=linux-vdso.so.1 \ --no-undefined --hash-style=both -warn-common -nostdlib \ --strip-debug -s --build-id=sha1 -Bsymbolic \ - -T${SRCTOP}/sys/${MACHINE}/linux/linux_vdso.lds.s \ + -T${SRCTOP}/sys/${MACHINE}/linux/linux_vdso.lds.S \ -o ${.TARGET} ${.ALLSRC:M*.o} .if ${MACHINE_CPUARCH} == "aarch64"