Skip to content

Commit db87114

Browse files
committed
Merge tag 'x86_urgent_for_v6.12_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Borislav Petkov: - Explicitly disable the TSC deadline timer when going idle to address some CPU errata in that area - Do not apply the Zenbleed fix on anything else except AMD Zen2 on the late microcode loading path - Clear CPU buffers later in the NMI exit path on 32-bit to avoid register clearing while they still contain sensitive data, for the RDFS mitigation - Do not clobber EFLAGS.ZF with VERW on the opportunistic SYSRET exit path on 32-bit - Fix parsing issues of memory bandwidth specification in sysfs for resctrl's memory bandwidth allocation feature - Other small cleanups and improvements * tag 'x86_urgent_for_v6.12_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/apic: Always explicitly disarm TSC-deadline timer x86/CPU/AMD: Only apply Zenbleed fix for Zen2 during late microcode load x86/bugs: Use code segment selector for VERW operand x86/entry_32: Clear CPU buffers after register restore in NMI return x86/entry_32: Do not clobber user EFLAGS.ZF x86/resctrl: Annotate get_mem_config() functions as __init x86/resctrl: Avoid overflow in MB settings in bw_validate() x86/amd_nb: Add new PCI ID for AMD family 1Ah model 20h
2 parents 949c9ef + ffd9584 commit db87114

File tree

7 files changed

+47
-16
lines changed

7 files changed

+47
-16
lines changed

arch/x86/entry/entry_32.S

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,8 @@ SYM_FUNC_START(entry_SYSENTER_32)
871871

872872
/* Now ready to switch the cr3 */
873873
SWITCH_TO_USER_CR3 scratch_reg=%eax
874+
/* Clobbers ZF */
875+
CLEAR_CPU_BUFFERS
874876

875877
/*
876878
* Restore all flags except IF. (We restore IF separately because
@@ -881,7 +883,6 @@ SYM_FUNC_START(entry_SYSENTER_32)
881883
BUG_IF_WRONG_CR3 no_user_check=1
882884
popfl
883885
popl %eax
884-
CLEAR_CPU_BUFFERS
885886

886887
/*
887888
* Return back to the vDSO, which will pop ecx and edx.
@@ -1144,7 +1145,6 @@ SYM_CODE_START(asm_exc_nmi)
11441145

11451146
/* Not on SYSENTER stack. */
11461147
call exc_nmi
1147-
CLEAR_CPU_BUFFERS
11481148
jmp .Lnmi_return
11491149

11501150
.Lnmi_from_sysenter_stack:
@@ -1165,6 +1165,7 @@ SYM_CODE_START(asm_exc_nmi)
11651165

11661166
CHECK_AND_APPLY_ESPFIX
11671167
RESTORE_ALL_NMI cr3_reg=%edi pop=4
1168+
CLEAR_CPU_BUFFERS
11681169
jmp .Lirq_return
11691170

11701171
#ifdef CONFIG_X86_ESPFIX32
@@ -1206,6 +1207,7 @@ SYM_CODE_START(asm_exc_nmi)
12061207
* 1 - orig_ax
12071208
*/
12081209
lss (1+5+6)*4(%esp), %esp # back to espfix stack
1210+
CLEAR_CPU_BUFFERS
12091211
jmp .Lirq_return
12101212
#endif
12111213
SYM_CODE_END(asm_exc_nmi)

arch/x86/include/asm/nospec-branch.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,16 @@
323323
* Note: Only the memory operand variant of VERW clears the CPU buffers.
324324
*/
325325
.macro CLEAR_CPU_BUFFERS
326-
ALTERNATIVE "", __stringify(verw _ASM_RIP(mds_verw_sel)), X86_FEATURE_CLEAR_CPU_BUF
326+
#ifdef CONFIG_X86_64
327+
ALTERNATIVE "", "verw mds_verw_sel(%rip)", X86_FEATURE_CLEAR_CPU_BUF
328+
#else
329+
/*
330+
* In 32bit mode, the memory operand must be a %cs reference. The data
331+
* segments may not be usable (vm86 mode), and the stack segment may not
332+
* be flat (ESPFIX32).
333+
*/
334+
ALTERNATIVE "", "verw %cs:mds_verw_sel", X86_FEATURE_CLEAR_CPU_BUF
335+
#endif
327336
.endm
328337

329338
#ifdef CONFIG_X86_64

