ports/sysutils/opensbi/files/patch-lib_sbi_sbi__hart.c
Mitchell Horne cd45ca02e4 sysutils/opensbi: update to v0.9
This change adds a patch to disable the PMP for the sifive/fu540 target,
which is a workaround to a PMP errata in the chip. The OpenSBI update
itself is quite minor.

Bump the dependent port, sysutils/u-boot-sifive-fu540.

Reviewed by:	lwhsu, kp
Approved by:	lwhsu (ports)
Tested by:	Klaus Küchemann (maciphone2@googlemail.com)
Differential Revision:	https://reviews.freebsd.org/D28471
2021-02-04 15:27:38 +00:00

19 lines
596 B
C

--- lib/sbi/sbi_hart.c.orig 2021-01-30 20:30:32 UTC
+++ lib/sbi/sbi_hart.c
@@ -188,6 +188,16 @@ int sbi_hart_pmp_configure(struct sbi_scratch *scratch
if (!pmp_count)
return 0;
+ /*
+ * Disable the PMP for the sifive/fu540 platform, required to work
+ * around a hardware errata.
+ */
+ extern int need_pmp_war;
+ if (need_pmp_war) {
+ pmp_set(0, PMP_R | PMP_W | PMP_X, -1, __riscv_xlen);
+ return 0;
+ }
+
pmp_gran_log2 = log2roundup(sbi_hart_pmp_granularity(scratch));
pmp_bits = sbi_hart_pmp_addrbits(scratch) - 1;
pmp_addr_max = (1UL << pmp_bits) | ((1UL << pmp_bits) - 1);