Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <adobriyan@gmail.com>
Acked-by: Juergen Gross <jgross@suse.com>
Message-ID: <20240802154253.482658-2-adobriyan@gmail.com>
Signed-off-by: Juergen Gross <jgross@suse.com>

authored by

Alexey Dobriyan and committed by
Juergen Gross
416a33c9 661362e3

+6 -1
+6 -1
arch/x86/include/asm/cpuid.h
··· 196 196 for_each_possible_hypervisor_cpuid_base(base) { 197 197 cpuid(base, &eax, &signature[0], &signature[1], &signature[2]); 198 198 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) && 200 205 (leaves == 0 || ((eax - base) >= leaves))) 201 206 return base; 202 207 }