• Andy Chiu's avatar
    riscv: vector: allow kernel-mode Vector with preemption · 2080ff94
    Andy Chiu authored
    Add kernel_vstate to keep track of kernel-mode Vector registers when
    trap introduced context switch happens. Also, provide riscv_v_flags to
    let context save/restore routine track context status. Context tracking
    happens whenever the core starts its in-kernel Vector executions. An
    active (dirty) kernel task's V contexts will be saved to memory whenever
    a trap-introduced context switch happens. Or, when a softirq, which
    happens to nest on top of it, uses Vector. Context retoring happens when
    the execution transfer back to the original Kernel context where it
    first enable preempt_v.
    
    Also, provide a config CONFIG_RISCV_ISA_V_PREEMPTIVE to give users an
    option to disable preemptible kernel-mode Vector at build time. Users
    with constraint memory may want to disable this config as preemptible
    kernel-mode Vector needs extra space for tracking of per thread's
    kernel-mode V context. Or, users might as well want to disable it if all
    kernel-mode Vector code is time sensitive and cannot tolerate context
    switch overhead.
    Signed-off-by: default avatarAndy Chiu <andy.chiu@sifive.com>
    Tested-by: default avatarBjörn Töpel <bjorn@rivosinc.com>
    Tested-by: default avatarLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
    Link: https://lore.kernel.org/r/20240115055929.4736-11-andy.chiu@sifive.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
    2080ff94
process.c 6.29 KB