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 BAE00C47083 for ; Wed, 2 Jun 2021 16:02:41 +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 8A42661582 for ; Wed, 2 Jun 2021 16:02:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A42661582 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=IUT0s8N0gDJm84+6ANE0gMgnRxjxKAEybhgIX0PXxPA=; b=VQiJ5gyElef50Z 8wLF6iCLv+H3mKLVRGgtkHDTGgdywl1fCIShMNVepzMwhjpHx2gqwLNQhQjJI0/OPO8dNiO/RD968 jzt7SGrb6vzAxM0pVVcOMO4JUj7IVLvECBojp/zZI+KNxkYblnF4aQQanSlLlcaqIvSht/xTz+l9D l9w8XOFnuVRuAm9DQXbqHbCVC37CY5ZbdmgJKblsPWDD0k4Rufff9eLi5M7bnZVsxXOn1KiT2OTBY OFhmiLURR700l8OGviIcx7Zs0+L/n20uWwhnW2txXok+ubfUMAdX2hfcBEdzj076c0Syy5fo9GOHZ wMzAaBWUGd76jXditB1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loTIi-004zWQ-5D; Wed, 02 Jun 2021 16:01:00 +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 1loTH0-004yFv-Un; Wed, 02 Jun 2021 15:59:16 +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 95D2C61466; Wed, 2 Jun 2021 15:59:14 +0000 (UTC) Received: from 82-132-234-54.dab.02.net ([82.132.234.54] 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 1loTGy-0055D9-Eq; Wed, 02 Jun 2021 16:59:12 +0100 Date: Wed, 02 Jun 2021 16:59:09 +0100 Message-ID: <8735u01cmq.wl-maz@kernel.org> From: Marc Zyngier To: James Morse Cc: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Ard Biesheuvel , Mark Rutland , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , Eric Biederman , Bhupesh Sharma , AKASHI Takahiro , kernel-team@android.com, Moritz Fischer Subject: Re: [PATCH 0/2] arm64: kexec_file_load vs memory reservations In-Reply-To: References: <20210429133533.1750721-1-maz@kernel.org> 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: 82.132.234.54 X-SA-Exim-Rcpt-To: james.morse@arm.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, ardb@kernel.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, guohanjun@huawei.com, sudeep.holla@arm.com, ebiederm@xmission.com, bhsharma@redhat.com, takahiro.akashi@linaro.org, kernel-team@android.com, mdf@kernel.org 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-20210602_085915_067146_E6057DE2 X-CRM114-Status: GOOD ( 30.11 ) 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 Hi James, On Wed, 02 Jun 2021 15:22:00 +0100, James Morse wrote: > > Hi Marc, > > On 29/04/2021 14:35, 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. > > One is spilled into the other by request_standard_resources()... > > > > And of course, > > our LPI tables are only reserved using the resource tree, leading to > > the aforementioned stamping. > > Presumably well after efi_init() has run... Yup, much later. And we can keep on reserving memory as long as we boot new CPUs. Having it as a one-off sync doesn't really help here. > > > Similar things could happen with ACPI tables as well. > > efi_init() calls reserve_regions(), which has: > | /* keep ACPI reclaim memory intact for kexec etc. */ > | if (md->type == EFI_ACPI_RECLAIM_MEMORY) > | memblock_reserve(paddr, size); > > This is also what stops mm from allocating them, as > memblock-reserved gets copied into the PG_Reserved flag by > free_low_memory_core_early()'s calls to reserve_bootmem_region(). > > Is your machines firmware putting them in a region with a different type? Good question. Moritz (cc'd) saw the tables being overwritten on his system (which I don't have access to), so I guess this is not entirely clear cut how this happens. My SQ box reports the ACPI region as "ACPI Reclaim", so I guess it works as expected here. > (The UEFI spec has something to say: see 2.3.6 "AArch64 Platforms": > | ACPI Tables loaded at boot time can be contained in memory of type EfiACPIReclaimMemory > | (recommended) or EfiACPIMemoryNVS > > NVS would fail the is_usable_memory() check earlier, so gets treated > as nomap) Note that I've since changed tactics and proposed that we fully rely on the resource tree instead[1]. Thanks, M. [1] https://lore.kernel.org/r/20210531095720.77469-1-maz@kernel.org -- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Date: Wed, 02 Jun 2021 16:59:09 +0100 Message-ID: <8735u01cmq.wl-maz@kernel.org> From: Marc Zyngier Subject: Re: [PATCH 0/2] arm64: kexec_file_load vs memory reservations In-Reply-To: References: <20210429133533.1750721-1-maz@kernel.org> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") 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: James Morse Cc: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Ard Biesheuvel , Mark Rutland , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , Eric Biederman , Bhupesh Sharma , AKASHI Takahiro , kernel-team@android.com, Moritz Fischer Hi James, On Wed, 02 Jun 2021 15:22:00 +0100, James Morse wrote: > > Hi Marc, > > On 29/04/2021 14:35, 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. > > One is spilled into the other by request_standard_resources()... > > > > And of course, > > our LPI tables are only reserved using the resource tree, leading to > > the aforementioned stamping. > > Presumably well after efi_init() has run... Yup, much later. And we can keep on reserving memory as long as we boot new CPUs. Having it as a one-off sync doesn't really help here. > > > Similar things could happen with ACPI tables as well. > > efi_init() calls reserve_regions(), which has: > | /* keep ACPI reclaim memory intact for kexec etc. */ > | if (md->type == EFI_ACPI_RECLAIM_MEMORY) > | memblock_reserve(paddr, size); > > This is also what stops mm from allocating them, as > memblock-reserved gets copied into the PG_Reserved flag by > free_low_memory_core_early()'s calls to reserve_bootmem_region(). > > Is your machines firmware putting them in a region with a different type? Good question. Moritz (cc'd) saw the tables being overwritten on his system (which I don't have access to), so I guess this is not entirely clear cut how this happens. My SQ box reports the ACPI region as "ACPI Reclaim", so I guess it works as expected here. > (The UEFI spec has something to say: see 2.3.6 "AArch64 Platforms": > | ACPI Tables loaded at boot time can be contained in memory of type EfiACPIReclaimMemory > | (recommended) or EfiACPIMemoryNVS > > NVS would fail the is_usable_memory() check earlier, so gets treated > as nomap) Note that I've since changed tactics and proposed that we fully rely on the resource tree instead[1]. Thanks, M. [1] https://lore.kernel.org/r/20210531095720.77469-1-maz@kernel.org -- Without deviation from the norm, progress is not possible. _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec