Re: [tip:x86/urgent] x86/CPU: Add native CPUID variants returning a single datum
From: Borislav Petkov
Date: Tue Jan 10 2017 - 12:09:48 EST
On Tue, Jan 10, 2017 at 08:40:39AM -0800, hpa@xxxxxxxxx wrote:
> You are introducing a new API; makes more sense to do it right from
> the start. The only reason not to have a subleaf for the non-native
> variants is that they may decay into a function call so there is an
> extra cost.
The "do it right" is what I'm not sure of. Do you see any use cases for
the subleaf != 0 *native* variant at all?
Most if not all users of native_cpuid() in the tree set ecx to 0.
> C doesn't allow function name overloading ;) (Well, except the C11
> type hacks; to the best of my knowledge that doesn't in any way
> support argument *count* overloading.)
Grr, I forgot to change the function name. I didn't mean that.
>From looking at it again, what I mean would be ugly too :-)
I guess *if* the need arises - and again, I'm really sceptical about it
- we should simply add the respective native version of cpuid_count():
/* Some CPUID calls want 'count' to be placed in ecx */
static inline void native_cpuid_count(unsigned int op, int count,
unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)
{
*eax = op;
*ecx = count;
native_cpuid(eax, ebx, ecx, edx);
}
Because this way you have both native and non-native versions nicely
comparable wrt arguments and retvals. And there won't be any confusion
wrt to "oh, the native version takes different args". This was my main
intent wrt the native_cpuid_<reg>() versions - to be consistent with the
cpuid_<reg>() ones.
--
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix ImendÃrffer, Jane Smithard, Graham Norton, HRB 21284 (AG NÃrnberg)
--