Module Name:    src
Committed By:   marty
Date:           Sat Nov 28 20:51:36 UTC 2015

Modified Files:
        src/sys/arch/evbarm/conf: mk.odroid
        src/sys/arch/evbarm/odroid: odroid_start.S

Log Message:
Exit hypervisor mode before entering supervisor

The Odroid XU4 is booted in hypervisor mode, probably because it is trust
zone enabled.  Before we can put it in supervisor we must explicitly remove
it from hypervisor.

This change is from Nick, who figured it out and adapted code from FreeBSD
to make the necessary change.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/conf/mk.odroid
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/evbarm/odroid/odroid_start.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/conf/mk.odroid
diff -u src/sys/arch/evbarm/conf/mk.odroid:1.1 src/sys/arch/evbarm/conf/mk.odroid:1.2
--- src/sys/arch/evbarm/conf/mk.odroid:1.1	Sun Apr 13 02:26:26 2014
+++ src/sys/arch/evbarm/conf/mk.odroid	Sat Nov 28 20:51:36 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: mk.odroid,v 1.1 2014/04/13 02:26:26 matt Exp $
+#	$NetBSD: mk.odroid,v 1.2 2015/11/28 20:51:36 marty Exp $
 
 .if !empty(MACHINE_ARCH:M*eb)
 EXTRA_LINKFLAGS+=	--be8
@@ -6,6 +6,7 @@ EXTRA_LINKFLAGS+=	--be8
 
 SYSTEM_FIRST_OBJ=	odroid_start.o
 SYSTEM_FIRST_SFILE=	${THISARM}/odroid/odroid_start.S
+AFLAGS.odroid_start.S+=        -Wa,-march=armv7-a+virt
 
 GENASSYM_EXTRAS+=	${THISARM}/odroid/genassym.cf
 

Index: src/sys/arch/evbarm/odroid/odroid_start.S
diff -u src/sys/arch/evbarm/odroid/odroid_start.S:1.17 src/sys/arch/evbarm/odroid/odroid_start.S:1.18
--- src/sys/arch/evbarm/odroid/odroid_start.S:1.17	Fri Nov 27 09:45:03 2015
+++ src/sys/arch/evbarm/odroid/odroid_start.S	Sat Nov 28 20:51:36 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: odroid_start.S,v 1.17 2015/11/27 09:45:03 skrll Exp $	*/
+/*	$NetBSD: odroid_start.S,v 1.18 2015/11/28 20:51:36 marty Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -46,7 +46,7 @@
 
 #include <evbarm/odroid/platform.h>
 
-RCSID("$NetBSD: odroid_start.S,v 1.17 2015/11/27 09:45:03 skrll Exp $")
+RCSID("$NetBSD: odroid_start.S,v 1.18 2015/11/28 20:51:36 marty Exp $")
 
 
 #if defined(VERBOSE_INIT_ARM)
@@ -88,9 +88,26 @@ _C_LABEL(odroid_start):
 	setend	be			/* force big endian */
 #endif
 
-	/* Move into supervisor mode and disable IRQs/FIQs. */
-	cpsid	if, #PSR_SVC32_MODE
+//        .arch_extension virt
+        /* Leave HYP mode */
+        mrs        r0, cpsr
+        and        r0, r0, #(PSR_MODE)   /* Mode is in the low 5 bits of CPSR */
+        teq        r0, #(PSR_HYP32_MODE) /* Hyp Mode? */
+        bne        1f
+        /* Ensure that IRQ, FIQ and Aborts will be disabled after eret */
+        mrs        r0, cpsr
+        bic        r0, r0, #(PSR_MODE)
+        orr        r0, r0, #(PSR_SVC32_MODE)
+        orr        r0, r0, #(I32_bit | F32_bit)
+        msr        spsr_cxsf, r0
+        /* Exit hypervisor mode */
+        adr        lr, 1f
+        msr        elr_hyp, lr
+        eret
+1:
 
+//        /* Move into supervisor mode and disable IRQs/FIQs. */
+//        cpsid        if, #PSR_SVC32_MODE
 	/*
 	 * Save any arguments passed to us.  If .start is not at
 	 * 0x80000000 but .text is, we can't directly use the address that

Reply via email to