]> xenbits.xensource.com Git - people/aperard/linux.git/commitdiff
riscv: Introduce set_compat_task() in asm/compat.h
authorLeonardo Bras <leobras@redhat.com>
Wed, 3 Jan 2024 16:00:23 +0000 (13:00 -0300)
committerPalmer Dabbelt <palmer@rivosinc.com>
Tue, 19 Mar 2024 23:39:40 +0000 (16:39 -0700)
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>
arch/riscv/include/asm/compat.h
arch/riscv/include/asm/elf.h

index da4b28cd01a9563f47cf1b4af4bf2cd57764feec..aa103530a5c83a501ac00c0e00c5e15f8e6a59a9 100644 (file)
@@ -28,6 +28,14 @@ static inline int is_compat_thread(struct thread_info *thread)
        return test_ti_thread_flag(thread, TIF_32BIT);
 }
 
+static inline void set_compat_task(bool is_compat)
+{
+       if (is_compat)
+               set_thread_flag(TIF_32BIT);
+       else
+               clear_thread_flag(TIF_32BIT);
+}
+
 struct compat_user_regs_struct {
        compat_ulong_t pc;
        compat_ulong_t ra;
index 2e88257cafaead98e53d5a17a60655876910f86d..c7aea7886d22aaede04dba348c38779f139c31ee 100644 (file)
@@ -135,10 +135,7 @@ do {                                                       \
 #ifdef CONFIG_COMPAT
 
 #define SET_PERSONALITY(ex)                                    \
-do {    if ((ex).e_ident[EI_CLASS] == ELFCLASS32)              \
-               set_thread_flag(TIF_32BIT);                     \
-       else                                                    \
-               clear_thread_flag(TIF_32BIT);                   \
+do {   set_compat_task((ex).e_ident[EI_CLASS] == ELFCLASS32);  \
        if (personality(current->personality) != PER_LINUX32)   \
                set_personality(PER_LINUX |                     \
                        (current->personality & (~PER_MASK)));  \