git: c36fa8d5022d - main - hwpmc/arm64: Support the kernel booting to VHE
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 25 Jun 2024 09:31:28 UTC
The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=c36fa8d5022db8b4cca01b391d9d82f26c632234 commit c36fa8d5022db8b4cca01b391d9d82f26c632234 Author: Andrew Turner <andrew@FreeBSD.org> AuthorDate: 2024-06-25 08:41:50 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2024-06-25 09:07:19 +0000 hwpmc/arm64: Support the kernel booting to VHE When booting to VHE we need to handle using the PMU at either EL1 or EL2. WE already support EL1 so add support for EL2. Reviewed by: mhorne Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D45527 --- sys/dev/hwpmc/hwpmc_arm64.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/dev/hwpmc/hwpmc_arm64.c b/sys/dev/hwpmc/hwpmc_arm64.c index 4b2fd5cc746f..5d221c738c2f 100644 --- a/sys/dev/hwpmc/hwpmc_arm64.c +++ b/sys/dev/hwpmc/hwpmc_arm64.c @@ -34,6 +34,7 @@ #include <machine/pmc_mdep.h> #include <machine/cpu.h> +#include <machine/machdep.h> #include "opt_acpi.h" @@ -186,10 +187,18 @@ arm64_allocate_pmc(int cpu, int ri, struct pmc *pm, switch (a->pm_caps & (PMC_CAP_SYSTEM | PMC_CAP_USER)) { case PMC_CAP_SYSTEM: + /* Exclude EL0 */ config |= PMEVTYPER_U; + if (in_vhe()) { + /* If in VHE we need to include EL2 and exclude EL1 */ + config |= PMEVTYPER_NSH | PMEVTYPER_P; + } break; case PMC_CAP_USER: + /* Exclude EL1 */ config |= PMEVTYPER_P; + /* Exclude EL2 */ + config &= ~PMEVTYPER_NSH; break; default: /* @@ -197,6 +206,10 @@ arm64_allocate_pmc(int cpu, int ri, struct pmc *pm, * (default setting) or if both flags are specified * (user explicitly requested both qualifiers). */ + if (in_vhe()) { + /* If in VHE we need to include EL2 */ + config |= PMEVTYPER_NSH; + } break; }