2022-08-03 15:20:48

by Yun Levi

[permalink] [raw]
Subject: [PATCH] arm64/kexec: Fix missing extra range for crashkres_low.

Like crashk_res, Calling crash_exclude_mem_range function with
crashk_low_res area would need extra crash_mem range too.
Add one extra crash_mem range when crashk_low_res is used.

Signed-off-by: Levi Yun <[email protected]>
---
arch/arm64/kernel/machine_kexec_file.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c
index 889951291cc0..378aee04e7d4 100644
--- a/arch/arm64/kernel/machine_kexec_file.c
+++ b/arch/arm64/kernel/machine_kexec_file.c
@@ -51,6 +51,9 @@ static int prepare_elf_headers(void **addr, unsigned long *sz)
for_each_mem_range(i, &start, &end)
nr_ranges++;

+ if (crashk_low_res.end)
+ nr_ranges++; /**< for exclusion of crashkernel=size,low region */
+
cmem = kmalloc(struct_size(cmem, ranges, nr_ranges), GFP_KERNEL);
if (!cmem)
return -ENOMEM;
--
2.35.1


2022-08-30 05:05:15

by Yun Levi

[permalink] [raw]
Subject: [PATCH-RESEND] arm64/kexec: Fix missing extra range for crashkres_low.

Like crashk_res, Calling crash_exclude_mem_range function with
crashk_low_res area would need extra crash_mem range too.
Add one extra crash_mem range when crashk_low_res is used.

Signed-off-by: Levi Yun <[email protected]>
---
arch/arm64/kernel/machine_kexec_file.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/arm64/kernel/machine_kexec_file.c
b/arch/arm64/kernel/machine_kexec_file.c
index 889951291cc0..378aee04e7d4 100644
--- a/arch/arm64/kernel/machine_kexec_file.c
+++ b/arch/arm64/kernel/machine_kexec_file.c
@@ -51,6 +51,9 @@ static int prepare_elf_headers(void **addr, unsigned long *sz)
for_each_mem_range(i, &start, &end)
nr_ranges++;

+ if (crashk_low_res.end)
+ nr_ranges++; /**< for exclusion of
crashkernel=size,low region */
+
cmem = kmalloc(struct_size(cmem, ranges, nr_ranges), GFP_KERNEL);
if (!cmem)
return -ENOMEM;
--
2.35.1

2022-08-30 08:33:37

by Yun Levi

[permalink] [raw]
Subject: Re: [PATCH-RESEND] arm64/kexec: Fix missing extra range for crashkres_low.

> Right, excluding crashkernel region may cause memory region splitting,
> so we need extra slot for that.
>
> Meanwhile, can you fix above code comment mess? Otherwise, this looks
> good to me.

Thanks! I'll remove the comment.

> Or we can add extra 2 slots like we do in x86, it just add another 16
> bytes temporarily.

Agree. I'll send the patch again by modifying nr_ranges' initialized value as 2.

Thanks!

2022-08-30 08:52:28

by Baoquan He

[permalink] [raw]
Subject: Re: [PATCH-RESEND] arm64/kexec: Fix missing extra range for crashkres_low.

On 08/30/22 at 01:28pm, Yun Levi wrote:
> Like crashk_res, Calling crash_exclude_mem_range function with
> crashk_low_res area would need extra crash_mem range too.
> Add one extra crash_mem range when crashk_low_res is used.
>
> Signed-off-by: Levi Yun <[email protected]>
> ---
> arch/arm64/kernel/machine_kexec_file.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/arm64/kernel/machine_kexec_file.c
> b/arch/arm64/kernel/machine_kexec_file.c
> index 889951291cc0..378aee04e7d4 100644
> --- a/arch/arm64/kernel/machine_kexec_file.c
> +++ b/arch/arm64/kernel/machine_kexec_file.c
> @@ -51,6 +51,9 @@ static int prepare_elf_headers(void **addr, unsigned long *sz)
> for_each_mem_range(i, &start, &end)
> nr_ranges++;
>
> + if (crashk_low_res.end)
> + nr_ranges++; /**< for exclusion of
> crashkernel=size,low region */
> +

Right, excluding crashkernel region may cause memory region splitting,
so we need extra slot for that.

Meanwhile, can you fix above code comment mess? Otherwise, this looks
good to me.

Or we can add extra 2 slots like we do in x86, it just add another 16
bytes temporarily.


> cmem = kmalloc(struct_size(cmem, ranges, nr_ranges), GFP_KERNEL);
> if (!cmem)
> return -ENOMEM;
> --
> 2.35.1
>

2022-08-30 09:56:40

by Yun Levi

[permalink] [raw]
Subject: [PATCH v2] arm64/kexec: Fix missing extra range for crashkres_low.

Like crashk_res, Calling crash_exclude_mem_range function with
crashk_low_res area would need extra crash_mem range too.

Add one more extra cmem range slot in case of crashk_low_res is used.

Signed-off-by: Levi Yun <[email protected]>
---
arch/arm64/kernel/machine_kexec_file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c
index 889951291cc0..a11a6e14ba89 100644
--- a/arch/arm64/kernel/machine_kexec_file.c
+++ b/arch/arm64/kernel/machine_kexec_file.c
@@ -47,7 +47,7 @@ static int prepare_elf_headers(void **addr, unsigned long *sz)
u64 i;
phys_addr_t start, end;

- nr_ranges = 1; /* for exclusion of crashkernel region */
+ nr_ranges = 2; /* for exclusion of crashkernel region */
for_each_mem_range(i, &start, &end)
nr_ranges++;

--
2.35.1

2022-08-30 12:53:58

by Baoquan He

[permalink] [raw]
Subject: Re: [PATCH v2] arm64/kexec: Fix missing extra range for crashkres_low.

On 08/30/22 at 06:28pm, Levi Yun wrote:
> Like crashk_res, Calling crash_exclude_mem_range function with
> crashk_low_res area would need extra crash_mem range too.
>
> Add one more extra cmem range slot in case of crashk_low_res is used.
~~^ should be removed.

LGTM,

Acked-by: Baoquan He <[email protected]>

>
> Signed-off-by: Levi Yun <[email protected]>
> ---
> arch/arm64/kernel/machine_kexec_file.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c
> index 889951291cc0..a11a6e14ba89 100644
> --- a/arch/arm64/kernel/machine_kexec_file.c
> +++ b/arch/arm64/kernel/machine_kexec_file.c
> @@ -47,7 +47,7 @@ static int prepare_elf_headers(void **addr, unsigned long *sz)
> u64 i;
> phys_addr_t start, end;
>
> - nr_ranges = 1; /* for exclusion of crashkernel region */
> + nr_ranges = 2; /* for exclusion of crashkernel region */
> for_each_mem_range(i, &start, &end)
> nr_ranges++;
>
> --
> 2.35.1
>

2022-08-30 16:47:46

by Catalin Marinas

[permalink] [raw]
Subject: Re: [PATCH v2] arm64/kexec: Fix missing extra range for crashkres_low.

On Tue, Aug 30, 2022 at 06:28:39PM +0900, Levi Yun wrote:
> Like crashk_res, Calling crash_exclude_mem_range function with
> crashk_low_res area would need extra crash_mem range too.
>
> Add one more extra cmem range slot in case of crashk_low_res is used.
>
> Signed-off-by: Levi Yun <[email protected]>

Reviewed-by: Catalin Marinas <[email protected]>

Does this need a Fixes tag and cc stable?

--
Catalin

2022-08-31 00:55:02

by Yun Levi

[permalink] [raw]
Subject: Re: [PATCH v2] arm64/kexec: Fix missing extra range for crashkres_low.

> Reviewed-by: Catalin Marinas <[email protected]>
>
> Does this need a Fixes tag and cc stable?
>
> --
> Catalin

IMHO, it seems good to add two tags like:
Fixes: 3751e728cef29 ("arm64: kexec_file: add crash dump support")
Cc: [email protected]

BTW, To add above two tags, should I resend the patch again with
former tags (Acked-by & Reviewed-by)?


Thanks.

--
Best regards,
Levi

2022-08-31 01:35:28

by Baoquan He

[permalink] [raw]
Subject: Re: [PATCH v2] arm64/kexec: Fix missing extra range for crashkres_low.

On 08/31/22 at 09:38am, Yun Levi wrote:
> > Reviewed-by: Catalin Marinas <[email protected]>
> >
> > Does this need a Fixes tag and cc stable?
> >
> > --
> > Catalin
>
> IMHO, it seems good to add two tags like:
> Fixes: 3751e728cef29 ("arm64: kexec_file: add crash dump support")
> Cc: [email protected]

No, I don't think the Fixes commit is right. It should fix the commit
where crashkernel,low is introduced. Before that, no issue caused.
So the tags should be:

Fixes: 944a45abfabc ("arm64: kdump: Reimplement crashkernel=X")
Cc: [email protected]

2022-08-31 02:02:41

by Yun Levi

[permalink] [raw]
Subject: Re: [PATCH v2] arm64/kexec: Fix missing extra range for crashkres_low.

> No, I don't think the Fixes commit is right. It should fix the commit
> where crashkernel,low is introduced. Before that, no issue caused.
> So the tags should be:
>
> Fixes: 944a45abfabc ("arm64: kdump: Reimplement crashkernel=X")
> Cc: [email protected]

Thanks! I'will resend the patch with fixed commit message and the tags
including Fixes, Cc, Review-By and Acked-by.