Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions components/lwp/arch/risc-v/rv64/lwp_gcc.S
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ arch_ret_to_user_impl:
// TODO: we don't support kernel gdb server in risc-v yet
// so we don't check debug state here and handle debugging bussiness

/* Signal handling takes sleeping locks and must remain schedulable. */
OPEN_INTERRUPT
call lwp_check_exit_request
beqz a0, 1f
mv a0, x0
Expand All @@ -121,6 +123,7 @@ arch_ret_to_user_impl:
call lwp_thread_signal_catch

ret_to_user_exit:
CLOSE_INTERRUPT
RESTORE_ALL
// `RESTORE_ALL` also reset sp to user sp, and setup sscratch
sret
Expand All @@ -130,8 +133,10 @@ ret_to_user_exit:
* And handle pending signals;
*/
arch_signal_quit:
OPEN_INTERRUPT
LOAD a0, FRAME_OFF_SP(sp)
call arch_signal_ucontext_restore
CLOSE_INTERRUPT

/* reset kernel sp to the stack */
addi sp, sp, CTX_REG_NR * REGBYTES
Expand Down Expand Up @@ -167,6 +172,7 @@ arch_thread_signal_enter:
LOAD t0, FRAME_OFF_SP(a2)
mv a3, t0
call arch_signal_ucontext_save
CLOSE_INTERRUPT

/** restore kernel sp */
addi sp, s3, CTX_REG_NR * REGBYTES
Expand Down
23 changes: 20 additions & 3 deletions components/lwp/lwp_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,24 @@ static int elf_zero_bss(struct rt_lwp *lwp, int fd, const Elf_Phdr *phdr, rt_uba
* @return -RT_ERROR if memory mapping fails.
* @return -ENOMEM if memory allocation fails.
*/
static size_t elf_prot_from_pflags(uint32_t p_flags)
{
size_t prot = PROT_NONE;
if (p_flags & PF_R)
{
prot |= PROT_READ;
}
if (p_flags & PF_W)
{
prot |= PROT_WRITE;
}
if (p_flags & PF_X)
{
prot |= PROT_EXEC;
}
return prot;
}

static int elf_file_mmap(elf_load_info_t *load_info, elf_info_t *elf_info, rt_ubase_t *elfload_addr,
rt_uint32_t map_size, rt_ubase_t *load_base)
{
Expand All @@ -626,7 +644,6 @@ static int elf_file_mmap(elf_load_info_t *load_info, elf_info_t *elf_info, rt_ub
const Elf_Phdr *tmp_phdr = phdr; /* Current program header */
int fd = elf_info->fd; /* File descriptor for ELF file */
rt_ubase_t load_addr; /* Calculated load address */
size_t prot = PROT_READ | PROT_WRITE; /* Memory protection flags */
size_t flags = MAP_FIXED | MAP_PRIVATE; /* Memory mapping flags */

/* Iterate through all program headers */
Expand Down Expand Up @@ -659,8 +676,8 @@ static int elf_file_mmap(elf_load_info_t *load_info, elf_info_t *elf_info, rt_ub
flags &= ~MAP_FIXED;
}

/* Map the segment into memory */
map_va = elf_map(load_info->lwp, tmp_phdr, fd, load_addr, prot, flags, map_size);
/* Map the segment into memory with correct permissions */
map_va = elf_map(load_info->lwp, tmp_phdr, fd, load_addr, elf_prot_from_pflags(tmp_phdr->p_flags), flags, map_size);
if (!map_va)
{
LOG_E("%s : elf_map failed", __func__);
Expand Down
5 changes: 3 additions & 2 deletions components/lwp/lwp_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,10 @@ static void sigqueue_enqueue(lwp_sigqueue_t sigqueue, lwp_siginfo_t siginfo)
rt_bool_t inserted = RT_FALSE;
rt_list_for_each_entry(idx, &sigqueue->siginfo_list, node)
{
if (idx->ksiginfo.signo >= siginfo->ksiginfo.signo)
/* Keep ascending signal order and FIFO order for equal signals. */
if (idx->ksiginfo.signo > siginfo->ksiginfo.signo)
{
rt_list_insert_after(&idx->node, &siginfo->node);
rt_list_insert_before(&idx->node, &siginfo->node);
inserted = RT_TRUE;
break;
}
Expand Down
Loading