mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
riscv: Introduce is_compat_thread() into compat.h
task_user_regset_view() makes use of a function very similar to is_compat_task(), but pointing to a any thread. In arm64 asm/compat.h there is a function very similar to that: is_compat_thread(struct thread_info *thread) Copy this function to riscv asm/compat.h and make use of it into task_user_regset_view(). Also, introduce a compile-time test for CONFIG_COMPAT and simplify the function code by removing the #ifdef. Signed-off-by: Leonardo Bras <leobras@redhat.com> Reviewed-by: Guo Ren <guoren@kernel.org> Reviewed-by: Andy Chiu <andy.chiu@sifive.com> Link: https://lore.kernel.org/r/20240103160024.70305-6-leobras@redhat.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
This commit is contained in:
parent
4c0b5a4516
commit
5917ea17ad
2 changed files with 11 additions and 3 deletions
|
@ -20,6 +20,14 @@ static inline int is_compat_task(void)
|
||||||
return test_thread_flag(TIF_32BIT);
|
return test_thread_flag(TIF_32BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int is_compat_thread(struct thread_info *thread)
|
||||||
|
{
|
||||||
|
if (!IS_ENABLED(CONFIG_COMPAT))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return test_ti_thread_flag(thread, TIF_32BIT);
|
||||||
|
}
|
||||||
|
|
||||||
struct compat_user_regs_struct {
|
struct compat_user_regs_struct {
|
||||||
compat_ulong_t pc;
|
compat_ulong_t pc;
|
||||||
compat_ulong_t ra;
|
compat_ulong_t ra;
|
||||||
|
|
|
@ -374,14 +374,14 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
static const struct user_regset_view compat_riscv_user_native_view = {};
|
||||||
#endif /* CONFIG_COMPAT */
|
#endif /* CONFIG_COMPAT */
|
||||||
|
|
||||||
const struct user_regset_view *task_user_regset_view(struct task_struct *task)
|
const struct user_regset_view *task_user_regset_view(struct task_struct *task)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_COMPAT
|
if (is_compat_thread(&task->thread_info))
|
||||||
if (test_tsk_thread_flag(task, TIF_32BIT))
|
|
||||||
return &compat_riscv_user_native_view;
|
return &compat_riscv_user_native_view;
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
return &riscv_user_native_view;
|
return &riscv_user_native_view;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue