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-5.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux

Pull RISC-V fixes from Palmer Dabbelt:

- a workaround for a compiler surprise related to the "r" inline
assembly that allows LLVM to boot.

- a fix to avoid WX-only mappings, which the ISA does not allow. While
this probably manifests in many ways, the bug was found in stress-ng.

- a missing lock in set_direct_map_*(), which due to a recent lockdep
change started asserting.

* tag 'riscv-for-linus-5.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
RISC-V: Acquire mmap lock before invoking walk_page_range
RISC-V: Don't allow write+exec only page mapping request in mmap
riscv/atomic: Fix sign extension for RV64I

+22 -6
+4 -4
arch/riscv/include/asm/cmpxchg.h
··· 179 179 " bnez %1, 0b\n" \ 180 180 "1:\n" \ 181 181 : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ 182 - : "rJ" (__old), "rJ" (__new) \ 182 + : "rJ" ((long)__old), "rJ" (__new) \ 183 183 : "memory"); \ 184 184 break; \ 185 185 case 8: \ ··· 224 224 RISCV_ACQUIRE_BARRIER \ 225 225 "1:\n" \ 226 226 : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ 227 - : "rJ" (__old), "rJ" (__new) \ 227 + : "rJ" ((long)__old), "rJ" (__new) \ 228 228 : "memory"); \ 229 229 break; \ 230 230 case 8: \ ··· 270 270 " bnez %1, 0b\n" \ 271 271 "1:\n" \ 272 272 : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ 273 - : "rJ" (__old), "rJ" (__new) \ 273 + : "rJ" ((long)__old), "rJ" (__new) \ 274 274 : "memory"); \ 275 275 break; \ 276 276 case 8: \ ··· 316 316 " fence rw, rw\n" \ 317 317 "1:\n" \ 318 318 : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ 319 - : "rJ" (__old), "rJ" (__new) \ 319 + : "rJ" ((long)__old), "rJ" (__new) \ 320 320 : "memory"); \ 321 321 break; \ 322 322 case 8: \
+6
arch/riscv/kernel/sys_riscv.c
··· 8 8 #include <linux/syscalls.h> 9 9 #include <asm/unistd.h> 10 10 #include <asm/cacheflush.h> 11 + #include <asm-generic/mman-common.h> 11 12 12 13 static long riscv_sys_mmap(unsigned long addr, unsigned long len, 13 14 unsigned long prot, unsigned long flags, ··· 17 16 { 18 17 if (unlikely(offset & (~PAGE_MASK >> page_shift_offset))) 19 18 return -EINVAL; 19 + 20 + if ((prot & PROT_WRITE) && (prot & PROT_EXEC)) 21 + if (unlikely(!(prot & PROT_READ))) 22 + return -EINVAL; 23 + 20 24 return ksys_mmap_pgoff(addr, len, prot, flags, fd, 21 25 offset >> (PAGE_SHIFT - page_shift_offset)); 22 26 }
+12 -2
arch/riscv/mm/pageattr.c
··· 151 151 152 152 int set_direct_map_invalid_noflush(struct page *page) 153 153 { 154 + int ret; 154 155 unsigned long start = (unsigned long)page_address(page); 155 156 unsigned long end = start + PAGE_SIZE; 156 157 struct pageattr_masks masks = { ··· 159 158 .clear_mask = __pgprot(_PAGE_PRESENT) 160 159 }; 161 160 162 - return walk_page_range(&init_mm, start, end, &pageattr_ops, &masks); 161 + mmap_read_lock(&init_mm); 162 + ret = walk_page_range(&init_mm, start, end, &pageattr_ops, &masks); 163 + mmap_read_unlock(&init_mm); 164 + 165 + return ret; 163 166 } 164 167 165 168 int set_direct_map_default_noflush(struct page *page) 166 169 { 170 + int ret; 167 171 unsigned long start = (unsigned long)page_address(page); 168 172 unsigned long end = start + PAGE_SIZE; 169 173 struct pageattr_masks masks = { ··· 176 170 .clear_mask = __pgprot(0) 177 171 }; 178 172 179 - return walk_page_range(&init_mm, start, end, &pageattr_ops, &masks); 173 + mmap_read_lock(&init_mm); 174 + ret = walk_page_range(&init_mm, start, end, &pageattr_ops, &masks); 175 + mmap_read_unlock(&init_mm); 176 + 177 + return ret; 180 178 } 181 179 182 180 void __kernel_map_pages(struct page *page, int numpages, int enable)