kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com, Thomas Huth <thuth@redhat.com>
Subject: [PATCH kvm-unit-tests 3/8] powerpc: don't use NMI's to signal end of migration
Date: Wed,  7 Feb 2018 20:03:29 +0100	[thread overview]
Message-ID: <20180207190334.16516-4-drjones@redhat.com> (raw)
In-Reply-To: <20180207190334.16516-1-drjones@redhat.com>

The SPRs test already supports using serial input as the trigger to
proceed after waiting for migration to complete, but the general
test framework uses NMI's (which the SPR test also supported before
this patch). ARM doesn't support NMI injection, so change the general
framework to use serial input instead, and drop the NMI support from
the SPR test.

Cc: Thomas Huth <thuth@redhat.com>
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 powerpc/sprs.c        | 26 +++++++++-----------------
 scripts/arch-run.bash | 13 ++++++++-----
 2 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/powerpc/sprs.c b/powerpc/sprs.c
index c02bcc9fcf32..3b920e9f929a 100644
--- a/powerpc/sprs.c
+++ b/powerpc/sprs.c
@@ -8,13 +8,13 @@
  * The basic idea of this test is to check whether the contents of the Special
  * Purpose Registers (SPRs) are preserved correctly during migration. So we
  * fill in the SPRs with a well-known value, read the values back (since not
- * all bits might be retained in the SPRs), then wait for a key or NMI (if the
- * '-w' option has been specified) so that the user has a chance to migrate the
- * VM. Alternatively, the test can also simply sleep a little bit with the
- * H_CEDE hypercall, in the hope that we'll get scheduled to another host CPU
- * and thus register contents might have changed, too (in case of bugs).
- * Finally, we read back the values from the SPRs and compare them with the
- * values before the migration. Mismatches are reported as test failures.
+ * all bits might be retained in the SPRs), then wait for migration to complete
+ * (if the '-w' option has been specified) so that the user has a chance to
+ * migrate the VM. Alternatively, the test can also simply sleep a little bit
+ * with the H_CEDE hypercall, in the hope that we'll get scheduled to another
+ * host CPU and thus register contents might have changed, too (in case of
+ * bugs). Finally, we read back the values from the SPRs and compare them with
+ * the values before the migration. Mismatches are reported as test failures.
  * Note that we do not test all SPRs since some of the registers change their
  * content automatically, and some are only accessible with hypervisor privi-
  * leges or have bad side effects, so we have to omit those registers.
@@ -38,13 +38,6 @@
 
 uint64_t before[1024], after[1024];
 
-volatile int nmi_occurred;
-
-static void nmi_handler(struct pt_regs *regs __unused, void *opaque __unused)
-{
-	nmi_occurred = 1;
-}
-
 static int h_get_term_char(uint64_t termno)
 {
 	register uint64_t r3 asm("r3") = 0x54; /* H_GET_TERM_CHAR */
@@ -303,9 +296,8 @@ int main(int argc, char **argv)
 	get_sprs(before);
 
 	if (pause) {
-		handle_exception(0x100, &nmi_handler, NULL);
-		puts("Now migrate the VM, then press a key or send NMI...\n");
-		while (!nmi_occurred && h_get_term_char(0) == 0)
+		puts("Now migrate the VM, then press a key to continue...\n");
+		while (h_get_term_char(0) == 0)
 			cpu_relax();
 	} else {
 		puts("Sleeping...\n");
diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index 565e299295db..e13af8e8064a 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -115,17 +115,22 @@ run_migration ()
 	migout1=`mktemp -t mig-helper-stdout1.XXXXXXXXXX`
 	qmp1=`mktemp -u -t mig-helper-qmp1.XXXXXXXXXX`
 	qmp2=`mktemp -u -t mig-helper-qmp2.XXXXXXXXXX`
+	fifo=`mktemp -u -t mig-helper-fifo.XXXXXXXXXX`
 	qmpout1=/dev/null
 	qmpout2=/dev/null
 
 	trap 'kill 0; exit 2' INT TERM
-	trap 'rm -f ${migout1} ${migsock} ${qmp1} ${qmp2}' RETURN EXIT
+	trap 'rm -f ${migout1} ${migsock} ${qmp1} ${qmp2} ${fifo}' RETURN EXIT
 
 	eval "$@" -chardev socket,id=mon1,path=${qmp1},server,nowait \
 		-mon chardev=mon1,mode=control | tee ${migout1} &
 
+	# We have to use cat to open the named FIFO, because named FIFO's, unlike
+	# pipes, will block on open() until the other end is also opened, and that
+	# totally breaks QEMU...
+	mkfifo ${fifo}
 	eval "$@" -chardev socket,id=mon2,path=${qmp2},server,nowait \
-		-mon chardev=mon2,mode=control -incoming unix:${migsock} &
+		-mon chardev=mon2,mode=control -incoming unix:${migsock} < <(cat ${fifo}) &
 	incoming_pid=`jobs -l %+ | awk '{print$2}'`
 
 	# The test must prompt the user to migrate, so wait for the "migrate" keyword
@@ -148,9 +153,7 @@ run_migration ()
 		fi
 	done
 	qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null
-
-	qmp ${qmp2} '"inject-nmi"'> ${qmpout2}
-
+	echo > ${fifo}
 	wait $incoming_pid
 	ret=$?
 	wait
-- 
2.13.6

  parent reply	other threads:[~2018-02-07 19:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-07 19:03 [PATCH kvm-unit-tests 0/8] arm/arm64: extend psci tests Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 1/8] virtio-mmio: fix queue allocation Andrew Jones
2018-02-07 19:32   ` Andrew Jones
2018-02-07 19:34   ` [PATCH kvm-unit-tests v2 " Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 2/8] scripts/arch-run: run_migration improvements Andrew Jones
2018-02-07 19:03 ` Andrew Jones [this message]
2018-02-08 10:58   ` [PATCH kvm-unit-tests 3/8] powerpc: don't use NMI's to signal end of migration Thomas Huth
2018-02-07 19:03 ` [PATCH kvm-unit-tests 4/8] powerpc: Introduce getchar Andrew Jones
2018-02-08 11:06   ` Thomas Huth
2018-02-08 12:59     ` Andrew Jones
2018-02-14 11:43       ` Paolo Bonzini
2018-02-14 12:38         ` Andrew Jones
2018-02-14 13:25           ` Paolo Bonzini
2018-02-14 14:38             ` Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 5/8] lib: Introduce do_migration Andrew Jones
2018-02-14 11:45   ` Paolo Bonzini
2018-02-14 12:44     ` Andrew Jones
2018-02-14 13:24       ` Paolo Bonzini
2018-02-07 19:03 ` [PATCH kvm-unit-tests 6/8] arm/arm64: Add support for migration tests Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 7/8] arm/arm64: psci: add migration test Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 8/8] arm/psci: add smccc 1.1 tests Andrew Jones
2018-02-14 11:46 ` [PATCH kvm-unit-tests 0/8] arm/arm64: extend psci tests Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180207190334.16516-4-drjones@redhat.com \
    --to=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).