kern/i386/pc/init: Flush cache only on VIA C3 and earlier

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>
This commit is contained in:
ValdikSS 2023-10-06 20:13:51 +03:00 committed by Daniel Kiper
parent 3c7e842571
commit cab04dcda3

View 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");