[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240103160024.70305-7-leobras@redhat.com>
Date: Wed, 3 Jan 2024 13:00:23 -0300
From: Leonardo Bras <leobras@...hat.com>
To: Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
Eric Biederman <ebiederm@...ssion.com>,
Kees Cook <keescook@...omium.org>,
Oleg Nesterov <oleg@...hat.com>,
Leonardo Bras <leobras@...hat.com>,
Guo Ren <guoren@...nel.org>,
Andy Chiu <andy.chiu@...ive.com>,
Conor Dooley <conor.dooley@...rochip.com>,
Xiao Wang <xiao.w.wang@...el.com>,
Vincent Chen <vincent.chen@...ive.com>,
Charlie Jenkins <charlie@...osinc.com>,
Greg Ungerer <gerg@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Kemeng Shi <shikemeng@...weicloud.com>,
Alexandre Ghiti <alexghiti@...osinc.com>,
David Hildenbrand <david@...hat.com>,
"Matthew Wilcox (Oracle)" <willy@...radead.org>,
Qinglin Pan <panqinglin2020@...as.ac.cn>,
Greentime Hu <greentime.hu@...ive.com>,
Baoquan He <bhe@...hat.com>,
Clément Léger <cleger@...osinc.com>
Cc: linux-riscv@...ts.infradead.org,
linux-kernel@...r.kernel.org,
linux-mm@...ck.org
Subject: [PATCH v1 5/5] 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@...hat.com>
Reviewed-by: Guo Ren <guoren@...nel.org>
---
arch/riscv/include/asm/compat.h | 8 ++++++++
arch/riscv/include/asm/elf.h | 5 +----
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/arch/riscv/include/asm/compat.h b/arch/riscv/include/asm/compat.h
index da4b28cd01a95..aa103530a5c83 100644
--- a/arch/riscv/include/asm/compat.h
+++ b/arch/riscv/include/asm/compat.h
@@ -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;
diff --git a/arch/riscv/include/asm/elf.h b/arch/riscv/include/asm/elf.h
index 2e88257cafaea..c7aea7886d22a 100644
--- a/arch/riscv/include/asm/elf.h
+++ b/arch/riscv/include/asm/elf.h
@@ -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))); \
--
2.43.0
Powered by blists - more mailing lists