Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'x86_urgent_for_v5.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fixes from Borislav Petkov:
"The freshest pile of shiny x86 fixes for 5.12:

- Add the arch-specific mapping between physical and logical CPUs to
fix devicetree-node lookups

- Restore the IRQ2 ignore logic

- Fix get_nr_restart_syscall() to return the correct restart syscall
number. Split in a 4-patches set to avoid kABI breakage when
backporting to dead kernels"

* tag 'x86_urgent_for_v5.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/apic/of: Fix CPU devicetree-node lookups
x86/ioapic: Ignore IRQ2 again
x86: Introduce restart_block->arch_data to remove TS_COMPAT_RESTART
x86: Introduce TS_COMPAT_RESTART to fix get_nr_restart_syscall()
x86: Move TS_COMPAT back to asm/thread_info.h
kernel, fs: Introduce and use set_restart_fn() and arch_set_restart_data()

+52 -44
-9
arch/x86/include/asm/processor.h
··· 551 551 *size = fpu_kernel_xstate_size; 552 552 } 553 553 554 - /* 555 - * Thread-synchronous status. 556 - * 557 - * This is different from the flags in that nobody else 558 - * ever touches our thread-synchronous status, so we don't 559 - * have to worry about atomic accesses. 560 - */ 561 - #define TS_COMPAT 0x0002 /* 32bit syscall active (64BIT)*/ 562 - 563 554 static inline void 564 555 native_load_sp0(unsigned long sp0) 565 556 {
+14 -1
arch/x86/include/asm/thread_info.h
··· 205 205 206 206 #endif 207 207 208 + /* 209 + * Thread-synchronous status. 210 + * 211 + * This is different from the flags in that nobody else 212 + * ever touches our thread-synchronous status, so we don't 213 + * have to worry about atomic accesses. 214 + */ 215 + #define TS_COMPAT 0x0002 /* 32bit syscall active (64BIT)*/ 216 + 217 + #ifndef __ASSEMBLY__ 208 218 #ifdef CONFIG_COMPAT 209 219 #define TS_I386_REGS_POKED 0x0004 /* regs poked by 32-bit ptracer */ 220 + 221 + #define arch_set_restart_data(restart) \ 222 + do { restart->arch_data = current_thread_info()->status; } while (0) 223 + 210 224 #endif 211 - #ifndef __ASSEMBLY__ 212 225 213 226 #ifdef CONFIG_X86_32 214 227 #define in_ia32_syscall() true
+5
arch/x86/kernel/apic/apic.c
··· 2342 2342 [0 ... NR_CPUS - 1] = -1, 2343 2343 }; 2344 2344 2345 + bool arch_match_cpu_phys_id(int cpu, u64 phys_id) 2346 + { 2347 + return phys_id == cpuid_to_apicid[cpu]; 2348 + } 2349 + 2345 2350 #ifdef CONFIG_SMP 2346 2351 /** 2347 2352 * apic_id_is_primary_thread - Check whether APIC ID belongs to a primary thread
+10
arch/x86/kernel/apic/io_apic.c
··· 1032 1032 if (idx >= 0 && test_bit(mp_irqs[idx].srcbus, mp_bus_not_pci)) { 1033 1033 irq = mp_irqs[idx].srcbusirq; 1034 1034 legacy = mp_is_legacy_irq(irq); 1035 + /* 1036 + * IRQ2 is unusable for historical reasons on systems which 1037 + * have a legacy PIC. See the comment vs. IRQ2 further down. 1038 + * 1039 + * If this gets removed at some point then the related code 1040 + * in lapic_assign_system_vectors() needs to be adjusted as 1041 + * well. 1042 + */ 1043 + if (legacy && irq == PIC_CASCADE_IR) 1044 + return -EINVAL; 1035 1045 } 1036 1046 1037 1047 mutex_lock(&ioapic_mutex);
+1 -23
arch/x86/kernel/signal.c
··· 766 766 767 767 static inline unsigned long get_nr_restart_syscall(const struct pt_regs *regs) 768 768 { 769 - /* 770 - * This function is fundamentally broken as currently 771 - * implemented. 772 - * 773 - * The idea is that we want to trigger a call to the 774 - * restart_block() syscall and that we want in_ia32_syscall(), 775 - * in_x32_syscall(), etc. to match whatever they were in the 776 - * syscall being restarted. We assume that the syscall 777 - * instruction at (regs->ip - 2) matches whatever syscall 778 - * instruction we used to enter in the first place. 779 - * 780 - * The problem is that we can get here when ptrace pokes 781 - * syscall-like values into regs even if we're not in a syscall 782 - * at all. 783 - * 784 - * For now, we maintain historical behavior and guess based on 785 - * stored state. We could do better by saving the actual 786 - * syscall arch in restart_block or (with caveats on x32) by 787 - * checking if regs->ip points to 'int $0x80'. The current 788 - * behavior is incorrect if a tracer has a different bitness 789 - * than the tracee. 790 - */ 791 769 #ifdef CONFIG_IA32_EMULATION 792 - if (current_thread_info()->status & (TS_COMPAT|TS_I386_REGS_POKED)) 770 + if (current->restart_block.arch_data & TS_COMPAT) 793 771 return __NR_ia32_restart_syscall; 794 772 #endif 795 773 #ifdef CONFIG_X86_X32_ABI
+4 -6
fs/select.c
··· 1055 1055 1056 1056 ret = do_sys_poll(ufds, nfds, to); 1057 1057 1058 - if (ret == -ERESTARTNOHAND) { 1059 - restart_block->fn = do_restart_poll; 1060 - ret = -ERESTART_RESTARTBLOCK; 1061 - } 1058 + if (ret == -ERESTARTNOHAND) 1059 + ret = set_restart_fn(restart_block, do_restart_poll); 1060 + 1062 1061 return ret; 1063 1062 } 1064 1063 ··· 1079 1080 struct restart_block *restart_block; 1080 1081 1081 1082 restart_block = &current->restart_block; 1082 - restart_block->fn = do_restart_poll; 1083 1083 restart_block->poll.ufds = ufds; 1084 1084 restart_block->poll.nfds = nfds; 1085 1085 ··· 1089 1091 } else 1090 1092 restart_block->poll.has_timeout = 0; 1091 1093 1092 - ret = -ERESTART_RESTARTBLOCK; 1094 + ret = set_restart_fn(restart_block, do_restart_poll); 1093 1095 } 1094 1096 return ret; 1095 1097 }
+1
include/linux/restart_block.h
··· 23 23 * System call restart block. 24 24 */ 25 25 struct restart_block { 26 + unsigned long arch_data; 26 27 long (*fn)(struct restart_block *); 27 28 union { 28 29 /* For futex_wait and futex_wait_requeue_pi */
+13
include/linux/thread_info.h
··· 11 11 #include <linux/types.h> 12 12 #include <linux/bug.h> 13 13 #include <linux/restart_block.h> 14 + #include <linux/errno.h> 14 15 15 16 #ifdef CONFIG_THREAD_INFO_IN_TASK 16 17 /* ··· 59 58 #include <asm/thread_info.h> 60 59 61 60 #ifdef __KERNEL__ 61 + 62 + #ifndef arch_set_restart_data 63 + #define arch_set_restart_data(restart) do { } while (0) 64 + #endif 65 + 66 + static inline long set_restart_fn(struct restart_block *restart, 67 + long (*fn)(struct restart_block *)) 68 + { 69 + restart->fn = fn; 70 + arch_set_restart_data(restart); 71 + return -ERESTART_RESTARTBLOCK; 72 + } 62 73 63 74 #ifndef THREAD_ALIGN 64 75 #define THREAD_ALIGN THREAD_SIZE
+1 -2
kernel/futex.c
··· 2728 2728 goto out; 2729 2729 2730 2730 restart = &current->restart_block; 2731 - restart->fn = futex_wait_restart; 2732 2731 restart->futex.uaddr = uaddr; 2733 2732 restart->futex.val = val; 2734 2733 restart->futex.time = *abs_time; 2735 2734 restart->futex.bitset = bitset; 2736 2735 restart->futex.flags = flags | FLAGS_HAS_TIMEOUT; 2737 2736 2738 - ret = -ERESTART_RESTARTBLOCK; 2737 + ret = set_restart_fn(restart, futex_wait_restart); 2739 2738 2740 2739 out: 2741 2740 if (to) {
+1 -1
kernel/time/alarmtimer.c
··· 854 854 if (flags == TIMER_ABSTIME) 855 855 return -ERESTARTNOHAND; 856 856 857 - restart->fn = alarm_timer_nsleep_restart; 858 857 restart->nanosleep.clockid = type; 859 858 restart->nanosleep.expires = exp; 859 + set_restart_fn(restart, alarm_timer_nsleep_restart); 860 860 return ret; 861 861 } 862 862
+1 -1
kernel/time/hrtimer.c
··· 1957 1957 } 1958 1958 1959 1959 restart = &current->restart_block; 1960 - restart->fn = hrtimer_nanosleep_restart; 1961 1960 restart->nanosleep.clockid = t.timer.base->clockid; 1962 1961 restart->nanosleep.expires = hrtimer_get_expires_tv64(&t.timer); 1962 + set_restart_fn(restart, hrtimer_nanosleep_restart); 1963 1963 out: 1964 1964 destroy_hrtimer_on_stack(&t.timer); 1965 1965 return ret;
+1 -1
kernel/time/posix-cpu-timers.c
··· 1480 1480 if (flags & TIMER_ABSTIME) 1481 1481 return -ERESTARTNOHAND; 1482 1482 1483 - restart_block->fn = posix_cpu_nsleep_restart; 1484 1483 restart_block->nanosleep.clockid = which_clock; 1484 + set_restart_fn(restart_block, posix_cpu_nsleep_restart); 1485 1485 } 1486 1486 return error; 1487 1487 }