All of lore.kernel.org
 help / color / mirror / Atom feed
From: Janosch Frank <frankja@linux.ibm.com>
To: pbonzini@redhat.com
Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com,
	borntraeger@de.ibm.com, cohuck@redhat.com,
	linux-s390@vger.kernel.org, imbrenda@linux.ibm.com
Subject: [kvm-unit-tests GIT PULL 11/11] s390x: Fix uv_call() exception behavior
Date: Wed, 20 Jan 2021 06:41:58 -0500	[thread overview]
Message-ID: <20210120114158.104559-12-frankja@linux.ibm.com> (raw)
In-Reply-To: <20210120114158.104559-1-frankja@linux.ibm.com>

On a program exception we usually skip the instruction that caused the
exception and continue. That won't work for UV calls since a "brc
3,0b" will retry the instruction if the CC is > 1. Let's forgo the brc
when checking for privilege exceptions and use a uv_call_once().

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Suggested-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
---
 lib/s390x/asm/uv.h | 24 ++++++++++++++++--------
 s390x/uv-guest.c   |  6 +++---
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/lib/s390x/asm/uv.h b/lib/s390x/asm/uv.h
index 4c2fc48..39d2dc0 100644
--- a/lib/s390x/asm/uv.h
+++ b/lib/s390x/asm/uv.h
@@ -50,19 +50,12 @@ struct uv_cb_share {
 	u64 reserved28;
 } __attribute__((packed))  __attribute__((aligned(8)));
 
-static inline int uv_call(unsigned long r1, unsigned long r2)
+static inline int uv_call_once(unsigned long r1, unsigned long r2)
 {
 	int cc;
 
-	/*
-	 * The brc instruction will take care of the cc 2/3 case where
-	 * we need to continue the execution because we were
-	 * interrupted. The inline assembly will only return on
-	 * success/error i.e. cc 0/1.
-	*/
 	asm volatile(
 		"0:	.insn rrf,0xB9A40000,%[r1],%[r2],0,0\n"
-		"		brc	3,0b\n"
 		"		ipm	%[cc]\n"
 		"		srl	%[cc],28\n"
 		: [cc] "=d" (cc)
@@ -71,4 +64,19 @@ static inline int uv_call(unsigned long r1, unsigned long r2)
 	return cc;
 }
 
+static inline int uv_call(unsigned long r1, unsigned long r2)
+{
+	int cc;
+
+	/*
+	 * CC 2 and 3 tell us to re-execute because the instruction
+	 * hasn't yet finished.
+	 */
+	do {
+		cc = uv_call_once(r1, r2);
+	} while (cc > 1);
+
+	return cc;
+}
+
 #endif
diff --git a/s390x/uv-guest.c b/s390x/uv-guest.c
index e51b85e..9954444 100644
--- a/s390x/uv-guest.c
+++ b/s390x/uv-guest.c
@@ -29,7 +29,7 @@ static void test_priv(void)
 	uvcb.len = sizeof(struct uv_cb_qui);
 	expect_pgm_int();
 	enter_pstate();
-	uv_call(0, (u64)&uvcb);
+	uv_call_once(0, (u64)&uvcb);
 	check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION);
 	report_prefix_pop();
 
@@ -38,7 +38,7 @@ static void test_priv(void)
 	uvcb.len = sizeof(struct uv_cb_share);
 	expect_pgm_int();
 	enter_pstate();
-	uv_call(0, (u64)&uvcb);
+	uv_call_once(0, (u64)&uvcb);
 	check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION);
 	report_prefix_pop();
 
@@ -47,7 +47,7 @@ static void test_priv(void)
 	uvcb.len = sizeof(struct uv_cb_share);
 	expect_pgm_int();
 	enter_pstate();
-	uv_call(0, (u64)&uvcb);
+	uv_call_once(0, (u64)&uvcb);
 	check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION);
 	report_prefix_pop();
 
-- 
2.25.1

  parent reply	other threads:[~2021-01-20 11:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-20 11:41 [kvm-unit-tests GIT PULL 00/11] s390x update Janosch Frank
2021-01-20 11:41 ` [kvm-unit-tests GIT PULL 01/11] s390x: Move to GPL 2 and SPDX license identifiers Janosch Frank
2021-01-20 11:41 ` [kvm-unit-tests GIT PULL 02/11] s390x: lib: " Janosch Frank
2021-01-20 11:41 ` [kvm-unit-tests GIT PULL 03/11] s390x: Add test_bit to library Janosch Frank
2021-01-20 11:41 ` [kvm-unit-tests GIT PULL 04/11] s390x: Consolidate sclp read info Janosch Frank
2021-01-20 11:41 ` [kvm-unit-tests GIT PULL 05/11] s390x: SCLP feature checking Janosch Frank
2021-01-20 11:41 ` [kvm-unit-tests GIT PULL 06/11] s390x: Split assembly into multiple files Janosch Frank
2021-01-20 11:41 ` [kvm-unit-tests GIT PULL 07/11] s390x: sie: Add SIE to lib Janosch Frank
2021-01-20 11:41 ` [kvm-unit-tests GIT PULL 08/11] s390x: sie: Add first SIE test Janosch Frank
2021-01-20 11:41 ` [kvm-unit-tests GIT PULL 09/11] s390x: Add diag318 intercept test Janosch Frank
2021-01-20 11:41 ` [kvm-unit-tests GIT PULL 10/11] s390x: Fix sclp.h style issues Janosch Frank
2021-01-20 11:41 ` Janosch Frank [this message]
2021-01-20 12:46 ` [kvm-unit-tests GIT PULL 00/11] s390x update 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=20210120114158.104559-12-frankja@linux.ibm.com \
    --to=frankja@linux.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=pbonzini@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.