x86: Complete backports for x86_match_cpu()
cover x86: Complete backports for x86_match_cpu()
Hi,
Upstream commit 93022482b294 ("x86/cpu: Fix x86_match_cpu() to match just X86_VENDOR_INTEL") introduced a flags member to struct x86_cpu_id. Bit 0 of x86_cpu.id.flags must be set to 1 for x86_match_cpu() to work correctly. This upstream commit has been backported to 6.1.y.
Callers that use the X86_MATCH_*() family of macros to compose the argument of x86_match_cpu() function correctly. Callers that use their own custom mechanisms may not work if they fail to set x86_cpu_id.flags correctly.
There are two remaining callers in 6.1.y that use their own mechanisms:setup_pcid() and rapl_msr_probe(). The former caused a regression that Thomas Lindroth reported in [1]. The latter works by luck but it still populates its x86_cpu_id[] array incorrectly.
I backported two patches that fix these bugs in mainline. Hopefully the authors and/or maintainers can ack the backports?
I tested these patches in Alder Lake and Meteor Lake systems as the two involved callers behave differently on these two systems. I wrote the testing details in each patch separately.
Thanks and BR,
Ricardo
[1]. https://lore.kernel.org/all/[email protected]/
Sumeet Pawnikar (1):
powercap: RAPL: fix invalid initialization for pl4_supported field
Tony Luck (1):
x86/mm: Switch to new Intel CPU model defines
arch/x86/mm/init.c | 16 ++++++---------- drivers/powercap/intel_rapl_msr.c | 12 ++++++------ 2 files changed, 12 insertions(+), 16 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 powercap: RAPL: fix invalid initialization for pl4_supported field
From: Sumeet Pawnikar <[email protected]>
[ Upstream commit d05b5e0baf424c8c4b4709ac11f66ab726c8deaf ]
The current initialization of the struct x86_cpu_id via pl4_support_ids[] is partial and wrong. It is initializing "stepping" field with "X86_FEATURE_ANY" instead of "feature" field.
Use X86_MATCH_INTEL_FAM6_MODEL macro instead of initializing each field of the struct x86_cpu_id for pl4_supported list of CPUs. This X86_MATCH_INTEL_FAM6_MODEL macro internally uses another macro X86_MATCH_VENDOR_FAM_MODEL_FEATURE for X86 based CPU matching with appropriate initialized values.
[ Ricardo: I removed METEORLAKE and METEORLAKE_L from pl4_support_ids as
they are not included in v6.1. ]
---
I tested this backport on Alder Lake and Meteor Lake systems. printk() tells me that the former is detected whereas the latter is not. The stepping and the feature fields are 0 as expected.
--- drivers/powercap/intel_rapl_msr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/powercap/intel_rapl_msr.c +6 -6
@@ -136,12 +136,12 @@ static int rapl_msr_write_raw(int cpu, struct reg_action *ra)/* List of verified CPUs. */ static const struct x86_cpu_id pl4_support_ids[] = { - {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_TIGERLAKE_L ,X86_FEATURE_ANY }, - {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_ALDERLAKE ,X86_FEATURE_ANY }, - {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_ALDERLAKE_L ,X86_FEATURE_ANY }, - {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_ALDERLAKE_N ,X86_FEATURE_ANY }, - {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_RAPTORLAKE ,X86_FEATURE_ANY }, - {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_RAPTORLAKE_P ,X86_FEATURE_ANY }, +X86_MATCH_INTEL_FAM6_MODEL (TIGERLAKE_L ,NULL ), +X86_MATCH_INTEL_FAM6_MODEL (ALDERLAKE ,NULL ), +X86_MATCH_INTEL_FAM6_MODEL (ALDERLAKE_L ,NULL ), +X86_MATCH_INTEL_FAM6_MODEL (ALDERLAKE_N ,NULL ), +X86_MATCH_INTEL_FAM6_MODEL (RAPTORLAKE ,NULL ), +X86_MATCH_INTEL_FAM6_MODEL (RAPTORLAKE_P ,NULL ), {} };
Signature · 1 line
2.34.1
Re: [PATCH 6.1.y 1/2] powercap: RAPL: fix invalid initialization for pl4_supported field
Quoted 23 lines · Ricardo Neri
From: Sumeet Pawnikar <[email protected]>
[ Upstream commit
d05b5e0baf424c8c4b4709ac11f66ab726c8deaf]The current initialization of the struct
x86_cpu_idvia pl4_support_ids[] is partial and wrong. It is initializing "stepping" field with "X86_FEATURE_ANY" instead of "feature" field.Use
X86_MATCH_INTEL_FAM6_MODELmacro instead of initializing each field of the structx86_cpu_idforpl4_supportedlist of CPUs. ThisX86_MATCH_INTEL_FAM6_MODELmacro internally uses another macroX86_MATCH_VENDOR_FAM_MODEL_FEATUREfor X86 based CPU matching with appropriate initialized values.Reported-by Dave Hansen <[email protected]>Fixes eb52bc2ae5b8 ("powercap: RAPL: Add Power Limit4 support for Meteor Lake SoC")Fixes b08b95cf30f5 ("powercap: RAPL: Add Power Limit4 support for Alder Lake-N and Raptor Lake-P")Fixes 515755906921 ("powercap: RAPL: Add Power Limit4 support for RaptorLake")Fixes 1cc5b9a411e4 ("powercap: Add Power Limit4 support for Alder Lake SoC")Fixes 8365a898fe53 ("powercap: Add Power Limit4 support")Signed-off-by Sumeet Pawnikar <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>
Quoted 3 lines
[ Ricardo: I removed METEORLAKE and
METEORLAKE_Lfrompl4_support_idsas
they are not included in v6.1. ]Signed-off-by Ricardo Neri <[email protected]>
PATCH 2/2 x86/mm: Switch to new Intel CPU model defines
In reply to Ricardo NeriFrom: Tony Luck <[email protected]>
[ Upstream commit 2eda374e883ad297bd9fe575a16c1dc850346075 ]
New CPU #defines encode vendor and family as well as model.
[ dhansen: vertically align 0's in invlpg_miss_ids[] ]
[ Ricardo: I used the old match macro X86_MATCH_INTEL_FAM6_MODEL()
instead of X86_MATCH_VFM() as in the upstream commit.
I also kept the ALDERLAKE_N name instead of ATOM_GRACEMONT. Both refer to the same CPU model. ]
---
I tested this backport on an Alder Lake system. Now pr_info("Incomplete global flushes, disabling PCID") is back in dmesg. I also tested on a Meteor Lake system, which unaffected by the INVLPG issue. The message in question is not there before and after the backport, as expected.
--- arch/x86/mm/init.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
arch/x86/mm/init.c +6 -10
@@ -262,21 +262,17 @@ static void __init probe_page_size_mask(void) } } -#define INTEL_MATCH (_model) { .vendor = X86_VENDOR_INTEL, \ - .family = 6, \ - .model = _model, \ - }/* * INVLPG may not properly flush Global entries * on these CPUs when PCIDs are enabled. */ static const struct x86_cpu_id invlpg_miss_ids[] = { -INTEL_MATCH (INTEL_FAM6_ALDERLAKE ), -INTEL_MATCH (INTEL_FAM6_ALDERLAKE_L ), -INTEL_MATCH (INTEL_FAM6_ALDERLAKE_N ), -INTEL_MATCH (INTEL_FAM6_RAPTORLAKE ), -INTEL_MATCH (INTEL_FAM6_RAPTORLAKE_P ), -INTEL_MATCH (INTEL_FAM6_RAPTORLAKE_S ), +X86_MATCH_INTEL_FAM6_MODEL (ALDERLAKE ,0 ), +X86_MATCH_INTEL_FAM6_MODEL (ALDERLAKE_L ,0 ), +X86_MATCH_INTEL_FAM6_MODEL (ALDERLAKE_N ,0 ), +X86_MATCH_INTEL_FAM6_MODEL (RAPTORLAKE ,0 ), +X86_MATCH_INTEL_FAM6_MODEL (RAPTORLAKE_P ,0 ), +X86_MATCH_INTEL_FAM6_MODEL (RAPTORLAKE_S ,0 ), {} };
Signature · 1 line
2.34.1
Re: [PATCH 6.1.y 2/2] x86/mm: Switch to new Intel CPU model defines
Quoted 12 lines · Ricardo Neri
From: Tony Luck <[email protected]>
[ Upstream commit
2eda374e883ad297bd9fe575a16c1dc850346075]New CPU #defines encode vendor and family as well as model.
[ dhansen: vertically align 0's in invlpg_miss_ids[] ]
Signed-off-by Tony Luck <[email protected]>Signed-off-by Dave Hansen <[email protected]>Signed-off-by Borislav Petkov (AMD) <[email protected]>
Quoted 5 lines
[ Ricardo: I used the old match macro
X86_MATCH_INTEL_FAM6_MODEL()
instead ofX86_MATCH_VFM()as in the upstream commit.
I also kept theALDERLAKE_Nname instead ofATOM_GRACEMONT. Both refer to the same CPU model. ]Signed-off-by Ricardo Neri <[email protected]>