Home | History | Annotate | Line # | Download | only in aarch64
linux32_sigcode.S revision 1.1
      1  1.1  ryo /*	$NetBSD: linux32_sigcode.S,v 1.1 2021/11/25 03:08:04 ryo Exp $	*/
      2  1.1  ryo 
      3  1.1  ryo /*-
      4  1.1  ryo  * Copyright (c) 2021 Ryo Shimizu <ryo (at) nerv.org>
      5  1.1  ryo  * All rights reserved.
      6  1.1  ryo  *
      7  1.1  ryo  * Redistribution and use in source and binary forms, with or without
      8  1.1  ryo  * modification, are permitted provided that the following conditions
      9  1.1  ryo  * are met:
     10  1.1  ryo  * 1. Redistributions of source code must retain the above copyright
     11  1.1  ryo  *    notice, this list of conditions and the following disclaimer.
     12  1.1  ryo  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  ryo  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  ryo  *    documentation and/or other materials provided with the distribution.
     15  1.1  ryo  *
     16  1.1  ryo  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     17  1.1  ryo  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     18  1.1  ryo  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  1.1  ryo  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     20  1.1  ryo  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     21  1.1  ryo  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     22  1.1  ryo  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  1.1  ryo  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     24  1.1  ryo  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     25  1.1  ryo  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.1  ryo  * POSSIBILITY OF SUCH DAMAGE.
     27  1.1  ryo  */
     28  1.1  ryo 
     29  1.1  ryo #include <machine/asm.h>
     30  1.1  ryo 
     31  1.1  ryo RCSID("$NetBSD: linux32_sigcode.S,v 1.1 2021/11/25 03:08:04 ryo Exp $")
     32  1.1  ryo 
     33  1.1  ryo #include <compat/linux32/linux32_syscall.h>
     34  1.1  ryo 
     35  1.1  ryo /*
     36  1.1  ryo  * linux aarch32 Signal trampoline code
     37  1.1  ryo  */
     38  1.1  ryo 	.text
     39  1.1  ryo 	.section .rodata
     40  1.1  ryo 	.align 12
     41  1.1  ryo 
     42  1.1  ryo 	.global	_C_LABEL(linux32_sigcode)
     43  1.1  ryo _C_LABEL(linux32_sigcode):
     44  1.1  ryo 	/* mov r7, #LINUX32_SYS_sigreturn */
     45  1.1  ryo 	.word	0xe3a07000 + LINUX32_SYS_sigreturn
     46  1.1  ryo 	.word	0xef000000	/* svc 0   */
     47  1.1  ryo 	/* NOTREACHED */
     48  1.1  ryo 	.word	0xe7f000f0	/* udf #0  */
     49  1.1  ryo 
     50  1.1  ryo 	.global	_C_LABEL(linux32_rt_sigcode)
     51  1.1  ryo _C_LABEL(linux32_rt_sigcode):
     52  1.1  ryo 	/* mov r7, #LINUX32_SYS_rt_sigreturn */
     53  1.1  ryo 	.word	0xe3a07000 + LINUX32_SYS_rt_sigreturn
     54  1.1  ryo 	.word	0xef000000	/* svc 0   */
     55  1.1  ryo 	/* NOTREACHED */
     56  1.1  ryo 	.word	0xe7f000f0	/* udf #0  */
     57  1.1  ryo 
     58  1.1  ryo /*
     59  1.1  ryo  * linux/arm kuser_helper
     60  1.1  ryo  *   - should be mapped on userspace vaddr 0xffff0f60
     61  1.1  ryo  *   - https://www.kernel.org/doc/Documentation/arm/kernel_user_helpers.txt
     62  1.1  ryo  */
     63  1.1  ryo 
     64  1.1  ryo .kuser_helper_pad:
     65  1.1  ryo #define KUSER_HELPER_START	0x00000f60
     66  1.1  ryo 	.space	KUSER_HELPER_START - (.kuser_helper_pad - _C_LABEL(linux32_sigcode))
     67  1.1  ryo 
     68  1.1  ryo /*
     69  1.1  ryo  * 0xffff0f60
     70  1.1  ryo  * int __kuser_cmpxchg64(const int64_t *oldval, const int64_t *newval, volatile int64_t *ptr);
     71  1.1  ryo  */
     72  1.1  ryo .__kuser_cmpxchg64:
     73  1.1  ryo 	.word	0xe92d00f0	/* push {r4, r5, r6, r7}  */
     74  1.1  ryo 	.word	0xf57ff05f	/* dmb sy                 */
     75  1.1  ryo 	.word	0xe1c040d0	/* ldrd r4, [r0]          */
     76  1.1  ryo 	.word	0xe1c160d0	/* ldrd r6, [r1]          */
     77  1.1  ryo 	.word	0xe1b20f9f	/* ldrexd r0, [r2]        */
     78  1.1  ryo 	.word	0xe0500004	/* subs r0, r0, r4        */
     79  1.1  ryo 	.word	0xe0c11005	/* sbc r1, r1, r5         */
     80  1.1  ryo 	.word	0xe1900001	/* orrs r0, r0, r1        */
     81  1.1  ryo 	.word	0x01a20f96	/* strexdeq r0, r6, [r2]  */
     82  1.1  ryo 	.word	0xf57ff05f	/* dmb sy                 */
     83  1.1  ryo 	.word	0xe8bd00f0	/* pop {r4, r5, r6, r7}   */
     84  1.1  ryo 	.word	0xe12fff1e	/* bx lr                  */
     85  1.1  ryo 
     86  1.1  ryo 	.align	5
     87  1.1  ryo /*
     88  1.1  ryo  * 0xffff0fa0
     89  1.1  ryo  * void __kuser_memory_barrier(void);
     90  1.1  ryo  */
     91  1.1  ryo .__kuser_memory_barrier:
     92  1.1  ryo 	.word	0xf57ff05f	/* dmb sy  */
     93  1.1  ryo 	.word	0xe12fff1e	/* bx lr   */
     94  1.1  ryo 
     95  1.1  ryo 	.align	5
     96  1.1  ryo /*
     97  1.1  ryo  * 0xffff0fc0
     98  1.1  ryo  * int __kuser_cmpxchg(int32_t oldval, int32_t newval, volatile int32_t *ptr);
     99  1.1  ryo  */
    100  1.1  ryo .__kuser_cmpxchg:
    101  1.1  ryo 	.word	0xf57ff05f	/* dmb sy                */
    102  1.1  ryo 	.word	0xe1923f9f	/* ldrex r3, [r2]        */
    103  1.1  ryo 	.word	0xe0530000	/* subs r0, r3, r0       */
    104  1.1  ryo 	.word	0x01820f91	/* strexeq r0, r1, [r2]  */
    105  1.1  ryo 	.word	0xf57ff05f	/* dmb sy                */
    106  1.1  ryo 	.word	0xe12fff1e	/* bx lr                 */
    107  1.1  ryo 
    108  1.1  ryo 
    109  1.1  ryo 	.align	5
    110  1.1  ryo /* 0xffff0fe0 */
    111  1.1  ryo .__kuser_get_tls:
    112  1.1  ryo 	.word	0xee1d0f70	/* mrc p15, 0, r0, c13, c0, 3  */
    113  1.1  ryo 	.word	0xe12fff1e	/* bx lr                       */
    114  1.1  ryo 
    115  1.1  ryo 	.align	4
    116  1.1  ryo /* 0xffff0ff0 */
    117  1.1  ryo 	.word	0
    118  1.1  ryo /* 0xffff0ff4 */
    119  1.1  ryo 	.word	0
    120  1.1  ryo /* 0xffff0ff8 */
    121  1.1  ryo 	.word	0
    122  1.1  ryo 
    123  1.1  ryo /* 0xffff0ffc */
    124  1.1  ryo .__kuser_helper_version:
    125  1.1  ryo 	.word	2
    126  1.1  ryo 
    127  1.1  ryo 
    128  1.1  ryo 	.global	_C_LABEL(linux32_esigcode)
    129  1.1  ryo _C_LABEL(linux32_esigcode):
    130