Received: by 10.213.65.68 with SMTP id h4csp2119128imn; Sun, 8 Apr 2018 20:10:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/3+GPw6rl/QStpeK7cTsHfL0AuOE70IdwVZsbB1sE2aoa8RkxlN4OHckD6D2EuhXcBao6Y X-Received: by 2002:a17:902:be07:: with SMTP id r7-v6mr2824171pls.337.1523243439562; Sun, 08 Apr 2018 20:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243439; cv=none; d=google.com; s=arc-20160816; b=RtqVWErbNPHZpPFgzrnyL7TLeXxPpKRomN4cGTn7Zd1euSD52tZAcKOwI3cwPnjAzf QS0WhtrRZn/UT1r4kq2oBAsqe1D+5r+FrAG6vMD9WIAxhApJdWtQY8wMlgyoziL3LeB7 tHAU8YmF+FoZlU01t7+1U+k2ddOuI6mxUul5bRmrzfy8grGRcaR0O/RRAF86yF/21CYj B8J7UR6QS5wEvzjPOxIxVYTHWahsFQDLvPXzdzVHhoNBkeUIXSLwlNE8vZ7MDysQH5o+ tec6ZDxSyKpWHwyMYrFi7rZL92fYPQSEc2ZQiMpj8N/oMKMoeHCml2fGd6tAT0qtxrG/ npYQ== 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=fyKD7EH5sUR5qrQQFz3fuCai3Xe2/sWqxCm5wQ4cvXU=; b=mrk72UrGNmgyqz5EUvz0E5AHM3jFln8r+gXYETirLMeX/aCUoV8eX6F5CC+U7dkOjV I2gawzkmkoM7OtaPwek586bjWyXKRn0h68Q7w9qkZ3PR3eT1yRmLCu0SB5MgDqXt9e1m t7TmESf1T3044rZzox/iZSMUs4Ur7U5Kim0URrjb0H1ZFnjdLz/ymx4N6JI9GRXJ8j5r hCphw6TIclqDhrvf9vmGDWQ4QhejqVOyLQsS8rwojvsTxMolsWX89zshHo4vNpX4xKWZ tM5UPdcaQxVQCGf5cBSLhw0NbbYIM1piyJgLZIr0xQKU1CnPsEZFFQqptpQBOjxXcBVV 9X8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=PjgR8vAv; 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 z8-v6si4320246plk.734.2018.04.08.20.10.03; Sun, 08 Apr 2018 20:10:39 -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=PjgR8vAv; 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 S1757989AbeDICNd (ORCPT + 98 others); Sun, 8 Apr 2018 22:13:33 -0400 Received: from mail-by2nam03on0135.outbound.protection.outlook.com ([104.47.42.135]:16544 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756180AbeDIAbK (ORCPT ); Sun, 8 Apr 2018 20:31:10 -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=fyKD7EH5sUR5qrQQFz3fuCai3Xe2/sWqxCm5wQ4cvXU=; b=PjgR8vAv/nyr4npdB1rLYLo23AXwDZjyH0NRgS2yF/vmT6X3Iy01wBASYZPI8BENRNCNNwpFsXzqWmoJdT+i8OK+p7TeNH+5x2vRoKcCkCGoq4z1XkziSzBXcmmlVZx/sM6R5XZV30+zz9+EjdHQrEqGvNMRN7SExMHvPouRsvk= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0917.namprd21.prod.outlook.com (52.132.132.162) 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:31:09 +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:31:08 +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.9 156/293] powerpc/fadump: avoid duplicates in crash memory ranges Thread-Topic: [PATCH AUTOSEL for 4.9 156/293] powerpc/fadump: avoid duplicates in crash memory ranges Thread-Index: AQHTz5kv+Ek3qJPUWkyOFtfhKGG/1Q== Date: Mon, 9 Apr 2018 00:24:55 +0000 Message-ID: <20180409002239.163177-156-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-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;DM5PR2101MB0917;7:ih/H556CQY+o4CRu08xfCUCxm9xrhY2uzdr0Gto0L/UyGZmBy6BLmFXxUVMybgI0F8R9QwfY3T8X3E9alqb5jxd3LLTaFgxEEGta/oTmADxV3CLXubfLQCPRxIWO79l5uOAhAgHr5Pl/jLT+to8+fJ5m1Hv8KcI7wAI+sxEVdfQC0/zCJ3jIHayhjOlXQBfUotOTFc3LzIpSFjuQ92iG6AlQ0+sbhxx3/Avc3WSzMhr+Lj0X6usSZkyPyjwFZfJW;20:Pzmd9Kqfqyw+hY4qmNwhdWsz7uBSOC91bBibfKnLk4xX8R6bhnHQJJIBkxHg9SepeHGRJZRa1FqJuWFhv9vX3suDSx8r2vIJ60qF53RixFoxbG0Uw+qlw3P4f5e6Qt9B6hlHWwy7T0PgPbgXtVnkyvQs9pRoBfq8IOnuC9WLWBY= X-MS-Office365-Filtering-Correlation-Id: 26da0179-1e32-43b2-034b-08d59db13069 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7193020);SRVR:DM5PR2101MB0917; x-ms-traffictypediagnostic: DM5PR2101MB0917: 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:DM5PR2101MB0917;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0917; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(39860400002)(366004)(396003)(346002)(376002)(189003)(199004)(99286004)(22452003)(106356001)(26005)(110136005)(478600001)(54906003)(10290500003)(316002)(1076002)(72206003)(186003)(4326008)(97736004)(66066001)(11346002)(25786009)(86362001)(575784001)(476003)(446003)(2906002)(6666003)(6486002)(105586002)(86612001)(3280700002)(3660700001)(6512007)(3846002)(6116002)(6436002)(2616005)(486006)(53936002)(7736002)(8676002)(81166006)(81156014)(8936002)(68736007)(305945005)(10090500001)(76176011)(6506007)(102836004)(36756003)(107886003)(2900100001)(2501003)(14454004)(5660300001)(5250100002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0917;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: C9KE9PY+Bo0vhOW/rXxAv3LerrFuy/NC/YHZWuJWeqhSiwER6xSwizvfCGojMgzoImbPiLQ387pEnigizdfHmRdFmaFUlNZ9W6awe29i1rB0xdqk2H8K5EhyvI8A9m3OUBwCP7BBRDtAIhbvvHFU33PsTsWzGjWvDo0PGbZKR1xsQf3rLpoNdYy/UD+fx9RqfGTzQmia2Msfyxexyo9Ol0EZYpzsPchm33jauHZ1+KL+aR+dHlZVCQQp+/pcsfB0Aq1He2uVZo0K9DFuQQ25GpRawaYJMDbuFzAQ8kQPqUzYAfal6H1/vhY2+vu6iHkGsOmcTs0x9h/xMitxbGosa3KvCx1vwmzrpZcvMpBhxnOrVLtirq8ck7xPYYN4tXiQRdhipRcmTDAkw+4myGgL3d24V8G4lkRWCxWi5cT/+fM= 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: 26da0179-1e32-43b2-034b-08d59db13069 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:24:55.0188 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0917 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 8f0c7c5d93f2..4088eef74b65 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -821,8 +821,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