From 6ef48fa30e168c283d44ee7c48dba3e380bea2d5 Mon Sep 17 00:00:00 2001 From: Yin Fengwei Date: Thu, 17 May 2018 22:21:13 +0800 Subject: [PATCH] hv: Add reboot shell command To trigger warm reboot for debugging. Signed-off-by: Yin Fengwei Acked-by: Eddie Dong --- hypervisor/Makefile | 1 + hypervisor/arch/x86/debug/reboot.c | 12 ++++++++++++ hypervisor/debug/shell_internal.c | 7 +++++++ hypervisor/debug/shell_internal.h | 5 +++++ hypervisor/debug/shell_public.c | 6 ++++++ hypervisor/include/arch/x86/reboot.h | 9 +++++++++ 6 files changed, 40 insertions(+) create mode 100644 hypervisor/arch/x86/debug/reboot.c create mode 100644 hypervisor/include/arch/x86/reboot.h diff --git a/hypervisor/Makefile b/hypervisor/Makefile index b82d06155..5eb3883f2 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -117,6 +117,7 @@ C_SRCS += arch/x86/guest/vioapic.c C_SRCS += arch/x86/guest/instr_emul.c C_SRCS += arch/x86/guest/ucode.c C_SRCS += arch/x86/guest/pm.c +C_SRCS += arch/x86/debug/reboot.c C_SRCS += lib/spinlock.c C_SRCS += lib/udelay.c C_SRCS += lib/mdelay.c diff --git a/hypervisor/arch/x86/debug/reboot.c b/hypervisor/arch/x86/debug/reboot.c new file mode 100644 index 000000000..4aa783ef0 --- /dev/null +++ b/hypervisor/arch/x86/debug/reboot.c @@ -0,0 +1,12 @@ +/* + * Copyright (C) <2018> Intel Corporation + * SPDX-License-Identifier: BSD-3-Clause + */ +#include +#include + +int warm_reboot(void) +{ + io_write_byte(0x6, 0xcf9); + return 0; +} diff --git a/hypervisor/debug/shell_internal.c b/hypervisor/debug/shell_internal.c index e41daa6d3..362f8a05b 100644 --- a/hypervisor/debug/shell_internal.c +++ b/hypervisor/debug/shell_internal.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "shell_internal.h" #include "serial_internal.h" @@ -931,6 +932,12 @@ int shell_show_ptdev_info(struct shell *p_shell, return 0; } +int shell_reboot(__unused struct shell *p_shell, + __unused int argc, __unused char **argv) +{ + return warm_reboot(); +} + int shell_show_req_info(struct shell *p_shell, __unused int argc, __unused char **argv) { diff --git a/hypervisor/debug/shell_internal.h b/hypervisor/debug/shell_internal.h index 357f2a1c1..5fcc6a752 100644 --- a/hypervisor/debug/shell_internal.h +++ b/hypervisor/debug/shell_internal.h @@ -117,6 +117,10 @@ struct shell_cmd { #define SHELL_CMD_PTDEV_PARAM NULL #define SHELL_CMD_PTDEV_HELP "show pass-through device info" +#define SHELL_CMD_REBOOT "reboot" +#define SHELL_CMD_REBOOT_PARAM NULL +#define SHELL_CMD_REBOOT_HELP "trigger system warm reboot" + #define SHELL_CMD_REQ "lsreq" #define SHELL_CMD_REQ_PARAM NULL #define SHELL_CMD_REQ_HELP "show ioreq info" @@ -170,6 +174,7 @@ int shell_trace_cmd(struct shell *p_shell, int argc, char **argv); int shell_to_sos_console(struct shell *p_shell, int argc, char **argv); int shell_show_cpu_int(struct shell *p_shell, int argc, char **argv); int shell_show_ptdev_info(struct shell *p_shell, int argc, char **argv); +int shell_reboot(struct shell *p_shell, int argc, char **argv); int shell_show_vioapic_info(struct shell *p_shell, int argc, char **argv); int shell_show_ioapic_info(struct shell *p_shell, int argc, char **argv); int shell_show_vmexit_profile(struct shell *p_shell, int argc, char **argv); diff --git a/hypervisor/debug/shell_public.c b/hypervisor/debug/shell_public.c index 2f0fb597f..fdbbaa239 100644 --- a/hypervisor/debug/shell_public.c +++ b/hypervisor/debug/shell_public.c @@ -147,6 +147,12 @@ static struct shell_cmd acrn_cmd[] = { .help_str = SHELL_CMD_CPUID_HELP, .fcn = shell_cpuid, }, + { + .str = SHELL_CMD_REBOOT, + .cmd_param = SHELL_CMD_REBOOT_PARAM, + .help_str = SHELL_CMD_REBOOT_HELP, + .fcn = shell_reboot, + }, }; int shell_init(void) diff --git a/hypervisor/include/arch/x86/reboot.h b/hypervisor/include/arch/x86/reboot.h new file mode 100644 index 000000000..db502b1ae --- /dev/null +++ b/hypervisor/include/arch/x86/reboot.h @@ -0,0 +1,9 @@ +/* + * Copyright (C) <2018> Intel Corporation + * SPDX-License-Identifier: BSD-3-Clause + */ +#ifndef REBOOT_H +#define REBOOT_H + +int warm_reboot(void); +#endif