Skip to content

Commit 55b8954

Browse files
Matthew Leachctmarinas
authored andcommitted
arm64: compat: correct register concatenation for syscall wrappers
The arm64 port contains wrappers for arm32 syscalls that pass 64-bit values. These wrappers concatenate the two registers to hold a 64-bit value in a single X register. On BE, however, the lower and higher words are swapped. Create a new assembler macro, regs_to_64, that when on BE systems swaps the registers in the orr instruction. Acked-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Matthew Leach <matthew.leach@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent a795a38 commit 55b8954

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

‎arch/arm64/include/asm/assembler.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,15 @@ lr .req x30 // link register
115115
.align 7
116116
b \label
117117
.endm
118+
/*
119+
* Define a macro that constructs a 64-bit value by concatenating two
120+
* 32-bit registers. Note that on big endian systems the order of the
121+
* registers is swapped.
122+
*/
123+
#ifndef CONFIG_CPU_BIG_ENDIAN
124+
.macro regs_to_64, rd, lbits, hbits
125+
#else
126+
.macro regs_to_64, rd, hbits, lbits
127+
#endif
128+
orr \rd, \lbits, \hbits, lsl #32
129+
.endm

‎arch/arm64/kernel/sys32.S‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,48 +59,48 @@ ENDPROC(compat_sys_fstatfs64_wrapper)
5959
* extension.
6060
*/
6161
compat_sys_pread64_wrapper:
62-
orr x3, x4, x5, lsl #32
62+
regs_to_64 x3, x4, x5
6363
b sys_pread64
6464
ENDPROC(compat_sys_pread64_wrapper)
6565

6666
compat_sys_pwrite64_wrapper:
67-
orr x3, x4, x5, lsl #32
67+
regs_to_64 x3, x4, x5
6868
b sys_pwrite64
6969
ENDPROC(compat_sys_pwrite64_wrapper)
7070

7171
compat_sys_truncate64_wrapper:
72-
orr x1, x2, x3, lsl #32
72+
regs_to_64 x1, x2, x3
7373
b sys_truncate
7474
ENDPROC(compat_sys_truncate64_wrapper)
7575

7676
compat_sys_ftruncate64_wrapper:
77-
orr x1, x2, x3, lsl #32
77+
regs_to_64 x1, x2, x3
7878
b sys_ftruncate
7979
ENDPROC(compat_sys_ftruncate64_wrapper)
8080

8181
compat_sys_readahead_wrapper:
82-
orr x1, x2, x3, lsl #32
82+
regs_to_64 x1, x2, x3
8383
mov w2, w4
8484
b sys_readahead
8585
ENDPROC(compat_sys_readahead_wrapper)
8686

8787
compat_sys_fadvise64_64_wrapper:
8888
mov w6, w1
89-
orr x1, x2, x3, lsl #32
90-
orr x2, x4, x5, lsl #32
89+
regs_to_64 x1, x2, x3
90+
regs_to_64 x2, x4, x5
9191
mov w3, w6
9292
b sys_fadvise64_64
9393
ENDPROC(compat_sys_fadvise64_64_wrapper)
9494

9595
compat_sys_sync_file_range2_wrapper:
96-
orr x2, x2, x3, lsl #32
97-
orr x3, x4, x5, lsl #32
96+
regs_to_64 x2, x2, x3
97+
regs_to_64 x3, x4, x5
9898
b sys_sync_file_range2
9999
ENDPROC(compat_sys_sync_file_range2_wrapper)
100100

101101
compat_sys_fallocate_wrapper:
102-
orr x2, x2, x3, lsl #32
103-
orr x3, x4, x5, lsl #32
102+
regs_to_64 x2, x2, x3
103+
regs_to_64 x3, x4, x5
104104
b sys_fallocate
105105
ENDPROC(compat_sys_fallocate_wrapper)
106106

0 commit comments

Comments
 (0)