This patch facilitates the existing fp-reserved words for placement of the first extension's context header on the user's sigframe. A context header consists of a distinct magic word and the size, including the header itself, of an extension on the stack. Then, the frame is followed by the context of that extension, and then a header + context body for another extension if exists. If there is no more extension to come, then the frame must be ended with a null context header. A special case is rv64gc, where the kernel support no extensions requiring to expose additional regfile to the user. In such case the kernel would place the null context header right after the first reserved word of __riscv_q_ext_state when saving sigframe. And the kernel would check if all reserved words are zeros when a signal handler returns. __riscv_q_ext_state---->| |<-__riscv_extra_ext_header ~ ~ .reserved[0]--->|0 |<- .reserved <-------|magic |<- .hdr | |size |_______ end of sc_fpregs | |ext-bdy| | ~ ~ +)size ------->|magic |<- another context header |size | |ext-bdy| ~ ~ |magic:0|<- null context header |size:0 | The vector registers will be saved in datap pointer. The datap pointer will be allocated dynamically when the task needs in kernel space. On the other hand, datap pointer on the sigframe will be set right after the __riscv_v_ext_state data structure. Co-developed-by: Vincent Chen <vincent.chen@sifive.com> Signed-off-by: Vincent Chen <vincent.chen@sifive.com> Signed-off-by: Greentime Hu <greentime.hu@sifive.com> Suggested-by: Vineet Gupta <vineetg@rivosinc.com> Suggested-by: Richard Henderson <richard.henderson@linaro.org> Co-developed-by: Andy Chiu <andy.chiu@sifive.com> Signed-off-by: Andy Chiu <andy.chiu@sifive.com> Acked-by: Conor Dooley <conor.dooley@microchip.com> Acked-by: Heiko Stuebner <heiko.stuebner@vrull.eu> Tested-by: Heiko Stuebner <heiko.stuebner@vrull.eu> Link: https://lore.kernel.org/r/20230605110724.21391-15-andy.chiu@sifive.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
36 lines
878 B
C
36 lines
878 B
C
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
|
|
/*
|
|
* Copyright (C) 2012 Regents of the University of California
|
|
*/
|
|
|
|
#ifndef _UAPI_ASM_RISCV_SIGCONTEXT_H
|
|
#define _UAPI_ASM_RISCV_SIGCONTEXT_H
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
/* The Magic number for signal context frame header. */
|
|
#define RISCV_V_MAGIC 0x53465457
|
|
#define END_MAGIC 0x0
|
|
|
|
/* The size of END signal context header. */
|
|
#define END_HDR_SIZE 0x0
|
|
|
|
struct __sc_riscv_v_state {
|
|
struct __riscv_v_ext_state v_state;
|
|
} __attribute__((aligned(16)));
|
|
|
|
/*
|
|
* Signal context structure
|
|
*
|
|
* This contains the context saved before a signal handler is invoked;
|
|
* it is restored by sys_sigreturn / sys_rt_sigreturn.
|
|
*/
|
|
struct sigcontext {
|
|
struct user_regs_struct sc_regs;
|
|
union {
|
|
union __riscv_fp_state sc_fpregs;
|
|
struct __riscv_extra_ext_header sc_extdesc;
|
|
};
|
|
};
|
|
|
|
#endif /* _UAPI_ASM_RISCV_SIGCONTEXT_H */
|