RISC-V Fixes for 6.10-rc3

* Another fix to avoid allocating pages that overlap with ERR_PTR, which
   manifests on rv32.
 * A revert for the badaccess patch I incorrectly picked up an early
   version of.
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCAAxFiEEKzw3R0RoQ7JKlDp6LhMZ81+7GIkFAmZjGDcTHHBhbG1lckBk
 YWJiZWx0LmNvbQAKCRAuExnzX7sYiWGoD/9LuIorx3Oxtq8oWq42DpMHQDKIJU/p
 PlopOk0acCucfg13ZfAQDJ0H8PN64SLJ/Zhzh/+Ge+6s1FRD1b5pqsT0ZKUytsrk
 pdWVha8QAQYCm3YekLGvQCHHN1Lh3/dilOvZEJZN1l+ltnRFh+tfurB+E/Cre/mb
 pRMGDtAASXGUAkuEZqKfxEe7zQ4xRnyVx0DtcFl1xVjNP11ywwwbnkf7GyrhmDHT
 SITcjF3NaoqQ4zgEwD8MflL6k0fwhwECw3RBvwT23jfHX56ttPJRw0bn9l8UlY25
 HdvBw45bcIbva0COIMIBnYjpokj5wIOnaOhJSHbHllkVFTpBcaiO+CgDj440sAlJ
 4vvl7ll8Fn/DCEjzQgvePndjzWPyxEGkAU6b8f68wj0dfRU/FW16GE3nO/mYLjjx
 RWob8+/qh6kg51KsaCdDNHaASoeVG6ZYokIOYecc30rDZv2fjQv5ly81k6UpKcCu
 0v9el1vX7KaM6GYQkIhyJbnlCCTGLfKJWcWU/Sup7pw7S2HmAkwV3LnuUQwkVXrG
 Qc6GWTbD7YrfVVQF+yX/PrpmuhQWk6ZUZjoA20jmkoeN4IDUG5l1j6xy6I0dDp6T
 OYSYdQNuGfic2X6wO73iImFJTdleuqFVW5GjiD2LkZXziV5rMGpgaXVGzhwnltk8
 A+B53s9STVmbyQ==
 =tO1B
 -----END PGP SIGNATURE-----

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

Pull RISC-V fixes from Palmer Dabbelt:

 - Another fix to avoid allocating pages that overlap with ERR_PTR,
   which manifests on rv32

 - A revert for the badaccess patch I incorrectly picked up an early
   version of

* tag 'riscv-for-linus-6.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  Revert "riscv: mm: accelerate pagefault when badaccess"
  riscv: fix overlap of allocated page and PTR_ERR
This commit is contained in:
Linus Torvalds 2024-06-07 14:47:38 -07:00
commit 0a02756d91
2 changed files with 13 additions and 12 deletions

View File

@ -293,8 +293,8 @@ void handle_page_fault(struct pt_regs *regs)
if (unlikely(access_error(cause, vma))) { if (unlikely(access_error(cause, vma))) {
vma_end_read(vma); vma_end_read(vma);
count_vm_vma_lock_event(VMA_LOCK_SUCCESS); count_vm_vma_lock_event(VMA_LOCK_SUCCESS);
tsk->thread.bad_cause = SEGV_ACCERR; tsk->thread.bad_cause = cause;
bad_area_nosemaphore(regs, code, addr); bad_area_nosemaphore(regs, SEGV_ACCERR, addr);
return; return;
} }

View File

@ -250,18 +250,19 @@ static void __init setup_bootmem(void)
kernel_map.va_pa_offset = PAGE_OFFSET - phys_ram_base; kernel_map.va_pa_offset = PAGE_OFFSET - phys_ram_base;
/* /*
* memblock allocator is not aware of the fact that last 4K bytes of * Reserve physical address space that would be mapped to virtual
* the addressable memory can not be mapped because of IS_ERR_VALUE * addresses greater than (void *)(-PAGE_SIZE) because:
* macro. Make sure that last 4k bytes are not usable by memblock * - This memory would overlap with ERR_PTR
* if end of dram is equal to maximum addressable memory. For 64-bit * - This memory belongs to high memory, which is not supported
* kernel, this problem can't happen here as the end of the virtual *
* address space is occupied by the kernel mapping then this check must * This is not applicable to 64-bit kernel, because virtual addresses
* be done as soon as the kernel mapping base address is determined. * after (void *)(-PAGE_SIZE) are not linearly mapped: they are
* occupied by kernel mapping. Also it is unrealistic for high memory
* to exist on 64-bit platforms.
*/ */
if (!IS_ENABLED(CONFIG_64BIT)) { if (!IS_ENABLED(CONFIG_64BIT)) {
max_mapped_addr = __pa(~(ulong)0); max_mapped_addr = __va_to_pa_nodebug(-PAGE_SIZE);
if (max_mapped_addr == (phys_ram_end - 1)) memblock_reserve(max_mapped_addr, (phys_addr_t)-max_mapped_addr);
memblock_set_current_limit(max_mapped_addr - 4096);
} }
min_low_pfn = PFN_UP(phys_ram_base); min_low_pfn = PFN_UP(phys_ram_base);