arm64: Add in_vhe() to find if the kernel is in VHE

Add a function to support devices that may need to know if the kernel
has enabled the Armv8.1 Virtulization Host Extensions (FEAT_VHE).
Some devices, e.g. the generic timer, will need to know, e.g. use a
different interrupt.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D43973
This commit is contained in:
Andrew Turner 2024-01-11 17:01:52 +00:00
parent 37563d39ef
commit 353b6a5bcb
2 changed files with 9 additions and 0 deletions

View file

@ -215,6 +215,14 @@ has_hyp(void)
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)
{

View file

@ -48,6 +48,7 @@ extern enum arm64_bus arm64_bus_method;
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