kvm.vger.kernel.org archive mirror
 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,
	thuth@redhat.com
Subject: [kvm-unit-tests GIT PULL 1/9] s390x: mvpg: add checks for op_acc_id
Date: Wed,  5 May 2021 10:42:53 +0200	[thread overview]
Message-ID: <20210505084301.17395-2-frankja@linux.ibm.com> (raw)
In-Reply-To: <20210505084301.17395-1-frankja@linux.ibm.com>

From: Claudio Imbrenda <imbrenda@linux.ibm.com>

Check the operand access identification when MVPG causes a page fault.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/kvm/20210427121608.157783-1-imbrenda@linux.ibm.com/
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 s390x/mvpg.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/s390x/mvpg.c b/s390x/mvpg.c
index 5743d5b6..2b7c6cc9 100644
--- a/s390x/mvpg.c
+++ b/s390x/mvpg.c
@@ -36,6 +36,7 @@
 
 static uint8_t source[PAGE_SIZE]  __attribute__((aligned(PAGE_SIZE)));
 static uint8_t buffer[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
+static struct lowcore * const lc;
 
 /* Keep track of fresh memory */
 static uint8_t *fresh;
@@ -77,6 +78,21 @@ static int page_ok(const uint8_t *p)
 	return 1;
 }
 
+/*
+ * Check that the Operand Access Identification matches with the values of
+ * the r1 and r2 fields in the instruction format. The r1 and r2 fields are
+ * in the last byte of the instruction, and the Program Old PSW will point
+ * to the beginning of the instruction after the one that caused the fault
+ * (the fixup code in the interrupt handler takes care of that for
+ * nullifying instructions). Therefore it is enough to compare the byte
+ * before the one contained in the Program Old PSW with the value of the
+ * Operand Access Identification.
+ */
+static inline bool check_oai(void)
+{
+	return *(uint8_t *)(lc->pgm_old_psw.addr - 1) == lc->op_acc_id;
+}
+
 static void test_exceptions(void)
 {
 	int i, expected;
@@ -201,17 +217,25 @@ static void test_mmu_prot(void)
 	report(clear_pgm_int() == PGM_INT_CODE_PROTECTION, "destination read only");
 	fresh += PAGE_SIZE;
 
+	report_prefix_push("source invalid");
 	protect_page(source, PAGE_ENTRY_I);
+	lc->op_acc_id = 0;
 	expect_pgm_int();
 	mvpg(0, fresh, source);
-	report(clear_pgm_int() == PGM_INT_CODE_PAGE_TRANSLATION, "source invalid");
+	report(clear_pgm_int() == PGM_INT_CODE_PAGE_TRANSLATION, "exception");
 	unprotect_page(source, PAGE_ENTRY_I);
+	report(check_oai(), "operand access ident");
+	report_prefix_pop();
 	fresh += PAGE_SIZE;
 
+	report_prefix_push("destination invalid");
 	protect_page(fresh, PAGE_ENTRY_I);
+	lc->op_acc_id = 0;
 	expect_pgm_int();
 	mvpg(0, fresh, source);
-	report(clear_pgm_int() == PGM_INT_CODE_PAGE_TRANSLATION, "destination invalid");
+	report(clear_pgm_int() == PGM_INT_CODE_PAGE_TRANSLATION, "exception");
+	report(check_oai(), "operand access ident");
+	report_prefix_pop();
 	fresh += PAGE_SIZE;
 
 	report_prefix_pop();
-- 
2.30.2


  reply	other threads:[~2021-05-05  8:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05  8:42 [kvm-unit-tests GIT PULL 0/9] s390x update 2021-05-05 Janosch Frank
2021-05-05  8:42 ` Janosch Frank [this message]
2021-05-05  8:42 ` [kvm-unit-tests GIT PULL 2/9] s390x: css: Store CSS Characteristics Janosch Frank
2021-05-05  8:42 ` [kvm-unit-tests GIT PULL 3/9] s390x: css: simplifications of the tests Janosch Frank
2021-05-05  8:42 ` [kvm-unit-tests GIT PULL 4/9] s390x: css: extending the subchannel modifying functions Janosch Frank
2021-05-05  8:42 ` [kvm-unit-tests GIT PULL 5/9] s390x: css: implementing Set CHannel Monitor Janosch Frank
2021-05-05  8:42 ` [kvm-unit-tests GIT PULL 6/9] s390x: css: testing measurement block format 0 Janosch Frank
2021-05-05  8:42 ` [kvm-unit-tests GIT PULL 7/9] s390x: css: testing measurement block format 1 Janosch Frank
2021-05-05  8:43 ` [kvm-unit-tests GIT PULL 8/9] MAINTAINERS: s390x: add myself as reviewer Janosch Frank
2021-05-05  8:43 ` [kvm-unit-tests GIT PULL 9/9] s390x: Fix vector stfle checks Janosch Frank
2021-05-05  9:40 ` [kvm-unit-tests GIT PULL 0/9] s390x update 2021-05-05 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=20210505084301.17395-2-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 \
    --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).