diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -215,6 +215,14 @@ return (boot_el == 2 && (hcr_el2 & HCR_E2H) == 0); } +bool +in_vhe(void) +{ + /* If we are currently in EL2 then must be in VHE */ + return ((READ_SPECIALREG(CurrentEL) & CURRENTEL_EL_MASK) == + CURRENTEL_EL_EL2); +} + static void cpu_startup(void *dummy) { diff --git a/sys/arm64/include/machdep.h b/sys/arm64/include/machdep.h --- a/sys/arm64/include/machdep.h +++ b/sys/arm64/include/machdep.h @@ -48,6 +48,7 @@ void dbg_init(void); bool has_hyp(void); +bool in_vhe(void); void initarm(struct arm64_bootparams *); vm_offset_t parse_boot_param(struct arm64_bootparams *abp); #ifdef FDT