Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/evbarm Exit hypervisor mode before entering supervisor



details:   https://anonhg.NetBSD.org/src/rev/06ce7eb51c40
branches:  trunk
changeset: 341910:06ce7eb51c40
user:      marty <marty%NetBSD.org@localhost>
date:      Sat Nov 28 20:51:36 2015 +0000

description:
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.

diffstat:

 sys/arch/evbarm/conf/mk.odroid        |   3 ++-
 sys/arch/evbarm/odroid/odroid_start.S |  25 +++++++++++++++++++++----
 2 files changed, 23 insertions(+), 5 deletions(-)

diffs (64 lines):

diff -r 6a668c2e8bb4 -r 06ce7eb51c40 sys/arch/evbarm/conf/mk.odroid
--- a/sys/arch/evbarm/conf/mk.odroid    Sat Nov 28 18:08:40 2015 +0000
+++ b/sys/arch/evbarm/conf/mk.odroid    Sat Nov 28 20:51:36 2015 +0000
@@ -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 @@
 
 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
 
diff -r 6a668c2e8bb4 -r 06ce7eb51c40 sys/arch/evbarm/odroid/odroid_start.S
--- a/sys/arch/evbarm/odroid/odroid_start.S     Sat Nov 28 18:08:40 2015 +0000
+++ b/sys/arch/evbarm/odroid/odroid_start.S     Sat Nov 28 20:51:36 2015 +0000
@@ -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 @@
        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



Home | Main Index | Thread Index | Old Index