Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2752192imj; Mon, 11 Feb 2019 07:59:00 -0800 (PST) X-Google-Smtp-Source: AHgI3IYxOqO10EbrSaISc7kYWo86zSNeZOzI8b2hJtsI4oo8OxDZO8KaQhzAfzzr7P8+v//e+EKj X-Received: by 2002:a63:8743:: with SMTP id i64mr8577283pge.69.1549900739913; Mon, 11 Feb 2019 07:58:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549900739; cv=none; d=google.com; s=arc-20160816; b=lONT8F43R3K92jc1fAkUCv5WWgeK0GNz8aC7ANEctNi/qT7UioxkbZtD9dF6B6mbg+ 2AULz1vVFuSH7XQyG8ESzVhkIevblJC9eLog0MB0TPOfpqKYympCkaBRmFcJ3SwrkGLT p9Iuq7rDw1x0OrQ5XNC64Jz1nsF4lPL6Q+71bk7wovsINeZN4HidHNGEb6VSpU9s78ZW oe6oPM6TFnnZowf0btBJn3rDIa3kloPUKMuDVrPTT2Cms7VJxGp65e11prxxSbtGtGC9 0y+mQbYIWmKP9tuoqWg5FeZXmYmL1bfZOVYU/WBbvgxZS4lNrGn/3PwnGvORHnwiXiHj j4Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+zTwOYcKS9GhEyJWaHXHAtKifzPQn3nZla97H1BOAAM=; b=IImkd8ouGXw22sPS4R8Eaj6tF+anmFA21OoJaSNkPD+h3mXK6uOA7siAjyxmHyLuSZ mnBRYbCaXF75MQMhDKs51q4YUl1K36DI8QRz4xGg2NXDMW3w3waIi2CcY/JNP3lE0joB 9lycVYiQK3IWHpUZtsS1yZxJDBhPPEtJaMNnbT69RocbsacrXRhXPGPltp55ltoMPwOv GRCW+SRcode9oMWd2c3c9sD9s2sNICJkqfRfVMQYeAqhrB1936Zof7Ny6m470roHHcrf y6F/YC+ks9hrLTdHb1dNubNEMpmAsZ+eJ5cQzCtO+of07nq62ub/u7erm3SKE51MlMMd a8YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ychBdCNU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si9702659pgq.535.2019.02.11.07.58.43; Mon, 11 Feb 2019 07:58:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ychBdCNU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730795AbfBKOeN (ORCPT + 99 others); Mon, 11 Feb 2019 09:34:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:42342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728257AbfBKOeL (ORCPT ); Mon, 11 Feb 2019 09:34:11 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A29452081B; Mon, 11 Feb 2019 14:34:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895650; bh=hepuA9x5vf8MzH0/lhlK4Bb10SReS8VXED0zX66dIXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ychBdCNUGc5PwHVp3xTUdQW7CSU6eyCjTKvkvMtc7Bb074exRWtp3NKw1uleCdHeE 6b8fcYsBjMo0MueKSjGwKkpcakCBFwBoDgHg2GOxbuPRaoL7zdfn+u7MiT8IGXPX1k CelMQ244YyA7tgxr4eeEf7WjutfUS6J7AjH9Tbqo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mahesh Salgaonkar , Michael Ellerman , Sasha Levin Subject: [PATCH 4.20 246/352] powerpc/fadump: Do not allow hot-remove memory from fadump reserved area. Date: Mon, 11 Feb 2019 15:17:53 +0100 Message-Id: <20190211141902.785114907@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 0db6896ff6332ba694f1e61b93ae3b2640317633 ] For fadump to work successfully there should not be any holes in reserved memory ranges where kernel has asked firmware to move the content of old kernel memory in event of crash. Now that fadump uses CMA for reserved area, this memory area is now not protected from hot-remove operations unless it is cma allocated. Hence, fadump service can fail to re-register after the hot-remove operation, if hot-removed memory belongs to fadump reserved region. To avoid this make sure that memory from fadump reserved area is not hot-removable if fadump is registered. However, if user still wants to remove that memory, he can do so by manually stopping fadump service before hot-remove operation. Signed-off-by: Mahesh Salgaonkar Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/include/asm/fadump.h | 2 +- arch/powerpc/kernel/fadump.c | 10 ++++++++-- arch/powerpc/platforms/pseries/hotplug-memory.c | 7 +++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/fadump.h b/arch/powerpc/include/asm/fadump.h index 1e7a33592e29..15bc07a31c46 100644 --- a/arch/powerpc/include/asm/fadump.h +++ b/arch/powerpc/include/asm/fadump.h @@ -200,7 +200,7 @@ struct fad_crash_memory_ranges { unsigned long long size; }; -extern int is_fadump_boot_memory_area(u64 addr, ulong size); +extern int is_fadump_memory_area(u64 addr, ulong size); extern int early_init_dt_scan_fw_dump(unsigned long node, const char *uname, int depth, void *data); extern int fadump_reserve_mem(void); diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index 761b28b1427d..7fd9b3e1fa39 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -118,13 +118,19 @@ int __init early_init_dt_scan_fw_dump(unsigned long node, /* * If fadump is registered, check if the memory provided - * falls within boot memory area. + * falls within boot memory area and reserved memory area. */ -int is_fadump_boot_memory_area(u64 addr, ulong size) +int is_fadump_memory_area(u64 addr, ulong size) { + u64 d_start = fw_dump.reserve_dump_area_start; + u64 d_end = d_start + fw_dump.reserve_dump_area_size; + if (!fw_dump.dump_registered) return 0; + if (((addr + size) > d_start) && (addr <= d_end)) + return 1; + return (addr + size) > RMA_START && addr <= fw_dump.boot_memory_size; } diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index 2a983b5a52e1..2318ab29d5dd 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -355,8 +355,11 @@ static bool lmb_is_removable(struct drmem_lmb *lmb) phys_addr = lmb->base_addr; #ifdef CONFIG_FA_DUMP - /* Don't hot-remove memory that falls in fadump boot memory area */ - if (is_fadump_boot_memory_area(phys_addr, block_sz)) + /* + * Don't hot-remove memory that falls in fadump boot memory area + * and memory that is reserved for capturing old kernel memory. + */ + if (is_fadump_memory_area(phys_addr, block_sz)) return false; #endif -- 2.19.1