All of lore.kernel.org
 help / color / mirror / Atom feed
* [makedumpfile PATCH v2] Always use bigger SECTION_MAP_MASK
@ 2018-03-20  9:30 Petr Tesarik
  2018-03-20 12:48 ` Masaki Tachibana
  0 siblings, 1 reply; 2+ messages in thread
From: Petr Tesarik @ 2018-03-20  9:30 UTC (permalink / raw)
  To: Masaki Tachibana; +Cc: kexec mailing list

It is not necessary to distinguish between different kernel
versions. Kernel commit 2d070eab2e82 merely reuses a previously
unused bit (see clarification in kernel commit def9b71ee651a). The
bit was always zero even before that commit, so it is safe to mask
it off even for kernel versions before 4.13, removing some of the
complexity.

More importantly, makedumpfile fails on kernels which backport the
patch on top of an older version (for example SLES15).

Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
 makedumpfile.c | 5 +----
 makedumpfile.h | 9 ++++++++-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index ed138d3..b180eb3 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -3337,10 +3337,7 @@ section_mem_map_addr(unsigned long addr)
 		return NOT_KV_ADDR;
 	}
 	map = ULONG(mem_section + OFFSET(mem_section.section_mem_map));
-	if (info->kernel_version < KERNEL_VERSION(4, 13, 0))
-		map &= SECTION_MAP_MASK_4_12;
-	else
-		map &= SECTION_MAP_MASK;
+	map &= SECTION_MAP_MASK;
 	free(mem_section);
 
 	return map;
diff --git a/makedumpfile.h b/makedumpfile.h
index 01eece2..8491025 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -185,8 +185,15 @@ isAnon(unsigned long mapping)
 #define SECTION_ROOT_MASK()	(SECTIONS_PER_ROOT() - 1)
 #define SECTION_NR_TO_ROOT(sec)	((sec) / SECTIONS_PER_ROOT())
 #define SECTION_IS_ONLINE	(1UL<<2)
+/*
+ * SECTION_MAP_LAST_BIT was 1UL<<2 before Linux 4.13.0.
+ * However, we always use the higher value, because:
+ *  1. at least one distributor backported commit 2d070eab2e82 to kernel
+ *     version 4.12,
+ *  2. it has been verified that (1UL<<2) was never set, so it is
+ *     safe to mask that bit off even in old kernels.
+ */
 #define SECTION_MAP_LAST_BIT	(1UL<<3)
-#define SECTION_MAP_MASK_4_12	(~(SECTION_IS_ONLINE-1))
 #define SECTION_MAP_MASK	(~(SECTION_MAP_LAST_BIT-1))
 #define NR_SECTION_ROOTS()	divideup(num_section, SECTIONS_PER_ROOT())
 #define SECTION_NR_TO_PFN(sec)	((sec) << PFN_SECTION_SHIFT())
-- 
2.13.6

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [makedumpfile PATCH v2] Always use bigger SECTION_MAP_MASK
  2018-03-20  9:30 [makedumpfile PATCH v2] Always use bigger SECTION_MAP_MASK Petr Tesarik
@ 2018-03-20 12:48 ` Masaki Tachibana
  0 siblings, 0 replies; 2+ messages in thread
From: Masaki Tachibana @ 2018-03-20 12:48 UTC (permalink / raw)
  To: Petr Tesarik; +Cc: Masahiko Hayashi, kexec mailing list

Hi Petr,

Thank you for your V2 patch.
I will merge it into V1.6.4.

Thanks
Tachibana

> -----Original Message-----
> From: kexec [mailto:kexec-bounces@lists.infradead.org] On Behalf Of Petr Tesarik
> Sent: Tuesday, March 20, 2018 6:31 PM
> To: Tachibana Masaki() <mas-tachibana@vf.jp.nec.com>
> Cc: kexec mailing list <kexec@lists.infradead.org>
> Subject: [makedumpfile PATCH v2] Always use bigger SECTION_MAP_MASK
> 
> It is not necessary to distinguish between different kernel
> versions. Kernel commit 2d070eab2e82 merely reuses a previously
> unused bit (see clarification in kernel commit def9b71ee651a). The
> bit was always zero even before that commit, so it is safe to mask
> it off even for kernel versions before 4.13, removing some of the
> complexity.
> 
> More importantly, makedumpfile fails on kernels which backport the
> patch on top of an older version (for example SLES15).
> 
> Signed-off-by: Petr Tesarik <ptesarik@suse.com>
> ---
>  makedumpfile.c | 5 +----
>  makedumpfile.h | 9 ++++++++-
>  2 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/makedumpfile.c b/makedumpfile.c
> index ed138d3..b180eb3 100644
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -3337,10 +3337,7 @@ section_mem_map_addr(unsigned long addr)
>  		return NOT_KV_ADDR;
>  	}
>  	map = ULONG(mem_section + OFFSET(mem_section.section_mem_map));
> -	if (info->kernel_version < KERNEL_VERSION(4, 13, 0))
> -		map &= SECTION_MAP_MASK_4_12;
> -	else
> -		map &= SECTION_MAP_MASK;
> +	map &= SECTION_MAP_MASK;
>  	free(mem_section);
> 
>  	return map;
> diff --git a/makedumpfile.h b/makedumpfile.h
> index 01eece2..8491025 100644
> --- a/makedumpfile.h
> +++ b/makedumpfile.h
> @@ -185,8 +185,15 @@ isAnon(unsigned long mapping)
>  #define SECTION_ROOT_MASK()	(SECTIONS_PER_ROOT() - 1)
>  #define SECTION_NR_TO_ROOT(sec)	((sec) / SECTIONS_PER_ROOT())
>  #define SECTION_IS_ONLINE	(1UL<<2)
> +/*
> + * SECTION_MAP_LAST_BIT was 1UL<<2 before Linux 4.13.0.
> + * However, we always use the higher value, because:
> + *  1. at least one distributor backported commit 2d070eab2e82 to kernel
> + *     version 4.12,
> + *  2. it has been verified that (1UL<<2) was never set, so it is
> + *     safe to mask that bit off even in old kernels.
> + */
>  #define SECTION_MAP_LAST_BIT	(1UL<<3)
> -#define SECTION_MAP_MASK_4_12	(~(SECTION_IS_ONLINE-1))
>  #define SECTION_MAP_MASK	(~(SECTION_MAP_LAST_BIT-1))
>  #define NR_SECTION_ROOTS()	divideup(num_section, SECTIONS_PER_ROOT())
>  #define SECTION_NR_TO_PFN(sec)	((sec) << PFN_SECTION_SHIFT())
> --
> 2.13.6
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-20 12:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-20  9:30 [makedumpfile PATCH v2] Always use bigger SECTION_MAP_MASK Petr Tesarik
2018-03-20 12:48 ` Masaki Tachibana

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.