[MODERATED] Re: Re: [PATCH 2/4] V8 more sampling fun 2

mark gross <[email protected]> Thu, 16 Apr 2020 15:47:44 -0700
Newsgroups org.kernel.lore.historical-speck
Message-ID <20200416224744.GB2583@u1904>
ack

Signed-off-by: Mark Gross <[email protected]>

thanks!

--mark

On Thu, Apr 16, 2020 at 07:33:24PM +0200, speck for Borislav Petkov wrote:
> On Thu, Apr 16, 2020 at 12:16:21PM -0500, speck for Josh Poimboeuf wrote:
> > On Mon, Mar 16, 2020 at 05:56:27PM -0700, speck for mark gross wrote:
> > > From: mark gross <[email protected]>
> > > Subject: [PATCH 2/4] x86/cpu: clean up cpu_matches
> >=20
> > Vague subject, how about
> >=20
> >   x86/cpu: Add 'table' argument to cpu_matches()
>=20
> Fixed, below final result:
>=20
> ---
> From: Mark Gross <[email protected]>
> Date: Thu, 16 Apr 2020 17:32:42 +0200
> Subject: [PATCH] x86/cpu: Add 'table' argument to cpu_matches()
>=20
> To make cpu_matches() reusable for other matching tables, have it take a
> x86_cpu_id table as an argument.
>=20
>  [ bp: Flip arguments order. ]
>=20
> Signed-off-by: Mark Gross <[email protected]>
> Signed-off-by: Borislav Petkov <[email protected]>
> ---
>  arch/x86/kernel/cpu/common.c | 25 ++++++++++++++-----------
>  1 file changed, 14 insertions(+), 11 deletions(-)
>=20
> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> index bed0cb83fe24..1131ae032bf2 100644
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -1075,9 +1075,9 @@ static const __initconst struct x86_cpu_id cpu_vuln_w=
hitelist[] =3D {
>  	{}
>  };
> =20
> -static bool __init cpu_matches(unsigned long which)
> +static bool __init cpu_matches(const struct x86_cpu_id *table, unsigned lo=
ng which)
>  {
> -	const struct x86_cpu_id *m =3D x86_match_cpu(cpu_vuln_whitelist);
> +	const struct x86_cpu_id *m =3D x86_match_cpu(table);
> =20
>  	return m && !!(m->driver_data & which);
>  }
> @@ -1097,31 +1097,34 @@ static void __init cpu_set_bug_bits(struct cpuinfo_=
x86 *c)
>  	u64 ia32_cap =3D x86_read_arch_cap_msr();
> =20
>  	/* Set ITLB_MULTIHIT bug if cpu is not in the whitelist and not mitigated=
 */
> -	if (!cpu_matches(NO_ITLB_MULTIHIT) && !(ia32_cap & ARCH_CAP_PSCHANGE_MC_N=
O))
> +	if (!cpu_matches(cpu_vuln_whitelist, NO_ITLB_MULTIHIT) &&
> +	    !(ia32_cap & ARCH_CAP_PSCHANGE_MC_NO))
>  		setup_force_cpu_bug(X86_BUG_ITLB_MULTIHIT);
> =20
> -	if (cpu_matches(NO_SPECULATION))
> +	if (cpu_matches(cpu_vuln_whitelist, NO_SPECULATION))
>  		return;
> =20
>  	setup_force_cpu_bug(X86_BUG_SPECTRE_V1);
> =20
> -	if (!cpu_matches(NO_SPECTRE_V2))
> +	if (!cpu_matches(cpu_vuln_whitelist, NO_SPECTRE_V2))
>  		setup_force_cpu_bug(X86_BUG_SPECTRE_V2);
> =20
> -	if (!cpu_matches(NO_SSB) && !(ia32_cap & ARCH_CAP_SSB_NO) &&
> +	if (!cpu_matches(cpu_vuln_whitelist, NO_SSB) &&
> +	    !(ia32_cap & ARCH_CAP_SSB_NO) &&
>  	   !cpu_has(c, X86_FEATURE_AMD_SSB_NO))
>  		setup_force_cpu_bug(X86_BUG_SPEC_STORE_BYPASS);
> =20
>  	if (ia32_cap & ARCH_CAP_IBRS_ALL)
>  		setup_force_cpu_cap(X86_FEATURE_IBRS_ENHANCED);
> =20
> -	if (!cpu_matches(NO_MDS) && !(ia32_cap & ARCH_CAP_MDS_NO)) {
> +	if (!cpu_matches(cpu_vuln_whitelist, NO_MDS) &&
> +	    !(ia32_cap & ARCH_CAP_MDS_NO)) {
>  		setup_force_cpu_bug(X86_BUG_MDS);
> -		if (cpu_matches(MSBDS_ONLY))
> +		if (cpu_matches(cpu_vuln_whitelist, MSBDS_ONLY))
>  			setup_force_cpu_bug(X86_BUG_MSBDS_ONLY);
>  	}
> =20
> -	if (!cpu_matches(NO_SWAPGS))
> +	if (!cpu_matches(cpu_vuln_whitelist, NO_SWAPGS))
>  		setup_force_cpu_bug(X86_BUG_SWAPGS);
> =20
>  	/*
> @@ -1139,7 +1142,7 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x8=
6 *c)
>  	     (ia32_cap & ARCH_CAP_TSX_CTRL_MSR)))
>  		setup_force_cpu_bug(X86_BUG_TAA);
> =20
> -	if (cpu_matches(NO_MELTDOWN))
> +	if (cpu_matches(cpu_vuln_whitelist, NO_MELTDOWN))
>  		return;
> =20
>  	/* Rogue Data Cache Load? No! */
> @@ -1148,7 +1151,7 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x8=
6 *c)
> =20
>  	setup_force_cpu_bug(X86_BUG_CPU_MELTDOWN);
> =20
> -	if (cpu_matches(NO_L1TF))
> +	if (cpu_matches(cpu_vuln_whitelist, NO_L1TF))
>  		return;
> =20
>  	setup_force_cpu_bug(X86_BUG_L1TF);
> --=20
> 2.21.0
>=20
> SUSE Software Solutions Germany GmbH, GF: Felix Imend=C3=B6rffer, HRB 36809=
, AG N=C3=BCrnberg
> --=20