Skip to content

Commit 496dcc5

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: "This update provides: - prevent KASLR from randomizing EFI regions - restrict the usage of -maccumulate-outgoing-args and document when and why it is required. - make the Global Physical Address calculation for UV4 systems work correctly. - address a copy->paste->forgot-edit problem in the MCE exception table entries. - assign a name to AMD MCA bank 3, so the sysfs file registration works. - add a missing include in the boot code" * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/boot: Include missing header file x86/mce/AMD: Give a name to MCA bank 3 when accessed with legacy MSRs x86/build: Mostly disable '-maccumulate-outgoing-args' x86/mm/KASLR: Exclude EFI region from KASLR VA space randomization x86/mce: Fix copy/paste error in exception table entries x86/platform/uv: Fix calculation of Global Physical Address
2 parents 128c434 + 6b1cc94 commit 496dcc5

File tree

10 files changed

+53
-30
lines changed

10 files changed

+53
-30
lines changed

arch/x86/Makefile

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ else
120120
# -funit-at-a-time shrinks the kernel .text considerably
121121
# unfortunately it makes reading oopses harder.
122122
KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)
123-
124-
# this works around some issues with generating unwind tables in older gccs
125-
# newer gccs do it by default
126-
KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args)
127123
endif
128124

129125
ifdef CONFIG_X86_X32
@@ -147,6 +143,37 @@ ifeq ($(CONFIG_KMEMCHECK),y)
147143
KBUILD_CFLAGS += $(call cc-option,-fno-builtin-memcpy)
148144
endif
149145

146+
#
147+
# If the function graph tracer is used with mcount instead of fentry,
148+
# '-maccumulate-outgoing-args' is needed to prevent a GCC bug
149+
# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42109)
150+
#
151+
ifdef CONFIG_FUNCTION_GRAPH_TRACER
152+
ifndef CONFIG_HAVE_FENTRY
153+
ACCUMULATE_OUTGOING_ARGS := 1
154+
else
155+
ifeq ($(call cc-option-yn, -mfentry), n)
156+
ACCUMULATE_OUTGOING_ARGS := 1
157+
endif
158+
endif
159+
endif
160+
161+
#
162+
# Jump labels need '-maccumulate-outgoing-args' for gcc < 4.5.2 to prevent a
163+
# GCC bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46226). There's no way
164+
# to test for this bug at compile-time because the test case needs to execute,
165+
# which is a no-go for cross compilers. So check the GCC version instead.
166+
#
167+
ifdef CONFIG_JUMP_LABEL
168+
ifneq ($(ACCUMULATE_OUTGOING_ARGS), 1)
169+
ACCUMULATE_OUTGOING_ARGS = $(call cc-if-fullversion, -lt, 040502, 1)
170+
endif
171+
endif
172+
173+
ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
174+
KBUILD_CFLAGS += -maccumulate-outgoing-args
175+
endif
176+
150177
# Stackpointer is addressed different for 32 bit and 64 bit x86
151178
sp-$(CONFIG_X86_32) := esp
152179
sp-$(CONFIG_X86_64) := rsp

arch/x86/Makefile_32.cpu

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,6 @@ cflags-$(CONFIG_MGEODE_LX) += $(call cc-option,-march=geode,-march=pentium-mmx)
4545
# cpu entries
4646
cflags-$(CONFIG_X86_GENERIC) += $(call tune,generic,$(call tune,i686))
4747

48-
# Work around the pentium-mmx code generator madness of gcc4.4.x which
49-
# does stack alignment by generating horrible code _before_ the mcount
50-
# prologue (push %ebp, mov %esp, %ebp) which breaks the function graph
51-
# tracer assumptions. For i686, generic, core2 this is set by the
52-
# compiler anyway
53-
ifeq ($(CONFIG_FUNCTION_GRAPH_TRACER), y)
54-
ADD_ACCUMULATE_OUTGOING_ARGS := y
55-
endif
56-
57-
# Work around to a bug with asm goto with first implementations of it
58-
# in gcc causing gcc to mess up the push and pop of the stack in some
59-
# uses of asm goto.
60-
ifeq ($(CONFIG_JUMP_LABEL), y)
61-
ADD_ACCUMULATE_OUTGOING_ARGS := y
62-
endif
63-
64-
cflags-$(ADD_ACCUMULATE_OUTGOING_ARGS) += $(call cc-option,-maccumulate-outgoing-args)
65-
6648
# Bug fix for binutils: this option is required in order to keep
6749
# binutils from generating NOPL instructions against our will.
6850
ifneq ($(CONFIG_X86_P6_NOP),y)

arch/x86/boot/compressed/error.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* memcpy() and memmove() are defined for the compressed boot environment.
55
*/
66
#include "misc.h"
7+
#include "error.h"
78

89
void warn(char *m)
910
{

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,15 +485,17 @@ static inline unsigned long uv_soc_phys_ram_to_gpa(unsigned long paddr)
485485

486486
if (paddr < uv_hub_info->lowmem_remap_top)
487487
paddr |= uv_hub_info->lowmem_remap_base;
488-
paddr |= uv_hub_info->gnode_upper;
489-
if (m_val)
488+
489+
if (m_val) {
490+
paddr |= uv_hub_info->gnode_upper;
490491
paddr = ((paddr << uv_hub_info->m_shift)
491492
>> uv_hub_info->m_shift) |
492493
((paddr >> uv_hub_info->m_val)
493494
<< uv_hub_info->n_lshift);
494-
else
495+
} else {
495496
paddr |= uv_soc_phys_ram_to_nasid(paddr)
496497
<< uv_hub_info->gpa_shift;
498+
}
497499
return paddr;
498500
}
499501

arch/x86/kernel/apic/x2apic_uv_x.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,8 @@ void __init uv_init_hub_info(struct uv_hub_info_s *hi)
11051105
node_id.v = uv_read_local_mmr(UVH_NODE_ID);
11061106
uv_cpuid.gnode_shift = max_t(unsigned int, uv_cpuid.gnode_shift, mn.n_val);
11071107
hi->gnode_extra = (node_id.s.node_id & ~((1 << uv_cpuid.gnode_shift) - 1)) >> 1;
1108-
hi->gnode_upper = (unsigned long)hi->gnode_extra << mn.m_val;
1108+
if (mn.m_val)
1109+
hi->gnode_upper = (u64)hi->gnode_extra << mn.m_val;
11091110

11101111
if (uv_gp_table) {
11111112
hi->global_mmr_base = uv_gp_table->mmr_base;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static const char * const th_names[] = {
6060
"load_store",
6161
"insn_fetch",
6262
"combined_unit",
63-
"",
63+
"decode_unit",
6464
"northbridge",
6565
"execution_unit",
6666
};

arch/x86/kernel/ftrace.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
#include <asm/ftrace.h>
3030
#include <asm/nops.h>
3131

32+
#if defined(CONFIG_FUNCTION_GRAPH_TRACER) && \
33+
!defined(CC_USING_FENTRY) && \
34+
!defined(CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE)
35+
# error The following combination is not supported: ((compiler missing -mfentry) || (CONFIG_X86_32 and !CONFIG_DYNAMIC_FTRACE)) && CONFIG_FUNCTION_GRAPH_TRACER && CONFIG_CC_OPTIMIZE_FOR_SIZE
36+
#endif
37+
3238
#ifdef CONFIG_DYNAMIC_FTRACE
3339

3440
int ftrace_arch_code_modify_prepare(void)

arch/x86/lib/memcpy_64.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ EXPORT_SYMBOL_GPL(memcpy_mcsafe_unrolled)
290290
_ASM_EXTABLE_FAULT(.L_copy_leading_bytes, .L_memcpy_mcsafe_fail)
291291
_ASM_EXTABLE_FAULT(.L_cache_w0, .L_memcpy_mcsafe_fail)
292292
_ASM_EXTABLE_FAULT(.L_cache_w1, .L_memcpy_mcsafe_fail)
293-
_ASM_EXTABLE_FAULT(.L_cache_w3, .L_memcpy_mcsafe_fail)
293+
_ASM_EXTABLE_FAULT(.L_cache_w2, .L_memcpy_mcsafe_fail)
294294
_ASM_EXTABLE_FAULT(.L_cache_w3, .L_memcpy_mcsafe_fail)
295295
_ASM_EXTABLE_FAULT(.L_cache_w4, .L_memcpy_mcsafe_fail)
296296
_ASM_EXTABLE_FAULT(.L_cache_w5, .L_memcpy_mcsafe_fail)

arch/x86/mm/kaslr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static const unsigned long vaddr_start = __PAGE_OFFSET_BASE;
4848
#if defined(CONFIG_X86_ESPFIX64)
4949
static const unsigned long vaddr_end = ESPFIX_BASE_ADDR;
5050
#elif defined(CONFIG_EFI)
51-
static const unsigned long vaddr_end = EFI_VA_START;
51+
static const unsigned long vaddr_end = EFI_VA_END;
5252
#else
5353
static const unsigned long vaddr_end = __START_KERNEL_map;
5454
#endif
@@ -105,7 +105,7 @@ void __init kernel_randomize_memory(void)
105105
*/
106106
BUILD_BUG_ON(vaddr_start >= vaddr_end);
107107
BUILD_BUG_ON(IS_ENABLED(CONFIG_X86_ESPFIX64) &&
108-
vaddr_end >= EFI_VA_START);
108+
vaddr_end >= EFI_VA_END);
109109
BUILD_BUG_ON((IS_ENABLED(CONFIG_X86_ESPFIX64) ||
110110
IS_ENABLED(CONFIG_EFI)) &&
111111
vaddr_end >= __START_KERNEL_map);

scripts/Kbuild.include

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ cc-fullversion = $(shell $(CONFIG_SHELL) \
148148
# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
149149
cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4))
150150

151+
# cc-if-fullversion
152+
# Usage: EXTRA_CFLAGS += $(call cc-if-fullversion, -lt, 040502, -O1)
153+
cc-if-fullversion = $(shell [ $(cc-fullversion) $(1) $(2) ] && echo $(3) || echo $(4))
154+
151155
# cc-ldoption
152156
# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
153157
cc-ldoption = $(call try-run,\

0 commit comments

Comments
 (0)