Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3635851imu; Mon, 28 Jan 2019 08:12:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN5nmfs27hqOl/RS0ItJD/gV/hiddfzOQ5TtGhhsHE6Oe/Nh/wVtF6RcbQI+/n+K8yrMrU2E X-Received: by 2002:a62:4156:: with SMTP id o83mr22405806pfa.72.1548691933257; Mon, 28 Jan 2019 08:12:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691933; cv=none; d=google.com; s=arc-20160816; b=0xIUdDYT+CnVVbvhfZP4ZaYQb3trXFIiU8EPnkxGpGR/o6M8J7ZC06LWjy/rbu1853 I43nO4FhGj7nMOHOmmKTRWuaRPtlVwEv9XwA89vIfhoUbZGHDd2oB3qrvJ7TjbZuqsvD K9m7lQpss/Pmdgtp6wXMkb/dQN48hhJliyNq2trIulBGtMMYlpivm/L/7Hb/FtV4ekCP 7G3ZIiJy1B/VLNk+gryxvpx4GdBxHf3FSmJC6sJbwlV2C1uezEoLtvtJ+eNAbCW93urF 5lNRz6kv68VXWQjkcynqYTGNgXwsruTmRFJMpn1N/6NmIw0PbtBCuSQUJm66KoJxnwGb zmsQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8M/XxFC/wyBfpBGL1yB6ZTBioR1rRT+ZBmBRT066wPo=; b=yNiuwgRiquayQtQXsJv/tHEN7sAwIzRYll9citn1+4T2PI8Gnf7R50d0OA0Cw9lz62 oOaETARlH8CpNst3BAYwAWQw61vS6IgEMX7MevZ23Rg5wbdgv80F1xSZNut6hjBxwNJH 3EAnULwAFl2fygz41v/DKm0GaTdIvBKGI3JVHSKE+lTHjRo/QhqN10wt1FokrLmjzMNM 2Yo8FX8bBLxV5OETJfbV2qfgcK/MgPC/nb+olXOOOrP7QfKhGLKNMlm0fAcmXrPmZ5Oh f6+PS8dyT0x5ulYXm7GX8YggT9w/UK5uARIYnrW79El4TzvbMQu3IqWA9J1AzcZ98HXZ DdBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GkHY6SMF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si33793586pfg.78.2019.01.28.08.11.57; Mon, 28 Jan 2019 08:12:13 -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=GkHY6SMF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731958AbfA1QJu (ORCPT + 99 others); Mon, 28 Jan 2019 11:09:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:34950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731968AbfA1QJs (ORCPT ); Mon, 28 Jan 2019 11:09:48 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7E3C32084A; Mon, 28 Jan 2019 16:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691787; bh=Pdlj63uyEGLaIL2HS853MKgCVpl3Py1mA+id0kfh0E4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GkHY6SMFJdbA+hZAvKDXogYaHhf68+XEIZGtVbV6LfwfxTqE9ORE5N6u8iM1TuPew UPEkoCdnQrGEuLPsKKRQwXEoUHMWNf0KQfjOupQam4SQjSSf4AsQub/D57eYIUOrkw gQaejWcU8snMgWy7NKslckIWiXQLGWZbN6vjF7x8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mahesh Salgaonkar , Michael Ellerman , Sasha Levin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 4.19 216/258] powerpc/fadump: Do not allow hot-remove memory from fadump reserved area. Date: Mon, 28 Jan 2019 10:58:42 -0500 Message-Id: <20190128155924.51521-216-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mahesh Salgaonkar [ 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 a711d22339ea..c02c95287a5f 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 c1578f54c626..e4c658cda3a7 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -389,8 +389,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