View Issue Details

IDProjectCategoryView StatusLast Update
0014703CentOS-7kernel-pluspublic2018-05-11 16:56
Reportertoracat 
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
PlatformOSOS Version7
Product Version7.5.1804 
Target Version7.5.1804Fixed in Version 
Summary0014703: kernel-plus-3.10.0-862.el7 does not compile on i686
DescriptionCentOS 7.5.1804 GA kernel-plus 3.10.0-862.el7 does not build on i686.
Additional InformationThe srpm file for kernel-plus-3.10.0-862.el7 can be found here:

https://people.centos.org/toracat/kernel/7/plus/7.5.1804/kernel-plus-3.10.0-862.el7.centos.plus.src.rpm

It builds fine on x86_64.
TagsNo tags attached.
abrt_hash
URL

Activities

kabe

kabe

2018-04-20 13:38

reporter   ~0031645

Posting Patches I had been working on.
There are many, beware.
Some patches were already posted here, but included here also for convenience.
kabe

kabe

2018-04-20 13:39

reporter  

i386-retpoline-support.patch (959 bytes)
https://bugs.centos.org/view.php?id=14597
https://bugs.centos.org/file_download.php?file_id=23450&type=bug

diff -aurp a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
--- a/arch/x86/kernel/i386_ksyms_32.c	2018-02-23 14:18:23.000000000 -0300
+++ b/arch/x86/kernel/i386_ksyms_32.c	2018-03-14 11:57:46.239599959 -0300
@@ -4,6 +4,7 @@
 #include <asm/pgtable.h>
 #include <asm/desc.h>
 #include <asm/ftrace.h>
+#include <asm/asm.h>
 
 #ifdef CONFIG_FUNCTION_TRACER
 /* mcount is defined in assembly */
@@ -37,3 +38,17 @@ EXPORT_SYMBOL(strstr);
 
 EXPORT_SYMBOL(csum_partial);
 EXPORT_SYMBOL(empty_zero_page);
