]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Support creating and using arm64 pmap at stage 2
authorAndrew Turner <andrew@FreeBSD.org>
Wed, 27 May 2020 08:00:38 +0000 (08:00 +0000)
committerAndrew Turner <andrew@FreeBSD.org>
Wed, 27 May 2020 08:00:38 +0000 (08:00 +0000)
commit2cb0e95f48cbdad706d4ccfef9da832b3e5af995
tree2c929f08e2e73d77616570c62706417272b815f5
parent69c41b7071b2e7683fced837f503db59c38dd093
Support creating and using arm64 pmap at stage 2

Add minimal support for creating stage 2 IPA -> PA mappings. For this we
need to:

 - Create a new vmid set to allocate a vmid for each Virtual Machine
 - Add the missing stage 2 attributes
 - Use these in pmap_enter to create a new mapping
 - Handle stage 2 faults

The vmid set is based on the current asid set that was generalised in
r358328. It adds a function pointer for bhyve to use when the kernel needs
to reset the vmid set. This will need to call into EL2 and invalidate the
TLB.

The stage 2 attributes have been added. To simplify setting these fields
two new functions are added to get the memory type and protection fields.
These are slightly different on stage 1 and stage 2 tables. We then use
them in pmap_enter to set the new level 3 entry to be stored.

The D-cache on all entries is cleaned to the point of coherency. This is
to allow the data to be visible to the VM. To allow for userspace to load
code when creating a new executable entry an invalid entry is created. When
the VM tried to use it the I-cache is invalidated. As the D-cache has
already been cleaned this will ensure the I-cache is synchronised with the
D-cache.

When the hardware implements a VPIPT I-cache we need to either have the
correct VMID set or invalidate it from EL2. As the host kernel will have
the wrong VMID set we need to call into EL2 to clean it. For this a second
function pointer is added that is called when this invalidation is needed.

Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D23875
sys/arm64/arm64/pmap.c
sys/arm64/include/cpufunc.h
sys/arm64/include/pcpu.h
sys/arm64/include/pmap.h
sys/arm64/include/pte.h