riscv: set pmp configuration if kernel is running in M-mode
[sfrench/cifs-2.6.git] / arch / riscv / kernel / head.S
index 271860fc2c3f02a5d50552339a005004444ab456..85f2073e7fe4abee5dcb97f91cd2f07cf9d9f9e7 100644 (file)
@@ -58,6 +58,12 @@ _start_kernel:
        /* Reset all registers except ra, a0, a1 */
        call reset_regs
 
+       /* Setup a PMP to permit access to all of memory. */
+       li a0, -1
+       csrw CSR_PMPADDR0, a0
+       li a0, (PMP_A_NAPOT | PMP_R | PMP_W | PMP_X)
+       csrw CSR_PMPCFG0, a0
+
        /*
         * The hartid in a0 is expected later on, and we have no firmware
         * to hand it to us.