From: Marc Zyngier <maz@kernel.org> To: Catalin Marinas <catalin.marinas@arm.com> Cc: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Will Deacon <will@kernel.org>, Ard Biesheuvel <ardb@kernel.org>, Mark Rutland <mark.rutland@arm.com>, James Morse <james.morse@arm.com>, Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>, Hanjun Guo <guohanjun@huawei.com>, Sudeep Holla <sudeep.holla@arm.com>, Eric Biederman <ebiederm@xmission.com>, Bhupesh SHARMA <bhupesh.sharma@linaro.org>, AKASHI Takahiro <takahiro.akashi@linaro.org>, kernel-team@android.com Subject: Re: [PATCH 0/2] arm64: kexec_file_load vs memory reservations Date: Tue, 25 May 2021 17:22:08 +0100 [thread overview] Message-ID: <878s42wzpr.wl-maz@kernel.org> (raw) In-Reply-To: <20210519151942.GB21619@arm.com> On Wed, 19 May 2021 16:19:44 +0100, Catalin Marinas <catalin.marinas@arm.com> 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
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org> To: Catalin Marinas <catalin.marinas@arm.com> Cc: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Will Deacon <will@kernel.org>, Ard Biesheuvel <ardb@kernel.org>, Mark Rutland <mark.rutland@arm.com>, James Morse <james.morse@arm.com>, Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>, Hanjun Guo <guohanjun@huawei.com>, Sudeep Holla <sudeep.holla@arm.com>, Eric Biederman <ebiederm@xmission.com>, Bhupesh SHARMA <bhupesh.sharma@linaro.org>, AKASHI Takahiro <takahiro.akashi@linaro.org>, kernel-team@android.com Subject: Re: [PATCH 0/2] arm64: kexec_file_load vs memory reservations Date: Tue, 25 May 2021 17:22:08 +0100 [thread overview] Message-ID: <878s42wzpr.wl-maz@kernel.org> (raw) In-Reply-To: <20210519151942.GB21619@arm.com> On Wed, 19 May 2021 16:19:44 +0100, Catalin Marinas <catalin.marinas@arm.com> 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. _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2021-05-25 16:54 UTC|newest] Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-29 13:35 [PATCH 0/2] arm64: kexec_file_load vs memory reservations Marc Zyngier 2021-04-29 13:35 ` Marc Zyngier 2021-04-29 13:35 ` [PATCH 1/2] firmware/efi: Tell memblock about EFI reservations Marc Zyngier 2021-04-29 13:35 ` Marc Zyngier 2021-05-03 18:56 ` Moritz Fischer 2021-05-03 18:56 ` Moritz Fischer 2021-05-13 3:20 ` Dave Young 2021-05-13 3:20 ` Dave Young 2021-05-13 11:11 ` Marc Zyngier 2021-05-13 11:11 ` Marc Zyngier 2021-04-29 13:35 ` [PATCH 2/2] ACPI: arm64: Reserve the ACPI tables in memblock Marc Zyngier 2021-04-29 13:35 ` Marc Zyngier 2021-05-03 18:57 ` Moritz Fischer 2021-05-03 18:57 ` Moritz Fischer 2021-05-12 18:04 ` [PATCH 0/2] arm64: kexec_file_load vs memory reservations Marc Zyngier 2021-05-12 18:04 ` Marc Zyngier 2021-05-13 3:17 ` Dave Young 2021-05-13 3:17 ` Dave Young 2021-05-13 11:07 ` Marc Zyngier 2021-05-13 11:07 ` Marc Zyngier 2021-05-18 11:48 ` Will Deacon 2021-05-18 11:48 ` Will Deacon 2021-05-18 14:23 ` Bhupesh Sharma 2021-05-18 14:23 ` Bhupesh Sharma 2021-05-19 15:19 ` Catalin Marinas 2021-05-19 15:19 ` Catalin Marinas 2021-05-25 16:22 ` Marc Zyngier [this message] 2021-05-25 16:22 ` Marc Zyngier 2021-06-02 14:22 ` James Morse 2021-06-02 14:22 ` James Morse 2021-06-02 15:59 ` Marc Zyngier 2021-06-02 15:59 ` Marc Zyngier 2021-06-02 16:58 ` James Morse 2021-06-02 16:58 ` James Morse
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=878s42wzpr.wl-maz@kernel.org \ --to=maz@kernel.org \ --cc=ardb@kernel.org \ --cc=bhupesh.sharma@linaro.org \ --cc=catalin.marinas@arm.com \ --cc=ebiederm@xmission.com \ --cc=guohanjun@huawei.com \ --cc=james.morse@arm.com \ --cc=kernel-team@android.com \ --cc=kexec@lists.infradead.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=lorenzo.pieralisi@arm.com \ --cc=mark.rutland@arm.com \ --cc=sudeep.holla@arm.com \ --cc=takahiro.akashi@linaro.org \ --cc=will@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.