Skip to content

Commit 0b35d32

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. * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/nmi: Fix section mismatch warnings on 32-bit x86/uv: Fix UV2 BAU legacy mode x86/mm: Only add extra pages count for the first memory range during pre-allocation early page table space x86, efi stub: Add .reloc section back into image x86/ioapic: Fix NULL pointer dereference on CPU hotplug after disabling irqs x86/reboot: Fix a warning message triggered by stop_other_cpus() x86/intel/moorestown: Change intel_scu_devices_create() to __devinit x86/numa: Set numa_nodes_parsed at acpi_numa_memory_affinity_init() x86/gart: Fix kmemleak warning x86: mce: Add the dropped timer interval init back x86/mce: Fix the MCE poll timer logic
2 parents 106544d + eeaaa96 commit 0b35d32

File tree

13 files changed

+168
-91
lines changed

13 files changed

+168
-91
lines changed

arch/x86/boot/header.S

+31-11
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ bs_die:
9494

9595
.section ".bsdata", "a"
9696
bugger_off_msg:
97-
.ascii "Direct booting from floppy is no longer supported.\r\n"
98-
.ascii "Please use a boot loader program instead.\r\n"
97+
.ascii "Direct floppy boot is not supported. "
98+
.ascii "Use a boot loader program instead.\r\n"
9999
.ascii "\n"
100-
.ascii "Remove disk and press any key to reboot . . .\r\n"
100+
.ascii "Remove disk and press any key to reboot ...\r\n"
101101
.byte 0
102102

103103
#ifdef CONFIG_EFI_STUB
@@ -111,7 +111,7 @@ coff_header:
111111
#else
112112
.word 0x8664 # x86-64
113113
#endif
114-
.word 2 # nr_sections
114+
.word 3 # nr_sections
115115
.long 0 # TimeDateStamp
116116
.long 0 # PointerToSymbolTable
117117
.long 1 # NumberOfSymbols
@@ -158,8 +158,8 @@ extra_header_fields:
158158
#else
159159
.quad 0 # ImageBase
160160
#endif
161-
.long 0x1000 # SectionAlignment
162-
.long 0x200 # FileAlignment
161+
.long 0x20 # SectionAlignment
162+
.long 0x20 # FileAlignment
163163
.word 0 # MajorOperatingSystemVersion
164164
.word 0 # MinorOperatingSystemVersion
165165
.word 0 # MajorImageVersion
@@ -200,8 +200,10 @@ extra_header_fields:
200200

201201
# Section table
202202
section_table:
203-
.ascii ".text"
204-
.byte 0
203+
#
204+
# The offset & size fields are filled in by build.c.
205+
#
206+
.ascii ".setup"
205207
.byte 0
206208
.byte 0
207209
.long 0
@@ -217,9 +219,8 @@ section_table:
217219

218220
#
219221
# The EFI application loader requires a relocation section
220-
# because EFI applications must be relocatable. But since
221-
# we don't need the loader to fixup any relocs for us, we
222-
# just create an empty (zero-length) .reloc section header.
222+
# because EFI applications must be relocatable. The .reloc
223+
# offset & size fields are filled in by build.c.
223224
#
224225
.ascii ".reloc"
225226
.byte 0
@@ -233,6 +234,25 @@ section_table:
233234
.word 0 # NumberOfRelocations
234235
.word 0 # NumberOfLineNumbers
235236
.long 0x42100040 # Characteristics (section flags)
237+
238+
#
239+
# The offset & size fields are filled in by build.c.
240+
#
241+
.ascii ".text"
242+
.byte 0
243+
.byte 0
244+
.byte 0
245+
.long 0
246+
.long 0x0 # startup_{32,64}
247+
.long 0 # Size of initialized data
248+
# on disk
249+
.long 0x0 # startup_{32,64}
250+
.long 0 # PointerToRelocations
251+
.long 0 # PointerToLineNumbers
252+
.word 0 # NumberOfRelocations
253+
.word 0 # NumberOfLineNumbers
254+
.long 0x60500020 # Characteristics (section flags)
255+
236256
#endif /* CONFIG_EFI_STUB */
237257

238258
# Kernel attributes; used by setup. This is part 1 of the

arch/x86/boot/tools/build.c

