[lkml]   [2016]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] x86/cpuid: expose AVX512_4VNNIW and AVX512_4FMAPS features to kvm guest
On Tue, Nov 01, 2016 at 03:48:50PM +0800, He Chen wrote:
> Before sending a patch, let me check if my understanding is right...
> I will add a helper in scattered.c like:
> unsigned int get_scattered_cpuid_features(unsigned int level,
> unsigned int sub_leaf, enum cpuid_regs reg)
> {
> u32 val = 0;
> const struct cpuid_bit *cb;
> for (cb = cpuid_bits; cb->feature; cb++) {

Right, we can improve that by keeping cpuid_bit.level sorted so that you
can break out early if the level is exceeded. For that please sort it
and add a comment stating that the leaf should be kept sorted ontop of

And then you do something like this:

u32 get_scattered_cpuid_leaf(unsigned int level, unsigned int sub_leaf,
enum cpuid_regs reg)
u32 cpuid_val = 0;

for (cb = cpuid_bits; cb->feature; cb++) {

if (level < cb->level)

if (level > cb->level)

if (cb->reg == reg && sub_leaf == cb->sub_leaf) {
if (cpu_has(cb->feature))
cpuid_val |= BIT(cb->bit);

return cpuid_val;

Completely untested, of course.


ECO tip #101: Trim your mails when you reply.

 \ /
  Last update: 2016-11-01 09:47    [W:0.071 / U:1.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site