From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: From: Marc Zyngier Subject: [PATCH 0/2] arm64: kexec_file_load vs memory reservations Date: Thu, 29 Apr 2021 14:35:31 +0100 Message-Id: <20210429133533.1750721-1-maz@kernel.org> MIME-Version: 1.0 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: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Catalin Marinas , Will Deacon , Ard Biesheuvel , Mark Rutland , James Morse , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , Eric Biederman , Bhupesh Sharma , AKASHI Takahiro , kernel-team@android.com 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. On my 24xA53 system artificially limited to 256MB of RAM (yes, it boots with that little memory), trying to kexec a secondary kernel failed every times. I can only presume that this was mostly tested using kdump, which preserves the entire kernel memory range. This small series aims at triggering a discussion on what are the expectations for kexec_file, and whether we should unify the two reservation mechanisms. And in the meantime, it gets things going... Marc Zyngier (2): firmware/efi: Tell memblock about EFI reservations ACPI: arm64: Reserve the ACPI tables in memblock arch/arm64/kernel/acpi.c | 1 + drivers/firmware/efi/efi.c | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) -- 2.29.2 _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec 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=-12.2 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,USER_AGENT_GIT autolearn=ham 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 3CECEC433ED for ; Thu, 29 Apr 2021 13:37:38 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 D826E6144B for ; Thu, 29 Apr 2021 13:37:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D826E6144B 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=jTNizoXHLFYaLPwraljd6jmQpAOw5quQuHKyQ4J/QhM=; b=Nsvi2nWcIT8/xz99XESyuIQ46z U+g2dGGYAheERMpyesKmrg9arQyC0BiLB4bOxhngXpvmudn7O3XtFLbPEf3AcZAp82o9OHGEbsALi 52ZSYcquM/cSRUJGmphyjCx22jDG2nsMGfSU3PrTtFdIFB/dfGuUc6MG4BgUZ/Ewt2wR1weAU9Wvv um863S1R1blT+d7y0Z35E9wmMlW1oplr7SCJ+5FKyWQhzjfHBj0yNHnZ71jBZRjPfOzOg9BKwNS6y 1siCfx3mBrfAWWJv+MWNrUg2zLBczrTjqEI6WtVKYNjurobhmlbDTkSD0Sf/jiCIUqOUVn8xFarGr HqiqHQmw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lc6pz-005hs8-EU; Thu, 29 Apr 2021 13:36:15 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lc6pY-005hpU-8U; Thu, 29 Apr 2021 13:35:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=DaBt8fdXWP8LU0C2yDB/Q2ss+m9nGDZmVjQZneQ477A=; b=PtoF2roU7okWkGaM8Mlu94DyOE wW5JcDjugIXroqZ/ETUxmfel5fzrmBkS/pH63voUWt+HMKwiwr5zFZBF+WVoD7b1FMngcdPIgvLUn +LwCr49wrI7/72NiqIM21MEOQ1qaloevi9RgTwIniQYUs+niSYFH0pk1uxoc11gjjgpXuXZ3f6q1g SrecfZpQS1u3vvq7T7JwPKN7PukzrjqB2avnp9qrXBzqLlFedS7EKY6P187Iu+kPyljzcrk2HSuho jsE+Ri6d+RJuD6SBaJKUSqZ4vn5oF+p4lsmsBU6mnCYZxGrcYvGG38x3orUx0k82PnMfcp3VqV5qp j+4OLJpg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lc6pV-000eiT-PZ; Thu, 29 Apr 2021 13:35:47 +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 E6F19613B4; Thu, 29 Apr 2021 13:35:44 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1lc6pS-00A21L-MI; Thu, 29 Apr 2021 14:35:42 +0100 From: Marc Zyngier To: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Catalin Marinas , 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: [PATCH 0/2] arm64: kexec_file_load vs memory reservations Date: Thu, 29 Apr 2021 14:35:31 +0100 Message-Id: <20210429133533.1750721-1-maz@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, 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, bhsharma@redhat.com, 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-20210429_063545_886043_9F6E754B X-CRM114-Status: GOOD ( 14.56 ) 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 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. On my 24xA53 system artificially limited to 256MB of RAM (yes, it boots with that little memory), trying to kexec a secondary kernel failed every times. I can only presume that this was mostly tested using kdump, which preserves the entire kernel memory range. This small series aims at triggering a discussion on what are the expectations for kexec_file, and whether we should unify the two reservation mechanisms. And in the meantime, it gets things going... Marc Zyngier (2): firmware/efi: Tell memblock about EFI reservations ACPI: arm64: Reserve the ACPI tables in memblock arch/arm64/kernel/acpi.c | 1 + drivers/firmware/efi/efi.c | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) -- 2.29.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel