Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F171548636
D59050.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D59050.id.diff
View Options
diff --git a/sys/riscv/include/md_var.h b/sys/riscv/include/md_var.h
--- a/sys/riscv/include/md_var.h
+++ b/sys/riscv/include/md_var.h
@@ -49,6 +49,8 @@
extern bool has_vector;
extern bool has_svinval;
+extern bool has_errata_buggy_sfence;
+
struct dumperinfo;
struct minidumpstate;
diff --git a/sys/riscv/riscv/identcpu.c b/sys/riscv/riscv/identcpu.c
--- a/sys/riscv/riscv/identcpu.c
+++ b/sys/riscv/riscv/identcpu.c
@@ -86,6 +86,12 @@
bool has_zicboz;
bool has_zicbop;
+/*
+ * CIP-1200: A non-global sfence may leave stale mappings if it races with
+ * I-TLB refill. sfence.vma x0, x0 should be used in all cases.
+ */
+bool __read_frequently has_errata_buggy_sfence = false;
+
struct cpu_desc {
const char *cpu_mvendor_name;
const char *cpu_march_name;
@@ -528,6 +534,21 @@
}
}
+static void
+handle_sifive_quirks(u_int cpu, struct cpu_desc *desc)
+{
+ if (cpu != 0)
+ return;
+
+ switch (marchid) {
+ case 0x1:
+ case MARCHID_SIFIVE_U7:
+ if ((mimpid & 0xffffff) > 0x200630 || mimpid == 0x1200626)
+ has_errata_buggy_sfence = true;
+ break;
+ }
+}
+
static void
handle_thead_quirks(u_int cpu, struct cpu_desc *desc)
{
@@ -554,6 +575,9 @@
handle_cpu_quirks(u_int cpu, struct cpu_desc *desc)
{
switch (mvendorid) {
+ case MVENDORID_SIFIVE:
+ handle_sifive_quirks(cpu, desc);
+ break;
case MVENDORID_THEAD:
handle_thead_quirks(cpu, desc);
break;
diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c
--- a/sys/riscv/riscv/pmap.c
+++ b/sys/riscv/riscv/pmap.c
@@ -968,6 +968,8 @@
* Global 'G' PTE bit feature support.
*/
TUNABLE_BOOL_FETCH("vm.pmap.global_bit_enabled", &global_bit_enabled);
+ if (has_errata_buggy_sfence)
+ global_bit_enabled = false;
if (!global_bit_enabled)
pte_g = 0;
@@ -1088,7 +1090,7 @@
static __inline void
pmap_local_invalidate_all(pmap_t pmap)
{
- if (pmap == kernel_pmap)
+ if (pmap == kernel_pmap || __predict_false(has_errata_buggy_sfence))
sfence_vma();
else
sfence_vma_asid(0);
@@ -1252,6 +1254,8 @@
{
if (has_svinval)
return (pmap_invalidate_range_svinval);
+ if (has_errata_buggy_sfence)
+ return (pmap_invalidate_range_sbi_global);
return (pmap_invalidate_range_sbi);
}
@@ -1260,11 +1264,13 @@
{
if (has_svinval)
return (pmap_invalidate_page_svinval);
+ if (has_errata_buggy_sfence)
+ return (pmap_invalidate_page_sbi_global);
return (pmap_invalidate_page_sbi);
}
static void
-pmap_invalidate_all_global(pmap_t pmap)
+pmap_invalidate_all_sbi_global(pmap_t pmap)
{
cpuset_t mask;
@@ -1281,12 +1287,12 @@
}
static void
-pmap_invalidate_all(pmap_t pmap)
+pmap_invalidate_all_sbi(pmap_t pmap)
{
cpuset_t mask;
if (pmap == kernel_pmap) {
- pmap_invalidate_all_global(pmap);
+ pmap_invalidate_all_sbi_global(pmap);
return;
}
@@ -1302,6 +1308,13 @@
sched_unpin();
}
+DEFINE_IFUNC(, void, pmap_invalidate_all, (pmap_t pmap))
+{
+ if (has_errata_buggy_sfence)
+ return (pmap_invalidate_all_sbi_global);
+ return (pmap_invalidate_all_sbi);
+}
+
#else /* !SMP */
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Sep 12, 5:08 PM (6 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38763077
Default Alt Text
D59050.id.diff (2 KB)
Attached To
Mode
D59050: sifive: handle sfence.vma errata
Attached
Detach File
Event Timeline
Log In to Comment