[patch 10/27] kexec_file: make use of purgatory optional

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: AKASHI Takahiro <takahiro.akashi@xxxxxxxxxx>
Subject: kexec_file: make use of purgatory optional

Patch series "kexec_file, x86, powerpc: refactoring for other
architecutres", v2.

This is a preparatory patchset for adding kexec_file support on arm64.

It was originally included in a arm64 patch set[1], but Philipp is also
working on their kexec_file support on s390[2] and some changes are now
conflicting.

So these common parts were extracted and put into a separate patch set for
better integration.  What's more, my original patch#4 was split into a few
small chunks for easier review after Dave's comment.

As such, the resulting code is basically identical with my original, and
the only *visible* differences are:
  * renamings of _kexec_kernel_image_probe() and
    _kimage_file_post_load_cleanup()
  * change one of types of arguments at prepare_elf64_headers()

Those, unfortunately, require a couple of trivial changes on the rest
(#1, #6 to #13) of my arm64 kexec_file patch set[1].

Patch #1 allows making a use of purgatory optional, particularly useful
for arm64.

Patch #2 commonalizes arch_kexec_kernel_{image_probe, image_load,
verify_sig}() and arch_kimage_file_post_load_cleanup() across
architectures.

Patches #3-#7 are also intended to generalize parse_elf64_headers(), along
with exclude_mem_range(), to be made best re-use of.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2018-February/561182.html
[2] http://lkml.iu.edu//hypermail/linux/kernel/1802.1/02596.html


This patch (of 7):

On arm64, crash dump kernel's usable memory is protected by *unmapping* it
from kernel virtual space unlike other architectures where the region is
just made read-only.  It is highly unlikely that the region is
accidentally corrupted and this observation rationalizes that digest check
code can also be dropped from purgatory.  The resulting code is so simple
as it doesn't require a bit ugly re-linking/relocation stuff, i.e. 
arch_kexec_apply_relocations_add().

Please see:
   http://lists.infradead.org/pipermail/linux-arm-kernel/2017-December/545428.html
All that the purgatory does is to shuffle arguments and jump into a new
kernel, while we still need to have some space for a hash value
(purgatory_sha256_digest) which is never checked against.

As such, it doesn't make sense to have trampline code between old kernel
and new kernel on arm64.

This patch introduces a new configuration, ARCH_HAS_KEXEC_PURGATORY, and
allows related code to be compiled in only if necessary.

[takahiro.akashi@xxxxxxxxxx: fix trivial screwup]
  Link: http://lkml.kernel.org/r/20180309093346.GF25863@xxxxxxxxxx
Link: http://lkml.kernel.org/r/20180306102303.9063-2-takahiro.akashi@xxxxxxxxxx
Signed-off-by: AKASHI Takahiro <takahiro.akashi@xxxxxxxxxx>
Acked-by: Dave Young <dyoung@xxxxxxxxxx>
Tested-by: Dave Young <dyoung@xxxxxxxxxx>
Cc: Vivek Goyal <vgoyal@xxxxxxxxxx>
Cc: Baoquan He <bhe@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 arch/powerpc/Kconfig |    3 +++
 arch/x86/Kconfig     |    3 +++
 kernel/kexec_file.c  |    5 +++++
 3 files changed, 11 insertions(+)

diff -puN arch/powerpc/Kconfig~kexec_file-make-an-use-of-purgatory-optional arch/powerpc/Kconfig
--- a/arch/powerpc/Kconfig~kexec_file-make-an-use-of-purgatory-optional
+++ a/arch/powerpc/Kconfig
@@ -552,6 +552,9 @@ config KEXEC_FILE
 	  for kernel and initramfs as opposed to a list of segments as is the
 	  case for the older kexec call.
 
+config ARCH_HAS_KEXEC_PURGATORY
+	def_bool KEXEC_FILE
+
 config RELOCATABLE
 	bool "Build a relocatable kernel"
 	depends on PPC64 || (FLATMEM && (44x || FSL_BOOKE))
diff -puN arch/x86/Kconfig~kexec_file-make-an-use-of-purgatory-optional arch/x86/Kconfig
--- a/arch/x86/Kconfig~kexec_file-make-an-use-of-purgatory-optional
+++ a/arch/x86/Kconfig
@@ -2008,6 +2008,9 @@ config KEXEC_FILE
 	  for kernel and initramfs as opposed to list of segments as
 	  accepted by previous system call.
 
+config ARCH_HAS_KEXEC_PURGATORY
+	def_bool KEXEC_FILE
+
 config KEXEC_VERIFY_SIG
 	bool "Verify kernel signature during kexec_file_load() syscall"
 	depends on KEXEC_FILE
diff -puN kernel/kexec_file.c~kexec_file-make-an-use-of-purgatory-optional kernel/kexec_file.c
--- a/kernel/kexec_file.c~kexec_file-make-an-use-of-purgatory-optional
+++ a/kernel/kexec_file.c
@@ -532,6 +532,9 @@ static int kexec_calculate_store_digests
 	struct kexec_sha_region *sha_regions;
 	struct purgatory_info *pi = &image->purgatory_info;
 
+	if (!IS_ENABLED(CONFIG_ARCH_HAS_KEXEC_PURGATORY))
+		return 0;
+
 	zero_buf = __va(page_to_pfn(ZERO_PAGE(0)) << PAGE_SHIFT);
 	zero_buf_sz = PAGE_SIZE;
 
@@ -633,6 +636,7 @@ out:
 	return ret;
 }
 
+#ifdef CONFIG_ARCH_HAS_KEXEC_PURGATORY
 /* Actually load purgatory. Lot of code taken from kexec-tools */
 static int __kexec_load_purgatory(struct kimage *image, unsigned long min,
 				  unsigned long max, int top_down)
@@ -1022,3 +1026,4 @@ int kexec_purgatory_get_set_symbol(struc
 
 	return 0;
 }
+#endif /* CONFIG_ARCH_HAS_KEXEC_PURGATORY */
_
--
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux