* [PATCH v2 0/2] efi: Fixes for EFI_MEMORY_SP memory on RISC-V and ARM64
@ 2024-02-02 18:07 Andrew Bresticker
2024-02-02 18:07 ` [PATCH v2 1/2] efi: runtime: Fix potential overflow of soft-reserved region size Andrew Bresticker
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Andrew Bresticker @ 2024-02-02 18:07 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-efi,
linux-kernel, linux-riscv, Andrew Bresticker
Two small fixes to enable the use soft-reserved/special-purpose memory
(EFI_MEMORY_SP) with dax_kmem on RISC-V (and ARM64, I think, though I
don't have a platform to test it on).
Patch 1 fixes a trivial integer narrowing bug. Patch 2 prevents adding
memblocks for soft-reserved memory so that it can later be hotplugged by
dax_kmem.
Tested on a RISC-V platform that presents a range of EFI_MEMORY_SP with
Bjorn's MEMORY_HOTPLUG series[0] applied.
[0]: https://lore.kernel.org/lkml/20230512145737.985671-1-bjorn@kernel.org/
v1->v2: address comments from Ard
Andrew Bresticker (2):
efi: runtime: Fix potential overflow of soft-reserved region size
efi: Don't add memblocks for soft-reserved memory
drivers/firmware/efi/arm-runtime.c | 2 +-
drivers/firmware/efi/efi-init.c | 19 ++++++++++---------
drivers/firmware/efi/riscv-runtime.c | 2 +-
3 files changed, 12 insertions(+), 11 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 1/2] efi: runtime: Fix potential overflow of soft-reserved region size
2024-02-02 18:07 [PATCH v2 0/2] efi: Fixes for EFI_MEMORY_SP memory on RISC-V and ARM64 Andrew Bresticker
@ 2024-02-02 18:07 ` Andrew Bresticker
2024-02-02 18:07 ` [PATCH v2 2/2] efi: Don't add memblocks for soft-reserved memory Andrew Bresticker
2024-02-02 18:28 ` [PATCH v2 0/2] efi: Fixes for EFI_MEMORY_SP memory on RISC-V and ARM64 Ard Biesheuvel
2 siblings, 0 replies; 5+ messages in thread
From: Andrew Bresticker @ 2024-02-02 18:07 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-efi,
linux-kernel, linux-riscv, Andrew Bresticker
md_size will have been narrowed if we have >= 4GB worth of pages in a
soft-reserved region.
Signed-off-by: Andrew Bresticker <abrestic@rivosinc.com>
---
v2: use u64 instead of unsigned long
---
drivers/firmware/efi/arm-runtime.c | 2 +-
drivers/firmware/efi/riscv-runtime.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c
index 83f5bb57fa4c..83092d93f36a 100644
--- a/drivers/firmware/efi/arm-runtime.c
+++ b/drivers/firmware/efi/arm-runtime.c
@@ -107,7 +107,7 @@ static int __init arm_enable_runtime_services(void)
efi_memory_desc_t *md;
for_each_efi_memory_desc(md) {
- int md_size = md->num_pages << EFI_PAGE_SHIFT;
+ u64 md_size = md->num_pages << EFI_PAGE_SHIFT;
struct resource *res;
if (!(md->attribute & EFI_MEMORY_SP))
diff --git a/drivers/firmware/efi/riscv-runtime.c b/drivers/firmware/efi/riscv-runtime.c
index 09525fb5c240..01f0f90ea418 100644
--- a/drivers/firmware/efi/riscv-runtime.c
+++ b/drivers/firmware/efi/riscv-runtime.c
@@ -85,7 +85,7 @@ static int __init riscv_enable_runtime_services(void)
efi_memory_desc_t *md;
for_each_efi_memory_desc(md) {
- int md_size = md->num_pages << EFI_PAGE_SHIFT;
+ u64 md_size = md->num_pages << EFI_PAGE_SHIFT;
struct resource *res;
if (!(md->attribute & EFI_MEMORY_SP))
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 2/2] efi: Don't add memblocks for soft-reserved memory
2024-02-02 18:07 [PATCH v2 0/2] efi: Fixes for EFI_MEMORY_SP memory on RISC-V and ARM64 Andrew Bresticker
2024-02-02 18:07 ` [PATCH v2 1/2] efi: runtime: Fix potential overflow of soft-reserved region size Andrew Bresticker
@ 2024-02-02 18:07 ` Andrew Bresticker
2024-02-02 18:28 ` [PATCH v2 0/2] efi: Fixes for EFI_MEMORY_SP memory on RISC-V and ARM64 Ard Biesheuvel
2 siblings, 0 replies; 5+ messages in thread
From: Andrew Bresticker @ 2024-02-02 18:07 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-efi,
linux-kernel, linux-riscv, Andrew Bresticker
Adding memblocks for soft-reserved regions prevents them from later being
hotplugged in by dax_kmem.
Signed-off-by: Andrew Bresticker <abrestic@rivosinc.com>
---
v2: only skip adding memblocks for soft-reserved mem
---
drivers/firmware/efi/efi-init.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c
index d4987d013080..a00e07b853f2 100644
--- a/drivers/firmware/efi/efi-init.c
+++ b/drivers/firmware/efi/efi-init.c
@@ -143,15 +143,6 @@ 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
@@ -196,6 +187,16 @@ static __init void reserve_regions(void)
size = npages << PAGE_SHIFT;
if (is_memory(md)) {
+ /*
+ * Special purpose memory is 'soft reserved', which
+ * means it is set aside initially. Don't add a memblock
+ * for it now so that it can be hotplugged back in or
+ * be assigned to the dax driver after boot.
+ */
+ if (efi_soft_reserve_enabled() &&
+ (md->attribute & EFI_MEMORY_SP))
+ continue;
+
early_init_dt_add_memory_arch(paddr, size);
if (!is_usable_memory(md))
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2 0/2] efi: Fixes for EFI_MEMORY_SP memory on RISC-V and ARM64
2024-02-02 18:07 [PATCH v2 0/2] efi: Fixes for EFI_MEMORY_SP memory on RISC-V and ARM64 Andrew Bresticker
2024-02-02 18:07 ` [PATCH v2 1/2] efi: runtime: Fix potential overflow of soft-reserved region size Andrew Bresticker
2024-02-02 18:07 ` [PATCH v2 2/2] efi: Don't add memblocks for soft-reserved memory Andrew Bresticker
@ 2024-02-02 18:28 ` Ard Biesheuvel
2024-02-07 1:04 ` Palmer Dabbelt
2 siblings, 1 reply; 5+ messages in thread
From: Ard Biesheuvel @ 2024-02-02 18:28 UTC (permalink / raw)
To: Andrew Bresticker
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-efi,
linux-kernel, linux-riscv
On Fri, 2 Feb 2024 at 19:07, Andrew Bresticker <abrestic@rivosinc.com> wrote:
>
> Two small fixes to enable the use soft-reserved/special-purpose memory
> (EFI_MEMORY_SP) with dax_kmem on RISC-V (and ARM64, I think, though I
> don't have a platform to test it on).
>
> Patch 1 fixes a trivial integer narrowing bug. Patch 2 prevents adding
> memblocks for soft-reserved memory so that it can later be hotplugged by
> dax_kmem.
>
> Tested on a RISC-V platform that presents a range of EFI_MEMORY_SP with
> Bjorn's MEMORY_HOTPLUG series[0] applied.
>
> [0]: https://lore.kernel.org/lkml/20230512145737.985671-1-bjorn@kernel.org/
>
> v1->v2: address comments from Ard
>
> Andrew Bresticker (2):
> efi: runtime: Fix potential overflow of soft-reserved region size
> efi: Don't add memblocks for soft-reserved memory
>
Thanks, I'll take these both as fixes.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] efi: Fixes for EFI_MEMORY_SP memory on RISC-V and ARM64
2024-02-02 18:28 ` [PATCH v2 0/2] efi: Fixes for EFI_MEMORY_SP memory on RISC-V and ARM64 Ard Biesheuvel
@ 2024-02-07 1:04 ` Palmer Dabbelt
0 siblings, 0 replies; 5+ messages in thread
From: Palmer Dabbelt @ 2024-02-07 1:04 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: abrestic, Paul Walmsley, aou, linux-efi, linux-kernel, linux-riscv
On Fri, 02 Feb 2024 10:28:54 PST (-0800), Ard Biesheuvel wrote:
> On Fri, 2 Feb 2024 at 19:07, Andrew Bresticker <abrestic@rivosinc.com> wrote:
>>
>> Two small fixes to enable the use soft-reserved/special-purpose memory
>> (EFI_MEMORY_SP) with dax_kmem on RISC-V (and ARM64, I think, though I
>> don't have a platform to test it on).
>>
>> Patch 1 fixes a trivial integer narrowing bug. Patch 2 prevents adding
>> memblocks for soft-reserved memory so that it can later be hotplugged by
>> dax_kmem.
>>
>> Tested on a RISC-V platform that presents a range of EFI_MEMORY_SP with
>> Bjorn's MEMORY_HOTPLUG series[0] applied.
>>
>> [0]: https://lore.kernel.org/lkml/20230512145737.985671-1-bjorn@kernel.org/
>>
>> v1->v2: address comments from Ard
>>
>> Andrew Bresticker (2):
>> efi: runtime: Fix potential overflow of soft-reserved region size
>> efi: Don't add memblocks for soft-reserved memory
>>
>
> Thanks, I'll take these both as fixes.
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-07 1:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-02 18:07 [PATCH v2 0/2] efi: Fixes for EFI_MEMORY_SP memory on RISC-V and ARM64 Andrew Bresticker
2024-02-02 18:07 ` [PATCH v2 1/2] efi: runtime: Fix potential overflow of soft-reserved region size Andrew Bresticker
2024-02-02 18:07 ` [PATCH v2 2/2] efi: Don't add memblocks for soft-reserved memory Andrew Bresticker
2024-02-02 18:28 ` [PATCH v2 0/2] efi: Fixes for EFI_MEMORY_SP memory on RISC-V and ARM64 Ard Biesheuvel
2024-02-07 1:04 ` Palmer Dabbelt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®