Vincenzo Frascino | d1e5ca6 | 2019-04-15 10:49:35 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 2 | /* |
Vincenzo Frascino | d1e5ca6 | 2019-04-15 10:49:35 +0100 | [diff] [blame] | 3 | * AArch32 user helpers. |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 4 | * Based on the kuser helpers in arch/arm/kernel/entry-armv.S. |
| 5 | * |
| 6 | * Copyright (C) 2005-2011 Nicolas Pitre <nico@fluxnic.net> |
Vincenzo Frascino | d1e5ca6 | 2019-04-15 10:49:35 +0100 | [diff] [blame] | 7 | * Copyright (C) 2012-2018 ARM Ltd. |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 8 | * |
Vincenzo Frascino | af1b3cf | 2019-04-15 10:49:37 +0100 | [diff] [blame] | 9 | * The kuser helpers below are mapped at a fixed address by |
| 10 | * aarch32_setup_additional_pages() and are provided for compatibility |
| 11 | * reasons with 32 bit (aarch32) applications that need them. |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 12 | * |
Mauro Carvalho Chehab | dc7a12b | 2019-04-14 15:51:10 -0300 | [diff] [blame] | 13 | * See Documentation/arm/kernel_user_helpers.rst for formal definitions. |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 14 | */ |
Matthew Leach | a1d5eba | 2013-10-11 14:52:14 +0100 | [diff] [blame] | 15 | |
Catalin Marinas | f3e5c84 | 2014-01-30 17:56:56 +0000 | [diff] [blame] | 16 | #include <asm/unistd.h> |
Matthew Leach | a1d5eba | 2013-10-11 14:52:14 +0100 | [diff] [blame] | 17 | |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 18 | .align 5 |
| 19 | .globl __kuser_helper_start |
| 20 | __kuser_helper_start: |
| 21 | |
| 22 | __kuser_cmpxchg64: // 0xffff0f60 |
| 23 | .inst 0xe92d00f0 // push {r4, r5, r6, r7} |
| 24 | .inst 0xe1c040d0 // ldrd r4, r5, [r0] |
| 25 | .inst 0xe1c160d0 // ldrd r6, r7, [r1] |
Will Deacon | 8e86f0b | 2014-02-04 12:29:12 +0000 | [diff] [blame] | 26 | .inst 0xe1b20f9f // 1: ldrexd r0, r1, [r2] |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 27 | .inst 0xe0303004 // eors r3, r0, r4 |
| 28 | .inst 0x00313005 // eoreqs r3, r1, r5 |
Robin Murphy | d0f38f9 | 2013-10-07 18:30:34 +0100 | [diff] [blame] | 29 | .inst 0x01a23e96 // stlexdeq r3, r6, [r2] |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 30 | .inst 0x03330001 // teqeq r3, #1 |
| 31 | .inst 0x0afffff9 // beq 1b |
Will Deacon | 8e86f0b | 2014-02-04 12:29:12 +0000 | [diff] [blame] | 32 | .inst 0xf57ff05b // dmb ish |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 33 | .inst 0xe2730000 // rsbs r0, r3, #0 |
| 34 | .inst 0xe8bd00f0 // pop {r4, r5, r6, r7} |
| 35 | .inst 0xe12fff1e // bx lr |
| 36 | |
| 37 | .align 5 |
| 38 | __kuser_memory_barrier: // 0xffff0fa0 |
Robin Murphy | d0f38f9 | 2013-10-07 18:30:34 +0100 | [diff] [blame] | 39 | .inst 0xf57ff05b // dmb ish |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 40 | .inst 0xe12fff1e // bx lr |
| 41 | |
| 42 | .align 5 |
| 43 | __kuser_cmpxchg: // 0xffff0fc0 |
Will Deacon | 8e86f0b | 2014-02-04 12:29:12 +0000 | [diff] [blame] | 44 | .inst 0xe1923f9f // 1: ldrex r3, [r2] |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 45 | .inst 0xe0533000 // subs r3, r3, r0 |
Robin Murphy | d0f38f9 | 2013-10-07 18:30:34 +0100 | [diff] [blame] | 46 | .inst 0x01823e91 // stlexeq r3, r1, [r2] |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 47 | .inst 0x03330001 // teqeq r3, #1 |
| 48 | .inst 0x0afffffa // beq 1b |
Will Deacon | 8e86f0b | 2014-02-04 12:29:12 +0000 | [diff] [blame] | 49 | .inst 0xf57ff05b // dmb ish |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 50 | .inst 0xe2730000 // rsbs r0, r3, #0 |
Robin Murphy | d0f38f9 | 2013-10-07 18:30:34 +0100 | [diff] [blame] | 51 | .inst 0xe12fff1e // bx lr |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 52 | |
| 53 | .align 5 |
| 54 | __kuser_get_tls: // 0xffff0fe0 |
| 55 | .inst 0xee1d0f70 // mrc p15, 0, r0, c13, c0, 3 |
| 56 | .inst 0xe12fff1e // bx lr |
| 57 | .rep 5 |
| 58 | .word 0 |
| 59 | .endr |
| 60 | |
| 61 | __kuser_helper_version: // 0xffff0ffc |
| 62 | .word ((__kuser_helper_end - __kuser_helper_start) >> 5) |
| 63 | .globl __kuser_helper_end |
| 64 | __kuser_helper_end: |