Skip to content

Commit 915ee0d

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 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
2 parents 590627f + f560bd1 commit 915ee0d

File tree

8 files changed

+19
-22
lines changed

8 files changed

+19
-22
lines changed

arch/x86/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,12 @@ ifdef CONFIG_RETPOLINE
219219
# Additionally, avoid generating expensive indirect jumps which
220220
# are subject to retpolines for small number of switch cases.
221221
# clang turns off jump table generation by default when under
222-
# retpoline builds, however, gcc does not for x86.
223-
KBUILD_CFLAGS += $(call cc-option,--param=case-values-threshold=20)
222+
# retpoline builds, however, gcc does not for x86. This has
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
224228
endif
225229

226230
archscripts: scripts_basic

arch/x86/boot/compressed/misc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ static inline void console_init(void)
120120

121121
void set_sev_encryption_mask(void);
122122

123-
#endif
124-
125123
/* acpi.c */
126124
#ifdef CONFIG_ACPI
127125
acpi_physical_address get_rsdp_addr(void);
@@ -135,3 +133,5 @@ int count_immovable_mem_regions(void);
135133
#else
136134
static inline int count_immovable_mem_regions(void) { return 0; }
137135
#endif
136+
137+
#endif /* BOOT_COMPRESSED_MISC_H */

arch/x86/include/asm/cpufeature.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
112112
test_cpu_cap(c, bit))
113113

114114
#define this_cpu_has(bit) \
115-
(__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
116-
x86_this_cpu_test_bit(bit, (unsigned long *)&cpu_info.x86_capability))
115+
(__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
116+
x86_this_cpu_test_bit(bit, \
117+
(unsigned long __percpu *)&cpu_info.x86_capability))
117118

118119
/*
119120
* This macro is for detection of features which need kernel

arch/x86/include/asm/realmode.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ static inline size_t real_mode_size_needed(void)
7777
return ALIGN(real_mode_blob_end - real_mode_blob, PAGE_SIZE);
7878
}
7979

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+
8185
void reserve_real_mode(void);
8286

8387
#endif /* __ASSEMBLY__ */

arch/x86/kernel/cpu/resctrl/monitor.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,8 @@ void cqm_handle_limbo(struct work_struct *work)
501501
void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms)
502502
{
503503
unsigned long delay = msecs_to_jiffies(delay_ms);
504-
struct rdt_resource *r;
505504
int cpu;
506505

507-
r = &rdt_resources_all[RDT_RESOURCE_L3];
508-
509506
cpu = cpumask_any(&dom->cpu_mask);
510507
dom->cqm_work_cpu = cpu;
511508

arch/x86/mm/mmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ bool mmap_address_hint_valid(unsigned long addr, unsigned long len)
230230
/* Can we access it for direct reading/writing? Must be RAM: */
231231
int valid_phys_addr_range(phys_addr_t addr, size_t count)
232232
{
233-
return addr + count <= __pa(high_memory);
233+
return addr + count - 1 <= __pa(high_memory - 1);
234234
}
235235

236236
/* Can we access it through mmap? Must be a valid physical address: */

arch/x86/platform/efi/quirks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ void __init efi_free_boot_services(void)
449449
*/
450450
rm_size = real_mode_size_needed();
451451
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);
453453
start += rm_size;
454454
size -= rm_size;
455455
}

arch/x86/realmode/init.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ u32 *trampoline_cr4_features;
1515
/* Hold the pgd entry used on booting additional CPUs */
1616
pgd_t trampoline_pgd_entry;
1717

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-
2718
void __init reserve_real_mode(void)
2819
{
2920
phys_addr_t mem;
@@ -42,7 +33,7 @@ void __init reserve_real_mode(void)
4233
}
4334

4435
memblock_reserve(mem, size);
45-
set_real_mode_mem(mem, size);
36+
set_real_mode_mem(mem);
4637
}
4738

4839
static void __init setup_real_mode(void)

0 commit comments

Comments
 (0)