Skip to content

Commit d1e5ca6

Browse files
thule-vincenzowildea01
authored andcommitted
arm64: compat: Split kuser32
To make it possible to disable kuser helpers in aarch32 we need to divide the kuser and the sigreturn functionalities. Split the current version of kuser32 in kuser32 (for kuser helpers) and sigreturn32 (for sigreturn helpers). Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 0d747f6 commit d1e5ca6

3 files changed

Lines changed: 50 additions & 57 deletions

File tree

‎arch/arm64/kernel/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE
2828
$(call if_changed,objcopy)
2929

3030
obj-$(CONFIG_COMPAT) += sys32.o kuser32.o signal32.o \
31-
sys_compat.o
31+
sigreturn32.o sys_compat.o
3232
obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o
3333
obj-$(CONFIG_MODULES) += module.o
3434
obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o

‎arch/arm64/kernel/kuser32.S‎

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
12
/*
2-
* Low-level user helpers placed in the vectors page for AArch32.
3+
* AArch32 user helpers.
34
* Based on the kuser helpers in arch/arm/kernel/entry-armv.S.
45
*
56
* Copyright (C) 2005-2011 Nicolas Pitre <nico@fluxnic.net>
6-
* Copyright (C) 2012 ARM Ltd.
7-
*
8-
* This program is free software; you can redistribute it and/or modify
9-
* it under the terms of the GNU General Public License version 2 as
10-
* published by the Free Software Foundation.
11-
*
12-
* This program is distributed in the hope that it will be useful,
13-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15-
* GNU General Public License for more details.
16-
*
17-
* You should have received a copy of the GNU General Public License
18-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19-
*
20-
*
21-
* AArch32 user helpers.
7+
* Copyright (C) 2012-2018 ARM Ltd.
228
*
239
* Each segment is 32-byte aligned and will be moved to the top of the high
2410
* vector page. New segments (if ever needed) must be added in front of
@@ -77,42 +63,3 @@ __kuser_helper_version: // 0xffff0ffc
7763
.word ((__kuser_helper_end - __kuser_helper_start) >> 5)
7864
.globl __kuser_helper_end
7965
__kuser_helper_end:
80-
81-
/*
82-
* AArch32 sigreturn code
83-
*
84-
* For ARM syscalls, the syscall number has to be loaded into r7.
85-
* We do not support an OABI userspace.
86-
*
87-
* For Thumb syscalls, we also pass the syscall number via r7. We therefore
88-
* need two 16-bit instructions.
89-
*/
90-
.globl __aarch32_sigret_code_start
91-
__aarch32_sigret_code_start:
92-
93-
/*
94-
* ARM Code
95-
*/
96-
.byte __NR_compat_sigreturn, 0x70, 0xa0, 0xe3 // mov r7, #__NR_compat_sigreturn
97-
.byte __NR_compat_sigreturn, 0x00, 0x00, 0xef // svc #__NR_compat_sigreturn
98-
99-
/*
100-
* Thumb code
101-
*/
102-
.byte __NR_compat_sigreturn, 0x27 // svc #__NR_compat_sigreturn
103-
.byte __NR_compat_sigreturn, 0xdf // mov r7, #__NR_compat_sigreturn
104-
105-
/*
106-
* ARM code
107-
*/
108-
.byte __NR_compat_rt_sigreturn, 0x70, 0xa0, 0xe3 // mov r7, #__NR_compat_rt_sigreturn
109-
.byte __NR_compat_rt_sigreturn, 0x00, 0x00, 0xef // svc #__NR_compat_rt_sigreturn
110-
111-
/*
112-
* Thumb code
113-
*/
114-
.byte __NR_compat_rt_sigreturn, 0x27 // svc #__NR_compat_rt_sigreturn
115-
.byte __NR_compat_rt_sigreturn, 0xdf // mov r7, #__NR_compat_rt_sigreturn
116-
117-
.globl __aarch32_sigret_code_end
118-
__aarch32_sigret_code_end:

‎arch/arm64/kernel/sigreturn32.S‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* AArch32 sigreturn code.
4+
* Based on the kuser helpers in arch/arm/kernel/entry-armv.S.
5+
*
6+
* Copyright (C) 2005-2011 Nicolas Pitre <nico@fluxnic.net>
7+
* Copyright (C) 2012-2018 ARM Ltd.
8+
*
9+
* For ARM syscalls, the syscall number has to be loaded into r7.
10+
* We do not support an OABI userspace.
11+
*
12+
* For Thumb syscalls, we also pass the syscall number via r7. We therefore
13+
* need two 16-bit instructions.
14+
*/
15+
16+
#include <asm/unistd.h>
17+
18+
.globl __aarch32_sigret_code_start
19+
__aarch32_sigret_code_start:
20+
21+
/*
22+
* ARM Code
23+
*/
24+
.byte __NR_compat_sigreturn, 0x70, 0xa0, 0xe3 // mov r7, #__NR_compat_sigreturn
25+
.byte __NR_compat_sigreturn, 0x00, 0x00, 0xef // svc #__NR_compat_sigreturn
26+
27+
/*
28+
* Thumb code
29+
*/
30+
.byte __NR_compat_sigreturn, 0x27 // svc #__NR_compat_sigreturn
31+
.byte __NR_compat_sigreturn, 0xdf // mov r7, #__NR_compat_sigreturn
32+
33+
/*
34+
* ARM code
35+
*/
36+
.byte __NR_compat_rt_sigreturn, 0x70, 0xa0, 0xe3 // mov r7, #__NR_compat_rt_sigreturn
37+
.byte __NR_compat_rt_sigreturn, 0x00, 0x00, 0xef // svc #__NR_compat_rt_sigreturn
38+
39+
/*
40+
* Thumb code
41+
*/
42+
.byte __NR_compat_rt_sigreturn, 0x27 // svc #__NR_compat_rt_sigreturn
43+
.byte __NR_compat_rt_sigreturn, 0xdf // mov r7, #__NR_compat_rt_sigreturn
44+
45+
.globl __aarch32_sigret_code_end
46+
__aarch32_sigret_code_end:

0 commit comments

Comments
 (0)