Skip to contentSkip to conversation

kexec: Add --lite option

PATCH In review Geoff Levand 9 participants 24 messages Oct 21, 2015 – Apr 19, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kexec: Add --lite option

Add a new option --lite to kexec that allows for a fast reboot by avoiding the purgatory integrity checks. This option is intended for use by kexec based bootloaders that load a new image and then immediately transfer control to it.

---
Hi Simon,

It was reported that on some systems where purgatory is running without caches enabled the sha256 calculations would take several minutes. For bootloaders that just load a new image and immediately jump into it the loss of the integrity check is worth the increase in boot speed. Please consider.

-Geoff

 kexec/kexec.8         |  3 +++
 kexec/kexec.c         | 19 +++++++++++++++++--
 kexec/kexec.h         |  4 ++++
 purgatory/purgatory.c |  3 ++-
 4 files changed, 26 insertions(+), 3 deletions(-)
kexec/kexec.8 +3 -0
index 4d0c1d1..93ed588 100644
@@ -126,6 +126,9 @@ in one call.
 Open a help file for
 .BR kexec .
 .TP
+.B \-i\ (\-\-lite)
+Fast reboot, no memory integrity checks.
+.TP
 .BI \-l\ (\-\-load) \ kernel
 Load the specified
 .I kernel
kexec/kexec.c +17 -2
index ff024f3..ebb1310 100644
@@ -613,6 +613,15 @@ static void update_purgatory(struct kexec_info *info)
 		return;
 	}
 	arch_update_purgatory(info);
+
+	if (info->kexec_lite) {
+		unsigned int tmp = 1;
+
+		elf_rel_set_symbol(&info->rhdr, "kexec_lite", &tmp,
+			sizeof(tmp));
+		return;
+	}
+
 	memset(region, 0, sizeof(region));
 	sha256_starts(&ctx);
 	/* Compute a hash of the loaded kernel */
