All of lore.kernel.org
 help / color / mirror / Atom feed
From: Janosch Frank <frankja@linux.ibm.com>
To: kvm390 mailing list <kvm390-list@tuxmaker.boeblingen.de.ibm.com>
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	imbrenda@linux.ibm.com, thuth@redhat.com, seiden@linux.ibm.com,
	nrb@linux.ibm.com, scgl@linux.ibm.com
Subject: [kvm-unit-tests PATCH 4/6] s390x: uv-host: Add access exception test
Date: Fri, 13 May 2022 09:50:15 +0000	[thread overview]
Message-ID: <20220513095017.16301-5-frankja@linux.ibm.com> (raw)
In-Reply-To: <20220513095017.16301-1-frankja@linux.ibm.com>

Let's check that we get access exceptions if the UVCB is on an invalid
page or starts at a valid page and crosses into an invalid one.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 s390x/uv-host.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/s390x/uv-host.c b/s390x/uv-host.c
index fcb82d24..153a94e1 100644
--- a/s390x/uv-host.c
+++ b/s390x/uv-host.c
@@ -15,12 +15,14 @@
 #include <sclp.h>
 #include <smp.h>
 #include <uv.h>
+#include <mmu.h>
 #include <asm/page.h>
 #include <asm/sigp.h>
 #include <asm/pgtable.h>
 #include <asm/asm-offsets.h>
 #include <asm/interrupt.h>
 #include <asm/facility.h>
+#include <asm/pgtable.h>
 #include <asm/uv.h>
 #include <asm-generic/barrier.h>
 
@@ -123,6 +125,54 @@ static void test_uv_uninitialized(void)
 	report_prefix_pop();
 }
 
+static void test_access(void)
+{
+	struct uv_cb_header *uvcb;
+	void *pages =  alloc_pages(1);
+	uint16_t pgm;
+	int i;
+
+	/* Put UVCB on second page which we will protect later */
+	uvcb = pages + PAGE_SIZE;
+
+	report_prefix_push("access");
+
+	report_prefix_push("non-crossing");
+	protect_page(uvcb, PAGE_ENTRY_I);
+	for (i = 0; cmds[i].name; i++) {
+		expect_pgm_int();
+		mb();
+		uv_call_once(0, (uint64_t)uvcb);
+		pgm = clear_pgm_int();
+		report(pgm == PGM_INT_CODE_PAGE_TRANSLATION, "%s", cmds[i].name);
+	}
+	report_prefix_pop();
+
+	report_prefix_push("crossing");
+	/*
+	 * Put the header into the readable page 1, everything after
+	 * the header will be on the second, invalid page.
+	 */
+	uvcb -= 1;
+	for (i = 0; cmds[i].name; i++) {
+		uvcb->cmd = cmds[i].cmd;
+		uvcb->len = cmds[i].len;
+
+		expect_pgm_int();
+		mb();
+		uv_call_once(0, (uint64_t)uvcb);
+		pgm = clear_pgm_int();
+		report(pgm == PGM_INT_CODE_PAGE_TRANSLATION, "%s", cmds[i].name);
+	}
+	report_prefix_pop();
+
+	uvcb += 1;
+	unprotect_page(uvcb, PAGE_ENTRY_I);
+
+	free_pages(pages);
+	report_prefix_pop();
+}
+
 static void test_config_destroy(void)
 {
 	int rc;
@@ -615,6 +665,8 @@ int main(void)
 	test_init();
 
 	setup_vmem();
+	test_access();
+
 	test_config_create();
 	test_cpu_create();
 	test_cpu_destroy();
-- 
2.34.1


  parent reply	other threads:[~2022-05-13  9:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-13  9:50 [kvm-unit-tests PATCH 0/6] s390x: uv-host: Access check extensions and improvements Janosch Frank
2022-05-13  9:50 ` [kvm-unit-tests PATCH 1/6] s390x: uv-host: Add access checks for donated memory Janosch Frank
2022-05-16  8:21   ` Nico Boehr
2022-05-16  9:22     ` Janosch Frank
2022-05-13  9:50 ` [kvm-unit-tests PATCH 2/6] s390x: uv-host: Add uninitialized UV tests Janosch Frank
2022-05-16  8:37   ` Nico Boehr
2022-05-16 15:02   ` Steffen Eiden
2022-05-16 15:15     ` Janosch Frank
2022-05-16 15:34       ` Steffen Eiden
2022-05-13  9:50 ` [kvm-unit-tests PATCH 3/6] s390x: uv-host: Test uv immediate parameter Janosch Frank
2022-05-17  8:29   ` Steffen Eiden
2022-05-17  9:03     ` Janosch Frank
2022-05-17  9:04       ` Steffen Eiden
2022-05-13  9:50 ` Janosch Frank [this message]
2022-05-16  8:42   ` [kvm-unit-tests PATCH 4/6] s390x: uv-host: Add access exception test Nico Boehr
2022-05-17  8:53   ` Steffen Eiden
2022-05-13  9:50 ` [kvm-unit-tests PATCH 5/6] s390x: uv-host: Add a set secure config parameters test function Janosch Frank
2022-05-17 11:32   ` Steffen Eiden
2022-05-13  9:50 ` [kvm-unit-tests PATCH 6/6] s390x: uv-host: Remove duplicated + Janosch Frank
2022-05-13 15:30   ` Claudio Imbrenda
2022-05-17 11:33   ` Steffen Eiden

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=20220513095017.16301-5-frankja@linux.ibm.com \
    --to=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm390-list@tuxmaker.boeblingen.de.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=nrb@linux.ibm.com \
    --cc=scgl@linux.ibm.com \
    --cc=seiden@linux.ibm.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 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.