x86/ioremap: clean up the mess in xxx_is_setup_data
Subsystems (4)
cover x86/ioremap: clean up the mess in xxx_is_setup_data
Functions memremap_is_setup_data() and early_memremap_is_setup_data() share completely the same process and handling, except of the different memremap/unmap invocations. The code can be extracted and put into a helper function __memremap_is_setup_data().
And parameter 'size' is unused in implementation of memremap_is_efi_data(), memremap_is_setup_data and early_memremap_is_setup_data().
This patchset is made to clean them up. It sits on top of tip/x86/urgent commit 8d9ffb2fe65a ("x86/mm: Fix a kdump kernel failure on SME system when CONFIG_IMA_KEXEC=y")
Baoquan He (3):
x86/ioremap: introduce helper to check if physical address is in
setup_data
x86/ioremap: use helper to implement xxx_is_setup_data() x86/mm: clean up unused parameters of functions
arch/x86/mm/ioremap.c | 117 +++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 76 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/3 x86/ioremap: introduce helper to check if physical address is in setup_data
Functions memremap_is_setup_data() and early_memremap_is_setup_data() share completely the same process and handling, except of the different memremap/unmap invocations.
Add helper __memremap_is_setup_data() to extract the common part, parameter 'early' is used to decide what kind of memremap/unmap APIs are called.
--- arch/x86/mm/ioremap.c | 81 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)
arch/x86/mm/ioremap.c +81 -0
@@ -628,6 +628,87 @@ static bool memremap_is_efi_data(resource_size_t phys_addr,return false; } +#define SD_SIZE sizeof(struct setup_data) +/* +* Examine the physical address to determine if it is boot data by checking +* it against the boot params setup_data chain. +*/ +static bool __init __memremap_is_setup_data (resource_size_t phys_addr, +bool early) +{ +struct setup_indirect *indirect; +struct setup_data *data; +u64 paddr, paddr_next; + + paddr = boot_params.hdr.setup_data; +while (paddr) { +unsigned int len, size; + +if (phys_addr == paddr) +return true; + +if (early) + data =early_memremap_decrypted (paddr,SD_SIZE ); +else + data =memremap (paddr,SD_SIZE , +MEMREMAP_WB |MEMREMAP_DEC ); +if (!data) { +pr_warn ("failed to memremap setup_data entry\n" ); +return false; + } + + size =SD_SIZE ; + + paddr_next = data->next; + len = data->len; + +if ((phys_addr > paddr) && + (phys_addr < (paddr +SD_SIZE + len))) { +if (early) +early_memunmap (data,SD_SIZE ); +else +memunmap (data); +return true; + } + +if (data->type ==SETUP_INDIRECT ) { + size += len; +if (early) { +early_memunmap (data,SD_SIZE ); + data =early_memremap_decrypted (paddr, size); + }else { +memunmap (data); + data =memremap (paddr, size, +MEMREMAP_WB |MEMREMAP_DEC ); + } +if (!data) { +pr_warn ("failed to memremap indirect setup_data\n" ); +return false; + } + + indirect = (struct setup_indirect *)data->data; + +if (indirect->type !=SETUP_INDIRECT ) { + paddr = indirect->addr; + len = indirect->len; + } + } + +if (early) +early_memunmap (data, size); +else +memunmap (data); + +if ((phys_addr > paddr) && (phys_addr < (paddr + len))) +return true; + + paddr = paddr_next; + } + +return false; +} +#undef SD_SIZE +/* * Examine the physical address to determine if it is boot data by checking * it against the boot params setup_data chain.
Signature · 1 line
2.41.0
[tip: x86/mm] x86/ioremap: Introduce helper to check if physical address is in setup_data
The following commit has been merged into the x86/mm branch of tip:
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: e1d30a1f6c2196de359ac7c2726ba07fcd389cc4 Gitweb: https://git.kernel.org/tip/e1d30a1f6c2196de359ac7c2726ba07fcd389cc4 Author: Baoquan He <[email protected]> AuthorDate: Fri, 15 Nov 2024 09:21:29 +08:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Fri, 15 Nov 2024 12:03:36 +01:00
x86/ioremap: Introduce helper to check if physical address is in setup_data
Functions memremap_is_setup_data() and early_memremap_is_setup_data() share completely the same process and handling, except of the different memremap/unmap invocations.
Add helper __memremap_is_setup_data() to extract the common part, parameter 'early' is used to decide what kind of memremap/unmap APIs are called.
--- arch/x86/mm/ioremap.c | 81 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+)
arch/x86/mm/ioremap.c +81 -0
@@ -628,6 +628,87 @@ static bool memremap_is_efi_data(resource_size_t phys_addr,return false; } +#define SD_SIZE sizeof(struct setup_data) +/* +* Examine the physical address to determine if it is boot data by checking +* it against the boot params setup_data chain. +*/ +static bool __init __memremap_is_setup_data (resource_size_t phys_addr, +bool early) +{ +struct setup_indirect *indirect; +struct setup_data *data; +u64 paddr, paddr_next; + + paddr = boot_params.hdr.setup_data; +while (paddr) { +unsigned int len, size; + +if (phys_addr == paddr) +return true; + +if (early) + data =early_memremap_decrypted (paddr,SD_SIZE ); +else + data =memremap (paddr,SD_SIZE , +MEMREMAP_WB |MEMREMAP_DEC ); +if (!data) { +pr_warn ("failed to memremap setup_data entry\n" ); +return false; + } + + size =SD_SIZE ; + + paddr_next = data->next; + len = data->len; + +if ((phys_addr > paddr) && + (phys_addr < (paddr +SD_SIZE + len))) { +if (early) +early_memunmap (data,SD_SIZE ); +else +memunmap (data); +return true; + } + +if (data->type ==SETUP_INDIRECT ) { + size += len; +if (early) { +early_memunmap (data,SD_SIZE ); + data =early_memremap_decrypted (paddr, size); + }else { +memunmap (data); + data =memremap (paddr, size, +MEMREMAP_WB |MEMREMAP_DEC ); + } +if (!data) { +pr_warn ("failed to memremap indirect setup_data\n" ); +return false; + } + + indirect = (struct setup_indirect *)data->data; + +if (indirect->type !=SETUP_INDIRECT ) { + paddr = indirect->addr; + len = indirect->len; + } + } + +if (early) +early_memunmap (data, size); +else +memunmap (data); + +if ((phys_addr > paddr) && (phys_addr < (paddr + len))) +return true; + + paddr = paddr_next; + } + +return false; +} +#undef SD_SIZE +/* * Examine the physical address to determine if it is boot data by checking * it against the boot params setup_data chain.
Re: [PATCH 1/3] x86/ioremap: introduce helper to check if physical address is in setup_data
In reply to Baoquan HeQuoted 18 lines · Baoquan He
Functions
memremap_is_setup_data()andearly_memremap_is_setup_data()share completely the same process and handling, except of the different memremap/unmap invocations.Add helper
__memremap_is_setup_data()to extract the common part, parameter 'early' is used to decide what kind of memremap/unmap APIs are called.Signed-off-by Baoquan He <[email protected]>--- arch/x86/mm/ioremap.c | 81 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)arch/x86/mm/ioremap.c +0
-0
arch/x86/mm/ioremap.c static bool memremap_is_efi_data(resource_size_t phys_addr, · line 636
Quoted 9 lines
arch/x86/mm/ioremap.c +6
-0@@ -628,6 +628,87 @@ static bool memremap_is_efi_data(resource_size_t phys_addr,return false; } +#define SD_SIZE sizeof(struct setup_data) +/* +* Examine the physical address to determine if it is boot data by checking +* it against the boot params setup_data chain. +*/ +static bool __init __memremap_is_setup_data(resource_size_t phys_addr,
You should remove the __init for this helper since it is called by a function that is outside of __init.
Quoted 14 lines
arch/x86/mm/ioremap.c +14
-0+ bool early) +{ +struct setup_indirect *indirect; +struct setup_data *data; +u64 paddr, paddr_next; + + paddr = boot_params.hdr.setup_data; +while (paddr) { +unsigned int len, size; + +if (phys_addr == paddr) +return true; + +if (early)
arch/x86/mm/ioremap.c static bool memremap_is_efi_data(resource_size_t phys_addr, · line 660
Quoted 10 lines
arch/x86/mm/ioremap.c +10
-0+ data =early_memremap_decrypted (paddr,SD_SIZE ); + else + data =memremap (paddr,SD_SIZE , +MEMREMAP_WB |MEMREMAP_DEC ); +if (!data) { +pr_warn ("failed to memremap setup_data entry\n" ); +return false; + } + + size =SD_SIZE ;
Just me, but I would use sizeof(*data) here instead of using a #define that is later undefined below.
Thanks,
Tom
Quoted 54 lines
arch/x86/mm/ioremap.c +51
-0+ + paddr_next = data->next; + len = data->len; + +if ((phys_addr > paddr) && + (phys_addr < (paddr +SD_SIZE + len))) { +if (early) +early_memunmap (data,SD_SIZE ); +else +memunmap (data); +return true; + } + +if (data->type ==SETUP_INDIRECT ) { + size += len; +if (early) { +early_memunmap (data,SD_SIZE ); + data =early_memremap_decrypted (paddr, size); + }else { +memunmap (data); + data =memremap (paddr, size, +MEMREMAP_WB |MEMREMAP_DEC ); + } +if (!data) { +pr_warn ("failed to memremap indirect setup_data\n" ); +return false; + } + + indirect = (struct setup_indirect *)data->data; + +if (indirect->type !=SETUP_INDIRECT ) { + paddr = indirect->addr; + len = indirect->len; + } + } + +if (early) +early_memunmap (data, size); +else +memunmap (data); + +if ((phys_addr > paddr) && (phys_addr < (paddr + len))) +return true; + + paddr = paddr_next; + } + +return false; +} +#undef SD_SIZE +/* * Examine the physical address to determine if it is boot data by checking * it against the boot params setup_data chain.
Re: [PATCH 1/3] x86/ioremap: introduce helper to check if physical address is in setup_data
Quoted 22 lines · Tom Lendacky
Quoted 21 lines · Baoquan He
Functions
memremap_is_setup_data()andearly_memremap_is_setup_data()share completely the same process and handling, except of the different memremap/unmap invocations.Add helper
__memremap_is_setup_data()to extract the common part, parameter 'early' is used to decide what kind of memremap/unmap APIs are called.Signed-off-by Baoquan He <[email protected]>--- arch/x86/mm/ioremap.c | 81 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)arch/x86/mm/ioremap.c +0
-0@@ -628,6 +628,87 @@ static bool memremap_is_efi_data(resource_size_t phys_addr,return false; }
Quoted 9 lines
arch/x86/mm/ioremap.c static bool memremap_is_efi_data(resource_size_t phys_addr, · line 636
Quoted 6 lines
arch/x86/mm/ioremap.c +6
-0+#define SD_SIZE sizeof(struct setup_data) +/* +* Examine the physical address to determine if it is boot data by checking +* it against the boot params setup_data chain. +*/ +static bool __init __memremap_is_setup_data(resource_size_t phys_addr,You should remove the
__initfor this helper since it is called by a function that is outside of__init.
Removing __init for helper will trigger below warning. Then __ref need be added to helper __memremap_is_setup_data() to suppress it. Maybe the latter way should be taken since the helper need be called by a normal function?
WARNING: modpost: vmlinux: section mismatch in reference: __memremap_is_setup_data+0x5f (section: .text) -> early_memunmap (section: .init.text)
WARNING: modpost: vmlinux: section mismatch in reference: __memremap_is_setup_data+0x167 (section: .text) -> early_memremap_decrypted (section: .init.text)
WARNING: modpost: vmlinux: section mismatch in reference: __memremap_is_setup_data+0x180 (section: .text) -> early_memunmap (section: .init.text)
WARNING: modpost: vmlinux: section mismatch in reference: __memremap_is_setup_data+0x1a9 (section: .text) -> early_memunmap (section: .init.text)
WARNING: modpost: vmlinux: section mismatch in reference: __memremap_is_setup_data+0x1b4 (section: .text) -> early_memremap_decrypted (section: .init.text)
Thanks
Baoquan
PATCH 2/3 x86/ioremap: use helper to implement xxx_is_setup_data()
In reply to Baoquan HeThis simplifies codes a lot by removing the duplicated code handling.
And also remove the similar code comment above of them.
While at it, add __ref to memremap_is_setup_data() to avoid the section mismatch warning:
WARNING: modpost: vmlinux: section mismatch in reference: arch_memremap_can_ram_remap.cold+0x6 (section: .text.unlikely) -> __memremap_is_setup_data (section: .init.text)
--- arch/x86/mm/ioremap.c | 119 ++---------------------------------------- 1 file changed, 3 insertions(+), 116 deletions(-)
arch/x86/mm/ioremap.c +3 -116
@@ -709,129 +709,16 @@ static bool __init __memremap_is_setup_data(resource_size_t phys_addr, }#undef SD_SIZE -/* -* Examine the physical address to determine if it is boot data by checking -* it against the boot params setup_data chain. -*/ -static bool memremap_is_setup_data (resource_size_t phys_addr, +static bool __ref memremap_is_setup_data (resource_size_t phys_addr,unsigned long size) { -struct setup_indirect *indirect; -struct setup_data *data; -u64 paddr, paddr_next; - - paddr = boot_params.hdr.setup_data; -while (paddr) { -unsigned int len; - -if (phys_addr == paddr) -return true; - - data =memremap (paddr,sizeof (*data), -MEMREMAP_WB |MEMREMAP_DEC ); -if (!data) { -pr_warn ("failed to memremap setup_data entry\n" ); -return false; - } - - paddr_next = data->next; - len = data->len; - -if ((phys_addr > paddr) && - (phys_addr < (paddr +sizeof (struct setup_data ) + len))) { -memunmap (data); -return true; - } - -if (data->type ==SETUP_INDIRECT ) { -memunmap (data); - data =memremap (paddr,sizeof (*data) + len, -MEMREMAP_WB |MEMREMAP_DEC ); -if (!data) { -pr_warn ("failed to memremap indirect setup_data\n" ); -return false; - } - - indirect = (struct setup_indirect *)data->data; - -if (indirect->type !=SETUP_INDIRECT ) { - paddr = indirect->addr; - len = indirect->len; - } - } - -memunmap (data); - -if ((phys_addr > paddr) && (phys_addr < (paddr + len))) -return true; - - paddr = paddr_next; - } - -return false; +return __memremap_is_setup_data (phys_addr, false); } -/* -* Examine the physical address to determine if it is boot data by checking -* it against the boot params setup_data chain (early boot version). -*/ static bool __init early_memremap_is_setup_data (resource_size_t phys_addr,unsigned long size) { -struct setup_indirect *indirect; -struct setup_data *data; -u64 paddr, paddr_next; - - paddr = boot_params.hdr.setup_data; -while (paddr) { -unsigned int len, size; - -if (phys_addr == paddr) -return true; - - data =early_memremap_decrypted (paddr,sizeof (*data)); -if (!data) { -pr_warn ("failed to early memremap setup_data entry\n" ); -return false; - } - - size =sizeof (*data); - - paddr_next = data->next; - len = data->len; - -if ((phys_addr > paddr) && - (phys_addr < (paddr +sizeof (struct setup_data ) + len))) { -early_memunmap (data,sizeof (*data)); -return true; - } - -if (data->type ==SETUP_INDIRECT ) { - size += len; -early_memunmap (data,sizeof (*data)); - data =early_memremap_decrypted (paddr, size); -if (!data) { -pr_warn ("failed to early memremap indirect setup_data\n" ); -return false; - } - - indirect = (struct setup_indirect *)data->data; - -if (indirect->type !=SETUP_INDIRECT ) { - paddr = indirect->addr; - len = indirect->len; - } - } - -early_memunmap (data, size); - -if ((phys_addr > paddr) && (phys_addr < (paddr + len))) -return true; - - paddr = paddr_next; - } - -return false; +return __memremap_is_setup_data (phys_addr, true); }/*
Signature · 1 line
2.41.0
[tip: x86/mm] x86/ioremap: Use helper to implement xxx_is_setup_data()
The following commit has been merged into the x86/mm branch of tip:
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: ca9114c1fbb478f69e2e4508b3c126058c5d5521 Gitweb: https://git.kernel.org/tip/ca9114c1fbb478f69e2e4508b3c126058c5d5521 Author: Baoquan He <[email protected]> AuthorDate: Fri, 15 Nov 2024 09:21:30 +08:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Fri, 15 Nov 2024 12:03:36 +01:00
x86/ioremap: Use helper to implement xxx_is_setup_data()
This simplifies codes a lot by removing the duplicated code handling.
And also remove the similar code comment above of them.
While at it, add __ref to memremap_is_setup_data() to avoid the section mismatch warning:
WARNING: modpost: vmlinux: section mismatch in reference: arch_memremap_can_ram_remap.cold+0x6 (section: .text.unlikely) -> __memremap_is_setup_data (section: .init.text)
--- arch/x86/mm/ioremap.c | 119 +---------------------------------------- 1 file changed, 3 insertions(+), 116 deletions(-)
arch/x86/mm/ioremap.c +3 -116
@@ -709,129 +709,16 @@ static bool __init __memremap_is_setup_data(resource_size_t phys_addr, }#undef SD_SIZE -/* -* Examine the physical address to determine if it is boot data by checking -* it against the boot params setup_data chain. -*/ -static bool memremap_is_setup_data (resource_size_t phys_addr, +static bool __ref memremap_is_setup_data (resource_size_t phys_addr,unsigned long size) { -struct setup_indirect *indirect; -struct setup_data *data; -u64 paddr, paddr_next; - - paddr = boot_params.hdr.setup_data; -while (paddr) { -unsigned int len; - -if (phys_addr == paddr) -return true; - - data =memremap (paddr,sizeof (*data), -MEMREMAP_WB |MEMREMAP_DEC ); -if (!data) { -pr_warn ("failed to memremap setup_data entry\n" ); -return false; - } - - paddr_next = data->next; - len = data->len; - -if ((phys_addr > paddr) && - (phys_addr < (paddr +sizeof (struct setup_data ) + len))) { -memunmap (data); -return true; - } - -if (data->type ==SETUP_INDIRECT ) { -memunmap (data); - data =memremap (paddr,sizeof (*data) + len, -MEMREMAP_WB |MEMREMAP_DEC ); -if (!data) { -pr_warn ("failed to memremap indirect setup_data\n" ); -return false; - } - - indirect = (struct setup_indirect *)data->data; - -if (indirect->type !=SETUP_INDIRECT ) { - paddr = indirect->addr; - len = indirect->len; - } - } - -memunmap (data); - -if ((phys_addr > paddr) && (phys_addr < (paddr + len))) -return true; - - paddr = paddr_next; - } - -return false; +return __memremap_is_setup_data (phys_addr, false); } -/* -* Examine the physical address to determine if it is boot data by checking -* it against the boot params setup_data chain (early boot version). -*/ static bool __init early_memremap_is_setup_data (resource_size_t phys_addr,unsigned long size) { -struct setup_indirect *indirect; -struct setup_data *data; -u64 paddr, paddr_next; - - paddr = boot_params.hdr.setup_data; -while (paddr) { -unsigned int len, size; - -if (phys_addr == paddr) -return true; - - data =early_memremap_decrypted (paddr,sizeof (*data)); -if (!data) { -pr_warn ("failed to early memremap setup_data entry\n" ); -return false; - } - - size =sizeof (*data); - - paddr_next = data->next; - len = data->len; - -if ((phys_addr > paddr) && - (phys_addr < (paddr +sizeof (struct setup_data ) + len))) { -early_memunmap (data,sizeof (*data)); -return true; - } - -if (data->type ==SETUP_INDIRECT ) { - size += len; -early_memunmap (data,sizeof (*data)); - data =early_memremap_decrypted (paddr, size); -if (!data) { -pr_warn ("failed to early memremap indirect setup_data\n" ); -return false; - } - - indirect = (struct setup_indirect *)data->data; - -if (indirect->type !=SETUP_INDIRECT ) { - paddr = indirect->addr; - len = indirect->len; - } - } - -early_memunmap (data, size); - -if ((phys_addr > paddr) && (phys_addr < (paddr + len))) -return true; - - paddr = paddr_next; - } - -return false; +return __memremap_is_setup_data (phys_addr, true); }/*
Re: [PATCH 2/3] x86/ioremap: use helper to implement xxx_is_setup_data()
In reply to Baoquan HeQuoted 1 line · Baoquan He
This simplifies codes a lot by removing the duplicated code handling.
You should probably squash this with the first patch.
Quoted 4 lines
And also remove the similar code comment above of them.
While at it, add
__reftomemremap_is_setup_data()to avoid
The __ref shouldn't be needed if you remove the __init from the helper function.
Thanks,
Tom
Quoted 145 lines
the section mismatch warning:
WARNING: modpost: vmlinux: section mismatch in reference:
arch_memremap_can_ram_remap.cold+0x6(section: .text.unlikely) ->__memremap_is_setup_data(section: .init.text)Signed-off-by Baoquan He <[email protected]>--- arch/x86/mm/ioremap.c | 119 ++---------------------------------------- 1 file changed, 3 insertions(+), 116 deletions(-)arch/x86/mm/ioremap.c +3
-116@@ -709,129 +709,16 @@ static bool __init __memremap_is_setup_data(resource_size_t phys_addr, }#undef SD_SIZE -/* -* Examine the physical address to determine if it is boot data by checking -* it against the boot params setup_data chain. -*/ -static bool memremap_is_setup_data (resource_size_t phys_addr, +static bool __ref memremap_is_setup_data (resource_size_t phys_addr,unsigned long size) { -struct setup_indirect *indirect; -struct setup_data *data; -u64 paddr, paddr_next; - - paddr = boot_params.hdr.setup_data; -while (paddr) { -unsigned int len; - -if (phys_addr == paddr) -return true; - - data =memremap (paddr,sizeof (*data), -MEMREMAP_WB |MEMREMAP_DEC ); -if (!data) { -pr_warn ("failed to memremap setup_data entry\n" ); -return false; - } - - paddr_next = data->next; - len = data->len; - -if ((phys_addr > paddr) && - (phys_addr < (paddr +sizeof (struct setup_data ) + len))) { -memunmap (data); -return true; - } - -if (data->type ==SETUP_INDIRECT ) { -memunmap (data); - data =memremap (paddr,sizeof (*data) + len, -MEMREMAP_WB |MEMREMAP_DEC ); -if (!data) { -pr_warn ("failed to memremap indirect setup_data\n" ); -return false; - } - - indirect = (struct setup_indirect *)data->data; - -if (indirect->type !=SETUP_INDIRECT ) { - paddr = indirect->addr; - len = indirect->len; - } - } - -memunmap (data); - -if ((phys_addr > paddr) && (phys_addr < (paddr + len))) -return true; - - paddr = paddr_next; - } - -return false; +return __memremap_is_setup_data (phys_addr, false); } -/* -* Examine the physical address to determine if it is boot data by checking -* it against the boot params setup_data chain (early boot version). -*/ static bool __init early_memremap_is_setup_data (resource_size_t phys_addr,unsigned long size) { -struct setup_indirect *indirect; -struct setup_data *data; -u64 paddr, paddr_next; - - paddr = boot_params.hdr.setup_data; -while (paddr) { -unsigned int len, size; - -if (phys_addr == paddr) -return true; - - data =early_memremap_decrypted (paddr,sizeof (*data)); -if (!data) { -pr_warn ("failed to early memremap setup_data entry\n" ); -return false; - } - - size =sizeof (*data); - - paddr_next = data->next; - len = data->len; - -if ((phys_addr > paddr) && - (phys_addr < (paddr +sizeof (struct setup_data ) + len))) { -early_memunmap (data,sizeof (*data)); -return true; - } - -if (data->type ==SETUP_INDIRECT ) { - size += len; -early_memunmap (data,sizeof (*data)); - data =early_memremap_decrypted (paddr, size); -if (!data) { -pr_warn ("failed to early memremap indirect setup_data\n" ); -return false; - } - - indirect = (struct setup_indirect *)data->data; - -if (indirect->type !=SETUP_INDIRECT ) { - paddr = indirect->addr; - len = indirect->len; - } - } - -early_memunmap (data, size); - -if ((phys_addr > paddr) && (phys_addr < (paddr + len))) -return true; - - paddr = paddr_next; - } - -return false; +return __memremap_is_setup_data (phys_addr, true); }/*
Re: [PATCH 2/3] x86/ioremap: use helper to implement xxx_is_setup_data()
Quoted 6 lines · Tom Lendacky
Quoted 1 line · Baoquan He
This simplifies codes a lot by removing the duplicated code handling.
You should probably squash this with the first patch.
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
And also remove the similar code comment above of them.
While at it, add
__reftomemremap_is_setup_data()to avoidThe
__refshouldn't be needed if you remove the__initfrom the helper function.
Yeah.
Baoquan, I've zapped these 3 commits from tip:x86/mm for now, mind resending them the init annotations fixed?
Thanks,
Ingo
Re: [PATCH 2/3] x86/ioremap: use helper to implement xxx_is_setup_data()
Quoted 13 lines · Ingo Molnar
Quoted 10 lines · Tom Lendacky
Quoted 1 line · Baoquan He
This simplifies codes a lot by removing the duplicated code handling.
You should probably squash this with the first patch.
Quoted 4 lines
And also remove the similar code comment above of them.
While at it, add
__reftomemremap_is_setup_data()to avoid
Quoted 7 lines
Quoted 2 lines
The
__refshouldn't be needed if you remove the__initfrom the helper function.Yeah.
Baoquan, I've zapped these 3 commits from tip:x86/mm for now, mind resending them the init annotations fixed?
Sure, will resend. Thanks.
PATCH 3/3 x86/mm: clean up unused parameters of functions
In reply to Baoquan HeFor functions memremap_is_efi_data(), memremap_is_setup_data and early_memremap_is_setup_data(), their parameter 'size' is not used and sometime cause confusion. Remove it now.
--- arch/x86/mm/ioremap.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
arch/x86/mm/ioremap.c +7 -10
@@ -593,8 +593,7 @@ static bool memremap_should_map_decrypted(resource_size_t phys_addr,* Examine the physical address to determine if it is EFI data. Check * it against the boot params structure and EFI tables and memory types. */ -static bool memremap_is_efi_data (resource_size_t phys_addr, -unsigned long size) +static bool memremap_is_efi_data (resource_size_t phys_addr) {u64 paddr;
@@ -709,14 +708,12 @@ static bool __init __memremap_is_setup_data(resource_size_t phys_addr, }#undef SD_SIZE -static bool __ref memremap_is_setup_data (resource_size_t phys_addr, -unsigned long size) +static bool __ref memremap_is_setup_data (resource_size_t phys_addr) {return __memremap_is_setup_data (phys_addr, false); } -static bool __init early_memremap_is_setup_data (resource_size_t phys_addr, -unsigned long size) +static bool __init early_memremap_is_setup_data (resource_size_t phys_addr) {return __memremap_is_setup_data (phys_addr, true); }
@@ -739,8 +736,8 @@ bool arch_memremap_can_ram_remap(resource_size_t phys_addr, unsigned long size,return false;if (cc_platform_has (CC_ATTR_HOST_MEM_ENCRYPT )) { -if (memremap_is_setup_data (phys_addr, size) || -memremap_is_efi_data (phys_addr, size)) +if (memremap_is_setup_data (phys_addr) || +memremap_is_efi_data (phys_addr))return false; }
@@ -765,8 +762,8 @@ pgprot_t __init early_memremap_pgprot_adjust(resource_size_t phys_addr, encrypted_prot = true;if (cc_platform_has (CC_ATTR_HOST_MEM_ENCRYPT )) { -if (early_memremap_is_setup_data (phys_addr, size) || -memremap_is_efi_data (phys_addr, size)) +if (early_memremap_is_setup_data (phys_addr) || +memremap_is_efi_data (phys_addr)) encrypted_prot = false; }
Signature · 1 line
2.41.0
[tip: x86/mm] x86/mm: Clean up unused parameters of functions
The following commit has been merged into the x86/mm branch of tip:
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: 390c9c9e48b821fc53b67dd93ae0f7a1f82a0469 Gitweb: https://git.kernel.org/tip/390c9c9e48b821fc53b67dd93ae0f7a1f82a0469 Author: Baoquan He <[email protected]> AuthorDate: Fri, 15 Nov 2024 09:21:31 +08:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Fri, 15 Nov 2024 12:03:36 +01:00
x86/mm: Clean up unused parameters of functions
For functions memremap_is_efi_data(), memremap_is_setup_data and early_memremap_is_setup_data(), their parameter 'size' is not used and sometime cause confusion. Remove it now.
--- arch/x86/mm/ioremap.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
arch/x86/mm/ioremap.c +7 -10
@@ -593,8 +593,7 @@ static bool memremap_should_map_decrypted(resource_size_t phys_addr,* Examine the physical address to determine if it is EFI data. Check * it against the boot params structure and EFI tables and memory types. */ -static bool memremap_is_efi_data (resource_size_t phys_addr, -unsigned long size) +static bool memremap_is_efi_data (resource_size_t phys_addr) {u64 paddr;
@@ -709,14 +708,12 @@ static bool __init __memremap_is_setup_data(resource_size_t phys_addr, }#undef SD_SIZE -static bool __ref memremap_is_setup_data (resource_size_t phys_addr, -unsigned long size) +static bool __ref memremap_is_setup_data (resource_size_t phys_addr) {return __memremap_is_setup_data (phys_addr, false); } -static bool __init early_memremap_is_setup_data (resource_size_t phys_addr, -unsigned long size) +static bool __init early_memremap_is_setup_data (resource_size_t phys_addr) {return __memremap_is_setup_data (phys_addr, true); }
@@ -739,8 +736,8 @@ bool arch_memremap_can_ram_remap(resource_size_t phys_addr, unsigned long size,return false;if (cc_platform_has (CC_ATTR_HOST_MEM_ENCRYPT )) { -if (memremap_is_setup_data (phys_addr, size) || -memremap_is_efi_data (phys_addr, size)) +if (memremap_is_setup_data (phys_addr) || +memremap_is_efi_data (phys_addr))return false; }
@@ -765,8 +762,8 @@ pgprot_t __init early_memremap_pgprot_adjust(resource_size_t phys_addr, encrypted_prot = true;if (cc_platform_has (CC_ATTR_HOST_MEM_ENCRYPT )) { -if (early_memremap_is_setup_data (phys_addr, size) || -memremap_is_efi_data (phys_addr, size)) +if (early_memremap_is_setup_data (phys_addr) || +memremap_is_efi_data (phys_addr)) encrypted_prot = false; }
Re: [PATCH 3/3] x86/mm: clean up unused parameters of functions
In reply to Baoquan HeQuoted 5 lines · Baoquan He
For functions
memremap_is_efi_data(),memremap_is_setup_dataandearly_memremap_is_setup_data(), their parameter 'size' is not used and sometime cause confusion. Remove it now.Signed-off-by Baoquan He <[email protected]>
Quoted 57 lines
--- arch/x86/mm/ioremap.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)arch/x86/mm/ioremap.c +7
-10@@ -593,8 +593,7 @@ static bool memremap_should_map_decrypted(resource_size_t phys_addr,* Examine the physical address to determine if it is EFI data. Check * it against the boot params structure and EFI tables and memory types. */ -static bool memremap_is_efi_data (resource_size_t phys_addr, -unsigned long size) +static bool memremap_is_efi_data (resource_size_t phys_addr) {u64 paddr;@@ -709,14 +708,12 @@ static bool __init __memremap_is_setup_data(resource_size_t phys_addr, }#undef SD_SIZE -static bool __ref memremap_is_setup_data (resource_size_t phys_addr, -unsigned long size) +static bool __ref memremap_is_setup_data (resource_size_t phys_addr) {return __memremap_is_setup_data (phys_addr, false); } -static bool __init early_memremap_is_setup_data (resource_size_t phys_addr, -unsigned long size) +static bool __init early_memremap_is_setup_data (resource_size_t phys_addr) {return __memremap_is_setup_data (phys_addr, true); }@@ -739,8 +736,8 @@ bool arch_memremap_can_ram_remap(resource_size_t phys_addr, unsigned long size,return false;if (cc_platform_has (CC_ATTR_HOST_MEM_ENCRYPT )) { -if (memremap_is_setup_data (phys_addr, size) || -memremap_is_efi_data (phys_addr, size)) +if (memremap_is_setup_data (phys_addr) || +memremap_is_efi_data (phys_addr))return false; }@@ -765,8 +762,8 @@ pgprot_t __init early_memremap_pgprot_adjust(resource_size_t phys_addr, encrypted_prot = true;if (cc_platform_has (CC_ATTR_HOST_MEM_ENCRYPT )) { -if (early_memremap_is_setup_data (phys_addr, size) || -memremap_is_efi_data (phys_addr, size)) +if (early_memremap_is_setup_data (phys_addr) || +memremap_is_efi_data (phys_addr)) encrypted_prot = false; }
Also CC kexec list.
Quoted 24 lines · Baoquan He
Functions
memremap_is_setup_data()andearly_memremap_is_setup_data()share completely the same process and handling, except of the different memremap/unmap invocations. The code can be extracted and put into a helper function__memremap_is_setup_data().And parameter 'size' is unused in implementation of
memremap_is_efi_data(),memremap_is_setup_dataandearly_memremap_is_setup_data().This patchset is made to clean them up. It sits on top of tip/x86/urgent commit
8d9ffb2fe65a("x86/mm: Fix a kdump kernel failure on SME system whenCONFIG_IMA_KEXEC=y")Baoquan He (3):
x86/ioremap: introduce helper to check if physical address is in
setup_data
x86/ioremap: use helper to implementxxx_is_setup_data()x86/mm: clean up unused parameters of functionsarch/x86/mm/ioremap.c | 117 +++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 76 deletions(-)Signature · 1 line
2.41.0