]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
powerpc/64s/powernv: Fix memory corruption when saving SLB entries on MCE
authorNicholas Piggin <npiggin@gmail.com>
Sat, 28 Nov 2020 07:07:21 +0000 (17:07 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Dec 2020 12:22:09 +0000 (13:22 +0100)
commit a1ee28117077c3bf24e5ab6324c835eaab629c45 upstream.

This can be hit by an HPT guest running on an HPT host and bring down
the host, so it's quite important to fix.

Fixes: 7290f3b3d3e6 ("powerpc/64s/powernv: machine check dump SLB contents")
Cc: stable@vger.kernel.org # v5.4+
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Acked-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20201128070728.825934-2-npiggin@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/platforms/powernv/setup.c

index 0b4f72e002c2e7140e2ff21060d6e73084676196..47eb218a4ae0b21ef6bc04dff473bf992c9033eb 100644 (file)
@@ -186,11 +186,16 @@ static void __init pnv_init(void)
                add_preferred_console("hvc", 0, NULL);
 
        if (!radix_enabled()) {
+               size_t size = sizeof(struct slb_entry) * mmu_slb_size;
                int i;
 
                /* Allocate per cpu area to save old slb contents during MCE */
-               for_each_possible_cpu(i)
-                       paca_ptrs[i]->mce_faulty_slbs = memblock_alloc_node(mmu_slb_size, __alignof__(*paca_ptrs[i]->mce_faulty_slbs), cpu_to_node(i));
+               for_each_possible_cpu(i) {
+                       paca_ptrs[i]->mce_faulty_slbs =
+                                       memblock_alloc_node(size,
+                                               __alignof__(struct slb_entry),
+                                               cpu_to_node(i));
+               }
        }
 }