lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20161101084641.2a66qov3itzfbmnt@pd.tnic>
Date:   Tue, 1 Nov 2016 09:46:41 +0100
From:   Borislav Petkov <bp@...en8.de>
To:     He Chen <he.chen@...ux.intel.com>
Cc:     Paolo Bonzini <pbonzini@...hat.com>,
        "Luc, Piotr" <Piotr.Luc@...el.com>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "x86@...nel.org" <x86@...nel.org>, "hpa@...or.com" <hpa@...or.com>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "Kang, Luwei" <luwei.kang@...el.com>,
        "rkrcmar@...hat.com" <rkrcmar@...hat.com>
Subject: Re: [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
it.

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)
			continue;

		if (level > cb->level)
			break;

		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.

-- 
Regards/Gruss,
    Boris.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