Skip to content

Commit f0f70dd

Browse files
committed
Merge tag 'x86_urgent_for_v6.2_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Borislav Petkov: - Make sure the poking PGD is pinned for Xen PV as it requires it this way - Fixes for two resctrl races when moving a task or creating a new monitoring group - Fix SEV-SNP guests running under HyperV where MTRRs are disabled to not return a UC- type mapping type on memremap() and thus cause a serious slowdown - Fix insn mnemonics in bioscall.S now that binutils is starting to fix confusing insn suffixes * tag 'x86_urgent_for_v6.2_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/mm: fix poking_init() for Xen PV guests x86/resctrl: Fix event counts regression in reused RMIDs x86/resctrl: Fix task CLOSID/RMID update race x86/pat: Fix pat_x_mtrr_type() for MTRR disabled case x86/boot: Avoid using Intel mnemonics in AT&T syntax asm
2 parents 8aa9761 + 26ce6ec commit f0f70dd

File tree

5 files changed

+52
-20
lines changed

5 files changed

+52
-20
lines changed

arch/x86/boot/bioscall.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ intcall:
3232
movw %dx, %si
3333
movw %sp, %di
3434
movw $11, %cx
35-
rep; movsd
35+
rep; movsl
3636

3737
/* Pop full state from the stack */
3838
popal
@@ -67,7 +67,7 @@ intcall:
6767
jz 4f
6868
movw %sp, %si
6969
movw $11, %cx
70-
rep; movsd
70+
rep; movsl
7171
4: addw $44, %sp
7272

7373
/* Restore state and return */

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

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,30 @@ static inline struct rmid_entry *__rmid_entry(u32 rmid)
146146
return entry;
147147
}
148148

149+
static int __rmid_read(u32 rmid, enum resctrl_event_id eventid, u64 *val)
150+
{
151+
u64 msr_val;
152+
153+
/*
154+
* As per the SDM, when IA32_QM_EVTSEL.EvtID (bits 7:0) is configured
155+
* with a valid event code for supported resource type and the bits
156+
* IA32_QM_EVTSEL.RMID (bits 41:32) are configured with valid RMID,
157+
* IA32_QM_CTR.data (bits 61:0) reports the monitored data.
158+
* IA32_QM_CTR.Error (bit 63) and IA32_QM_CTR.Unavailable (bit 62)
159+
* are error bits.
160+
*/
161+
wrmsr(MSR_IA32_QM_EVTSEL, eventid, rmid);
162+
rdmsrl(MSR_IA32_QM_CTR, msr_val);
163+
164+
if (msr_val & RMID_VAL_ERROR)
165+
return -EIO;
166+
if (msr_val & RMID_VAL_UNAVAIL)
167+
return -EINVAL;
168+
169+
*val = msr_val;
170+
return 0;
171+
}
172+
149173
static struct arch_mbm_state *get_arch_mbm_state(struct rdt_hw_domain *hw_dom,
150174
u32 rmid,
151175
enum resctrl_event_id eventid)
@@ -172,8 +196,12 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_domain *d,
172196
struct arch_mbm_state *am;
173197

174198
am = get_arch_mbm_state(hw_dom, rmid, eventid);
175-
if (am)
199+
if (am) {
176200
memset(am, 0, sizeof(*am));
201+
202+
/* Record any initial, non-zero count value. */
203+
__rmid_read(rmid, eventid, &am->prev_msr);
204+
}
177205
}
178206

179207
static u64 mbm_overflow_count(u64 prev_msr, u64 cur_msr, unsigned int width)
@@ -191,25 +219,14 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain *d,
191219
struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d);
192220
struct arch_mbm_state *am;
193221
u64 msr_val, chunks;
222+
int ret;
194223

195224
if (!cpumask_test_cpu(smp_processor_id(), &d->cpu_mask))
196225
return -EINVAL;
197226

198-
/*
199-
* As per the SDM, when IA32_QM_EVTSEL.EvtID (bits 7:0) is configured
200-
* with a valid event code for supported resource type and the bits
201-
* IA32_QM_EVTSEL.RMID (bits 41:32) are configured with valid RMID,
202-
* IA32_QM_CTR.data (bits 61:0) reports the monitored data.
203-
* IA32_QM_CTR.Error (bit 63) and IA32_QM_CTR.Unavailable (bit 62)
204-
* are error bits.
205-
*/
206-
wrmsr(MSR_IA32_QM_EVTSEL, eventid, rmid);
207-
rdmsrl(MSR_IA32_QM_CTR, msr_val);
208-
209-
if (msr_val & RMID_VAL_ERROR)
210-
return -EIO;
211-
if (msr_val & RMID_VAL_UNAVAIL)
212-
return -EINVAL;
227+
ret = __rmid_read(rmid, eventid, &msr_val);
228+
if (ret)
229+
return ret;
213230

214231
am = get_arch_mbm_state(hw_dom, rmid, eventid);
215232
if (am) {

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,10 @@ static int __rdtgroup_move_task(struct task_struct *tsk,
580580
/*
581581
* Ensure the task's closid and rmid are written before determining if
582582
* the task is current that will decide if it will be interrupted.
583+
* This pairs with the full barrier between the rq->curr update and
584+
* resctrl_sched_in() during context switch.
583585
*/
584-
barrier();
586+
smp_mb();
585587

586588
/*
587589
* By now, the task's closid and rmid are set. If the task is current
@@ -2401,6 +2403,14 @@ static void rdt_move_group_tasks(struct rdtgroup *from, struct rdtgroup *to,
24012403
WRITE_ONCE(t->closid, to->closid);
24022404
WRITE_ONCE(t->rmid, to->mon.rmid);
24032405

2406+
/*
2407+
* Order the closid/rmid stores above before the loads
2408+
* in task_curr(). This pairs with the full barrier
2409+
* between the rq->curr update and resctrl_sched_in()
2410+
* during context switch.
2411+
*/
2412+
smp_mb();
2413+
24042414
/*
24052415
* If the task is on a CPU, set the CPU in the mask.
24062416
* The detection is inaccurate as tasks might move or

arch/x86/mm/init.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <asm/pti.h>
2727
#include <asm/text-patching.h>
2828
#include <asm/memtype.h>
29+
#include <asm/paravirt.h>
2930

3031
/*
3132
* We need to define the tracepoints somewhere, and tlb.c
@@ -804,6 +805,9 @@ void __init poking_init(void)
804805
poking_mm = mm_alloc();
805806
BUG_ON(!poking_mm);
806807

808+
/* Xen PV guests need the PGD to be pinned. */
809+
paravirt_arch_dup_mmap(NULL, poking_mm);
810+
807811
/*
808812
* Randomize the poking address, but make sure that the following page
809813
* will be mapped at the same PMD. We need 2 pages, so find space for 3,

arch/x86/mm/pat/memtype.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ static unsigned long pat_x_mtrr_type(u64 start, u64 end,
387387
u8 mtrr_type, uniform;
388388

389389
mtrr_type = mtrr_type_lookup(start, end, &uniform);
390-
if (mtrr_type != MTRR_TYPE_WRBACK)
390+
if (mtrr_type != MTRR_TYPE_WRBACK &&
391+
mtrr_type != MTRR_TYPE_INVALID)
391392
return _PAGE_CACHE_MODE_UC_MINUS;
392393

393394
return _PAGE_CACHE_MODE_WB;

0 commit comments

Comments
 (0)