Skip to content

Commit c332f3a

Browse files
committed
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Thomas Gleixner: "A set of fixes for x86: - Fix the inconsistent error handling in the umwait init code - Rework the boot param zeroing so gcc9 stops complaining about out of bound memset. The resulting source code is actually more sane to read than the smart solution we had - Maintainers update so Tony gets involved when Intel models are added - Some more fallthrough fixes" * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/boot: Save fields explicitly, zero out everything else MAINTAINERS, x86/CPU: Tony Luck will maintain asm/intel-family.h x86/fpu/math-emu: Address fallthrough warnings x86/apic/32: Fix yet another implicit fallthrough warning x86/umwait: Fix error handling in umwait_init()
2 parents 645c03a + a90118c commit c332f3a

File tree

6 files changed

+99
-20
lines changed

6 files changed

+99
-20
lines changed

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8072,6 +8072,13 @@ T: git git://git.code.sf.net/p/intel-sas/isci
80728072
S: Supported
80738073
F: drivers/scsi/isci/
80748074

8075+
INTEL CPU family model numbers
8076+
M: Tony Luck <[email protected]>
8077+
8078+
8079+
S: Supported
8080+
F: arch/x86/include/asm/intel-family.h
8081+
80758082
INTEL DRM DRIVERS (excluding Poulsbo, Moorestown and derivative chipsets)
80768083
M: Jani Nikula <[email protected]>
80778084
M: Joonas Lahtinen <[email protected]>

arch/x86/include/asm/bootparam_utils.h

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@
1818
* Note: efi_info is commonly left uninitialized, but that field has a
1919
* private magic, so it is better to leave it unchanged.
2020
*/
21+
22+
#define sizeof_mbr(type, member) ({ sizeof(((type *)0)->member); })
23+
24+
#define BOOT_PARAM_PRESERVE(struct_member) \
25+
{ \
26+
.start = offsetof(struct boot_params, struct_member), \
27+
.len = sizeof_mbr(struct boot_params, struct_member), \
28+
}
29+
30+
struct boot_params_to_save {
31+
unsigned int start;
32+
unsigned int len;
33+
};
34+
2135
static void sanitize_boot_params(struct boot_params *boot_params)
2236
{
2337
/*
@@ -35,21 +49,40 @@ static void sanitize_boot_params(struct boot_params *boot_params)
3549
* problems again.
3650
*/
3751
if (boot_params->sentinel) {
38-
/* fields in boot_params are left uninitialized, clear them */
39-
boot_params->acpi_rsdp_addr = 0;
40-
memset(&boot_params->ext_ramdisk_image, 0,
41-
(char *)&boot_params->efi_info -
42-
(char *)&boot_params->ext_ramdisk_image);
43-
memset(&boot_params->kbd_status, 0,
44-
(char *)&boot_params->hdr -
45-
(char *)&boot_params->kbd_status);
46-
memset(&boot_params->_pad7[0], 0,
47-
(char *)&boot_params->edd_mbr_sig_buffer[0] -
48-
(char *)&boot_params->_pad7[0]);
49-
memset(&boot_params->_pad8[0], 0,
50-
(char *)&boot_params->eddbuf[0] -
51-
(char *)&boot_params->_pad8[0]);
52-
memset(&boot_params->_pad9[0], 0, sizeof(boot_params->_pad9));
52+
static struct boot_params scratch;
53+
char *bp_base = (char *)boot_params;
54+
char *save_base = (char *)&scratch;
55+
int i;
56+
57+
const struct boot_params_to_save to_save[] = {
58+
BOOT_PARAM_PRESERVE(screen_info),
59+
BOOT_PARAM_PRESERVE(apm_bios_info),
60+
BOOT_PARAM_PRESERVE(tboot_addr),
61+
BOOT_PARAM_PRESERVE(ist_info),
62+
BOOT_PARAM_PRESERVE(acpi_rsdp_addr),
63+
BOOT_PARAM_PRESERVE(hd0_info),
64+
BOOT_PARAM_PRESERVE(hd1_info),
65+
BOOT_PARAM_PRESERVE(sys_desc_table),
66+
BOOT_PARAM_PRESERVE(olpc_ofw_header),
67+
BOOT_PARAM_PRESERVE(efi_info),
68+
BOOT_PARAM_PRESERVE(alt_mem_k),
69+
BOOT_PARAM_PRESERVE(scratch),
70+
BOOT_PARAM_PRESERVE(e820_entries),
71+
BOOT_PARAM_PRESERVE(eddbuf_entries),
72+
BOOT_PARAM_PRESERVE(edd_mbr_sig_buf_entries),
73+
BOOT_PARAM_PRESERVE(edd_mbr_sig_buffer),
74+
BOOT_PARAM_PRESERVE(e820_table),
75+
BOOT_PARAM_PRESERVE(eddbuf),
76+
};
77+
78+
memset(&scratch, 0, sizeof(scratch));
79+
80+
for (i = 0; i < ARRAY_SIZE(to_save); i++) {
81+
memcpy(save_base + to_save[i].start,
82+
bp_base + to_save[i].start, to_save[i].len);
83+
}
84+
85+
memcpy(boot_params, save_base, sizeof(*boot_params));
5386
}
5487
}
5588

