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

Yun Levi posted 1 patch 3 years, 7 months ago
There is a newer version of this series
arch/arm64/kernel/machine_kexec_file.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH-RESEND] arm64/kexec: Fix missing extra range for crashkres_low.
Posted by Yun Levi 3 years, 7 months ago
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 <ppbuk5246@gmail.com>
---
 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
Re: [PATCH-RESEND] arm64/kexec: Fix missing extra range for crashkres_low.
Posted by Baoquan He 3 years, 7 months ago
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 <ppbuk5246@gmail.com>
> ---
>  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
>
Re: [PATCH-RESEND] arm64/kexec: Fix missing extra range for crashkres_low.
Posted by Yun Levi 3 years, 7 months ago
> 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!
[PATCH v2] arm64/kexec: Fix missing extra range for crashkres_low.
Posted by Levi Yun 3 years, 7 months ago
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 <ppbuk5246@gmail.com>
---
 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
Re: [PATCH v2] arm64/kexec: Fix missing extra range for crashkres_low.
Posted by Catalin Marinas 3 years, 7 months ago
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 <ppbuk5246@gmail.com>

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

Does this need a Fixes tag and cc stable?

-- 
Catalin
Re: [PATCH v2] arm64/kexec: Fix missing extra range for crashkres_low.
Posted by Yun Levi 3 years, 7 months ago
> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
>
> 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: stable@vger.kernel.org

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


Thanks.

-- 
Best regards,
Levi
Re: [PATCH v2] arm64/kexec: Fix missing extra range for crashkres_low.
Posted by Baoquan He 3 years, 7 months ago
On 08/31/22 at 09:38am, Yun Levi wrote:
> > Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
> >
> > 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: stable@vger.kernel.org

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: stable@vger.kernel.org
Re: [PATCH v2] arm64/kexec: Fix missing extra range for crashkres_low.
Posted by Yun Levi 3 years, 7 months ago
> 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: stable@vger.kernel.org

Thanks! I'will resend the patch with fixed commit message and the tags
including Fixes, Cc, Review-By and Acked-by.
[PATCH v2-RESEND] arm64/kexec: Fix missing extra range for crashkres_low.
Posted by Yun Levi 3 years, 7 months ago
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 slot in case of crashk_low_res is used.

Signed-off-by: Levi Yun <ppbuk5246@gmail.com>
Fixes: 944a45abfabc ("arm64: kdump: Reimplement crashkernel=X")
Cc: stable@vger.kernel.org
Acked-by: Baoquan He <bhe@redhat.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
---
 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
Re: [PATCH v2-RESEND] arm64/kexec: Fix missing extra range for crashkres_low.
Posted by Catalin Marinas 3 years, 7 months ago
On Wed, Aug 31, 2022 at 10:49:30AM +0900, 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 more extra cmem slot in case of crashk_low_res is used.
> 
> Signed-off-by: Levi Yun <ppbuk5246@gmail.com>
> Fixes: 944a45abfabc ("arm64: kdump: Reimplement crashkernel=X")
> Cc: stable@vger.kernel.org

To be even more precise, it should be:

Cc: <stable@vger.kernel.org> # 5.19.x

> Acked-by: Baoquan He <bhe@redhat.com>
> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
> ---
>  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++;

Something happened to the whitespace here, so the patch can't be
applied.

-- 
Catalin
Re: [PATCH v2-RESEND] arm64/kexec: Fix missing extra range for crashkres_low.
Posted by Yun Levi 3 years, 7 months ago
>
> To be even more precise, it should be:
>
> Cc: <stable@vger.kernel.org> # 5.19.x

Thanks! I'll fix it!


> Something happened to the whitespace here, so the patch can't be
> applied.

Sorry, I'll check and send again :). Thanks!

On Wed, Aug 31, 2022 at 7:26 PM Catalin Marinas <catalin.marinas@arm.com> wrote:
>
> On Wed, Aug 31, 2022 at 10:49:30AM +0900, 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 more extra cmem slot in case of crashk_low_res is used.
> >
> > Signed-off-by: Levi Yun <ppbuk5246@gmail.com>
> > Fixes: 944a45abfabc ("arm64: kdump: Reimplement crashkernel=X")
> > Cc: stable@vger.kernel.org
>
> To be even more precise, it should be:
>
> Cc: <stable@vger.kernel.org> # 5.19.x
>
> > Acked-by: Baoquan He <bhe@redhat.com>
> > Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
> > ---
> >  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++;
>
> Something happened to the whitespace here, so the patch can't be
> applied.
>
> --
> Catalin
[PATCH v3] arm64/kexec: Fix missing extra range for crashkres_low.
Posted by Levi Yun 3 years, 7 months ago
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 slot in case of crashk_low_res is used.

Signed-off-by: Levi Yun <ppbuk5246@gmail.com>
Fixes: 944a45abfabc ("arm64: kdump: Reimplement crashkernel=X")
Cc: <stable@vger.kernel.org> # 5.19.x
Acked-by: Baoquan He <bhe@redhat.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
---
 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
Re: [PATCH v3] arm64/kexec: Fix missing extra range for crashkres_low.
Posted by Will Deacon 3 years, 7 months ago
On Wed, 31 Aug 2022 19:39:13 +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 slot in case of crashk_low_res is used.
> 
> 

Applied to arm64 (for-next/fixes), thanks!

[1/1] arm64/kexec: Fix missing extra range for crashkres_low.
      https://git.kernel.org/arm64/c/4831be702b95

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
Re: [PATCH v2] arm64/kexec: Fix missing extra range for crashkres_low.
Posted by Baoquan He 3 years, 7 months ago
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 <bhe@redhat.com>

> 
> Signed-off-by: Levi Yun <ppbuk5246@gmail.com>
> ---
>  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
>