linux-next: manual merge of the arm tree with Linus' tree

From: Stephen Rothwell
Date: Tue Mar 08 2022 - 17:35:32 EST


Hi all,

Today's linux-next merge of the arm tree got a conflict in:

arch/arm/kernel/traps.c

between commit:

04e91b732476 ("ARM: early traps initialisation")

from Linus' tree and commits:

a1c510d0adc6 ("ARM: implement support for vmap'ed stacks")
d31e23aff011 ("ARM: mm: make vmalloc_seq handling SMP safe")

from the arm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

--
Cheers,
Stephen Rothwell

diff --cc arch/arm/kernel/traps.c
index 5d58aee24087,2dec6944e5dd..000000000000
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@@ -878,5 -840,72 +893,72 @@@ void __init early_trap_init(void *vecto
* memory area. The address is configurable and so a table in the kernel
* image can be used.
*/
-#endif
}
+#endif
+
+ #ifdef CONFIG_VMAP_STACK
+
+ DECLARE_PER_CPU(u8 *, irq_stack_ptr);
+
+ asmlinkage DEFINE_PER_CPU(u8 *, overflow_stack_ptr);
+
+ static int __init allocate_overflow_stacks(void)
+ {
+ u8 *stack;
+ int cpu;
+
+ for_each_possible_cpu(cpu) {
+ stack = (u8 *)__get_free_page(GFP_KERNEL);
+ if (WARN_ON(!stack))
+ return -ENOMEM;
+ per_cpu(overflow_stack_ptr, cpu) = &stack[OVERFLOW_STACK_SIZE];
+ }
+ return 0;
+ }
+ early_initcall(allocate_overflow_stacks);
+
+ asmlinkage void handle_bad_stack(struct pt_regs *regs)
+ {
+ unsigned long tsk_stk = (unsigned long)current->stack;
+ #ifdef CONFIG_IRQSTACKS
+ unsigned long irq_stk = (unsigned long)this_cpu_read(irq_stack_ptr);
+ #endif
+ unsigned long ovf_stk = (unsigned long)this_cpu_read(overflow_stack_ptr);
+
+ console_verbose();
+ pr_emerg("Insufficient stack space to handle exception!");
+
+ pr_emerg("Task stack: [0x%08lx..0x%08lx]\n",
+ tsk_stk, tsk_stk + THREAD_SIZE);
+ #ifdef CONFIG_IRQSTACKS
+ pr_emerg("IRQ stack: [0x%08lx..0x%08lx]\n",
+ irq_stk - THREAD_SIZE, irq_stk);
+ #endif
+ pr_emerg("Overflow stack: [0x%08lx..0x%08lx]\n",
+ ovf_stk - OVERFLOW_STACK_SIZE, ovf_stk);
+
+ die("kernel stack overflow", regs, 0);
+ }
+
+ #ifndef CONFIG_ARM_LPAE
+ /*
+ * Normally, we rely on the logic in do_translation_fault() to update stale PMD
+ * entries covering the vmalloc space in a task's page tables when it first
+ * accesses the region in question. Unfortunately, this is not sufficient when
+ * the task stack resides in the vmalloc region, as do_translation_fault() is a
+ * C function that needs a stack to run.
+ *
+ * So we need to ensure that these PMD entries are up to date *before* the MM
+ * switch. As we already have some logic in the MM switch path that takes care
+ * of this, let's trigger it by bumping the counter every time the core vmalloc
+ * code modifies a PMD entry in the vmalloc region. Use release semantics on
+ * the store so that other CPUs observing the counter's new value are
+ * guaranteed to see the updated page table entries as well.
+ */
+ void arch_sync_kernel_mappings(unsigned long start, unsigned long end)
+ {
+ if (start < VMALLOC_END && end > VMALLOC_START)
+ atomic_inc_return_release(&init_mm.context.vmalloc_seq);
+ }
+ #endif
+ #endif

Attachment: pgp5hXdmeTpQE.pgp
Description: OpenPGP digital signature