+109-63
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ typedef unsigned int u32;
5050
u8 buf[SETUP_SECT_MAX*512];
5151
int is_big_kernel;
5252

53+
#define PECOFF_RELOC_RESERVE 0x20
54+
5355
/*----------------------------------------------------------------------*/
5456

5557
static const u32 crctab32[] = {
@@ -133,11 +135,103 @@ static void usage(void)
133135
die("Usage: build setup system [> image]");
134136
}
135137

136-
int main(int argc, char ** argv)
137-
{
138138
#ifdef CONFIG_EFI_STUB
139-
unsigned int file_sz, pe_header;
139+
140+
static void update_pecoff_section_header(char *section_name, u32 offset, u32 size)
141+
{
142+
unsigned int pe_header;
143+
unsigned short num_sections;
144+
u8 *section;
145+
146+
pe_header = get_unaligned_le32(&buf[0x3c]);
147+
num_sections = get_unaligned_le16(&buf[pe_header + 6]);
148+
149+
#ifdef CONFIG_X86_32
150+
section = &buf[pe_header + 0xa8];
151+
#else
152+
section = &buf[pe_header + 0xb8];
140153
#endif
154+
155+
while (num_sections > 0) {
156+
if (strncmp((char*)section, section_name, 8) == 0) {
157+
/* section header size field */
158+
put_unaligned_le32(size, section + 0x8);
159+
160+
/* section header vma field */
161+
put_unaligned_le32(offset, section + 0xc);
162+
163+
/* section header 'size of initialised data' field */
164+
put_unaligned_le32(size, section + 0x10);
165+
166+
/* section header 'file offset' field */
167+
put_unaligned_le32(offset, section + 0x14);
168+
169+
break;
170+
}
171+
section += 0x28;
172+
num_sections--;
173+
}
174+
}
175+
176+
static void update_pecoff_setup_and_reloc(unsigned int size)
177+
{
178+
u32 setup_offset = 0x200;
179+
u32 reloc_offset = size - PECOFF_RELOC_RESERVE;
180+
u32 setup_size = reloc_offset - setup_offset;
181+
182+
update_pecoff_section_header(".setup", setup_offset, setup_size);
183+
update_pecoff_section_header(".reloc", reloc_offset, PECOFF_RELOC_RESERVE);
184+
185+
/*
186+
* Modify .reloc section contents with a single entry. The
187+
* relocation is applied to offset 10 of the relocation section.
188+
*/
189+
put_unaligned_le32(reloc_offset + 10, &buf[reloc_offset]);
190+
put_unaligned_le32(10, &buf[reloc_offset + 4]);
191+
}
192+
193+
static void update_pecoff_text(unsigned int text_start, unsigned int file_sz)
194+
{
195+
unsigned int pe_header;
196+
unsigned int text_sz = file_sz - text_start;
197+
198+
pe_header = get_unaligned_le32(&buf[0x3c]);
199+
200+
/* Size of image */
201+
put_unaligned_le32(file_sz, &buf[pe_header + 0x50]);
202+
203+
/*
204+
* Size of code: Subtract the size of the first sector (512 bytes)
205+
* which includes the header.
206+
*/
207+
put_unaligned_le32(file_sz - 512, &buf[pe_header + 0x1c]);
208+
209+
#ifdef CONFIG_X86_32
210+
/*
211+
* Address of entry point.
212+
*
213+
* The EFI stub entry point is +16 bytes from the start of
214+
* the .text section.
215+
*/
216+
put_unaligned_le32(text_start + 16, &buf[pe_header + 0x28]);
217+
#else
218+
/*
219+
* Address of entry point. startup_32 is at the beginning and
220+
* the 64-bit entry point (startup_64) is always 512 bytes
221+
* after. The EFI stub entry point is 16 bytes after that, as
222+
* the first instruction allows legacy loaders to jump over
223+
* the EFI stub initialisation
224+
*/
225+
put_unaligned_le32(text_start + 528, &buf[pe_header + 0x28]);
226+
#endif /* CONFIG_X86_32 */
227+
228+
update_pecoff_section_header(".text", text_start, text_sz);
229+
}
230+
231+
#endif /* CONFIG_EFI_STUB */
232+
233+
int main(int argc, char ** argv)
234+
{
141235
unsigned int i, sz, setup_sectors;
142236
int c;
143237
u32 sys_size;
@@ -163,13 +257,23 @@ int main(int argc, char ** argv)
163257
die("Boot block hasn't got boot flag (0xAA55)");
164258
fclose(file);
165259

260+
#ifdef CONFIG_EFI_STUB
261+
/* Reserve 0x20 bytes for .reloc section */
262+
memset(buf+c, 0, PECOFF_RELOC_RESERVE);
263+
c += PECOFF_RELOC_RESERVE;
264+
#endif
265+
166266
/* Pad unused space with zeros */
167267
setup_sectors = (c + 511) / 512;
168268
if (setup_sectors < SETUP_SECT_MIN)
169269
setup_sectors = SETUP_SECT_MIN;
170270
i = setup_sectors*512;
171271
memset(buf+c, 0, i-c);
172272

273+
#ifdef CONFIG_EFI_STUB
274+
update_pecoff_setup_and_reloc(i);
275+
#endif
276+
173277
/* Set the default root device */
174278
put_unaligned_le16(DEFAULT_ROOT_DEV, &buf[508]);
175279

@@ -194,66 +298,8 @@ int main(int argc, char ** argv)
194298
put_unaligned_le32(sys_size, &buf[0x1f4]);
195299

196300
#ifdef CONFIG_EFI_STUB
197-
file_sz = sz + i + ((sys_size * 16) - sz);
198-
199-
pe_header = get_unaligned_le32(&buf[0x3c]);
200-
201-
/* Size of image */
202-
put_unaligned_le32(file_sz, &buf[pe_header + 0x50]);
203-
204-
/*
205-
* Subtract the size of the first section (512 bytes) which
206-
* includes the header and .reloc section. The remaining size
207-
* is that of the .text section.
208-
*/
209-
file_sz -= 512;
210-
211-
/* Size of code */
212-
put_unaligned_le32(file_sz, &buf[pe_header + 0x1c]);
213-
214-
#ifdef CONFIG_X86_32
215-
/*
216-
* Address of entry point.
217-
*
218-
* The EFI stub entry point is +16 bytes from the start of
219-
* the .text section.
220-
*/
221-
put_unaligned_le32(i + 16, &buf[pe_header + 0x28]);
222-
223-
/* .text size */
224-
put_unaligned_le32(file_sz, &buf[pe_header + 0xb0]);
225-
226-
/* .text vma */
227-
put_unaligned_le32(0x200, &buf[pe_header + 0xb4]);
228-
229-
/* .text size of initialised data */
230-
put_unaligned_le32(file_sz, &buf[pe_header + 0xb8]);
231-
232-
/* .text file offset */
233-
put_unaligned_le32(0x200, &buf[pe_header + 0xbc]);
234-
#else
235-
/*
236-
* Address of entry point. startup_32 is at the beginning and
237-
* the 64-bit entry point (startup_64) is always 512 bytes
238-
* after. The EFI stub entry point is 16 bytes after that, as
239-
* the first instruction allows legacy loaders to jump over
240-
* the EFI stub initialisation
241-
*/
242-
put_unaligned_le32(i + 528, &buf[pe_header + 0x28]);
243-
244-
/* .text size */
245-
put_unaligned_le32(file_sz, &buf[pe_header + 0xc0]);
246-
247-
/* .text vma */
248-
put_unaligned_le32(0x200, &buf[pe_header + 0xc4]);
249-
250-
/* .text size of initialised data */
251-
put_unaligned_le32(file_sz, &buf[pe_header + 0xc8]);
252-
253-
/* .text file offset */
254-
put_unaligned_le32(0x200, &buf[pe_header + 0xcc]);
255-
#endif /* CONFIG_X86_32 */
256-
#endif /* CONFIG_EFI_STUB */
301+
update_pecoff_text(setup_sectors * 512, sz + i + ((sys_size * 16) - sz));
302+
#endif
257303

258304
crc = partial_crc32(buf, i, crc);
259305
if (fwrite(buf, 1, i, stdout) != i)

arch/x86/include/asm/nmi.h

+14
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ struct nmiaction {
5454
__register_nmi_handler((t), &fn##_na); \
5555
})
5656

57+
/*
58+
* For special handlers that register/unregister in the
59+
* init section only. This should be considered rare.
60+
*/
61+
#define register_nmi_handler_initonly(t, fn, fg, n) \
62+
({ \
63+
static struct nmiaction fn##_na __initdata = { \
64+
.handler = (fn), \
65+
.name = (n), \
66+
.flags = (fg), \
67+
}; \
68+
__register_nmi_handler((t), &fn##_na); \
69+
})
70+
5771
int __register_nmi_handler(unsigned int, struct nmiaction *);
5872

5973
void unregister_nmi_handler(unsigned int, const char *);

arch/x86/include/asm/uv/uv_bau.h

-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@
149149
/* 4 bits of software ack period */
150150
#define UV2_ACK_MASK 0x7UL
151151
#define UV2_ACK_UNITS_SHFT 3
152-
#define UV2_LEG_SHFT UV2H_LB_BAU_MISC_CONTROL_USE_LEGACY_DESCRIPTOR_FORMATS_SHFT
153152
#define UV2_EXT_SHFT UV2H_LB_BAU_MISC_CONTROL_ENABLE_EXTENDED_SB_STATUS_SHFT
154153

155154
/*

arch/x86/kernel/aperture_64.c

-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <linux/bitops.h>
2121
#include <linux/ioport.h>
2222
#include <linux/suspend.h>
23-
#include <linux/kmemleak.h>
2423
#include <asm/e820.h>
2524
#include <asm/io.h>
2625
#include <asm/iommu.h>
@@ -95,11 +94,6 @@ static u32 __init allocate_aperture(void)
9594
return 0;
9695
}
9796
memblock_reserve(addr, aper_size);
98-
/*
99-
* Kmemleak should not scan this block as it may not be mapped via the
100-
* kernel direct mapping.
101-
*/
102-
kmemleak_ignore(phys_to_virt(addr));
10397
printk(KERN_INFO "Mapping aperture over %d KB of RAM @ %lx\n",
10498
aper_size >> 10, addr);
10599
insert_aperture_resource((u32)addr, aper_size);

arch/x86/kernel/apic/io_apic.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1195,15 +1195,15 @@ static void __clear_irq_vector(int irq, struct irq_cfg *cfg)
11951195
BUG_ON(!cfg->vector);
11961196

11971197
vector = cfg->vector;
1198-
for_each_cpu_and(cpu, cfg->domain, cpu_online_mask)
1198+
for_each_cpu(cpu, cfg->domain)
11991199
per_cpu(vector_irq, cpu)[vector] = -1;
12001200

12011201
cfg->vector = 0;
12021202
cpumask_clear(cfg->domain);
12031203

12041204
if (likely(!cfg->move_in_progress))
12051205
return;
1206-
for_each_cpu_and(cpu, cfg->old_domain, cpu_online_mask) {
1206+
for_each_cpu(cpu, cfg->old_domain) {
12071207
for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS;
12081208
vector++) {
12091209
if (per_cpu(vector_irq, cpu)[vector] != irq)

arch/x86/kernel/cpu/mcheck/mce.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,7 @@ static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 *c)
15571557
static void __mcheck_cpu_init_timer(void)
15581558
{
15591559
struct timer_list *t = &__get_cpu_var(mce_timer);
1560-
unsigned long iv = __this_cpu_read(mce_next_interval);
1560+
unsigned long iv = check_interval * HZ;
15611561

15621562
setup_timer(t, mce_timer_fn, smp_processor_id());
15631563

arch/x86/kernel/nmi_selftest.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static int __init nmi_unk_cb(unsigned int val, struct pt_regs *regs)
4242
static void __init init_nmi_testsuite(void)
4343
{
4444
/* trap all the unknown NMIs we may generate */
45-
register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk");
45+
register_nmi_handler_initonly(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk");
4646
}
4747

4848
static void __init cleanup_nmi_testsuite(void)
@@ -64,7 +64,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
6464
{
6565
unsigned long timeout;
6666

67-
if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
67+
if (register_nmi_handler_initonly(NMI_LOCAL, test_nmi_ipi_callback,
6868
NMI_FLAG_FIRST, "nmi_selftest")) {
6969
nmi_fail = FAILURE;
7070
return;

0 commit comments

Comments
 (0)