Skip to content

Commit ed8780e

Browse files
committed
Merge tag 'x86-urgent-2020-10-27' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Thomas Gleixner: "A couple of x86 fixes which missed rc1 due to my stupidity: - Drop lazy TLB mode before switching to the temporary address space for text patching. text_poke() switches to the temporary mm which clears the lazy mode and restores the original mm afterwards. Due to clearing lazy mode this might restore a already dead mm if exit_mmap() runs in parallel on another CPU. - Document the x32 syscall design fail vs. syscall numbers 512-547 properly. - Fix the ORC unwinder to handle the inactive task frame correctly. This was unearthed due to the slightly different code generation of gcc-10. - Use an up to date screen_info for the boot params of kexec instead of the possibly stale and invalid version which happened to be valid when the kexec kernel was loaded" * tag 'x86-urgent-2020-10-27' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/alternative: Don't call text_poke() in lazy TLB mode x86/syscalls: Document the fact that syscalls 512-547 are a legacy mistake x86/unwind/orc: Fix inactive tasks with stack pointer in %sp on GCC 10 compiled kernels hyperv_fb: Update screen_info after removing old framebuffer x86/kexec: Use up-to-dated screen_info copy to fill boot params
2 parents 8c2ab80 + abee7c4 commit ed8780e

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

arch/x86/entry/syscalls/syscall_64.tbl

+6-4
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,10 @@
364364
440 common process_madvise sys_process_madvise
365365

366366
#
367-
# x32-specific system call numbers start at 512 to avoid cache impact
368-
# for native 64-bit operation. The __x32_compat_sys stubs are created
369-
# on-the-fly for compat_sys_*() compatibility system calls if X86_X32
370-
# is defined.
367+
# Due to a historical design error, certain syscalls are numbered differently
368+
# in x32 as compared to native x86_64. These syscalls have numbers 512-547.
369+
# Do not add new syscalls to this range. Numbers 548 and above are available
370+
# for non-x32 use.
371371
#
372372
512 x32 rt_sigaction compat_sys_rt_sigaction
373373
513 x32 rt_sigreturn compat_sys_x32_rt_sigreturn
@@ -405,3 +405,5 @@
405405
545 x32 execveat compat_sys_execveat
406406
546 x32 preadv2 compat_sys_preadv64v2
407407
547 x32 pwritev2 compat_sys_pwritev64v2
408+
# This is the end of the legacy x32 range. Numbers 548 and above are
409+
# not special and are not to be used for x32-specific syscalls.

arch/x86/kernel/alternative.c

+9
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,15 @@ static inline temp_mm_state_t use_temporary_mm(struct mm_struct *mm)
807807
temp_mm_state_t temp_state;
808808

809809
lockdep_assert_irqs_disabled();
810+
811+
/*
812+
* Make sure not to be in TLB lazy mode, as otherwise we'll end up
813+
* with a stale address space WITHOUT being in lazy mode after
814+
* restoring the previous mm.
815+
*/
816+
if (this_cpu_read(cpu_tlbstate.is_lazy))
817+
leave_mm(smp_processor_id());
818+
810819
temp_state.mm = this_cpu_read(cpu_tlbstate.loaded_mm);
811820
switch_mm_irqs_off(NULL, mm, current);
812821

arch/x86/kernel/kexec-bzimage64.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ setup_boot_parameters(struct kimage *image, struct boot_params *params,
200200
params->hdr.hardware_subarch = boot_params.hdr.hardware_subarch;
201201

202202
/* Copying screen_info will do? */
203-
memcpy(&params->screen_info, &boot_params.screen_info,
204-
sizeof(struct screen_info));
203+
memcpy(&params->screen_info, &screen_info, sizeof(struct screen_info));
205204

206205
/* Fill in memsize later */
207206
params->screen_info.ext_mem_k = 0;

arch/x86/kernel/unwind_orc.c

+1-8
Original file line numberDiff line numberDiff line change
@@ -321,19 +321,12 @@ EXPORT_SYMBOL_GPL(unwind_get_return_address);
321321

322322
unsigned long *unwind_get_return_address_ptr(struct unwind_state *state)
323323
{
324-
struct task_struct *task = state->task;
325-
326324
if (unwind_done(state))
327325
return NULL;
328326

329327
if (state->regs)
330328
return &state->regs->ip;
331329

332-
if (task != current && state->sp == task->thread.sp) {
333-
struct inactive_task_frame *frame = (void *)task->thread.sp;
334-
return &frame->ret_addr;
335-
}
336-
337330
if (state->sp)
338331
return (unsigned long *)state->sp - 1;
339332

@@ -663,7 +656,7 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
663656
} else {
664657
struct inactive_task_frame *frame = (void *)task->thread.sp;
665658

666-
state->sp = task->thread.sp;
659+
state->sp = task->thread.sp + sizeof(*frame);
667660
state->bp = READ_ONCE_NOCHECK(frame->bp);
668661
state->ip = READ_ONCE_NOCHECK(frame->ret_addr);
669662
state->signal = (void *)state->ip == ret_from_fork;

drivers/video/fbdev/hyperv_fb.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -1114,8 +1114,15 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
11141114
getmem_done:
11151115
remove_conflicting_framebuffers(info->apertures,
11161116
KBUILD_MODNAME, false);
1117-
if (!gen2vm)
1117+
1118+
if (gen2vm) {
1119+
/* framebuffer is reallocated, clear screen_info to avoid misuse from kexec */
1120+
screen_info.lfb_size = 0;
1121+
screen_info.lfb_base = 0;
1122+
screen_info.orig_video_isVGA = 0;
1123+
} else {
11181124
pci_dev_put(pdev);
1125+
}
11191126
kfree(info->apertures);
11201127

11211128
return 0;

0 commit comments

Comments
 (0)