From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
To: "Thomas Huth" <thuth@redhat.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Andrew Jones" <andrew.jones@linux.dev>,
"Nico Böhr" <nrb@linux.ibm.com>,
"Claudio Imbrenda" <imbrenda@linux.ibm.com>,
"Janosch Frank" <frankja@linux.ibm.com>,
"Nina Schoetterl-Glausch" <nsg@linux.ibm.com>
Cc: David Hildenbrand <david@redhat.com>,
kvm@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [kvm-unit-tests PATCH v3 0/7] s390x: STFLE nested interpretation
Date: Thu, 20 Jun 2024 16:16:53 +0200 [thread overview]
Message-ID: <20240620141700.4124157-1-nsg@linux.ibm.com> (raw)
v2 -> v3:
* pick up Ack (thanks Andrew)
* minor cosmetic change to rand generator
* add sie_is_pv function
* extend sie_is_diag_icpt to support pv, replace pv_icptdata_check_diag
Add a test case that tests the interpretation of STFLE performed by a
nested guest using a snippet.
Also add some functionality to lib/, namely:
* pseudo random number generation (arch independent)
* exit (optionally with return code) from snippet (s390x)
* add function for checking diag intercepts, replacing
pv_icptdata_check_diag (s390x)
v1 -> v2:
* implement SHA-256 based PRNG
* pick up R-b (thanks Claudio)
* change snippet exit API and implementation (thanks Claudio)
* add stfle-sie to unittests.cfg
Nina Schoetterl-Glausch (7):
lib: Add pseudo random functions
s390x: lib: Remove double include
s390x: Add sie_is_pv
s390x: Add function for checking diagnose intercepts
s390x: Add library functions for exiting from snippet
s390x: Use library functions for snippet exit
s390x: Add test for STFLE interpretive execution (format-0)
Makefile | 1 +
s390x/Makefile | 3 +
lib/s390x/asm/arch_def.h | 13 ++
lib/s390x/asm/facility.h | 10 +-
lib/rand.h | 21 +++
lib/s390x/pv_icptdata.h | 42 ------
lib/s390x/sie.h | 18 +++
lib/s390x/snippet-guest.h | 26 ++++
lib/s390x/{snippet.h => snippet-host.h} | 10 +-
lib/rand.c | 177 ++++++++++++++++++++++++
lib/s390x/sie.c | 58 +++++++-
lib/s390x/snippet-host.c | 42 ++++++
lib/s390x/uv.c | 2 +-
s390x/mvpg-sie.c | 2 +-
s390x/pv-diags.c | 10 +-
s390x/pv-icptcode.c | 13 +-
s390x/pv-ipl.c | 9 +-
s390x/sie-dat.c | 13 +-
s390x/snippets/c/sie-dat.c | 19 +--
s390x/snippets/c/stfle.c | 26 ++++
s390x/spec_ex-sie.c | 2 +-
s390x/stfle-sie.c | 134 ++++++++++++++++++
s390x/uv-host.c | 2 +-
s390x/unittests.cfg | 3 +
24 files changed, 558 insertions(+), 98 deletions(-)
create mode 100644 lib/rand.h
delete mode 100644 lib/s390x/pv_icptdata.h
create mode 100644 lib/s390x/snippet-guest.h
rename lib/s390x/{snippet.h => snippet-host.h} (92%)
create mode 100644 lib/rand.c
create mode 100644 lib/s390x/snippet-host.c
create mode 100644 s390x/snippets/c/stfle.c
create mode 100644 s390x/stfle-sie.c
Range-diff against v2:
1: 6c869961 ! 1: baecabf2 lib: Add pseudo random functions
@@ Commit message
for i in range(8):
yield int.from_bytes(state[i*4:(i+1)*4], byteorder="big")
+ Acked-by: Andrew Jones <andrew.jones@linux.dev>
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
@@ lib/rand.c (new)
+ return rot(x, 17) ^ rot(x, 19) ^ (x >> 10);
+}
+
-+enum alphabet { a, b, c, d, e, f, g, h, };
++enum alphabet { A, B, C, D, E, F, G, H, };
+
+static void sha256_chunk(const uint32_t (*chunk)[16], uint32_t (*hash)[8])
+{
@@ lib/rand.c (new)
+ for (int i = 0; i < 64; i++) {
+ uint32_t t1, t2;
+
-+ t1 = w_hash[h] +
-+ upper_sig1(w_hash[e]) +
-+ ch(w_hash[e], w_hash[f], w_hash[g]) +
++ t1 = w_hash[H] +
++ upper_sig1(w_hash[E]) +
++ ch(w_hash[E], w_hash[F], w_hash[G]) +
+ K[i] +
+ w[i];
+
-+ t2 = upper_sig0(w_hash[a]) + maj(w_hash[a], w_hash[b], w_hash[c]);
++ t2 = upper_sig0(w_hash[A]) + maj(w_hash[A], w_hash[B], w_hash[C]);
+
-+ w_hash[h] = w_hash[g];
-+ w_hash[g] = w_hash[f];
-+ w_hash[f] = w_hash[e];
-+ w_hash[e] = w_hash[d] + t1;
-+ w_hash[d] = w_hash[c];
-+ w_hash[c] = w_hash[b];
-+ w_hash[b] = w_hash[a];
-+ w_hash[a] = t1 + t2;
++ w_hash[H] = w_hash[G];
++ w_hash[G] = w_hash[F];
++ w_hash[F] = w_hash[E];
++ w_hash[E] = w_hash[D] + t1;
++ w_hash[D] = w_hash[C];
++ w_hash[C] = w_hash[B];
++ w_hash[B] = w_hash[A];
++ w_hash[A] = t1 + t2;
+ }
+
+ for (int i = 0; i < 8; i++)
2: 77319d3e = 2: b30314eb s390x: lib: Remove double include
-: -------- > 3: f2af539b s390x: Add sie_is_pv
-: -------- > 4: c4331d19 s390x: Add function for checking diagnose intercepts
3: e2c2cad8 ! 5: a3f92777 s390x: Add library functions for exiting from snippet
@@ lib/s390x/asm/arch_def.h: static inline uint32_t get_prefix(void)
+
#endif
- ## lib/s390x/sie.h ##
-@@ lib/s390x/sie.h: void sie_expect_validity(struct vm *vm);
- uint16_t sie_get_validity(struct vm *vm);
- void sie_check_validity(struct vm *vm, uint16_t vir_exp);
- void sie_handle_validity(struct vm *vm);
-+bool sie_is_diag_icpt(struct vm *vm, unsigned int diag);
- void sie_guest_sca_create(struct vm *vm);
- void sie_guest_create(struct vm *vm, uint64_t guest_mem, uint64_t guest_mem_len);
- void sie_guest_destroy(struct vm *vm);
-
## lib/s390x/snippet-guest.h (new) ##
@@
+/* SPDX-License-Identifier: GPL-2.0-only */
@@ lib/s390x/snippet-guest.h (new)
+ mb(); /* allow host to modify guest memory */
+}
+
-+#endif
++#endif /* _S390X_SNIPPET_GUEST_H_ */
## lib/s390x/snippet.h => lib/s390x/snippet-host.h ##
@@
@@ lib/s390x/snippet-host.h: static inline void snippet_setup_guest(struct vm *vm,
+void snippet_check_force_exit_value(struct vm *vm, uint64_t exit_exp);
#endif
- ## lib/s390x/sie.c ##
-@@ lib/s390x/sie.c: void sie_check_validity(struct vm *vm, uint16_t vir_exp)
- report(vir_exp == vir, "VALIDITY: %x", vir);
- }
-
-+bool sie_is_diag_icpt(struct vm *vm, unsigned int diag)
-+{
-+ union {
-+ struct {
-+ uint64_t : 16;
-+ uint64_t ipa : 16;
-+ uint64_t ipb : 32;
-+ };
-+ struct {
-+ uint64_t : 16;
-+ uint64_t opcode : 8;
-+ uint64_t r_1 : 4;
-+ uint64_t r_2 : 4;
-+ uint64_t r_base : 4;
-+ uint64_t displace : 12;
-+ uint64_t zero : 16;
-+ };
-+ } instr = { .ipa = vm->sblk->ipa, .ipb = vm->sblk->ipb };
-+ uint64_t code;
-+
-+ assert(diag == 0x44 || diag == 0x9c);
-+
-+ if (vm->sblk->icptcode != ICPT_INST)
-+ return false;
-+ if (instr.opcode != 0x83 || instr.zero)
-+ return false;
-+ code = instr.r_base ? vm->save_area.guest.grs[instr.r_base] : 0;
-+ code = (code + instr.displace) & 0xffff;
-+ return code == diag;
-+}
-+
- void sie_handle_validity(struct vm *vm)
- {
- if (vm->sblk->icptcode != ICPT_VALIDITY)
-
## lib/s390x/snippet-host.c (new) ##
@@
+/* SPDX-License-Identifier: GPL-2.0-only */
@@ s390x/pv-diags.c
#include <libcflat.h>
-#include <snippet.h>
+#include <snippet-host.h>
- #include <pv_icptdata.h>
#include <sie.h>
#include <sclp.h>
+ #include <asm/facility.h>
## s390x/pv-icptcode.c ##
@@
@@ s390x/pv-icptcode.c
#include <sclp.h>
-#include <snippet.h>
+#include <snippet-host.h>
- #include <pv_icptdata.h>
#include <asm/facility.h>
#include <asm/barrier.h>
+ #include <asm/sigp.h>
## s390x/pv-ipl.c ##
@@
@@ s390x/pv-ipl.c
#include <sclp.h>
-#include <snippet.h>
+#include <snippet-host.h>
- #include <pv_icptdata.h>
#include <asm/facility.h>
#include <asm/uv.h>
+
## s390x/sie-dat.c ##
@@
4: 67fbf0bb ! 6: a1db588b s390x: Use library functions for snippet exit
@@ s390x/sie-dat.c: static void test_sie_dat(void)
## s390x/snippets/c/sie-dat.c ##
@@
- */
#include <libcflat.h>
#include <asm-generic/page.h>
+ #include <asm/mem.h>
+#include <snippet-guest.h>
#include "sie-dat.h"
5: 157079f2 ! 7: 0b89b3c6 s390x: Add test for STFLE interpretive execution (format-0)
@@ s390x/stfle-sie.c (new)
+}
## s390x/unittests.cfg ##
-@@ s390x/unittests.cfg: extra_params = """-cpu max,ctop=on -smp cpus=1,drawers=2,books=2,sockets=2,cores
+@@ s390x/unittests.cfg: file = sie-dat.elf
- [sie-dat]
- file = sie-dat.elf
+ [pv-attest]
+ file = pv-attest.elf
+
+[stfle-sie]
+file = stfle-sie.elf
base-commit: 28ac3b10d6f982b1d9c2fe629f23d23ec5024b4f
--
2.44.0
next reply other threads:[~2024-06-20 14:17 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-20 14:16 Nina Schoetterl-Glausch [this message]
2024-06-20 14:16 ` [kvm-unit-tests PATCH v3 1/7] lib: Add pseudo random functions Nina Schoetterl-Glausch
2024-06-25 3:08 ` Nicholas Piggin
2024-06-25 7:06 ` Nina Schoetterl-Glausch
2024-08-12 14:17 ` Andrew Jones
2024-10-10 8:25 ` Nico Boehr
2024-10-10 8:37 ` Andrew Jones
2024-06-20 14:16 ` [kvm-unit-tests PATCH v3 2/7] s390x: lib: Remove double include Nina Schoetterl-Glausch
2024-06-21 6:58 ` Janosch Frank
2024-06-20 14:16 ` [kvm-unit-tests PATCH v3 3/7] s390x: Add sie_is_pv Nina Schoetterl-Glausch
2024-06-20 16:41 ` Claudio Imbrenda
2024-06-21 6:59 ` Janosch Frank
2024-06-25 1:58 ` Nicholas Piggin
2024-06-20 14:16 ` [kvm-unit-tests PATCH v3 4/7] s390x: Add function for checking diagnose intercepts Nina Schoetterl-Glausch
2024-06-20 16:47 ` Claudio Imbrenda
2024-06-20 17:46 ` Nina Schoetterl-Glausch
2024-06-21 7:13 ` Janosch Frank
2024-06-25 2:14 ` Nicholas Piggin
2024-06-25 8:11 ` Nina Schoetterl-Glausch
2024-06-25 23:52 ` Nicholas Piggin
2024-06-20 14:16 ` [kvm-unit-tests PATCH v3 5/7] s390x: Add library functions for exiting from snippet Nina Schoetterl-Glausch
2024-06-20 16:55 ` Claudio Imbrenda
2024-06-20 17:16 ` Nina Schoetterl-Glausch
2024-06-20 17:26 ` Claudio Imbrenda
2024-06-25 3:13 ` Nicholas Piggin
2024-06-25 2:43 ` Nicholas Piggin
2024-10-16 14:42 ` Nina Schoetterl-Glausch
2024-06-25 2:57 ` Nicholas Piggin
2024-06-25 9:21 ` Claudio Imbrenda
2024-06-20 14:16 ` [kvm-unit-tests PATCH v3 6/7] s390x: Use library functions for snippet exit Nina Schoetterl-Glausch
2024-06-20 16:56 ` Claudio Imbrenda
2024-06-25 2:58 ` Nicholas Piggin
2024-06-20 14:17 ` [kvm-unit-tests PATCH v3 7/7] s390x: Add test for STFLE interpretive execution (format-0) Nina Schoetterl-Glausch
2024-06-20 17:25 ` Claudio Imbrenda
2024-06-20 17:42 ` Nina Schoetterl-Glausch
2024-06-25 3:11 ` Nicholas Piggin
2024-08-27 14:08 ` Nico Boehr
2024-09-02 14:24 ` Nina Schoetterl-Glausch
2024-09-03 10:46 ` Heiko Carstens
2024-10-10 8:27 ` Nico Boehr
2024-10-15 11:01 ` Nina Schoetterl-Glausch
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=20240620141700.4124157-1-nsg@linux.ibm.com \
--to=nsg@linux.ibm.com \
--cc=andrew.jones@linux.dev \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=npiggin@gmail.com \
--cc=nrb@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox