Skip to content

Commit c586165

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 Ingo Molnar: "Misc fixes from all around the place: - a KASLR related revert where we ran out of time to get a fix - this represents a substantial portion of the diffstat, - two FPU fixes, - two x86 platform fixes: an ACPI reduced-hw fix and a NumaChip fix, - an entry code fix, - and a VDSO build fix" * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: Revert "x86/mm/ASLR: Propagate base load address calculation" x86/fpu: Drop_fpu() should not assume that tsk equals current x86/fpu: Avoid math_state_restore() without used_math() in __restore_xstate_sig() x86/apic/numachip: Fix sibling map with NumaChip x86/platform, acpi: Bypass legacy PIC and PIT in ACPI hardware reduced mode x86/asm/entry/32: Fix user_mode() misuses x86/vdso: Fix the build on GCC5
2 parents 13326e5 + 69797da commit c586165

File tree

13 files changed

+66
-73
lines changed

13 files changed

+66
-73
lines changed

arch/x86/boot/compressed/aslr.c

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414
static const char build_str[] = UTS_RELEASE " (" LINUX_COMPILE_BY "@"
1515
LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION;
1616

17-
struct kaslr_setup_data {
18-
__u64 next;
19-
__u32 type;
20-
__u32 len;
21-
__u8 data[1];
22-
} kaslr_setup_data;
23-
2417
#define I8254_PORT_CONTROL 0x43
2518
#define I8254_PORT_COUNTER0 0x40
2619
#define I8254_CMD_READBACK 0xC0
@@ -302,29 +295,7 @@ static unsigned long find_random_addr(unsigned long minimum,
302295
return slots_fetch_random();
303296
}
304297