arch/x86/kernel/apic/probe_32.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ void __init default_setup_apic_routing(void)
184184
def_to_bigsmp = 0;
185185
break;
186186
}
187-
/* If P4 and above fall through */
187+
/* P4 and above */
188+
/* fall through */
188189
case X86_VENDOR_HYGON:
189190
case X86_VENDOR_AMD:
190191
def_to_bigsmp = 1;

arch/x86/kernel/cpu/umwait.c

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
*/
1818
static u32 umwait_control_cached = UMWAIT_CTRL_VAL(100000, UMWAIT_C02_ENABLE);
1919

20+
/*
21+
* Cache the original IA32_UMWAIT_CONTROL MSR value which is configured by
22+
* hardware or BIOS before kernel boot.
23+
*/
24+
static u32 orig_umwait_control_cached __ro_after_init;
25+
2026
/*
2127
* Serialize access to umwait_control_cached and IA32_UMWAIT_CONTROL MSR in
2228
* the sysfs write functions.
@@ -52,6 +58,23 @@ static int umwait_cpu_online(unsigned int cpu)
5258
return 0;
5359
}
5460

61+
/*
62+
* The CPU hotplug callback sets the control MSR to the original control
63+
* value.
64+
*/
65+
static int umwait_cpu_offline(unsigned int cpu)
66+
{
67+
/*
68+
* This code is protected by the CPU hotplug already and
69+
* orig_umwait_control_cached is never changed after it caches
70+
* the original control MSR value in umwait_init(). So there
71+
* is no race condition here.
72+
*/
73+
wrmsr(MSR_IA32_UMWAIT_CONTROL, orig_umwait_control_cached, 0);
74+
75+
return 0;
76+
}
77+
5578
/*
5679
* On resume, restore IA32_UMWAIT_CONTROL MSR on the boot processor which
5780
* is the only active CPU at this time. The MSR is set up on the APs via the
@@ -185,8 +208,22 @@ static int __init umwait_init(void)
185208
if (!boot_cpu_has(X86_FEATURE_WAITPKG))
186209
return -ENODEV;
187210

211+
/*
212+
* Cache the original control MSR value before the control MSR is
213+
* changed. This is the only place where orig_umwait_control_cached
214+
* is modified.
215+
*/
216+
rdmsrl(MSR_IA32_UMWAIT_CONTROL, orig_umwait_control_cached);
217+
188218
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "umwait:online",
189-
umwait_cpu_online, NULL);
219+
umwait_cpu_online, umwait_cpu_offline);
220+
if (ret < 0) {
221+
/*
222+
* On failure, the control MSR on all CPUs has the
223+
* original control value.
224+
*/
225+
return ret;
226+
}
190227

191228
register_syscore_ops(&umwait_syscore_ops);
192229

arch/x86/math-emu/errors.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,15 @@ void FPU_printall(void)
178178
for (i = 0; i < 8; i++) {
179179
FPU_REG *r = &st(i);
180180
u_char tagi = FPU_gettagi(i);
181+
181182
switch (tagi) {
182183
case TAG_Empty:
183184
continue;
184-
break;
185185
case TAG_Zero:
186186
case TAG_Special:
187+
/* Update tagi for the printk below */
187188
tagi = FPU_Special(r);
189+
/* fall through */
188190
case TAG_Valid:
189191
printk("st(%d) %c .%04lx %04lx %04lx %04lx e%+-6d ", i,
190192
getsign(r) ? '-' : '+',
@@ -198,7 +200,6 @@ void FPU_printall(void)
198200
printk("Whoops! Error in errors.c: tag%d is %d ", i,
199201
tagi);
200202
continue;
201-
break;
202203
}
203204
printk("%s\n", tag_desc[(int)(unsigned)tagi]);
204205
}

arch/x86/math-emu/fpu_trig.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ static void fyl2xp1(FPU_REG *st0_ptr, u_char st0_tag)
13521352
case TW_Denormal:
13531353
if (denormal_operand() < 0)
13541354
return;
1355-
1355+
/* fall through */
13561356
case TAG_Zero:
13571357
case TAG_Valid:
13581358
setsign(st0_ptr, getsign(st0_ptr) ^ getsign(st1_ptr));

0 commit comments

Comments
 (0)