git: 339990879cf4 - stable/13 - Disable superpage use for stage 2 arm64 mappings

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Mon, 23 Jan 2023 12:37:38 UTC
The branch stable/13 has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=339990879cf4837aa20d509bcbddf403107d10a0

commit 339990879cf4837aa20d509bcbddf403107d10a0
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2022-11-07 11:21:42 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2023-01-23 12:36:27 +0000

    Disable superpage use for stage 2 arm64 mappings
    
    When modifying a stage 2 mapping we may need to call into the
    hypervisor to invalidate the TLB. Until it is known if the cost of
    this operation is less than the performance gains superpages offers
    disable their use.
    
    Reviewed by:    kib. markj
    Sponsored by:   Innovate UK
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D37299
    
    (cherry picked from commit 0b976be033c2d7ad774da341e66aa69bfdb7f0ce)
---
 sys/arm64/arm64/pmap.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index f2a94769b40d..6f268c83e503 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -601,8 +601,15 @@ pmap_pte(pmap_t pmap, vm_offset_t va, int *level)
 }
 
 bool
-pmap_ps_enabled(pmap_t pmap __unused)
+pmap_ps_enabled(pmap_t pmap)
 {
+	/*
+	 * Promotion requires a hypervisor call when the kernel is running
+	 * in EL1. To stop this disable superpage support on non-stage 1
+	 * pmaps for now.
+	 */
+	if (pmap->pm_stage != PM_STAGE1)
+		return (false);
 
 	return (superpages_enabled != 0);
 }