opnsense-src/sys
Jessica Clarke 98138bbde0 riscv: Fix pmap_alloc_l2 when it should allocate a new L1 entry
The current code checks the RWX bits are 0 but does not check the V bit
is non-zero, meaning not-yet-allocated L1 entries that are still zero
are regarded as being allocated. This is likely due to copying the arm64
code that checks ATTR_DESC_MASK is L1_TABLE, which emcompasses both the
type and the validity in a single field, and erroneously translating
that to a check of just PTE_RWX being 0 to indicate non-leaf, forgetting
about the V bit. This then results in the following panic:

    panic: Fatal page fault at 0xffffffc0005cf292: 0x00000000000050
    cpuid = 1
    time = 1628379581
    KDB: stack backtrace:
    db_trace_self() at db_trace_self
    db_trace_self_wrapper() at db_trace_self_wrapper+0x38
    kdb_backtrace() at kdb_backtrace+0x2c
    vpanic() at vpanic+0x148
    panic() at panic+0x2a
    page_fault_handler() at page_fault_handler+0x1ba
    do_trap_supervisor() at do_trap_supervisor+0x7a
    cpu_exception_handler_supervisor() at
    cpu_exception_handler_supervisor+0x70
    --- exception 13, tval = 0x50
    pmap_enter_l2() at pmap_enter_l2+0xb2
    pmap_enter_object() at pmap_enter_object+0x15e
    vm_map_pmap_enter() at vm_map_pmap_enter+0x228
    vm_map_insert() at vm_map_insert+0x4ec
    vm_map_find() at vm_map_find+0x474
    vm_map_find_min() at vm_map_find_min+0x52
    vm_mmap_object() at vm_mmap_object+0x1ba
    vn_mmap() at vn_mmap+0xf8
    kern_mmap() at kern_mmap+0x4c4
    sys_mmap() at sys_mmap+0x38
    do_trap_user() at do_trap_user+0x208
    cpu_exception_handler_user() at cpu_exception_handler_user+0x72
    --- exception 8, tval = 0x1dd

Instead, we should just check the V bit, as on amd64, and assert that
any valid L1 entries are not leaves, since an L1 leaf would render the
entire range allocated and thus we should not have attempted to map that
VA in the first place.

Reported by:	David Gilbert <dgilbert@daveg.ca>
MFC after:	1 week
Reviewed by:	markj, mhorne
Differential Revision:	https://reviews.freebsd.org/D31460
2021-08-09 20:28:37 +01:00
..
amd64 vmm: Make iommu ops tables const 2021-08-09 13:28:27 -04:00
arm Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
arm64 Remove an unused arm64 panic string 2021-08-08 21:28:25 +00:00
bsm Add fspacectl(2), vn_deallocate(9) and VOP_DEALLOCATE(9). 2021-08-05 23:20:42 +08:00
cam cam: revert half of 75b5caa08e 2021-08-08 13:24:19 +00:00
cddl dtrace: use %zu format specifier for data of size_t type 2021-08-09 00:27:04 +03:00
compat Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
conf Remove duplicate entry for arm/mv/armada38x/armada38x_rtc.c 2021-08-09 18:57:50 +00:00
contrib Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
crypto Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
ddb fix style nit: space after if 2021-05-05 15:26:09 -06:00
dev mmc_fdt_helper: correct typo in DT property name 2021-08-09 02:27:41 +02:00
dts Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
fs nfscl: Cache an open stateid for the "oneopenown" mount option 2021-07-28 15:48:27 -07:00
gdb gdb: report specific stop reason for watchpoints 2021-03-30 11:36:41 -03:00
geom geom_vfs: Pre-allocate event for g_vfs_destroy. 2021-07-29 17:09:23 -07:00
gnu Remove the old dts imported tree. 2021-01-15 20:09:55 +01:00
i386 Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
isa newbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location} with sbuf 2021-06-22 20:52:06 -06:00
kern vfs: Avoid a comparison with an uninitialized field in setutimes() 2021-08-09 13:27:20 -04:00
kgssapi opencrypto: Introduce crypto_dispatch_async() 2021-02-08 09:19:19 -05:00
libkern Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
mips Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
modules enetc: Add autogenerated files to Makefile 2021-08-08 22:27:16 +02:00
net Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
net80211 Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
netgraph socket: Implement SO_RERROR 2021-07-28 09:35:09 -07:00
netinet sctp: remove some set, but unused variables 2021-08-09 15:58:46 +02:00
netinet6 nd6: Mark several callouts as MPSAFE 2021-08-09 13:27:52 -04:00
netipsec ipsec: Handle ICMP NEEDFRAG message. 2021-08-09 12:01:46 +02:00
netpfil pf: bound DIOCGETSTATES memory use 2021-08-02 16:29:23 +02:00
netsmb netsmb: Avoid a read-after-free in smb_t2_request_int() 2021-05-26 10:45:40 -04:00
nfs Fix panic when using BOOTP to resolve root path. 2021-03-28 14:02:40 -05:00
nfsclient nfs: Cleanup dead files 2021-03-17 06:16:31 +11:00
nfsserver nfs: Cleanup dead files 2021-03-17 06:16:31 +11:00
nlm
ofed ibcore: Kernel space update based on Linux 5.7-rc1. 2021-07-28 13:28:29 +02:00
opencrypto Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
powerpc Add pmap_vm_page_alloc_check() 2021-07-31 16:53:42 +03:00
riscv riscv: Fix pmap_alloc_l2 when it should allocate a new L1 entry 2021-08-09 20:28:37 +01:00
rpc Consistently use the SOLISTENING() macro 2021-06-14 17:32:27 -04:00
security Add fspacectl(2), vn_deallocate(9) and VOP_DEALLOCATE(9). 2021-08-05 23:20:42 +08:00
sys Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
teken loader: implement framebuffer console 2021-01-02 21:41:36 +02:00
tests tests: Revise FIB lookups per second benchmarking routines 2021-06-17 08:49:09 +02:00
tools Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
ufs Clean up orphaned indirdep dependency structures after disk failure. 2021-07-29 16:31:16 -07:00
vm Add vnode_pager_purge_range(9) KPI 2021-08-05 22:52:26 +08:00
x86 Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
xdr
xen xen: introduce xen_pv_disks_disabled() 2021-07-28 17:27:04 +02:00
Makefile