Skip to content

Commit 5c00eca

Browse files
committed
Merge tag 'x86_urgent_for_v6.16_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Borislav Petkov: - Make sure the array tracking which kernel text positions need to be alternatives-patched doesn't get mishandled by out-of-order modifications, leading to it overflowing and causing page faults when patching - Avoid an infinite loop when early code does a ranged TLB invalidation before the broadcast TLB invalidation count of how many pages it can flush, has been read from CPUID - Fix a CONFIG_MODULES typo - Disable broadcast TLB invalidation when PTI is enabled to avoid an overflow of the bitmap tracking dynamic ASIDs which need to be flushed when the kernel switches between the user and kernel address space - Handle the case of a CPU going offline and thus reporting zeroes when reading top-level events in the resctrl code * tag 'x86_urgent_for_v6.16_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/alternatives: Fix int3 handling failure from broken text_poke array x86/mm: Fix early boot use of INVPLGB x86/its: Fix an ifdef typo in its_alloc() x86/mm: Disable INVLPGB when PTI is enabled x86,fs/resctrl: Remove inappropriate references to cacheinfo in the resctrl subsystem
2 parents 33efa7d + 2aebf5e commit 5c00eca

File tree

9 files changed

+32
-18
lines changed

9 files changed

+32
-18
lines changed

arch/x86/kernel/alternative.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static void *its_alloc(void)
228228
struct its_array *pages = &its_pages;
229229
void *page;
230230

231-
#ifdef CONFIG_MODULE
231+
#ifdef CONFIG_MODULES
232232
if (its_mod)
233233
pages = &its_mod->arch.its_pages;
234234
#endif
@@ -3138,6 +3138,6 @@ void __ref smp_text_poke_batch_add(void *addr, const void *opcode, size_t len, c
31383138
*/
31393139
void __ref smp_text_poke_single(void *addr, const void *opcode, size_t len, const void *emulate)
31403140
{
3141-
__smp_text_poke_batch_add(addr, opcode, len, emulate);
3141+
smp_text_poke_batch_add(addr, opcode, len, emulate);
31423142
smp_text_poke_batch_finish();
31433143
}

arch/x86/kernel/cpu/amd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#include "cpu.h"
3333

34-
u16 invlpgb_count_max __ro_after_init;
34+
u16 invlpgb_count_max __ro_after_init = 1;
3535

3636
static inline int rdmsrq_amd_safe(unsigned msr, u64 *p)
3737
{

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r)
498498
struct rdt_hw_mon_domain *hw_dom;
499499
struct rdt_domain_hdr *hdr;
500500
struct rdt_mon_domain *d;
501+
struct cacheinfo *ci;
501502
int err;
502503

503504
lockdep_assert_held(&domain_list_lock);
@@ -525,12 +526,13 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r)
525526
d = &hw_dom->d_resctrl;
526527
d->hdr.id = id;
527528
d->hdr.type = RESCTRL_MON_DOMAIN;
528-
d->ci = get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE);
529-
if (!d->ci) {
529+
ci = get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE);
530+
if (!ci) {
530531
pr_warn_once("Can't find L3 cache for CPU:%d resource %s\n", cpu, r->name);
531532
mon_domain_free(hw_dom);
532533
return;
533534
}
535+
d->ci_id = ci->id;
534536
cpumask_set_cpu(cpu, &d->hdr.cpu_mask);
535537

536538
arch_mon_domain_online(r, d);

arch/x86/mm/pti.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ void __init pti_check_boottime_disable(void)
9898
return;
9999

100100
setup_force_cpu_cap(X86_FEATURE_PTI);
101+
102+
if (cpu_feature_enabled(X86_FEATURE_INVLPGB)) {
103+
pr_debug("PTI enabled, disabling INVLPGB\n");
104+
setup_clear_cpu_cap(X86_FEATURE_INVLPGB);
105+
}
101106
}
102107

103108
static int __init pti_parse_cmdline(char *arg)

fs/resctrl/ctrlmondata.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,10 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)
594594
struct rmid_read rr = {0};
595595
struct rdt_mon_domain *d;
596596
struct rdtgroup *rdtgrp;
597+
int domid, cpu, ret = 0;
597598
struct rdt_resource *r;
599+
struct cacheinfo *ci;
598600
struct mon_data *md;
599-
int domid, ret = 0;
600601

601602
rdtgrp = rdtgroup_kn_lock_live(of->kn);
602603
if (!rdtgrp) {
@@ -623,10 +624,14 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)
623624
* one that matches this cache id.
624625
*/
625626
list_for_each_entry(d, &r->mon_domains, hdr.list) {
626-
if (d->ci->id == domid) {
627-
rr.ci = d->ci;
627+
if (d->ci_id == domid) {
628+
rr.ci_id = d->ci_id;
629+
cpu = cpumask_any(&d->hdr.cpu_mask);
630+
ci = get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE);
631+
if (!ci)
632+
continue;
628633
mon_event_read(&rr, r, NULL, rdtgrp,
629-
&d->ci->shared_cpu_map, evtid, false);
634+
&ci->shared_cpu_map, evtid, false);
630635
goto checkresult;
631636
}
632637
}

