From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Dan Williams <dan.j.williams@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Peter Zijlstra <peterz@infradead.org>,
Vishal L Verma <vishal.l.verma@intel.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
"the arch/x86 maintainers" <x86@kernel.org>,
linux-efi <linux-efi@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>
Subject: Re: [PATCH v6 06/12] arm/efi: EFI soft reservation to memblock
Date: Thu, 10 Oct 2019 08:46:00 +0200 [thread overview]
Message-ID: <CAKv+Gu9X2B1e56DwGw=MDfwgkMmGoNnHM7BZ3dV8LVKOJbZrSA@mail.gmail.com> (raw)
In-Reply-To: <157066230919.1059972.9000449870543851830.stgit@dwillia2-desk3.amr.corp.intel.com>
On Thu, 10 Oct 2019 at 01:19, Dan Williams <dan.j.williams@intel.com> wrote:
>
> UEFI 2.8 defines an EFI_MEMORY_SP attribute bit to augment the
> interpretation of the EFI Memory Types as "reserved for a specific
> purpose".
>
> The proposed Linux behavior for specific purpose memory is that it is
> reserved for direct-access (device-dax) by default and not available for
> any kernel usage, not even as an OOM fallback. Later, through udev
> scripts or another init mechanism, these device-dax claimed ranges can
> be reconfigured and hot-added to the available System-RAM with a unique
> node identifier. This device-dax management scheme implements "soft" in
> the "soft reserved" designation by allowing some or all of the
> reservation to be recovered as typical memory. This policy can be
> disabled at compile-time with CONFIG_EFI_SOFT_RESERVE=n, or runtime with
> efi=nosoftreserve.
>
> For this patch, update the ARM paths that consider
> EFI_CONVENTIONAL_MEMORY to optionally take the EFI_MEMORY_SP attribute
> into account as a reservation indicator. Publish the soft reservation as
> IORES_DESC_SOFT_RESERVED memory, similar to x86.
>
> (Based on an original patch by Ard)
>
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> arch/arm64/mm/mmu.c | 2 ++
> drivers/firmware/efi/arm-init.c | 9 +++++++++
> drivers/firmware/efi/arm-runtime.c | 24 ++++++++++++++++++++++++
> drivers/firmware/efi/libstub/arm32-stub.c | 5 +++++
> drivers/firmware/efi/libstub/random.c | 4 ++++
> 5 files changed, 44 insertions(+)
>
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 60c929f3683b..2c385fe05fde 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -1061,6 +1061,8 @@ int arch_add_memory(int nid, u64 start, u64 size,
> __create_pgd_mapping(swapper_pg_dir, start, __phys_to_virt(start),
> size, PAGE_KERNEL, __pgd_pgtable_alloc, flags);
>
> + memblock_clear_nomap(start, size);
> +
> return __add_pages(nid, start >> PAGE_SHIFT, size >> PAGE_SHIFT,
> restrictions);
> }
> diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c
> index 311cd349a862..904fa09e6a6b 100644
> --- a/drivers/firmware/efi/arm-init.c
> +++ b/drivers/firmware/efi/arm-init.c
> @@ -163,6 +163,15 @@ static __init int is_usable_memory(efi_memory_desc_t *md)
> case EFI_BOOT_SERVICES_DATA:
> case EFI_CONVENTIONAL_MEMORY:
> case EFI_PERSISTENT_MEMORY:
> + /*
> + * Special purpose memory is 'soft reserved', which means it
> + * is set aside initially, but can be hotplugged back in or
> + * be assigned to the dax driver after boot.
> + */
> + if (efi_soft_reserve_enabled() &&
> + (md->attribute & EFI_MEMORY_SP))
> + return false;
> +
> /*
> * According to the spec, these regions are no longer reserved
> * after calling ExitBootServices(). However, we can only use
> diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c
> index e2ac5fa5531b..899b803842bb 100644
> --- a/drivers/firmware/efi/arm-runtime.c
> +++ b/drivers/firmware/efi/arm-runtime.c
> @@ -121,6 +121,30 @@ static int __init arm_enable_runtime_services(void)
> return 0;
> }
>
> + if (efi_soft_reserve_enabled()) {
> + efi_memory_desc_t *md;
> +
> + for_each_efi_memory_desc(md) {
> + int md_size = md->num_pages << EFI_PAGE_SHIFT;
> + struct resource *res;
> +
> + if (!(md->attribute & EFI_MEMORY_SP))
> + continue;
> +
> + res = kzalloc(sizeof(*res), GFP_KERNEL);
> + if (WARN_ON(!res))
> + break;
> +
> + res->start = md->phys_addr;
> + res->end = md->phys_addr + md_size - 1;
> + res->name = "Soft Reserved";
> + res->flags = IORESOURCE_MEM;
> + res->desc = IORES_DESC_SOFT_RESERVED;
> +
> + insert_resource(&iomem_resource, res);
> + }
> + }
> +
> if (efi_runtime_disabled()) {
> pr_info("EFI runtime services will be disabled.\n");
> return 0;
> diff --git a/drivers/firmware/efi/libstub/arm32-stub.c b/drivers/firmware/efi/libstub/arm32-stub.c
> index e8f7aefb6813..3cd54d2096c6 100644
> --- a/drivers/firmware/efi/libstub/arm32-stub.c
> +++ b/drivers/firmware/efi/libstub/arm32-stub.c
> @@ -146,6 +146,11 @@ static efi_status_t reserve_kernel_base(efi_system_table_t *sys_table_arg,
> continue;
>
> case EFI_CONVENTIONAL_MEMORY:
> + /* Skip soft reserved conventional memory */
> + if (efi_soft_reserve_enabled() &&
> + (desc->attribute & EFI_MEMORY_SP))
> + continue;
> +
> /*
> * Reserve the intersection between this entry and the
> * region.
> diff --git a/drivers/firmware/efi/libstub/random.c b/drivers/firmware/efi/libstub/random.c
> index b4b1d1dcb5fd..6c188695e730 100644
> --- a/drivers/firmware/efi/libstub/random.c
> +++ b/drivers/firmware/efi/libstub/random.c
> @@ -46,6 +46,10 @@ static unsigned long get_entry_num_slots(efi_memory_desc_t *md,
> if (md->type != EFI_CONVENTIONAL_MEMORY)
> return 0;
>
> + if (efi_soft_reserve_enabled() &&
> + (md->attribute & EFI_MEMORY_SP))
> + return 0;
> +
> region_end = min((u64)ULONG_MAX, md->phys_addr + md->num_pages*EFI_PAGE_SIZE - 1);
>
> first_slot = round_up(md->phys_addr, align);
>
next prev parent reply other threads:[~2019-10-10 6:46 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-09 23:04 [PATCH v6 00/12] EFI Specific Purpose Memory Support Dan Williams
2019-10-09 23:04 ` [PATCH v6 01/12] acpi/numa: Establish a new drivers/acpi/numa/ directory Dan Williams
2019-10-09 23:04 ` [PATCH v6 02/12] efi: Enumerate EFI_MEMORY_SP Dan Williams
2019-10-09 23:04 ` [PATCH v6 03/12] x86/efi: Push EFI_MEMMAP check into leaf routines Dan Williams
2019-10-09 23:04 ` [PATCH v6 04/12] efi: Common enable/disable infrastructure for EFI soft reservation Dan Williams
2019-10-10 6:36 ` Ard Biesheuvel
2019-10-09 23:05 ` [PATCH v6 05/12] x86/efi: EFI soft reservation to E820 enumeration Dan Williams
2019-10-10 6:44 ` Ard Biesheuvel
2019-10-10 18:31 ` Dan Williams
2019-10-10 18:40 ` Ard Biesheuvel
2019-10-11 2:39 ` Dan Williams
2019-10-11 5:52 ` Ard Biesheuvel
2019-10-11 14:35 ` Dan Williams
2019-10-11 14:38 ` Ard Biesheuvel
2019-10-09 23:05 ` [PATCH v6 06/12] arm/efi: EFI soft reservation to memblock Dan Williams
2019-10-10 6:46 ` Ard Biesheuvel [this message]
2019-10-09 23:05 ` [PATCH v6 07/12] x86/efi: Add efi_fake_mem support for EFI_MEMORY_SP Dan Williams
2019-10-10 7:01 ` Ard Biesheuvel
2019-10-09 23:05 ` [PATCH v6 08/12] lib: Uplevel the pmem "region" ida to a global allocator Dan Williams
2019-10-09 23:05 ` [PATCH v6 09/12] dax: Fix alloc_dax_region() compile warning Dan Williams
2019-10-09 23:05 ` [PATCH v6 10/12] device-dax: Add a driver for "hmem" devices Dan Williams
2019-10-09 23:05 ` [PATCH v6 11/12] acpi/numa/hmat: Register HMAT at device_initcall level Dan Williams
2019-10-09 23:05 ` [PATCH v6 12/12] acpi/numa/hmat: Register "soft reserved" memory as an "hmem" device Dan Williams
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='CAKv+Gu9X2B1e56DwGw=MDfwgkMmGoNnHM7BZ3dV8LVKOJbZrSA@mail.gmail.com' \
--to=ard.biesheuvel@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=vishal.l.verma@intel.com \
--cc=will@kernel.org \
--cc=x86@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: 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).