From: Nicholas Piggin Date: Sat, 28 Nov 2020 07:07:21 +0000 Subject: [PATCH 1/8] powerpc/64s/powernv: Fix memory corruption when saving SLB entries on MCE Message-Id: <20201128070728.825934-2-npiggin@gmail.com> List-Id: References: <20201128070728.825934-1-npiggin@gmail.com> In-Reply-To: <20201128070728.825934-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linuxppc-dev@lists.ozlabs.org Cc: kvm-ppc@vger.kernel.org, Nicholas Piggin , Mahesh Salgaonkar 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: 7290f3b3d3e66 ("powerpc/64s/powernv: machine check dump SLB contents") Signed-off-by: Nicholas Piggin --- arch/powerpc/platforms/powernv/setup.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c index 46115231a3b2..4426a109ec2f 100644 --- a/arch/powerpc/platforms/powernv/setup.c +++ b/arch/powerpc/platforms/powernv/setup.c @@ -211,11 +211,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)); + } } } -- 2.23.0