Put the arm64 vttbr_el2 register into a state

Zero the vttbr_el2 register on each CPU so we can tell if we are
running the host or guest kernel from a hypervisor.

Obtained from:	https://github.com/FreeBSD-UPB/freebsd-src (earlier version)
Sponsored by:	Innovate UK
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Andrew Turner 2022-11-15 12:53:28 +00:00
parent 80ba994bfa
commit ae43a817d3
2 changed files with 4 additions and 0 deletions

View File

@ -295,6 +295,9 @@ LENTRY(drop_to_el1)
add x2, x2, :lo12:hyp_vectors
msr vbar_el2, x2
/* Zero vttbr_el2 so a hypervisor can tell the host and guest apart */
msr vttbr_el2, xzr
mov x2, #(PSR_F | PSR_I | PSR_A | PSR_D | PSR_M_EL1h)
msr spsr_el2, x2

View File

@ -199,6 +199,7 @@
/* VTTBR_EL2 - Virtualization Translation Table Base Register */
#define VTTBR_VMID_MASK 0xffff000000000000
#define VTTBR_VMID_SHIFT 48
/* Assumed to be 0 by locore.S */
#define VTTBR_HOST 0x0000000000000000
#endif /* !_MACHINE_HYPERVISOR_H_ */