Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp740422rwd; Sat, 27 May 2023 05:54:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6d5Lq59j6yHcBxO8Ta/m7598Z6rq+Zt1uV8CjSS+C/kary6kHG+EHqm/JyrGT/Edxu9KBf X-Received: by 2002:a17:902:e890:b0:1a6:c595:d7c3 with SMTP id w16-20020a170902e89000b001a6c595d7c3mr6748767plg.22.1685192073103; Sat, 27 May 2023 05:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685192073; cv=none; d=google.com; s=arc-20160816; b=s0PAC7IJ3u31x4TtrXjZ5nQG6S7t28fr6tOrGjVf+tLy1BVPn9QztCxg+ZM2Mg1P9Y X+UH+EcDw+xzvHGbl4V/mAjgzR2rIRXnlwnGpsbj87YbrmKdYMHH53DmMQpa4KCVq0Ps rDrNfzOntsdMcCMg0hKngLrwHhja8tRALe8t8ZB7t2pitv99jx4O8eAOd5GAyt8p1y4k GhYCpY7hyBhHsBBWosY8Mi84Ggxq++YNG4151FQmXiGG8tHAj07q4wm1pnb0QmBccRf4 Z9CohjpRsjM9uCem4NG5HfnoseupwPoeghJ6Qw8/hNVARLeT+fyGzTKKqq6W0pSfklaX e04g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=hS+4erVE1Vm+SRo+MuqXnkT3dOP0gtqqH2sJ57SF8Ao=; b=CGKInrtMiFkCPRUWWGrT8FFIjKQMpVeJbHaO8l8EFrs1M15+cOXlVgGHB6dh0zZNbG nMVyFWndBoGLE7zGbnHwLLg0KkRLEMJmxqB7cu+GX+Jxi9A0z3gMjgY7zHgrkQzuymLH shCw/464Y87Z4x8R1dwejS8OhxSREwIOPQo37kCQr3S2I2zUk4ikpBb0hjQC679XqTKm zeFTmPMiKDTKb8u2qOmZ8ygV4pQ/tZi7Aris3Lhiv0KaurZfgRvEq3YbNOo+ATQwspLJ q4fVbXwjK1evY/PTKs2KUnmeJGCowrC5IRKgXX8yoIpywby45Q9lqVPkAVI+rQXSknW9 83ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p6-20020a170902b08600b001a6556cf95esi6178619plr.170.2023.05.27.05.54.18; Sat, 27 May 2023 05:54:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232635AbjE0MgY (ORCPT + 99 others); Sat, 27 May 2023 08:36:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232555AbjE0MgM (ORCPT ); Sat, 27 May 2023 08:36:12 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15C6B1BD for ; Sat, 27 May 2023 05:35:51 -0700 (PDT) Received: from dggpemm500006.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4QT1Nz3J4hz18LRM; Sat, 27 May 2023 20:31:15 +0800 (CST) Received: from thunder-town.china.huawei.com (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Sat, 27 May 2023 20:35:48 +0800 From: Zhen Lei To: Eric Biederman , Baoquan He , , CC: Zhen Lei , Michael Holzheu , Andrew Morton , Amerigo Wang Subject: [PATCH 3/6] kexec: clear crashk_res if all its memory has been released Date: Sat, 27 May 2023 20:34:36 +0800 Message-ID: <20230527123439.772-4-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.37.3.windows.1 In-Reply-To: <20230527123439.772-1-thunder.leizhen@huawei.com> References: <20230527123439.772-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the resource of crashk_res has been released, it is better to clear crashk_res.start and crashk_res.end. Because 'end = start - 1' is not reasonable, and in some places the test is based on crashk_res.end, not resource_size(&crashk_res). Signed-off-by: Zhen Lei --- kernel/kexec_core.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index d1ab139dd49035e..bcc86a250ab3bf9 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -1137,15 +1137,18 @@ int crash_shrink_memory(unsigned long new_size) end = start + new_size; crash_free_reserved_phys_range(end, crashk_res.end); - if (start == end) - release_resource(&crashk_res); - ram_res->start = end; ram_res->end = crashk_res.end; ram_res->flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM; ram_res->name = "System RAM"; - crashk_res.end = end - 1; + if (start == end) { + release_resource(&crashk_res); + crashk_res.start = 0; + crashk_res.end = 0; + } else { + crashk_res.end = end - 1; + } insert_resource(&iomem_resource, ram_res); -- 2.25.1