Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2718439imj; Mon, 11 Feb 2019 07:27:30 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia9lirGhJWz81WZ+dBzTZI07QMeU8LlGaq5sAXrBaKmRijFI8FqIuBNQtYPY6UZk+d+ioWx X-Received: by 2002:a63:fc49:: with SMTP id r9mr33277379pgk.209.1549898849977; Mon, 11 Feb 2019 07:27:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549898849; cv=none; d=google.com; s=arc-20160816; b=PkpcpsQUxhiSLpia+vCdsccCpY7cipkHxwO41MwRNVtvpGFxbtEO/+5aVejTiWlYaf fgTthIu/9swo2bhgHQ4Rqxu+dVZgUr/SGMX4hWHwKoiA0b+vbKxynoln40Qk87Ge/OrT +mnG94kKGkPYdcy4YdPmrAsS97GEs1nYgCT2Su4nXJ39rklP+ktpUM0oW/fO0VLiZVBc /kMN5dgTulCLDy3zM35Wan3JkAnmybHtvdTh2ZFdBvP188Z4X3mVYPlPfYi8TdgRf1Oc kIhNojNWlQsvAqqHvFdKAH0a0rlMyDopaWRlYQtBWc8m3QTXvId/lDboALmsmoriN5z6 WGFw== 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=KipoPnN56WJfP5vJQ9YO3q9S0ysJs9B7XcI5EBoxvRg=; b=UpvoqDnJGW4RmQE9K1/MYFzKnTKY9BLmFazHMURnFPUJfM4egXu8pddHt+x6NpFsUM WNHIl8BuoNnuXY4/owQTKj9GBTZuxcHNz4mZA0lyMwufGEQL3d5RMLpqzzPoonELnOuB 8mqCaXt8TVSDtOl2f0X69N7YWdGd+MEDCBlspiuaAiH1et91cyEnWoKOi3y+AT2d3ok0 PGlxEA+JrG77DNWqlXlEyJjyMUezzbs9Xkb6m/MMjwK0azP4HYosxmYNj2Rsne017JWl uGXtXeIN/joBYScDENcOCNfnnnnF5nXDLtdh8CyFf4I8H6jBj5H6LbKbHA0H24uw5CrO P/Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q0Tz1WDX; 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 p66si10667476pfp.144.2019.02.11.07.27.12; Mon, 11 Feb 2019 07:27:29 -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=Q0Tz1WDX; 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 S2390021AbfBKPAa (ORCPT + 99 others); Mon, 11 Feb 2019 10:00:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:48398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389247AbfBKPA2 (ORCPT ); Mon, 11 Feb 2019 10:00:28 -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 31BC0206BA; Mon, 11 Feb 2019 15:00:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897227; bh=6b+ctTYqYz3tBK/TjgU5ZEhPDXa6QtnLJhpwPg/EwCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q0Tz1WDXDJ7vRpC3NB1xduhk1kGfsJn1rCmBVLHF9zgxMKRTQNzE+YT5LvIxsXgZj 1fhWpyLY9AGtBDA4++2Sr3Pzv/CD0uCXuIMx1ia5ftoNEED6+qmauuLxCI3WSpnPH2 ltRMY5L1MZcqmL1kDG0PPnjo0CsH2oqP8HUj8Ij4= 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.14 133/205] powerpc/fadump: Do not allow hot-remove memory from fadump reserved area. Date: Mon, 11 Feb 2019 15:18:51 +0100 Message-Id: <20190211141837.115830985@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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.14-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 5a6470383ca3..62d7ef6508de 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -117,13 +117,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 1d48ab424bd9..93e09f108ca1 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -441,8 +441,11 @@ static bool lmb_is_removable(struct of_drconf_cell *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