Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation

From: Borislav Petkov
Date: Sat Dec 03 2016 - 07:44:19 EST


On Fri, Dec 02, 2016 at 09:38:38AM -0800, Andy Lutomirski wrote:
> TBH, I didn't start down this path for performance. I did it because
> I wanted to kill off a CPUID that was breaking on old CPUs that don't
> have CPUID. So I propose MOV-to-CR2 followed by an unconditional
> jump. My goal here is to make the #*!& thing work reliably and not be
> ludicrously slow. Borislav and I mulled over using an alternative to
> use CPUID if and only if we have CPUID, but that doesn't work because
> we call sync_core() before we're done applying alternatives.

Btw if the noinline thing which Linus suggested, works out, we can still
do the alternatives thing with CPUID in sync_core() because we won't
need it in alternatives.c itself anymore.

Just putting it on the table, I know you complained about the mess
yesterday on IRC and in case the CR2 move looks painful on xen, we can
still do what we initially considered. I.e., that thing:

+ /* Do a CPUID if available, otherwise do a forward jump. */
+ alternative_io("jmp 1f\n\t1:", "cpuid",
+ X86_FEATURE_CPUID,
+ "=a" (tmp),
+ "0" (1)
+ : "ebx", "ecx", "edx", "memory");

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.