From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B892C433FE for ; Thu, 16 Dec 2021 12:23:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235920AbhLPMXr (ORCPT ); Thu, 16 Dec 2021 07:23:47 -0500 Received: from szxga01-in.huawei.com ([45.249.212.187]:33858 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbhLPMXq (ORCPT ); Thu, 16 Dec 2021 07:23:46 -0500 Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4JFB992pRrzcbvh; Thu, 16 Dec 2021 20:23:25 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 16 Dec 2021 20:23:43 +0800 Received: from [10.174.178.55] (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.2308.20; Thu, 16 Dec 2021 20:23:42 +0800 Subject: Re: [PATCH v17 03/10] x86: kdump: use macro CRASH_ADDR_LOW_MAX in functions reserve_crashkernel() From: "Leizhen (ThunderTown)" To: Borislav Petkov CC: Baoquan He , Thomas Gleixner , "Ingo Molnar" , , "H . Peter Anvin" , , Dave Young , Vivek Goyal , Eric Biederman , , Catalin Marinas , Will Deacon , , Rob Herring , Frank Rowand , , "Jonathan Corbet" , , Randy Dunlap , Feng Zhou , Kefeng Wang , Chen Zhou References: <20211210065533.2023-1-thunder.leizhen@huawei.com> <20211210065533.2023-4-thunder.leizhen@huawei.com> <20211216011040.GG3023@MiWiFi-R3L-srv> <9513d74c-d4c7-babd-f823-8999e195d96d@huawei.com> <35810a61-604e-9b90-2a7f-cfca6ae042ac@huawei.com> Message-ID: <20d765ff-59bb-7bb3-df06-9f02eada3cb0@huawei.com> Date: Thu, 16 Dec 2021 20:23:31 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <35810a61-604e-9b90-2a7f-cfca6ae042ac@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/12/16 20:08, Leizhen (ThunderTown) wrote: > > > On 2021/12/16 19:07, Borislav Petkov wrote: >> On Thu, Dec 16, 2021 at 10:46:12AM +0800, Leizhen (ThunderTown) wrote: >>> The original value (1ULL << 32) is inaccurate >> >> I keep asking *why*? >> >>> and it enlarged the CRASH_ADDR_LOW upper limit. >> >> $ git grep -E "CRASH_ADDR_LOW\W" >> $ >> >> I have no clue what you mean here. > > #ifdef CONFIG_X86_32 > # define CRASH_ADDR_LOW_MAX SZ_512M > # define CRASH_ADDR_HIGH_MAX SZ_512M > #endif > > if (!high) > (1) crash_base = memblock_phys_alloc_range(crash_size, > CRASH_ALIGN, CRASH_ALIGN, > CRASH_ADDR_LOW_MAX); > if (!crash_base) > (2) crash_base = memblock_phys_alloc_range(crash_size, > CRASH_ALIGN, CRASH_ALIGN, > CRASH_ADDR_HIGH_MAX); > > - if (crash_base >= (1ULL << 32) && reserve_crashkernel_low()) > +(3) if (crash_base >= CRASH_ADDR_LOW_MAX && reserve_crashkernel_low()) > > If the memory of 'crash_base' is successfully allocated at (1), because the last > parameter CRASH_ADDR_LOW_MAX is the upper bound, so we can sure that > "crash_base < CRASH_ADDR_LOW_MAX". So that, reserve_crashkernel_low() will not be > invoked at (3). That's why I said (1ULL << 32) is inaccurate and enlarge the CRASH_ADDR_LOW > upper limit. > > If the memory of 'crash_base' is successfully allocated at (2), you see, > CRASH_ADDR_HIGH_MAX = CRASH_ADDR_LOW_MAX = SZ_512M, the same as (1). In fact, > "crashkernel=high," may not be recommended on X86_32. > > Is it possible that (CRASH_ADDR_HIGH_MAX >= 4G) and (CRASH_ADDR_LOW_MAX < 4G)? > In this case, the memory allocated at (2) maybe over 4G. But why shouldn't > CRASH_ADDR_LOW_MAX be equal to 4G at this point? We divide two memory areas: low memory area and high memory area. The doc told us: at least 256MB memory should be reserved at low memory area. So that if "crash_base >= CRASH_ADDR_LOW_MAX" is true at (3), that means we have not reserved any memory at low memory area, so we should call reserve_crashkernel_low(). The low memory area is not equivalent to <=4G, I think. So replace (1ULL << 32) with CRASH_ADDR_LOW_MAX is logically correct. > > >> >>> This is because when the memory is allocated from the low end, the >>> address cannot exceed CRASH_ADDR_LOW_MAX, see "if (!high)" branch. >> >>> If >>> the memory is allocated from the high end, 'crash_base' is greater than or >>> equal to (1ULL << 32), and naturally, it is greater than CRASH_ADDR_LOW_MAX. >>> >>> I think I should update the description, thanks. >> >> I think you should explain why is (1ULL << 32) wrong. >> >> It came from: >> >> eb6db83d1059 ("x86/setup: Do not reserve crashkernel high memory if low reservation failed") >> >> which simply frees the high memory portion when the low reservation >> fails. And the test for that is, is crash base > 4G. So that makes >> perfect sense to me. >> >> So your change is a NOP on 64-bit and it is a NOP on 32-bit by virtue of >> the _low() variant always returning 0 on 32-bit. >> From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F28B0C433F5 for ; Thu, 16 Dec 2021 12:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:References:CC:To:From:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=pa+sUcP4pwjG3ucn4rOjRzANNZFXGMXTY+gN2lsiCmw=; b=UarCQa+W+Aa3bpMDin1PydKsZY S9g3pGO+2SAzmtNZvNg6PmWi1QgtWyqI8PBaoy7gTY4hWfYUVnihQrOOzxEMzW8pljoPx4K2y8h++ Mz6HwuHVjFBz+zW0lgZOawmj0GRBT8j9D02iZ8uRjQ4TzYrJevEPAk4DA+Doy7/HhiSQj7CU+j/p8 b1iFm74OpNl5ICIQ4KArz98uOJMuZA3oTgUAjSd1XuMFzwA2jyD/AaYQO2LynfUgdqIeug3znCqVU /Z7Ti91PF8Om13+YCD96dvr6ytOc/pbDEPlI7nqXVJAJcWwqbOJsp3Y3G6+P3cRiwqb3XhHnLZwud gWSD/AKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxqBC-005WkL-Kk; Thu, 16 Dec 2021 12:48:15 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxpnW-005PJv-W0; Thu, 16 Dec 2021 12:23:49 +0000 Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4JFB992pRrzcbvh; Thu, 16 Dec 2021 20:23:25 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 16 Dec 2021 20:23:43 +0800 Received: from [10.174.178.55] (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.2308.20; Thu, 16 Dec 2021 20:23:42 +0800 Subject: Re: [PATCH v17 03/10] x86: kdump: use macro CRASH_ADDR_LOW_MAX in functions reserve_crashkernel() From: "Leizhen (ThunderTown)" To: Borislav Petkov CC: Baoquan He , Thomas Gleixner , "Ingo Molnar" , , "H . Peter Anvin" , , Dave Young , Vivek Goyal , Eric Biederman , , Catalin Marinas , Will Deacon , , Rob Herring , Frank Rowand , , "Jonathan Corbet" , , Randy Dunlap , Feng Zhou , Kefeng Wang , Chen Zhou References: <20211210065533.2023-1-thunder.leizhen@huawei.com> <20211210065533.2023-4-thunder.leizhen@huawei.com> <20211216011040.GG3023@MiWiFi-R3L-srv> <9513d74c-d4c7-babd-f823-8999e195d96d@huawei.com> <35810a61-604e-9b90-2a7f-cfca6ae042ac@huawei.com> Message-ID: <20d765ff-59bb-7bb3-df06-9f02eada3cb0@huawei.com> Date: Thu, 16 Dec 2021 20:23:31 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <35810a61-604e-9b90-2a7f-cfca6ae042ac@huawei.com> Content-Language: en-US X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211216_042347_458092_C7F97C59 X-CRM114-Status: GOOD ( 23.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2021/12/16 20:08, Leizhen (ThunderTown) wrote: > > > On 2021/12/16 19:07, Borislav Petkov wrote: >> On Thu, Dec 16, 2021 at 10:46:12AM +0800, Leizhen (ThunderTown) wrote: >>> The original value (1ULL << 32) is inaccurate >> >> I keep asking *why*? >> >>> and it enlarged the CRASH_ADDR_LOW upper limit. >> >> $ git grep -E "CRASH_ADDR_LOW\W" >> $ >> >> I have no clue what you mean here. > > #ifdef CONFIG_X86_32 > # define CRASH_ADDR_LOW_MAX SZ_512M > # define CRASH_ADDR_HIGH_MAX SZ_512M > #endif > > if (!high) > (1) crash_base = memblock_phys_alloc_range(crash_size, > CRASH_ALIGN, CRASH_ALIGN, > CRASH_ADDR_LOW_MAX); > if (!crash_base) > (2) crash_base = memblock_phys_alloc_range(crash_size, > CRASH_ALIGN, CRASH_ALIGN, > CRASH_ADDR_HIGH_MAX); > > - if (crash_base >= (1ULL << 32) && reserve_crashkernel_low()) > +(3) if (crash_base >= CRASH_ADDR_LOW_MAX && reserve_crashkernel_low()) > > If the memory of 'crash_base' is successfully allocated at (1), because the last > parameter CRASH_ADDR_LOW_MAX is the upper bound, so we can sure that > "crash_base < CRASH_ADDR_LOW_MAX". So that, reserve_crashkernel_low() will not be > invoked at (3). That's why I said (1ULL << 32) is inaccurate and enlarge the CRASH_ADDR_LOW > upper limit. > > If the memory of 'crash_base' is successfully allocated at (2), you see, > CRASH_ADDR_HIGH_MAX = CRASH_ADDR_LOW_MAX = SZ_512M, the same as (1). In fact, > "crashkernel=high," may not be recommended on X86_32. > > Is it possible that (CRASH_ADDR_HIGH_MAX >= 4G) and (CRASH_ADDR_LOW_MAX < 4G)? > In this case, the memory allocated at (2) maybe over 4G. But why shouldn't > CRASH_ADDR_LOW_MAX be equal to 4G at this point? We divide two memory areas: low memory area and high memory area. The doc told us: at least 256MB memory should be reserved at low memory area. So that if "crash_base >= CRASH_ADDR_LOW_MAX" is true at (3), that means we have not reserved any memory at low memory area, so we should call reserve_crashkernel_low(). The low memory area is not equivalent to <=4G, I think. So replace (1ULL << 32) with CRASH_ADDR_LOW_MAX is logically correct. > > >> >>> This is because when the memory is allocated from the low end, the >>> address cannot exceed CRASH_ADDR_LOW_MAX, see "if (!high)" branch. >> >>> If >>> the memory is allocated from the high end, 'crash_base' is greater than or >>> equal to (1ULL << 32), and naturally, it is greater than CRASH_ADDR_LOW_MAX. >>> >>> I think I should update the description, thanks. >> >> I think you should explain why is (1ULL << 32) wrong. >> >> It came from: >> >> eb6db83d1059 ("x86/setup: Do not reserve crashkernel high memory if low reservation failed") >> >> which simply frees the high memory portion when the low reservation >> fails. And the test for that is, is crash base > 4G. So that makes >> perfect sense to me. >> >> So your change is a NOP on 64-bit and it is a NOP on 32-bit by virtue of >> the _low() variant always returning 0 on 32-bit. >> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Subject: Re: [PATCH v17 03/10] x86: kdump: use macro CRASH_ADDR_LOW_MAX in functions reserve_crashkernel() From: "Leizhen (ThunderTown)" References: <20211210065533.2023-1-thunder.leizhen@huawei.com> <20211210065533.2023-4-thunder.leizhen@huawei.com> <20211216011040.GG3023@MiWiFi-R3L-srv> <9513d74c-d4c7-babd-f823-8999e195d96d@huawei.com> <35810a61-604e-9b90-2a7f-cfca6ae042ac@huawei.com> Message-ID: <20d765ff-59bb-7bb3-df06-9f02eada3cb0@huawei.com> Date: Thu, 16 Dec 2021 20:23:31 +0800 MIME-Version: 1.0 In-Reply-To: <35810a61-604e-9b90-2a7f-cfca6ae042ac@huawei.com> Content-Language: en-US List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: Borislav Petkov Cc: Baoquan He , Thomas Gleixner , Ingo Molnar , x86@kernel.org, "H . Peter Anvin" , linux-kernel@vger.kernel.org, Dave Young , Vivek Goyal , Eric Biederman , kexec@lists.infradead.org, Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Rob Herring , Frank Rowand , devicetree@vger.kernel.org, Jonathan Corbet , linux-doc@vger.kernel.org, Randy Dunlap , Feng Zhou , Kefeng Wang , Chen Zhou On 2021/12/16 20:08, Leizhen (ThunderTown) wrote: > > > On 2021/12/16 19:07, Borislav Petkov wrote: >> On Thu, Dec 16, 2021 at 10:46:12AM +0800, Leizhen (ThunderTown) wrote: >>> The original value (1ULL << 32) is inaccurate >> >> I keep asking *why*? >> >>> and it enlarged the CRASH_ADDR_LOW upper limit. >> >> $ git grep -E "CRASH_ADDR_LOW\W" >> $ >> >> I have no clue what you mean here. > > #ifdef CONFIG_X86_32 > # define CRASH_ADDR_LOW_MAX SZ_512M > # define CRASH_ADDR_HIGH_MAX SZ_512M > #endif > > if (!high) > (1) crash_base = memblock_phys_alloc_range(crash_size, > CRASH_ALIGN, CRASH_ALIGN, > CRASH_ADDR_LOW_MAX); > if (!crash_base) > (2) crash_base = memblock_phys_alloc_range(crash_size, > CRASH_ALIGN, CRASH_ALIGN, > CRASH_ADDR_HIGH_MAX); > > - if (crash_base >= (1ULL << 32) && reserve_crashkernel_low()) > +(3) if (crash_base >= CRASH_ADDR_LOW_MAX && reserve_crashkernel_low()) > > If the memory of 'crash_base' is successfully allocated at (1), because the last > parameter CRASH_ADDR_LOW_MAX is the upper bound, so we can sure that > "crash_base < CRASH_ADDR_LOW_MAX". So that, reserve_crashkernel_low() will not be > invoked at (3). That's why I said (1ULL << 32) is inaccurate and enlarge the CRASH_ADDR_LOW > upper limit. > > If the memory of 'crash_base' is successfully allocated at (2), you see, > CRASH_ADDR_HIGH_MAX = CRASH_ADDR_LOW_MAX = SZ_512M, the same as (1). In fact, > "crashkernel=high," may not be recommended on X86_32. > > Is it possible that (CRASH_ADDR_HIGH_MAX >= 4G) and (CRASH_ADDR_LOW_MAX < 4G)? > In this case, the memory allocated at (2) maybe over 4G. But why shouldn't > CRASH_ADDR_LOW_MAX be equal to 4G at this point? We divide two memory areas: low memory area and high memory area. The doc told us: at least 256MB memory should be reserved at low memory area. So that if "crash_base >= CRASH_ADDR_LOW_MAX" is true at (3), that means we have not reserved any memory at low memory area, so we should call reserve_crashkernel_low(). The low memory area is not equivalent to <=4G, I think. So replace (1ULL << 32) with CRASH_ADDR_LOW_MAX is logically correct. > > >> >>> This is because when the memory is allocated from the low end, the >>> address cannot exceed CRASH_ADDR_LOW_MAX, see "if (!high)" branch. >> >>> If >>> the memory is allocated from the high end, 'crash_base' is greater than or >>> equal to (1ULL << 32), and naturally, it is greater than CRASH_ADDR_LOW_MAX. >>> >>> I think I should update the description, thanks. >> >> I think you should explain why is (1ULL << 32) wrong. >> >> It came from: >> >> eb6db83d1059 ("x86/setup: Do not reserve crashkernel high memory if low reservation failed") >> >> which simply frees the high memory portion when the low reservation >> fails. And the test for that is, is crash base > 4G. So that makes >> perfect sense to me. >> >> So your change is a NOP on 64-bit and it is a NOP on 32-bit by virtue of >> the _low() variant always returning 0 on 32-bit. >> _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec