From: Tom Lendacky <thomas.lendacky@amd.com>
To: Baoquan He <bhe@redhat.com>, linux-kernel@vger.kernel.org
Cc: dyoung@redhat.com, daniel.kiper@oracle.com, noodles@fb.com,
lijiang@redhat.com, kexec@lists.infradead.org
Subject: Re: [PATCH v2 1/2] x86/mm: rename the confusing local variable in early_memremap_is_setup_data()
Date: Mon, 9 Sep 2024 09:43:37 -0500 [thread overview]
Message-ID: <3abbad0d-2c01-bb57-bffe-ae75e1138a03@amd.com> (raw)
In-Reply-To: <20240829104016.84139-2-bhe@redhat.com>
On 8/29/24 05:40, Baoquan He wrote:
> In function early_memremap_is_setup_data(), parameter 'size' passed has
> the same name as the local variable inside the while loop. That
> confuses people who sometime mix up them when reading code.
>
> Here rename the local variable 'size' inside while loop to 'sd_size'.
>
> And also add one local variable 'sd_size' likewise in function
> memremap_is_setup_data() to simplify code. In later patch, this can also
> be used.
>
> Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
> arch/x86/mm/ioremap.c | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
> index aa7d279321ea..f1ee8822ddf1 100644
> --- a/arch/x86/mm/ioremap.c
> +++ b/arch/x86/mm/ioremap.c
> @@ -640,7 +640,7 @@ static bool memremap_is_setup_data(resource_size_t phys_addr,
>
> paddr = boot_params.hdr.setup_data;
> while (paddr) {
> - unsigned int len;
> + unsigned int len, sd_size;
>
> if (phys_addr == paddr)
> return true;
> @@ -652,6 +652,8 @@ static bool memremap_is_setup_data(resource_size_t phys_addr,
> return false;
> }
>
> + sd_size = sizeof(*data);
> +
> paddr_next = data->next;
> len = data->len;
>
> @@ -662,7 +664,9 @@ static bool memremap_is_setup_data(resource_size_t phys_addr,
>
> if (data->type == SETUP_INDIRECT) {
> memunmap(data);
> - data = memremap(paddr, sizeof(*data) + len,
> +
> + sd_size += len;
> + data = memremap(paddr, sd_size,
> MEMREMAP_WB | MEMREMAP_DEC);
> if (!data) {
> pr_warn("failed to memremap indirect setup_data\n");
> @@ -701,7 +705,7 @@ static bool __init early_memremap_is_setup_data(resource_size_t phys_addr,
>
> paddr = boot_params.hdr.setup_data;
> while (paddr) {
> - unsigned int len, size;
> + unsigned int len, sd_size;
>
> if (phys_addr == paddr)
> return true;
> @@ -712,7 +716,7 @@ static bool __init early_memremap_is_setup_data(resource_size_t phys_addr,
> return false;
> }
>
> - size = sizeof(*data);
> + sd_size = sizeof(*data);
>
> paddr_next = data->next;
> len = data->len;
> @@ -723,9 +727,9 @@ static bool __init early_memremap_is_setup_data(resource_size_t phys_addr,
> }
>
> if (data->type == SETUP_INDIRECT) {
> - size += len;
> + sd_size += len;
> early_memunmap(data, sizeof(*data));
> - data = early_memremap_decrypted(paddr, size);
> + data = early_memremap_decrypted(paddr, sd_size);
> if (!data) {
> pr_warn("failed to early memremap indirect setup_data\n");
> return false;
> @@ -739,7 +743,7 @@ static bool __init early_memremap_is_setup_data(resource_size_t phys_addr,
> }
> }
>
> - early_memunmap(data, size);
> + early_memunmap(data, sd_size);
>
> if ((phys_addr > paddr) && (phys_addr < (paddr + len)))
> return true;
next prev parent reply other threads:[~2024-09-09 14:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-29 10:40 [PATCH v2 0/2] x86/mm/sme: fix the kdump kernel breakage on SME system when CONFIG_IMA_KEXEC=y Baoquan He
2024-08-29 10:40 ` [PATCH v2 1/2] x86/mm: rename the confusing local variable in early_memremap_is_setup_data() Baoquan He
2024-09-09 14:43 ` Tom Lendacky [this message]
2024-08-29 10:40 ` [PATCH v2 2/2] x86/mm/sme: fix the kdump kernel breakage on SME system when CONFIG_IMA_KEXEC=y Baoquan He
2024-09-09 14:53 ` Tom Lendacky
2024-09-10 9:40 ` Baoquan He
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=3abbad0d-2c01-bb57-bffe-ae75e1138a03@amd.com \
--to=thomas.lendacky@amd.com \
--cc=bhe@redhat.com \
--cc=daniel.kiper@oracle.com \
--cc=dyoung@redhat.com \
--cc=kexec@lists.infradead.org \
--cc=lijiang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=noodles@fb.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox