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=-4.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 8BC7CC2B9F8 for ; Tue, 25 May 2021 16:54:44 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 56C1F613E1 for ; Tue, 25 May 2021 16:54:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 56C1F613E1 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=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UKfaeegixTXz8SBTPIsFzJ3zyMQCl/mI7UkHTtDODDE=; b=TbV8t3b/7LDGRV Cu6cKyU0k79SknvtkH4+HKeAcOxd65dqYIzY2r9nL7TPxQtJMaD4oUB826ZdVJoaytlHYjipaPyNU DXAodkKxLeKno97MLdJahrC7AacxVGuWGUoCd6NKXm0w9niFu3oa2h9C2h8UPjzlGJM8nBufuMZxo yBv/DLhoI0YiGyWjrmFioqG8DgGWzgme0ciIubSUK/N0o+F7tE02pBgUlOPLTh1Vye/JW+HKYXgRI wO3LEcI7XYbrCANjwzJLDyvU8GEQaZfg6vX8F925lETEKwl5SOFEXP1MhU3QdMp8WiUOkot5T47wY O6rbJFggMg0jJWBp+DbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1llaHC-006avD-FQ; Tue, 25 May 2021 16:51:31 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1llZoq-006NtY-N1; Tue, 25 May 2021 16:22:14 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9F4C3611C2; Tue, 25 May 2021 16:22:11 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1llZon-003WJ7-P2; Tue, 25 May 2021 17:22:09 +0100 Date: Tue, 25 May 2021 17:22:08 +0100 Message-ID: <878s42wzpr.wl-maz@kernel.org> From: Marc Zyngier To: Catalin Marinas Cc: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Will Deacon , Ard Biesheuvel , Mark Rutland , James Morse , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , Eric Biederman , Bhupesh SHARMA , AKASHI Takahiro , kernel-team@android.com Subject: Re: [PATCH 0/2] arm64: kexec_file_load vs memory reservations In-Reply-To: <20210519151942.GB21619@arm.com> References: <20210429133533.1750721-1-maz@kernel.org> <20210519151942.GB21619@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: catalin.marinas@arm.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, will@kernel.org, ardb@kernel.org, mark.rutland@arm.com, james.morse@arm.com, lorenzo.pieralisi@arm.com, guohanjun@huawei.com, sudeep.holla@arm.com, ebiederm@xmission.com, bhupesh.sharma@linaro.org, takahiro.akashi@linaro.org, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210525_092212_831386_6D2006E0 X-CRM114-Status: GOOD ( 32.21 ) 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 Wed, 19 May 2021 16:19:44 +0100, Catalin Marinas wrote: > > On Thu, Apr 29, 2021 at 02:35:31PM +0100, Marc Zyngier wrote: > > It recently became apparent that using kexec with kexec_file_load() on > > arm64 is pretty similar to playing Russian roulette. > > > > Depending on the amount of memory, the HW supported and the firmware > > interface used, your secondary kernel may overwrite critical memory > > regions without which the secondary kernel cannot boot (the GICv3 LPI > > tables being a prime example of such reserved regions). > > > > It turns out that there is at least two ways for reserved memory > > regions to be described to kexec: /proc/iomem for the userspace > > implementation, and memblock.reserved for kexec_file. And of course, > > our LPI tables are only reserved using the resource tree, leading to > > the aforementioned stamping. Similar things could happen with ACPI > > tables as well. > > So which one of these (/proc/iomem and memblock.reserved) would be the > correct option? If none of them, is their intersection any better? /proc/iomem is what we use for userspace, so you'd expect this to be the right thing to use. > Looking at the default kexec_locate_mem_hole(), it uses the resources > tree if !CONFIG_ARCH_KEEP_MEMBLOCK, otherwise memblock. Yup, and funnily enough, forcing a fallback to the resources tree doesn't help either, because the logic used here isn't much better (it takes the RAM areas at face value, without excluding any of the reserved regions that are children of the "System RAM" regions). It's not funny anymore. > PowerPC implements its own arch_kexec_locate_mem_hole() to skip specific > arch regions. We could do something similar for arm64 if the arch code > knows where the LPI reservation is or the ACPI tables. It feels like a bit of a failure to duplicate all that code. I'd consider that the last possible outcome. > If we conclude that we need some intersection of resource reservations > and memblock, maybe we should change the default kexec_locate_mem_hole() > implementation to check for both (e.g. start with the resource tree and > only consider a range valid if not in memblock.reserved). I am more angling towards this. But my worry is that different architectures have already different ways to reserve memory (PPC seems to do their own stuff on top of memblock, x86 I assumes uses the resource tree in a different way than arm64). Anyway, I'll keep digging. M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel