ce63d81
From 3fcb817840fd4bed114d6bbe7275d08310feb797 Mon Sep 17 00:00:00 2001
ce63d81
From: David Marchand <david.marchand@redhat.com>
ce63d81
Date: Wed, 7 Jun 2023 10:24:40 +0200
ce63d81
Subject: [PATCH] cpu: Fix cpuid check for some AMD processors.
ce63d81
ce63d81
Some venerable AMD processors do not support querying extended features
ce63d81
(EAX=7) with cpuid.
ce63d81
In this case, it is not a programmatic error and the runtime check should
ce63d81
simply return the isa is unsupported.
ce63d81
ce63d81
Reported-by: Davide Repetto <red@idp.it>
ce63d81
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=2211747
ce63d81
Fixes: b366fa2f4947 ("dpif-netdev: Call cpuid for x86 isa availability.")
ce63d81
Signed-off-by: David Marchand <david.marchand@redhat.com>
ce63d81
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
ce63d81
---
ce63d81
 lib/cpu.c | 4 +++-
ce63d81
 1 file changed, 3 insertions(+), 1 deletion(-)
ce63d81
ce63d81
diff --git a/lib/cpu.c b/lib/cpu.c
ce63d81
index 0292f715e..fbbea4005 100644
ce63d81
--- a/lib/cpu.c
ce63d81
+++ b/lib/cpu.c
ce63d81
@@ -37,7 +37,9 @@ static bool x86_has_isa(uint32_t leaf, enum x86_reg reg, uint32_t bit)
ce63d81
 {
ce63d81
     uint32_t regs[4];
ce63d81
 
ce63d81
-    ovs_assert(__get_cpuid_max(leaf & X86_LEAF_MASK, NULL) >= leaf);
ce63d81
+    if (__get_cpuid_max(leaf & X86_LEAF_MASK, NULL) < leaf) {
ce63d81
+        return false;
ce63d81
+    }
ce63d81
 
ce63d81
     __cpuid_count(leaf, 0, regs[EAX], regs[EBX], regs[ECX], regs[EDX]);
ce63d81
     return (regs[reg] & ((uint32_t) 1 << bit)) != 0;
ce63d81
-- 
ce63d81
2.40.1
ce63d81