Skip to content

Commit 416a33c

Browse files
Alexey Dobriyanjgross1
authored andcommitted
x86/cpu: fix unbootable VMs by inlining memcmp() in hypervisor_cpuid_base()
If this memcmp() is not inlined then PVH early boot code can call into KASAN-instrumented memcmp() which results in unbootable VMs: pvh_start_xen xen_prepare_pvh xen_cpuid_base hypervisor_cpuid_base memcmp Signed-off-by: Alexey Dobriyan <[email protected]> Acked-by: Juergen Gross <[email protected]> Message-ID: <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent 661362e commit 416a33c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arch/x86/include/asm/cpuid.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,12 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
196196
for_each_possible_hypervisor_cpuid_base(base) {
197197
cpuid(base, &eax, &signature[0], &signature[1], &signature[2]);
198198

199-
if (!memcmp(sig, signature, 12) &&
199+
/*
200+
* This must not compile to "call memcmp" because it's called
201+
* from PVH early boot code before instrumentation is set up
202+
* and memcmp() itself may be instrumented.
203+
*/
204+
if (!__builtin_memcmp(sig, signature, 12) &&
200205
(leaves == 0 || ((eax - base) >= leaves)))
201206
return base;
202207
}

0 commit comments

Comments
 (0)