@@ -652,7 +661,7 @@ static void update_purgatory(struct kexec_info *info)
  *	Load the new kernel
  */
 static int my_load(const char *type, int fileind, int argc, char **argv,
-		   unsigned long kexec_flags, void *entry)
+		   unsigned long kexec_flags, int kexec_lite, void *entry)
 {
 	char *kernel;
 	char *kernel_buf;
@@ -665,6 +674,7 @@ static int my_load(const char *type, int fileind, int argc, char **argv,
 
 	memset(&info, 0, sizeof(info));
 	info.kexec_flags = kexec_flags;
+	info.kexec_lite = kexec_lite;
 
 	result = 0;
 	if (argc - fileind <= 0) {
@@ -914,6 +924,7 @@ void usage(void)
 	       " -v, --version        Print the version of kexec.\n"
 	       " -f, --force          Force an immediate kexec,\n"
 	       "                      don't call shutdown.\n"
+	       " -i, --lite           Fast reboot, no memory integrity checks.\n"
 	       " -x, --no-ifdown      Don't bring down network interfaces.\n"
 	       " -y, --no-sync        Don't sync filesystems before kexec.\n"
 	       " -l, --load           Load the new kernel into the\n"
@@ -1173,6 +1184,7 @@ int main(int argc, char *argv[])
 	int do_unload = 0;
 	int do_reuse_initrd = 0;
 	int do_kexec_file_syscall = 0;
+	int do_lite = 0;
 	void *entry = 0;
 	char *type = 0;
 	char *endptr;
@@ -1314,6 +1326,9 @@ int main(int argc, char *argv[])
 		case OPT_KEXEC_FILE_SYSCALL:
 			/* We already parsed it. Nothing to do. */
 			break;
+		case OPT_LITE:
+			do_lite = 1;
+			break;
 		default:
 			break;
 		}
@@ -1374,7 +1389,7 @@ int main(int argc, char *argv[])
 						 kexec_file_flags);
 		else
 			result = my_load(type, fileind, argc, argv,
-						kexec_flags, entry);
+						kexec_flags, do_lite, entry);
 	}
 	/* Don't shutdown unless there is something to reboot to! */
 	if ((result == 0) && (do_shutdown || do_exec) && !kexec_loaded()) {
kexec/kexec.h +4 -0
index 7c97b25..06e08f4 100644
@@ -165,6 +165,8 @@ struct kexec_info {
 	int initrd_fd;
 	char *command_line;
 	int command_line_len;
+
+	int kexec_lite;
 };
 
 struct arch_map_entry {
@@ -218,6 +220,7 @@ extern int file_types;
 #define OPT_TYPE		't'
 #define OPT_PANIC		'p'
 #define OPT_KEXEC_FILE_SYSCALL	's'
+#define OPT_LITE		'i'
 #define OPT_MEM_MIN             256
 #define OPT_MEM_MAX             257
 #define OPT_REUSE_INITRD	258
@@ -243,6 +246,7 @@ extern int file_types;
 	{ "mem-max",		1, 0, OPT_MEM_MAX }, \
 	{ "reuseinitrd",	0, 0, OPT_REUSE_INITRD }, \
 	{ "kexec-file-syscall",	0, 0, OPT_KEXEC_FILE_SYSCALL }, \
+	{ "lite",		0, 0, OPT_LITE }, \
 	{ "debug",		0, 0, OPT_DEBUG }, \
 
 #define KEXEC_OPT_STR "h?vdfxyluet:ps"
purgatory/purgatory.c +2 -1
index 3bbcc09..7e99b92 100644
@@ -8,6 +8,7 @@
 
 struct sha256_region sha256_regions[SHA256_REGIONS] = {};
 sha256_digest_t sha256_digest = { };
+int kexec_lite = 0;
 
 int verify_sha256_digest(void)
 {
@@ -43,7 +44,7 @@ void purgatory(void)
 {
 	printf("I'm in purgatory\n");
 	setup_arch();
-	if (verify_sha256_digest()) {
+	if (!kexec_lite && verify_sha256_digest()) {
 		for(;;) {
 			/* loop forever */
 		}
Signature · 7 lines
2.5.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw

Hi Geoff,

Quoted 4 lines

Add a new option --lite to kexec that allows for a fast reboot by avoiding the purgatory integrity checks. This option is intended for use by kexec based bootloaders that load a new image and then immediately transfer control to it.

Can we call this something other than 'lite'? I'd want to prevent any confusion when referring to 'kexec-lite', which is a separate project.

Cheers,

Jeremy

Quoted 148 lines

---
Hi Simon,

It was reported that on some systems where purgatory is running without caches enabled the sha256 calculations would take several minutes. For bootloaders that just load a new image and immediately jump into it the loss of the integrity check is worth the increase in boot speed. Please consider.

(quoted diff) +0 -1
-Geoff
 
 kexec/kexec.8         |  3 +++
 kexec/kexec.c         | 19 +++++++++++++++++--
 kexec/kexec.h         |  4 ++++
 purgatory/purgatory.c |  3 ++-
 4 files changed, 26 insertions(+), 3 deletions(-)
kexec/kexec.8 +3 -0
index 4d0c1d1..93ed588 100644
@@ -126,6 +126,9 @@ in one call.
 Open a help file for
 .BR kexec .
 .TP
+.B \-i\ (\-\-lite)
+Fast reboot, no memory integrity checks.
+.TP
 .BI \-l\ (\-\-load) \ kernel
 Load the specified
 .I kernel
kexec/kexec.c +17 -2
index ff024f3..ebb1310 100644
@@ -613,6 +613,15 @@ static void update_purgatory(struct kexec_info *info)
 		return;
 	}
 	arch_update_purgatory(info);
+
+	if (info->kexec_lite) {
+		unsigned int tmp = 1;
+
+		elf_rel_set_symbol(&info->rhdr, "kexec_lite", &tmp,
+			sizeof(tmp));
+		return;
+	}
+
 	memset(region, 0, sizeof(region));
 	sha256_starts(&ctx);
 	/* Compute a hash of the loaded kernel */
@@ -652,7 +661,7 @@ static void update_purgatory(struct kexec_info *info)
  *	Load the new kernel
  */
 static int my_load(const char *type, int fileind, int argc, char **argv,
-		   unsigned long kexec_flags, void *entry)
+		   unsigned long kexec_flags, int kexec_lite, void *entry)
 {
 	char *kernel;
 	char *kernel_buf;
@@ -665,6 +674,7 @@ static int my_load(const char *type, int fileind, int argc, char **argv,
 
 	memset(&info, 0, sizeof(info));
 	info.kexec_flags = kexec_flags;
+	info.kexec_lite = kexec_lite;
 
 	result = 0;
 	if (argc - fileind <= 0) {
@@ -914,6 +924,7 @@ void usage(void)
 	       " -v, --version        Print the version of kexec.\n"
 	       " -f, --force          Force an immediate kexec,\n"
 	       "                      don't call shutdown.\n"
+	       " -i, --lite           Fast reboot, no memory integrity checks.\n"
 	       " -x, --no-ifdown      Don't bring down network interfaces.\n"
 	       " -y, --no-sync        Don't sync filesystems before kexec.\n"
 	       " -l, --load           Load the new kernel into the\n"
@@ -1173,6 +1184,7 @@ int main(int argc, char *argv[])
 	int do_unload = 0;
 	int do_reuse_initrd = 0;
 	int do_kexec_file_syscall = 0;
+	int do_lite = 0;
 	void *entry = 0;
 	char *type = 0;
 	char *endptr;
@@ -1314,6 +1326,9 @@ int main(int argc, char *argv[])
 		case OPT_KEXEC_FILE_SYSCALL:
 			/* We already parsed it. Nothing to do. */
 			break;
+		case OPT_LITE:
+			do_lite = 1;
+			break;
 		default:
 			break;
 		}
@@ -1374,7 +1389,7 @@ int main(int argc, char *argv[])
 						 kexec_file_flags);
 		else
 			result = my_load(type, fileind, argc, argv,
-						kexec_flags, entry);
+						kexec_flags, do_lite, entry);
 	}
 	/* Don't shutdown unless there is something to reboot to! */
 	if ((result == 0) && (do_shutdown || do_exec) && !kexec_loaded()) {
kexec/kexec.h +4 -0
index 7c97b25..06e08f4 100644
@@ -165,6 +165,8 @@ struct kexec_info {
 	int initrd_fd;
 	char *command_line;
 	int command_line_len;
+
+	int kexec_lite;
 };
 
 struct arch_map_entry {
@@ -218,6 +220,7 @@ extern int file_types;
 #define OPT_TYPE		't'
 #define OPT_PANIC		'p'
 #define OPT_KEXEC_FILE_SYSCALL	's'
+#define OPT_LITE		'i'
 #define OPT_MEM_MIN             256
 #define OPT_MEM_MAX             257
 #define OPT_REUSE_INITRD	258
@@ -243,6 +246,7 @@ extern int file_types;
 	{ "mem-max",		1, 0, OPT_MEM_MAX }, \
 	{ "reuseinitrd",	0, 0, OPT_REUSE_INITRD }, \
 	{ "kexec-file-syscall",	0, 0, OPT_KEXEC_FILE_SYSCALL }, \
+	{ "lite",		0, 0, OPT_LITE }, \
 	{ "debug",		0, 0, OPT_DEBUG }, \
 
 #define KEXEC_OPT_STR "h?vdfxyluet:ps"
purgatory/purgatory.c +1 -0
index 3bbcc09..7e99b92 100644
@@ -8,6 +8,7 @@
 
 struct sha256_region sha256_regions[SHA256_REGIONS] = {};
 sha256_digest_t sha256_digest = { };
+int kexec_lite = 0;
 
 int verify_sha256_digest(void)
 {

purgatory/purgatory.c void purgatory(void) · line 50

Quoted 8 lines
purgatory/purgatory.c +1 -1
@@ -43,7 +44,7 @@ void purgatory(void)
 {
 	printf("I'm in purgatory\n");
 	setup_arch();
-	if (verify_sha256_digest()) {
+	if (!kexec_lite && verify_sha256_digest()) {
 		for(;;) {
 			/* loop forever */
 		}

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#2 lore raw

Hi Jeremy,

Quoted 8 lines · Jeremy Kerr

Add a new option --lite to kexec that allows for a fast reboot

Quoted 3 lines

by avoiding the purgatory integrity checks. This option is intended for use by kexec based bootloaders that load a new image and then immediately transfer control to it.

Can we call this something other than 'lite'? I'd want to prevent any confusion when referring to 'kexec-lite', which is a separate project.

Well, that is why I chose the name 'lite', because it mimics what kexec -lite does...

What do others think?

-Geoff

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#3 lore raw
Quoted 8 lines · Geoff Levand

Hi Jeremy,

Quoted 5 lines · Jeremy Kerr

Add a new option --lite to kexec that allows for a fast reboot

Quoted 3 lines

by avoiding the purgatory integrity checks. This option is intended for use by kexec based bootloaders that load a new image and then immediately transfer control to it.

Quoted 8 lines
Quoted 3 lines

Can we call this something other than 'lite'? I'd want to prevent any confusion when referring to 'kexec-lite', which is a separate project.

Well, that is why I chose the name 'lite', because it mimics what kexec -lite does...

What do others think?

I don't think it's a good name. Even if the user has any idea what the kexec- lite project is and that this is a reference to it, you're mimicking a specific aspect of kexec-lite behavior, not kexec-lite in general.

If it's an option to skip sha256 verification, then call it something like "-- skip-sha256".

-Scott

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw
In reply to Geoff Levand
Quoted 4 lines · Geoff Levand

Add a new option --lite to kexec that allows for a fast reboot by avoiding the purgatory integrity checks. This option is intended for use by kexec based bootloaders that load a new image and then immediately transfer control to it.

I think Vivek was rejecting this --lite since kdump need the purgatory integrity checks. Ccing him.

Quoted 10 lines

---
Hi Simon,

It was reported that on some systems where purgatory is running without caches enabled the sha256 calculations would take several minutes. For bootloaders that just load a new image and immediately jump into it the loss of the integrity check is worth the increase in boot speed. Please consider.

Pratyush reported the arm64 issue, he sent a patch to fix it with enabling cache for purgatory. I think the patch can fix the problem. Why not fix it? The fix is simple enough and it does not introduce complicate logic.

Quoted 155 lines
(quoted diff) +0 -1
-Geoff
 
 kexec/kexec.8         |  3 +++
 kexec/kexec.c         | 19 +++++++++++++++++--
 kexec/kexec.h         |  4 ++++
 purgatory/purgatory.c |  3 ++-
 4 files changed, 26 insertions(+), 3 deletions(-)
kexec/kexec.8 +3 -0
index 4d0c1d1..93ed588 100644
@@ -126,6 +126,9 @@ in one call.
 Open a help file for
 .BR kexec .
 .TP
+.B \-i\ (\-\-lite)
+Fast reboot, no memory integrity checks.
+.TP
 .BI \-l\ (\-\-load) \ kernel
 Load the specified
 .I kernel
kexec/kexec.c +17 -2
index ff024f3..ebb1310 100644
@@ -613,6 +613,15 @@ static void update_purgatory(struct kexec_info *info)
 		return;
 	}
 	arch_update_purgatory(info);
+
+	if (info->kexec_lite) {
+		unsigned int tmp = 1;
+
+		elf_rel_set_symbol(&info->rhdr, "kexec_lite", &tmp,
+			sizeof(tmp));
+		return;
+	}
+
 	memset(region, 0, sizeof(region));
 	sha256_starts(&ctx);
 	/* Compute a hash of the loaded kernel */
@@ -652,7 +661,7 @@ static void update_purgatory(struct kexec_info *info)
  *	Load the new kernel
  */
 static int my_load(const char *type, int fileind, int argc, char **argv,
-		   unsigned long kexec_flags, void *entry)
+		   unsigned long kexec_flags, int kexec_lite, void *entry)
 {
 	char *kernel;
 	char *kernel_buf;
@@ -665,6 +674,7 @@ static int my_load(const char *type, int fileind, int argc, char **argv,
 
 	memset(&info, 0, sizeof(info));
 	info.kexec_flags = kexec_flags;
+	info.kexec_lite = kexec_lite;
 
 	result = 0;
 	if (argc - fileind <= 0) {
@@ -914,6 +924,7 @@ void usage(void)
 	       " -v, --version        Print the version of kexec.\n"
 	       " -f, --force          Force an immediate kexec,\n"
 	       "                      don't call shutdown.\n"
+	       " -i, --lite           Fast reboot, no memory integrity checks.\n"
 	       " -x, --no-ifdown      Don't bring down network interfaces.\n"
 	       " -y, --no-sync        Don't sync filesystems before kexec.\n"
 	       " -l, --load           Load the new kernel into the\n"
@@ -1173,6 +1184,7 @@ int main(int argc, char *argv[])
 	int do_unload = 0;
 	int do_reuse_initrd = 0;
 	int do_kexec_file_syscall = 0;
+	int do_lite = 0;
 	void *entry = 0;
 	char *type = 0;
 	char *endptr;
@@ -1314,6 +1326,9 @@ int main(int argc, char *argv[])
 		case OPT_KEXEC_FILE_SYSCALL:
 			/* We already parsed it. Nothing to do. */
 			break;
+		case OPT_LITE:
+			do_lite = 1;
+			break;
 		default:
 			break;
 		}
@@ -1374,7 +1389,7 @@ int main(int argc, char *argv[])
 						 kexec_file_flags);
 		else
 			result = my_load(type, fileind, argc, argv,
-						kexec_flags, entry);
+						kexec_flags, do_lite, entry);
 	}
 	/* Don't shutdown unless there is something to reboot to! */
 	if ((result == 0) && (do_shutdown || do_exec) && !kexec_loaded()) {
kexec/kexec.h +4 -0
index 7c97b25..06e08f4 100644
@@ -165,6 +165,8 @@ struct kexec_info {
 	int initrd_fd;
 	char *command_line;
 	int command_line_len;
+
+	int kexec_lite;
 };
 
 struct arch_map_entry {
@@ -218,6 +220,7 @@ extern int file_types;
 #define OPT_TYPE		't'
 #define OPT_PANIC		'p'
 #define OPT_KEXEC_FILE_SYSCALL	's'
+#define OPT_LITE		'i'
 #define OPT_MEM_MIN             256
 #define OPT_MEM_MAX             257
 #define OPT_REUSE_INITRD	258
@@ -243,6 +246,7 @@ extern int file_types;
 	{ "mem-max",		1, 0, OPT_MEM_MAX }, \
 	{ "reuseinitrd",	0, 0, OPT_REUSE_INITRD }, \
 	{ "kexec-file-syscall",	0, 0, OPT_KEXEC_FILE_SYSCALL }, \
+	{ "lite",		0, 0, OPT_LITE }, \
 	{ "debug",		0, 0, OPT_DEBUG }, \
 
 #define KEXEC_OPT_STR "h?vdfxyluet:ps"
purgatory/purgatory.c +2 -1
index 3bbcc09..7e99b92 100644
@@ -8,6 +8,7 @@
 
 struct sha256_region sha256_regions[SHA256_REGIONS] = {};
 sha256_digest_t sha256_digest = { };
+int kexec_lite = 0;
 
 int verify_sha256_digest(void)
 {
@@ -43,7 +44,7 @@ void purgatory(void)
 {
 	printf("I'm in purgatory\n");
 	setup_arch();
-	if (verify_sha256_digest()) {
+	if (!kexec_lite && verify_sha256_digest()) {
 		for(;;) {
 			/* loop forever */
 		}
Signature · 7 lines
2.5.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#5 lore raw
Quoted 8 lines · Dave Young
Quoted 4 lines · Geoff Levand

Add a new option --lite to kexec that allows for a fast reboot by avoiding the purgatory integrity checks. This option is intended for use by kexec based bootloaders that load a new image and then immediately transfer control to it.

I think Vivek was rejecting this --lite since kdump need the purgatory integrity checks. Ccing him.

Right. Why are we trying to bypass sha256 hash verification of loaded segments at run time, that needs to be justified.

Atleast on x86, this integrity verification was fast and we did not notice any siginificant delays in purgatory. And in that case extra knob like this is hard to justify.

Thanks
Vivek

Quoted 166 lines
Quoted 11 lines

---
Hi Simon,

It was reported that on some systems where purgatory is running without caches enabled the sha256 calculations would take several minutes. For bootloaders that just load a new image and immediately jump into it the loss of the integrity check is worth the increase in boot speed. Please consider.

Pratyush reported the arm64 issue, he sent a patch to fix it with enabling cache for purgatory. I think the patch can fix the problem. Why not fix it? The fix is simple enough and it does not introduce complicate logic.

Quoted 149 lines
(quoted diff) +0 -1
-Geoff
 
 kexec/kexec.8         |  3 +++
 kexec/kexec.c         | 19 +++++++++++++++++--
 kexec/kexec.h         |  4 ++++
 purgatory/purgatory.c |  3 ++-
 4 files changed, 26 insertions(+), 3 deletions(-)
kexec/kexec.8 +3 -0
index 4d0c1d1..93ed588 100644
@@ -126,6 +126,9 @@ in one call.
 Open a help file for
 .BR kexec .
 .TP
+.B \-i\ (\-\-lite)
+Fast reboot, no memory integrity checks.
+.TP
 .BI \-l\ (\-\-load) \ kernel
 Load the specified
 .I kernel
kexec/kexec.c +17 -2
index ff024f3..ebb1310 100644
@@ -613,6 +613,15 @@ static void update_purgatory(struct kexec_info *info)
 		return;
 	}
 	arch_update_purgatory(info);
+
+	if (info->kexec_lite) {
+		unsigned int tmp = 1;
+
+		elf_rel_set_symbol(&info->rhdr, "kexec_lite", &tmp,
+			sizeof(tmp));
+		return;
+	}
+
 	memset(region, 0, sizeof(region));
 	sha256_starts(&ctx);
 	/* Compute a hash of the loaded kernel */
@@ -652,7 +661,7 @@ static void update_purgatory(struct kexec_info *info)
  *	Load the new kernel
  */
 static int my_load(const char *type, int fileind, int argc, char **argv,
-		   unsigned long kexec_flags, void *entry)
+		   unsigned long kexec_flags, int kexec_lite, void *entry)
 {
 	char *kernel;
 	char *kernel_buf;
@@ -665,6 +674,7 @@ static int my_load(const char *type, int fileind, int argc, char **argv,
 
 	memset(&info, 0, sizeof(info));
 	info.kexec_flags = kexec_flags;
+	info.kexec_lite = kexec_lite;
 
 	result = 0;
 	if (argc - fileind <= 0) {
@@ -914,6 +924,7 @@ void usage(void)
 	       " -v, --version        Print the version of kexec.\n"
 	       " -f, --force          Force an immediate kexec,\n"
 	       "                      don't call shutdown.\n"
+	       " -i, --lite           Fast reboot, no memory integrity checks.\n"
 	       " -x, --no-ifdown      Don't bring down network interfaces.\n"
 	       " -y, --no-sync        Don't sync filesystems before kexec.\n"
 	       " -l, --load           Load the new kernel into the\n"
@@ -1173,6 +1184,7 @@ int main(int argc, char *argv[])
 	int do_unload = 0;
 	int do_reuse_initrd = 0;
 	int do_kexec_file_syscall = 0;
+	int do_lite = 0;
 	void *entry = 0;
 	char *type = 0;
 	char *endptr;
@@ -1314,6 +1326,9 @@ int main(int argc, char *argv[])
 		case OPT_KEXEC_FILE_SYSCALL:
 			/* We already parsed it. Nothing to do. */
 			break;
+		case OPT_LITE:
+			do_lite = 1;
+			break;
 		default:
 			break;
 		}
@@ -1374,7 +1389,7 @@ int main(int argc, char *argv[])
 						 kexec_file_flags);
 		else
 			result = my_load(type, fileind, argc, argv,
-						kexec_flags, entry);
+						kexec_flags, do_lite, entry);
 	}
 	/* Don't shutdown unless there is something to reboot to! */
 	if ((result == 0) && (do_shutdown || do_exec) && !kexec_loaded()) {
kexec/kexec.h +4 -0
index 7c97b25..06e08f4 100644
@@ -165,6 +165,8 @@ struct kexec_info {
 	int initrd_fd;
 	char *command_line;
 	int command_line_len;
+
+	int kexec_lite;
 };
 
 struct arch_map_entry {
@@ -218,6 +220,7 @@ extern int file_types;
 #define OPT_TYPE		't'
 #define OPT_PANIC		'p'
 #define OPT_KEXEC_FILE_SYSCALL	's'
+#define OPT_LITE		'i'
 #define OPT_MEM_MIN             256
 #define OPT_MEM_MAX             257
 #define OPT_REUSE_INITRD	258
@@ -243,6 +246,7 @@ extern int file_types;
 	{ "mem-max",		1, 0, OPT_MEM_MAX }, \
 	{ "reuseinitrd",	0, 0, OPT_REUSE_INITRD }, \
 	{ "kexec-file-syscall",	0, 0, OPT_KEXEC_FILE_SYSCALL }, \
+	{ "lite",		0, 0, OPT_LITE }, \
 	{ "debug",		0, 0, OPT_DEBUG }, \
 
 #define KEXEC_OPT_STR "h?vdfxyluet:ps"
purgatory/purgatory.c +2 -1
index 3bbcc09..7e99b92 100644
@@ -8,6 +8,7 @@
 
 struct sha256_region sha256_regions[SHA256_REGIONS] = {};
 sha256_digest_t sha256_digest = { };
+int kexec_lite = 0;
 
 int verify_sha256_digest(void)
 {
@@ -43,7 +44,7 @@ void purgatory(void)
 {
 	printf("I'm in purgatory\n");
 	setup_arch();
-	if (verify_sha256_digest()) {
+	if (!kexec_lite && verify_sha256_digest()) {
 		for(;;) {
 			/* loop forever */
 		}
Signature · 1 line
2.5.0
Quoted 6 lines
Quoted 6 lines

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#6 lore raw

Hi Vivek,

Quoted 7 lines · Vivek Goyal
Quoted 6 lines · Dave Young
Quoted 4 lines · Geoff Levand

Add a new option --lite to kexec that allows for a fast reboot by avoiding the purgatory integrity checks. This option is intended for use by kexec based bootloaders that load a new image and then immediately transfer control to it.

Quoted 5 lines
Quoted 2 lines

I think Vivek was rejecting this --lite since kdump need the purgatory integrity checks. Ccing him.

Right. Why are we trying to bypass sha256 hash verification of loaded segments at run time, that needs to be justified.

Please see my reply to Dave.

Quoted 3 lines

Atleast on x86, this integrity verification was fast and we did not notice any siginificant delays in purgatory. And in that case extra knob like this is hard to justify.

I notice the difference on the my arm64 system, so I guess we are even on that.

In general, faster boot times are desirable. This option allows a faster system boot for kexec based bootloaders that use kexec-tools.

-Geoff

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#7 lore raw
Quoted 16 lines · Geoff Levand

Hi Vivek,

Quoted 7 lines · Vivek Goyal
Quoted 6 lines · Dave Young
Quoted 4 lines · Geoff Levand

Add a new option --lite to kexec that allows for a fast reboot by avoiding the purgatory integrity checks. This option is intended for use by kexec based bootloaders that load a new image and then immediately transfer control to it.

Quoted 5 lines
Quoted 2 lines

I think Vivek was rejecting this --lite since kdump need the purgatory integrity checks. Ccing him.

Right. Why are we trying to bypass sha256 hash verification of loaded segments at run time, that needs to be justified.

Quoted 8 lines

Please see my reply to Dave.

Quoted 3 lines

Atleast on x86, this integrity verification was fast and we did not notice any siginificant delays in purgatory. And in that case extra knob like this is hard to justify.

I notice the difference on the my arm64 system, so I guess we are even on that.

For me it was beyond "notice the difference" -- I thought it was completely broken, and was preparing to debug, until it started spitting out output over a minute later.

Compiling the sha256 code with -O2 instead of -O0 cut it down to around 10 seconds (still unpleasant, but not quite as crazy... still unacceptable for non-kdump, though). There was a patch posted a couple years ago to do that -- does anyone know what happened to it?

http://kexec.infradead.narkive.com/JSemzXoT/patch-purgatory-compile-sha256-c-only-on-ia64-with-o0

-Scott

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#8 lore raw

[email protected] (May be someone from arm kernel list can give some more input)

Quoted 11 lines · Scott Wood
Quoted 2 lines · Geoff Levand

I notice the difference on the my arm64 system, so I guess we are even on that.

For me it was beyond "notice the difference" -- I thought it was completely broken, and was preparing to debug, until it started spitting out output over a minute later.

Compiling the sha256 code with -O2 instead of -O0 cut it down to around 10 seconds (still unpleasant, but not quite as crazy... still unacceptable for non-kdump, though).

Yes, compiling purgatory code with -O2 helps to improve the timing, and I notice that enabling D-cache on top of -O2 does not improve it further. However, I am still not able to understand that why there is huge difference between following two.

1) When we execute kexec() system call in first kernel, at that time it calculates sha256 on all the binaries [1]. It take almost un-noticeable time (less than a sec) there.

2) When purgatory is executed then it re-calculates sha256 using same routines
[2] on same binary data as that of case (1). But, now it takes 10-20 sec (depending of size of binaries)?

Why did not it take same time with O2 + D-cache enabled? I think, we should be able to achieve same time in second case as well. What is missing?

~Pratyush

[1] http://git.kernel.org/cgit/utils/kernel/kexec/kexec-tools.git/tree/kexec/kexec.c#n650
[2] http://git.kernel.org/cgit/utils/kernel/kexec/kexec-tools.git/tree/purgatory/purgatory.c#n20

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#9 lore raw

Sorry, forgot to add [email protected]. Now CCed.

Quoted 29 lines · Pratyush Anand

[email protected] (May be someone from arm kernel list can give some more input)

Quoted 11 lines · Scott Wood
Quoted 2 lines · Geoff Levand

I notice the difference on the my arm64 system, so I guess we are even on that.

For me it was beyond "notice the difference" -- I thought it was completely broken, and was preparing to debug, until it started spitting out output over a minute later.

Compiling the sha256 code with -O2 instead of -O0 cut it down to around 10 seconds (still unpleasant, but not quite as crazy... still unacceptable for non-kdump, though).

Yes, compiling purgatory code with -O2 helps to improve the timing, and I notice that enabling D-cache on top of -O2 does not improve it further. However, I am still not able to understand that why there is huge difference between following two.

1) When we execute kexec() system call in first kernel, at that time it calculates sha256 on all the binaries [1]. It take almost un-noticeable time (less than a sec) there.

2) When purgatory is executed then it re-calculates sha256 using same routines
[2] on same binary data as that of case (1). But, now it takes 10-20 sec (depending of size of binaries)?

Quoted 7 lines

Why did not it take same time with O2 + D-cache enabled? I think, we should be able to achieve same time in second case as well. What is missing?

~Pratyush

[1] http://git.kernel.org/cgit/utils/kernel/kexec/kexec-tools.git/tree/kexec/kexec.c#n650
[2] http://git.kernel.org/cgit/utils/kernel/kexec/kexec-tools.git/tree/purgatory/purgatory.c#n20

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#10 lore raw

Hi Pratyush,

Quoted 10 lines · Pratyush Anand
Quoted 10 lines

1) When we execute kexec() system call in first kernel, at that time it calculates sha256 on all the binaries [1]. It take almost un-noticeable time (less than a sec) there.

2) When purgatory is executed then it re-calculates sha256 using same routines
[2] on same binary data as that of case (1). But, now it takes 10-20 sec (depending of size of binaries)?

Why did not it take same time with O2 + D-cache enabled? I think, we should be able to achieve same time in second case as well. What is missing?

I haven't benchmarked this, but:

util_lib/sha256.c contains calls out to memcpy().
In your case 1, this will use the glibc version. In case 2, it will use the version implemented in purgatory/string.c, which is a byte-by-byte copy.

Thanks,

James

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#11 lore raw

Hi James,

Thanks for the reply.

Quoted 11 lines · James Morse

Hi Pratyush,

Quoted 8 lines · Pratyush Anand
Quoted 8 lines

1) When we execute kexec() system call in first kernel, at that time it calculates sha256 on all the binaries [1]. It take almost un-noticeable time (less than a sec) there.

2) When purgatory is executed then it re-calculates sha256 using same routines
[2] on same binary data as that of case (1). But, now it takes 10-20 sec (depending of size of binaries)?

Quoted 9 lines
Quoted 2 lines
Quoted 2 lines

Why did not it take same time with O2 + D-cache enabled? I think, we should be able to achieve same time in second case as well. What is missing?

I haven't benchmarked this, but:

util_lib/sha256.c contains calls out to memcpy().
In your case 1, this will use the glibc version. In case 2, it will use the version implemented in purgatory/string.c, which is a byte-by-byte copy.

Yes, I agree that byte copy is too slow. But, memcpy() in sha256_update() will copy only few bytes (I think max 126 bytes). Most of the data will be processed using loop while( length >= 64 ){}, where we do not have any memcpy.So, I do not think that this would be causing such a difference.

Could it be the case that I am not using perfect memory attributes while setting up identity mapping and enabling D-cache. My implementation is here:
https://github.com/pratyushanand/kexec-tools/commit/8efdbc56b52f99a8a074edd0ddc519d7b68be82f

~Pratyush

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#12 lore raw
Quoted 40 lines · Pratyush Anand

Hi James,

Thanks for the reply.

Quoted 19 lines · James Morse

Hi Pratyush,

Quoted 12 lines · Pratyush Anand
Quoted 12 lines

1) When we execute kexec() system call in first kernel, at that time it
calculates sha256 on all the binaries [1]. It take almost un -noticeable time
(less than a sec) there.

2) When purgatory is executed then it re-calculates sha256 using same routines
[2] on same binary data as that of case (1). But, now it takes 10-20 sec
(depending of size of binaries)?

Quoted 3 lines
Quoted 3 lines

Why did not it take same time with O2 + D-cache enabled? I think, we should be
able to achieve same time in second case as well. What is missing?

Quoted 7 lines

I haven't benchmarked this, but:

util_lib/sha256.c contains calls out to memcpy().
In your case 1, this will use the glibc version. In case 2, it will use the version implemented in purgatory/string.c, which is a byte-by-byte copy.

Yes, I agree that byte copy is too slow. But, memcpy() in sha256_update() will
copy only few bytes (I think max 126 bytes). Most of the data will be processed
using loop while( length >= 64 ){}, where we do not have any memcpy.So, I do not
think that this would be causing such a difference.

Quoted 5 lines

Could it be the case that I am not using perfect memory attributes while setting
up identity mapping and enabling D-cache. My implementation is here:
https://github.com/pratyushanand/kexec-tools/commit/8efdbc56b52f99a8a074edd0
ddc519d7b68be82f

FWIW, purgatory is fast for me on PPC (sub-second), so between that (assuming it's not due to some PPC-specific optimization) and the fact that you don't see any improvement with cache, I'd guess there's something wrong with how you're enabling caches.

-Scott

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#13 lore raw
In reply to Pratyush Anand

Hi Pratyush,

Quoted 8 lines · Pratyush Anand
Quoted 6 lines · James Morse

I haven't benchmarked this, but:

util_lib/sha256.c contains calls out to memcpy().
In your case 1, this will use the glibc version. In case 2, it will use the version implemented in purgatory/string.c, which is a byte-by-byte copy.

Quoted 4 lines

Yes, I agree that byte copy is too slow. But, memcpy() in sha256_update() will copy only few bytes (I think max 126 bytes). Most of the data will be processed using loop while( length >= 64 ){}, where we do not have any memcpy.So, I do not think that this would be causing such a difference.

You're right, I benchmarked the two sha256.o files checksumming a 10MB buffer - one takes 0.6s, the other 1.7s, we can probably expect a couple of seconds to do this.

Is the sha256 really useful? Purgatory can't print out an error message, if it fails...

Quoted 3 lines

Could it be the case that I am not using perfect memory attributes while setting up identity mapping and enabling D-cache. My implementation is here:
https://github.com/pratyushanand/kexec-tools/commit/8efdbc56b52f99a8a074edd0ddc519d7b68be82f

I'm no expert, but that looks like you're setting it up as 'normal' memory. You're missing some isb-s and tlbi-s: depending on how long the changes to system state take, you may be using old memory-attributes or page-tables. If you depend on a change to system state, (like turning the mmu on), you need explicit synchronisation, see section 12.3.2 of the 'Architecture Programmers Guide' (arm den0024a), and D7.1.2 of the ARM ARM.

I haven't managed to get your kexec-tools branch to work with v10 of Geoff's series. It looks like you save registers to the stack, which give stale values once you turn the mmu off. You also do the opposite, saving registers with the mmu off, then cleaning cache lines over the top, corrupting the saved registers.

The page size of 64K is hard coded. Kexec-ing from a 4K kernel, to a 4K kernel will work, but only if the hardware also supports 64K, this will be surprising to debug.

Thanks,

James

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#14 lore raw

Hi James,

Quoted 16 lines · James Morse

Hi Pratyush,

Quoted 8 lines · Pratyush Anand
Quoted 6 lines · James Morse

I haven't benchmarked this, but:

util_lib/sha256.c contains calls out to memcpy().
In your case 1, this will use the glibc version. In case 2, it will use the version implemented in purgatory/string.c, which is a byte-by-byte copy.

Quoted 4 lines

Yes, I agree that byte copy is too slow. But, memcpy() in sha256_update() will copy only few bytes (I think max 126 bytes). Most of the data will be processed using loop while( length >= 64 ){}, where we do not have any memcpy.So, I do not think that this would be causing such a difference.

Quoted 6 lines

You're right, I benchmarked the two sha256.o files checksumming a 10MB buffer - one takes 0.6s, the other 1.7s, we can probably expect a couple of seconds to do this.

Is the sha256 really useful? Purgatory can't print out an error message, if it fails...

kdump needs the sha256 integrity checks. Please see previous reply from Dave, Vivek and Eric in this thread.

Purgatory prints error message, in case sha256 fails. It prints expected and calculated sha256 values. You must pass --port with proper value to see print messages. Geoff has been able to see purgatory debug messages on foundation model only with --port, however I need below patch and pass --port-lsr as well in order to print all the characters properly.
https://github.com/pratyushanand/kexec-tools/commit/ab30f4015189b177dd2e78980f5b7e47c2d22fe4

So, on a system having pl011 base address 0xe1010000, I pass --port=0xe1010000 --port-lsr=0xe1010018,0x80 to the kexec command.

Quoted 6 lines
Quoted 5 lines

Could it be the case that I am not using perfect memory attributes while setting up identity mapping and enabling D-cache. My implementation is here:
https://github.com/pratyushanand/kexec-tools/commit/8efdbc56b52f99a8a074edd0ddc519d7b68be82f

First of all, thanks a lot for taking out your time to review it :-)

Quoted 1 line

I'm no expert, but that looks like you're setting it up as 'normal'

Me too not an expert.

Shouldn't it be normal type memory? I think, I will need to define only UART area as device type (currently it is not defined, and so I am not able to use print message while mmu is enabled).

Quoted 6 lines

memory. You're missing some isb-s and tlbi-s: depending on how long the changes to system state take, you may be using old memory-attributes or page-tables. If you depend on a change to system state, (like turning the mmu on), you need explicit synchronisation, see section 12.3.2 of the 'Architecture Programmers Guide' (arm den0024a), and D7.1.2 of the ARM ARM.

I will go through these docs and kernel arch/arm64/kernel/head.S and will rewrite the cache implementation.

Quoted 2 lines

I haven't managed to get your kexec-tools branch to work with v10 of

May be you can try master branch. It is almost same as that of Geoff's. Additionally, it has support to "wait for transmit completion before next character transmission".

Quoted 8 lines

Geoff's series. It looks like you save registers to the stack, which give stale values once you turn the mmu off. You also do the opposite, saving registers with the mmu off, then cleaning cache lines over the top, corrupting the saved registers.

The page size of 64K is hard coded. Kexec-ing from a 4K kernel, to a 4K kernel will work, but only if the hardware also supports 64K, this will be surprising to debug.

OK, I will take care in the re-implementation.

Thanks

~Pratyush

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#15 lore raw

+Fu

Hi James,

Quoted 4 lines · James Morse
Quoted 3 lines

Hi Pratyush,

I haven't managed to get your kexec-tools branch to work with v10 of

Thanks for all your feedback. It helped to stabilize the code better. I took all your suggestions and also did few other modifications [1]. Now, purgatory does SHA verifications on mustang and seattle within a second. I think this would be helpful in handling few of the kdump issues with watchdog. May be you can give a try to the code in branch purgatory-enable-dcache of my tree. Any feedback would be welcome.

~Pratyush

[1] https://github.com/pratyushanand/kexec-tools/commit/5679d4baaa5e644f8302982c6f468214ed3d3f3d

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#16 lore raw
Quoted 7 lines · Pratyush Anand

+Fu

Hi James,

Quoted 2 lines · James Morse
Quoted 1 line

Hi Pratyush,

Quoted 8 lines
Quoted 1 line
Quoted 1 line

I haven't managed to get your kexec-tools branch to work with v10 of

Thanks for all your feedback. It helped to stabilize the code better. I took all your suggestions and also did few other modifications [1]. Now, purgatory does SHA verifications on mustang and seattle within a second. I think this would be helpful in handling few of the kdump issues with watchdog. May be you can give a try to the code in branch purgatory-enable-dcache of my tree. Any feedback would be welcome.

Please post the patches here for review.

Thanks

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#17 lore raw
In reply to Dave Young

Hi Dave,

Quoted 8 lines · Dave Young
Quoted 4 lines · Geoff Levand

Add a new option --lite to kexec that allows for a fast reboot by avoiding the purgatory integrity checks. This option is intended for use by kexec based bootloaders that load a new image and then immediately transfer control to it.

I think Vivek was rejecting this --lite since kdump need the purgatory integrity checks. Ccing him.

As stated, this is not intended for use by kdump.

This is an optional feature. It does not remove the integrity checks, but provides the user a way to bypass them if they so desire.

Quoted 10 lines
Quoted 5 lines

It was reported that on some systems where purgatory is running without caches enabled the sha256 calculations would take several minutes. For bootloaders that just load a new image and immediately jump into it the loss of the integrity check is worth the increase in boot speed. Please consider.

Pratyush reported the arm64 issue, he sent a patch to fix it with enabling cache for purgatory. I think the patch can fix the problem. Why not fix it? The fix is simple enough and it does not introduce complicate logic.

This patch also is simple, and is architecture independent. I see this feature as an improvement to kexec, not necessarily as a fix for that problem.

-Geoff

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#18 lore raw
Quoted 9 lines · Geoff Levand

Hi Dave,

Quoted 6 lines · Dave Young
Quoted 4 lines · Geoff Levand

Add a new option --lite to kexec that allows for a fast reboot by avoiding the purgatory integrity checks. This option is intended for use by kexec based bootloaders that load a new image and then immediately transfer control to it.

Quoted 8 lines
Quoted 2 lines

I think Vivek was rejecting this --lite since kdump need the purgatory integrity checks. Ccing him.

As stated, this is not intended for use by kdump.

This is an optional feature. It does not remove the integrity checks, but provides the user a way to bypass them if they so desire.

Why would somebody like to bypass these checks?

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

It was reported that on some systems where purgatory is running without caches enabled the sha256 calculations would take several minutes. For bootloaders that just load a new image and immediately jump into it the loss of the integrity check is worth the increase in boot speed. Please consider.

Quoted 8 lines
Quoted 4 lines

Pratyush reported the arm64 issue, he sent a patch to fix it with enabling cache for purgatory. I think the patch can fix the problem. Why not fix it? The fix is simple enough and it does not introduce complicate logic.

This patch also is simple, and is architecture independent. I see this feature as an improvement to kexec, not necessarily as a fix for that problem.

I am not sure why does somebody care if segments are being checked during transition or not?

Thanks
Vivek

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#19 lore raw
In reply to Geoff Levand

Hi, Geoff

Quoted 9 lines · Geoff Levand

Hi Dave,

Quoted 6 lines · Dave Young
Quoted 4 lines · Geoff Levand

Add a new option --lite to kexec that allows for a fast reboot by avoiding the purgatory integrity checks. This option is intended for use by kexec based bootloaders that load a new image and then immediately transfer control to it.

Quoted 8 lines
Quoted 2 lines

I think Vivek was rejecting this --lite since kdump need the purgatory integrity checks. Ccing him.

As stated, this is not intended for use by kdump.

This is an optional feature. It does not remove the integrity checks, but provides the user a way to bypass them if they so desire.

Problem is why they so desire to skip purgatory? what is the background? If the only problem is the performace issue without cache enabled then I think it is not a strong one. We have a design to verify the image and it works why can't we maintain it and fix the issue instead of introducing the --lite?

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#20 lore raw

Hi Dave,

Quoted 8 lines · Dave Young
Quoted 5 lines · Geoff Levand

As stated, this is not intended for use by kdump.

This is an optional feature. It does not remove the integrity checks, but provides the user a way to bypass them if they so desire.

Problem is why they so desire to skip purgatory? what is the background?

This doesn't remove or skip purgatory. Purgatory is still used.

What it does do is skip the digest calculations that are done when an image is loaded (kexec --load), and it skips the digest calculations and comparison when the new image is run (kexec --exec).

The digest check is great for kdump, where the crash kernel is loaded, and some time later a possibly unstable system tries to do a kexec and we want to assure the integrity of the new image. Kexec based bootloaders are very different. They are running in a stable state. They load a new image and immediately transfer control to that new image. Because the system is in a stable state, and very little is done between the time the image is loaded and the time it is entered, there is little reason to do an integrity check, and by avoiding it we can speed up the boot process.

Faster boot (and re-boot) time is important to users, vendors, highly available systems, they all want it.

-Geoff

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#21 lore raw
In reply to Geoff Levand
Quoted 6 lines · Geoff Levand
Quoted 6 lines
Quoted 5 lines

It was reported that on some systems where purgatory is running without caches enabled the sha256 calculations would take several minutes. For bootloaders that just load a new image and immediately jump into it the loss of the integrity check is worth the increase in boot speed. Please consider.

Quoted 8 lines
Quoted 4 lines

Pratyush reported the arm64 issue, he sent a patch to fix it with enabling cache for purgatory. I think the patch can fix the problem. Why not fix it? The fix is simple enough and it does not introduce complicate logic.

This patch also is simple, and is architecture independent. I see this feature as an improvement to kexec, not necessarily as a fix for that problem.

Disabling image verification is not an improvement, all it does is allow for a nasty form of heisenbug.

Eric

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#22 lore raw

PATCH v2 1/1 kexec: Add --no-checks option

In reply to Geoff Levand

Add a new option --no-checks to kexec that allows for a fast reboot by avoiding the purgatory integrity checks. This option is intended for use by kexec based bootloaders that load a new image and then immediately transfer control to it.

---
Hi Simon,

Quoted 7 lines · Geoff Levand

Hi Simon,

It was reported that on some systems where purgatory is running without caches enabled the sha256 calculations would take several minutes. For bootloaders that just load a new image and immediately jump into it the loss of the integrity check is worth the increase in boot speed. Please consider.

There seems to be continued interest in faster kexec re-boot times on arm64 systems so I rebased my old patch and renamed the option from '--lite' to '--no-checks'. Please consider.

-Geoff

 kexec/kexec.8         |  3 +++
 kexec/kexec.c         | 19 +++++++++++++++++--
 kexec/kexec.h         |  6 +++++-
 purgatory/purgatory.c |  3 ++-
 4 files changed, 27 insertions(+), 4 deletions(-)
kexec/kexec.8 +3 -0
index fb8a4c9..2fafaaa 100644
@@ -132,6 +132,9 @@ in one call.
 Open a help file for
 .BR kexec .
 .TP
+.B \-i\ (\-\-no-checks)
+Fast reboot, no memory integrity checks.
+.TP
 .BI \-l\ (\-\-load) \ kernel
 Load the specified
 .I kernel
kexec/kexec.c +17 -2
index 313d9fe..a512047 100644
@@ -647,6 +647,15 @@ static void update_purgatory(struct kexec_info *info)
 		return;
 	}
 	arch_update_purgatory(info);
+
+	if (info->skip_checks) {
+		unsigned int tmp = 1;
+
+		elf_rel_set_symbol(&info->rhdr, "skip_checks", &tmp,
+			sizeof(tmp));
+		return;
+	}
+
 	memset(region, 0, sizeof(region));
 	sha256_starts(&ctx);
 	/* Compute a hash of the loaded kernel */
@@ -686,7 +695,7 @@ static void update_purgatory(struct kexec_info *info)
  *	Load the new kernel
  */
 static int my_load(const char *type, int fileind, int argc, char **argv,
-		   unsigned long kexec_flags, void *entry)
+		   unsigned long kexec_flags, int skip_checks, void *entry)
 {
 	char *kernel;
 	char *kernel_buf;
@@ -699,6 +708,7 @@ static int my_load(const char *type, int fileind, int argc, char **argv,
 
 	memset(&info, 0, sizeof(info));
 	info.kexec_flags = kexec_flags;
+	info.skip_checks = skip_checks;
 
 	result = 0;
 	if (argc - fileind <= 0) {
@@ -980,6 +990,7 @@ void usage(void)
 	       " -v, --version        Print the version of kexec.\n"
 	       " -f, --force          Force an immediate kexec,\n"
 	       "                      don't call shutdown.\n"
+	       " -i, --no-checks      Fast reboot, no memory integrity checks.\n"
 	       " -x, --no-ifdown      Don't bring down network interfaces.\n"
 	       " -y, --no-sync        Don't sync filesystems before kexec.\n"
 	       " -l, --load           Load the new kernel into the\n"
@@ -1250,6 +1261,7 @@ int main(int argc, char *argv[])
 	int do_reuse_initrd = 0;
 	int do_kexec_file_syscall = 0;
 	int do_kexec_fallback = 0;
+	int skip_checks = 0;
 	int do_status = 0;
 	void *entry = 0;
 	char *type = 0;
@@ -1385,6 +1397,9 @@ int main(int argc, char *argv[])
 			do_kexec_file_syscall = 1;
 			do_kexec_fallback = 1;
 			break;
+		case OPT_NOCHECKS:
+			skip_checks = 1;
+			break;
 		case OPT_STATUS:
 			do_status = 1;
 			break;
@@ -1519,7 +1534,7 @@ int main(int argc, char *argv[])
 		}
 		if (!do_kexec_file_syscall)
 			result = my_load(type, fileind, argc, argv,
-						kexec_flags, entry);
+						kexec_flags, skip_checks, entry);
 	}
 	/* Don't shutdown unless there is something to reboot to! */
 	if ((result == 0) && (do_shutdown || do_exec) && !kexec_loaded(KEXEC_LOADED_PATH)) {
kexec/kexec.h +5 -1
index d445fbe..a97b9ce 100644
@@ -166,6 +166,8 @@ struct kexec_info {
 	int initrd_fd;
 	char *command_line;
 	int command_line_len;
+
+	int skip_checks;
 };
 
 struct arch_map_entry {
@@ -211,6 +213,7 @@ extern int file_types;
 #define OPT_VERSION		'v'
 #define OPT_DEBUG		'd'
 #define OPT_FORCE		'f'
+#define OPT_NOCHECKS		'i'
 #define OPT_NOIFDOWN		'x'
 #define OPT_NOSYNC		'y'
 #define OPT_EXEC		'e'
@@ -234,6 +237,7 @@ extern int file_types;
 	{ "help",		0, 0, OPT_HELP }, \
 	{ "version",		0, 0, OPT_VERSION }, \
 	{ "force",		0, 0, OPT_FORCE }, \
+	{ "no-checks",		0, 0, OPT_NOCHECKS }, \
 	{ "no-ifdown",		0, 0, OPT_NOIFDOWN }, \
 	{ "no-sync",		0, 0, OPT_NOSYNC }, \
 	{ "load",		0, 0, OPT_LOAD }, \
@@ -254,7 +258,7 @@ extern int file_types;
 	{ "status",		0, 0, OPT_STATUS }, \
 	{ "print-ckr-size",     0, 0, OPT_PRINT_CKR_SIZE }, \
 
-#define KEXEC_OPT_STR "h?vdfxyluet:pscaS"
+#define KEXEC_OPT_STR "h?vdfixyluet:pscaS"
 
 extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);
 extern void die(const char *fmt, ...)
purgatory/purgatory.c +2 -1
index 3bbcc09..73930aa 100644
@@ -8,6 +8,7 @@
 
 struct sha256_region sha256_regions[SHA256_REGIONS] = {};
 sha256_digest_t sha256_digest = { };
+int skip_checks = 0;
 
 int verify_sha256_digest(void)
 {
@@ -43,7 +44,7 @@ void purgatory(void)
 {
 	printf("I'm in purgatory\n");
 	setup_arch();
-	if (verify_sha256_digest()) {
+	if (!skip_checks && verify_sha256_digest()) {
 		for(;;) {
 			/* loop forever */
 		}
Signature · 8 lines
2.14.1



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Applied
#23 lore raw

Re: [PATCH v2] kexec: Add --no-checks option

Quoted 18 lines · Geoff Levand

Add a new option --no-checks to kexec that allows for a fast reboot by avoiding the purgatory integrity checks. This option is intended for use by kexec based bootloaders that load a new image and then immediately transfer control to it.

---
Hi Simon,

Quoted 7 lines · Geoff Levand

Hi Simon,

It was reported that on some systems where purgatory is running without caches enabled the sha256 calculations would take several minutes. For bootloaders that just load a new image and immediately jump into it the loss of the integrity check is worth the increase in boot speed. Please consider.

Quoted 3 lines

There seems to be continued interest in faster kexec re-boot times on arm64 systems so I rebased my old patch and renamed the option from '--lite' to '--no-checks'. Please consider.

Thanks, applied.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec