From: Ard Biesheuvel <ard.biesheuvel@linaro.org> To: linux-arm-kernel@lists.infradead.org Cc: mark.rutland@arm.com, linux-efi@vger.kernel.org, Ard Biesheuvel <ard.biesheuvel@linaro.org>, marc.zyngier@arm.com, bhsharma@redhat.com, will.deacon@arm.com, Russell King <linux@armlinux.org.uk> Subject: [PATCH 2/4] efi/arm: defer persistent reservations until after paging_init() Date: Tue, 6 Nov 2018 12:37:30 +0100 [thread overview] Message-ID: <20181106113732.16351-3-ard.biesheuvel@linaro.org> (raw) In-Reply-To: <20181106113732.16351-1-ard.biesheuvel@linaro.org> The new memory EFI reservation feature we introduced to allow memory reservations to persist across kexec may trigger an unbounded number of calls to memblock_reserve(). The memblock subsystem can deal with this fine, but not before memblock resizing is enabled, which we can only do after paging_init(), when the memory we reallocate the array into is actually mapped. So break out the memreserve table processing into a separate function and call if after paging_init() on both arm64 and ARM. Cc: Russell King <linux@armlinux.org.uk> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- arch/arm/kernel/setup.c | 1 + arch/arm64/kernel/setup.c | 1 + drivers/firmware/efi/efi.c | 8 ++++++-- include/linux/efi.h | 7 +++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index ac7e08886863..e99f12eaf390 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -1117,6 +1117,7 @@ void __init setup_arch(char **cmdline_p) early_ioremap_reset(); paging_init(mdesc); + efi_apply_persistent_mem_reservations(); request_standard_resources(mdesc); if (mdesc->restart) diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 953e316521fc..f4fc1e0544b7 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p) arm64_memblock_init(); paging_init(); + efi_apply_persistent_mem_reservations(); acpi_table_upgrade(); diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 249eb70691b0..55e4ea20bdc3 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -592,7 +592,11 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, early_memunmap(tbl, sizeof(*tbl)); } + return 0; +} +int __init efi_apply_persistent_mem_reservations(void) +{ if (efi.mem_reserve != EFI_INVALID_TABLE_ADDR) { unsigned long prsv = efi.mem_reserve; @@ -602,7 +606,7 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, /* reserve the entry itself */ memblock_reserve(prsv, sizeof(*rsv)); - rsv = early_memremap(prsv, sizeof(*rsv)); + rsv = memremap(prsv, sizeof(*rsv), MEMREMAP_WB); if (rsv == NULL) { pr_err("Could not map UEFI memreserve entry!\n"); return -ENOMEM; @@ -612,7 +616,7 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, memblock_reserve(rsv->base, rsv->size); prsv = rsv->next; - early_memunmap(rsv, sizeof(*rsv)); + memunmap(rsv); } } diff --git a/include/linux/efi.h b/include/linux/efi.h index 845174e113ce..100ce4a4aff6 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1167,6 +1167,8 @@ static inline bool efi_enabled(int feature) extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused); extern bool efi_is_table_address(unsigned long phys_addr); + +extern int efi_apply_persistent_mem_reservations(void); #else static inline bool efi_enabled(int feature) { @@ -1185,6 +1187,11 @@ static inline bool efi_is_table_address(unsigned long phys_addr) { return false; } + +static inline int efi_apply_persistent_mem_reservations(void) +{ + return 0; +} #endif extern int efi_status_to_err(efi_status_t status); -- 2.19.1
WARNING: multiple messages have this Message-ID (diff)
From: ard.biesheuvel@linaro.org (Ard Biesheuvel) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/4] efi/arm: defer persistent reservations until after paging_init() Date: Tue, 6 Nov 2018 12:37:30 +0100 [thread overview] Message-ID: <20181106113732.16351-3-ard.biesheuvel@linaro.org> (raw) In-Reply-To: <20181106113732.16351-1-ard.biesheuvel@linaro.org> The new memory EFI reservation feature we introduced to allow memory reservations to persist across kexec may trigger an unbounded number of calls to memblock_reserve(). The memblock subsystem can deal with this fine, but not before memblock resizing is enabled, which we can only do after paging_init(), when the memory we reallocate the array into is actually mapped. So break out the memreserve table processing into a separate function and call if after paging_init() on both arm64 and ARM. Cc: Russell King <linux@armlinux.org.uk> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- arch/arm/kernel/setup.c | 1 + arch/arm64/kernel/setup.c | 1 + drivers/firmware/efi/efi.c | 8 ++++++-- include/linux/efi.h | 7 +++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index ac7e08886863..e99f12eaf390 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -1117,6 +1117,7 @@ void __init setup_arch(char **cmdline_p) early_ioremap_reset(); paging_init(mdesc); + efi_apply_persistent_mem_reservations(); request_standard_resources(mdesc); if (mdesc->restart) diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 953e316521fc..f4fc1e0544b7 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p) arm64_memblock_init(); paging_init(); + efi_apply_persistent_mem_reservations(); acpi_table_upgrade(); diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 249eb70691b0..55e4ea20bdc3 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -592,7 +592,11 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, early_memunmap(tbl, sizeof(*tbl)); } + return 0; +} +int __init efi_apply_persistent_mem_reservations(void) +{ if (efi.mem_reserve != EFI_INVALID_TABLE_ADDR) { unsigned long prsv = efi.mem_reserve; @@ -602,7 +606,7 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, /* reserve the entry itself */ memblock_reserve(prsv, sizeof(*rsv)); - rsv = early_memremap(prsv, sizeof(*rsv)); + rsv = memremap(prsv, sizeof(*rsv), MEMREMAP_WB); if (rsv == NULL) { pr_err("Could not map UEFI memreserve entry!\n"); return -ENOMEM; @@ -612,7 +616,7 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, memblock_reserve(rsv->base, rsv->size); prsv = rsv->next; - early_memunmap(rsv, sizeof(*rsv)); + memunmap(rsv); } } diff --git a/include/linux/efi.h b/include/linux/efi.h index 845174e113ce..100ce4a4aff6 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1167,6 +1167,8 @@ static inline bool efi_enabled(int feature) extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused); extern bool efi_is_table_address(unsigned long phys_addr); + +extern int efi_apply_persistent_mem_reservations(void); #else static inline bool efi_enabled(int feature) { @@ -1185,6 +1187,11 @@ static inline bool efi_is_table_address(unsigned long phys_addr) { return false; } + +static inline int efi_apply_persistent_mem_reservations(void) +{ + return 0; +} #endif extern int efi_status_to_err(efi_status_t status); -- 2.19.1
next prev parent reply other threads:[~2018-11-06 11:37 UTC|newest] Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-11-06 11:37 [PATCH 0/4] arm/efi: fix memblock reallocation crash due to persistent reservations Ard Biesheuvel 2018-11-06 11:37 ` Ard Biesheuvel 2018-11-06 11:37 ` [PATCH 1/4] arm64: memblock: don't permit memblock resizing until linear mapping is up Ard Biesheuvel 2018-11-06 11:37 ` Ard Biesheuvel 2018-11-06 21:22 ` Will Deacon 2018-11-06 21:22 ` Will Deacon 2018-11-06 11:37 ` Ard Biesheuvel [this message] 2018-11-06 11:37 ` [PATCH 2/4] efi/arm: defer persistent reservations until after paging_init() Ard Biesheuvel 2018-11-06 19:02 ` Ard Biesheuvel 2018-11-06 19:02 ` Ard Biesheuvel 2018-11-06 19:08 ` Russell King - ARM Linux 2018-11-06 19:08 ` Russell King - ARM Linux 2018-11-06 20:06 ` Ard Biesheuvel 2018-11-06 20:06 ` Ard Biesheuvel 2018-11-06 23:49 ` Russell King - ARM Linux 2018-11-06 23:49 ` Russell King - ARM Linux 2018-11-07 9:51 ` Marc Zyngier 2018-11-07 9:51 ` Marc Zyngier 2018-11-07 9:58 ` Russell King - ARM Linux 2018-11-07 9:58 ` Russell King - ARM Linux 2018-11-07 10:04 ` Ard Biesheuvel 2018-11-07 10:04 ` Ard Biesheuvel 2018-11-07 10:24 ` Russell King - ARM Linux 2018-11-07 10:24 ` Russell King - ARM Linux 2018-11-06 11:37 ` [PATCH 3/4] efi: permit multiple entries in persistent memreserve data structure Ard Biesheuvel 2018-11-06 11:37 ` Ard Biesheuvel 2018-11-06 11:37 ` [PATCH 4/4] efi: reduce the amount of memblock reservations for persistent allocations Ard Biesheuvel 2018-11-06 11:37 ` Ard Biesheuvel 2018-11-06 18:27 ` [PATCH 0/4] arm/efi: fix memblock reallocation crash due to persistent reservations Marc Zyngier 2018-11-06 18:27 ` Marc Zyngier 2018-11-06 19:01 ` Ard Biesheuvel 2018-11-06 19:01 ` Ard Biesheuvel 2018-11-06 19:40 ` Marc Zyngier 2018-11-06 19:40 ` Marc Zyngier 2018-11-06 21:34 ` Will Deacon 2018-11-06 21:34 ` Will Deacon 2018-11-06 21:39 ` Ard Biesheuvel 2018-11-06 21:39 ` Ard Biesheuvel 2018-11-06 21:46 ` Will Deacon 2018-11-06 21:46 ` Will Deacon
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=20181106113732.16351-3-ard.biesheuvel@linaro.org \ --to=ard.biesheuvel@linaro.org \ --cc=bhsharma@redhat.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-efi@vger.kernel.org \ --cc=linux@armlinux.org.uk \ --cc=marc.zyngier@arm.com \ --cc=mark.rutland@arm.com \ --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: 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.