freebsd-dev/sys
Jessica Clarke ade2ea3c45 riscv: Fix pindex level confusion
The pindex values are assigned from the L3 leaves upwards, meaning there
are NUL2E L3 tables and then NUL1E L2 tables (with a futher NUL0E L1
tables in future when we implement Sv48 support). Therefore anything
below NUL2E is an L3 table's page and anything above or equal to NUL2E
is an L2 table's page (with the threshold of NUL2E + NUL1E marking the
start of the L1 tables' pages in Sv48). Thus all the comparisons and
arithmetic operations must use NUL2E to handle the L3/L2 allocation (and
thus L2/L1 entry) transition point, not NUL1E as all but pmap_alloc_l2
were doing.

To make matters confusing, the NUL1E and NUL2E definitions in the RISC-V
pmap are based on a 4-level page hierarchy but we currently use the
3-level Sv39 format (as that's the only required one, and hardware
support for the 4-level Sv48 is not widespread). This means that, in
effect, the above bug cancels out with the bloated NULxE definitions
such that things "work" (but are still technically wrong, and thus would
break when adding Sv48 support), with one exception. pmap_enter_l2 is
currently the only function to use the correct constant, but since
_pmap_alloc_l3 uses the incorrect constant, it will do complete nonsense
when it needs to allocate a new L2 table (which is rather rare). In this
instance, _pmap_alloc_l3, whilst it would correctly determine the pindex
was for an L2 table, would only subtract NUL1E when computing l1index
and thus go way out of bounds (by 511*512*512 bytes, or 127.75 GiB) of
its own L1 table and, thanks to pmap_distribute_l1, of every other
pmap's L1 table in the whole system. This has likely never been hit as
it would presumably instantly fault and panic.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D31087
2021-07-21 02:51:26 +01:00
..
amd64 linux(4): Allow musl brand to use FUTEX_REQUEUE op. 2021-07-20 14:39:20 +03:00
arm arm: Bump KSTACK_PAGES default to match i386/amd64 2021-07-20 18:35:54 -07:00
arm64 Split out the arm64 ID field comparison function 2021-07-19 21:30:11 +00:00
bsm
cam cam: Mark the qos data is valid in xpd_done_direct() too. 2021-07-17 16:12:00 -06:00
cddl
compat linux(4): Factor out the futex_wait() op into linux_futex_wait(). 2021-07-20 14:40:24 +03:00
conf pf: fix LINT build 2021-07-20 18:08:30 +02:00
contrib zfs: Remove zfs-images submodule 2021-07-19 16:40:09 -04:00
crypto ossl: Use crypto_cursor_segment(). 2021-05-25 16:59:19 -07:00
ddb fix style nit: space after if 2021-05-05 15:26:09 -06:00
dev cgem: Add support for the SiFive FU740 2021-07-21 02:51:25 +01:00
dts dts: Bump the freebsd branding version to 5.13 2021-07-01 18:48:56 +02:00
fs nfscl: Send stateid.seqid of 0 for NFSv4.1/4.2 mounts 2021-07-19 17:35:39 -07:00
gdb
geom geom_label: Partially reinstate old sysinstall(8) workaround 2021-07-21 02:51:25 +01:00
gnu
i386 linux(4): Allow musl brand to use FUTEX_REQUEUE op. 2021-07-20 14:39:20 +03: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 Implement unprivileged chroot 2021-07-20 08:57:53 +00:00
kgssapi
libkern Add missing libkern/strnstr.c file 2021-07-14 17:56:03 -07:00
mips Pass the syscall number to capsicum permission-denied signals 2021-07-16 18:06:44 +01:00
modules pf: syncookie support 2021-07-20 10:36:13 +02:00
net pf: clean up syncookie callout on vnet shutdown 2021-07-20 21:13:25 +02:00
net80211 net80211: ieee80211_probereq_ie fix length calculation for hw scans 2021-06-28 12:17:11 +00:00
netgraph Consistently use the SOLISTENING() macro 2021-06-14 17:32:27 -04:00
netinet pf: syncookie support 2021-07-20 10:36:13 +02:00
netinet6 sctp: Fix errno in case of association setup failures 2021-07-09 23:19:25 +02:00
netipsec ipsec: globalize lft zone and zero out buffers at allocation time 2021-06-28 08:14:26 +00:00
netpfil pf: clean up syncookie callout on vnet shutdown 2021-07-20 21:13:25 +02:00
netsmb netsmb: Avoid a read-after-free in smb_t2_request_int() 2021-05-26 10:45:40 -04:00
nfs
nfsclient
nfsserver
nlm
ofed Fix LINT kernel build issues after c3987b8ea7 . 2021-07-12 18:00:30 +02:00
opencrypto crypto: Remove now-unused crypto_cursor_seg{base,len}. 2021-06-16 15:23:16 -07:00
powerpc Pass the syscall number to capsicum permission-denied signals 2021-07-16 18:06:44 +01:00
riscv riscv: Fix pindex level confusion 2021-07-21 02:51:26 +01:00
rpc Consistently use the SOLISTENING() macro 2021-06-14 17:32:27 -04:00
security mac: cheaper check for ifnet_create_mbuf and ifnet_check_transmit 2021-06-29 15:06:45 +02:00
sys linux(4): Modify sv_onexec hook to return an error. 2021-07-20 09:56:25 +03:00
teken
tests tests: Revise FIB lookups per second benchmarking routines 2021-06-17 08:49:09 +02:00
tools makesyscalls.lua: improve generated file style(9) compliance 2021-05-13 13:59:25 -04:00
ufs ffs_softdep: force sync if journal is low in journal_check_space 2021-06-23 23:47:05 +03:00
vm uma: Fix a few problems with KASAN integration 2021-07-09 20:38:50 -04:00
x86 Drop "All rights reserved" from my copyright statements. 2021-07-20 10:05:50 +03:00
xdr
xen x86/xen: remove PVHv1 code 2021-05-17 11:41:21 +02:00
Makefile