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 X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 396EBC433E7 for ; Mon, 12 Oct 2020 15:55:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E4FCD208B8 for ; Mon, 12 Oct 2020 15:55:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602518158; bh=hub1pUsQ6j4L0DSXsL6UZmMPdK88ONZg32/xMFIkibA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=O7MOZWamfY286nyWsLKb1PhcbGq8W6fn61iygzm/rjwUD0xYP/tjk19W8BBnGHi8p mn2gmGveDIf6J9CjfnEFtQbaB1ggT80JyaZWYzWpdfJ9VspoxRGQdub9rBXpuOQNbH b1xD/WSKUPt60aCtVzuB6T5fR9fgOvoo1+fWxFFE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729021AbgJLPz5 (ORCPT ); Mon, 12 Oct 2020 11:55:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:53168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730508AbgJLPz5 (ORCPT ); Mon, 12 Oct 2020 11:55:57 -0400 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C8A7120797 for ; Mon, 12 Oct 2020 15:55:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602518156; bh=hub1pUsQ6j4L0DSXsL6UZmMPdK88ONZg32/xMFIkibA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=GzUeYmUT79wPmNg+ZR9wLa6+/0VcgOZyyaA0aVLgk8fknD58q/5HU7F1IKWPvnpV8 rfE5Gdls4DY0ZPxmvFVOvf+vHZ9RQSh/8o+PdUTCCTmoatDpMBgoidPKuu8C7OBDij ekx/jcAZLXtSNy6dBP6pZzAR3Pb49Cxhum67WhRU= Received: by mail-oi1-f172.google.com with SMTP id 16so19149509oix.9 for ; Mon, 12 Oct 2020 08:55:56 -0700 (PDT) X-Gm-Message-State: AOAM531K4/Tqi065VBpxB5hKoKlGnDGJGVCa7VTVx4mVfJyfJUUq0/Lo Tghlay6/d5Vg6hxyAEySJ+CLRChkxhOy1f+dn34= X-Google-Smtp-Source: ABdhPJwOaUVqeXUONPkmLLacYp4eFynS2HQ4PinEgAttyptU8xRimxnqS+i6ERzts5Dwz1grElg0MwKybl8PwrNtNZY= X-Received: by 2002:aca:4085:: with SMTP id n127mr3252731oia.33.1602518156075; Mon, 12 Oct 2020 08:55:56 -0700 (PDT) MIME-Version: 1.0 References: <20201010093153.30177-1-ardb@kernel.org> <20201012092821.GB9844@gaia> <20201012112453.GD9844@gaia> <20201012154954.GB6493@gaia> In-Reply-To: <20201012154954.GB6493@gaia> From: Ard Biesheuvel Date: Mon, 12 Oct 2020 17:55:45 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] arm64: mm: set ZONE_DMA size based on early IORT scan To: Catalin Marinas Cc: Linux ARM , ACPI Devel Maling List , Will Deacon , Jeremy Linton , Lorenzo Pieralisi , Nicolas Saenz Julienne , Rob Herring , Christoph Hellwig , Robin Murphy , Hanjun Guo , Sudeep Holla , Anshuman Khandual Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Mon, 12 Oct 2020 at 17:50, Catalin Marinas wrote: > > On Mon, Oct 12, 2020 at 04:19:08PM +0200, Ard Biesheuvel wrote: > > On Mon, 12 Oct 2020 at 13:24, Catalin Marinas wrote: > > > On Mon, Oct 12, 2020 at 12:43:05PM +0200, Ard Biesheuvel wrote: > > > > On Mon, 12 Oct 2020 at 11:30, Ard Biesheuvel wrote: > > > > > On Mon, 12 Oct 2020 at 11:28, Catalin Marinas wrote: > > > > > > On Sat, Oct 10, 2020 at 11:31:53AM +0200, Ard Biesheuvel wrote: > > > > > > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > > > > > > > index f0599ae73b8d..829fa63c3d72 100644 > > > > > > > --- a/arch/arm64/mm/init.c > > > > > > > +++ b/arch/arm64/mm/init.c > > > > > > > @@ -191,6 +191,14 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) > > > > > > > unsigned long max_zone_pfns[MAX_NR_ZONES] = {0}; > > > > > > > > > > > > > > #ifdef CONFIG_ZONE_DMA > > > > > > > + if (IS_ENABLED(CONFIG_ACPI)) { > > > > > > > + extern unsigned int acpi_iort_get_zone_dma_size(void); > > > > > > > > > > > > Nitpick: can we add this prototype to include/linux/acpi_iort.h? > > > > > > > > > > > > > + > > > > > > > + zone_dma_bits = min(zone_dma_bits, > > > > > > > + acpi_iort_get_zone_dma_size()); > > > > > > > + arm64_dma_phys_limit = max_zone_phys(zone_dma_bits); > > > > > > > + } > > > > > > > + > > > > > > > max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit); > > > > > > > > > > > > I think we should initialise zone_dma_bits slightly earlier via > > > > > > arm64_memblock_init(). We'll eventually have reserve_crashkernel() > > > > > > called before this and it will make use of arm64_dma_phys_limit for > > > > > > "low" reservations: > > > > > > > > > > > > https://lore.kernel.org/linux-arm-kernel/20200907134745.25732-7-chenzhou10@huawei.com/ > > > > > > > > > > > > > > > > We don't have access to the ACPI tables yet at that point. > > > > > > > > Also, could someone give an executive summary of why it matters where > > > > the crashkernel is loaded? As far as I can tell, reserve_crashkernel() > > > > only allocates memory for the kernel's executable image itself, which > > > > can usually be loaded anywhere in memory. I could see how a > > > > crashkernel might need some DMA'able memory if it needs to use the > > > > hardware, but I don't think that is what is going on here. > > > > > > I thought the crashkernel needs some additional reserved RAM as well to > > > be able to run. It should not touch the original kernel's memory as it > > > usually needs to dump it. > > > > Looking at the code, it is definitely allocating memory for the kernel > > itself (as it refers to the 2 MB alignment requirement), and given > > that we used to require the kernel to be at the base of the linear > > region to even be able to access all of memory, I suspect that we > > might be able to relax this requirement. Not sure what that means for > > the userland tools, though. > > The 2MB is an interpretation of booting.txt that the DRAM must start at > this alignment (not sure what we do these days, in lots of > configurations we just use 4K pages for the linear map). > On 4k granule kernels, We still need 2 MB alignment today unless you use a relocatable kernel. The reason is that virtual addresses are assigned at link time, and we use section mappings to map the kernel. If CONFIG_RELOCATABLE=y, the kernel can run happily at any 64k aligned address (except for the 64k granule kernel with CONFIG_VMAP=y, which needs 128k in this case) So keeping a 2 MB alignment requirement in booting.txt still makes sense. > However, the crashkernel=... range is meant for sufficiently large > reservation to be able to run the kdump kernel, not just load the image. > Sure. But I was referring to the requirement that it is loaded low in memory. Unless I am misunderstanding something, all we need for the crashkernel to be able to operate is some ZONE_DMA memory in case it is needed by the hardware, and beyond that, it could happily live anywhere in memory. 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 X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CCB8C433E7 for ; Mon, 12 Oct 2020 15:57:26 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD0912067C for ; Mon, 12 Oct 2020 15:57:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="v4PrOSqb"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="GzUeYmUT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD0912067C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kSFsL5HM9S58cgH/gEXcc0GOgTiU0RBrESBruGi8UWc=; b=v4PrOSqbDHB8+VwVoVornQHXC dFAJLOWYvINJR9wlebcMnFIvWZR9hMkbShJR9z4qu1IJtbxVmxaQExH94O3VL+Thm7XODSu4+C/lq hvE4Io+zMaZpZLvLrJjYozxFJGUgoqyF7zJmfHlnqaUjJaEyHjOANe9cSwB79xh1zXsf+OblYjciS ta833vNkk/zqL+nNL1qEK07hyJM8gi13cy1c8vkDD16XP8Pe7P4Z2n3nSJzKUGnIVu+XvaJGjpoHU wVO8MAKWeGw6GwR1oX1WI28YdN+hKfohHPTLg11NXKA32KN7pTMew4rUQdq1LIDjv+E4SROx4hF0t 8R7gI48lQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kS0B8-0005mp-Kt; Mon, 12 Oct 2020 15:56:02 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kS0B4-0005li-8k for linux-arm-kernel@lists.infradead.org; Mon, 12 Oct 2020 15:56:00 +0000 Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BDC5720735 for ; Mon, 12 Oct 2020 15:55:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602518156; bh=hub1pUsQ6j4L0DSXsL6UZmMPdK88ONZg32/xMFIkibA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=GzUeYmUT79wPmNg+ZR9wLa6+/0VcgOZyyaA0aVLgk8fknD58q/5HU7F1IKWPvnpV8 rfE5Gdls4DY0ZPxmvFVOvf+vHZ9RQSh/8o+PdUTCCTmoatDpMBgoidPKuu8C7OBDij ekx/jcAZLXtSNy6dBP6pZzAR3Pb49Cxhum67WhRU= Received: by mail-oi1-f181.google.com with SMTP id w204so3992569oiw.1 for ; Mon, 12 Oct 2020 08:55:56 -0700 (PDT) X-Gm-Message-State: AOAM530B5Z3pONWagPhfM0iAU34lcebAWb1D6jIK+Z7nmdy952tsmw2l //7pFaxemPG9tlyN+cFDzFGDtEsUm/Bsv11EbvA= X-Google-Smtp-Source: ABdhPJwOaUVqeXUONPkmLLacYp4eFynS2HQ4PinEgAttyptU8xRimxnqS+i6ERzts5Dwz1grElg0MwKybl8PwrNtNZY= X-Received: by 2002:aca:4085:: with SMTP id n127mr3252731oia.33.1602518156075; Mon, 12 Oct 2020 08:55:56 -0700 (PDT) MIME-Version: 1.0 References: <20201010093153.30177-1-ardb@kernel.org> <20201012092821.GB9844@gaia> <20201012112453.GD9844@gaia> <20201012154954.GB6493@gaia> In-Reply-To: <20201012154954.GB6493@gaia> From: Ard Biesheuvel Date: Mon, 12 Oct 2020 17:55:45 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] arm64: mm: set ZONE_DMA size based on early IORT scan To: Catalin Marinas X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201012_115558_524165_6FAB0920 X-CRM114-Status: GOOD ( 40.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Anshuman Khandual , Robin Murphy , Sudeep Holla , Jeremy Linton , ACPI Devel Maling List , Rob Herring , Linux ARM , Hanjun Guo , Will Deacon , Christoph Hellwig , Nicolas Saenz Julienne 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 Mon, 12 Oct 2020 at 17:50, Catalin Marinas wrote: > > On Mon, Oct 12, 2020 at 04:19:08PM +0200, Ard Biesheuvel wrote: > > On Mon, 12 Oct 2020 at 13:24, Catalin Marinas wrote: > > > On Mon, Oct 12, 2020 at 12:43:05PM +0200, Ard Biesheuvel wrote: > > > > On Mon, 12 Oct 2020 at 11:30, Ard Biesheuvel wrote: > > > > > On Mon, 12 Oct 2020 at 11:28, Catalin Marinas wrote: > > > > > > On Sat, Oct 10, 2020 at 11:31:53AM +0200, Ard Biesheuvel wrote: > > > > > > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > > > > > > > index f0599ae73b8d..829fa63c3d72 100644 > > > > > > > --- a/arch/arm64/mm/init.c > > > > > > > +++ b/arch/arm64/mm/init.c > > > > > > > @@ -191,6 +191,14 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) > > > > > > > unsigned long max_zone_pfns[MAX_NR_ZONES] = {0}; > > > > > > > > > > > > > > #ifdef CONFIG_ZONE_DMA > > > > > > > + if (IS_ENABLED(CONFIG_ACPI)) { > > > > > > > + extern unsigned int acpi_iort_get_zone_dma_size(void); > > > > > > > > > > > > Nitpick: can we add this prototype to include/linux/acpi_iort.h? > > > > > > > > > > > > > + > > > > > > > + zone_dma_bits = min(zone_dma_bits, > > > > > > > + acpi_iort_get_zone_dma_size()); > > > > > > > + arm64_dma_phys_limit = max_zone_phys(zone_dma_bits); > > > > > > > + } > > > > > > > + > > > > > > > max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit); > > > > > > > > > > > > I think we should initialise zone_dma_bits slightly earlier via > > > > > > arm64_memblock_init(). We'll eventually have reserve_crashkernel() > > > > > > called before this and it will make use of arm64_dma_phys_limit for > > > > > > "low" reservations: > > > > > > > > > > > > https://lore.kernel.org/linux-arm-kernel/20200907134745.25732-7-chenzhou10@huawei.com/ > > > > > > > > > > > > > > > > We don't have access to the ACPI tables yet at that point. > > > > > > > > Also, could someone give an executive summary of why it matters where > > > > the crashkernel is loaded? As far as I can tell, reserve_crashkernel() > > > > only allocates memory for the kernel's executable image itself, which > > > > can usually be loaded anywhere in memory. I could see how a > > > > crashkernel might need some DMA'able memory if it needs to use the > > > > hardware, but I don't think that is what is going on here. > > > > > > I thought the crashkernel needs some additional reserved RAM as well to > > > be able to run. It should not touch the original kernel's memory as it > > > usually needs to dump it. > > > > Looking at the code, it is definitely allocating memory for the kernel > > itself (as it refers to the 2 MB alignment requirement), and given > > that we used to require the kernel to be at the base of the linear > > region to even be able to access all of memory, I suspect that we > > might be able to relax this requirement. Not sure what that means for > > the userland tools, though. > > The 2MB is an interpretation of booting.txt that the DRAM must start at > this alignment (not sure what we do these days, in lots of > configurations we just use 4K pages for the linear map). > On 4k granule kernels, We still need 2 MB alignment today unless you use a relocatable kernel. The reason is that virtual addresses are assigned at link time, and we use section mappings to map the kernel. If CONFIG_RELOCATABLE=y, the kernel can run happily at any 64k aligned address (except for the 64k granule kernel with CONFIG_VMAP=y, which needs 128k in this case) So keeping a 2 MB alignment requirement in booting.txt still makes sense. > However, the crashkernel=... range is meant for sufficiently large > reservation to be able to run the kdump kernel, not just load the image. > Sure. But I was referring to the requirement that it is loaded low in memory. Unless I am misunderstanding something, all we need for the crashkernel to be able to operate is some ZONE_DMA memory in case it is needed by the hardware, and beyond that, it could happily live anywhere in memory. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel