diff options
author | Wesley W. Terpstra <wesley@sifive.com> | 2017-04-05 16:27:19 -0700 |
---|---|---|
committer | Wesley W. Terpstra <wesley@sifive.com> | 2017-04-05 17:25:21 -0700 |
commit | 8b4421bacba28f97da2ddeb6a6fba9e184e91bee (patch) | |
tree | d4d3cad1671503a47ae6e56821da8e69f2793da0 | |
parent | 91636ac4639a7993c485288d34f1c8e22b1980b4 (diff) | |
download | riscv-pk-8b4421bacba28f97da2ddeb6a6fba9e184e91bee.zip riscv-pk-8b4421bacba28f97da2ddeb6a6fba9e184e91bee.tar.gz riscv-pk-8b4421bacba28f97da2ddeb6a6fba9e184e91bee.tar.bz2 |
bbl: prevent named cores from booting
-rw-r--r-- | bbl/bbl.c | 2 | ||||
-rw-r--r-- | machine/mentry.S | 14 | ||||
-rw-r--r-- | machine/minit.c | 2 | ||||
-rw-r--r-- | machine/mtrap.c | 1 | ||||
-rw-r--r-- | machine/mtrap.h | 3 |
5 files changed, 19 insertions, 3 deletions
@@ -23,7 +23,7 @@ static void filter_dtb(uintptr_t source) memcpy((void*)dest, (void*)source, size); // Remove information from the chained FDT - // filter_harts(dest, 0x2); + filter_harts(dest, HART_MASK); filter_plic(dest); filter_compat(dest, "riscv,clint0"); filter_compat(dest, "riscv,debug-013"); diff --git a/machine/mentry.S b/machine/mentry.S index 9575dc9..62a850d 100644 --- a/machine/mentry.S +++ b/machine/mentry.S @@ -257,7 +257,11 @@ do_reset: slli a2, a3, RISCV_PGSHIFT add sp, sp, a2 - beqz a3, init_first_hart + # Boot on the first unmasked hart + li a4, (~HART_MASK & (HART_MASK+1)) + srl a4, a4, a3 + andi a4, a4, 1 + bnez a4, init_first_hart # set MSIE bit to receive IPI li a2, MIP_MSIP @@ -267,6 +271,14 @@ do_reset: #if MAX_HARTS > 1 # wait for an IPI to signal that it's safe to boot wfi + + # masked harts never start + li a4, HART_MASK + srl a4, a4, a3 + andi a4, a4, 1 + bnez a4, .LmultiHart + + # only start if mip is set csrr a2, mip andi a2, a2, MIP_MSIP beqz a2, .LmultiHart diff --git a/machine/minit.c b/machine/minit.c index baf45a5..94a1491 100644 --- a/machine/minit.c +++ b/machine/minit.c @@ -124,7 +124,7 @@ static void hart_plic_init() static void wake_harts() { for (int hart = 0; hart < MAX_HARTS; ++hart) - if (((hart_mask >> hart) & 1)) + if ((((~HART_MASK & hart_mask) >> hart) & 1)) *OTHER_HLS(hart)->ipi = 1; // wakeup the hart } diff --git a/machine/mtrap.c b/machine/mtrap.c index d7def4c..be264f3 100644 --- a/machine/mtrap.c +++ b/machine/mtrap.c @@ -50,6 +50,7 @@ void printm(const char* s, ...) static void send_ipi(uintptr_t recipient, int event) { + if (((HART_MASK >> recipient) & 1)) return; atomic_or(&OTHER_HLS(recipient)->mipi_pending, event); mb(); *OTHER_HLS(recipient)->ipi = 1; diff --git a/machine/mtrap.h b/machine/mtrap.h index e8dfc49..1437b11 100644 --- a/machine/mtrap.h +++ b/machine/mtrap.h @@ -9,6 +9,9 @@ # define MAX_HARTS 1 #endif +// These harts will be prevented from booting beyond bbl +#define HART_MASK 0x0UL + #ifndef __ASSEMBLER__ #include <stdint.h> |