Skip to contentSkip to conversation

riscv: compat: Add UXL_32 support in start_thread

PATCH Superseded [email protected] 2 participants 3 messages Jan 20, 2022

Subsystems (4)

v3 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH v3 15/17 riscv: compat: Add UXL_32 support in start_thread

From: Guo Ren <[email protected]>

If the current task is in COMPAT mode, set SR_UXL_32 in status for returning userspace.

---
 arch/riscv/kernel/process.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/riscv/kernel/process.c +5 -0
index 03ac3aa611f5..1a666ad299b4 100644
@@ -97,6 +97,11 @@ void start_thread(struct pt_regs *regs, unsigned long pc,
 	}
 	regs->epc = pc;
 	regs->sp = sp;
+
+#ifdef CONFIG_COMPAT
+	if (is_compat_task())
+		regs->status |= SR_UXL_32;
+#endif
 }
 
 void flush_thread(void)
Signature · 1 line
2.25.1
#1 lore raw

arch/riscv/kernel/process.c void start_thread(struct pt_regs *regs, unsigned long pc, · line 104

Quoted 5 lines · On Thu, Jan 20, 2022 at 8:39 AM <[email protected]> wrote:
arch/riscv/kernel/process.c +5 -0
+
+#ifdef CONFIG_COMPAT
+       if (is_compat_task())
+               regs->status |= SR_UXL_32;
+#endif

You should not need that #ifdef, as the is_compat_task() definition is meant to drop the code at compile time, unless the SR_UXL_32 definition is not visible here.

Arnd

author maintainer
#2 lore raw
Quoted 12 lines · Arnd Bergmann

arch/riscv/kernel/process.c void start_thread(struct pt_regs *regs, unsigned long pc, · line 104

Quoted 5 lines · On Thu, Jan 20, 2022 at 8:39 AM <[email protected]> wrote:
arch/riscv/kernel/process.c +5 -0
+
+#ifdef CONFIG_COMPAT
+       if (is_compat_task())
+               regs->status |= SR_UXL_32;
+#endif

You should not need that #ifdef, as the is_compat_task() definition is meant to drop the code at compile time, unless the SR_UXL_32 definition is not visible here.

I almost put CONFIG_COMPAT in every compat related code, because I hope the next arch that wants to support COMPAT could easily find where to be modified.

Quoted 2 lines

Arnd

Signature · 4 lines
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/