+
+#ifdef CONFIG_RETPOLINE
+#define EXPORT_THUNK(reg)						\
+	extern void __x86_indirect_thunk_ ## reg(void);			\
+	EXPORT_SYMBOL(__x86_indirect_thunk_ ## reg)
+
+EXPORT_THUNK(eax);
+EXPORT_THUNK(ebx);
+EXPORT_THUNK(ecx);
+EXPORT_THUNK(edx);
+EXPORT_THUNK(esi);
+EXPORT_THUNK(edi);
+EXPORT_THUNK(ebp);
+#endif /* CONFIG_RETPOLINE */

kabe

kabe

2018-04-20 13:42

reporter  

patch-ALIGN-dupdef.patch (458 bytes)
diff -up ./arch/x86/kernel/entry_32.S.s32 ./arch/x86/kernel/entry_32.S
--- ./arch/x86/kernel/entry_32.S.s32	2018-04-15 20:28:44.000000000 +0900
+++ ./arch/x86/kernel/entry_32.S	2018-04-15 22:25:48.000000000 +0900
@@ -54,7 +54,7 @@
 #include <asm/processor-flags.h>
 #include <asm/ftrace.h>
 #include <asm/irq_vectors.h>
-#include <asm/cpufeature.h>
+#include <asm/cpufeatures.h>
 #include <asm/alternative-asm.h>
 #include <asm/asm.h>
 #include <asm/smap.h>
kabe

kabe

2018-04-20 13:42

reporter  

patch-MAX_LFS_FILESIZE-0cc3b0ec23.patch (3,723 bytes)
commit 0cc3b0ec23ce4c69e1e890ed2b8d2fa932b14aad
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Aug 27 12:12:25 2017 -0700

    Clarify (and fix) MAX_LFS_FILESIZE macros
    
    We have a MAX_LFS_FILESIZE macro that is meant to be filled in by
    filesystems (and other IO targets) that know they are 64-bit clean and
    don't have any 32-bit limits in their IO path.
    
    It turns out that our 32-bit value for that limit was bogus.  On 32-bit,
    the VM layer is limited by the page cache to only 32-bit index values,
    but our logic for that was confusing and actually wrong.  We used to
    define that value to
    
    	(((loff_t)PAGE_SIZE << (BITS_PER_LONG-1))-1)
    
    which is actually odd in several ways: it limits the index to 31 bits,
    and then it limits files so that they can't have data in that last byte
    of a page that has the highest 31-bit index (ie page index 0x7fffffff).
    
    Neither of those limitations make sense.  The index is actually the full
    32 bit unsigned value, and we can use that whole full page.  So the
    maximum size of the file would logically be "PAGE_SIZE << BITS_PER_LONG".
    
    However, we do wan tto avoid the maximum index, because we have code
    that iterates over the page indexes, and we don't want that code to
    overflow.  So the maximum size of a file on a 32-bit host should
    actually be one page less than the full 32-bit index.
    
    So the actual limit is ULONG_MAX << PAGE_SHIFT.  That means that we will
    not actually be using the page of that last index (ULONG_MAX), but we
    can grow a file up to that limit.
    
    The wrong value of MAX_LFS_FILESIZE actually caused problems for Doug
    Nazar, who was still using a 32-bit host, but with a 9.7TB 2 x RAID5
    volume.  It turns out that our old MAX_LFS_FILESIZE was 8TiB (well, one
    byte less), but the actual true VM limit is one page less than 16TiB.
    
    This was invisible until commit c2a9737f45e2 ("vfs,mm: fix a dead loop
    in truncate_inode_pages_range()"), which started applying that
    MAX_LFS_FILESIZE limit to block devices too.
    
    NOTE! On 64-bit, the page index isn't a limiter at all, and the limit is
    actually just the offset type itself (loff_t), which is signed.  But for
    clarity, on 64-bit, just use the maximum signed value, and don't make
    people have to count the number of 'f' characters in the hex constant.
    
    So just use LLONG_MAX for the 64-bit case.  That was what the value had
    been before too, just written out as a hex constant.
    
    Fixes: c2a9737f45e2 ("vfs,mm: fix a dead loop in truncate_inode_pages_range()")
    Reported-and-tested-by: Doug Nazar <nazard@nazar.ca>
    Cc: Andreas Dilger <adilger@dilger.ca>
    Cc: Mark Fasheh <mfasheh@versity.com>
    Cc: Joel Becker <jlbec@evilplan.org>
    Cc: Dave Kleikamp <shaggy@kernel.org>
    Cc: stable@kernel.org
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Ported to kernel-3.10.0-862.el7 by T.Kabe
diff -up ./include/linux/fs.h.pcs ./include/linux/fs.h
--- ./include/linux/fs.h.pcs	2018-04-18 14:53:21.000000000 +0900
+++ ./include/linux/fs.h	2018-04-18 14:55:36.000000000 +0900
@@ -989,9 +989,9 @@ static inline int file_check_writeable(s
 /* Page cache limit. The filesystems should put that into their s_maxbytes 
    limits, otherwise bad things can happen in VM. */ 
 #if BITS_PER_LONG==32
-#define MAX_LFS_FILESIZE	(((loff_t)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) 
+#define MAX_LFS_FILESIZE	((loff_t)ULONG_MAX << PAGE_SHIFT)
 #elif BITS_PER_LONG==64
-#define MAX_LFS_FILESIZE 	((loff_t)0x7fffffffffffffffLL)
+#define MAX_LFS_FILESIZE 	((loff_t)LLONG_MAX)
 #endif
 
 #define FL_POSIX	1
kabe

kabe

2018-04-20 13:43

reporter  

patch-copy_from_user-warning-v1.patch (4,250 bytes)
32bit version of copy_from_user() requires that
compiler statically knows that buffer overflow won't occur.
These patch so that static analysis by the compiler succeeds.

diff -up ./drivers/isdn/hardware/avm/b1.c.cfu4 ./drivers/isdn/hardware/avm/b1.c
--- ./drivers/isdn/hardware/avm/b1.c.cfu4	2018-03-22 06:40:12.000000000 +0900
+++ ./drivers/isdn/hardware/avm/b1.c	2018-04-18 16:24:24.000000000 +0900
@@ -176,6 +176,8 @@ int b1_load_t4file(avmcard *card, capilo
 	}
 	if (left) {
 		if (t4file->user) {
+			if (left > sizeof(buf)) /* make copy_from_user happy */
+				return -EFAULT;
 			if (copy_from_user(buf, dp, left))
 				return -EFAULT;
 		} else {
@@ -224,6 +226,8 @@ int b1_load_config(avmcard *card, capilo
 	}
 	if (left) {
 		if (config->user) {
+			if (left > sizeof(buf)) /* make copy_from_user happy */
+				return -EFAULT;
 			if (copy_from_user(buf, dp, left))
 				return -EFAULT;
 		} else {
diff -up ./fs/binfmt_misc.c.cfu2 ./fs/binfmt_misc.c
--- ./fs/binfmt_misc.c.cfu2	2018-03-22 06:40:12.000000000 +0900
+++ ./fs/binfmt_misc.c	2018-04-18 14:19:53.000000000 +0900
@@ -396,12 +396,12 @@ static int parse_command(const char __us
 {
 	char s[4];
 
-	if (!count)
-		return 0;
 	if (count > 3)
 		return -EINVAL;
 	if (copy_from_user(s, buffer, count))
 		return -EFAULT;
+	if (!count)
+		return 0;
 	if (s[count-1] == '\n')
 		count--;
 	if (count == 1 && s[0] == '0')
diff -up ./net/core/pktgen.c.pkt ./net/core/pktgen.c
--- ./net/core/pktgen.c.pkt	2018-03-22 06:40:12.000000000 +0900
+++ ./net/core/pktgen.c	2018-04-18 20:13:43.000000000 +0900
@@ -881,6 +881,8 @@ static ssize_t pktgen_if_write(struct fi
 		return len;
 
 	memset(name, 0, sizeof(name));
+	if (len > sizeof(name))
+		return -EFAULT;
 	if (copy_from_user(name, &user_buffer[i], len))
 		return -EFAULT;
 	i += len;
@@ -1798,6 +1800,8 @@ static ssize_t pktgen_thread_write(struc
 		return len;
 
 	memset(name, 0, sizeof(name));
+	if (len > sizeof(name))
+		return -EFAULT;
 	if (copy_from_user(name, &user_buffer[i], len))
 		return -EFAULT;
 	i += len;
@@ -1828,6 +1832,8 @@ static ssize_t pktgen_thread_write(struc
 			ret = len;
 			goto out;
 		}
+		if (len > sizeof(f))
+			return -EFAULT;
 		if (copy_from_user(f, &user_buffer[i], len))
 			return -EFAULT;
 		i += len;
diff -up ./sound/core/seq/seq_clientmgr.c.cfu5 ./sound/core/seq/seq_clientmgr.c
--- ./sound/core/seq/seq_clientmgr.c.cfu5	2018-03-22 06:40:12.000000000 +0900
+++ ./sound/core/seq/seq_clientmgr.c	2018-04-18 18:57:48.000000000 +0900
@@ -2123,6 +2123,8 @@ static long snd_seq_ioctl(struct file *f
 	 */
 	size = _IOC_SIZE(handler->cmd);
 	if (handler->cmd & IOC_IN) {
+		if (size > sizeof(buf)) /* make copy_from_user happy */
+			return -EFAULT;
 		if (copy_from_user(&buf, (const void __user *)arg, size))
 			return -EFAULT;
 	}
diff -up ./kernel/sys.c.cfu ./kernel/sys.c
--- ./kernel/sys.c.cfu	2018-03-22 06:40:12.000000000 +0900
+++ ./kernel/sys.c	2018-04-16 13:03:32.000000000 +0900
@@ -2091,7 +2091,10 @@ static int prctl_set_mm_map(int opt, con
 		return error;
 
 	if (prctl_map.auxv_size) {
+		unsigned long arg4 = prctl_map.auxv_size;
 		memset(user_auxv, 0, sizeof(user_auxv));
+		if (arg4 > sizeof(user_auxv)) /* to make copy_from_user happy */
+			return -EFAULT;
 		if (copy_from_user(user_auxv,
 				   (const void __user *)prctl_map.auxv,
 				   prctl_map.auxv_size))
diff -up ./drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c.cfu3 ./drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
--- ./drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c.cfu3	2018-03-22 06:40:12.000000000 +0900
+++ ./drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c	2018-04-18 15:54:52.000000000 +0900
@@ -4493,12 +4493,16 @@ int vmw_execbuf_ioctl(struct drm_device
 		return -EINVAL;
 	}
 
-	if (arg.version > 1 &&
-	    copy_from_user(&arg.context_handle,
+	if (arg.version > 1) {
+	    /* to make copy_from_user() happy, check bounds beforehand */
+	    size_t copysize = copy_offset[arg.version - 1] - copy_offset[0];
+	    if (copysize > sizeof(arg.context_handle))
+		return -EFAULT;
+	    if (copy_from_user(&arg.context_handle,
 			   (void __user *) (data + copy_offset[0]),
-			   copy_offset[arg.version - 1] -
-			   copy_offset[0]) != 0)
+			    copysize) != 0)
 		return -EFAULT;
+	    }
 
 	switch (arg.version) {
 	case 1:
kabe

kabe

2018-04-20 13:43

reporter  

patch-flush_tlb-undef.patch (419 bytes)
diff -up ./arch/x86/kernel/vm86_32.c.tlb ./arch/x86/kernel/vm86_32.c
--- ./arch/x86/kernel/vm86_32.c.tlb	2018-03-22 06:40:12.000000000 +0900
+++ ./arch/x86/kernel/vm86_32.c	2018-04-15 22:46:42.000000000 +0900
@@ -194,7 +194,7 @@ static void mark_screen_rdonly(struct mm
 	pte_unmap_unlock(pte, ptl);
 out:
 	up_write(&mm->mmap_sem);
-	flush_tlb();
+	flush_tlb_mm_range(mm, 0xA0000, 0xA0000 + 32*PAGE_SIZE, 0UL);
 }
 
 
kabe

kabe

2018-04-20 13:52

reporter  

patch-get_stack_info-198d208df4.patch (13,307 bytes)
diff -up ./arch/x86/include/asm/processor.h.gsi ./arch/x86/include/asm/processor.h
--- ./arch/x86/include/asm/processor.h.gsi	2018-03-22 06:40:12.000000000 +0900
+++ ./arch/x86/include/asm/processor.h	2018-04-16 21:12:06.000000000 +0900
@@ -527,6 +527,15 @@ struct stack_canary {
 };
 DECLARE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);
 #endif
+/*
+ * per-CPU IRQ handling stacks
+ */
+struct irq_stack {
+	u32                     stack[THREAD_SIZE/sizeof(u32)];
+} __aligned(THREAD_SIZE);
+
+DECLARE_PER_CPU(struct irq_stack *, hardirq_stack);
+DECLARE_PER_CPU(struct irq_stack *, softirq_stack);
 #endif	/* X86_64 */
 
 extern unsigned int xstate_size;
diff -up ./arch/x86/include/asm/thread_info.h.gsi ./arch/x86/include/asm/thread_info.h
--- ./arch/x86/include/asm/thread_info.h.gsi	2018-03-22 06:40:12.000000000 +0900
+++ ./arch/x86/include/asm/thread_info.h	2018-04-16 23:01:00.000000000 +0900
@@ -9,6 +9,7 @@
 
 #include <linux/compiler.h>
 #include <asm/page.h>
+#include <asm/percpu.h>
 #include <asm/types.h>
 
 /*
@@ -34,9 +35,6 @@ struct thread_info {
 	struct restart_block    restart_block;
 	void __user		*sysenter_return;
 #ifdef CONFIG_X86_32
-	unsigned long           previous_esp;   /* ESP of the previous stack in
-						   case of nested (IRQ) stacks
-						*/
 	__u8			supervisor_stack[0];
 #endif
 	unsigned int		sig_on_uaccess_error:1;
@@ -159,9 +157,9 @@ struct thread_info {
 
 #define PREEMPT_ACTIVE		0x10000000
 
-#ifdef CONFIG_X86_32
+#define STACK_WARN		(THREAD_SIZE/8)
+#define KERNEL_STACK_OFFSET	(5*(BITS_PER_LONG/8))
 
-#define STACK_WARN	(THREAD_SIZE/8)
 /*
  * macros/functions for gaining access to the thread information structure
  *
@@ -173,30 +171,9 @@ struct thread_info {
 /* how to get the current stack pointer from C */
 register unsigned long current_stack_pointer asm("esp") __used;
 
-/* how to get the thread information struct from C */
-static inline struct thread_info *current_thread_info(void)
-{
-	return (struct thread_info *)
-		(current_stack_pointer & ~(THREAD_SIZE - 1));
-}
-
-#else /* !__ASSEMBLY__ */
-
-/* how to get the thread information struct from ASM */
-#define GET_THREAD_INFO(reg)	 \
-	movl $-THREAD_SIZE, reg; \
-	andl %esp, reg
-
-/* use this one if reg already contains %esp */
-#define GET_THREAD_INFO_WITH_ESP(reg) \
-	andl $-THREAD_SIZE, reg
-
 #endif
 
-#else /* X86_32 */
-
 #include <asm/percpu.h>
-#define KERNEL_STACK_OFFSET (5*8)
 
 /*
  * macros/functions for gaining access to the thread information structure
@@ -220,8 +197,8 @@ static inline struct thread_info *curren
 
 /* how to get the thread information struct from ASM */
 #define GET_THREAD_INFO(reg) \
-	movq PER_CPU_VAR(kernel_stack),reg ; \
-	subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
+	_ASM_MOV PER_CPU_VAR(kernel_stack),reg ; \
+	_ASM_SUB $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg ;
 
 /*
  * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
@@ -231,8 +208,6 @@ static inline struct thread_info *curren
 
 #endif
 
-#endif /* !X86_32 */
-
 /*
  * Thread-synchronous status.
  *
diff -up ./arch/x86/kernel/cpu/common.c.gsi ./arch/x86/kernel/cpu/common.c
--- ./arch/x86/kernel/cpu/common.c.gsi	2018-04-15 20:28:45.000000000 +0900
+++ ./arch/x86/kernel/cpu/common.c	2018-04-16 23:48:12.000000000 +0900
@@ -1286,6 +1286,13 @@ static __init int setup_clearcpuid(char
 }
 __setup("clearcpuid=", setup_clearcpuid);
 
+DEFINE_PER_CPU(unsigned long, kernel_stack) =
+	(unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
+DEFINE_PER_CPU(unsigned long, __kernel_stack_70__) =
+	(unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE - 8192;
+EXPORT_PER_CPU_SYMBOL(kernel_stack);
+EXPORT_PER_CPU_SYMBOL(__kernel_stack_70__);
+
 #ifdef CONFIG_X86_64
 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
 struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
@@ -1302,12 +1309,6 @@ DEFINE_PER_CPU(struct task_struct *, cur
 	&init_task;
 EXPORT_PER_CPU_SYMBOL(current_task);
 
-DEFINE_PER_CPU(unsigned long, kernel_stack) =
-	(unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
-DEFINE_PER_CPU(unsigned long, __kernel_stack_70__) =
-	(unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE - 8192;
-EXPORT_PER_CPU_SYMBOL(kernel_stack);
-EXPORT_PER_CPU_SYMBOL(__kernel_stack_70__);
 
 DEFINE_PER_CPU(char *, irq_stack_ptr) =
 	init_per_cpu_var(irq_stack_union.irq_stack) + IRQ_STACK_SIZE;
diff -up ./arch/x86/kernel/dumpstack_32.c.gsi ./arch/x86/kernel/dumpstack_32.c
--- ./arch/x86/kernel/dumpstack_32.c.gsi	2018-04-16 21:12:06.000000000 +0900
+++ ./arch/x86/kernel/dumpstack_32.c	2018-04-17 19:43:45.000000000 +0900
@@ -17,6 +17,95 @@
 #include <asm/stacktrace.h>
 
 
+void stack_type_str(enum stack_type type, const char **begin, const char **end)
+{
+	switch (type) {
+	case STACK_TYPE_IRQ:
+		*begin = "IRQ";
+		*end   = "EOI";
+		break;
+	case STACK_TYPE_SOFTIRQ:
+		*begin = "SOFTIRQ";
+		*end   = "EOI";
+		break;
+#if 0 /*{*/
+	case STACK_TYPE_ENTRY:
+		*begin = "ENTRY_TRAMPOLINE";
+		*end   = "EOE";
+#endif /*}*/
+	default:
+		*begin = NULL;
+		*end   = NULL;
+	}
+}
+
+static bool in_hardirq_stack(unsigned long *stack, struct stack_info *info)
+{
+	unsigned long *begin = (unsigned long *)this_cpu_read(hardirq_stack);
+	unsigned long *end   = begin + (THREAD_SIZE / sizeof(long));
+
+	if (stack < begin || stack >= end)
+		return false;
+
+	info->type	= STACK_TYPE_IRQ;
+	info->begin	= begin;
+	info->end	= end;
+
+	/*
+	 * See irq_32.c -- the next stack pointer is stored at the beginning of
+	 * the stack.
+	 */
+	info->next_sp	= (unsigned long *)*begin;
+
+	return true;
+}
+
+static bool in_softirq_stack(unsigned long *stack, struct stack_info *info)
+{
+	unsigned long *begin = (unsigned long *)this_cpu_read(softirq_stack);
+	unsigned long *end   = begin + (THREAD_SIZE / sizeof(long));
+
+	if (stack < begin || stack >= end)
+		return false;
+
+	info->type	= STACK_TYPE_SOFTIRQ;
+	info->begin	= begin;
+	info->end	= end;
+
+	/*
+	 * The next stack pointer is stored at the beginning of the stack.
+	 * See irq_32.c.
+	 */
+	info->next_sp	= (unsigned long *)*begin;
+
+	return true;
+}
+
+int get_stack_info(unsigned long *stack, struct task_struct *task,
+		   struct stack_info *info, unsigned long *visit_mask)
+{
+	if (!stack)
+		goto unknown;
+
+	task = task ? : current;
+
+	if (in_task_stack(stack, task, info))
+		return 0;
+
+	if (task != current)
+		goto unknown;
+
+	if (in_hardirq_stack(stack, info))
+		return 0;
+
+	if (in_softirq_stack(stack, info))
+		return 0;
+
+unknown:
+	info->type = STACK_TYPE_UNKNOWN;
+	return -EINVAL;
+}
+
 void show_regs(struct pt_regs *regs)
 {
 	int i;
diff -up ./arch/x86/kernel/irq_32.c.gsi ./arch/x86/kernel/irq_32.c
--- ./arch/x86/kernel/irq_32.c.gsi	2018-04-15 20:28:44.000000000 +0900
+++ ./arch/x86/kernel/irq_32.c	2018-04-16 23:09:01.000000000 +0900
@@ -58,16 +58,8 @@ static inline int check_stack_overflow(v
 static inline void print_stack_overflow(void) { }
 #endif
 
-/*
- * per-CPU IRQ handling contexts (thread information and stack)
- */
-union irq_ctx {
-	struct thread_info      tinfo;
-	u32                     stack[THREAD_SIZE/sizeof(u32)];
-} __attribute__((aligned(THREAD_SIZE)));
-
-static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
-static DEFINE_PER_CPU(union irq_ctx *, softirq_ctx);
+DEFINE_PER_CPU(struct irq_stack *, hardirq_stack);
+DEFINE_PER_CPU(struct irq_stack *, softirq_stack);
 
 static void call_on_stack(void *func, void *stack)
 {
@@ -80,14 +72,22 @@ static void call_on_stack(void *func, vo
 		     : "memory", "cc", "edx", "ecx", "eax");
 }
 
+/* how to get the current stack pointer from C */
+register unsigned long current_stack_pointer asm("esp") __used;
+
+static inline void *current_stack(void)
+{
+	return (void *)(current_stack_pointer & ~(THREAD_SIZE - 1));
+}
+
 static inline int
 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
 {
-	union irq_ctx *curctx, *irqctx;
-	u32 *isp, arg1, arg2;
+	struct irq_stack *curstk, *irqstk;
+ 	u32 *isp, *prev_esp, arg1, arg2;
 
-	curctx = (union irq_ctx *) current_thread_info();
-	irqctx = __this_cpu_read(hardirq_ctx);
+	curstk = (struct irq_stack *) current_stack();
+	irqstk = __this_cpu_read(hardirq_stack);
 
 	/*
 	 * this is where we switch to the IRQ stack. However, if we are
@@ -95,16 +95,14 @@ execute_on_irq_stack(int overflow, struc
 	 * handler) we can't do that and just have to keep using the
 	 * current stack (which is the irq stack already after all)
 	 */
-	if (unlikely(curctx == irqctx))
+	if (unlikely(curstk == irqstk))
 		return 0;
 
-	/* build the stack frame on the IRQ stack */
-	isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
-	irqctx->tinfo.task = curctx->tinfo.task;
-	irqctx->tinfo.previous_esp = current_stack_pointer;
+	isp = (u32 *) ((char *)irqstk + sizeof(*irqstk));
 
-	/* Copy the preempt_count so that the [soft]irq checks work. */
-	irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
+	/* Save the next esp at the bottom of the stack */
+	prev_esp = (u32 *)irqstk;
+ 	*prev_esp = current_stack_pointer;
 
 	if (unlikely(overflow))
 		call_on_stack(print_stack_overflow, isp);
@@ -124,40 +122,31 @@ execute_on_irq_stack(int overflow, struc
  */
 void irq_ctx_init(int cpu)
 {
-	union irq_ctx *irqctx;
+	struct irq_stack *irqstk;
 
-	if (per_cpu(hardirq_ctx, cpu))
+	if (per_cpu(hardirq_stack, cpu))
 		return;
 
-	irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
+	irqstk = page_address(alloc_pages_node(cpu_to_node(cpu),
 					       THREADINFO_GFP,
 					       THREAD_SIZE_ORDER));
-	memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
-	irqctx->tinfo.cpu		= cpu;
-	irqctx->tinfo.preempt_count	= HARDIRQ_OFFSET;
-	irqctx->tinfo.addr_limit	= MAKE_MM_SEG(0);
-
-	per_cpu(hardirq_ctx, cpu) = irqctx;
+	per_cpu(hardirq_stack, cpu) = irqstk;
 
-	irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
+	irqstk = page_address(alloc_pages_node(cpu_to_node(cpu),
 					       THREADINFO_GFP,
 					       THREAD_SIZE_ORDER));
-	memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
-	irqctx->tinfo.cpu		= cpu;
-	irqctx->tinfo.addr_limit	= MAKE_MM_SEG(0);
-
-	per_cpu(softirq_ctx, cpu) = irqctx;
+	per_cpu(softirq_stack, cpu) = irqstk;
 
 	printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
-	       cpu, per_cpu(hardirq_ctx, cpu),  per_cpu(softirq_ctx, cpu));
+	       cpu, per_cpu(hardirq_stack, cpu),  per_cpu(softirq_stack, cpu));
 }
 
 asmlinkage void do_softirq(void)
 {
 	unsigned long flags;
-	struct thread_info *curctx;
-	union irq_ctx *irqctx;
-	u32 *isp;
+	struct thread_info *curstk;
+	struct irq_stack *irqstk;
+ 	u32 *isp, *prev_esp;
 
 	if (in_interrupt())
 		return;
@@ -165,13 +154,14 @@ asmlinkage void do_softirq(void)
 	local_irq_save(flags);
 
 	if (local_softirq_pending()) {
-		curctx = current_thread_info();
-		irqctx = __this_cpu_read(softirq_ctx);
-		irqctx->tinfo.task = curctx->task;
-		irqctx->tinfo.previous_esp = current_stack_pointer;
+		curstk = current_stack();
+		irqstk = __this_cpu_read(softirq_stack);
 
 		/* build the stack frame on the softirq stack */
-		isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
+		isp = (u32 *) ((char *)irqstk + sizeof(*irqstk));
+
+		prev_esp = (u32 *)irqstk;
+		*prev_esp = current_stack_pointer;
 
 		call_on_stack(__do_softirq, isp);
 		/*
diff -up ./arch/x86/kernel/process_32.c.gsi ./arch/x86/kernel/process_32.c
--- ./arch/x86/kernel/process_32.c.gsi	2018-03-22 06:40:12.000000000 +0900
+++ ./arch/x86/kernel/process_32.c	2018-04-16 21:12:06.000000000 +0900
@@ -307,6 +307,10 @@ __switch_to(struct task_struct *prev_p,
 	 */
 	arch_end_context_switch(next_p);
 
+	this_cpu_write(kernel_stack,
+		  (unsigned long)task_stack_page(next_p) +
+		  THREAD_SIZE - KERNEL_STACK_OFFSET);
+
 	/*
 	 * Restore %gs if needed (which is common)
 	 */
diff -up ./arch/x86/kernel/ptrace.c.gsi ./arch/x86/kernel/ptrace.c
--- ./arch/x86/kernel/ptrace.c.gsi	2018-04-16 21:12:06.000000000 +0900
+++ ./arch/x86/kernel/ptrace.c	2018-04-16 23:39:44.000000000 +0900
@@ -184,14 +184,15 @@ unsigned long kernel_stack_pointer(struc
 {
 	unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
 	unsigned long sp = (unsigned long)&regs->sp;
-	struct thread_info *tinfo;
+	u32 *prev_esp;
 
 	if (context == (sp & ~(THREAD_SIZE - 1)))
 		return sp;
 
-	tinfo = (struct thread_info *)context;
-	if (tinfo->previous_esp)
-		return tinfo->previous_esp;
+	prev_esp = (u32 *)(context);
+	if (*prev_esp)
+		return (unsigned long)*prev_esp;
+
 
 	return (unsigned long)regs;
 }
diff -up ./arch/x86/kernel/smpboot.c.gsi ./arch/x86/kernel/smpboot.c
--- ./arch/x86/kernel/smpboot.c.gsi	2018-04-16 21:12:06.000000000 +0900
+++ ./arch/x86/kernel/smpboot.c	2018-04-16 21:46:54.000000000 +0900
@@ -898,13 +898,13 @@ static int do_boot_cpu(int apicid, int c
 #else
 	clear_tsk_thread_flag(idle, TIF_FORK);
 	initial_gs = per_cpu_offset(cpu);
+#endif
 	per_cpu(kernel_stack, cpu) =
 		(unsigned long)task_stack_page(idle) -
 		KERNEL_STACK_OFFSET + THREAD_SIZE;
 	per_cpu(__kernel_stack_70__, cpu) =
 		(unsigned long)task_stack_page(idle) -
 		KERNEL_STACK_OFFSET + THREAD_SIZE - 8192;
-#endif
 	early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
 	initial_code = (unsigned long)start_secondary;
 	initial_stack  = idle->thread.sp;
kabe

kabe

2018-04-20 13:52

reporter  

patch-i686-fpu-issues.patch (2,179 bytes)
https://bugs.centos.org/view.php?id=14597
https://bugs.centos.org/file_download.php?file_id=23451&type=bug

diff -Naurp a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
--- a/arch/x86/kernel/cpu/bugs.c	2018-02-23 14:18:23.000000000 -0300
+++ b/arch/x86/kernel/cpu/bugs.c	2018-03-13 11:04:58.923951923 -0300
@@ -24,6 +24,70 @@
 #include <asm/cacheflush.h>
 #include <asm/spec_ctrl.h>
 
+static int __init no_387(char *s)
+{
+	boot_cpu_data.hard_math = 0;
+	write_cr0(X86_CR0_TS | X86_CR0_EM | X86_CR0_MP | read_cr0());
+	return 1;
+}
+
+__setup("no387", no_387);
+
+static double __initdata x = 4195835.0;
+static double __initdata y = 3145727.0;
+
+/*
+ * This used to check for exceptions..
+ * However, it turns out that to support that,
+ * the XMM trap handlers basically had to
+ * be buggy. So let's have a correct XMM trap
+ * handler, and forget about printing out
+ * some status at boot.
+ *
+ * We should really only care about bugs here
+ * anyway. Not features.
+ */
+static void __init check_fpu(void)
+{
+	s32 fdiv_bug;
+
+	if (!boot_cpu_data.hard_math) {
+#ifndef CONFIG_MATH_EMULATION
+		pr_emerg("No coprocessor found and no math emulation present\n");
+		pr_emerg("Giving up\n");
+		for (;;) ;
+#endif
+		return;
+	}
+
+	kernel_fpu_begin();
+
+	/*
+	 * trap_init() enabled FXSR and company _before_ testing for FP
+	 * problems here.
+	 *
+	 * Test for the divl bug: http://en.wikipedia.org/wiki/Fdiv_bug
+	 */
+	__asm__("fninit\n\t"
+		"fldl %1\n\t"
+		"fdivl %2\n\t"
+		"fmull %2\n\t"
+		"fldl %1\n\t"
+		"fsubp %%st,%%st(1)\n\t"
+		"fistpl %0\n\t"
+		"fwait\n\t"
+		"fninit"
+		: "=m" (*&fdiv_bug)
+		: "m" (*&x), "m" (*&y));
+
+	kernel_fpu_end();
+
+	if (fdiv_bug) {
+		set_cpu_bug(&boot_cpu_data, X86_BUG_FDIV);
+		pr_warn("Hmm, FPU with FDIV bug\n");
+	}
+}
+
 static void __init spectre_v2_select_mitigation(void);
 
 void __init check_bugs(void)
@@ -206,8 +270,10 @@ ssize_t cpu_show_meltdown(struct device
 {
 	if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
 		return sprintf(buf, "Not affected\n");
+#ifdef CONFIG_KAISER
 	if (kaiser_enabled)
 		return sprintf(buf, "Mitigation: PTI\n");
+#endif
 	return sprintf(buf, "Vulnerable\n");
 }
 
kabe

kabe

2018-04-20 13:53

reporter  

patch-no-unwind_unsafe_stack.patch (1,090 bytes)
diff -up ./arch/x86/kernel/unwind_frame.c.unwind ./arch/x86/kernel/unwind_frame.c
--- ./arch/x86/kernel/unwind_frame.c.unwind	2018-03-22 06:40:12.000000000 +0900
+++ ./arch/x86/kernel/unwind_frame.c	2018-04-17 21:03:45.000000000 +0900
@@ -43,6 +43,7 @@ static bool update_stack_state(struct un
 	return true;
 }
 
+#ifdef CONFIG_X86_64
 extern const unsigned long __start___unwind_unsafe_stack[],
 			   __stop___unwind_unsafe_stack[];
 
@@ -57,6 +58,7 @@ static bool unwind_unsafe(struct unwind_
 
 	return false;
 }
+
 extern const unsigned long __start___unwind_end_of_stack[],
 			   __stop___unwind_end_of_stack[],
 			   ret_from_fork_nospec_begin[],
@@ -82,6 +84,7 @@ static bool unwind_end(struct unwind_sta
 
 	return false;
 }
+#endif
 
 bool unwind_next_frame(struct unwind_state *state)
 {
@@ -90,11 +93,13 @@ bool unwind_next_frame(struct unwind_sta
 	if (unwind_done(state))
 		return false;
 
+#ifdef CONFIG_X86_64
 	if (unwind_unsafe(state))
 		state->error = true;
 
 	if (unwind_end(state))
 		goto the_end;
+#endif
 
 	next_bp = (unsigned long *)READ_ONCE(*state->bp);
 
kabe

kabe

2018-04-20 13:54

reporter  

patch-nospec-32-v1.patch (1,929 bytes)
diff -up ./arch/x86/kernel/entry_32.S.spec32 ./arch/x86/kernel/entry_32.S
--- ./arch/x86/kernel/entry_32.S.spec32	2018-04-18 21:29:26.000000000 +0900
+++ ./arch/x86/kernel/entry_32.S	2018-04-18 23:49:49.000000000 +0900
@@ -58,6 +58,7 @@
 #include <asm/alternative-asm.h>
 #include <asm/asm.h>
 #include <asm/smap.h>
+#include <asm/nospec-branch.h>
 
 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this.  */
 #include <linux/elf-em.h>
@@ -1285,7 +1286,7 @@ error_code:
 	movl %ecx, %es
 	TRACE_IRQS_OFF
 	movl %esp,%eax			# pt_regs pointer
-	call *%edi
+	CALL_NOSPEC %edi
 	jmp ret_from_exception
 	CFI_ENDPROC
 END(page_fault)
diff -up ./arch/x86/kernel/irq_32.c.spec32 ./arch/x86/kernel/irq_32.c
--- ./arch/x86/kernel/irq_32.c.spec32	2018-04-18 21:29:26.000000000 +0900
+++ ./arch/x86/kernel/irq_32.c	2018-04-18 23:53:10.000000000 +0900
@@ -20,6 +20,7 @@
 #include <linux/mm.h>
 
 #include <asm/apic.h>
+#include <asm/nospec-branch.h>
 
 DEFINE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat);
 EXPORT_PER_CPU_SYMBOL(irq_stat);
@@ -64,11 +65,11 @@ DEFINE_PER_CPU(struct irq_stack *, softi
 static void call_on_stack(void *func, void *stack)
 {
 	asm volatile("xchgl	%%ebx,%%esp	\n"
-		     "call	*%%edi		\n"
+		     CALL_NOSPEC
 		     "movl	%%ebx,%%esp	\n"
 		     : "=b" (stack)
 		     : "0" (stack),
-		       "D"(func)
+		       [thunk_target] "D"(func)
 		     : "memory", "cc", "edx", "ecx", "eax");
 }
 
@@ -108,11 +109,11 @@ execute_on_irq_stack(int overflow, struc
 		call_on_stack(print_stack_overflow, isp);
 
 	asm volatile("xchgl	%%ebx,%%esp	\n"
-		     "call	*%%edi		\n"
+		     CALL_NOSPEC
 		     "movl	%%ebx,%%esp	\n"
 		     : "=a" (arg1), "=d" (arg2), "=b" (isp)
 		     :  "0" (irq),   "1" (desc),  "2" (isp),
-			"D" (desc->handle_irq)
+			[thunk_target] "D" (desc->handle_irq)
 		     : "memory", "cc", "ecx");
 	return 1;
 }
diff -up ./drivers/watchdog/hpwdt.c.spec32 ./drivers/watchdog/hpwdt.c
patch-nospec-32-v1.patch (1,929 bytes)
kabe

kabe

2018-04-20 13:54

reporter  

patch-pcc-long-cast.patch (970 bytes)
diff -up ./drivers/mailbox/pcc.c.pcc ./drivers/mailbox/pcc.c
--- ./drivers/mailbox/pcc.c.pcc	2018-03-22 06:40:12.000000000 +0900
+++ ./drivers/mailbox/pcc.c	2018-04-16 16:58:39.000000000 +0900
@@ -172,7 +172,7 @@ static bool pcc_tx_done(struct mbox_chan
 {
 	struct acpi_pcct_hw_reduced *pcct_ss = chan->con_priv;
 	struct acpi_pcct_shared_memory *generic_comm_base =
-		(struct acpi_pcct_shared_memory *) pcct_ss->base_address;
+		(struct acpi_pcct_shared_memory *) (unsigned long) pcct_ss->base_address;
 	u16 cmd_delay = pcct_ss->latency;
 	unsigned int retries = 0;
 
@@ -207,7 +207,7 @@ static int pcc_send_data(struct mbox_cha
 {
 	struct acpi_pcct_hw_reduced *pcct_ss = chan->con_priv;
 	struct acpi_pcct_shared_memory *generic_comm_base =
-		(struct acpi_pcct_shared_memory *) pcct_ss->base_address;
+		(struct acpi_pcct_shared_memory *) (unsigned long) pcct_ss->base_address;
 	struct acpi_generic_address doorbell;
 	u64 doorbell_preserve;
 	u64 doorbell_val;
kabe

kabe

2018-04-20 14:03

reporter  

patch-pps-timespec64-ade1bdffe9.patch (4,869 bytes)
commit ade1bdffe90e59cd257cb9bd4f5abe4de5f14911
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Mon Sep 28 22:21:31 2015 +0200

    ntp/pps: use y2038 safe types in pps_event_time
    
    The pps_event_time uses two 'timespec' structures internally, which
    suffer from the y2038 problem. The uses of this structure are
    fairly self-contained in the pps code, so this replaces them all at
    once.
    
    Unfortunately, this includes the sfc ethernet driver aside from the
    pps subsystem, so we change that one as well. Both touch the
    same data structure, and there probably is no good way to split
    the patch into smaller units.
    
    Acked-by: Richard Cochran <richardcochran@gmail.com>
    Acked-by: David S. Miller <davem@davemloft.net>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: John Stultz <john.stultz@linaro.org>

Ported to kernel-3.10.0-862.el7 by T.Kabe
diff -up ./drivers/net/ethernet/sfc/ptp.c.pps ./drivers/net/ethernet/sfc/ptp.c
--- ./drivers/net/ethernet/sfc/ptp.c.pps	2018-03-22 06:40:12.000000000 +0900
+++ ./drivers/net/ethernet/sfc/ptp.c	2018-04-18 17:22:49.000000000 +0900
@@ -646,26 +646,26 @@ static void efx_ptp_send_times(struct ef
 			       struct pps_event_time *last_time)
 {
 	struct pps_event_time now;
-	struct timespec limit;
+	struct timespec64 limit;
 	struct efx_ptp_data *ptp = efx->ptp_data;
 	int *mc_running = ptp->start.addr;
 
 	pps_get_ts(&now);
 	limit = now.ts_real;
-	timespec_add_ns(&limit, SYNCHRONISE_PERIOD_NS);
+	timespec64_add_ns(&limit, SYNCHRONISE_PERIOD_NS);
 
 	/* Write host time for specified period or until MC is done */
-	while ((timespec_compare(&now.ts_real, &limit) < 0) &&
+	while ((timespec64_compare(&now.ts_real, &limit) < 0) &&
 	       ACCESS_ONCE(*mc_running)) {
-		struct timespec update_time;
+		struct timespec64 update_time;
 		unsigned int host_time;
 
 		/* Don't update continuously to avoid saturating the PCIe bus */
 		update_time = now.ts_real;
-		timespec_add_ns(&update_time, SYNCHRONISATION_GRANULARITY_NS);
+		timespec64_add_ns(&update_time, SYNCHRONISATION_GRANULARITY_NS);
 		do {
 			pps_get_ts(&now);
-		} while ((timespec_compare(&now.ts_real, &update_time) < 0) &&
+		} while ((timespec64_compare(&now.ts_real, &update_time) < 0) &&
 			 ACCESS_ONCE(*mc_running));
 
 		/* Synchronise NIC with single word of time only */
@@ -721,7 +721,7 @@ efx_ptp_process_times(struct efx_nic *ef
 	struct efx_ptp_data *ptp = efx->ptp_data;
 	u32 last_sec;
 	u32 start_sec;
-	struct timespec delta;
+	struct timespec64 delta;
 	ktime_t mc_time;
 
 	if (number_readings == 0)
diff -up ./drivers/pps/kapi.c.pps ./drivers/pps/kapi.c
--- ./drivers/pps/kapi.c.pps	2018-03-22 06:40:12.000000000 +0900
+++ ./drivers/pps/kapi.c	2018-04-18 17:13:42.000000000 +0900
@@ -179,8 +179,8 @@ void pps_event(struct pps_device *pps, s
 	/* check event type */
 	BUG_ON((event & (PPS_CAPTUREASSERT | PPS_CAPTURECLEAR)) == 0);
 
-	dev_dbg(pps->dev, "PPS event at %ld.%09ld\n",
-			ts->ts_real.tv_sec, ts->ts_real.tv_nsec);
+	dev_dbg(pps->dev, "PPS event at %lld.%09ld\n",
+			(s64)ts->ts_real.tv_sec, ts->ts_real.tv_nsec);
 
 	timespec_to_pps_ktime(&ts_real, ts->ts_real);
 
diff -up ./include/linux/pps_kernel.h.pps ./include/linux/pps_kernel.h
--- ./include/linux/pps_kernel.h.pps	2018-04-15 20:28:44.000000000 +0900
+++ ./include/linux/pps_kernel.h	2018-04-18 17:19:29.000000000 +0900
@@ -48,9 +48,9 @@ struct pps_source_info {
 
 struct pps_event_time {
 #ifdef CONFIG_NTP_PPS
-	struct timespec ts_raw;
+	struct timespec64 ts_raw;
 #endif /* CONFIG_NTP_PPS */
-	struct timespec ts_real;
+	struct timespec64 ts_real;
 };
 
 /* The main struct */
@@ -105,7 +105,7 @@ extern void pps_event(struct pps_device
 struct pps_device *pps_lookup_dev(void const *cookie);
 
 static inline void timespec_to_pps_ktime(struct pps_ktime *kt,
-		struct timespec ts)
+		struct timespec64 ts)
 {
 	kt->sec = ts.tv_sec;
 	kt->nsec = ts.tv_nsec;
@@ -115,25 +115,18 @@ static inline void pps_get_ts(struct pps
 {
 	struct system_time_snapshot snap;
 	ktime_get_snapshot(&snap);
-#if defined CONFIG_X86_64
 	ts->ts_real = ktime_to_timespec64(snap.real);
 #ifdef CONFIG_NTP_PPS
 	ts->ts_raw = ktime_to_timespec64(snap.raw);
 #endif
-#else
-	ts->ts_real = ktime_to_timespec(snap.real);
-#ifdef CONFIG_NTP_PPS
-	ts->ts_raw = ktime_to_timespec(snap.raw);
-#endif
-#endif
 }
 
 /* Subtract known time delay from PPS event time(s) */
-static inline void pps_sub_ts(struct pps_event_time *ts, struct timespec delta)
+static inline void pps_sub_ts(struct pps_event_time *ts, struct timespec64 delta)
 {
-	ts->ts_real = timespec_sub(ts->ts_real, delta);
+	ts->ts_real = timespec64_sub(ts->ts_real, delta);
 #ifdef CONFIG_NTP_PPS
-	ts->ts_raw = timespec_sub(ts->ts_raw, delta);
+	ts->ts_raw = timespec64_sub(ts->ts_raw, delta);
 #endif
 }
 
kabe

kabe

2018-04-20 14:03

reporter  

patch-pud_devmap-multidef.patch (2,200 bytes)
diff -up ./arch/x86/include/asm/pgtable.h.pud ./arch/x86/include/asm/pgtable.h
--- ./arch/x86/include/asm/pgtable.h.pud	2018-04-15 20:52:06.000000000 +0900
+++ ./arch/x86/include/asm/pgtable.h	2018-04-15 20:59:16.000000000 +0900
@@ -216,6 +216,7 @@ static inline int pud_trans_splitting(pu
 	return pud_val(pud) & _PAGE_SPLITTING;
 }
 
+#define __HAVE_ARCH_PUD_TRANS_HUGE
 static inline int pud_trans_huge(pud_t pud)
 {
 	return (pud_val(pud) & (_PAGE_PSE|_PAGE_DEVMAP)) == _PAGE_PSE;
@@ -234,6 +235,7 @@ static inline int pmd_devmap(pmd_t pmd)
 }
 #endif
 
+#define __HAVE_ARCH_PUD_DEVMAP
 #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
 static inline int pud_devmap(pud_t pud)
 {
@@ -1033,6 +1035,7 @@ static inline int pmd_write(pmd_t pmd)
 #if !defined(CONFIG_TRANSPARENT_HUGEPAGE) || \
 	(defined(CONFIG_TRANSPARENT_HUGEPAGE) && \
 	 !defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD))
+#define __HAVE_ARCH_PUD_TRANS_HUGE
 static inline int pud_trans_huge(pud_t pud)
 {
 	return 0;
diff -up ./include/asm-generic/pgtable.h.pud ./include/asm-generic/pgtable.h
--- ./include/asm-generic/pgtable.h.pud	2018-03-22 06:40:12.000000000 +0900
+++ ./include/asm-generic/pgtable.h	2018-04-15 20:53:45.000000000 +0900
@@ -629,10 +629,12 @@ static inline int pmd_trans_splitting(pm
 {
 	return 0;
 }
+# ifndef __HAVE_ARCH_PUD_TRANS_HUGE
 static inline int pud_trans_huge(pud_t pud)
 {
 	return 0;
 }
+# endif
 static inline int pud_trans_splitting(pud_t pud)
 {
 	return 0;
@@ -656,10 +658,12 @@ static inline int pud_write(pud_t pud)
 #if !defined(CONFIG_TRANSPARENT_HUGEPAGE) || \
 	(defined(CONFIG_TRANSPARENT_HUGEPAGE) && \
 	 !defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD))
+# ifndef __HAVE_ARCH_PUD_TRANS_HUGE
 static inline int pud_trans_huge(pud_t pud)
 {
 	return 0;
 }
+# endif
 #endif
 
 #ifndef pmd_read_atomic
diff -up ./include/linux/mm.h.pud ./include/linux/mm.h
--- ./include/linux/mm.h.pud	2018-04-15 21:00:18.000000000 +0900
+++ ./include/linux/mm.h	2018-04-15 20:59:43.000000000 +0900
@@ -380,10 +380,12 @@ static inline int pmd_devmap(pmd_t pmd)
 {
 	return 0;
 }
+# ifndef __HAVE_ARCH_PUD_DEVMAP
 static inline int pud_devmap(pud_t pud)
 {
 	return 0;
 }
+# endif
 #endif
 
 /*
toracat

toracat

2018-04-20 14:04

manager   ~0031646

@kabe

Thank you for the patches.
kabe

kabe

2018-04-20 14:04

reporter  

patch-spec_ctrl_i686.patch (2,291 bytes)
diff -up ./arch/x86/kernel/cpu/common.c.dist ./arch/x86/kernel/cpu/common.c
--- ./arch/x86/kernel/cpu/common.c.dist	2017-12-29 03:59:43.000000000 +0900
+++ ./arch/x86/kernel/cpu/common.c	2018-01-10 15:37:06.848478838 +0900
@@ -1349,6 +1349,9 @@ DEFINE_PER_CPU(struct task_struct *, fpu
 DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);
 #endif
 
+DEFINE_PER_CPU_USER_MAPPED(unsigned int, spec_ctrl_pcp);
+EXPORT_PER_CPU_SYMBOL_GPL(spec_ctrl_pcp);
+
 #endif	/* CONFIG_X86_64 */
 
 /*
diff -up ./arch/x86/include/asm/spec_ctrl.h.dist ./arch/x86/include/asm/spec_ctrl.h
--- ./arch/x86/include/asm/spec_ctrl.h.dist	2017-12-29 03:59:43.000000000 +0900
+++ ./arch/x86/include/asm/spec_ctrl.h	2018-01-10 16:10:06.048822844 +0900
@@ -161,6 +161,8 @@ extern void spec_ctrl_rescan_cpuid(void)
 extern void spec_ctrl_init(void);
 extern void spec_ctrl_cpu_init(void);
 
+DECLARE_PER_CPU_USER_MAPPED(unsigned int, spec_ctrl_pcp);
+
 bool spec_ctrl_force_enable_ibrs(void);
 bool spec_ctrl_cond_enable_ibrs(bool full_retpoline);
 bool spec_ctrl_enable_ibrs_always(void);
diff -up ./arch/x86/kernel/reboot.c.dist ./arch/x86/kernel/reboot.c
--- ./arch/x86/kernel/reboot.c.dist	2017-12-29 03:59:43.000000000 +0900
+++ ./arch/x86/kernel/reboot.c	2018-01-10 15:43:36.819240224 +0900
@@ -23,6 +23,7 @@
 #include <asm/cpu.h>
 #include <asm/nmi.h>
 #include <asm/smp.h>
+#include <asm/mmu_context.h>
 
 #include <linux/ctype.h>
 #include <linux/mc146818rtc.h>
diff -up ./arch/x86/kernel/smpboot.c.dist ./arch/x86/kernel/smpboot.c
--- ./arch/x86/kernel/smpboot.c.dist	2018-01-10 14:53:15.251175037 +0900
+++ ./arch/x86/kernel/smpboot.c	2018-01-10 15:45:14.219976320 +0900
@@ -72,6 +72,7 @@
 #include <asm/fpu-internal.h>
 #include <asm/setup.h>
 #include <asm/uv/uv.h>
+#include <asm/mmu_context.h>
 #include <linux/mc146818rtc.h>
 
 #include <asm/smpboot_hooks.h>
diff -up ./arch/x86/platform/efi/efi_32.c.dist ./arch/x86/platform/efi/efi_32.c
--- ./arch/x86/platform/efi/efi_32.c.dist	2017-12-29 03:59:43.000000000 +0900
+++ ./arch/x86/platform/efi/efi_32.c	2018-01-10 15:45:56.356433372 +0900
@@ -30,6 +30,7 @@
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/efi.h>
+#include <asm/mmu_context.h>
 
 /*
  * To make EFI call EFI runtime service in physical addressing mode we need

kabe

kabe

2018-04-20 14:05

reporter  

patch-typo-7.5.patch (1,599 bytes)
diff -up ./arch/x86/include/asm/efi.h.efi ./arch/x86/include/asm/efi.h
--- ./arch/x86/include/asm/efi.h.efi	2018-03-22 06:40:12.000000000 +0900
+++ ./arch/x86/include/asm/efi.h	2018-04-16 16:53:32.000000000 +0900
@@ -35,18 +35,18 @@
 extern unsigned long asmlinkage efi_call_phys(void *, ...);
 
 #define arch_efi_call_virt_setup()					\
-{(									\
+({									\
 	bool ibrs_on;							\
 	kernel_fpu_begin();						\
 	ibrs_on = unprotected_firmware_begin();				\
 	ibrs_on;							\
-)}
+})
 
 #define arch_efi_call_virt_teardown(ibrs_on)				\
-{(									\
+({									\
 	unprotected_firmware_end(ibrs_on);				\
 	kernel_fpu_end();						\
-)}
+})
 
 
 /*
diff -up ./include/linux/ftrace.h.ftrace ./include/linux/ftrace.h
--- ./include/linux/ftrace.h.ftrace	2018-03-22 06:40:12.000000000 +0900
+++ ./include/linux/ftrace.h	2018-04-16 14:21:51.000000000 +0900
@@ -685,6 +685,9 @@ struct ftrace_ret_stack {
 	unsigned long func;
 	unsigned long long calltime;
 	unsigned long long subtime;
+#ifdef HAVE_FUNCTION_GRAPH_FP_TEST
+	unsigned long fp;
+#endif
 	RH_KABI_REPLACE(unsigned long fp, unsigned long *retp)
 };
 
diff -up ./kernel/trace/trace_output.c.ftrace ./kernel/trace/trace_output.c
--- ./kernel/trace/trace_output.c.ftrace	2018-03-22 06:40:12.000000000 +0900
+++ ./kernel/trace/trace_output.c	2018-04-16 13:21:31.000000000 +0900
@@ -399,7 +399,7 @@ ftrace_print_flags_seq_u64(struct trace_
 
 	return ret;
 }
-EXPORT_SYMBOL(trace_print_flags_seq_u64);
+EXPORT_SYMBOL(ftrace_print_flags_seq_u64);
 
 const char *
 ftrace_print_symbols_seq_u64(struct trace_seq *p, unsigned long long val,
patch-typo-7.5.patch (1,599 bytes)
kabe

kabe

2018-04-20 14:06

reporter  

patch-vmx-cmpxchg64-c0a1666bcb.patch (1,660 bytes)
commit c0a1666bcb2a33e84187a15eabdcd54056be9a97
Author: Paolo Bonzini <pbonzini@redhat.com>
Date:   Thu Sep 28 17:58:41 2017 +0200

    KVM: VMX: use cmpxchg64
    
    This fixes a compilation failure on 32-bit systems.
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index b9d2140..7f62c94 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2238,8 +2238,8 @@ static void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu)
 			new.ndst = (dest << 8) & 0xFF00;
 
 		new.sn = 0;
-	} while (cmpxchg(&pi_desc->control, old.control,
-			new.control) != old.control);
+	} while (cmpxchg64(&pi_desc->control, old.control,
+			   new.control) != old.control);
 }
 
 static void decache_tsc_multiplier(struct vcpu_vmx *vmx)
@@ -11730,8 +11730,8 @@ static void __pi_post_block(struct kvm_vcpu *vcpu)
 
 		/* set 'NV' to 'notification vector' */
 		new.nv = POSTED_INTR_VECTOR;
-	} while (cmpxchg(&pi_desc->control, old.control,
-			new.control) != old.control);
+	} while (cmpxchg64(&pi_desc->control, old.control,
+			   new.control) != old.control);
 
 	if (!WARN_ON_ONCE(vcpu->pre_pcpu == -1)) {
 		spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));
@@ -11800,8 +11800,8 @@ static int pi_pre_block(struct kvm_vcpu *vcpu)
 
 		/* set 'NV' to 'wakeup vector' */
 		new.nv = POSTED_INTR_WAKEUP_VECTOR;
-	} while (cmpxchg(&pi_desc->control, old.control,
-			new.control) != old.control);
+	} while (cmpxchg64(&pi_desc->control, old.control,
+			   new.control) != old.control);
 
 	/* We should not block the vCPU if an interrupt is posted for it.  */
 	if (pi_test_on(pi_desc) == 1)
kabe

kabe

2018-04-20 14:12

reporter  

patch-zu-format-v1.patch (1,183 bytes)
diff -up ./drivers/firmware/efi/efi.c.zu1 ./drivers/firmware/efi/efi.c
--- ./drivers/firmware/efi/efi.c.zu1	2018-03-22 06:40:12.000000000 +0900
+++ ./drivers/firmware/efi/efi.c	2018-04-16 16:48:08.000000000 +0900
@@ -277,7 +277,7 @@ int __init efi_mem_desc_lookup(u64 phys_
 				map->nr_map * map->desc_size);
 	if (!memmap) {
 		pr_err_once("early_memremap(%#llx, %zu) failed.\n",
-			    (unsigned long long) map->phys_map, map->nr_map * map->desc_size);
+			    (unsigned long long) map->phys_map, (size_t) (map->nr_map * map->desc_size));
 		return -ENOMEM;
 	}
 
diff -up ./drivers/target/target_core_user.c.tgt1 ./drivers/target/target_core_user.c
--- ./drivers/target/target_core_user.c.tgt1	2018-03-22 06:40:12.000000000 +0900
+++ ./drivers/target/target_core_user.c	2018-04-18 18:44:51.000000000 +0900
@@ -551,7 +551,7 @@ static bool is_ring_space_avail(struct t
 
 	space = spc_free(cmd_head, udev->cmdr_last_cleaned, udev->cmdr_size);
 	if (space < cmd_needed) {
-		pr_debug("no cmd space: %u %u %u %lu %lu\n", cmd_head,
+		pr_debug("no cmd space: %u %u %u %zu %zu\n", cmd_head,
 		       udev->cmdr_last_cleaned, udev->cmdr_size, cmd_needed, space);
 		return false;
 	}
patch-zu-format-v1.patch (1,183 bytes)
kabe

kabe

2018-04-20 14:13

reporter  

upstream-32bit-fixes-7_5.patch (5,052 bytes)
Replace this with previous upstream-32bit-fixes-7_4.patch .

diff -up ./drivers/scsi/qla2xxx/qla_init.c.int ./drivers/scsi/qla2xxx/qla_init.c
--- ./drivers/scsi/qla2xxx/qla_init.c.int	2018-03-22 06:40:12.000000000 +0900
+++ ./drivers/scsi/qla2xxx/qla_init.c	2018-04-15 22:53:13.000000000 +0900
@@ -6835,8 +6835,8 @@ qla24xx_load_risc_blob(scsi_qla_host_t *
 	ha->fw_dump_template_len = 0;
 
 	ql_dbg(ql_dbg_init, vha, 0x171,
-	    "Loading fwdump template from %lx\n",
-	    (void *)fwcode - (void *)blob->fw->data);
+	    "Loading fwdump template from %x\n",
+	    (uint32_t)((void *)fwcode - (void *)blob->fw->data));
 	risc_size = be32_to_cpu(fwcode[2]);
 	ql_dbg(ql_dbg_init, vha, 0x172,
 	    "-> array size %x dwords\n", risc_size);
--
1.8.3.1

From b9469523631bd376a5f877d4e816f3a81c12b790 Mon Sep 17 00:00:00 2001
From: Paul Bolle <pebolle@tiscali.nl>
Date: Mon, 30 Jun 2014 16:32:29 +0200
Subject: [PATCH] x86: Remove unused variable "polling"

Compile tested. "polling" is unused since commit f80c5b39b80a
("sched/idle, x86: Switch from TS_POLLING to TIF_POLLING_NRFLAG").

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Jiri Kosina <jkosina@suse.cz>
Link: http://lkml.kernel.org/r/1404138749.2978.6.camel@x41
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/apm_32.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 8fdcec6..66d3b1f 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -841,7 +841,6 @@ static int apm_do_idle(void)
 	u32 eax;
 	u8 ret = 0;
 	int idled = 0;
-	int polling;
 	int err = 0;
 
 	if (!need_resched()) {
-- 
1.8.3.1

From 75c2e0e53d2fb5df66b8fe162d71930348ac0b96 Mon Sep 17 00:00:00 2001
From: John Stultz <john.stultz@linaro.org>
Date: Wed, 16 Jul 2014 21:03:56 +0000
Subject: [PATCH] ktime: Change ktime_set() to take 64bit seconds value

In order to support dates past 2038 on 32bit systems, ktime_set()
needs to handle 64bit second values.

[ tglx: Removed the BITS_PER_LONG check ]

Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 include/linux/ktime.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index e4e9a9f..6950c96 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -71,13 +71,12 @@ typedef union ktime ktime_t;		/* Kill this */
  *
  * Return the ktime_t representation of the value
  */
-static inline ktime_t ktime_set(const long secs, const unsigned long nsecs)
+static inline ktime_t ktime_set(const s64 secs, const unsigned long nsecs)
 {
-#if (BITS_PER_LONG == 64)
 	if (unlikely(secs >= KTIME_SEC_MAX))
 		return (ktime_t){ .tv64 = KTIME_MAX };
-#endif
-	return (ktime_t) { .tv64 = (s64)secs * NSEC_PER_SEC + (s64)nsecs };
+
+	return (ktime_t) { .tv64 = secs * NSEC_PER_SEC + (s64)nsecs };
 }
 
 /* Subtract two ktime_t variables. rem = lhs -rhs: */
-- 
1.8.3.1

From 80a667f7ab1beee42b31e263ba4681fdfe00a0b6 Mon Sep 17 00:00:00 2001
From: Florian Westphal <fw@strlen.de>
Date: Wed, 17 Jun 2015 23:58:28 +0200
Subject: [PATCH] netfilter: xtables: fix warnings on 32bit platforms

On 32bit archs gcc complains due to cast from void* to u64.
Add intermediate casts to long to silence these warnings.

include/linux/netfilter/x_tables.h:376:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
include/linux/netfilter/x_tables.h:384:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
include/linux/netfilter/x_tables.h:391:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
include/linux/netfilter/x_tables.h:400:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

Fixes: 71ae0dff02d756e ("netfilter: xtables: use percpu rule counters")
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 include/linux/netfilter/x_tables.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff -up ./include/linux/netfilter/x_tables.h.int ./include/linux/netfilter/x_tables.h
--- ./include/linux/netfilter/x_tables.h.int	2018-03-22 06:40:12.000000000 +0900
+++ ./include/linux/netfilter/x_tables.h	2018-04-15 23:09:40.000000000 +0900
@@ -381,7 +381,7 @@ static inline struct xt_counters *
 xt_get_this_cpu_counter(struct xt_counters *cnt)
 {
 	if (nr_cpu_ids > 1)
-		return this_cpu_ptr((void __percpu *) cnt->pcnt);
+		return this_cpu_ptr((void __percpu *) (unsigned long) cnt->pcnt);
 
 	return cnt;
 }
@@ -390,7 +390,7 @@ static inline struct xt_counters *
 xt_get_per_cpu_counter(struct xt_counters *cnt, unsigned int cpu)
 {
 	if (nr_cpu_ids > 1)
-		return per_cpu_ptr((void __percpu *) cnt->pcnt, cpu);
+		return per_cpu_ptr((void __percpu *) (unsigned long) cnt->pcnt, cpu);
 
 	return cnt;
 }
kabe

kabe

2018-04-20 14:18

reporter   ~0031648

I had to disable CONFIG_NFP and CONFIG_SCSI_SMARTPQI drivers
since these drivers use readq() (atomic read quadword from I/O memory) unconditionally,
which isn't available on 32bit.
http://lkml.iu.edu/hypermail/linux/kernel/0904.3/01969.html

kernel-3.10.0-i686.config.gz (36,235 bytes)
kabe

kabe

2018-04-20 14:23

reporter   ~0031649

kernel.spec I am using, just in case.

kernel.spec.gz (1,485,368 bytes)
kabe

kabe

2018-04-20 14:31

reporter   ~0031650

That's all. Thank you for your attention.
Thank you @toracat for providing the kernel-plus source;
I felt wandering in the dark with my local copy of the source which was
just the "git rebase" of the previous kernel-3.10.0-693.21.1 .
toracat

toracat

2018-04-20 15:38

manager   ~0031651

@kabe

I thank *you* for all the invaluable help. I am building from the files you have submitted.
kabe

kabe

2018-04-20 16:47

reporter   ~0031652

i386-retpoline-support.patch was old.
Please replace that with this i386-retpoline-support-v6.patch .
Needed for proper retpoline support.

i386-retpoline-support-v6.patch (4,154 bytes)
diff -up ./arch/x86/include/asm/mshyperv.h.retp ./arch/x86/include/asm/mshyperv.h
--- ./arch/x86/include/asm/mshyperv.h.retp	2018-03-22 06:40:12.000000000 +0900
+++ ./arch/x86/include/asm/mshyperv.h	2018-04-21 01:29:24.000000000 +0900
@@ -200,13 +200,13 @@ static inline u64 hv_do_hypercall(u64 co
 	if (!hv_hypercall_pg)
 		return U64_MAX;
 
-	__asm__ __volatile__(CALL_NOSPEC
+	__asm__ __volatile__(CALL_NOSPEC_FULL
 			     : "=A" (hv_status),
 			       "+c" (input_address_lo), "+r" (__sp)
 			     : "A" (control),
 			       "b" (input_address_hi),
 			       "D"(output_address_hi), "S"(output_address_lo),
-			       THUNK_TARGET(hv_hypercall_pg)
+			       THUNK_TARGET_FULL(hv_hypercall_pg)
 			     : "cc", "memory");
 #endif /* !x86_64 */
 	return hv_status;
diff -up ./arch/x86/include/asm/nospec-branch.h.retp ./arch/x86/include/asm/nospec-branch.h
--- ./arch/x86/include/asm/nospec-branch.h.retp	2018-03-22 06:40:12.000000000 +0900
+++ ./arch/x86/include/asm/nospec-branch.h	2018-04-21 01:27:33.000000000 +0900
@@ -160,6 +160,67 @@
 	"call __x86_indirect_thunk_%V[thunk_target]\n"
 #define THUNK_TARGET(addr) [thunk_target] "r" (addr)
 
+#elif defined(CONFIG_X86_32) && defined(CONFIG_RETPOLINE)
+/*
+ * Redefinition of STATIC_JUMP in arch/x86/include/asm/jump_label.h
+ * as inline asm code.
+ */
+# define STATIC_JUMP(target, key) \
+	"911: .byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t"	\
+	".pushsection __jump_table, \"aw\" \n\t"		\
+	_ASM_ALIGN "\n\t"					\
+	_ASM_PTR "911b, " target ", " #key "\n\t" /*jump_entry*/\
+	".popsection\n"
+/*
+ * For i386 we use the original ret-equivalent retpoline, because
+ * otherwise we'll run out of registers. We don't care about CET
+ * here, anyway.
+ */
+# define CALL_NOSPEC STATIC_JUMP("912f", retp_enabled_key)	\
+	"	call *%[thunk_target]\n"			\
+	"	jmp    913f\n"					\
+	"912:	\n"						\
+	"       jmp    904f;\n"					\
+	"       .align 16\n"					\
+	"901:	call   903f;\n"					\
+	"902:	pause;\n"					\
+	"    	lfence;\n"					\
+	"       jmp    902b;\n"					\
+	"       .align 16\n"					\
+	"903:	addl   $4, %%esp;\n"				\
+	"       pushl  %[thunk_target];\n"			\
+	"       ret;\n"						\
+	"       .align 16\n"					\
+	"904:	call   901b;\n"					\
+	"913:	\n"					
+
+# define THUNK_TARGET(addr) [thunk_target] "rm" (addr)
+/*
+ * CALL_NOSPEC doesn't work if [thunk_target] was *(%esp),
+ * when all registers except %ebp is used up, as in
+ * drivers/hv/hv.c:hv_do_hypercall().
+ */
+# define CALL_NOSPEC_FULL STATIC_JUMP("912f", retp_enabled_key)	\
+	"	call *%[thunk_target]\n"			\
+	"	jmp    913f\n"					\
+	"912:	\n"						\
+	"	pushl  %[thunk_target];\n"			\
+	"       jmp    904f;\n"					\
+	"       .align 16\n"					\
+	"901:	call   903f;\n"					\
+	"902:	pause;\n"					\
+	"    	lfence;\n"					\
+	"       jmp    902b;\n"					\
+	"       .align 16\n"					\
+	"903:	addl   $4, %%esp;\n"				\
+	"       pushl  4(%%esp);\n"				\
+	"       ret;\n"						\
+	"       .align 16\n"					\
+	"904:	call   901b;\n"					\
+	"	addl   $4, %%esp;\n"				\
+	"913:	\n"					
+
+# define THUNK_TARGET_FULL(addr) [thunk_target] "rm" (addr)
 #else /* No retpoline for C / inline asm */
 # define CALL_NOSPEC "call *%[thunk_target]\n"
 # define THUNK_TARGET(addr) [thunk_target] "rm" (addr)
diff -up ./arch/x86/kernel/i386_ksyms_32.c.retp ./arch/x86/kernel/i386_ksyms_32.c
--- ./arch/x86/kernel/i386_ksyms_32.c.retp	2018-03-22 06:40:12.000000000 +0900
+++ ./arch/x86/kernel/i386_ksyms_32.c	2018-04-21 01:26:08.000000000 +0900
@@ -4,6 +4,7 @@
 #include <asm/pgtable.h>
 #include <asm/desc.h>
 #include <asm/ftrace.h>
+#include <asm/asm.h>
 
 #ifdef CONFIG_FUNCTION_TRACER
 /* mcount is defined in assembly */
@@ -37,3 +38,17 @@ EXPORT_SYMBOL(strstr);
 
 EXPORT_SYMBOL(csum_partial);
 EXPORT_SYMBOL(empty_zero_page);
+
+#ifdef CONFIG_RETPOLINE
+#define EXPORT_THUNK(reg)						\
+	extern void __x86_indirect_thunk_ ## reg(void);			\
+	EXPORT_SYMBOL(__x86_indirect_thunk_ ## reg)
+
+EXPORT_THUNK(eax);
+EXPORT_THUNK(ebx);
+EXPORT_THUNK(ecx);
+EXPORT_THUNK(edx);
+EXPORT_THUNK(esi);
+EXPORT_THUNK(edi);
+EXPORT_THUNK(ebp);
+#endif /* CONFIG_RETPOLINE */
diff -up ./drivers/hv/hv.c.retp ./drivers/hv/hv.c
toracat

toracat

2018-04-20 16:55

manager   ~0031653

Will do. Thanks.
toracat

toracat

2018-04-20 21:10

manager   ~0031655

With all the patches in and CONFIG_NFP and CONFIG_SCSI_SMARTPQI disabled, I get the following error:

drivers/pinctrl/pinctrl-amd.c: In function 'amd_gpio_should_save':
drivers/pinctrl/pinctrl-amd.c:744:8: error: 'const struct pin_desc' has no member named 'mux_owner'
  if (pd->mux_owner || pd->gpio_owner ||
        ^
drivers/pinctrl/pinctrl-amd.c:744:25: error: 'const struct pin_desc' has no member named 'gpio_owner'
  if (pd->mux_owner || pd->gpio_owner ||
toracat

toracat

2018-04-20 21:36

manager   ~0031656

Last edited: 2018-04-21 00:27

View 2 revisions

Enable this: CONFIG_PINMUX=y

And the build was successful.

toracat

toracat

2018-04-21 06:47

manager   ~0031657

Here's a test set of packages ( kernel-3.10.0-862.el7.centos.plus.i686 ):

https://people.centos.org/toracat/kernel/7/plus/i386/

linux-firmware (required) is also provided.
kabe

kabe

2018-04-22 07:37

reporter   ~0031660

SOURCES/x509.genkey says "CN=Red Hat Enterprise Linux kernel signing key" .
(also for the preliminary kernel-plus src.rpm)
Is this intentional or just debranding failure?
toracat

toracat

2018-04-22 13:28

manager   ~0031661

Last edited: 2018-04-22 13:44

View 2 revisions

Thanks for catching this. I will correct it.

[EDIT] Both kernel.i686 and kernel-plus.x86_64 have been corrected.

toracat

toracat

2018-05-11 16:54

manager   ~0031764

CentOS 7.5.1804 is out.

kernel-3.10.0-862.el7.centos.plus.i686 and kernel-3.10.0-862.2.3.el7.centos.plus.i686 have been released.

Issue History

Date Modified Username Field Change
2018-04-20 00:41 toracat New Issue
2018-04-20 00:50 toracat OS Version => 7
2018-04-20 00:50 toracat Product Version => 7.5.1804
2018-04-20 00:50 toracat Target Version => 7.5.1804
2018-04-20 00:54 toracat Status new => assigned
2018-04-20 13:38 kabe Note Added: 0031645
2018-04-20 13:39 kabe File Added: i386-retpoline-support.patch
2018-04-20 13:42 kabe File Added: patch-ALIGN-dupdef.patch
2018-04-20 13:42 kabe File Added: patch-MAX_LFS_FILESIZE-0cc3b0ec23.patch
2018-04-20 13:43 kabe File Added: patch-copy_from_user-warning-v1.patch
2018-04-20 13:43 kabe File Added: patch-flush_tlb-undef.patch
2018-04-20 13:52 kabe File Added: patch-get_stack_info-198d208df4.patch
2018-04-20 13:52 kabe File Added: patch-i686-fpu-issues.patch
2018-04-20 13:53 kabe File Added: patch-no-unwind_unsafe_stack.patch
2018-04-20 13:54 kabe File Added: patch-nospec-32-v1.patch
2018-04-20 13:54 kabe File Added: patch-pcc-long-cast.patch
2018-04-20 14:03 kabe File Added: patch-pps-timespec64-ade1bdffe9.patch
2018-04-20 14:03 kabe File Added: patch-pud_devmap-multidef.patch
2018-04-20 14:04 toracat Note Added: 0031646
2018-04-20 14:04 kabe File Added: patch-spec_ctrl_i686.patch
2018-04-20 14:05 kabe File Added: patch-typo-7.5.patch
2018-04-20 14:06 kabe File Added: patch-vmx-cmpxchg64-c0a1666bcb.patch
2018-04-20 14:12 kabe File Added: patch-zu-format-v1.patch
2018-04-20 14:13 kabe File Added: upstream-32bit-fixes-7_5.patch
2018-04-20 14:18 kabe File Added: kernel-3.10.0-i686.config.gz
2018-04-20 14:18 kabe Note Added: 0031648
2018-04-20 14:23 kabe File Added: kernel.spec.gz
2018-04-20 14:23 kabe Note Added: 0031649
2018-04-20 14:31 kabe Note Added: 0031650
2018-04-20 15:38 toracat Note Added: 0031651
2018-04-20 16:47 kabe File Added: i386-retpoline-support-v6.patch
2018-04-20 16:47 kabe Note Added: 0031652
2018-04-20 16:55 toracat Note Added: 0031653
2018-04-20 21:10 toracat Note Added: 0031655
2018-04-20 21:36 toracat Note Added: 0031656
2018-04-21 00:27 toracat Note Edited: 0031656 View Revisions
2018-04-21 06:47 toracat Note Added: 0031657
2018-04-22 07:37 kabe Note Added: 0031660
2018-04-22 13:28 toracat Note Added: 0031661
2018-04-22 13:44 toracat Note Edited: 0031661 View Revisions
2018-05-11 16:54 toracat Note Added: 0031764
2018-05-11 16:56 toracat Status assigned => resolved
2018-05-11 16:56 toracat Resolution open => fixed