Skip to content

Commit

Permalink
cpu: Fix cpuid check for some AMD processors.
Browse files Browse the repository at this point in the history
Some venerable AMD processors do not support querying extended features
(EAX=7) with cpuid.
In this case, it is not a programmatic error and the runtime check should
simply return the isa is unsupported.

Reported-by: Davide Repetto <red@idp.it>
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=2211747
Fixes: b366fa2 ("dpif-netdev: Call cpuid for x86 isa availability.")
Signed-off-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
  • Loading branch information
david-marchand authored and igsilya committed Jun 7, 2023
1 parent 106ef21 commit 474a179
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/cpu.c
Expand Up @@ -37,7 +37,9 @@ static bool x86_has_isa(uint32_t leaf, enum x86_reg reg, uint32_t bit)
{
uint32_t regs[4];

ovs_assert(__get_cpuid_max(leaf & X86_LEAF_MASK, NULL) >= leaf);
if (__get_cpuid_max(leaf & X86_LEAF_MASK, NULL) < leaf) {
return false;
}

__cpuid_count(leaf, 0, regs[EAX], regs[EBX], regs[ECX], regs[EDX]);
return (regs[reg] & ((uint32_t) 1 << bit)) != 0;
Expand Down

0 comments on commit 474a179

Please sign in to comment.