Skip to content

Commit 2a8986f

Browse files
Leonardo Braspalmer-dabbelt
authored andcommitted
riscv: Introduce set_compat_task() in asm/compat.h
In order to have all task compat bit access directly in compat.h, introduce set_compat_task() to set/reset those when needed. Also, since it's only used on an if/else scenario, simplify the macro using it. Signed-off-by: Leonardo Bras <leobras@redhat.com> Reviewed-by: Guo Ren <guoren@kernel.org> Link: https://lore.kernel.org/r/20240103160024.70305-7-leobras@redhat.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 5917ea1 commit 2a8986f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

arch/riscv/include/asm/compat.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ static inline int is_compat_thread(struct thread_info *thread)
2828
return test_ti_thread_flag(thread, TIF_32BIT);
2929
}
3030

31+
static inline void set_compat_task(bool is_compat)
32+
{
33+
if (is_compat)
34+
set_thread_flag(TIF_32BIT);
35+
else
36+
clear_thread_flag(TIF_32BIT);
37+
}
38+
3139
struct compat_user_regs_struct {
3240
compat_ulong_t pc;
3341
compat_ulong_t ra;

arch/riscv/include/asm/elf.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ do { \
135135
#ifdef CONFIG_COMPAT
136136

137137
#define SET_PERSONALITY(ex) \
138-
do { if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
139-
set_thread_flag(TIF_32BIT); \
140-
else \
141-
clear_thread_flag(TIF_32BIT); \
138+
do { set_compat_task((ex).e_ident[EI_CLASS] == ELFCLASS32); \
142139
if (personality(current->personality) != PER_LINUX32) \
143140
set_personality(PER_LINUX | \
144141
(current->personality & (~PER_MASK))); \

0 commit comments

Comments
 (0)