git: 79a19e0e8d8d - main - arm64/vmm: Hide non-VHE exception code from VHE

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Tue, 20 Aug 2024 09:02:25 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=79a19e0e8d8d1fa71092e542671213bfe99b024e

commit 79a19e0e8d8d1fa71092e542671213bfe99b024e
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2024-08-19 12:44:24 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-08-20 08:49:16 +0000

    arm64/vmm: Hide non-VHE exception code from VHE
    
    Remove the non-VHE exception code from the VHE code path. As we replace
    the exception vectors when entering the guest we don't need to check
    which context we are in so can skip parts of the exception vectors.
    
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D46082
---
 sys/arm64/vmm/vmm_hyp_exception.S | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sys/arm64/vmm/vmm_hyp_exception.S b/sys/arm64/vmm/vmm_hyp_exception.S
index cd2b94f1ff0b..95b0e20f37ed 100644
--- a/sys/arm64/vmm/vmm_hyp_exception.S
+++ b/sys/arm64/vmm/vmm_hyp_exception.S
@@ -183,6 +183,7 @@ hyp_vectors:
 
 
 .macro handle_el2_excp type
+#ifndef VMM_VHE
 	/* Save registers before modifying so we can restore them */
 	str	x9, [sp, #-16]!
 
@@ -193,15 +194,18 @@ hyp_vectors:
 
 	/* We got the exception while the guest was running */
 	ldr	x9, [sp], #16
+#endif /* !VMM_VHE */
 	do_world_switch_to_host
 	mov	x0, \type
 	ret
 
+#ifndef VMM_VHE
 1:
 	/* We got the exception while the host was running */
 	ldr	x9, [sp], #16
 	mov	x0, \type
 	ERET
+#endif /* !VMM_VHE */
 .endm
 
 
@@ -223,6 +227,7 @@ LEND(handle_el2_el2h_error)
 
 
 LENTRY(handle_el2_el1_sync64)
+#ifndef VMM_VHE
 	/* Save registers before modifying so we can restore them */
 	str	x9, [sp, #-16]!
 
@@ -245,7 +250,9 @@ LENTRY(handle_el2_el1_sync64)
 	ldr	lr, [sp], #16
 	ERET
 
-1:	/* Guest exception taken to EL2 */
+1:
+#endif
+	/* Guest exception taken to EL2 */
 	do_world_switch_to_host
 	mov	x0, #EXCP_TYPE_EL1_SYNC
 	ret