]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
kern/i386/pc/init: Flush cache only on VIA C3 and earlier
authorValdikSS <iam@valdikss.org.ru>
Fri, 6 Oct 2023 17:13:51 +0000 (20:13 +0300)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 12 Oct 2023 17:18:58 +0000 (19:18 +0200)
The code flushes the cache on VIA processors unconditionally which
is excessive. Check for cpuid family and execute wbinvd only on C3
and earlier.

Fixes: https://savannah.gnu.org/bugs/?45149
Fixes: 25492a0f0 (Add wbinvd around bios call.)
Signed-off-by: ValdikSS <iam@valdikss.org.ru>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/kern/i386/pc/init.c

index 27bc68b8a534ec0cea794f9e0584b58ac0acdfce..326d491c586c51d9967031b2ebbbf2b00bcfda34 100644 (file)
@@ -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, proc_info;
   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, proc_info, /* Don't care. */ manufacturer[0],
+                  manufacturer[2], manufacturer[1]);
+      /* Check model, apply only to VIA C3 and lower. */
+      if (((proc_info & 0xf0) >> 4 | (proc_info & 0xf0000) >> 12) > 10)
+        return;
+    }
+
   grub_bios_via_workaround1 = 0x090f;
   grub_bios_via_workaround2 = 0x090f;
   asm volatile ("wbinvd");