git: 4dd63b65cb76 - stable/13 - Put the arm64 vttbr_el2 register into a state
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 23 Jan 2023 12:37:40 UTC
The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=4dd63b65cb76ed963dbd23b651ea8e2895b4dd20 commit 4dd63b65cb76ed963dbd23b651ea8e2895b4dd20 Author: Andrew Turner <andrew@FreeBSD.org> AuthorDate: 2022-11-15 12:53:28 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2023-01-23 12:36:28 +0000 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 (cherry picked from commit ae43a817d33db3aa51f6dfce8dd940f06716e2a9) --- sys/arm64/arm64/locore.S | 3 +++ sys/arm64/include/hypervisor.h | 1 + 2 files changed, 4 insertions(+) diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S index 94c8f8b87403..70ddfe4893f3 100644 --- a/sys/arm64/arm64/locore.S +++ b/sys/arm64/arm64/locore.S @@ -283,6 +283,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 diff --git a/sys/arm64/include/hypervisor.h b/sys/arm64/include/hypervisor.h index f209ecde120a..dc6ccbfe20a9 100644 --- a/sys/arm64/include/hypervisor.h +++ b/sys/arm64/include/hypervisor.h @@ -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_ */