Merge tag 'riscv-for-linus-6.5-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux

Pull RISC-V fixes from Palmer Dabbelt:
"This is obviously not ideal, particularly for something this late in
the cycle.

Unfortunately we found some uABI issues in the vector support while
reviewing the GDB port, which has triggered a revert -- probably a
good sign we should have reviewed GDB before merging this, I guess I
just dropped the ball because I was so worried about the context
extension and libc suff I forgot. Hence the late revert.

There's some risk here as we're still exposing the vector context for
signal handlers, but changing that would have meant reverting all of
the vector support. The issues we've found so far have been fixed
already and they weren't absolute showstoppers, so we're essentially
just playing it safe by holding ptrace support for another release (or
until we get through a proper userspace code review).

Summary:

- The vector ucontext extension has been extended with vlenb

- The vector registers ELF core dump note type has been changed to
avoid aliasing with the CSR type used in embedded systems

- Support for accessing vector registers via ptrace() has been
reverted

- Another build fix for the ISA spec changes around Zifencei/Zicsr
that manifests on some systems built with binutils-2.37 and
gcc-11.2"

* tag 'riscv-for-linus-6.5-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
riscv: Fix build errors using binutils2.37 toolchains
RISC-V: vector: export VLENB csr in __sc_riscv_v_state
RISC-V: Remove ptrace support for vectors

