[PATCH v2 1/2] x86/e820: Expose API to update e820 kexec and firmware tables externally.

Ashish Kalra posted 2 patches 1 year, 10 months ago
There is a newer version of this series
[PATCH v2 1/2] x86/e820: Expose API to update e820 kexec and firmware tables externally.
Posted by Ashish Kalra 1 year, 10 months ago
From: Ashish Kalra <ashish.kalra@amd.com>

Export the API interfaces to update the e820_table_kexec and
e820_table_firmware.

Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
---
 arch/x86/include/asm/e820/api.h | 3 +++
 arch/x86/kernel/e820.c          | 7 ++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/e820/api.h b/arch/x86/include/asm/e820/api.h
index e8f58ddd06d9..09fe1ddcdf2b 100644
--- a/arch/x86/include/asm/e820/api.h
+++ b/arch/x86/include/asm/e820/api.h
@@ -18,6 +18,9 @@ extern void e820__range_add   (u64 start, u64 size, enum e820_type type);
 extern u64  e820__range_update(u64 start, u64 size, enum e820_type old_type, enum e820_type new_type);
 extern u64  e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool check_type);
 
+extern u64 e820__range_update_kexec(u64 start, u64 size, enum e820_type old_type, enum e820_type  new_type);
+extern u64 e820__range_update_firmware(u64 start, u64 size, enum e820_type old_type, enum e820_type new_type);
+
 extern void e820__print_table(char *who);
 extern int  e820__update_table(struct e820_table *table);
 extern void e820__update_table_print(void);
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 6f1b379e3b38..c59d1bbbe3f2 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -532,7 +532,12 @@ u64 __init e820__range_update(u64 start, u64 size, enum e820_type old_type, enum
 	return __e820__range_update(e820_table, start, size, old_type, new_type);
 }
 
-static u64 __init e820__range_update_kexec(u64 start, u64 size, enum e820_type old_type, enum e820_type  new_type)
+u64 __init e820__range_update_firmware(u64 start, u64 size, enum e820_type old_type, enum e820_type new_type)
+{
+	return __e820__range_update(e820_table_firmware, start, size, old_type, new_type);
+}
+
+u64 __init e820__range_update_kexec(u64 start, u64 size, enum e820_type old_type, enum e820_type  new_type)
 {
 	return __e820__range_update(e820_table_kexec, start, size, old_type, new_type);
 }
-- 
2.34.1
Re: [PATCH v2 1/2] x86/e820: Expose API to update e820 kexec and firmware tables externally.
Posted by Borislav Petkov 1 year, 9 months ago
On Mon, Apr 15, 2024 at 09:09:10PM +0000, Ashish Kalra wrote:
> -static u64 __init e820__range_update_kexec(u64 start, u64 size, enum e820_type old_type, enum e820_type  new_type)
> +u64 __init e820__range_update_firmware(u64 start, u64 size, enum e820_type old_type, enum e820_type new_type)
> +{
> +	return __e820__range_update(e820_table_firmware, start, size, old_type, new_type);
> +}
> +
> +u64 __init e820__range_update_kexec(u64 start, u64 size, enum e820_type old_type, enum e820_type  new_type)

Yah, no point in defining silly wrappers _kexec() and _firmware() if the
actual e820 tables are already exported in asm/e820/api.h

You need a single

e820__range_update_table(struct e820_table *t, ..)

helper and move all current and future users to it while leaving
e820__range_update() alone which works on the e820_table.

As a future cleanup, e820__range_update() should be changed to use the
new e820__range_update_table() helper and then perhaps all code should
be converted back to a new

e820__range_update()

which takes a table as a first argument.

But the cleanup can go in later, after the current issue has been
resolved.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette