Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1545931 > unrolled thread

[PATCH 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init()

Started byNicolai Stange <nicstange@gmail.com>
First post2016-12-21 19:30 +0100
Last post2016-12-22 11:30 +0100
Articles 2 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init() Nicolai Stange <nicstange@gmail.com> - 2016-12-21 19:30 +0100
    Re: [PATCH 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init() Nicolai Stange <nicstange@gmail.com> - 2016-12-22 11:30 +0100

#1545931 — [PATCH 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init()

FromNicolai Stange <nicstange@gmail.com>
Date2016-12-21 19:30 +0100
Subject[PATCH 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init()
Message-ID<sQTOh-6Uv-9@gated-at.bofh.it>
Before invoking the arch specific handler, efi_mem_reserve() reserves
the given memory region through memblock.

efi_mem_reserve() can get called after mm_init() though -- through
efi_bgrt_init(), for example. After mm_init(), memblock is dead and should
not be used anymore.

Let efi_mem_reserve() check whether memblock is dead and not do the
reservation if so. Emit a warning from the generic efi_arch mem_reserve()
in this case: if the architecture doesn't provide any other means of
registering the region as reserved, the operation would be a nop.

Fixes: 4bc9f92e64c8 ("x86/efi-bgrt: Use efi_mem_reserve() to avoid copying image data")
Signed-off-by: Nicolai Stange <nicstange@gmail.com>
---
 drivers/firmware/efi/efi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 92914801e388..12b2e3a6d73f 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -403,7 +403,10 @@ u64 __init efi_mem_desc_end(efi_memory_desc_t *md)
 	return end;
 }
 
-void __init __weak efi_arch_mem_reserve(phys_addr_t addr, u64 size) {}
+void __init __weak efi_arch_mem_reserve(phys_addr_t addr, u64 size)
+{
+	WARN(slab_is_available(), "efi_mem_reserve() has no effect");
+}
 
 /**
  * efi_mem_reserve - Reserve an EFI memory region
@@ -419,7 +422,7 @@ void __init __weak efi_arch_mem_reserve(phys_addr_t addr, u64 size) {}
  */
 void __init efi_mem_reserve(phys_addr_t addr, u64 size)
 {
-	if (!memblock_is_region_reserved(addr, size))
+	if (slab_is_available() && !memblock_is_region_reserved(addr, size))
 		memblock_reserve(addr, size);
 
 	/*
-- 
2.11.0

[toc] | [next] | [standalone]


#1546262

FromNicolai Stange <nicstange@gmail.com>
Date2016-12-22 11:30 +0100
Message-ID<sR8Nk-8fG-3@gated-at.bofh.it>
In reply to#1545931
Mika Penttilä <mika.penttila@nextfour.com> writes:

> On 21.12.2016 20:28, Nicolai Stange wrote:
>>  /**
>>   * efi_mem_reserve - Reserve an EFI memory region
>> @@ -419,7 +422,7 @@ void __init __weak efi_arch_mem_reserve(phys_addr_t addr, u64 size) {}
>>   */
>>  void __init efi_mem_reserve(phys_addr_t addr, u64 size)
>>  {
>> -	if (!memblock_is_region_reserved(addr, size))
>> +	if (slab_is_available() && !memblock_is_region_reserved(addr, size))
>>  		memblock_reserve(addr, size);
> Maybe !slab_is_available() ?

You're right, thanks for catching this!

Fixed in v2 at http://lkml.kernel.org/r/20161222102340.2689-2-nicstange@gmail.com

Thanks,

Nicolai

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web