Page MenuHomeFreeBSD

D38884.diff
No OneTemporary

D38884.diff

diff --git a/sys/arm64/arm64/genassym.c b/sys/arm64/arm64/genassym.c
--- a/sys/arm64/arm64/genassym.c
+++ b/sys/arm64/arm64/genassym.c
@@ -45,6 +45,7 @@
ASSYM(BP_KERN_STACK, offsetof(struct arm64_bootparams, kern_stack));
ASSYM(BP_KERN_TTBR0, offsetof(struct arm64_bootparams, kern_ttbr0));
ASSYM(BP_BOOT_EL, offsetof(struct arm64_bootparams, boot_el));
+ASSYM(BP_HCR_EL2, offsetof(struct arm64_bootparams, hcr_el2));
ASSYM(PCPU_SIZE, sizeof(struct pcpu));
ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb));
diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S
--- a/sys/arm64/arm64/locore.S
+++ b/sys/arm64/arm64/locore.S
@@ -146,6 +146,7 @@
str x25, [x0, #BP_KERN_STACK]
str x27, [x0, #BP_KERN_TTBR0]
str x23, [x0, #BP_BOOT_EL]
+ str x4, [x0, #BP_HCR_EL2]
/* trace back starts here */
mov fp, #0
@@ -286,8 +287,8 @@
*/
tst x4, #HCR_E2H
mov x3, #CPTR_RES1 /* HCR_E2H == 0 */
- mov x4, #CPTR_FPEN /* HCR_E2H == 1 */
- csel x2, x3, x4, eq
+ mov x5, #CPTR_FPEN /* HCR_E2H == 1 */
+ csel x2, x3, x5, eq
msr cptr_el2, x2
/* Don't trap to EL2 for CP15 traps */
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
@@ -78,6 +78,7 @@
#include <machine/armreg.h>
#include <machine/cpu.h>
#include <machine/debug_monitor.h>
+#include <machine/hypervisor.h>
#include <machine/kdb.h>
#include <machine/machdep.h>
#include <machine/metadata.h>
@@ -124,6 +125,7 @@
int early_boot = 1;
int cold = 1;
static int boot_el;
+static uint64_t hcr_el2;
struct kva_md_info kmi;
@@ -191,7 +193,11 @@
has_hyp(void)
{
- return (boot_el == 2);
+ /*
+ * XXX The E2H check is wrong, but it's close enough for now. Needs to
+ * be re-evaluated once we're running regularly in EL2.
+ */
+ return (boot_el == 2 && (hcr_el2 & HCR_E2H) == 0);
}
static void
@@ -865,6 +871,7 @@
TSRAW(&thread0, TS_ENTER, __func__, NULL);
boot_el = abp->boot_el;
+ hcr_el2 = abp->hcr_el2;
/* 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
--- a/sys/arm64/include/machdep.h
+++ b/sys/arm64/include/machdep.h
@@ -36,6 +36,7 @@
uint64_t kern_delta;
vm_offset_t kern_stack;
vm_paddr_t kern_ttbr0;
+ uint64_t hcr_el2;
int boot_el; /* EL the kernel booted from */
int pad;
};

File Metadata

Mime Type
text/plain
Expires
Tue, May 19, 5:47 AM (35 m, 59 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33295204
Default Alt Text
D38884.diff (2 KB)

Event Timeline