Skip to content

Commit

Permalink
riscv: Fixup mix rv64 & rv32 running
Browse files Browse the repository at this point in the history
[  559.348135] run_ltp.sh[186]: unhandled signal 11 code 0x1 at 0x00000000ff91bca0 in busybox[10000+13d000]
[  559.358679] CPU: 0 PID: 186 Comm: run_ltp.sh Not tainted 5.10.4 #3
[  559.365135] epc: 000000000008d67e ra : 000000000008d674 sp : 0000003fff91bca0
[  559.372457]  gp : 0000000000150548 tp : 00000000001537a0 t0 : 0000000000000000
[  559.379856]  t1 : 2f2f2f2f2f2f2f2f t2 : 000000000000006a s0 : 0000000000154798
[  559.387225]  s1 : 0000000000141eef a0 : 000000000008e4a0 a1 : 00000000001547f0
[  559.394598]  a2 : 0000000000154810 a3 : 000000000000002f a4 : 000000000000002f
[  559.401969]  a5 : 0000000000000000 a6 : 7efefefefefefeff a7 : 00000000000000dd
[  559.409333]  s2 : 0000000000103960 s3 : 0000000000000008 s4 : 0000000000153828
[  559.416696]  s5 : 0000000000000000 s6 : 00000000001547d0 s7 : 0000000000000000
[  559.425234]  s8 : 0000000000000000 s9 : 0000000000157fc0 s10: 00000000001547f0
[  559.432662]  s11: 0000000000000001 t3 : ffffffffffffffff t4 : 0000003ff683e1a8
[  559.440022]  t5 : 0000000000000005 t6 : ffffffffffffffff
[  559.445504] status: 8000000100006620 badaddr: 00000000ff91bca0 cause: 000000000000000d
Segmentation fault

The status shows in UXL_32 mmde, but busybox is 64bit elf.

Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
  • Loading branch information
guoren83 committed Mar 11, 2022
1 parent 4095179 commit e203c6a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
3 changes: 0 additions & 3 deletions arch/riscv/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ do { if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
typedef compat_ulong_t compat_elf_greg_t;
typedef compat_elf_greg_t compat_elf_gregset_t[ELF_NGREG];

#define compat_start_thread compat_start_thread


extern int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
int uses_interp);
#define compat_arch_setup_additional_pages \
Expand Down
3 changes: 0 additions & 3 deletions arch/riscv/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ extern void start_thread(struct pt_regs *regs,
unsigned long pc, unsigned long sp);

#ifdef CONFIG_COMPAT
extern void compat_start_thread(struct pt_regs *regs,
unsigned long pc, unsigned long sp);

#define DEFAULT_MAP_WINDOW_64 TASK_SIZE_64
#else
#define DEFAULT_MAP_WINDOW_64 TASK_SIZE
Expand Down
14 changes: 7 additions & 7 deletions arch/riscv/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <asm/unistd.h>
#include <asm/processor.h>
#include <asm/compat.h>
#include <asm/csr.h>
#include <asm/string.h>
#include <asm/switch_to.h>
Expand Down Expand Up @@ -91,16 +92,15 @@ void start_thread(struct pt_regs *regs, unsigned long pc,

regs->epc = pc;
regs->sp = sp;
}

#ifdef CONFIG_COMPAT
void compat_start_thread(struct pt_regs *regs, unsigned long pc,
unsigned long sp)
{
start_thread(regs, pc, sp);
regs->status |= SR_UXL_32;
}
regs->status &= ~SR_UXL;
if (is_compat_task())
regs->status |= SR_UXL_32;
else
regs->status |= SR_UXL_64;
#endif
}

void flush_thread(void)
{
Expand Down

0 comments on commit e203c6a

Please sign in to comment.