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 6ED53C43467 for ; Mon, 12 Oct 2020 14:19:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2FB0A2076E for ; Mon, 12 Oct 2020 14:19:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602512362; bh=yxsOv5pHmOvwNOr94vesEEIlHaTWe6T9YBkAypSUujQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=B+1xRc6eZ21VlmJ5eQAz9SZmvn14gzgb95iCkPb6EmOpmztQ3pwSn+KAtYiGUj/V+ cqF26/ofOEYyDwZkUtl1bLFPbQJnrHEVUG7CJt0CDdwnztgDuM4rVN5CeRGKA3ALk3 uAqhi47494Of8txW1XhgIa6Gf6BzyiuCqYE87dOw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389080AbgJLOTV (ORCPT ); Mon, 12 Oct 2020 10:19:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:49650 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389085AbgJLOTV (ORCPT ); Mon, 12 Oct 2020 10:19:21 -0400 Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (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 9AC112087E for ; Mon, 12 Oct 2020 14:19:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602512360; bh=yxsOv5pHmOvwNOr94vesEEIlHaTWe6T9YBkAypSUujQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=fbCRRacqj1O4KX7PKftz+1q2qTQAtW62OtaVMfZHtvgqyiuygM22Pnx2ef8nrsLHU fzG44Ly/zmvDoR2L0/J87wPSW+rrjtZ5TReDqtoBVLx9yDdk6w+jBav/JGLWi/QTnh 5rfgtUWDF5tO78BlO1aZJJ850Fjw2GbZGZr40m38= Received: by mail-oi1-f176.google.com with SMTP id 16so18838209oix.9 for ; Mon, 12 Oct 2020 07:19:20 -0700 (PDT) X-Gm-Message-State: AOAM53000moGLfaw+BAVZZU8fiWRK1LVBO3gnPVSGa4NSO9k9BpLYS2s P/6vFCo9tNyVcyhXLAGPx/Mvd9wJkkvtkmva+8w= X-Google-Smtp-Source: ABdhPJyJguwdedJrJ9Eb4ZZVDdA2vQ1Dmhq2MpHhb4aBmbv2s4ekAMK3JPGZsSVtBCP4/ksiFOiuj33K9ZsCRkFAiNU= X-Received: by 2002:aca:4085:: with SMTP id n127mr3020100oia.33.1602512359905; Mon, 12 Oct 2020 07:19:19 -0700 (PDT) MIME-Version: 1.0 References: <20201010093153.30177-1-ardb@kernel.org> <20201012092821.GB9844@gaia> <20201012112453.GD9844@gaia> In-Reply-To: <20201012112453.GD9844@gaia> From: Ard Biesheuvel Date: Mon, 12 Oct 2020 16:19:08 +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 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. 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 497F0C43457 for ; Mon, 12 Oct 2020 14:20:45 +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 00A332076E for ; Mon, 12 Oct 2020 14:20:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="lY7X67wb"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="fbCRRacq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 00A332076E 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=djUr6tadBIJf2NDR43iE4px3D2t8KW3v4P3U0jZskeg=; b=lY7X67wbriEO8W/3I9TcOzyKX L9IOvnjtSn8zJYF7JKXJmurY9hLVYJharxCACLRPsA2CyXbnkZ1cNVoghUkdwEvDPdbOUL4zC8AEk ZxYf4xUzJvafozhNniAFzuxB1Cb7mcRXGL5RBOuiSwHOC7q4qsC3SNIMSlhzE+5HkMiDdxAw3ij7L Do1s4wI9DcmP9VXDKfEBB9xJ2BW04hDnGB9t6n+sNSfiF6bjf6aE/JGHrbAZNuYc1C208ucGS6o2E 9xiTOOMbEXBT7AIhg2s671JdWQN+3uUSZe/8IWVJOjc76H7CONJ56er/hzVRIt3/5JqdYJbC5AvzR zgFnKE2LA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kRyfc-0000XI-9y; Mon, 12 Oct 2020 14:19:24 +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 1kRyfZ-0000WW-9Y for linux-arm-kernel@lists.infradead.org; Mon, 12 Oct 2020 14:19:22 +0000 Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (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 8577920776 for ; Mon, 12 Oct 2020 14:19:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602512360; bh=yxsOv5pHmOvwNOr94vesEEIlHaTWe6T9YBkAypSUujQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=fbCRRacqj1O4KX7PKftz+1q2qTQAtW62OtaVMfZHtvgqyiuygM22Pnx2ef8nrsLHU fzG44Ly/zmvDoR2L0/J87wPSW+rrjtZ5TReDqtoBVLx9yDdk6w+jBav/JGLWi/QTnh 5rfgtUWDF5tO78BlO1aZJJ850Fjw2GbZGZr40m38= Received: by mail-oi1-f176.google.com with SMTP id w204so3683852oiw.1 for ; Mon, 12 Oct 2020 07:19:20 -0700 (PDT) X-Gm-Message-State: AOAM530hZQEohbaSOG6lVFffhEtZyKZjsyIT5aPJeyN/d1MXTlIpQ6ms mxC6bWn8Hv02axyTDSbOAswdf+6l1Hro6T6/2Mg= X-Google-Smtp-Source: ABdhPJyJguwdedJrJ9Eb4ZZVDdA2vQ1Dmhq2MpHhb4aBmbv2s4ekAMK3JPGZsSVtBCP4/ksiFOiuj33K9ZsCRkFAiNU= X-Received: by 2002:aca:4085:: with SMTP id n127mr3020100oia.33.1602512359905; Mon, 12 Oct 2020 07:19:19 -0700 (PDT) MIME-Version: 1.0 References: <20201010093153.30177-1-ardb@kernel.org> <20201012092821.GB9844@gaia> <20201012112453.GD9844@gaia> In-Reply-To: <20201012112453.GD9844@gaia> From: Ard Biesheuvel Date: Mon, 12 Oct 2020 16:19:08 +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_101921_482526_547E82D3 X-CRM114-Status: GOOD ( 34.05 ) 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 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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel