Skip to contentSkip to conversation

x86/CPUID: don't use UB shift when library is built as 32-bit

PATCH In review Jan Beulich 2 participants 2 messages Nov 9, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/CPUID: don't use UB shift when library is built as 32-bit

At least the insn emulator test harness will continue to be buildable (and ought to continue to be usable) also as a 32-bit binary. (Right now the CPU policy test harness is, too, but there it may be less relevant to keep it functional, just like e.g. we don't support fuzzing the insn emulator in 32-bit mode.) Hence the library code needs to cope with this.

xen/lib/x86/cpuid.c +1 -1
@@ -165,7 +165,7 @@ void x86_cpuid_policy_fill_native(struct
         for ( i = 2; i < min_t(unsigned int, 63,
                                ARRAY_SIZE(p->xstate.raw)); ++i )
         {
-            if ( xstates & (1ul << i) )
+            if ( xstates & (1ull << i) )
                 cpuid_count_leaf(0xd, i, &p->xstate.raw[i]);
         }
     }
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jan Beulich

At least the insn emulator test harness will continue to be buildable (and ought to continue to be usable) also as a 32-bit binary. (Right now the CPU policy test harness is, too, but there it may be less relevant to keep it functional, just like e.g. we don't support fuzzing the insn emulator in 32-bit mode.) Hence the library code needs to cope with this.