fs/resctrl/internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct mon_data {
9898
* domains in @r sharing L3 @ci.id
9999
* @evtid: Which monitor event to read.
100100
* @first: Initialize MBM counter when true.
101-
* @ci: Cacheinfo for L3. Only set when @d is NULL. Used when summing domains.
101+
* @ci_id: Cacheinfo id for L3. Only set when @d is NULL. Used when summing domains.
102102
* @err: Error encountered when reading counter.
103103
* @val: Returned value of event counter. If @rgrp is a parent resource group,
104104
* @val includes the sum of event counts from its child resource groups.
@@ -112,7 +112,7 @@ struct rmid_read {
112112
struct rdt_mon_domain *d;
113113
enum resctrl_event_id evtid;
114114
bool first;
115-
struct cacheinfo *ci;
115+
unsigned int ci_id;
116116
int err;
117117
u64 val;
118118
void *arch_mon_ctx;

fs/resctrl/monitor.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ static int __mon_event_count(u32 closid, u32 rmid, struct rmid_read *rr)
361361
{
362362
int cpu = smp_processor_id();
363363
struct rdt_mon_domain *d;
364+
struct cacheinfo *ci;
364365
struct mbm_state *m;
365366
int err, ret;
366367
u64 tval = 0;
@@ -388,7 +389,8 @@ static int __mon_event_count(u32 closid, u32 rmid, struct rmid_read *rr)
388389
}
389390

390391
/* Summing domains that share a cache, must be on a CPU for that cache. */
391-
if (!cpumask_test_cpu(cpu, &rr->ci->shared_cpu_map))
392+
ci = get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE);
393+
if (!ci || ci->id != rr->ci_id)
392394
return -EINVAL;
393395

394396
/*
@@ -400,7 +402,7 @@ static int __mon_event_count(u32 closid, u32 rmid, struct rmid_read *rr)
400402
*/
401403
ret = -EINVAL;
402404
list_for_each_entry(d, &rr->r->mon_domains, hdr.list) {
403-
if (d->ci->id != rr->ci->id)
405+
if (d->ci_id != rr->ci_id)
404406
continue;
405407
err = resctrl_arch_rmid_read(rr->r, d, closid, rmid,
406408
rr->evtid, &tval, rr->arch_mon_ctx);

fs/resctrl/rdtgroup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3036,7 +3036,7 @@ static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r,
30363036
char name[32];
30373037

30383038
snc_mode = r->mon_scope == RESCTRL_L3_NODE;
3039-
sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci->id : d->hdr.id);
3039+
sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci_id : d->hdr.id);
30403040
if (snc_mode)
30413041
sprintf(subname, "mon_sub_%s_%02d", r->name, d->hdr.id);
30423042

@@ -3061,7 +3061,7 @@ static int mon_add_all_files(struct kernfs_node *kn, struct rdt_mon_domain *d,
30613061
return -EPERM;
30623062

30633063
list_for_each_entry(mevt, &r->evt_list, list) {
3064-
domid = do_sum ? d->ci->id : d->hdr.id;
3064+
domid = do_sum ? d->ci_id : d->hdr.id;
30653065
priv = mon_get_kn_priv(r->rid, domid, mevt, do_sum);
30663066
if (WARN_ON_ONCE(!priv))
30673067
return -EINVAL;
@@ -3089,7 +3089,7 @@ static int mkdir_mondata_subdir(struct kernfs_node *parent_kn,
30893089
lockdep_assert_held(&rdtgroup_mutex);
30903090

30913091
snc_mode = r->mon_scope == RESCTRL_L3_NODE;
3092-
sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci->id : d->hdr.id);
3092+
sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci_id : d->hdr.id);
30933093
kn = kernfs_find_and_get(parent_kn, name);
30943094
if (kn) {
30953095
/*

include/linux/resctrl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ struct rdt_ctrl_domain {
159159
/**
160160
* struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
161161
* @hdr: common header for different domain types
162-
* @ci: cache info for this domain
162+
* @ci_id: cache info id for this domain
163163
* @rmid_busy_llc: bitmap of which limbo RMIDs are above threshold
164164
* @mbm_total: saved state for MBM total bandwidth
165165
* @mbm_local: saved state for MBM local bandwidth
@@ -170,7 +170,7 @@ struct rdt_ctrl_domain {
170170
*/
171171
struct rdt_mon_domain {
172172
struct rdt_domain_hdr hdr;
173-
struct cacheinfo *ci;
173+
unsigned int ci_id;
174174
unsigned long *rmid_busy_llc;
175175
struct mbm_state *mbm_total;
176176
struct mbm_state *mbm_local;

0 commit comments

Comments
 (0)