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=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 00B75C4708F for ; Wed, 2 Jun 2021 14:25:57 +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 C4A04610A1 for ; Wed, 2 Jun 2021 14:25:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4A04610A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com 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:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=jnmo41u/SKBDRscodvWM3EteDN890pxA0pI91eVTgvE=; b=2r6WTg9CdBP5BhpH+V4BoW+tFa +iCmR+CjLGnTKQjiImVLTRkkgJGU2uylAXr++OQxjTmT+rvu69QFeMvCgd7h86mpeWtPpt0KAjTnE QUI6WjcVb+guaMi0G02J+ftY/vg8nSWnB3275ua14xDShh1ObQteWSDTrdwmrlF5jw9Jh+PPmWe/f iV+tSZuhHLfZ/jwiSpqJngoU9b2k78PF/SspIXTh011FEmxHOH/9WMrxJORQRaDQxD8QKtQ6FeFRL 1POpoX07BoEMeUkTWEQXhOFIhMWid8u7Cq7F7OlZxAMSRrOPMW2afRabCmcaQmUldYdGcE/fk0luy tLYUNBag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loRlC-004YTx-9M; Wed, 02 Jun 2021 14:22:18 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loRl7-004YSw-55; Wed, 02 Jun 2021 14:22:14 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 299891042; Wed, 2 Jun 2021 07:22:10 -0700 (PDT) Received: from [192.168.0.14] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 186B53F73D; Wed, 2 Jun 2021 07:22:07 -0700 (PDT) Subject: Re: [PATCH 0/2] arm64: kexec_file_load vs memory reservations To: Marc Zyngier , kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Catalin Marinas , Will Deacon , Ard Biesheuvel , Mark Rutland , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , Eric Biederman , Bhupesh Sharma , AKASHI Takahiro , kernel-team@android.com References: <20210429133533.1750721-1-maz@kernel.org> From: James Morse Message-ID: Date: Wed, 2 Jun 2021 15:22:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210429133533.1750721-1-maz@kernel.org> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210602_072213_277739_A58EA49E X-CRM114-Status: GOOD ( 24.90 ) 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 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... > 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? (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) Thanks, James > 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(-) > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel