Skip to content

Commit 0e3cd31

Browse files
maciejwieczorretmanbp3tk0v
authored andcommitted
x86/resctrl: Enable non-contiguous CBMs in Intel CAT
The setting for non-contiguous 1s support in Intel CAT is hardcoded to false. On these systems, writing non-contiguous 1s into the schemata file will fail before resctrl passes the value to the hardware. In Intel CAT CPUID.0x10.1:ECX[3] and CPUID.0x10.2:ECX[3] stopped being reserved and now carry information about non-contiguous 1s value support for L3 and L2 cache respectively. The CAT capacity bitmask (CBM) supports a non-contiguous 1s value if the bit is set. The exception are Haswell systems where non-contiguous 1s value support needs to stay disabled since they can't make use of CPUID for Cache allocation. Originally-by: Fenghua Yu <[email protected]> Signed-off-by: Maciej Wieczor-Retman <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Reviewed-by: Peter Newman <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Reviewed-by: Babu Moger <[email protected]> Tested-by: Peter Newman <[email protected]> Link: https://lore.kernel.org/r/1849b487256fe4de40b30f88450cba3d9abc9171.1696934091.git.maciej.wieczor-retman@intel.com
1 parent 39c6eed commit 0e3cd31

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ static inline void cache_alloc_hsw_probe(void)
152152
r->cache.cbm_len = 20;
153153
r->cache.shareable_bits = 0xc0000;
154154
r->cache.min_cbm_bits = 2;
155+
r->cache.arch_has_sparse_bitmasks = false;
155156
r->alloc_capable = true;
156157

157158
rdt_alloc_capable = true;
@@ -267,15 +268,18 @@ static void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r)
267268
{
268269
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
269270
union cpuid_0x10_1_eax eax;
271+
union cpuid_0x10_x_ecx ecx;
270272
union cpuid_0x10_x_edx edx;
271-
u32 ebx, ecx;
273+
u32 ebx;
272274

273-
cpuid_count(0x00000010, idx, &eax.full, &ebx, &ecx, &edx.full);
275+
cpuid_count(0x00000010, idx, &eax.full, &ebx, &ecx.full, &edx.full);
274276
hw_res->num_closid = edx.split.cos_max + 1;
275277
r->cache.cbm_len = eax.split.cbm_len + 1;
276278
r->default_ctrl = BIT_MASK(eax.split.cbm_len + 1) - 1;
277279
r->cache.shareable_bits = ebx & r->default_ctrl;
278280
r->data_width = (r->cache.cbm_len + 3) / 4;
281+
if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
282+
r->cache.arch_has_sparse_bitmasks = ecx.split.noncont;
279283
r->alloc_capable = true;
280284
}
281285

@@ -872,7 +876,6 @@ static __init void rdt_init_res_defs_intel(void)
872876

873877
if (r->rid == RDT_RESOURCE_L3 ||
874878
r->rid == RDT_RESOURCE_L2) {
875-
r->cache.arch_has_sparse_bitmasks = false;
876879
r->cache.arch_has_per_cpu_cfg = false;
877880
r->cache.min_cbm_bits = 1;
878881
} else if (r->rid == RDT_RESOURCE_MBA) {

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s,
8787

8888
/*
8989
* Check whether a cache bit mask is valid.
90-
* For Intel the SDM says:
91-
* Please note that all (and only) contiguous '1' combinations
92-
* are allowed (e.g. FFFFH, 0FF0H, 003CH, etc.).
93-
* Additionally Haswell requires at least two bits set.
90+
* On Intel CPUs, non-contiguous 1s value support is indicated by CPUID:
91+
* - CPUID.0x10.1:ECX[3]: L3 non-contiguous 1s value supported if 1
92+
* - CPUID.0x10.2:ECX[3]: L2 non-contiguous 1s value supported if 1
93+
*
94+
* Haswell does not support a non-contiguous 1s value and additionally
95+
* requires at least two bits set.
9496
* AMD allows non-contiguous bitmasks.
9597
*/
9698
static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,15 @@ union cpuid_0x10_3_eax {
492492
unsigned int full;
493493
};
494494

495+
/* CPUID.(EAX=10H, ECX=ResID).ECX */
496+
union cpuid_0x10_x_ecx {
497+
struct {
498+
unsigned int reserved:3;
499+
unsigned int noncont:1;
500+
} split;
501+
unsigned int full;
502+
};
503+
495504
/* CPUID.(EAX=10H, ECX=ResID).EDX */
496505
union cpuid_0x10_x_edx {
497506
struct {

0 commit comments

Comments
 (0)