305-
static void add_kaslr_setup_data(struct boot_params *params, __u8 enabled)
306-
{
307-
struct setup_data *data;
308-
309-
kaslr_setup_data.type = SETUP_KASLR;
310-
kaslr_setup_data.len = 1;
311-
kaslr_setup_data.next = 0;
312-
kaslr_setup_data.data[0] = enabled;
313-
314-
data = (struct setup_data *)(unsigned long)params->hdr.setup_data;
315-
316-
while (data && data->next)
317-
data = (struct setup_data *)(unsigned long)data->next;
318-
319-
if (data)
320-
data->next = (unsigned long)&kaslr_setup_data;
321-
else
322-
params->hdr.setup_data = (unsigned long)&kaslr_setup_data;
323-
324-
}
325-
326-
unsigned char *choose_kernel_location(struct boot_params *params,
327-
unsigned char *input,
298+
unsigned char *choose_kernel_location(unsigned char *input,
328299
unsigned long input_size,
329300
unsigned char *output,
330301
unsigned long output_size)
@@ -335,17 +306,14 @@ unsigned char *choose_kernel_location(struct boot_params *params,
335306
#ifdef CONFIG_HIBERNATION
336307
if (!cmdline_find_option_bool("kaslr")) {
337308
debug_putstr("KASLR disabled by default...\n");
338-
add_kaslr_setup_data(params, 0);
339309
goto out;
340310
}
341311
#else
342312
if (cmdline_find_option_bool("nokaslr")) {
343313
debug_putstr("KASLR disabled by cmdline...\n");
344-
add_kaslr_setup_data(params, 0);
345314
goto out;
346315
}
347316
#endif
348-
add_kaslr_setup_data(params, 1);
349317

350318
/* Record the various known unsafe memory ranges. */
351319
mem_avoid_init((unsigned long)input, input_size,

arch/x86/boot/compressed/misc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,7 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap,
401401
* the entire decompressed kernel plus relocation table, or the
402402
* entire decompressed kernel plus .bss and .brk sections.
403403
*/
404-
output = choose_kernel_location(real_mode, input_data, input_len,
405-
output,
404+
output = choose_kernel_location(input_data, input_len, output,
406405
output_len > run_size ? output_len
407406
: run_size);
408407

arch/x86/boot/compressed/misc.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,15 @@ int cmdline_find_option_bool(const char *option);
5757

5858
#if CONFIG_RANDOMIZE_BASE
5959
/* aslr.c */
60-
unsigned char *choose_kernel_location(struct boot_params *params,
61-
unsigned char *input,
60+
unsigned char *choose_kernel_location(unsigned char *input,
6261
unsigned long input_size,
6362
unsigned char *output,
6463
unsigned long output_size);
6564
/* cpuflags.c */
6665
bool has_cpuflag(int flag);
6766
#else
6867
static inline
69-
unsigned char *choose_kernel_location(struct boot_params *params,
70-
unsigned char *input,
68+
unsigned char *choose_kernel_location(unsigned char *input,
7169
unsigned long input_size,
7270
unsigned char *output,
7371
unsigned long output_size)

arch/x86/include/asm/fpu-internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ static inline void drop_fpu(struct task_struct *tsk)
370370
preempt_disable();
371371
tsk->thread.fpu_counter = 0;
372372
__drop_fpu(tsk);
373-
clear_used_math();
373+
clear_stopped_child_used_math(tsk);
374374
preempt_enable();
375375
}
376376

arch/x86/include/asm/page_types.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ extern int devmem_is_allowed(unsigned long pagenr);
5151
extern unsigned long max_low_pfn_mapped;
5252
extern unsigned long max_pfn_mapped;
5353

54-
extern bool kaslr_enabled;
55-
5654
static inline phys_addr_t get_max_mapped(void)
5755
{
5856
return (phys_addr_t)max_pfn_mapped << PAGE_SHIFT;

arch/x86/include/uapi/asm/bootparam.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#define SETUP_DTB 2
88
#define SETUP_PCI 3
99
#define SETUP_EFI 4
10-
#define SETUP_KASLR 5
1110

1211
/* ram_size flags */
1312
#define RAMDISK_IMAGE_START_MASK 0x07FF

arch/x86/kernel/acpi/boot.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,26 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
13371337
return 0;
13381338
}
13391339

1340+
/*
1341+
* ACPI offers an alternative platform interface model that removes
1342+
* ACPI hardware requirements for platforms that do not implement
1343+
* the PC Architecture.
1344+
*
1345+
* We initialize the Hardware-reduced ACPI model here:
1346+
*/
1347+
static void __init acpi_reduced_hw_init(void)
1348+
{
1349+
if (acpi_gbl_reduced_hardware) {
1350+
/*
1351+
* Override x86_init functions and bypass legacy pic
1352+
* in Hardware-reduced ACPI mode
1353+
*/
1354+
x86_init.timers.timer_init = x86_init_noop;
1355+
x86_init.irqs.pre_vector_init = x86_init_noop;
1356+
legacy_pic = &null_legacy_pic;
1357+
}
1358+
}
1359+
13401360
/*
13411361
* If your system is blacklisted here, but you find that acpi=force
13421362
* works for you, please contact linux-acpi@vger.kernel.org
@@ -1536,6 +1556,11 @@ int __init early_acpi_boot_init(void)
15361556
*/
15371557
early_acpi_process_madt();
15381558

1559+
/*
1560+
* Hardware-reduced ACPI mode initialization:
1561+
*/
1562+
acpi_reduced_hw_init();
1563+
15391564
return 0;
15401565
}
15411566

arch/x86/kernel/apic/apic_numachip.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ static const struct apic apic_numachip;
3737
static unsigned int get_apic_id(unsigned long x)
3838
{
3939
unsigned long value;
40-
unsigned int id;
40+
unsigned int id = (x >> 24) & 0xff;
4141

42-
rdmsrl(MSR_FAM10H_NODE_ID, value);
43-
id = ((x >> 24) & 0xffU) | ((value << 2) & 0xff00U);
42+
if (static_cpu_has_safe(X86_FEATURE_NODEID_MSR)) {
43+
rdmsrl(MSR_FAM10H_NODE_ID, value);
44+
id |= (value << 2) & 0xff00;
45+
}
4446

4547
return id;
4648
}
@@ -155,10 +157,18 @@ static int __init numachip_probe(void)
155157

156158
static void fixup_cpu_id(struct cpuinfo_x86 *c, int node)
157159
{
158-
if (c->phys_proc_id != node) {
159-
c->phys_proc_id = node;
160-
per_cpu(cpu_llc_id, smp_processor_id()) = node;
160+
u64 val;
161+
u32 nodes = 1;
162+
163+
this_cpu_write(cpu_llc_id, node);
164+
165+
/* Account for nodes per socket in multi-core-module processors */
166+
if (static_cpu_has_safe(X86_FEATURE_NODEID_MSR)) {
167+
rdmsrl(MSR_FAM10H_NODE_ID, val);
168+
nodes = ((val >> 3) & 7) + 1;
161169
}
170+
171+
c->phys_proc_id = node / nodes;
162172
}
163173

164174
static int __init numachip_system_init(void)

arch/x86/kernel/module.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,21 @@ do { \
4747

4848
#ifdef CONFIG_RANDOMIZE_BASE
4949
static unsigned long module_load_offset;
50+
static int randomize_modules = 1;
5051

5152
/* Mutex protects the module_load_offset. */
5253
static DEFINE_MUTEX(module_kaslr_mutex);
5354

55+
static int __init parse_nokaslr(char *p)
56+
{
57+
randomize_modules = 0;
58+
return 0;
59+
}
60+
early_param("nokaslr", parse_nokaslr);
61+
5462
static unsigned long int get_module_load_offset(void)
5563
{
56-
if (kaslr_enabled) {
64+
if (randomize_modules) {
5765
mutex_lock(&module_kaslr_mutex);
5866
/*
5967
* Calculate the module_load_offset the first time this

arch/x86/kernel/setup.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@
122122
unsigned long max_low_pfn_mapped;
123123
unsigned long max_pfn_mapped;
124124

125-
bool __read_mostly kaslr_enabled = false;
126-
127125
#ifdef CONFIG_DMI
128126
RESERVE_BRK(dmi_alloc, 65536);
129127
#endif
@@ -427,11 +425,6 @@ static void __init reserve_initrd(void)
427425
}
428426
#endif /* CONFIG_BLK_DEV_INITRD */
429427

430-
static void __init parse_kaslr_setup(u64 pa_data, u32 data_len)
431-
{
432-
kaslr_enabled = (bool)(pa_data + sizeof(struct setup_data));
433-
}
434-
435428
static void __init parse_setup_data(void)
436429
{
437430
struct setup_data *data;
@@ -457,9 +450,6 @@ static void __init parse_setup_data(void)
457450
case SETUP_EFI:
458451
parse_efi_setup(pa_data, data_len);
459452
break;
460-
case SETUP_KASLR:
461-
parse_kaslr_setup(pa_data, data_len);
462-
break;
463453
default:
464454
break;
465455
}
@@ -842,14 +832,10 @@ static void __init trim_low_memory_range(void)
842832
static int
843833
dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
844834
{
845-
if (kaslr_enabled)
846-
pr_emerg("Kernel Offset: 0x%lx from 0x%lx (relocation range: 0x%lx-0x%lx)\n",
847-
(unsigned long)&_text - __START_KERNEL,
848-
__START_KERNEL,
849-
__START_KERNEL_map,
850-
MODULES_VADDR-1);
851-
else
852-
pr_emerg("Kernel Offset: disabled\n");
835+
pr_emerg("Kernel Offset: 0x%lx from 0x%lx "
836+
"(relocation range: 0x%lx-0x%lx)\n",
837+
(unsigned long)&_text - __START_KERNEL, __START_KERNEL,
838+
__START_KERNEL_map, MODULES_VADDR-1);
853839

854840
return 0;
855841
}

0 commit comments

Comments
 (0)