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] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z9KwG9t2OVhoapZc@gmail.com>
Date: Thu, 13 Mar 2025 11:14:51 +0100
From: Ingo Molnar <mingo@...nel.org>
To: Sohil Mehta <sohil.mehta@...el.com>
Cc: x86@...nel.org, Borislav Petkov <bp@...en8.de>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	Ingo Molnar <mingo@...hat.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	"H . Peter Anvin" <hpa@...or.com>, Uros Bizjak <ubizjak@...il.com>,
	Sandipan Das <sandipan.das@....com>,
	Sean Christopherson <seanjc@...gle.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Vegard Nossum <vegard.nossum@...cle.com>,
	Tony Luck <tony.luck@...el.com>,
	Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>,
	Nikolay Borisov <nik.borisov@...e.com>,
	Eric Biggers <ebiggers@...gle.com>, Xin Li <xin3.li@...el.com>,
	Alexander Shishkin <alexander.shishkin@...el.com>,
	Kirill Shutemov <kirill.shutemov@...ux.intel.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5] x86/cpufeature: Warn about unmet feature dependencies


* Sohil Mehta <sohil.mehta@...el.com> wrote:

> On 3/7/2025 3:55 AM, Ingo Molnar wrote:
> 
> >>  
> >> +	/* Scan for unmet dependencies based on the CPUID dependency table */
> >> +	scan_feature_dependencies(c);
> > 
> > s/scane_feature_dependencies
> >  /x86_check_cpufeature_deps
> > 
> 
> How about check_cpufeature_deps() without the "x86" prefix? It would
> blend in with the other function calls in early_identify_cpu() and
> identify_cpu().

Yeah, I suppose that would work too. There's no discernible rhyme and 
reason to the naming choices within the interfaces used by 
arch/x86/kernel/cpu/common.c that I can see, so I suppose the shorter 
one that is still unambiguous wins.

> >> + */
> >> +static const char *x86_feature_name(unsigned int feature, char *buf)
> >> +{
> >> +	if (x86_cap_flags[feature])
> >> +		return x86_cap_flags[feature];
> >> +
> >> +	snprintf(buf, 16, "%d*32+%2d", feature / 32, feature % 32);
> >> +
> >> +	return buf;
> >> +}
> >> +
> 
> I was wondering if it would be better to build the feature name using 
> a macro and reusing it elsewhere? This is all I could come up with:
> 
> /*
>  * Use with a %s format specifier to print the feature name.
>  *
>  * Return the feature "name" if set, otherwise return the X86_FEATURE_*
>  * numerals to make it easier to identify the feature.
>  */
> #define x86_feature_name(feature) \
> 	(x86_cap_flags[feature] ? x86_cap_flags[feature] : \
> 	({ \
> 		char buf[16]; \
> 		snprintf(buf, 16, "%d*32+%2d", feature >> 5, feature & 31); \
> 		buf; \
> 	}) \
> 	)

I'm not sure this is an improvement.

> This would remove the need for callers to explicitly define a buffer. 
> Also, it would help reduce a few lines in the newly merged 
> parse_set_clear_cpuid(). But overall, it doesn't seem worth it. Let 
> me know if you think otherwise or have a better idea.

No good ideas right now.

> > I'd make this a bit less passive-aggressive, something like:
> > 
> >      x86 CPU feature dependency check failure: CPU%d has '%s' enabled but '%s' disabled. Kernel might be fine, but no guarantees.
> > 
> 
> Sure! How about making it slightly shorter?
> 
> "x86 CPU feature check: CPU%d has '%s' enabled but '%s' disabled. Kernel
> might be fine, but no guarantees."

Yeah, so I really wanted to sneak in the 'dependency' part - because 
it's not necessarily obvious from the text, and most syslog readers 
will have no idea what it's all about.

I don't think line length should be an issue for a message we don't 
expect to trigger normally. Clarity is more important.

Thanks,

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