Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3122138imw; Mon, 11 Jul 2022 02:13:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1upChnPSKqoIRKQSNyy2BX3svfLHBkfS1RTFb7ACvJjJBWqCKkb0BW+4QiASAc9F6AQBGN1 X-Received: by 2002:a17:906:7482:b0:722:ea8f:3a12 with SMTP id e2-20020a170906748200b00722ea8f3a12mr17994544ejl.220.1657530799077; Mon, 11 Jul 2022 02:13:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657530799; cv=none; d=google.com; s=arc-20160816; b=vNxxgdgz30EHHCE+T+BFD6losfWKZRguVwKl4q+UaAs4WNk3GNA6HyJtbSsDtZyTVy LDeHXLJCke1uBSm7t0dobTh18lo6VQ0M57D7ZYe0+cYmrHH7z/WJEMBDGWmJ9t5Agl7K uALD9Xt1AHaKNKycx1g591gAB7oqYHOBkKv78UKU1vuw4gLLcABGJS3AJldViHevWD3E BG9Cd3BxqVA+8hUoGrNTWYS0UGcnZv3vnYbWkPdfy+z/pIXVMKiQcmSLWNKOi5g9sVgV 3E4Ju4QxJK9ycZktmJ4xSzZ8PrF9H7IYRjZcx2s7ZS5Z7zw6R64Ar61RAgJ+poD9jjJz CSjw== 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=Q6lYql8fIGZKImgv7zZi9x5Spd+BVxO3MV/vfS1TQEw=; b=hFi72dU8MDlQPIDnrI9hJ249y8Mu5BSezR9cKsUmZSh68kkmKKZl1LZGqyOYglDRpW UFtGICzhrBoMYtMyQczYr18kEIbAMcTJDkS9mPL5bxq5mirGung4TIyu0NZngC+NXcSj l29CkY8cHrNBZWrJohLy3vGIQGXkYviNM0wcNxJTzGrpUElpAE2vKxXG0mSea0lZHkCD XFdyFRkHZ89FdHGTR+hb4Ql6DrL+v17q2BL1B4no8z+DxgCHiN6ADoI4EICmo05GZM45 ev7n/y5MYT66PF5Y4pEq+qIwltmJHRdiwJ16JOA1qeri1hpRj7RlV127aCL6S0dqoqhw 4Ufw== 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 hq28-20020a1709073f1c00b00726f11c4c8esi5747101ejc.669.2022.07.11.02.12.53; Mon, 11 Jul 2022 02:13:19 -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 S230429AbiGKJEx (ORCPT + 99 others); Mon, 11 Jul 2022 05:04:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbiGKJEu (ORCPT ); Mon, 11 Jul 2022 05:04:50 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3752912638; Mon, 11 Jul 2022 02:04:49 -0700 (PDT) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LhHtB0k8zzTgkG; Mon, 11 Jul 2022 17:01:06 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 11 Jul 2022 17:04:43 +0800 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.2375.24; Mon, 11 Jul 2022 17:04:42 +0800 From: Zhen Lei To: Dave Young , Baoquan He , Vivek Goyal , , , Catalin Marinas , Will Deacon , , Jonathan Corbet , CC: Zhen Lei , "Eric W . Biederman" , Randy Dunlap , Feng Zhou , Kefeng Wang , "Chen Zhou" , John Donnelly , Dave Kleikamp Subject: [PATCH v3 2/2] arm64: kdump: Support crashkernel=X fall back to reserve region above DMA zones Date: Mon, 11 Jul 2022 17:03:19 +0800 Message-ID: <20220711090319.1604-3-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20220711090319.1604-1-thunder.leizhen@huawei.com> References: <20220711090319.1604-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: dggems703-chm.china.huawei.com (10.3.19.180) 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 For crashkernel=X without '@offset', select a region within DMA zones first, and fall back to reserve region above DMA zones. This allows users to use the same configuration on multiple platforms. Signed-off-by: Zhen Lei Acked-by: Baoquan He --- Documentation/admin-guide/kernel-parameters.txt | 2 +- arch/arm64/mm/init.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 65a2c3a22a4b57d..cb6a346419a1fe0 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -823,7 +823,7 @@ memory region [offset, offset + size] for that kernel image. If '@offset' is omitted, then a suitable offset is selected automatically. - [KNL, X86-64] Select a region under 4G first, and + [KNL, X86-64, ARM64] Select a region under 4G first, and fall back to reserve region above 4G when '@offset' hasn't been specified. See Documentation/admin-guide/kdump/kdump.rst for further details. diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 5390f361208ccf7..8539598f9e58b4d 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -138,6 +138,7 @@ static void __init reserve_crashkernel(void) unsigned long long crash_max = CRASH_ADDR_LOW_MAX; char *cmdline = boot_command_line; int ret; + bool fixed_base; if (!IS_ENABLED(CONFIG_KEXEC_CORE)) return; @@ -166,15 +167,28 @@ static void __init reserve_crashkernel(void) return; } + fixed_base = !!crash_base; crash_size = PAGE_ALIGN(crash_size); /* User specifies base address explicitly. */ - if (crash_base) + if (fixed_base) crash_max = crash_base + crash_size; +retry: crash_base = memblock_phys_alloc_range(crash_size, CRASH_ALIGN, crash_base, crash_max); if (!crash_base) { + /* + * Attempt to fully allocate low memory failed, fall back + * to high memory, the minimum required low memory will be + * reserved later. + */ + if (!fixed_base && (crash_max == CRASH_ADDR_LOW_MAX)) { + crash_max = CRASH_ADDR_HIGH_MAX; + crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; + goto retry; + } + pr_warn("cannot allocate crashkernel (size:0x%llx)\n", crash_size); return; -- 2.25.1