diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-03-31 11:40:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-03-31 11:40:15 -0400 |
commit | 915ee0da5ecb7ac7fd023ae36f01c47ce47a45d1 (patch) | |
tree | 59dd7488ed8b8570f18ef590c1e888035efb130e | |
parent | 590627f755bc385bd2b2fbd87de312a462889222 (diff) | |
parent | f560bd19d2fe0e54851d706b72acbc6f2eed3567 (diff) |
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 pile of x86 updates:
- Prevent exceeding he valid physical address space in the /dev/mem
limit checks.
- Move all header content inside the header guard to prevent compile
failures.
- Fix the bogus __percpu annotation in this_cpu_has() which makes
sparse very noisy.
- Disable switch jump tables completely when retpolines are enabled.
- Prevent leaking the trampoline address"
* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/realmode: Make set_real_mode_mem() static inline
x86/cpufeature: Fix __percpu annotation in this_cpu_has()
x86/mm: Don't exceed the valid physical address space
x86/retpolines: Disable switch jump tables when retpolines are enabled
x86/realmode: Don't leak the trampoline kernel address
x86/boot: Fix incorrect ifdeffery scope
x86/resctrl: Remove unused variable
-rw-r--r-- | arch/x86/Makefile | 8 | ||||
-rw-r--r-- | arch/x86/boot/compressed/misc.h | 4 | ||||
-rw-r--r-- | arch/x86/include/asm/cpufeature.h | 5 | ||||
-rw-r--r-- | arch/x86/include/asm/realmode.h | 6 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/resctrl/monitor.c | 3 | ||||
-rw-r--r-- | arch/x86/mm/mmap.c | 2 | ||||
-rw-r--r-- | arch/x86/platform/efi/quirks.c | 2 | ||||
-rw-r--r-- | arch/x86/realmode/init.c | 11 |
8 files changed, 19 insertions, 22 deletions
diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 2d8b9d8ca4f8..a587805c6687 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile | |||
@@ -219,8 +219,12 @@ ifdef CONFIG_RETPOLINE | |||
219 | # Additionally, avoid generating expensive indirect jumps which | 219 | # Additionally, avoid generating expensive indirect jumps which |
220 | # are subject to retpolines for small number of switch cases. | 220 | # are subject to retpolines for small number of switch cases. |
221 | # clang turns off jump table generation by default when under | 221 | # clang turns off jump table generation by default when under |
222 | # retpoline builds, however, gcc does not for x86. | 222 | # retpoline builds, however, gcc does not for x86. This has |
223 | KBUILD_CFLAGS += $(call cc-option,--param=case-values-threshold=20) | 223 | # only been fixed starting from gcc stable version 8.4.0 and |
224 | # onwards, but not for older ones. See gcc bug #86952. | ||
225 | ifndef CONFIG_CC_IS_CLANG | ||
226 | KBUILD_CFLAGS += $(call cc-option,-fno-jump-tables) | ||
227 | endif | ||
224 | endif | 228 | endif |
225 | 229 | ||
226 | archscripts: scripts_basic | 230 | archscripts: scripts_basic |
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h index fd13655e0f9b..d2f184165934 100644 --- a/arch/x86/boot/compressed/misc.h +++ b/arch/x86/boot/compressed/misc.h | |||
@@ -120,8 +120,6 @@ static inline void console_init(void) | |||
120 | 120 | ||
121 | void set_sev_encryption_mask(void); | 121 | void set_sev_encryption_mask(void); |
122 | 122 | ||
123 | #endif | ||
124 | |||
125 | /* acpi.c */ | 123 | /* acpi.c */ |
126 | #ifdef CONFIG_ACPI | 124 | #ifdef CONFIG_ACPI |
127 | acpi_physical_address get_rsdp_addr(void); | 125 | acpi_physical_address get_rsdp_addr(void); |
@@ -135,3 +133,5 @@ int count_immovable_mem_regions(void); | |||
135 | #else | 133 | #else |
136 | static inline int count_immovable_mem_regions(void) { return 0; } | 134 | static inline int count_immovable_mem_regions(void) { return 0; } |
137 | #endif | 135 | #endif |
136 | |||
137 | #endif /* BOOT_COMPRESSED_MISC_H */ | ||
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index ce95b8cbd229..0e56ff7e4848 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h | |||
@@ -112,8 +112,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; | |||
112 | test_cpu_cap(c, bit)) | 112 | test_cpu_cap(c, bit)) |
113 | 113 | ||
114 | #define this_cpu_has(bit) \ | 114 | #define this_cpu_has(bit) \ |
115 | (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \ | 115 | (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \ |
116 | x86_this_cpu_test_bit(bit, (unsigned long *)&cpu_info.x86_capability)) | 116 | x86_this_cpu_test_bit(bit, \ |
117 | (unsigned long __percpu *)&cpu_info.x86_capability)) | ||
117 | 118 | ||
118 | /* | 119 | /* |
119 | * This macro is for detection of features which need kernel | 120 | * This macro is for detection of features which need kernel |
diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h index 63b3393bd98e..c53682303c9c 100644 --- a/arch/x86/include/asm/realmode.h +++ b/arch/x86/include/asm/realmode.h | |||
@@ -77,7 +77,11 @@ static inline size_t real_mode_size_needed(void) | |||
77 | return ALIGN(real_mode_blob_end - real_mode_blob, PAGE_SIZE); | 77 | return ALIGN(real_mode_blob_end - real_mode_blob, PAGE_SIZE); |
78 | } | 78 | } |
79 | 79 | ||
80 | void set_real_mode_mem(phys_addr_t mem, size_t size); | 80 | static inline void set_real_mode_mem(phys_addr_t mem) |
81 | { | ||
82 | real_mode_header = (struct real_mode_header *) __va(mem); | ||
83 | } | ||
84 | |||
81 | void reserve_real_mode(void); | 85 | void reserve_real_mode(void); |
82 | 86 | ||
83 | #endif /* __ASSEMBLY__ */ | 87 | #endif /* __ASSEMBLY__ */ |
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index f33f11f69078..1573a0a6b525 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c | |||
@@ -501,11 +501,8 @@ out_unlock: | |||
501 | void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms) | 501 | void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms) |
502 | { | 502 | { |
503 | unsigned long delay = msecs_to_jiffies(delay_ms); | 503 | unsigned long delay = msecs_to_jiffies(delay_ms); |
504 | struct rdt_resource *r; | ||
505 | int cpu; | 504 | int cpu; |
506 | 505 | ||
507 | r = &rdt_resources_all[RDT_RESOURCE_L3]; | ||
508 | |||
509 | cpu = cpumask_any(&dom->cpu_mask); | 506 | cpu = cpumask_any(&dom->cpu_mask); |
510 | dom->cqm_work_cpu = cpu; | 507 | dom->cqm_work_cpu = cpu; |
511 | 508 | ||
diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c index db3165714521..dc726e07d8ba 100644 --- a/arch/x86/mm/mmap.c +++ b/arch/x86/mm/mmap.c | |||
@@ -230,7 +230,7 @@ bool mmap_address_hint_valid(unsigned long addr, unsigned long len) | |||
230 | /* Can we access it for direct reading/writing? Must be RAM: */ | 230 | /* Can we access it for direct reading/writing? Must be RAM: */ |
231 | int valid_phys_addr_range(phys_addr_t addr, size_t count) | 231 | int valid_phys_addr_range(phys_addr_t addr, size_t count) |
232 | { | 232 | { |
233 | return addr + count <= __pa(high_memory); | 233 | return addr + count - 1 <= __pa(high_memory - 1); |
234 | } | 234 | } |
235 | 235 | ||
236 | /* Can we access it through mmap? Must be a valid physical address: */ | 236 | /* Can we access it through mmap? Must be a valid physical address: */ |
diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c index 458a0e2bcc57..a25a9fd987a9 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c | |||
@@ -449,7 +449,7 @@ void __init efi_free_boot_services(void) | |||
449 | */ | 449 | */ |
450 | rm_size = real_mode_size_needed(); | 450 | rm_size = real_mode_size_needed(); |
451 | if (rm_size && (start + rm_size) < (1<<20) && size >= rm_size) { | 451 | if (rm_size && (start + rm_size) < (1<<20) && size >= rm_size) { |
452 | set_real_mode_mem(start, rm_size); | 452 | set_real_mode_mem(start); |
453 | start += rm_size; | 453 | start += rm_size; |
454 | size -= rm_size; | 454 | size -= rm_size; |
455 | } | 455 | } |
diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c index d10105825d57..7dce39c8c034 100644 --- a/arch/x86/realmode/init.c +++ b/arch/x86/realmode/init.c | |||
@@ -15,15 +15,6 @@ u32 *trampoline_cr4_features; | |||
15 | /* Hold the pgd entry used on booting additional CPUs */ | 15 | /* Hold the pgd entry used on booting additional CPUs */ |
16 | pgd_t trampoline_pgd_entry; | 16 | pgd_t trampoline_pgd_entry; |
17 | 17 | ||
18 | void __init set_real_mode_mem(phys_addr_t mem, size_t size) | ||
19 | { | ||
20 | void *base = __va(mem); | ||
21 | |||
22 | real_mode_header = (struct real_mode_header *) base; | ||
23 | printk(KERN_DEBUG "Base memory trampoline at [%p] %llx size %zu\n", | ||
24 | base, (unsigned long long)mem, size); | ||
25 | } | ||
26 | |||
27 | void __init reserve_real_mode(void) | 18 | void __init reserve_real_mode(void) |
28 | { | 19 | { |
29 | phys_addr_t mem; | 20 | phys_addr_t mem; |
@@ -42,7 +33,7 @@ void __init reserve_real_mode(void) | |||
42 | } | 33 | } |
43 | 34 | ||
44 | memblock_reserve(mem, size); | 35 | memblock_reserve(mem, size); |
45 | set_real_mode_mem(mem, size); | 36 | set_real_mode_mem(mem); |
46 | } | 37 | } |
47 | 38 | ||
48 | static void __init setup_real_mode(void) | 39 | static void __init setup_real_mode(void) |