From: David Hildenbrand <david@redhat.com>
To: kvm@vger.kernel.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Christian Borntraeger" <borntraeger@de.ibm.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"David Hildenbrand" <david@redhat.com>
Subject: [kvm-unit-tests PATCH v1] s390x: try multiple times to stop CPU
Date: Wed, 20 Sep 2017 18:25:48 +0200 [thread overview]
Message-ID: <20170920162548.7233-1-david@redhat.com> (raw)
In theory, we could get a CC == 3, meaning the SIGP facility is busy
and we have to retry. So let's retry quite a number of times and
at least print a message about the problem before going into a safe loop.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
While working on TCG SMP support, I had a BUG whereby the CPU would
not directly stop but cotinue running for some instructions. This should
no properly detect such scenarios where the CPU keeps running after the
SIGP without indicating CC=3.
lib/s390x/io.c | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/lib/s390x/io.c b/lib/s390x/io.c
index 12f9d26..c48d6b1 100644
--- a/lib/s390x/io.c
+++ b/lib/s390x/io.c
@@ -14,6 +14,7 @@
#include <argv.h>
#include <asm/spinlock.h>
#include <asm/facility.h>
+#include <asm/barrier.h>
#include "sclp.h"
extern char ipl_args[];
@@ -28,14 +29,36 @@ void puts(const char *s)
spin_unlock(&lock);
}
-static void sigp_stop()
+static int sigp_stop(void)
{
register unsigned long status asm ("1") = 0;
register unsigned long cpu asm ("2") = 0;
+ int cc;
asm volatile(
- " sigp %0,%1,0(%2)\n"
- : "+d" (status) : "d" (cpu), "d" (5) : "cc");
+ " sigp %1,%2,0(%3)\n"
+ " ipm %0\n"
+ " srl %0,28\n"
+ : "=d" (cc), "+d" (status) : "d" (cpu), "d" (5) : "cc");
+ return cc;
+}
+
+static void machine_stop(void)
+{
+ int retry = 999999;
+ int cc;
+
+ /* for now we only have 1 CPU to stop */
+ do {
+ cc = sigp_stop();
+ retry--;
+ } while (cc == 3 && retry);
+
+ printf("\nERROR: Could not stop CPU(s)\n");
+ printf("\nEXIT: STATUS=-1\n");
+ while (true) {
+ mb();
+ }
}
void setup()
@@ -48,5 +71,5 @@ void setup()
void exit(int code)
{
printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1);
- sigp_stop();
+ machine_stop();
}
--
2.13.5
next reply other threads:[~2017-09-20 16:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-20 16:25 David Hildenbrand [this message]
2017-09-20 20:11 ` [kvm-unit-tests PATCH v1] s390x: try multiple times to stop CPU David Hildenbrand
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=20170920162548.7233-1-david@redhat.com \
--to=david@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@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