crash_save_vmcsinfo updates the VMCSINFO when kernel crashes. If no VMCSINFO has been saved before, this function will do nothing. Signed-off-by: zhangyanfei <zhangyanfei@xxxxxxxxxxxxxx> --- include/linux/kexec.h | 1 + kernel/kexec.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 0d7d6a1..6e8ff13 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -145,6 +145,7 @@ void arch_crash_save_vmcoreinfo(void); __printf(1, 2) void vmcoreinfo_append_str(const char *fmt, ...); unsigned long paddr_vmcoreinfo_note(void); +void crash_save_vmcsinfo(void); #define VMCOREINFO_OSRELEASE(value) \ vmcoreinfo_append_str("OSRELEASE=%s\n", value) diff --git a/kernel/kexec.c b/kernel/kexec.c index 4e2e472..19843ef 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -38,6 +38,7 @@ #include <asm/uaccess.h> #include <asm/io.h> #include <asm/sections.h> +#include <asm/vmcsinfo.h> /* Per cpu memory for storing cpu states in case of system crash. */ note_buf_t __percpu *crash_notes; @@ -1094,6 +1095,7 @@ void crash_kexec(struct pt_regs *regs) crash_setup_regs(&fixed_regs, regs); crash_save_vmcoreinfo(); + crash_save_vmcsinfo(); machine_crash_shutdown(&fixed_regs); machine_kexec(kexec_crash_image); } @@ -1458,6 +1460,18 @@ unsigned long __attribute__ ((weak)) paddr_vmcoreinfo_note(void) return __pa((unsigned long)(char *)&vmcoreinfo_note); } +#ifdef CONFIG_X86 +void crash_save_vmcsinfo(void) +{ + if (!vmcsinfo_size) + return; + vmcsinfo_append_str("CRASHTIME=%ld", get_seconds()); + update_vmcsinfo_note(); +} +#else +void crash_save_vmcsinfo(void) {} +#endif /* CONFIG_X86 */ + static int __init crash_save_vmcoreinfo_init(void) { VMCOREINFO_OSRELEASE(init_uts_ns.name.release); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html