Skip to contentSkip to conversation

i386: flush cache only on VIA C3 and earlier

PATCH In review ValdikSS 3 participants 3 messages Jul 6, 2023 – Oct 6, 2023

lore
Share & tools
lore

ValdikSS

author
#0 lore raw

PATCH v2 1/1 i386: flush cache only on VIA C3 and earlier

The code used to flush the cache on VIA processors unconditionally, which is excessive.
Check for cpuid family and execute wbinvd only on C3 and earlier.

See: https://savannah.gnu.org/bugs/?45149
See: commit 25492a0f047cb7a6583ae195568599c296a604d6

---
 grub-core/kern/i386/pc/init.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
grub-core/kern/i386/pc/init.c +10 -1
index 27bc68b8a..7f08d2067 100644
@@ -191,7 +191,7 @@ extern grub_uint16_t grub_bios_via_workaround1, grub_bios_via_workaround2;
 static void
 grub_via_workaround_init (void)
 {
-  grub_uint32_t manufacturer[3], max_cpuid;
+  grub_uint32_t manufacturer[3], max_cpuid, procinfo;
   if (! grub_cpu_is_cpuid_supported ())
     return;
 
@@ -200,6 +200,15 @@ grub_via_workaround_init (void)
   if (grub_memcmp (manufacturer, "CentaurHauls", 12) != 0)
     return;
 
+  if (max_cpuid > 0)
+    {
+      grub_cpuid (1, procinfo, /* Don't care */ manufacturer[0],
+                  manufacturer[2], manufacturer[1]);
+      /* Check model, apply only to VIA C3 and lower */
+      if (((procinfo & 0xF0) >> 4 | (procinfo & 0xF0000) >> 12) > 10)
+        return;
+    }
+
   grub_bios_via_workaround1 = 0x090f;
   grub_bios_via_workaround2 = 0x090f;
   asm volatile ("wbinvd");
Signature · 1 line
2.41.0
#1 lore raw
Quoted 6 lines · ValdikSS via Grub-devel

The code used to flush the cache on VIA processors unconditionally, which is excessive.
Check for cpuid family and execute wbinvd only on C3 and earlier.

See: https://savannah.gnu.org/bugs/?45149
See: commit 25492a0f047cb7a6583ae195568599c296a604d6

s/See/Fixes/

The patch misses Signed-off-by line too. I can add it on your behalf if you are OK with it.

Otherwise Reviewed-by: Daniel Kiper <[email protected]>...

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#2 lore raw
Quoted 9 lines · Daniel Kiper
Quoted 6 lines · ValdikSS via Grub-devel

The code used to flush the cache on VIA processors unconditionally, which is excessive.
Check for cpuid family and execute wbinvd only on C3 and earlier.

See: https://savannah.gnu.org/bugs/?45149
See: commit 25492a0f047cb7a6583ae195568599c296a604d6

s/See/Fixes/

Done, check v3.

Quoted 5 lines

The patch misses Signed-off-by line too. I can add it on your behalf if you are OK with it.

Otherwise Reviewed-by: Daniel Kiper <[email protected]>...

+++

Quoted 2 lines

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel