diff options
author | Chris Williamson <[email protected]> | 2018-02-08 09:16:23 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-02-08 15:28:18 -0800 |
commit | d99a015343425a1c856c900aa8223016400ac2dc (patch) | |
tree | f6ab517b27b650c32127953b74567baa99951d08 /module/lua/setjmp | |
parent | 8824a7f133e4402f7176115cf8efd535c8cbdab2 (diff) |
OpenZFS 7431 - ZFS Channel Programs
Authored by: Chris Williamson <[email protected]>
Reviewed by: Matthew Ahrens <[email protected]>
Reviewed by: George Wilson <[email protected]>
Reviewed by: John Kennedy <[email protected]>
Reviewed by: Dan Kimmel <[email protected]>
Approved by: Garrett D'Amore <[email protected]>
Ported-by: Don Brady <[email protected]>
Ported-by: John Kennedy <[email protected]>
OpenZFS-issue: https://www.illumos.org/issues/7431
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/dfc11533
Porting Notes:
* The CLI long option arguments for '-t' and '-m' don't parse on linux
* Switched from kmem_alloc to vmem_alloc in zcp_lua_alloc
* Lua implementation is built as its own module (zlua.ko)
* Lua headers consumed directly by zfs code moved to 'include/sys/lua/'
* There is no native setjmp/longjump available in stock Linux kernel.
Brought over implementations from illumos and FreeBSD
* The get_temporary_prop() was adapted due to VFS platform differences
* Use of inline functions in lua parser to reduce stack usage per C call
* Skip some ZFS Test Suite ZCP tests on sparc64 to avoid stack overflow
Diffstat (limited to 'module/lua/setjmp')
-rw-r--r-- | module/lua/setjmp/setjmp.S | 17 | ||||
-rw-r--r-- | module/lua/setjmp/setjmp_aarch64.S | 86 | ||||
-rw-r--r-- | module/lua/setjmp/setjmp_arm.S | 67 | ||||
-rw-r--r-- | module/lua/setjmp/setjmp_i386.S | 69 | ||||
-rw-r--r-- | module/lua/setjmp/setjmp_mips.S | 105 | ||||
-rw-r--r-- | module/lua/setjmp/setjmp_ppc.S | 165 | ||||
-rw-r--r-- | module/lua/setjmp/setjmp_s390x.S | 64 | ||||
-rw-r--r-- | module/lua/setjmp/setjmp_sparc64.S | 105 | ||||
-rw-r--r-- | module/lua/setjmp/setjmp_x86_64.S | 77 |
9 files changed, 755 insertions, 0 deletions
diff --git a/module/lua/setjmp/setjmp.S b/module/lua/setjmp/setjmp.S new file mode 100644 index 000000000..8d06d3f8c --- /dev/null +++ b/module/lua/setjmp/setjmp.S @@ -0,0 +1,17 @@ +#if defined(__x86_64__) +#include "setjmp_x86_64.S" +#elif defined(__i386__) +#include "setjmp_i386.S" +#elif defined(__aarch64__) +#include "setjmp_aarch64.S" +#elif defined(__arm__) +#include "setjmp_arm.S" +#elif defined(__sparc__) && defined(__arch64__) +#include "setjmp_sparc64.S" +#elif defined(__powerpc__) +#include "setjmp_ppc.S" +#elif defined(__mips__) +#include "setjmp_mips.S" +#elif defined(__s390x__) +#include "setjmp_s390x.S" +#endif diff --git a/module/lua/setjmp/setjmp_aarch64.S b/module/lua/setjmp/setjmp_aarch64.S new file mode 100644 index 000000000..a5a9a85fd --- /dev/null +++ b/module/lua/setjmp/setjmp_aarch64.S @@ -0,0 +1,86 @@ +/*- + * Copyright (c) 2014 Andrew Turner + * Copyright (c) 2014-2015 The FreeBSD Foundation + * All rights reserved. + * + * Portions of this software were developed by Andrew Turner + * 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. + * + */ + + +#ifdef __aarch64__ + +#define ENTRY(sym) \ + .text; \ + .globl sym; \ + .align 2; \ + .type sym,#function; \ +sym: + +#define END(sym) \ + .size sym, . - sym + + +ENTRY(setjmp) + /* Store the stack pointer */ + mov x8, sp + str x8, [x0], #8 + + /* Store the general purpose registers and lr */ + stp x19, x20, [x0], #16 + stp x21, x22, [x0], #16 + stp x23, x24, [x0], #16 + stp x25, x26, [x0], #16 + stp x27, x28, [x0], #16 + stp x29, x30, [x0], #16 + + /* Return value */ + mov x0, #0 + ret +END(setjmp) + +ENTRY(longjmp) + /* Restore the stack pointer */ + ldr x8, [x0], #8 + mov sp, x8 + + /* Restore the general purpose registers and lr */ + ldp x19, x20, [x0], #16 + ldp x21, x22, [x0], #16 + ldp x23, x24, [x0], #16 + ldp x25, x26, [x0], #16 + ldp x27, x28, [x0], #16 + ldp x29, x30, [x0], #16 + + /* Load the return value */ + mov x0, x1 + ret +END(longjmp) + +#ifdef __ELF__ +.section .note.GNU-stack,"",%progbits +#endif + +#endif /* __aarch64__ */ diff --git a/module/lua/setjmp/setjmp_arm.S b/module/lua/setjmp/setjmp_arm.S new file mode 100644 index 000000000..8c08f4e6f --- /dev/null +++ b/module/lua/setjmp/setjmp_arm.S @@ -0,0 +1,67 @@ +/*- + * Copyright 2004-2014 Olivier Houchard <[email protected]> + * Copyright 2012-2014 Ian Lepore <[email protected]> + * Copyright 2013-2014 Andrew Turner <[email protected]> + * Copyright 2014 Svatopluk Kraus <[email protected]> + * Copyright 2014 Michal Meloun <[email protected]> + * 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. + */ + + +#if defined(__arm__) && !defined(__aarch64__) + +#define ENTRY(x) \ + .text; \ + .align 2; \ + .global x; \ + .type x,#function; \ + .code 32; \ +x: + +#define END(x) \ + .size x, . - x; + +#define RET bx lr + + +/* + * setjump + longjmp + */ +ENTRY(setjmp) + stmia r0, {r4-r14} + mov r0, #0x00000000 + RET +END(setjmp) + +ENTRY(longjmp) + ldmia r0, {r4-r14} + mov r0, #0x00000001 + RET +END(longjmp) + +#ifdef __ELF__ +.section .note.GNU-stack,"",%progbits +#endif + +#endif diff --git a/module/lua/setjmp/setjmp_i386.S b/module/lua/setjmp/setjmp_i386.S new file mode 100644 index 000000000..6d6a5f332 --- /dev/null +++ b/module/lua/setjmp/setjmp_i386.S @@ -0,0 +1,69 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#define ENTRY(x) \ + .text; \ + .align 8; \ + .globl x; \ + .type x, @function; \ +x: + +#define SET_SIZE(x) \ + .size x, [.-x] + +/* + * Setjmp and longjmp implement non-local gotos using state vectors + * type label_t. + */ +#ifdef __i386__ + + ENTRY(setjmp) /* save area is passed in eax */ + movl %ebp, 0(%eax) /* save ebp */ + movl %ebx, 4(%eax) /* save ebx */ + movl %esi, 8(%eax) /* save esi */ + movl %edi, 12(%eax) /* save edi */ + movl %esp, 16(%eax) /* save esp */ + movl (%esp), %ecx /* %eip (return address) */ + movl %ecx, 20(%eax) /* save eip */ + subl %eax, %eax /* return 0 */ + ret + SET_SIZE(setjmp) + + ENTRY(longjmp) /* save area is passed in eax */ + movl 0(%eax), %ebp /* restore ebp */ + movl 4(%eax), %ebx /* restore ebx */ + movl 8(%eax), %esi /* restore esi */ + movl 12(%eax), %edi /* restore edi */ + movl 16(%eax), %esp /* restore esp */ + movl 20(%eax), %ecx /* %eip (return address) */ + addl $4, %esp /* pop ret adr */ + jmp *%ecx /* indirect jump */ + SET_SIZE(longjmp) + +#ifdef __ELF__ +.section .note.GNU-stack,"",%progbits +#endif + +#endif /* __i386__ */ diff --git a/module/lua/setjmp/setjmp_mips.S b/module/lua/setjmp/setjmp_mips.S new file mode 100644 index 000000000..0084fbfa4 --- /dev/null +++ b/module/lua/setjmp/setjmp_mips.S @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009 + * The President and Fellows of Harvard College. + * Copyright (c) 2017 MIPS Technologies, Inc. + * + * 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 UNIVERSITY 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 UNIVERSITY 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. + */ + +#include <asm/asm.h> +#include <asm/regdef.h> + +/* + * setjmp and longjmp for MIPS. + */ + + .text + .set noreorder + + /* + * int setjmp(jmp_buf jb); + * + * Save the current state so we can return again from the call later + * if/when longjmp is called. (If the function that called setjmp + * returns before longjmp is called, the results are undefined. We + * only need to save registers, not the whole contents of the stack.) + */ +LEAF(setjmp) + /* + * jmp_buf is in a0. We need to save s0-s8, sp, gp, and ra in it. + * Don't store more registers without adjusting machine/setjmp.h. + */ + + REG_S sp, 0(a0) /* save registers */ + REG_S ra, 1*SZREG(a0) + REG_S gp, 2*SZREG(a0) + REG_S s0, 3*SZREG(a0) + REG_S s1, 4*SZREG(a0) + REG_S s2, 5*SZREG(a0) + REG_S s3, 6*SZREG(a0) + REG_S s4, 7*SZREG(a0) + REG_S s5, 8*SZREG(a0) + REG_S s6, 9*SZREG(a0) + REG_S s7, 10*SZREG(a0) + REG_S s8, 11*SZREG(a0) + + jr ra /* done */ + move v0, zero /* return 0 (in delay slot) */ +END(setjmp) + + + /* + * void longjmp(jmp_buf jb, int code); + */ +LEAF(longjmp) + /* + * jmp_buf is in a0. Return code is in a1. + * We need to restore s0-s8, sp, gp, and ra from the jmp_buf. + * The return code is forced to 1 if 0 is passed in. + */ + + sltiu t0, a1, 1 /* set t0 to 1 if return code is 0... otherwise 0 */ + addu a1, a1, t0 /* update the return code */ + + REG_L sp, 0(a0) /* restore registers */ + REG_L ra, 1*SZREG(a0) + REG_L gp, 2*SZREG(a0) + REG_L s0, 3*SZREG(a0) + REG_L s1, 4*SZREG(a0) + REG_L s2, 5*SZREG(a0) + REG_L s3, 6*SZREG(a0) + REG_L s4, 7*SZREG(a0) + REG_L s5, 8*SZREG(a0) + REG_L s6, 9*SZREG(a0) + REG_L s7, 10*SZREG(a0) + REG_L s8, 11*SZREG(a0) + + jr ra /* return, to where setjmp was called from */ + move v0, a1 /* set return value */ +END(longjmp) + +#ifdef __ELF__ +.section .note.GNU-stack,"",%progbits +#endif diff --git a/module/lua/setjmp/setjmp_ppc.S b/module/lua/setjmp/setjmp_ppc.S new file mode 100644 index 000000000..f787ef349 --- /dev/null +++ b/module/lua/setjmp/setjmp_ppc.S @@ -0,0 +1,165 @@ +/* $FreeBSD$ */ +/* from: NetBSD: setjmp.S,v 1.1 1998/01/27 15:13:12 sakamoto Exp $ */ +/* from: OpenBSD: setjmp.S,v 1.2 1996/12/28 06:22:18 rahnds Exp */ +/* kernel version of this file, does not have signal goop */ +/* int setjmp(jmp_buf env) */ + +#define _ASM +#include <asm/types.h> + +#ifdef __powerpc64__ +#if !defined(PPC64_ELF_ABI_v2) && !defined(PPC64_ELF_ABI_v1) +#if defined(_CALL_ELF) && _CALL_ELF == 2 +#define PPC64_ELF_ABI_v2 +#endif /* _CALL_ELF */ +#endif /* PPC64_ELF_ABI_ */ +#endif /* __powerpc64__ */ + +#ifdef __powerpc64__ +#define LD_REG ld +#define ST_REG std +#define REGWIDTH 8 +#else +#define LD_REG lwz +#define ST_REG stw +#define REGWIDTH 4 +#endif /* __powerpc64__ */ + +#define JMP_r1 1*REGWIDTH +#define JMP_r2 2*REGWIDTH +#define JMP_r14 3*REGWIDTH +#define JMP_r15 4*REGWIDTH +#define JMP_r16 5*REGWIDTH +#define JMP_r17 6*REGWIDTH +#define JMP_r18 7*REGWIDTH +#define JMP_r19 8*REGWIDTH +#define JMP_r20 9*REGWIDTH +#define JMP_r21 10*REGWIDTH +#define JMP_r22 11*REGWIDTH +#define JMP_r23 12*REGWIDTH +#define JMP_r24 13*REGWIDTH +#define JMP_r25 14*REGWIDTH +#define JMP_r26 15*REGWIDTH +#define JMP_r27 16*REGWIDTH +#define JMP_r28 17*REGWIDTH +#define JMP_r29 18*REGWIDTH +#define JMP_r30 19*REGWIDTH +#define JMP_r31 20*REGWIDTH +#define JMP_lr 21*REGWIDTH +#define JMP_cr 22*REGWIDTH +#define JMP_ctr 23*REGWIDTH +#define JMP_xer 24*REGWIDTH + +#ifdef __powerpc64__ +#ifdef PPC64_ELF_ABI_v2 + +#define ENTRY(name) \ + .align 2 ; \ + .type name,@function; \ + .globl name; \ +name: + +#else /* PPC64_ELF_ABI_v1 */ + +#define XGLUE(a,b) a##b +#define GLUE(a,b) XGLUE(a,b) +#define ENTRY(name) \ + .align 2 ; \ + .globl name; \ + .globl GLUE(.,name); \ + .pushsection ".opd","aw"; \ +name: \ + .quad GLUE(.,name); \ + .quad .TOC.@tocbase; \ + .quad 0; \ + .popsection; \ + .type GLUE(.,name),@function; \ +GLUE(.,name): + +#endif /* PPC64_ELF_ABI_v2 */ + +#else /* 32-bit */ + +#define ENTRY(name) \ + .text; \ + .p2align 4; \ + .globl name; \ + .type name,@function; \ +name: + +#endif /* __powerpc64__ */ + + +ENTRY(setjmp) + ST_REG 31, JMP_r31(3) + /* r1, r2, r14-r30 */ + ST_REG 1, JMP_r1 (3) + ST_REG 2, JMP_r2 (3) + ST_REG 14, JMP_r14(3) + ST_REG 15, JMP_r15(3) + ST_REG 16, JMP_r16(3) + ST_REG 17, JMP_r17(3) + ST_REG 18, JMP_r18(3) + ST_REG 19, JMP_r19(3) + ST_REG 20, JMP_r20(3) + ST_REG 21, JMP_r21(3) + ST_REG 22, JMP_r22(3) + ST_REG 23, JMP_r23(3) + ST_REG 24, JMP_r24(3) + ST_REG 25, JMP_r25(3) + ST_REG 26, JMP_r26(3) + ST_REG 27, JMP_r27(3) + ST_REG 28, JMP_r28(3) + ST_REG 29, JMP_r29(3) + ST_REG 30, JMP_r30(3) + /* cr, lr, ctr, xer */ + mfcr 0 + ST_REG 0, JMP_cr(3) + mflr 0 + ST_REG 0, JMP_lr(3) + mfctr 0 + ST_REG 0, JMP_ctr(3) + mfxer 0 + ST_REG 0, JMP_xer(3) + /* f14-f31, fpscr */ + li 3, 0 + blr + +ENTRY(longjmp) + LD_REG 31, JMP_r31(3) + /* r1, r2, r14-r30 */ + LD_REG 1, JMP_r1 (3) + LD_REG 2, JMP_r2 (3) + LD_REG 14, JMP_r14(3) + LD_REG 15, JMP_r15(3) + LD_REG 16, JMP_r16(3) + LD_REG 17, JMP_r17(3) + LD_REG 18, JMP_r18(3) + LD_REG 19, JMP_r19(3) + LD_REG 20, JMP_r20(3) + LD_REG 21, JMP_r21(3) + LD_REG 22, JMP_r22(3) + LD_REG 23, JMP_r23(3) + LD_REG 24, JMP_r24(3) + LD_REG 25, JMP_r25(3) + LD_REG 26, JMP_r26(3) + LD_REG 27, JMP_r27(3) + LD_REG 28, JMP_r28(3) + LD_REG 29, JMP_r29(3) + LD_REG 30, JMP_r30(3) + /* cr, lr, ctr, xer */ + LD_REG 0, JMP_cr(3) + mtcr 0 + LD_REG 0, JMP_lr(3) + mtlr 0 + LD_REG 0, JMP_ctr(3) + mtctr 0 + LD_REG 0, JMP_xer(3) + mtxer 0 + /* f14-f31, fpscr */ + mr 3, 4 + blr + +#ifdef __ELF__ +.section .note.GNU-stack,"",%progbits +#endif diff --git a/module/lua/setjmp/setjmp_s390x.S b/module/lua/setjmp/setjmp_s390x.S new file mode 100644 index 000000000..336c66c08 --- /dev/null +++ b/module/lua/setjmp/setjmp_s390x.S @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2005-2014 Rich Felker, et al. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + .global setjmp + .type setjmp,@function +setjmp: + stmg %r6, %r15, 0(%r2) + + std %f8, 10*8(%r2) + std %f9, 11*8(%r2) + std %f10, 12*8(%r2) + std %f11, 13*8(%r2) + std %f12, 14*8(%r2) + std %f13, 15*8(%r2) + std %f14, 16*8(%r2) + std %f15, 17*8(%r2) + + lghi %r2, 0 + br %r14 + + .global longjmp + .type longjmp,@function +longjmp: + +1: + lmg %r6, %r15, 0(%r2) + + ld %f8, 10*8(%r2) + ld %f9, 11*8(%r2) + ld %f10, 12*8(%r2) + ld %f11, 13*8(%r2) + ld %f12, 14*8(%r2) + ld %f13, 15*8(%r2) + ld %f14, 16*8(%r2) + ld %f15, 17*8(%r2) + + ltgr %r2, %r3 + bnzr %r14 + lhi %r2, 1 + br %r14 + +#ifdef __ELF__ +.section .note.GNU-stack,"",%progbits +#endif diff --git a/module/lua/setjmp/setjmp_sparc64.S b/module/lua/setjmp/setjmp_sparc64.S new file mode 100644 index 000000000..a37a71cbc --- /dev/null +++ b/module/lua/setjmp/setjmp_sparc64.S @@ -0,0 +1,105 @@ +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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. + * 4. 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. + * + * $Header: _setjmp.s,v 1.1 91/07/06 16:45:53 torek Exp + */ + +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 + .asciz "@(#)_setjmp.s 8.1 (Berkeley) 6/4/93" +#else + RCSID("$NetBSD: _setjmp.S,v 1.4 1998/10/08 02:27:59 eeh Exp $") +#endif +#endif /* LIBC_SCCS and not lint */ + +#define _JB_FP 0x0 +#define _JB_PC 0x8 +#define _JB_SP 0x10 + + .register %g2,#ignore + .register %g3,#ignore + +#define ENTRY(x) \ + .text ; \ + .align 32 ; \ + .globl x ; \ + .type x,@function ; \ +x: + +#define END(x) \ + .size x, . - x + +/* + * C library -- setjmp, longjmp + * + * longjmp(a,v) + * will generate a "return(v?v:1)" from + * the last call to + * setjmp(a) + * by restoring the previous context. + */ + +ENTRY(setjmp) + stx %sp, [%o0 + _JB_SP] + stx %o7, [%o0 + _JB_PC] + stx %fp, [%o0 + _JB_FP] + retl + clr %o0 +END(setjmp) + +ENTRY(longjmp) + mov 1, %g1 + movrnz %o1, %o1, %g1 + mov %o0, %g2 + ldx [%g2 + _JB_FP], %g3 +1: cmp %fp, %g3 + bl,a 1b + restore + be,a 2f + ldx [%g2 + _JB_SP], %o0 + +.Lbotch: + illtrap + +2: cmp %o0, %sp + bge,a 3f + mov %o0, %sp + b,a .Lbotch + nop +3: ldx [%g2 + _JB_PC], %o7 + retl + mov %g1, %o0 +END(longjmp) + +#ifdef __ELF__ +.section .note.GNU-stack,"",%progbits +#endif diff --git a/module/lua/setjmp/setjmp_x86_64.S b/module/lua/setjmp/setjmp_x86_64.S new file mode 100644 index 000000000..a469cbad7 --- /dev/null +++ b/module/lua/setjmp/setjmp_x86_64.S @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. + */ + + +#define ENTRY(x) \ + .text; \ + .align 8; \ + .globl x; \ + .type x, @function; \ +x: + +#define SET_SIZE(x) \ + .size x, [.-x] + + +/* + * Setjmp and longjmp implement non-local gotos using state vectors + * type label_t. + */ +#ifdef __x86_64__ + + ENTRY(setjmp) + movq %rsp, 0(%rdi) + movq %rbp, 8(%rdi) + movq %rbx, 16(%rdi) + movq %r12, 24(%rdi) + movq %r13, 32(%rdi) + movq %r14, 40(%rdi) + movq %r15, 48(%rdi) + movq 0(%rsp), %rdx /* return address */ + movq %rdx, 56(%rdi) /* rip */ + xorl %eax, %eax /* return 0 */ + ret + SET_SIZE(setjmp) + + ENTRY(longjmp) + movq 0(%rdi), %rsp + movq 8(%rdi), %rbp + movq 16(%rdi), %rbx + movq 24(%rdi), %r12 + movq 32(%rdi), %r13 + movq 40(%rdi), %r14 + movq 48(%rdi), %r15 + movq 56(%rdi), %rdx /* return address */ + movq %rdx, 0(%rsp) + xorl %eax, %eax + incl %eax /* return 1 */ + ret + SET_SIZE(longjmp) + +#ifdef __ELF__ +.section .note.GNU-stack,"",%progbits +#endif + +#endif /* __x86_64__ */ |