riscv64: more <sys/ucontext.h>.

Actually, we don't want to reuse the kernel struct ucontext because its
uc_mcontext has the wrong type, which means the fields within that end
up with the wrong names. Add the call site that made that evident, and
update <sys/ucontext.h> appropriately.

Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: If1d079afef0d5953aa22d9b0e049cfb0119c7718
This commit is contained in:
Elliott Hughes 2022-10-11 00:01:35 +00:00
parent ea988f43d8
commit 287f48e6e5
2 changed files with 17 additions and 5 deletions

View File

@ -204,12 +204,14 @@ static void HandleSigsysSeccompOverride(int /*signal_number*/, siginfo_t* info,
auto ret = -ENOSYS;
ucontext_t* ctx = reinterpret_cast<ucontext_t*>(void_context);
#if defined(__arm__)
#if defined(__aarch64__)
ctx->uc_mcontext.regs[0] = ret;
#elif defined(__arm__)
ctx->uc_mcontext.arm_r0 = ret;
#elif defined(__aarch64__)
ctx->uc_mcontext.regs[0] = ret; // x0
#elif defined(__i386__)
ctx->uc_mcontext.gregs[REG_EAX] = ret;
#elif defined(__riscv)
ctx->uc_mcontext.__gregs[REG_A0] = ret;
#elif defined(__x86_64__)
ctx->uc_mcontext.gregs[REG_RAX] = ret;
#else

View File

@ -320,6 +320,7 @@ typedef struct ucontext {
#define REG_RA 1
#define REG_SP 2
#define REG_TP 4
#define REG_A0 10
typedef unsigned long __riscv_mc_gp_state[NGREG];
@ -358,8 +359,17 @@ typedef struct mcontext_t {
union __riscv_mc_fp_state __fpregs;
} mcontext_t;
#include <asm/ucontext.h>
typedef struct ucontext ucontext_t;
/* This matches the kernel <asm/ucontext.h> but using mcontext_t. */
typedef struct ucontext_t {
unsigned long uc_flags;
struct ucontext_t* uc_link;
stack_t uc_stack;
sigset_t uc_sigmask;
/* The kernel adds extra padding here to allow sigset_t to grow. */
char __padding[128 - sizeof(sigset_t)];
mcontext_t uc_mcontext;
} ucontext_t;
#endif