arch/x86/kernel/amd_nb.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#define PCI_DEVICE_ID_AMD_19H_M70H_DF_F4 0x14f4
4545
#define PCI_DEVICE_ID_AMD_19H_M78H_DF_F4 0x12fc
4646
#define PCI_DEVICE_ID_AMD_1AH_M00H_DF_F4 0x12c4
47+
#define PCI_DEVICE_ID_AMD_1AH_M20H_DF_F4 0x16fc
4748
#define PCI_DEVICE_ID_AMD_1AH_M60H_DF_F4 0x124c
4849
#define PCI_DEVICE_ID_AMD_1AH_M70H_DF_F4 0x12bc
4950
#define PCI_DEVICE_ID_AMD_MI200_DF_F4 0x14d4
@@ -127,6 +128,7 @@ static const struct pci_device_id amd_nb_link_ids[] = {
127128
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M78H_DF_F4) },
128129
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F4) },
129130
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M00H_DF_F4) },
131+
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M20H_DF_F4) },
130132
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M60H_DF_F4) },
131133
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M70H_DF_F4) },
132134
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_MI200_DF_F4) },

arch/x86/kernel/apic/apic.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,19 @@ static int lapic_timer_shutdown(struct clock_event_device *evt)
440440
v = apic_read(APIC_LVTT);
441441
v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
442442
apic_write(APIC_LVTT, v);
443-
apic_write(APIC_TMICT, 0);
443+
444+
/*
445+
* Setting APIC_LVT_MASKED (above) should be enough to tell
446+
* the hardware that this timer will never fire. But AMD
447+
* erratum 411 and some Intel CPU behavior circa 2024 say
448+
* otherwise. Time for belt and suspenders programming: mask
449+
* the timer _and_ zero the counter registers:
450+
*/
451+
if (v & APIC_LVT_TIMER_TSCDEADLINE)
452+
wrmsrl(MSR_IA32_TSC_DEADLINE, 0);
453+
else
454+
apic_write(APIC_TMICT, 0);
455+
444456
return 0;
445457
}
446458

arch/x86/kernel/cpu/amd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,5 +1202,6 @@ void amd_check_microcode(void)
12021202
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
12031203
return;
12041204

1205-
on_each_cpu(zenbleed_check_cpu, NULL, 1);
1205+
if (cpu_feature_enabled(X86_FEATURE_ZEN2))
1206+
on_each_cpu(zenbleed_check_cpu, NULL, 1);
12061207
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static inline bool rdt_get_mb_table(struct rdt_resource *r)
207207
return false;
208208
}
209209

210-
static bool __get_mem_config_intel(struct rdt_resource *r)
210+
static __init bool __get_mem_config_intel(struct rdt_resource *r)
211211
{
212212
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
213213
union cpuid_0x10_3_eax eax;
@@ -241,7 +241,7 @@ static bool __get_mem_config_intel(struct rdt_resource *r)
241241
return true;
242242
}
243243

244-
static bool __rdt_get_mem_config_amd(struct rdt_resource *r)
244+
static __init bool __rdt_get_mem_config_amd(struct rdt_resource *r)
245245
{
246246
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
247247
u32 eax, ebx, ecx, edx, subleaf;

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
* hardware. The allocated bandwidth percentage is rounded to the next
3030
* control step available on the hardware.
3131
*/
32-
static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r)
32+
static bool bw_validate(char *buf, u32 *data, struct rdt_resource *r)
3333
{
34-
unsigned long bw;
3534
int ret;
35+
u32 bw;
3636

3737
/*
3838
* Only linear delay values is supported for current Intel SKUs.
@@ -42,16 +42,21 @@ static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r)
4242
return false;
4343
}
4444

45-
ret = kstrtoul(buf, 10, &bw);
45+
ret = kstrtou32(buf, 10, &bw);
4646
if (ret) {
47-
rdt_last_cmd_printf("Non-decimal digit in MB value %s\n", buf);
47+
rdt_last_cmd_printf("Invalid MB value %s\n", buf);
4848
return false;
4949
}
5050

51-
if ((bw < r->membw.min_bw || bw > r->default_ctrl) &&
52-
!is_mba_sc(r)) {
53-
rdt_last_cmd_printf("MB value %ld out of range [%d,%d]\n", bw,
54-
r->membw.min_bw, r->default_ctrl);
51+
/* Nothing else to do if software controller is enabled. */
52+
if (is_mba_sc(r)) {
53+
*data = bw;
54+
return true;
55+
}
56+
57+
if (bw < r->membw.min_bw || bw > r->default_ctrl) {
58+
rdt_last_cmd_printf("MB value %u out of range [%d,%d]\n",
59+
bw, r->membw.min_bw, r->default_ctrl);
5560
return false;
5661
}
5762

@@ -65,7 +70,7 @@ int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s,
6570
struct resctrl_staged_config *cfg;
6671
u32 closid = data->rdtgrp->closid;
6772
struct rdt_resource *r = s->res;
68-
unsigned long bw_val;
73+
u32 bw_val;
6974

7075
cfg = &d->staged_config[s->conf_type];
7176
if (cfg->have_new_ctrl) {

0 commit comments

Comments
 (0)