Received: by 10.213.65.68 with SMTP id h4csp2118477imn; Sun, 8 Apr 2018 20:09:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+c7kAtS7MfWrqVDU00GeQcf+HsM2LLJHjFM9DGBFbpbMDBqxcOUE7WrPHvJCHj7jmf6DV5 X-Received: by 10.99.55.68 with SMTP id g4mr23294591pgn.283.1523243389655; Sun, 08 Apr 2018 20:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243389; cv=none; d=google.com; s=arc-20160816; b=ylkvLY8SsZhnweh8S2HfuwWB8m7YIA7XjxC+aMU/QysXIblMsEtkMmC5nz2uvnlKBV jHK5qvjNW3EOBxSFA9nIQ7bFMDrQ9TvvSuRnBcNN44aSghk3qQz0EQKUwnckET+ArmDq 9mr9aq+80xhq0QxHTfv2GM031/AcR66uXbBO0NtUp7gmAmgclPqJNKWWVXY3JXzpl2nO Yr+wyPpgSJeBogCDNHwT55u+5DxDaQ43g0V/kAGYISwkk2BiHyOWHZLUhS2SpXe+HtJP XqecFZ9btkPfF/XgT+vETaLVbrWrzxtnwq2k7Hya4gc1EF+R/e+TZxKhguhUNyrBpu57 juQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=tZ/WVNCSU/ybSfzEyTrpXTM61s0I5ULjxa43+zZ8YFs=; b=kSw4FIbhh7byd5xUAwLFqLuxQIHLfsSw9Fqu0e6BgNgM7XIiFOu/1Nu594NSgweA6n YP3ROM1f10fW6qbZlhtp1kpYt2QeWp4MxKja2hN0oQHUFtxj9y5XF2pCl2znOqLR8rbr EjhtIeSpkpzvK0V4fcMZtTv9oOMilRuQ/c4aDnDqoVDbYK4ZUww3Q50ghXGtxxyee9Fs EtSSRkXOzkmGyw+r4hqDwiZJzcFT/eYZRkRkBtd8dZTB1oSVFmlBm6zxdFYu92Bibw9S cFW+cFS1hzFo4Sk/ra+yeHwZ/Kj4p9wTYYjmYQuJEuTY4XUrZDvdIIhqiU3bO3+kFEvS 8+7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=YedtXQAh; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2-v6si13717079plk.702.2018.04.08.20.09.12; Sun, 08 Apr 2018 20:09:49 -0700 (PDT) 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=@microsoft.com header.s=selector1 header.b=YedtXQAh; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757348AbeDIBWZ (ORCPT + 99 others); Sun, 8 Apr 2018 21:22:25 -0400 Received: from mail-sn1nam02on0113.outbound.protection.outlook.com ([104.47.36.113]:53303 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932732AbeDIAhG (ORCPT ); Sun, 8 Apr 2018 20:37:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=tZ/WVNCSU/ybSfzEyTrpXTM61s0I5ULjxa43+zZ8YFs=; b=YedtXQAh/IlWj1BOlNfTiTAz/OQ79etAftCG6wjjFKjSLGHPqp8gM0+Lmsk5Z6uNV3mmkVpIYUeplG0MxDOOLVA+2H77QOXOLjfK+XB7OtLoiVdDHSaPgaG2b+9u3Cmm2ZoCAJ0PBJyE2MsEALZJtFssHuk7x2wOsnE4swnfW50= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0885.namprd21.prod.outlook.com (52.132.132.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:37:01 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:37:01 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Hari Bathini , Michael Ellerman , Sasha Levin Subject: [PATCH AUTOSEL for 4.4 079/162] powerpc/fadump: avoid duplicates in crash memory ranges Thread-Topic: [PATCH AUTOSEL for 4.4 079/162] powerpc/fadump: avoid duplicates in crash memory ranges Thread-Index: AQHTz5m1tNPvS5jWMk6WiQizUfZDng== Date: Mon, 9 Apr 2018 00:28:41 +0000 Message-ID: <20180409002738.163941-79-alexander.levin@microsoft.com> References: <20180409002738.163941-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002738.163941-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0885;7:8fl6BK5SfLDHSxFnytgcN9lYbj/yCRfxxxAS2yOQRxLCV2v72D3/PxQcyaJBjTHT+4AHjk7jlZA2INFDdTKvGMsSBlpC5QwGAUKsiWAX25du9o2Z2wwVHL1vrB7HlORshC110ak+Hz2/yQIqPmBtXq4abq4IFLBYutu3fbE4UqCr2DwsfDzVfhYG++vQJyOZLeI2ij2WcPkQPTugnwD1L6CKiDmTsIGsEsfCn2Fu1obfGqNz+qdSn4/EC9pNuD7z;20:zcTLg9/wkO0aUnc/SbxmudZZEetvvM1idBa3eRefnLXbJP7KiKJoybH7CM3xiPGgsyxNrOuCRvfcjpF/2ZCZXZYdiEuWSNfy8jS8MUa5CwE2RikbX4RJnyp80LCcCcxMShUL19UKCeb8zn1GV6oIakBFkNy30y6Lz0leXhwc0ds= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 4c5512c2-083e-4bf8-500f-08d59db2023e x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0885; x-ms-traffictypediagnostic: DM5PR2101MB0885: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(104084551191319); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0885;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0885; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(396003)(376002)(39860400002)(366004)(346002)(199004)(189003)(66066001)(3846002)(6116002)(86362001)(305945005)(10290500003)(6436002)(5250100002)(3280700002)(10090500001)(3660700001)(6506007)(2501003)(107886003)(446003)(53936002)(11346002)(2616005)(26005)(76176011)(7736002)(478600001)(476003)(81156014)(25786009)(8676002)(81166006)(186003)(8936002)(4326008)(97736004)(102836004)(99286004)(14454004)(36756003)(6512007)(316002)(2906002)(22452003)(68736007)(54906003)(110136005)(486006)(6486002)(6666003)(5660300001)(2900100001)(1076002)(72206003)(86612001)(105586002)(106356001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0885;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: +PhLCYhGoYrwhH7ReSUfuZRPNGnbEpzIrjY472CN/wC+LbpyP5I9KBaKKMbRf8CIaFBrmf1Ex1sqEb+qSbEBZGvF7yOl9ktt3zQUmCIaS1d9J/rtnDoMBXBQWpXd03amUX1E4hmPl00jXZnzh14fLDLVVeV4cZ0jV2jvKF1nlLKLL70FuFRmsCGAiZ1/xP0baMZmcGfGL6qP7Ojp+Z8j2gLPPLXo0O6b1LT8MQWjErw1+pCQhQTH7Qmk5FLOHMyKVnTho36seM7hL941QYqPcRLR0Bz59+I/NSS+e8wh3Rs/TnmCCQ4tk1pqTamIEJdDVyq1jebd9r6x9S7Rlwvm73r3v/DOM+ORDhmLoCi/KcBq1Y0DPEaCXZ1OsBZxZIOWtWwD0Q2UsN1TmttXPchCje3XfT+i3mAXAVBfh7sK0zM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c5512c2-083e-4bf8-500f-08d59db2023e X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:28:41.3021 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0885 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hari Bathini [ Upstream commit a77af552ccc9d4d54459a39f9e5f7ad307aeb4f9 ] fadump sets up crash memory ranges to be used for creating PT_LOAD program headers in elfcore header. Memory chunk RMA_START through boot memory area size is added as the first memory range because firmware, at the time of crash, moves this memory chunk to different location specified during fadump registration making it necessary to create a separate program header for it with the correct offset. This memory chunk is skipped while setting up the remaining memory ranges. But currently, there is possibility that some of this memory may have duplicate entries like when it is hot-removed and added again. Ensure that no two memory ranges represent the same memory. When 5 lmbs are hot-removed and then hot-plugged before registering fadump, here is how the program headers in /proc/vmcore exported by fadump look like without this change: Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align NOTE 0x0000000000010000 0x0000000000000000 0x0000000000000000 0x0000000000001894 0x0000000000001894 0 LOAD 0x0000000000021020 0xc000000000000000 0x0000000000000000 0x0000000040000000 0x0000000040000000 RWE 0 LOAD 0x0000000040031020 0xc000000000000000 0x0000000000000000 0x0000000010000000 0x0000000010000000 RWE 0 LOAD 0x0000000050040000 0xc000000010000000 0x0000000010000000 0x0000000050000000 0x0000000050000000 RWE 0 LOAD 0x00000000a0040000 0xc000000060000000 0x0000000060000000 0x000000019ffe0000 0x000000019ffe0000 RWE 0 and with this change: Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align NOTE 0x0000000000010000 0x0000000000000000 0x0000000000000000 0x0000000000001894 0x0000000000001894 0 LOAD 0x0000000000021020 0xc000000000000000 0x0000000000000000 0x0000000040000000 0x0000000040000000 RWE 0 LOAD 0x0000000040030000 0xc000000040000000 0x0000000040000000 0x0000000020000000 0x0000000020000000 RWE 0 LOAD 0x0000000060030000 0xc000000060000000 0x0000000060000000 0x000000019ffe0000 0x000000019ffe0000 RWE 0 Signed-off-by: Hari Bathini Reviewed-by: Mahesh J Salgaonkar Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/kernel/fadump.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index 26d091a1a54c..5df362630ffc 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -812,8 +812,19 @@ static void fadump_setup_crash_memory_ranges(void) for_each_memblock(memory, reg) { start =3D (unsigned long long)reg->base; end =3D start + (unsigned long long)reg->size; - if (start =3D=3D RMA_START && end >=3D fw_dump.boot_memory_size) - start =3D fw_dump.boot_memory_size; + + /* + * skip the first memory chunk that is already added (RMA_START + * through boot_memory_size). This logic needs a relook if and + * when RMA_START changes to a non-zero value. + */ + BUILD_BUG_ON(RMA_START !=3D 0); + if (start < fw_dump.boot_memory_size) { + if (end > fw_dump.boot_memory_size) + start =3D fw_dump.boot_memory_size; + else + continue; + } =20 /* add this range excluding the reserved dump area. */ fadump_exclude_reserved_area(start, end); --=20 2.15.1