Patchwork [kvm-unit-tests,v3,5/5] lib: arm: Fallback to psci_system_off() in exit()

login
register
mail settings
Submitter Alexandru Elisei
Date Feb. 4, 2019, 1:44 p.m.
Message ID <20190204134412.47877-6-alexandru.elisei@arm.com>
Download mbox | patch
Permalink /patch/717327/
State New
Headers show

Comments

Alexandru Elisei - Feb. 4, 2019, 1:44 p.m.
On arm and arm64, kvm-unit-tests uses the QEMU chr-testdev device to shut
down the virtual machine at the end of a test. The function
psci_system_off() provides another mechanism for terminating the virtual
machine.

chr-testdev is implemented on top of virtio console. If the virtual machine
manager doesn't emulate a virtio console, then chr_testdev_exit() will
fail. If this happens, try to use psci_system_off() to terminate the test.

This patch makes it possible for a virtual machine manager which doesn't
have support for chr-testdev, but has been configured not to emulate a
virtio console, to gracefully terminate a virtual machine after a test has
been completed.

There is one limitation to using psci_system_off() to terminate a test:
chr-testdev allows kvm-unit-tests to specify an exit code;
psci_system_off() has no such mechanism.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
---
 lib/arm/io.c | 2 ++
 1 file changed, 2 insertions(+)

Patch

diff --git a/lib/arm/io.c b/lib/arm/io.c
index e55b8b854869..8226b765bdc5 100644
--- a/lib/arm/io.c
+++ b/lib/arm/io.c
@@ -12,6 +12,7 @@ 
 #include <devicetree.h>
 #include <chr-testdev.h>
 #include <config.h>
+#include <asm/psci.h>
 #include <asm/spinlock.h>
 #include <asm/io.h>
 
@@ -91,6 +92,7 @@  void puts(const char *s)
 void exit(int code)
 {
 	chr_testdev_exit(code);
+	psci_system_off();
 	halt(code);
 	__builtin_unreachable();
 }