Skip to content

Commit e503f53

Browse files
committed
Merge tag 'x86-urgent-2026-01-18' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull misc x86 fixes from Ingo Molnar: - Fix resctrl initialization on Hygon CPUs - Fix resctrl memory bandwidth counters on Hygon CPUs - Fix x86 self-tests build bug * tag 'x86-urgent-2026-01-18' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: selftests/x86: Add selftests include path for kselftest.h after centralization x86/resctrl: Fix memory bandwidth counter width for Hygon x86/resctrl: Add missing resctrl initialization for Hygon
2 parents b671c1d + d9b40d7 commit e503f53

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

arch/x86/kernel/cpu/resctrl/core.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,8 @@ static __init bool get_mem_config(void)
825825

826826
if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
827827
return __get_mem_config_intel(&hw_res->r_resctrl);
828-
else if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
828+
else if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
829+
boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
829830
return __rdt_get_mem_config_amd(&hw_res->r_resctrl);
830831

831832
return false;
@@ -987,7 +988,8 @@ static __init void rdt_init_res_defs(void)
987988
{
988989
if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
989990
rdt_init_res_defs_intel();
990-
else if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
991+
else if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
992+
boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
991993
rdt_init_res_defs_amd();
992994
}
993995

@@ -1019,8 +1021,19 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c)
10191021
c->x86_cache_occ_scale = ebx;
10201022
c->x86_cache_mbm_width_offset = eax & 0xff;
10211023

1022-
if (c->x86_vendor == X86_VENDOR_AMD && !c->x86_cache_mbm_width_offset)
1023-
c->x86_cache_mbm_width_offset = MBM_CNTR_WIDTH_OFFSET_AMD;
1024+
if (!c->x86_cache_mbm_width_offset) {
1025+
switch (c->x86_vendor) {
1026+
case X86_VENDOR_AMD:
1027+
c->x86_cache_mbm_width_offset = MBM_CNTR_WIDTH_OFFSET_AMD;
1028+
break;
1029+
case X86_VENDOR_HYGON:
1030+
c->x86_cache_mbm_width_offset = MBM_CNTR_WIDTH_OFFSET_HYGON;
1031+
break;
1032+
default:
1033+
/* Leave c->x86_cache_mbm_width_offset as 0 */
1034+
break;
1035+
}
1036+
}
10241037
}
10251038
}
10261039

arch/x86/kernel/cpu/resctrl/internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
#define MBM_CNTR_WIDTH_OFFSET_AMD 20
1616

17+
/* Hygon MBM counter width as an offset from MBM_CNTR_WIDTH_BASE */
18+
#define MBM_CNTR_WIDTH_OFFSET_HYGON 8
19+
1720
#define RMID_VAL_ERROR BIT_ULL(63)
1821

1922
#define RMID_VAL_UNAVAIL BIT_ULL(62)

tools/testing/selftests/x86/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32))
3636
BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64))
3737

3838
CFLAGS := -O2 -g -std=gnu99 -pthread -Wall $(KHDR_INCLUDES)
39+
CFLAGS += -I $(top_srcdir)/tools/testing/selftests/
3940

4041
# call32_from_64 in thunks.S uses absolute addresses.
4142
ifeq ($(CAN_BUILD_WITH_NOPIE),1)

0 commit comments

Comments
 (0)