svn commit: r358567 - in head/sys/arm64: arm64 include

Andrew Turner andrew at FreeBSD.org
Tue Mar 3 08:28:18 UTC 2020


Author: andrew
Date: Tue Mar  3 08:28:16 2020
New Revision: 358567
URL: https://svnweb.freebsd.org/changeset/base/358567

Log:
  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

Modified:
  head/sys/arm64/arm64/genassym.c
  head/sys/arm64/arm64/locore.S
  head/sys/arm64/arm64/machdep.c
  head/sys/arm64/include/machdep.h

Modified: head/sys/arm64/arm64/genassym.c
==============================================================================
--- head/sys/arm64/arm64/genassym.c	Tue Mar  3 08:24:09 2020	(r358566)
+++ head/sys/arm64/arm64/genassym.c	Tue Mar  3 08:28:16 2020	(r358567)
@@ -45,6 +45,7 @@ ASSYM(BP_KERN_L1PT, offsetof(struct arm64_bootparams, 
 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);

Modified: head/sys/arm64/arm64/locore.S
==============================================================================
--- head/sys/arm64/arm64/locore.S	Tue Mar  3 08:24:09 2020	(r358566)
+++ head/sys/arm64/arm64/locore.S	Tue Mar  3 08:28:16 2020	(r358567)
@@ -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:

Modified: head/sys/arm64/arm64/machdep.c
==============================================================================
--- head/sys/arm64/arm64/machdep.c	Tue Mar  3 08:24:09 2020	(r358566)
+++ head/sys/arm64/arm64/machdep.c	Tue Mar  3 08:28:16 2020	(r358567)
@@ -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)
 {
@@ -1089,6 +1097,8 @@ initarm(struct arm64_bootparams *abp)
 	vm_offset_t lastaddr;
 	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);

Modified: head/sys/arm64/include/machdep.h
==============================================================================
--- head/sys/arm64/include/machdep.h	Tue Mar  3 08:24:09 2020	(r358566)
+++ head/sys/arm64/include/machdep.h	Tue Mar  3 08:28:16 2020	(r358567)
@@ -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


More information about the svn-src-head mailing list