+7 -75
+4 -4
arch/riscv/Kconfig
··· 580 580 and Zifencei are supported in binutils from version 2.36 onwards. 581 581 To make life easier, and avoid forcing toolchains that default to a 582 582 newer ISA spec to version 2.2, relax the check to binutils >= 2.36. 583 - For clang < 17 or GCC < 11.1.0, for which this is not possible, this is 584 - dealt with in CONFIG_TOOLCHAIN_NEEDS_OLD_ISA_SPEC. 583 + For clang < 17 or GCC < 11.3.0, for which this is not possible or need 584 + special treatment, this is dealt with in TOOLCHAIN_NEEDS_OLD_ISA_SPEC. 585 585 586 586 config TOOLCHAIN_NEEDS_OLD_ISA_SPEC 587 587 def_bool y 588 588 depends on TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI 589 589 # https://github.com/llvm/llvm-project/commit/22e199e6afb1263c943c0c0d4498694e15bf8a16 590 - # https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=b03be74bad08c382da47e048007a78fa3fb4ef49 591 - depends on (CC_IS_CLANG && CLANG_VERSION < 170000) || (CC_IS_GCC && GCC_VERSION < 110100) 590 + # https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d29f5d6ab513c52fd872f532c492e35ae9fd6671 591 + depends on (CC_IS_CLANG && CLANG_VERSION < 170000) || (CC_IS_GCC && GCC_VERSION < 110300) 592 592 help 593 593 Certain versions of clang and GCC do not support zicsr and zifencei via 594 594 -march. This option causes an older ISA spec compatible with these older
+2 -1
arch/riscv/include/asm/vector.h
··· 70 70 "csrr %1, " __stringify(CSR_VTYPE) "\n\t" 71 71 "csrr %2, " __stringify(CSR_VL) "\n\t" 72 72 "csrr %3, " __stringify(CSR_VCSR) "\n\t" 73 + "csrr %4, " __stringify(CSR_VLENB) "\n\t" 73 74 : "=r" (dest->vstart), "=r" (dest->vtype), "=r" (dest->vl), 74 - "=r" (dest->vcsr) : :); 75 + "=r" (dest->vcsr), "=r" (dest->vlenb) : :); 75 76 } 76 77 77 78 static __always_inline void __vstate_csr_restore(struct __riscv_v_ext_state *src)
+1
arch/riscv/include/uapi/asm/ptrace.h
··· 97 97 unsigned long vl; 98 98 unsigned long vtype; 99 99 unsigned long vcsr; 100 + unsigned long vlenb; 100 101 void *datap; 101 102 /* 102 103 * In signal handler, datap will be set a correct user stack offset
-69
arch/riscv/kernel/ptrace.c
··· 25 25 #ifdef CONFIG_FPU 26 26 REGSET_F, 27 27 #endif 28 - #ifdef CONFIG_RISCV_ISA_V 29 - REGSET_V, 30 - #endif 31 28 }; 32 29 33 30 static int riscv_gpr_get(struct task_struct *target, ··· 81 84 } 82 85 #endif 83 86 84 - #ifdef CONFIG_RISCV_ISA_V 85 - static int riscv_vr_get(struct task_struct *target, 86 - const struct user_regset *regset, 87 - struct membuf to) 88 - { 89 - struct __riscv_v_ext_state *vstate = &target->thread.vstate; 90 - 91 - if (!riscv_v_vstate_query(task_pt_regs(target))) 92 - return -EINVAL; 93 - 94 - /* 95 - * Ensure the vector registers have been saved to the memory before 96 - * copying them to membuf. 97 - */ 98 - if (target == current) 99 - riscv_v_vstate_save(current, task_pt_regs(current)); 100 - 101 - /* Copy vector header from vstate. */ 102 - membuf_write(&to, vstate, offsetof(struct __riscv_v_ext_state, datap)); 103 - membuf_zero(&to, sizeof(vstate->datap)); 104 - 105 - /* Copy all the vector registers from vstate. */ 106 - return membuf_write(&to, vstate->datap, riscv_v_vsize); 107 - } 108 - 109 - static int riscv_vr_set(struct task_struct *target, 110 - const struct user_regset *regset, 111 - unsigned int pos, unsigned int count, 112 - const void *kbuf, const void __user *ubuf) 113 - { 114 - int ret, size; 115 - struct __riscv_v_ext_state *vstate = &target->thread.vstate; 116 - 117 - if (!riscv_v_vstate_query(task_pt_regs(target))) 118 - return -EINVAL; 119 - 120 - /* Copy rest of the vstate except datap */ 121 - ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, vstate, 0, 122 - offsetof(struct __riscv_v_ext_state, datap)); 123 - if (unlikely(ret)) 124 - return ret; 125 - 126 - /* Skip copy datap. */ 127 - size = sizeof(vstate->datap); 128 - count -= size; 129 - ubuf += size; 130 - 131 - /* Copy all the vector registers. */ 132 - pos = 0; 133 - ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, vstate->datap, 134 - 0, riscv_v_vsize); 135 - return ret; 136 - } 137 - #endif 138 - 139 87 static const struct user_regset riscv_user_regset[] = { 140 88 [REGSET_X] = { 141 89 .core_note_type = NT_PRSTATUS, ··· 98 156 .align = sizeof(elf_fpreg_t), 99 157 .regset_get = riscv_fpr_get, 100 158 .set = riscv_fpr_set, 101 - }, 102 - #endif 103 - #ifdef CONFIG_RISCV_ISA_V 104 - [REGSET_V] = { 105 - .core_note_type = NT_RISCV_VECTOR, 106 - .align = 16, 107 - .n = ((32 * RISCV_MAX_VLENB) + 108 - sizeof(struct __riscv_v_ext_state)) / sizeof(__u32), 109 - .size = sizeof(__u32), 110 - .regset_get = riscv_vr_get, 111 - .set = riscv_vr_set, 112 159 }, 113 160 #endif 114 161 };
-1
include/uapi/linux/elf.h
··· 443 443 #define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers */ 444 444 #define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode */ 445 445 #define NT_MIPS_MSA 0x802 /* MIPS SIMD registers */ 446 - #define NT_RISCV_VECTOR 0x900 /* RISC-V vector registers */ 447 446 #define NT_LOONGARCH_CPUCFG 0xa00 /* LoongArch CPU config registers */ 448 447 #define NT_LOONGARCH_CSR 0xa01 /* LoongArch control and status registers */ 449 448 #define NT_LOONGARCH_LSX 0xa02 /* LoongArch Loongson SIMD Extension registers */