Re: [PATCH 1/2] x86/CPU: Add native CPUID variants returning a single datum

From: Andy Lutomirski
Date: Fri Dec 30 2016 - 21:13:49 EST

On Thu, Dec 29, 2016 at 1:30 AM, Borislav Petkov <bp@xxxxxxxxx> wrote:
> On Wed, Dec 28, 2016 at 10:11:22AM -0800, Andy Lutomirski wrote:
>> On a very quick read, it looks like none of your new call sites
>> actually use the return value at all. Since you also appear to be
>> consolidating them all, would it make sense to just open-code the
>> single (?) remaining user?
> I've got stuff coming up which will use the retval but it is not fully
> cooked yet. And also, we want to have generic helpers so that people do
> not reimplement them left and right.

Okay, but I still think that a variant that says "do cpuid and ignore
the return value" would make sense. Imagine a very clever
implementation of native_cpuid_eax like:

asm ("cpuid" : "=a" (eax) : ...);
return eax;

Now you call it and ignore the return value and the compiler optimizes
it out :) Also, someone reading the code might scratch their head and
wonder why you picked eax and not ebx, ecx, or edx.