From: Thomas Huth <thuth@redhat.com>
To: kvm@vger.kernel.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>
Cc: David Hildenbrand <david@redhat.com>,
Janosch Frank <frankja@linux.ibm.com>
Subject: [kvm-unit-tests PULL 06/17] s390x: Move pfmf to lib and make address void
Date: Wed, 25 Sep 2019 18:37:03 +0200 [thread overview]
Message-ID: <20190925163714.27519-7-thuth@redhat.com> (raw)
In-Reply-To: <20190925163714.27519-1-thuth@redhat.com>
From: Janosch Frank <frankja@linux.ibm.com>
It's needed by other tests soon.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20190828113615.4769-2-frankja@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
lib/s390x/asm/mem.h | 31 ++++++++++++++++++++++++
s390x/pfmf.c | 57 +++++++++++----------------------------------
2 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/lib/s390x/asm/mem.h b/lib/s390x/asm/mem.h
index 75bd778..9b8fd70 100644
--- a/lib/s390x/asm/mem.h
+++ b/lib/s390x/asm/mem.h
@@ -54,4 +54,35 @@ static inline unsigned char get_storage_key(unsigned long addr)
asm volatile("iske %0,%1" : "=d" (skey) : "a" (addr));
return skey;
}
+
+#define PFMF_FSC_4K 0
+#define PFMF_FSC_1M 1
+#define PFMF_FSC_2G 2
+
+union pfmf_r1 {
+ struct {
+ unsigned long pad0 : 32;
+ unsigned long pad1 : 12;
+ unsigned long pad_fmfi : 2;
+ unsigned long sk : 1; /* set key*/
+ unsigned long cf : 1; /* clear frame */
+ unsigned long ui : 1; /* usage indication */
+ unsigned long fsc : 3;
+ unsigned long pad2 : 1;
+ unsigned long mr : 1;
+ unsigned long mc : 1;
+ unsigned long pad3 : 1;
+ unsigned long key : 8; /* storage keys */
+ } reg;
+ unsigned long val;
+};
+
+static inline void *pfmf(unsigned long r1, void *paddr)
+{
+ register void * addr asm("1") = paddr;
+
+ asm volatile(".insn rre,0xb9af0000,%[r1],%[addr]"
+ : [addr] "+a" (addr) : [r1] "d" (r1) : "memory");
+ return addr;
+}
#endif
diff --git a/s390x/pfmf.c b/s390x/pfmf.c
index 9bf434a..9986624 100644
--- a/s390x/pfmf.c
+++ b/s390x/pfmf.c
@@ -16,60 +16,29 @@
#include <asm/facility.h>
#include <asm/mem.h>
-#define FSC_4K 0
-#define FSC_1M 1
-#define FSC_2G 2
-
-union r1 {
- struct {
- unsigned long pad0 : 32;
- unsigned long pad1 : 12;
- unsigned long pad_fmfi : 2;
- unsigned long sk : 1; /* set key*/
- unsigned long cf : 1; /* clear frame */
- unsigned long ui : 1; /* usage indication */
- unsigned long fsc : 3;
- unsigned long pad2 : 1;
- unsigned long mr : 1;
- unsigned long mc : 1;
- unsigned long pad3 : 1;
- unsigned long key : 8; /* storage keys */
- } reg;
- unsigned long val;
-};
-
static uint8_t pagebuf[PAGE_SIZE * 256] __attribute__((aligned(PAGE_SIZE * 256)));
-static inline unsigned long pfmf(unsigned long r1, unsigned long paddr)
-{
- register uint64_t addr asm("1") = paddr;
-
- asm volatile(".insn rre,0xb9af0000,%[r1],%[addr]"
- : [addr] "+a" (addr) : [r1] "d" (r1) : "memory");
- return addr;
-}
-
static void test_priv(void)
{
report_prefix_push("privileged");
expect_pgm_int();
enter_pstate();
- pfmf(0, (unsigned long) pagebuf);
+ pfmf(0, pagebuf);
check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION);
report_prefix_pop();
}
static void test_4k_key(void)
{
- union r1 r1;
+ union pfmf_r1 r1;
union skey skey;
report_prefix_push("4K");
r1.val = 0;
r1.reg.sk = 1;
- r1.reg.fsc = FSC_4K;
+ r1.reg.fsc = PFMF_FSC_4K;
r1.reg.key = 0x30;
- pfmf(r1.val, (unsigned long) pagebuf);
+ pfmf(r1.val, pagebuf);
skey.val = get_storage_key((unsigned long) pagebuf);
skey.val &= SKEY_ACC | SKEY_FP;
report("set storage keys", skey.val == 0x30);
@@ -80,15 +49,15 @@ static void test_1m_key(void)
{
int i;
bool rp = true;
- union r1 r1;
+ union pfmf_r1 r1;
union skey skey;
report_prefix_push("1M");
r1.val = 0;
r1.reg.sk = 1;
- r1.reg.fsc = FSC_1M;
+ r1.reg.fsc = PFMF_FSC_1M;
r1.reg.key = 0x30;
- pfmf(r1.val, (unsigned long) pagebuf);
+ pfmf(r1.val, pagebuf);
for (i = 0; i < 256; i++) {
skey.val = get_storage_key((unsigned long) pagebuf + i * PAGE_SIZE);
skey.val &= SKEY_ACC | SKEY_FP;
@@ -103,15 +72,15 @@ static void test_1m_key(void)
static void test_4k_clear(void)
{
- union r1 r1;
+ union pfmf_r1 r1;
r1.val = 0;
r1.reg.cf = 1;
- r1.reg.fsc = FSC_4K;
+ r1.reg.fsc = PFMF_FSC_4K;
report_prefix_push("4K");
memset(pagebuf, 42, PAGE_SIZE);
- pfmf(r1.val, (unsigned long) pagebuf);
+ pfmf(r1.val, pagebuf);
report("clear memory", !memcmp(pagebuf, pagebuf + PAGE_SIZE, PAGE_SIZE));
report_prefix_pop();
}
@@ -119,16 +88,16 @@ static void test_4k_clear(void)
static void test_1m_clear(void)
{
int i;
- union r1 r1;
+ union pfmf_r1 r1;
unsigned long sum = 0;
r1.val = 0;
r1.reg.cf = 1;
- r1.reg.fsc = FSC_1M;
+ r1.reg.fsc = PFMF_FSC_1M;
report_prefix_push("1M");
memset(pagebuf, 42, PAGE_SIZE * 256);
- pfmf(r1.val, (unsigned long) pagebuf);
+ pfmf(r1.val, pagebuf);
for (i = 0; i < PAGE_SIZE * 256; i++)
sum |= pagebuf[i];
report("clear memory", !sum);
--
2.18.1
next prev parent reply other threads:[~2019-09-25 16:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-25 16:36 [kvm-unit-tests PULL 00/17] New s390x kvm-unit-tests and some fixes Thomas Huth
2019-09-25 16:36 ` [kvm-unit-tests PULL 01/17] s390x: Support PSW restart boot Thomas Huth
2019-09-25 16:36 ` [kvm-unit-tests PULL 02/17] s390x: Diag288 test Thomas Huth
2019-09-25 16:37 ` [kvm-unit-tests PULL 03/17] s390x: Move stsi to library Thomas Huth
2019-09-25 16:37 ` [kvm-unit-tests PULL 04/17] s390x: STSI tests Thomas Huth
2019-09-25 16:37 ` [kvm-unit-tests PULL 05/17] s390x: Add diag308 subcode 0 testing Thomas Huth
2019-09-25 16:37 ` Thomas Huth [this message]
2019-09-25 16:37 ` [kvm-unit-tests PULL 07/17] s390x: Storage key library functions now take void ptr addresses Thomas Huth
2019-09-25 16:37 ` [kvm-unit-tests PULL 08/17] s390x: Bump march to zEC12 Thomas Huth
2019-09-25 16:37 ` [kvm-unit-tests PULL 09/17] s390x: Add storage key removal facility Thomas Huth
2019-09-25 16:37 ` [kvm-unit-tests PULL 10/17] s390x: Fix stsi unaligned test and add selector tests Thomas Huth
2019-09-25 16:37 ` [kvm-unit-tests PULL 11/17] s390x: Use interrupts in SCLP and add locking Thomas Huth
2019-09-25 16:37 ` [kvm-unit-tests PULL 12/17] s390x: Add linemode console Thomas Huth
2019-09-25 16:37 ` [kvm-unit-tests PULL 13/17] s390x: Add linemode buffer to fix newline on every print Thomas Huth
2019-09-25 16:37 ` [kvm-unit-tests PULL 14/17] s390x: Add initial smp code Thomas Huth
2019-09-25 16:37 ` [kvm-unit-tests PULL 15/17] s390x: Prepare for external calls Thomas Huth
2019-09-25 16:37 ` [kvm-unit-tests PULL 16/17] s390x: SMP test Thomas Huth
2019-09-25 16:37 ` [kvm-unit-tests PULL 17/17] s390x: Free allocated page in iep test Thomas Huth
2019-09-25 16:39 ` [kvm-unit-tests PULL 00/17] New s390x kvm-unit-tests and some fixes 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=20190925163714.27519-7-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@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