Skip to content

Instantly share code, notes, and snippets.

@Tasssadar
Created November 28, 2012 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tasssadar/4164675 to your computer and use it in GitHub Desktop.
Save Tasssadar/4164675 to your computer and use it in GitHub Desktop.
From: Mike Kasick <mike@kasick.org>
Date: Mon, 12 Sep 2011 16:59:13 -0400
Add --load-hardboot option and support KEXEC_HARDBOOT flag.
diff --git a/jni/kexec/kexec-syscall.h b/jni/kexec/kexec-syscall.h
--- a/jni/kexec/kexec-syscall.h
+++ b/jni/kexec/kexec-syscall.h
@@ -78,6 +78,7 @@
#define KEXEC_ON_CRASH 0x00000001
#define KEXEC_PRESERVE_CONTEXT 0x00000002
+#define KEXEC_HARDBOOT 0x00000004
#define KEXEC_ARCH_MASK 0xffff0000
/* These values match the ELF architecture values.
diff --git a/jni/kexec/kexec.c b/jni/kexec/kexec.c
--- a/jni/kexec/kexec.c
+++ b/jni/kexec/kexec.c
@@ -899,6 +899,7 @@
" context of current kernel during kexec.\n"
" --load-jump-back-helper Load a helper image to jump back\n"
" to original kernel.\n"
+ " --load-hardboot Load the new kernel and hard boot it.\n"
"\n"
"Supported kernel file types and options: \n");
for (i = 0; i < file_types; i++) {
@@ -1161,6 +1162,12 @@
case OPT_REUSE_INITRD:
do_reuse_initrd = 1;
break;
+ case OPT_LOAD_HARDBOOT:
+ do_load = 1;
+ do_exec = 0;
+ do_shutdown = 0;
+ kexec_flags = KEXEC_HARDBOOT;
+ break;
default:
break;
}
@@ -1180,6 +1187,12 @@
die("\"--mem-max\" parameter\n");
}
+ if (do_load && (kexec_flags & KEXEC_HARDBOOT) && mem_min == 0) {
+ printf("Please specify memory range used by kexeced kernel\n");
+ printf("to avoid being overwritten by on reboot with the\n");
+ die("\"--min-max\" parameter\n");
+ }
+
fileind = optind;
/* Reset getopt for the next pass; called in other source modules */
opterr = 1;
diff --git a/jni/kexec/kexec.h b/jni/kexec/kexec.h
--- a/jni/kexec/kexec.h
+++ b/jni/kexec/kexec.h
@@ -178,7 +178,8 @@
#define OPT_LOAD_PRESERVE_CONTEXT 259
#define OPT_LOAD_JUMP_BACK_HELPER 260
#define OPT_ENTRY 261
-#define OPT_MAX 262
+#define OPT_LOAD_HARDBOOT 262
+#define OPT_MAX 263
#define KEXEC_OPTIONS \
{ "help", 0, 0, OPT_HELP }, \
{ "version", 0, 0, OPT_VERSION }, \
@@ -195,6 +196,7 @@
{ "mem-min", 1, 0, OPT_MEM_MIN }, \
{ "mem-max", 1, 0, OPT_MEM_MAX }, \
{ "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \
+ { "load-hardboot", 0, 0, OPT_LOAD_HARDBOOT}, \
#define KEXEC_OPT_STR "hvdfxluet:p"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment