From: James Morse <james.morse@arm.com>
To: John Stultz <john.stultz@linaro.org>,
AKASHI Takahiro <takahiro.akashi@linaro.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Len Brown <lenb@kernel.org>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Mark Rutland <mark.rutland@arm.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
G Gregory <graeme.gregory@linaro.org>,
al.stone@linaro.org, bhsharma@redhat.com, tbaicar@codeaurora.org,
kexec@lists.infradead.org, lkml <linux-kernel@vger.kernel.org>,
hanjun.guo@linaro.org, Sudeep Holla <sudeep.holla@arm.com>,
dyoung@redhat.com,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v4 1/5] arm64: export memblock_reserve()d regions via /proc/iomem
Date: Tue, 21 Aug 2018 17:48:05 +0100 [thread overview]
Message-ID: <55a21245-7bc2-a700-20ce-1103fbadf72b@arm.com> (raw)
In-Reply-To: <38e0224a-46f8-85c3-abe2-5e89d16810ea@arm.com>
On 08/21/2018 11:22 AM, James Morse wrote:
> On 08/21/2018 05:39 AM, John Stultz wrote:
>> On Sun, Jul 22, 2018 at 6:57 PM, AKASHI Takahiro
>> <takahiro.akashi@linaro.org> wrote:
>>> From: James Morse <james.morse@arm.com>
>>>
>>> There has been some confusion around what is necessary to prevent kexec
>>> overwriting important memory regions. memblock: reserve, or nomap?
>>> Only memblock nomap regions are reported via /proc/iomem, kexec's
>>> user-space doesn't know about memblock_reserve()d regions.
>>>
>>> Until commit f56ab9a5b73ca ("efi/arm: Don't mark ACPI reclaim memory
>>> as MEMBLOCK_NOMAP") the ACPI tables were nomap, now they are reserved
>>> and thus possible for kexec to overwrite with the new kernel or initrd.
>>> But this was always broken, as the UEFI memory map is also reserved
>>> and not marked as nomap.
>>>
>>> Exporting both nomap and reserved memblock types is a nuisance as
>>> they live in different memblock structures which we can't walk at
>>> the same time.
>>>
>>> Take a second walk over memblock.reserved and add new 'reserved'
>>> subnodes for the memblock_reserved() regions that aren't already
>>> described by the existing code. (e.g. Kernel Code)
>>>
>>> We use reserve_region_with_split() to find the gaps in existing named
>>> regions. This handles the gap between 'kernel code' and 'kernel data'
>>> which is memblock_reserve()d, but already partially described by
>>> request_standard_resources(). e.g.:
>>> | 80000000-dfffffff : System RAM
>>> | 80080000-80ffffff : Kernel code
>>> | 81000000-8158ffff : reserved
>>> | 81590000-8237efff : Kernel data
>>> | a0000000-dfffffff : Crash kernel
>>> | e00f0000-f949ffff : System RAM
>>>
>>> reserve_region_with_split needs kzalloc() which isn't available when
>>> request_standard_resources() is called, use an initcall.
>
>>> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
>>> index 30ad2f085d1f..5b4fac434c84 100644
>>> --- a/arch/arm64/kernel/setup.c
>>> +++ b/arch/arm64/kernel/setup.c
>>> @@ -241,6 +241,44 @@ static void __init request_standard_resources(void)
>
>>> +static int __init reserve_memblock_reserved_regions(void)
>
>>> + for_each_reserved_mem_region(i, &start, &end) {
>>> + if (end <= roundup_end)
>>> + continue; /* done already */
>>> +
>>> + start = __pfn_to_phys(PFN_DOWN(start));
>>> + end = __pfn_to_phys(PFN_UP(end)) - 1;
>>> + roundup_end = end;
>>> +
>>> + res = kzalloc(sizeof(*res), GFP_ATOMIC);
>>> + if (WARN_ON(!res))
>>> + return -ENOMEM;
>>> + res->start = start;
>>> + res->end = end;
>>> + res->name = "reserved";
>>> + res->flags = IORESOURCE_MEM;
>>> +
>>> + mem = request_resource_conflict(&iomem_resource, res);
>>> + /*
>>> + * We expected memblock_reserve() regions to conflict with
>>> + * memory created by request_standard_resources().
>>> + */
>>> + if (WARN_ON_ONCE(!mem))
>> Since this patch landed, on the HiKey board at bootup I'm seeing:
>>
>> [ 0.451884] WARNING: CPU: 1 PID: 1 at arch/arm64/kernel/setup.c:271
>> reserve_memblock_reserved_regions+0xd4/0x13c
>> From skimming the patch, it seems this is maybe expected? Or should
>> this warning raise eyebrows? I can't quite figure it out.
>
> Ugh, sorry for the noise! This is warning that there is something wrong
> with our assumptions about what types of memory exist.
>
>
>> It seems to trigger on the pstore memory at 0x21f00000-0x21ffffff.
>
> ... pmem ...
> So, this is a memblock_reserved() range that isn't actually memory.
>
> This happens because your DT has carved these regions out of the memory
> node, but added a named 'reserved-memory' region for them, just in case?
> I'm not sure what it means if 'reserved-memory' is not also described as
> memory....
>
> You do need the carve-out, otherwise this gets covered by the linear
> map, and when you throw in that 'unbuffered' property you get both a
> cacheable and uncacheable mapping of the same page.
Hmm, looks like its (even) more complicated than I thought, of_reserved_mem.c's
definition of 'nomap' is memblock_remove(), not memblock_mark_nomap().
This might be more common to all users of DTs memreserve.
Thanks,
James
next prev parent reply other threads:[~2018-08-21 16:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-23 1:57 [PATCH v4 0/5] arm64: kexec,kdump: fix boot failures on acpi-only system AKASHI Takahiro
2018-07-23 1:57 ` [PATCH v4 1/5] arm64: export memblock_reserve()d regions via /proc/iomem AKASHI Takahiro
2018-08-21 4:39 ` John Stultz
2018-08-21 6:07 ` AKASHI Takahiro
2018-08-21 10:22 ` James Morse
2018-08-21 16:48 ` James Morse [this message]
2018-08-21 19:38 ` John Stultz
2018-08-23 12:35 ` James Morse
2018-07-23 1:57 ` [PATCH v4 2/5] drivers: acpi: add dependency of EFI for arm64 AKASHI Takahiro
2018-07-23 1:57 ` [PATCH v4 3/5] efi/arm: preserve early mapping of UEFI memory map longer for BGRT AKASHI Takahiro
2018-07-23 1:57 ` [PATCH v4 4/5] efi/arm: map UEFI memory map even w/o runtime services enabled AKASHI Takahiro
2018-07-23 1:57 ` [PATCH v4 5/5] arm64: acpi: fix alignment fault in accessing ACPI AKASHI Takahiro
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=55a21245-7bc2-a700-20ce-1103fbadf72b@arm.com \
--to=james.morse@arm.com \
--cc=al.stone@linaro.org \
--cc=ard.biesheuvel@linaro.org \
--cc=bhsharma@redhat.com \
--cc=catalin.marinas@arm.com \
--cc=dyoung@redhat.com \
--cc=graeme.gregory@linaro.org \
--cc=hanjun.guo@linaro.org \
--cc=john.stultz@linaro.org \
--cc=kexec@lists.infradead.org \
--cc=lenb@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=mark.rutland@arm.com \
--cc=rjw@rjwysocki.net \
--cc=sudeep.holla@arm.com \
--cc=takahiro.akashi@linaro.org \
--cc=tbaicar@codeaurora.org \
--cc=will.deacon@arm.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).