aboutsummaryrefslogtreecommitdiff
path: root/sys/arm64
diff options
context:
space:
mode:
authorAndrew Turner <andrew@FreeBSD.org>2020-03-03 08:28:16 +0000
committerAndrew Turner <andrew@FreeBSD.org>2020-03-03 08:28:16 +0000
commit228b87bc31468008c29a39017ebfc1adb33d7a44 (patch)
tree9ef41806b0fb4a4f07f3c0cc66709a91855473e5 /sys/arm64
parent6df6aae9bdb88de1039474c4f4916685021a3b00 (diff)
downloadsrc-228b87bc31468008c29a39017ebfc1adb33d7a44.tar.gz
src-228b87bc31468008c29a39017ebfc1adb33d7a44.zip
Store the boot exception level on arm64 so it can be queried later
A hypervisor, e.g. bhyve, will need to know what exception levelthe kernel was in when it started booting. If it was EL2 we can then enable said hypervisor. Store the boot exception level and allow the kernel to later query it. Obtained from: https://github.com/FreeBSD-UPB/freebsd (earlier version) Sponsored by: Innovate UK
Notes
Notes: svn path=/head/; revision=358567
Diffstat (limited to 'sys/arm64')
-rw-r--r--sys/arm64/arm64/genassym.c1
-rw-r--r--sys/arm64/arm64/locore.S7
-rw-r--r--sys/arm64/arm64/machdep.c10
-rw-r--r--sys/arm64/include/machdep.h3
4 files changed, 18 insertions, 3 deletions
diff --git a/sys/arm64/arm64/genassym.c b/sys/arm64/arm64/genassym.c
index 328addb428e4..3f664d898916 100644
--- a/sys/arm64/arm64/genassym.c
+++ b/sys/arm64/arm64/genassym.c
@@ -45,6 +45,7 @@ ASSYM(BP_KERN_L1PT, offsetof(struct arm64_bootparams, kern_l1pt));
ASSYM(BP_KERN_DELTA, offsetof(struct arm64_bootparams, kern_delta));
ASSYM(BP_KERN_STACK, offsetof(struct arm64_bootparams, kern_stack));
ASSYM(BP_KERN_L0PT, offsetof(struct arm64_bootparams, kern_l0pt));
+ASSYM(BP_BOOT_EL, offsetof(struct arm64_bootparams, boot_el));
ASSYM(TDF_ASTPENDING, TDF_ASTPENDING);
ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED);
diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S
index 9ed76fb8f688..c8b7ded1bf29 100644
--- a/sys/arm64/arm64/locore.S
+++ b/sys/arm64/arm64/locore.S
@@ -165,6 +165,7 @@ virtdone:
adr x25, initstack
str x25, [x0, #BP_KERN_STACK]
str x24, [x0, #BP_KERN_L0PT]
+ str x23, [x0, #BP_BOOT_EL]
/* trace back starts here */
mov fp, #0
@@ -227,9 +228,9 @@ END(mpentry)
* registers and drop to EL1.
*/
drop_to_el1:
- mrs x1, CurrentEL
- lsr x1, x1, #2
- cmp x1, #0x2
+ mrs x23, CurrentEL
+ lsr x23, x23, #2
+ cmp x23, #0x2
b.eq 1f
ret
1:
diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index e26dc09f8536..b1a425ddde8a 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -109,6 +109,7 @@ static struct trapframe proc0_tf;
int early_boot = 1;
int cold = 1;
+static int boot_el;
struct kva_md_info kmi;
@@ -162,6 +163,13 @@ pan_enable(void)
}
}
+bool
+has_hyp(void)
+{
+
+ return (boot_el == 2);
+}
+
static void
cpu_startup(void *dummy)
{
@@ -1090,6 +1098,8 @@ initarm(struct arm64_bootparams *abp)
caddr_t kmdp;
bool valid;
+ boot_el = abp->boot_el;
+
/* Parse loader or FDT boot parametes. Determine last used address. */
lastaddr = parse_boot_param(abp);
diff --git a/sys/arm64/include/machdep.h b/sys/arm64/include/machdep.h
index 7a977ea16367..11d3f2a03712 100644
--- a/sys/arm64/include/machdep.h
+++ b/sys/arm64/include/machdep.h
@@ -35,6 +35,8 @@ struct arm64_bootparams {
uint64_t kern_delta;
vm_offset_t kern_stack;
vm_offset_t kern_l0pt; /* L1 page table for the kernel */
+ int boot_el; /* EL the kernel booted from */
+ int pad;
};
enum arm64_bus {
@@ -46,6 +48,7 @@ enum arm64_bus {
extern enum arm64_bus arm64_bus_method;
void dbg_init(void);
+bool has_hyp(void);
void initarm(struct arm64_bootparams *);
vm_offset_t parse_boot_param(struct arm64_bootparams *abp);
#ifdef FDT