Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull RISC-V fixes from Palmer Dabbelt:

- A fix for vector load/store instruction decoding, which could result
in reserved vector element length encodings decoding as valid vector
instructions.

- Instruction patching now aggressively flushes the local instruction
cache, to avoid situations where patching functions on the flush path
results in torn instructions being fetched.

- A fix to prevent the stack walker from showing up as part of traces.

* tag 'riscv-for-linus-6.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
riscv: stacktrace: convert arch_stack_walk() to noinstr
riscv: patch: Flush the icache right after patching to avoid illegal insns
RISC-V: fix vector insn load/store width mask

+22 -15
+1 -1
arch/riscv/include/asm/insn.h
··· 145 145 146 146 /* parts of opcode for RVF, RVD and RVQ */ 147 147 #define RVFDQ_FL_FS_WIDTH_OFF 12 148 - #define RVFDQ_FL_FS_WIDTH_MASK GENMASK(3, 0) 148 + #define RVFDQ_FL_FS_WIDTH_MASK GENMASK(2, 0) 149 149 #define RVFDQ_FL_FS_WIDTH_W 2 150 150 #define RVFDQ_FL_FS_WIDTH_D 3 151 151 #define RVFDQ_LS_FS_WIDTH_Q 4
+2 -5
arch/riscv/kernel/ftrace.c
··· 120 120 out = ftrace_make_nop(mod, rec, MCOUNT_ADDR); 121 121 mutex_unlock(&text_mutex); 122 122 123 - if (!mod) 124 - local_flush_icache_range(rec->ip, rec->ip + MCOUNT_INSN_SIZE); 125 - 126 123 return out; 127 124 } 128 125 ··· 153 156 } else { 154 157 while (atomic_read(&param->cpu_count) <= num_online_cpus()) 155 158 cpu_relax(); 156 - } 157 159 158 - local_flush_icache_all(); 160 + local_flush_icache_all(); 161 + } 159 162 160 163 return 0; 161 164 }
+18 -8
arch/riscv/kernel/patch.c
··· 89 89 90 90 memset(waddr, c, len); 91 91 92 + /* 93 + * We could have just patched a function that is about to be 94 + * called so make sure we don't execute partially patched 95 + * instructions by flushing the icache as soon as possible. 96 + */ 97 + local_flush_icache_range((unsigned long)waddr, 98 + (unsigned long)waddr + len); 99 + 92 100 patch_unmap(FIX_TEXT_POKE0); 93 101 94 102 if (across_pages) ··· 142 134 waddr = patch_map(addr, FIX_TEXT_POKE0); 143 135 144 136 ret = copy_to_kernel_nofault(waddr, insn, len); 137 + 138 + /* 139 + * We could have just patched a function that is about to be 140 + * called so make sure we don't execute partially patched 141 + * instructions by flushing the icache as soon as possible. 142 + */ 143 + local_flush_icache_range((unsigned long)waddr, 144 + (unsigned long)waddr + len); 145 145 146 146 patch_unmap(FIX_TEXT_POKE0); 147 147 ··· 205 189 206 190 ret = patch_insn_set(tp, c, len); 207 191 208 - if (!ret) 209 - flush_icache_range((uintptr_t)tp, (uintptr_t)tp + len); 210 - 211 192 return ret; 212 193 } 213 194 NOKPROBE_SYMBOL(patch_text_set_nosync); ··· 237 224 238 225 ret = patch_insn_write(tp, insns, len); 239 226 240 - if (!ret) 241 - flush_icache_range((uintptr_t) tp, (uintptr_t) tp + len); 242 - 243 227 return ret; 244 228 } 245 229 NOKPROBE_SYMBOL(patch_text_nosync); ··· 263 253 } else { 264 254 while (atomic_read(&patch->cpu_count) <= num_online_cpus()) 265 255 cpu_relax(); 266 - } 267 256 268 - local_flush_icache_all(); 257 + local_flush_icache_all(); 258 + } 269 259 270 260 return ret; 271 261 }
+1 -1
arch/riscv/kernel/stacktrace.c
··· 156 156 return pc; 157 157 } 158 158 159 - noinline void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, 159 + noinline noinstr void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, 160 160 struct task_struct *task, struct pt_regs *regs) 161 161 { 162 162 walk_stackframe(task, regs, consume_entry, cookie);