|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XTF PATCH v2 2/2] x86: Allow exiting QEMU in TCG/QEMU
If QEMU has a debug isa-debug-exit device, we can simply write to it
to exit rather than spinning after a failed hypercall.
While at it, reorder an out-of-order include.
Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
---
arch/x86/hvm/traps.c | 16 +++++++++++++++-
arch/x86/pv/traps.c | 5 +++++
common/lib.c | 2 +-
common/report.c | 8 +++++---
include/xtf/framework.h | 3 +++
5 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/arch/x86/hvm/traps.c b/arch/x86/hvm/traps.c
index ad7b8cb..b8c4d0c 100644
--- a/arch/x86/hvm/traps.c
+++ b/arch/x86/hvm/traps.c
@@ -1,5 +1,6 @@
-#include <xtf/traps.h>
+#include <xtf/hypercall.h>
#include <xtf/lib.h>
+#include <xtf/traps.h>
#include <arch/idt.h>
#include <arch/lib.h>
@@ -139,6 +140,19 @@ void arch_init_traps(void)
virt_to_gfn(__end_user_bss));
}
+void arch_shutdown(unsigned int reason)
+{
+ hypercall_shutdown(reason);
+
+ /*
+ * Not running under Xen. Attempt exit via the QEMU ISA debug exit device
on
+ * its default port.
+ *
+ * QEMU's rc is (reason << 1) | 1, if "-device isa-debug-exit" is set.
+ */
+ outb(reason, 0x501);
+}
+
void __noreturn arch_crash_hard(void)
{
/*
diff --git a/arch/x86/pv/traps.c b/arch/x86/pv/traps.c
index 66ef40e..913bab2 100644
--- a/arch/x86/pv/traps.c
+++ b/arch/x86/pv/traps.c
@@ -206,6 +206,11 @@ void arch_init_traps(void)
panic("Failed to unmap page at NULL: %d\n", rc);
}
+void arch_shutdown(unsigned int reason)
+{
+ hypercall_shutdown(reason);
+}
+
void __noreturn arch_crash_hard(void)
{
/*
diff --git a/common/lib.c b/common/lib.c
index 7f1813f..f4de22e 100644
--- a/common/lib.c
+++ b/common/lib.c
@@ -25,7 +25,7 @@ void __noreturn panic(const char *fmt, ...)
printk("******************************\n");
- hypercall_shutdown(SHUTDOWN_crash);
+ arch_shutdown(SHUTDOWN_crash);
arch_crash_hard();
}
diff --git a/common/report.c b/common/report.c
index ffdf098..158876e 100644
--- a/common/report.c
+++ b/common/report.c
@@ -1,6 +1,8 @@
+#include <xtf/framework.h>
#include <xtf/lib.h>
#include <xtf/report.h>
-#include <xtf/hypercall.h>
+
+#include <xen/sched.h>
enum test_status {
STATUS_RUNNING, /**< Test not yet completed. */
@@ -124,8 +126,8 @@ bool xtf_status_reported(void)
void xtf_exit(void)
{
xtf_report_status();
- hypercall_shutdown(SHUTDOWN_poweroff);
- panic("xtf_exit(): hypercall_shutdown(SHUTDOWN_poweroff) returned\n");
+ arch_shutdown(SHUTDOWN_poweroff);
+ panic("xtf_exit(): arch_shutdown(SHUTDOWN_poweroff) returned\n");
}
/*
diff --git a/include/xtf/framework.h b/include/xtf/framework.h
index 95de195..e852882 100644
--- a/include/xtf/framework.h
+++ b/include/xtf/framework.h
@@ -16,6 +16,9 @@ void arch_setup(void);
/* Set up test-specific configuration. */
void test_setup(void);
+/* Stop the machine. See SHUTDOWN_poweroff et al for reasons */
+void arch_shutdown(unsigned int reason);
+
/*
* In the case that normal shutdown actions have failed, contain execution as
* best as possible.
--
2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |