git: 21ef40aea1d3 - stable/13 - Always enable the virtual timer for userspace

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Mon, 15 May 2023 15:45:55 UTC
The branch stable/13 has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=21ef40aea1d312910163a25a890c679814936c11

commit 21ef40aea1d312910163a25a890c679814936c11
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2023-03-10 12:43:59 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2023-05-15 07:59:43 +0000

    Always enable the virtual timer for userspace
    
    We always have it, some languages assume it's present, e.g. go
    before 1.20. Enable it by default on arm and arm64.
    
    PR:             269070
    Reviewed by:    kevans
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D39059
    
    (cherry picked from commit 93d574ea957decec1c95dea9bfa8bc72457cc60d)
---
 sys/arm/arm/generic_timer.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/sys/arm/arm/generic_timer.c b/sys/arm/arm/generic_timer.c
index cba354909100..e0ec6281e402 100644
--- a/sys/arm/arm/generic_timer.c
+++ b/sys/arm/arm/generic_timer.c
@@ -266,13 +266,12 @@ setup_user_access(void *arg __unused)
 
 	cntkctl = get_el1(cntkctl);
 	cntkctl &= ~(GT_CNTKCTL_PL0PTEN | GT_CNTKCTL_PL0VTEN |
-	    GT_CNTKCTL_EVNTEN);
+	    GT_CNTKCTL_EVNTEN | GT_CNTKCTL_PL0PCTEN);
+	/* Always enable the virtual timer */
+	cntkctl |= GT_CNTKCTL_PL0VCTEN;
+	/* Enable the physical timer if supported */
 	if (arm_tmr_sc->physical) {
 		cntkctl |= GT_CNTKCTL_PL0PCTEN;
-		cntkctl &= ~GT_CNTKCTL_PL0VCTEN;
-	} else {
-		cntkctl |= GT_CNTKCTL_PL0VCTEN;
-		cntkctl &= ~GT_CNTKCTL_PL0PCTEN;
 	}
 	set_el1(cntkctl, cntkctl);
 	isb();