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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.21.1810171151010.6000@nanos.tec.linutronix.de>
Date:   Wed, 17 Oct 2018 11:59:59 +0200 (CEST)
From:   Thomas Gleixner <tglx@...utronix.de>
To:     Andi Kleen <andi@...stfloor.org>
cc:     peterz@...radead.org, x86@...nel.org, eranian@...gle.com,
        kan.liang@...el.com, linux-kernel@...r.kernel.org,
        Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH v2 1/2] x86/cpufeature: Add facility to match microcode
 revisions

On Wed, 10 Oct 2018, Andi Kleen wrote:
> +/*
> + * Match specific microcodes
> + *
> + * vendor/family/model/stepping must be all set.
> + * min_ucode is optional and can be 0.

Stale comment

> + */
> +
> +struct x86_ucode_id {
> +	u8 vendor;
> +	u8 family;
> +	u16 model;
> +	u16 stepping;

Still using u16 for no reason. And please make the members aligned in a
tabular fashion.

> +	u32 min_ucode;
> +};
> +
> +const struct x86_ucode_id *x86_match_ucode(const struct x86_ucode_id *match)

What's the point of returning the struct pointer? Shouldn't it be enough to
make it return bool? Also the function name really should reflect that this
checks whether the minimal required microcode revision is active.

> +{
> +	struct cpuinfo_x86 *c = &boot_cpu_data;
> +	const struct x86_ucode_id *m;
> +
> +	for (m = match; m->vendor | m->family | m->model; m++) {

VENDOR_INTEL = 0, so this check is obscure to begin with. Either you chose
a explicit condition to put at the end of the table, e.g. vendor = U8_MAX
or you hand in the array size to the function.

> +		if (c->x86_vendor != m->vendor)
> +			continue;
> +		if (c->x86 != m->family)
> +			continue;
> +		if (c->x86_model != m->model)
> +			continue;
> +		if (c->x86_stepping != m->stepping)
> +			continue;
> +		if (c->microcode < m->min_ucode)
> +			continue;

Why would you continue here? If vendor, family, model, stepping match, then
there is no point to continue, really. Assuming that the return type is bool:

      	    	return c->microcode >= m->min_ucode;

is sufficient.

Thanks,

	tglx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