lkml.org 
[lkml]   [2021]   [Sep]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH v8 08/21] riscv: Add vector struct and assembler definitions
    Date
    Add vector state context struct in struct thread and asm-offsets.c
    definitions.

    The vector registers will be saved in datap pointer of __riscv_v_state. It
    will be dynamically allocated in kernel space. It will be put right after
    the __riscv_v_state data structure in user space.

    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>
    ---
    arch/riscv/include/asm/processor.h | 1 +
    arch/riscv/include/uapi/asm/ptrace.h | 11 +++++++++++
    arch/riscv/kernel/asm-offsets.c | 6 ++++++
    3 files changed, 18 insertions(+)

    diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h
    index 021ed64ee608..1b037c69d311 100644
    --- a/arch/riscv/include/asm/processor.h
    +++ b/arch/riscv/include/asm/processor.h
    @@ -35,6 +35,7 @@ struct thread_struct {
    unsigned long s[12]; /* s[0]: frame pointer */
    struct __riscv_d_ext_state fstate;
    unsigned long bad_cause;
    + struct __riscv_v_state vstate;
    };

    #define INIT_THREAD { \
    diff --git a/arch/riscv/include/uapi/asm/ptrace.h b/arch/riscv/include/uapi/asm/ptrace.h
    index 882547f6bd5c..bd3b8a710246 100644
    --- a/arch/riscv/include/uapi/asm/ptrace.h
    +++ b/arch/riscv/include/uapi/asm/ptrace.h
    @@ -77,6 +77,17 @@ union __riscv_fp_state {
    struct __riscv_q_ext_state q;
    };

    +struct __riscv_v_state {
    + unsigned long vstart;
    + unsigned long vl;
    + unsigned long vtype;
    + unsigned long vcsr;
    + void *datap;
    +#if __riscv_xlen == 32
    + __u32 __padding;
    +#endif
    +};
    +
    #endif /* __ASSEMBLY__ */

    #endif /* _UAPI_ASM_RISCV_PTRACE_H */
    diff --git a/arch/riscv/kernel/asm-offsets.c b/arch/riscv/kernel/asm-offsets.c
    index 90f8ce64fa6f..34f43c84723a 100644
    --- a/arch/riscv/kernel/asm-offsets.c
    +++ b/arch/riscv/kernel/asm-offsets.c
    @@ -72,6 +72,12 @@ void asm_offsets(void)
    OFFSET(TSK_STACK_CANARY, task_struct, stack_canary);
    #endif

    + OFFSET(RISCV_V_STATE_VSTART, __riscv_v_state, vstart);
    + OFFSET(RISCV_V_STATE_VL, __riscv_v_state, vl);
    + OFFSET(RISCV_V_STATE_VTYPE, __riscv_v_state, vtype);
    + OFFSET(RISCV_V_STATE_VCSR, __riscv_v_state, vcsr);
    + OFFSET(RISCV_V_STATE_DATAP, __riscv_v_state, datap);
    +
    DEFINE(PT_SIZE, sizeof(struct pt_regs));
    OFFSET(PT_EPC, pt_regs, epc);
    OFFSET(PT_RA, pt_regs, ra);
    --
    2.31.1
    \
     
     \ /
      Last update: 2021-09-08 19:46    [W:4.280 / U:0.040 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site