* [kvm-unit-tests GIT PULL 01/18] s390x: Split and rework cpacf query functions
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 02/18] s390x: edat: test 2G large page spanning end of memory Nico Boehr
` (17 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones
Cc: kvm, frankja, imbrenda, Nina Schoetterl-Glausch
From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Cherry-pick 830999bd7e72 ("s390/cpacf: Split and rework cpacf query functions")
from the kernel:
Rework the cpacf query functions to use the correct RRE
or RRF instruction formats and set register fields within
instructions correctly.
Fixes: a555dc6b16bf ("s390x: add cpacf.h from Linux")
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Link: https://lore.kernel.org/r/20240621102212.3311494-1-nsg@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
lib/s390x/asm/cpacf.h | 77 +++++++++++++++++++++++++++++++++++++------
1 file changed, 67 insertions(+), 10 deletions(-)
diff --git a/lib/s390x/asm/cpacf.h b/lib/s390x/asm/cpacf.h
index 378cd5cf..ba53ec31 100644
--- a/lib/s390x/asm/cpacf.h
+++ b/lib/s390x/asm/cpacf.h
@@ -137,19 +137,76 @@
typedef struct { unsigned char bytes[16]; } cpacf_mask_t;
-static __always_inline void __cpacf_query(unsigned int opcode, cpacf_mask_t *mask)
+static __always_inline void __cpacf_query_rre(u32 opc, u8 r1, u8 r2,
+ cpacf_mask_t *mask)
{
- register unsigned long r0 asm("0") = 0; /* query function */
- register unsigned long r1 asm("1") = (unsigned long) mask;
+ asm volatile(
+ " la %%r1,%[mask]\n"
+ " xgr %%r0,%%r0\n"
+ " .insn rre,%[opc] << 16,%[r1],%[r2]\n"
+ : [mask] "=R" (*mask)
+ : [opc] "i" (opc),
+ [r1] "i" (r1), [r2] "i" (r2)
+ : "cc", "r0", "r1");
+}
+static __always_inline void __cpacf_query_rrf(u32 opc,
+ u8 r1, u8 r2, u8 r3, u8 m4,
+ cpacf_mask_t *mask)
+{
asm volatile(
- " spm 0\n" /* pckmo doesn't change the cc */
- /* Parameter regs are ignored, but must be nonzero and unique */
- "0: .insn rrf,%[opc] << 16,2,4,6,0\n"
- " brc 1,0b\n" /* handle partial completion */
- : "=m" (*mask)
- : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (opcode)
- : "cc");
+ " la %%r1,%[mask]\n"
+ " xgr %%r0,%%r0\n"
+ " .insn rrf,%[opc] << 16,%[r1],%[r2],%[r3],%[m4]\n"
+ : [mask] "=R" (*mask)
+ : [opc] "i" (opc), [r1] "i" (r1), [r2] "i" (r2),
+ [r3] "i" (r3), [m4] "i" (m4)
+ : "cc", "r0", "r1");
+}
+
+static __always_inline void __cpacf_query(unsigned int opcode,
+ cpacf_mask_t *mask)
+{
+ switch (opcode) {
+ case CPACF_KIMD:
+ __cpacf_query_rre(CPACF_KIMD, 0, 2, mask);
+ break;
+ case CPACF_KLMD:
+ __cpacf_query_rre(CPACF_KLMD, 0, 2, mask);
+ break;
+ case CPACF_KM:
+ __cpacf_query_rre(CPACF_KM, 2, 4, mask);
+ break;
+ case CPACF_KMA:
+ __cpacf_query_rrf(CPACF_KMA, 2, 4, 6, 0, mask);
+ break;
+ case CPACF_KMAC:
+ __cpacf_query_rre(CPACF_KMAC, 0, 2, mask);
+ break;
+ case CPACF_KMC:
+ __cpacf_query_rre(CPACF_KMC, 2, 4, mask);
+ break;
+ case CPACF_KMCTR:
+ __cpacf_query_rrf(CPACF_KMCTR, 2, 4, 6, 0, mask);
+ break;
+ case CPACF_KMF:
+ __cpacf_query_rre(CPACF_KMF, 2, 4, mask);
+ break;
+ case CPACF_KMO:
+ __cpacf_query_rre(CPACF_KMO, 2, 4, mask);
+ break;
+ case CPACF_PCC:
+ __cpacf_query_rre(CPACF_PCC, 0, 0, mask);
+ break;
+ case CPACF_PCKMO:
+ __cpacf_query_rre(CPACF_PCKMO, 0, 0, mask);
+ break;
+ case CPACF_PRNO:
+ __cpacf_query_rre(CPACF_PRNO, 2, 4, mask);
+ break;
+ default:
+ asm volatile(".error \"bad opcode\"");
+ }
}
static inline int __cpacf_check_opcode(unsigned int opcode)
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 02/18] s390x: edat: test 2G large page spanning end of memory
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 01/18] s390x: Split and rework cpacf query functions Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 03/18] s390x: edat: move LC_SIZE to arch_def.h Nico Boehr
` (16 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda
From: Claudio Imbrenda <imbrenda@linux.ibm.com>
Create a region 3 table with fc=1 (i.e. a 2G large page) mapping across the
end of memory.
Check that the part of the large page before the end of memory is accessible,
and the part that is after the end of memory is not.
Also fix a typo in the existing edat2 test.
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Link: https://lore.kernel.org/r/20241001113640.55210-1-imbrenda@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
s390x/edat.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/s390x/edat.c b/s390x/edat.c
index 16138397..1f582efc 100644
--- a/s390x/edat.c
+++ b/s390x/edat.c
@@ -196,6 +196,8 @@ static void test_edat1(void)
static void test_edat2(void)
{
+ uint64_t mem_end, i;
+
report_prefix_push("edat2");
p[0] = 42;
@@ -206,7 +208,21 @@ static void test_edat2(void)
/* Prefixing should not work with huge pages, just like large pages */
report(!memcmp(0, VIRT(prefix_buf), LC_SIZE) &&
!memcmp(prefix_buf, VIRT(0), LC_SIZE),
- "pmd, large, prefixing");
+ "pud, large, prefixing");
+
+ mem_end = get_ram_size();
+ if (mem_end >= BIT_ULL(REGION3_SHIFT)) {
+ report_skip("pud spanning end of memory");
+ } else {
+ for (i = 0; i < mem_end; i += PAGE_SIZE)
+ READ_ONCE(*(uint64_t *)VIRT(i));
+ for (i = mem_end; i < BIT_ULL(REGION3_SHIFT); i += PAGE_SIZE) {
+ expect_pgm_int();
+ READ_ONCE(*(uint64_t *)VIRT(i));
+ assert(clear_pgm_int() == PGM_INT_CODE_ADDRESSING);
+ }
+ report_pass("pud spanning end of memory");
+ }
report_prefix_pop();
}
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 03/18] s390x: edat: move LC_SIZE to arch_def.h
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 01/18] s390x: Split and rework cpacf query functions Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 02/18] s390x: edat: test 2G large page spanning end of memory Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 04/18] s390x: add test for diag258 Nico Boehr
` (15 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda
struct lowcore is defined in arch_def.h and LC_SIZE is useful to other
tests as well, therefore move it to arch_def.h.
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Link: https://lore.kernel.org/r/20241010071228.565038-2-nrb@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
lib/s390x/asm/arch_def.h | 1 +
s390x/edat.c | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
index 745a3387..5574a451 100644
--- a/lib/s390x/asm/arch_def.h
+++ b/lib/s390x/asm/arch_def.h
@@ -119,6 +119,7 @@ enum address_space {
#define CTL2_GUARDED_STORAGE (63 - 59)
+#define LC_SIZE (2 * PAGE_SIZE)
struct lowcore {
uint8_t pad_0x0000[0x0080 - 0x0000]; /* 0x0000 */
uint32_t ext_int_param; /* 0x0080 */
diff --git a/s390x/edat.c b/s390x/edat.c
index 1f582efc..89b9c2d3 100644
--- a/s390x/edat.c
+++ b/s390x/edat.c
@@ -17,7 +17,6 @@
#define PGD_PAGE_SHIFT (REGION1_SHIFT - PAGE_SHIFT)
-#define LC_SIZE (2 * PAGE_SIZE)
#define VIRT(x) ((void *)((unsigned long)(x) + (unsigned long)mem))
static uint8_t prefix_buf[LC_SIZE] __attribute__((aligned(LC_SIZE)));
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 04/18] s390x: add test for diag258
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (2 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 03/18] s390x: edat: move LC_SIZE to arch_def.h Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 05/18] s390x: lib: Remove double include Nico Boehr
` (14 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda
This adds a test for diag258 (page ref service/async page fault).
There recently was a virtual-real address confusion bug, so we should
test:
- diag258 parameter Rx is a real adress
- crossing the end of RAM with the parameter list yields an addressing
exception
- invalid diagcode in the parameter block yields an specification
exception
- diag258 correctly applies prefixing.
Note that we're just testing error cases as of now.
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Link: https://lore.kernel.org/r/20241010071228.565038-3-nrb@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
s390x/Makefile | 1 +
s390x/diag258.c | 259 ++++++++++++++++++++++++++++++++++++++++++++
s390x/unittests.cfg | 3 +
3 files changed, 263 insertions(+)
create mode 100644 s390x/diag258.c
diff --git a/s390x/Makefile b/s390x/Makefile
index 23342bd6..66d71351 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -44,6 +44,7 @@ tests += $(TEST_DIR)/exittime.elf
tests += $(TEST_DIR)/ex.elf
tests += $(TEST_DIR)/topology.elf
tests += $(TEST_DIR)/sie-dat.elf
+tests += $(TEST_DIR)/diag258.elf
pv-tests += $(TEST_DIR)/pv-diags.elf
pv-tests += $(TEST_DIR)/pv-icptcode.elf
diff --git a/s390x/diag258.c b/s390x/diag258.c
new file mode 100644
index 00000000..8ba75a72
--- /dev/null
+++ b/s390x/diag258.c
@@ -0,0 +1,259 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Diag 258: Async Page Fault Handler
+ *
+ * Copyright (c) 2024 IBM Corp
+ *
+ * Authors:
+ * Nico Boehr <nrb@linux.ibm.com>
+ */
+
+#include <libcflat.h>
+#include <asm-generic/barrier.h>
+#include <asm/asm-offsets.h>
+#include <asm/interrupt.h>
+#include <asm/mem.h>
+#include <asm/pgtable.h>
+#include <mmu.h>
+#include <sclp.h>
+#include <vmalloc.h>
+
+static uint8_t prefix_buf[LC_SIZE] __attribute__((aligned(LC_SIZE)));
+
+#define __PF_RES_FIELD 0x8000000000000000UL
+
+/* copied from Linux arch/s390/mm/pfault.c */
+struct pfault_refbk {
+ u16 refdiagc;
+ u16 reffcode;
+ u16 refdwlen;
+ u16 refversn;
+ u64 refgaddr;
+ u64 refselmk;
+ u64 refcmpmk;
+ u64 reserved;
+};
+
+uint64_t pfault_token = 0x0123fadec0fe3210UL;
+
+static struct pfault_refbk pfault_init_refbk __attribute__((aligned(8))) = {
+ .refdiagc = 0x258,
+ .reffcode = 0, /* TOKEN */
+ .refdwlen = sizeof(struct pfault_refbk) / sizeof(uint64_t),
+ .refversn = 2,
+ .refgaddr = (u64)&pfault_token,
+ .refselmk = 1UL << 48,
+ .refcmpmk = 1UL << 48,
+ .reserved = __PF_RES_FIELD
+};
+
+static struct pfault_refbk pfault_cancel_refbk __attribute((aligned(8))) = {
+ .refdiagc = 0x258,
+ .reffcode = 1, /* CANCEL */
+ .refdwlen = sizeof(struct pfault_refbk) / sizeof(uint64_t),
+ .refversn = 2,
+ .refgaddr = 0,
+ .refselmk = 0,
+ .refcmpmk = 0,
+ .reserved = 0
+};
+
+static inline int diag258(struct pfault_refbk *refbk)
+{
+ int rc = -1;
+
+ asm volatile(
+ " diag %[refbk],%[rc],0x258\n"
+ : [rc] "+d" (rc)
+ : [refbk] "a" (refbk), "m" (*(refbk))
+ : "cc");
+ return rc;
+}
+
+static void test_priv(void)
+{
+ report_prefix_push("privileged");
+ expect_pgm_int();
+ enter_pstate();
+ diag258(&pfault_init_refbk);
+ check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION);
+ report_prefix_pop();
+}
+
+static void *page_map_outside_real_space(phys_addr_t page_real)
+{
+ pgd_t *root = (pgd_t *)(stctg(1) & PAGE_MASK);
+ void *vaddr = alloc_vpage();
+
+ install_page(root, page_real, vaddr);
+
+ return vaddr;
+}
+
+/*
+ * Verify that the refbk pointer is a real address and not a virtual
+ * address. This is tested by enabling DAT and establishing a mapping
+ * for the refbk that is outside of the bounds of our (guest-)physical
+ * address space.
+ */
+static void test_refbk_real(void)
+{
+ struct pfault_refbk *refbk;
+ void *refbk_page;
+ pgd_t *root;
+
+ report_prefix_push("refbk is real");
+
+ /* Set up virtual memory and allocate a physical page for storing the refbk */
+ setup_vm();
+ refbk_page = alloc_page();
+
+ /* Map refblk page outside of physical memory identity mapping */
+ root = (pgd_t *)(stctg(1) & PAGE_MASK);
+ refbk = page_map_outside_real_space(virt_to_pte_phys(root, refbk_page));
+
+ /* Assert the mapping really is outside identity mapping */
+ report_info("refbk is at 0x%lx", (u64)refbk);
+ report_info("ram size is 0x%lx", get_ram_size());
+ assert((u64)refbk > get_ram_size());
+
+ /* Copy the init refbk to the page */
+ memcpy(refbk, &pfault_init_refbk, sizeof(struct pfault_refbk));
+
+ /* Protect the virtual mapping to avoid diag258 actually doing something */
+ protect_page(refbk, PAGE_ENTRY_I);
+
+ expect_pgm_int();
+ diag258(refbk);
+ check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
+ report_prefix_pop();
+
+ free_page(refbk_page);
+ disable_dat();
+ irq_set_dat_mode(false, 0);
+}
+
+/*
+ * Verify diag258 correctly applies prefixing.
+ */
+static void test_refbk_prefixing(void)
+{
+ const size_t lowcore_offset_for_refbk = offsetof(struct lowcore, pad_0x03a0);
+ struct pfault_refbk *refbk_in_prefix, *refbk_in_reverse_prefix;
+ uint32_t old_prefix;
+ uint64_t ry;
+
+ report_prefix_push("refbk prefixing");
+
+ report_info("refbk at lowcore offset 0x%lx", lowcore_offset_for_refbk);
+
+ assert((unsigned long)&prefix_buf < SZ_2G);
+
+ memcpy(prefix_buf, 0, LC_SIZE);
+
+ /*
+ * After the call to set_prefix() below, this will refer to absolute
+ * address lowcore_offset_for_refbk (reverse prefixing).
+ */
+ refbk_in_reverse_prefix = (struct pfault_refbk *)(&prefix_buf[0] + lowcore_offset_for_refbk);
+
+ /*
+ * After the call to set_prefix() below, this will refer to absolute
+ * address &prefix_buf[0] + lowcore_offset_for_refbk (forward prefixing).
+ */
+ refbk_in_prefix = (struct pfault_refbk *)OPAQUE_PTR(lowcore_offset_for_refbk);
+
+ old_prefix = get_prefix();
+ set_prefix((uint32_t)(uintptr_t)prefix_buf);
+
+ /*
+ * If diag258 would not be applying prefixing on access to
+ * refbk_in_reverse_prefix correctly, it would access absolute address
+ * refbk_in_reverse_prefix (which to us is accessible at real address
+ * refbk_in_prefix).
+ * Make sure it really fails by putting invalid function code
+ * at refbk_in_prefix.
+ */
+ refbk_in_prefix->refdiagc = 0xc0fe;
+
+ /*
+ * Put a valid refbk at refbk_in_reverse_prefix.
+ */
+ memcpy(refbk_in_reverse_prefix, &pfault_init_refbk, sizeof(pfault_init_refbk));
+
+ ry = diag258(refbk_in_reverse_prefix);
+ report(!ry, "real address refbk accessed");
+
+ /*
+ * Activating should have worked. Cancel the activation and expect
+ * return 0. If activation would not have worked, this should return with
+ * 4 (pfault handshaking not active).
+ */
+ ry = diag258(&pfault_cancel_refbk);
+ report(!ry, "handshaking canceled");
+
+ set_prefix(old_prefix);
+
+ report_prefix_pop();
+}
+
+/*
+ * Verify that a refbk exceeding physical memory is not accepted, even
+ * when crossing a frame boundary.
+ */
+static void test_refbk_crossing(void)
+{
+ const size_t bytes_in_last_page = 8;
+ struct pfault_refbk *refbk = (struct pfault_refbk *)(get_ram_size() - bytes_in_last_page);
+
+ report_prefix_push("refbk crossing");
+
+ report_info("refbk is at 0x%lx", (u64)refbk);
+ report_info("ram size is 0x%lx", get_ram_size());
+ assert(sizeof(struct pfault_refbk) > bytes_in_last_page);
+
+ /* Copy bytes_in_last_page bytes of the init refbk to the page */
+ memcpy(refbk, &pfault_init_refbk, bytes_in_last_page);
+
+ expect_pgm_int();
+ diag258(refbk);
+ check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
+ report_prefix_pop();
+}
+
+/*
+ * Verify that a refbk with an invalid refdiagc is not accepted.
+ */
+static void test_refbk_invalid_diagcode(void)
+{
+ struct pfault_refbk refbk __attribute__((aligned(8))) = pfault_init_refbk;
+
+ report_prefix_push("invalid refdiagc");
+ refbk.refdiagc = 0xc0fe;
+
+ expect_pgm_int();
+ diag258(&refbk);
+ check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
+ report_prefix_pop();
+}
+
+int main(void)
+{
+ report_prefix_push("diag258");
+
+ expect_pgm_int();
+ diag258((struct pfault_refbk *)0xfffffffffffffff0);
+ if (clear_pgm_int() == PGM_INT_CODE_SPECIFICATION) {
+ report_skip("diag258 not supported");
+ } else {
+ test_priv();
+ /* Other tests rely on invalid diagcodes doing nothing */
+ test_refbk_invalid_diagcode();
+ test_refbk_real();
+ test_refbk_prefixing();
+ test_refbk_crossing();
+ }
+
+ report_prefix_pop();
+ return report_summary();
+}
diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg
index 3a9decc9..8131ba10 100644
--- a/s390x/unittests.cfg
+++ b/s390x/unittests.cfg
@@ -392,3 +392,6 @@ file = sie-dat.elf
[pv-attest]
file = pv-attest.elf
+
+[diag258]
+file = diag258.elf
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 05/18] s390x: lib: Remove double include
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (3 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 04/18] s390x: add test for diag258 Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 06/18] s390x: Add sie_is_pv Nico Boehr
` (13 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones
Cc: kvm, frankja, imbrenda, Nina Schoetterl-Glausch
From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
libcflat.h was included twice.
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Link: https://lore.kernel.org/r/20241016180320.686132-2-nsg@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
lib/s390x/sie.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c
index 28fbf146..40936bd2 100644
--- a/lib/s390x/sie.c
+++ b/lib/s390x/sie.c
@@ -14,7 +14,6 @@
#include <sie.h>
#include <asm/page.h>
#include <asm/interrupt.h>
-#include <libcflat.h>
#include <alloc_page.h>
#include <vmalloc.h>
#include <sclp.h>
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 06/18] s390x: Add sie_is_pv
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (4 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 05/18] s390x: lib: Remove double include Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 07/18] s390x: Add function for checking diagnose intercepts Nico Boehr
` (12 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones
Cc: kvm, frankja, imbrenda, Nina Schoetterl-Glausch, Nicholas Piggin
From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Add a function to check if a guest VM is currently running protected.
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Link: https://lore.kernel.org/r/20241016180320.686132-3-nsg@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
lib/s390x/sie.h | 6 ++++++
lib/s390x/sie.c | 4 ++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h
index c1724cf2..53cd767f 100644
--- a/lib/s390x/sie.h
+++ b/lib/s390x/sie.h
@@ -281,6 +281,12 @@ 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);
+
+static inline bool sie_is_pv(struct vm *vm)
+{
+ return vm->sblk->sdf == 2;
+}
+
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);
diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c
index 40936bd2..0fa915cf 100644
--- a/lib/s390x/sie.c
+++ b/lib/s390x/sie.c
@@ -59,7 +59,7 @@ void sie(struct vm *vm)
/* When a pgm int code is set, we'll never enter SIE below. */
assert(!read_pgm_int_code());
- if (vm->sblk->sdf == 2)
+ if (sie_is_pv(vm))
memcpy(vm->sblk->pv_grregs, vm->save_area.guest.grs,
sizeof(vm->save_area.guest.grs));
@@ -98,7 +98,7 @@ void sie(struct vm *vm)
/* restore the old CR 13 */
lctlg(13, old_cr13);
- if (vm->sblk->sdf == 2)
+ if (sie_is_pv(vm))
memcpy(vm->save_area.guest.grs, vm->sblk->pv_grregs,
sizeof(vm->save_area.guest.grs));
}
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 07/18] s390x: Add function for checking diagnose intercepts
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (5 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 06/18] s390x: Add sie_is_pv Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 08/18] s390x: Add library functions for exiting from snippet Nico Boehr
` (11 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones
Cc: kvm, frankja, imbrenda, Nina Schoetterl-Glausch
From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
sie_is_diag_icpt() checks if the intercept is due to an expected
diagnose call and is valid.
It subsumes pv_icptdata_check_diag.
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/r/20241016180320.686132-4-nsg@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
s390x/Makefile | 1 +
lib/s390x/pv_icptdata.h | 42 -----------------------------
lib/s390x/sie-icpt.h | 39 +++++++++++++++++++++++++++
lib/s390x/sie-icpt.c | 60 +++++++++++++++++++++++++++++++++++++++++
s390x/pv-diags.c | 9 +++----
s390x/pv-icptcode.c | 12 ++++-----
s390x/pv-ipl.c | 8 +++---
7 files changed, 114 insertions(+), 57 deletions(-)
delete mode 100644 lib/s390x/pv_icptdata.h
create mode 100644 lib/s390x/sie-icpt.h
create mode 100644 lib/s390x/sie-icpt.c
diff --git a/s390x/Makefile b/s390x/Makefile
index 66d71351..907b3a04 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -112,6 +112,7 @@ cflatobjs += lib/s390x/css_lib.o
cflatobjs += lib/s390x/malloc_io.o
cflatobjs += lib/s390x/uv.o
cflatobjs += lib/s390x/sie.o
+cflatobjs += lib/s390x/sie-icpt.o
cflatobjs += lib/s390x/fault.o
OBJDIRS += lib/s390x
diff --git a/lib/s390x/pv_icptdata.h b/lib/s390x/pv_icptdata.h
deleted file mode 100644
index 4746117e..00000000
--- a/lib/s390x/pv_icptdata.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Commonly used checks for PV SIE intercept data
- *
- * Copyright IBM Corp. 2023
- * Author: Janosch Frank <frankja@linux.ibm.com>
- */
-
-#ifndef _S390X_PV_ICPTDATA_H_
-#define _S390X_PV_ICPTDATA_H_
-
-#include <sie.h>
-
-/*
- * Checks the diagnose instruction intercept data for consistency with
- * the constants defined by the PV SIE architecture
- *
- * Supports: 0x44, 0x9c, 0x288, 0x308, 0x500
- */
-static bool pv_icptdata_check_diag(struct vm *vm, int diag)
-{
- int icptcode;
-
- switch (diag) {
- case 0x44:
- case 0x9c:
- case 0x288:
- case 0x308:
- icptcode = ICPT_PV_NOTIFY;
- break;
- case 0x500:
- icptcode = ICPT_PV_INSTR;
- break;
- default:
- /* If a new diag is introduced add it to the cases above! */
- assert(0);
- }
-
- return vm->sblk->icptcode == icptcode && vm->sblk->ipa == 0x8302 &&
- vm->sblk->ipb == 0x50000000 && vm->save_area.guest.grs[5] == diag;
-}
-#endif
diff --git a/lib/s390x/sie-icpt.h b/lib/s390x/sie-icpt.h
new file mode 100644
index 00000000..604a7221
--- /dev/null
+++ b/lib/s390x/sie-icpt.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Functionality for SIE interception handling.
+ *
+ * Copyright IBM Corp. 2024
+ */
+
+#ifndef _S390X_SIE_ICPT_H_
+#define _S390X_SIE_ICPT_H_
+
+#include <libcflat.h>
+#include <sie.h>
+
+struct diag_itext {
+ 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;
+ uint64_t : 16;
+};
+
+struct diag_itext sblk_ip_as_diag(struct kvm_s390_sie_block *sblk);
+
+/**
+ * sie_is_diag_icpt() - Check if intercept is due to diagnose instruction
+ * @vm: the guest
+ * @diag: the expected diagnose code
+ *
+ * Check that the intercept is due to diagnose @diag and valid.
+ * For protected virtualization, check that the intercept data meets additional
+ * constraints.
+ *
+ * Returns: true if intercept is due to a valid and has matching diagnose code
+ */
+bool sie_is_diag_icpt(struct vm *vm, unsigned int diag);
+
+#endif /* _S390X_SIE_ICPT_H_ */
diff --git a/lib/s390x/sie-icpt.c b/lib/s390x/sie-icpt.c
new file mode 100644
index 00000000..17064424
--- /dev/null
+++ b/lib/s390x/sie-icpt.c
@@ -0,0 +1,60 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Functionality for SIE interception handling.
+ *
+ * Copyright IBM Corp. 2024
+ */
+
+#include <sie-icpt.h>
+
+struct diag_itext sblk_ip_as_diag(struct kvm_s390_sie_block *sblk)
+{
+ union {
+ struct {
+ uint64_t ipa : 16;
+ uint64_t ipb : 32;
+ uint64_t : 16;
+ };
+ struct diag_itext diag;
+ } instr = { .ipa = sblk->ipa, .ipb = sblk->ipb };
+
+ return instr.diag;
+}
+
+bool sie_is_diag_icpt(struct vm *vm, unsigned int diag)
+{
+ struct diag_itext instr = sblk_ip_as_diag(vm->sblk);
+ uint8_t icptcode;
+ uint64_t code;
+
+ switch (diag) {
+ case 0x44:
+ case 0x9c:
+ case 0x288:
+ case 0x308:
+ icptcode = ICPT_PV_NOTIFY;
+ break;
+ case 0x500:
+ icptcode = ICPT_PV_INSTR;
+ break;
+ default:
+ /* If a new diag is introduced add it to the cases above! */
+ assert_msg(false, "unknown diag 0x%x", diag);
+ }
+
+ if (sie_is_pv(vm)) {
+ if (instr.r_1 != 0 || instr.r_2 != 2 || instr.r_base != 5)
+ return false;
+ if (instr.displace)
+ return false;
+ } else {
+ icptcode = ICPT_INST;
+ }
+ if (vm->sblk->icptcode != icptcode)
+ 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;
+}
diff --git a/s390x/pv-diags.c b/s390x/pv-diags.c
index 3193ad99..09b83d59 100644
--- a/s390x/pv-diags.c
+++ b/s390x/pv-diags.c
@@ -9,7 +9,7 @@
*/
#include <libcflat.h>
#include <snippet.h>
-#include <pv_icptdata.h>
+#include <sie-icpt.h>
#include <sie.h>
#include <sclp.h>
#include <asm/facility.h>
@@ -32,8 +32,7 @@ static void test_diag_500(void)
size_gbin, size_hdr, SNIPPET_UNPACK_OFF);
sie(&vm);
- report(pv_icptdata_check_diag(&vm, 0x500),
- "intercept values");
+ report(sie_is_diag_icpt(&vm, 0x500), "intercept values");
report(vm.save_area.guest.grs[1] == 1 &&
vm.save_area.guest.grs[2] == 2 &&
vm.save_area.guest.grs[3] == 3 &&
@@ -45,7 +44,7 @@ static void test_diag_500(void)
*/
vm.sblk->iictl = IICTL_CODE_OPERAND;
sie(&vm);
- report(pv_icptdata_check_diag(&vm, 0x9c) &&
+ report(sie_is_diag_icpt(&vm, 0x9c) &&
vm.save_area.guest.grs[0] == PGM_INT_CODE_OPERAND,
"operand exception");
@@ -57,7 +56,7 @@ static void test_diag_500(void)
vm.sblk->iictl = IICTL_CODE_SPECIFICATION;
/* Inject PGM, next exit should be 9c */
sie(&vm);
- report(pv_icptdata_check_diag(&vm, 0x9c) &&
+ report(sie_is_diag_icpt(&vm, 0x9c) &&
vm.save_area.guest.grs[0] == PGM_INT_CODE_SPECIFICATION,
"specification exception");
diff --git a/s390x/pv-icptcode.c b/s390x/pv-icptcode.c
index d7c47d6f..5293306b 100644
--- a/s390x/pv-icptcode.c
+++ b/s390x/pv-icptcode.c
@@ -13,7 +13,7 @@
#include <smp.h>
#include <sclp.h>
#include <snippet.h>
-#include <pv_icptdata.h>
+#include <sie-icpt.h>
#include <asm/facility.h>
#include <asm/barrier.h>
#include <asm/sigp.h>
@@ -47,7 +47,7 @@ static void test_validity_timing(void)
size_gbin, size_hdr, SNIPPET_UNPACK_OFF);
sie(&vm);
- report(pv_icptdata_check_diag(&vm, 0x44), "spt done");
+ report(sie_is_diag_icpt(&vm, 0x44), "spt done");
stck(&time_exit);
tmp = vm.sblk->cputm;
mb();
@@ -258,7 +258,7 @@ static void test_validity_asce(void)
/* Try if we can still do an entry with the correct asce */
sie(&vm);
- report(pv_icptdata_check_diag(&vm, 0x44), "re-entry with valid CR1");
+ report(sie_is_diag_icpt(&vm, 0x44), "re-entry with valid CR1");
uv_destroy_guest(&vm);
free_pages(pgd_new);
report_prefix_pop();
@@ -294,7 +294,7 @@ static void run_icpt_122_tests_prefix(unsigned long prefix)
sie(&vm);
/* Guest indicates that it has been setup via the diag 0x44 */
- assert(pv_icptdata_check_diag(&vm, 0x44));
+ assert(sie_is_diag_icpt(&vm, 0x44));
/* If the pages have not been shared these writes will cause exceptions */
ptr = (uint32_t *)prefix;
WRITE_ONCE(ptr, 0);
@@ -328,7 +328,7 @@ static void test_icpt_112(void)
/* Setup of the guest's state for 0x0 prefix */
sie(&vm);
- assert(pv_icptdata_check_diag(&vm, 0x44));
+ assert(sie_is_diag_icpt(&vm, 0x44));
/* Test on standard 0x0 prefix */
run_icpt_122_tests_prefix(0);
@@ -348,7 +348,7 @@ static void test_icpt_112(void)
/* Try a re-entry after everything has been imported again */
sie(&vm);
- report(pv_icptdata_check_diag(&vm, 0x9c) &&
+ report(sie_is_diag_icpt(&vm, 0x9c) &&
vm.save_area.guest.grs[0] == 42,
"re-entry successful");
report_prefix_pop();
diff --git a/s390x/pv-ipl.c b/s390x/pv-ipl.c
index cc46e7f7..61a1e0c0 100644
--- a/s390x/pv-ipl.c
+++ b/s390x/pv-ipl.c
@@ -11,7 +11,7 @@
#include <sie.h>
#include <sclp.h>
#include <snippet.h>
-#include <pv_icptdata.h>
+#include <sie-icpt.h>
#include <asm/facility.h>
#include <asm/uv.h>
@@ -35,7 +35,7 @@ static void test_diag_308(int subcode)
/* First exit is a diag 0x500 */
sie(&vm);
- assert(pv_icptdata_check_diag(&vm, 0x500));
+ assert(sie_is_diag_icpt(&vm, 0x500));
/*
* The snippet asked us for the subcode and we answer by
@@ -46,7 +46,7 @@ static void test_diag_308(int subcode)
/* Continue after diag 0x500, next icpt should be the 0x308 */
sie(&vm);
- assert(pv_icptdata_check_diag(&vm, 0x308));
+ assert(sie_is_diag_icpt(&vm, 0x308));
assert(vm.save_area.guest.grs[2] == subcode);
/*
@@ -118,7 +118,7 @@ static void test_diag_308(int subcode)
* see a diagnose 0x9c PV instruction notification.
*/
sie(&vm);
- report(pv_icptdata_check_diag(&vm, 0x9c) &&
+ report(sie_is_diag_icpt(&vm, 0x9c) &&
vm.save_area.guest.grs[0] == 42,
"continue after load");
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 08/18] s390x: Add library functions for exiting from snippet
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (6 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 07/18] s390x: Add function for checking diagnose intercepts Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 09/18] s390x: Use library functions for snippet exit Nico Boehr
` (10 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones
Cc: kvm, frankja, imbrenda, Nina Schoetterl-Glausch
From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
It is useful to be able to force an exit to the host from the snippet,
as well as do so while returning a value.
Add this functionality, also add helper functions for the host to check
for an exit and get or check the value.
Use diag 0x44 and 0x9c for this.
Add a guest specific snippet header file and rename snippet.h to reflect
that it is host specific.
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Link: https://lore.kernel.org/r/20241016180320.686132-5-nsg@linux.ibm.com
[ nrb: fix out-of-tree builds ]
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
s390x/Makefile | 7 +++--
lib/s390x/asm/arch_def.h | 16 +++++++++++
lib/s390x/snippet-exit.h | 45 +++++++++++++++++++++++++++++++
s390x/snippets/lib/snippet-exit.h | 28 +++++++++++++++++++
4 files changed, 94 insertions(+), 2 deletions(-)
create mode 100644 lib/s390x/snippet-exit.h
create mode 100644 s390x/snippets/lib/snippet-exit.h
diff --git a/s390x/Makefile b/s390x/Makefile
index 907b3a04..9eeff198 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -71,7 +71,8 @@ test_cases: $(tests)
test_cases_binary: $(tests_binary)
test_cases_pv: $(tests_pv_binary)
-INCLUDE_PATHS = $(SRCDIR)/lib $(SRCDIR)/lib/s390x $(SRCDIR)/s390x
+SNIPPET_INCLUDE :=
+INCLUDE_PATHS = $(SNIPPET_INCLUDE) $(SRCDIR)/lib $(SRCDIR)/lib/s390x $(SRCDIR)/s390x
# Include generated header files (e.g. in case of out-of-source builds)
INCLUDE_PATHS += lib
CPPFLAGS = $(addprefix -I,$(INCLUDE_PATHS))
@@ -122,6 +123,7 @@ asmlib = $(TEST_DIR)/cstart64.o $(TEST_DIR)/cpu.o
FLATLIBS = $(libcflat)
SNIPPET_DIR = $(TEST_DIR)/snippets
+SNIPPET_SRC_DIR = $(SRCDIR)/s390x/snippets
snippet_asmlib = $(SNIPPET_DIR)/c/cstart.o
snippet_lib = $(snippet_asmlib) lib/auxinfo.o
@@ -149,9 +151,10 @@ snippet-hdr-obj =
endif
# the asm/c snippets %.o have additional generated files as dependencies
-$(SNIPPET_DIR)/asm/%.o: $(SNIPPET_DIR)/asm/%.S $(asm-offsets)
+$(SNIPPET_DIR)/asm/%.o: $(SNIPPET_SRC_DIR)/asm/%.S $(asm-offsets)
$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
+$(SNIPPET_DIR)/c/%.o: SNIPPET_INCLUDE := $(SNIPPET_SRC_DIR)/lib
$(SNIPPET_DIR)/c/%.o: $(SNIPPET_DIR)/c/%.c $(asm-offsets)
$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
index 5574a451..03adcd3c 100644
--- a/lib/s390x/asm/arch_def.h
+++ b/lib/s390x/asm/arch_def.h
@@ -505,4 +505,20 @@ static inline uint32_t get_prefix(void)
return current_prefix;
}
+static inline void diag44(void)
+{
+ asm volatile("diag 0,0,0x44\n");
+}
+
+static inline void diag500(uint64_t val)
+{
+ asm volatile(
+ "lgr 2,%[val]\n"
+ "diag 0,0,0x500\n"
+ :
+ : [val] "d"(val)
+ : "r2"
+ );
+}
+
#endif
diff --git a/lib/s390x/snippet-exit.h b/lib/s390x/snippet-exit.h
new file mode 100644
index 00000000..3ed4c22c
--- /dev/null
+++ b/lib/s390x/snippet-exit.h
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Functionality handling snippet exits
+ *
+ * Copyright IBM Corp. 2024
+ */
+
+#ifndef _S390X_SNIPPET_EXIT_H_
+#define _S390X_SNIPPET_EXIT_H_
+
+#include <libcflat.h>
+#include <sie.h>
+#include <sie-icpt.h>
+
+static inline bool snippet_is_force_exit(struct vm *vm)
+{
+ return sie_is_diag_icpt(vm, 0x44);
+}
+
+static inline bool snippet_is_force_exit_value(struct vm *vm)
+{
+ return sie_is_diag_icpt(vm, 0x500);
+}
+
+static inline uint64_t snippet_get_force_exit_value(struct vm *vm)
+{
+ assert(snippet_is_force_exit_value(vm));
+
+ return vm->save_area.guest.grs[2];
+}
+
+static inline void snippet_check_force_exit_value(struct vm *vm, uint64_t value_exp)
+{
+ uint64_t value;
+
+ if (snippet_is_force_exit_value(vm)) {
+ value = snippet_get_force_exit_value(vm);
+ report(value == value_exp, "guest forced exit with value (0x%lx == 0x%lx)",
+ value, value_exp);
+ } else {
+ report_fail("guest forced exit with value");
+ }
+}
+
+#endif /* _S390X_SNIPPET_EXIT_H_ */
diff --git a/s390x/snippets/lib/snippet-exit.h b/s390x/snippets/lib/snippet-exit.h
new file mode 100644
index 00000000..ac00de3f
--- /dev/null
+++ b/s390x/snippets/lib/snippet-exit.h
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Functionality for exiting the snippet.
+ *
+ * Copyright IBM Corp. 2023
+ */
+
+#ifndef _S390X_SNIPPET_LIB_EXIT_H_
+#define _S390X_SNIPPET_LIB_EXIT_H_
+
+#include <asm/arch_def.h>
+#include <asm/barrier.h>
+
+static inline void force_exit(void)
+{
+ mb(); /* host may read any memory written by the guest before */
+ diag44();
+ mb(); /* allow host to modify guest memory */
+}
+
+static inline void force_exit_value(uint64_t val)
+{
+ mb(); /* host may read any memory written by the guest before */
+ diag500(val);
+ mb(); /* allow host to modify guest memory */
+}
+
+#endif /* _S390X_SNIPPET_LIB_EXIT_H_ */
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 09/18] s390x: Use library functions for snippet exit
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (7 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 08/18] s390x: Add library functions for exiting from snippet Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 10/18] s390x: Add test for STFLE interpretive execution (format-0) Nico Boehr
` (9 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones
Cc: kvm, frankja, imbrenda, Nina Schoetterl-Glausch, Nicholas Piggin
From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Replace the existing code for exiting from snippets with the newly
introduced library functionality.
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/r/20241016180320.686132-6-nsg@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
s390x/sie-dat.c | 12 ++++--------
s390x/snippets/c/sie-dat.c | 19 +------------------
2 files changed, 5 insertions(+), 26 deletions(-)
diff --git a/s390x/sie-dat.c b/s390x/sie-dat.c
index f0257770..44bf29fe 100644
--- a/s390x/sie-dat.c
+++ b/s390x/sie-dat.c
@@ -17,6 +17,7 @@
#include <sclp.h>
#include <sie.h>
#include <snippet.h>
+#include <snippet-exit.h>
#include "snippets/c/sie-dat.h"
static struct vm vm;
@@ -27,23 +28,18 @@ static void test_sie_dat(void)
uint64_t test_page_gpa, test_page_hpa;
uint8_t *test_page_hva, expected_val;
bool contents_match;
- uint8_t r1;
/* guest will tell us the guest physical address of the test buffer */
sie(&vm);
- assert(vm.sblk->icptcode == ICPT_INST &&
- (vm.sblk->ipa & 0xff00) == 0x8300 && vm.sblk->ipb == 0x9c0000);
-
- r1 = (vm.sblk->ipa & 0xf0) >> 4;
- test_page_gpa = vm.save_area.guest.grs[r1];
+ assert(snippet_is_force_exit_value(&vm));
+ test_page_gpa = snippet_get_force_exit_value(&vm);
test_page_hpa = virt_to_pte_phys(guest_root, (void*)test_page_gpa);
test_page_hva = __va(test_page_hpa);
report_info("test buffer gpa=0x%lx hva=%p", test_page_gpa, test_page_hva);
/* guest will now write to the test buffer and we verify the contents */
sie(&vm);
- assert(vm.sblk->icptcode == ICPT_INST &&
- vm.sblk->ipa == 0x8300 && vm.sblk->ipb == 0x440000);
+ assert(snippet_is_force_exit(&vm));
contents_match = true;
for (unsigned int i = 0; i < GUEST_TEST_PAGE_COUNT; i++) {
diff --git a/s390x/snippets/c/sie-dat.c b/s390x/snippets/c/sie-dat.c
index 9d89801d..ba1604de 100644
--- a/s390x/snippets/c/sie-dat.c
+++ b/s390x/snippets/c/sie-dat.c
@@ -10,28 +10,11 @@
#include <libcflat.h>
#include <asm-generic/page.h>
#include <asm/mem.h>
+#include <snippet-exit.h>
#include "sie-dat.h"
static uint8_t test_pages[GUEST_TEST_PAGE_COUNT * PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));
-static inline void force_exit(void)
-{
- asm volatile("diag 0,0,0x44\n"
- :
- :
- : "memory"
- );
-}
-
-static inline void force_exit_value(uint64_t val)
-{
- asm volatile("diag %[val],0,0x9c\n"
- :
- : [val] "d"(val)
- : "memory"
- );
-}
-
int main(void)
{
uint8_t *invalid_ptr;
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 10/18] s390x: Add test for STFLE interpretive execution (format-0)
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (8 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 09/18] s390x: Use library functions for snippet exit Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 11/18] s390x/Makefile: snippets: Add separate target for the ELF snippets Nico Boehr
` (8 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones
Cc: kvm, frankja, imbrenda, Nina Schoetterl-Glausch
From: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
The STFLE instruction indicates installed facilities.
SIE can interpretively execute STFLE.
Use a snippet guest executing STFLE to get the result of
interpretive execution and check the result.
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Link: https://lore.kernel.org/r/20241016180320.686132-7-nsg@linux.ibm.com
[ nrb: fixup minor checkpatch issues ]
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
s390x/Makefile | 2 +
lib/s390x/asm/facility.h | 10 ++-
s390x/snippets/c/stfle.c | 29 ++++++++
s390x/stfle-sie.c | 138 +++++++++++++++++++++++++++++++++++++++
s390x/unittests.cfg | 3 +
5 files changed, 181 insertions(+), 1 deletion(-)
create mode 100644 s390x/snippets/c/stfle.c
create mode 100644 s390x/stfle-sie.c
diff --git a/s390x/Makefile b/s390x/Makefile
index 9eeff198..4424877e 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -45,6 +45,7 @@ tests += $(TEST_DIR)/ex.elf
tests += $(TEST_DIR)/topology.elf
tests += $(TEST_DIR)/sie-dat.elf
tests += $(TEST_DIR)/diag258.elf
+tests += $(TEST_DIR)/stfle-sie.elf
pv-tests += $(TEST_DIR)/pv-diags.elf
pv-tests += $(TEST_DIR)/pv-icptcode.elf
@@ -132,6 +133,7 @@ snippet_lib = $(snippet_asmlib) lib/auxinfo.o
$(TEST_DIR)/mvpg-sie.elf: snippets = $(SNIPPET_DIR)/c/mvpg-snippet.gbin
$(TEST_DIR)/sie-dat.elf: snippets = $(SNIPPET_DIR)/c/sie-dat.gbin
$(TEST_DIR)/spec_ex-sie.elf: snippets = $(SNIPPET_DIR)/c/spec_ex.gbin
+$(TEST_DIR)/stfle-sie.elf: snippets = $(SNIPPET_DIR)/c/stfle.gbin
$(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-yield.gbin
$(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-288.gbin
diff --git a/lib/s390x/asm/facility.h b/lib/s390x/asm/facility.h
index a66fe56a..2bad05c5 100644
--- a/lib/s390x/asm/facility.h
+++ b/lib/s390x/asm/facility.h
@@ -27,12 +27,20 @@ static inline void stfl(void)
asm volatile(" stfl 0(0)\n" : : : "memory");
}
-static inline void stfle(uint64_t *fac, unsigned int nb_doublewords)
+static inline unsigned int stfle(uint64_t *fac, unsigned int nb_doublewords)
{
register unsigned long r0 asm("0") = nb_doublewords - 1;
asm volatile(" .insn s,0xb2b00000,0(%1)\n"
: "+d" (r0) : "a" (fac) : "memory", "cc");
+ return r0 + 1;
+}
+
+static inline unsigned long stfle_size(void)
+{
+ uint64_t dummy;
+
+ return stfle(&dummy, 1);
}
static inline void setup_facilities(void)
diff --git a/s390x/snippets/c/stfle.c b/s390x/snippets/c/stfle.c
new file mode 100644
index 00000000..5fb6f948
--- /dev/null
+++ b/s390x/snippets/c/stfle.c
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright IBM Corp. 2023
+ *
+ * Snippet used by the STLFE interpretive execution facilities test.
+ */
+#include <libcflat.h>
+#include <snippet-exit.h>
+
+int main(void)
+{
+ const unsigned int max_fac_len = 8;
+ uint64_t len_arg = max_fac_len - 1;
+ uint64_t res[max_fac_len + 1];
+ uint64_t fac[max_fac_len];
+
+ asm volatile (" lgr 0,%[len]\n"
+ " stfle %[fac]\n"
+ " lgr %[len],0\n"
+ : [fac] "=Q"(fac),
+ [len] "+d"(len_arg)
+ :
+ : "%r0", "cc"
+ );
+ res[0] = len_arg;
+ memcpy(&res[1], fac, sizeof(fac));
+ force_exit_value((uint64_t)&res);
+ return 0;
+}
diff --git a/s390x/stfle-sie.c b/s390x/stfle-sie.c
new file mode 100644
index 00000000..21cf8ff8
--- /dev/null
+++ b/s390x/stfle-sie.c
@@ -0,0 +1,138 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright IBM Corp. 2023
+ *
+ * SIE with STLFE interpretive execution facilities test.
+ */
+#include <libcflat.h>
+#include <stdlib.h>
+#include <asm/facility.h>
+#include <asm/time.h>
+#include <snippet.h>
+#include <snippet-exit.h>
+#include <alloc_page.h>
+#include <sclp.h>
+#include <rand.h>
+
+static struct vm vm;
+static uint64_t (*fac)[PAGE_SIZE / sizeof(uint64_t)];
+static prng_state prng_s;
+
+static void setup_guest(void)
+{
+ extern const char SNIPPET_NAME_START(c, stfle)[];
+ extern const char SNIPPET_NAME_END(c, stfle)[];
+
+ setup_vm();
+ fac = alloc_pages_flags(0, AREA_DMA31);
+
+ snippet_setup_guest(&vm, false);
+ snippet_init(&vm, SNIPPET_NAME_START(c, stfle),
+ SNIPPET_LEN(c, stfle), SNIPPET_UNPACK_OFF);
+}
+
+struct guest_stfle_res {
+ uint16_t len;
+ unsigned char *mem;
+};
+
+static struct guest_stfle_res run_guest(void)
+{
+ struct guest_stfle_res res;
+ uint64_t guest_stfle_addr;
+ uint64_t reg;
+
+ sie(&vm);
+ assert(snippet_is_force_exit_value(&vm));
+ guest_stfle_addr = snippet_get_force_exit_value(&vm);
+ res.mem = &vm.guest_mem[guest_stfle_addr];
+ memcpy(®, res.mem, sizeof(reg));
+ res.len = (reg & 0xff) + 1;
+ res.mem += sizeof(reg);
+ return res;
+}
+
+static void test_stfle_format_0(void)
+{
+ struct guest_stfle_res res;
+
+ report_prefix_push("format-0");
+ for (int j = 0; j < stfle_size(); j++)
+ WRITE_ONCE((*fac)[j], prng64(&prng_s));
+ vm.sblk->fac = (uint32_t)(uint64_t)fac;
+ res = run_guest();
+ report(res.len == stfle_size(), "stfle len correct");
+ report(!memcmp(*fac, res.mem, res.len * sizeof(uint64_t)),
+ "Guest facility list as specified");
+ report_prefix_pop();
+}
+
+struct args {
+ uint64_t seed;
+};
+
+static bool parse_uint64_t(const char *arg, uint64_t *out)
+{
+ char *end;
+ uint64_t num;
+
+ if (arg[0] == '\0')
+ return false;
+ num = strtoul(arg, &end, 0);
+ if (end[0] != '\0')
+ return false;
+ *out = num;
+ return true;
+}
+
+static struct args parse_args(int argc, char **argv)
+{
+ struct args args;
+ const char *flag;
+ unsigned int i;
+ uint64_t arg;
+ bool has_arg;
+
+ stck(&args.seed);
+
+ for (i = 1; i < argc; i++) {
+ if (i + 1 < argc)
+ has_arg = parse_uint64_t(argv[i + 1], &arg);
+ else
+ has_arg = false;
+
+ flag = "--seed";
+ if (!strcmp(flag, argv[i])) {
+ if (!has_arg)
+ report_abort("%s needs an uint64_t parameter", flag);
+ args.seed = arg;
+ ++i;
+ continue;
+ }
+ report_abort("Unsupported parameter '%s'",
+ argv[i]);
+ }
+
+ return args;
+}
+
+int main(int argc, char **argv)
+{
+ struct args args = parse_args(argc, argv);
+ bool run_format_0 = test_facility(7);
+
+ if (!sclp_facilities.has_sief2) {
+ report_skip("SIEF2 facility unavailable");
+ goto out;
+ }
+ if (!run_format_0)
+ report_skip("STFLE facility not available");
+
+ report_info("PRNG seed: 0x%lx", args.seed);
+ prng_s = prng_init(args.seed);
+ setup_guest();
+ if (run_format_0)
+ test_stfle_format_0();
+out:
+ return report_summary();
+}
diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg
index 8131ba10..a9af6680 100644
--- a/s390x/unittests.cfg
+++ b/s390x/unittests.cfg
@@ -395,3 +395,6 @@ file = pv-attest.elf
[diag258]
file = diag258.elf
+
+[stfle-sie]
+file = stfle-sie.elf
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 11/18] s390x/Makefile: snippets: Add separate target for the ELF snippets
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (9 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 10/18] s390x: Add test for STFLE interpretive execution (format-0) Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 12/18] s390x/Makefile: Split snippet makefile rules into new file Nico Boehr
` (7 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones
Cc: kvm, frankja, imbrenda, Marc Hartmayer, Nicholas Piggin
From: Marc Hartmayer <mhartmay@linux.ibm.com>
It's unusual to create multiple files in one target rule, and it's even more
unusual to create an ELF file with a `.gbin` file extension first, and then
overwrite it in the next step. It might even lead to errors as the input file
path is also used as the output file path - but this depends on the objcopy
implementation. Therefore, create an extra target for the ELF files and list it
as a prerequisite for the *.gbin targets.
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/r/20240604115932.86596-2-mhartmay@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
s390x/Makefile | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/s390x/Makefile b/s390x/Makefile
index 4424877e..b3b2ae8c 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -160,14 +160,18 @@ $(SNIPPET_DIR)/c/%.o: SNIPPET_INCLUDE := $(SNIPPET_SRC_DIR)/lib
$(SNIPPET_DIR)/c/%.o: $(SNIPPET_DIR)/c/%.c $(asm-offsets)
$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
-$(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.o $(SNIPPET_DIR)/asm/flat.lds
+$(SNIPPET_DIR)/asm/%.elf: $(SNIPPET_DIR)/asm/%.o $(SNIPPET_DIR)/asm/flat.lds
$(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/asm/flat.lds $<
- $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $@ $@
+
+$(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.elf
+ $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $< $@
truncate -s '%4096' $@
-$(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) $(SNIPPET_DIR)/c/flat.lds
+$(SNIPPET_DIR)/c/%.elf: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) $(SNIPPET_DIR)/c/flat.lds
$(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/c/flat.lds $< $(snippet_lib) $(FLATLIBS)
- $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $@ $@
+
+$(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.elf
+ $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $< $@
truncate -s '%4096' $@
%.hdr: %.gbin $(HOST_KEY_DOCUMENT)
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 12/18] s390x/Makefile: Split snippet makefile rules into new file
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (10 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 11/18] s390x/Makefile: snippets: Add separate target for the ELF snippets Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 13/18] s390x/Makefile: Add more comments Nico Boehr
` (6 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones
Cc: kvm, frankja, imbrenda, Christoph Schlameuss
From: Janosch Frank <frankja@linux.ibm.com>
It's time to move the snippet related Makefile parts into a new file
to make s390x/Makefile less busy.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
Link: https://lore.kernel.org/r/20240806084409.169039-2-frankja@linux.ibm.com
[ nrb: fix out-of-tree build ]
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
s390x/Makefile | 39 ++++-----------------------------------
s390x/snippets/Makefile | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 35 deletions(-)
create mode 100644 s390x/snippets/Makefile
diff --git a/s390x/Makefile b/s390x/Makefile
index b3b2ae8c..e41a6433 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -123,10 +123,12 @@ asmlib = $(TEST_DIR)/cstart64.o $(TEST_DIR)/cpu.o
FLATLIBS = $(libcflat)
+# Snippets
SNIPPET_DIR = $(TEST_DIR)/snippets
SNIPPET_SRC_DIR = $(SRCDIR)/s390x/snippets
snippet_asmlib = $(SNIPPET_DIR)/c/cstart.o
snippet_lib = $(snippet_asmlib) lib/auxinfo.o
+include $(SNIPPET_SRC_DIR)/Makefile
# perquisites (=guests) for the snippet hosts.
# $(TEST_DIR)/<snippet-host>.elf: snippets = $(SNIPPET_DIR)/<c/asm>/<snippet>.gbin
@@ -152,39 +154,6 @@ else
snippet-hdr-obj =
endif
-# the asm/c snippets %.o have additional generated files as dependencies
-$(SNIPPET_DIR)/asm/%.o: $(SNIPPET_SRC_DIR)/asm/%.S $(asm-offsets)
- $(CC) $(CFLAGS) -c -nostdlib -o $@ $<
-
-$(SNIPPET_DIR)/c/%.o: SNIPPET_INCLUDE := $(SNIPPET_SRC_DIR)/lib
-$(SNIPPET_DIR)/c/%.o: $(SNIPPET_DIR)/c/%.c $(asm-offsets)
- $(CC) $(CFLAGS) -c -nostdlib -o $@ $<
-
-$(SNIPPET_DIR)/asm/%.elf: $(SNIPPET_DIR)/asm/%.o $(SNIPPET_DIR)/asm/flat.lds
- $(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/asm/flat.lds $<
-
-$(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.elf
- $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $< $@
- truncate -s '%4096' $@
-
-$(SNIPPET_DIR)/c/%.elf: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) $(SNIPPET_DIR)/c/flat.lds
- $(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/c/flat.lds $< $(snippet_lib) $(FLATLIBS)
-
-$(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.elf
- $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $< $@
- truncate -s '%4096' $@
-
-%.hdr: %.gbin $(HOST_KEY_DOCUMENT)
- $(GEN_SE_HEADER) -k $(HOST_KEY_DOCUMENT) -c $<,0x0,0x00000000000000420000000000000000 --psw-addr 0x4000 -o $@
-
-.SECONDARY:
-%.gobj: %.gbin
- $(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $< $@
-
-.SECONDARY:
-%.hdr.obj: %.hdr
- $(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $< $@
-
lds-autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d -MT $@
%.lds: %.lds.S $(asm-offsets)
$(CPP) $(lds-autodepend-flags) $(CPPFLAGS) -P -C -o $@ $<
@@ -238,8 +207,8 @@ $(snippet_asmlib): $$(patsubst %.o,%.S,$$@) $(asm-offsets)
$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
-arch_clean: asm_offsets_clean
- $(RM) $(TEST_DIR)/*.{o,elf,bin,lds} $(SNIPPET_DIR)/*/*.{o,elf,*bin,*obj,hdr,lds} $(SNIPPET_DIR)/asm/.*.d $(TEST_DIR)/.*.d lib/s390x/.*.d $(comm-key)
+arch_clean: asm_offsets_clean snippet_clean
+ $(RM) $(TEST_DIR)/*.{o,elf,bin,lds} $(TEST_DIR)/.*.d lib/s390x/.*.d $(comm-key)
generated-files = $(asm-offsets)
$(tests:.elf=.o) $(asmlib) $(cflatobjs): $(generated-files)
diff --git a/s390x/snippets/Makefile b/s390x/snippets/Makefile
new file mode 100644
index 00000000..ccadd733
--- /dev/null
+++ b/s390x/snippets/Makefile
@@ -0,0 +1,35 @@
+# the asm/c snippets %.o have additional generated files as dependencies
+$(SNIPPET_DIR)/asm/%.o: $(SNIPPET_SRC_DIR)/asm/%.S $(asm-offsets)
+ $(CC) $(CFLAGS) -c -nostdlib -o $@ $<
+
+$(SNIPPET_DIR)/c/%.o: SNIPPET_INCLUDE := $(SNIPPET_SRC_DIR)/lib
+$(SNIPPET_DIR)/c/%.o: $(SNIPPET_SRC_DIR)/c/%.c $(asm-offsets)
+ $(CC) $(CFLAGS) -c -nostdlib -o $@ $<
+
+$(SNIPPET_DIR)/asm/%.elf: $(SNIPPET_DIR)/asm/%.o $(SNIPPET_DIR)/asm/flat.lds
+ $(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_SRC_DIR)/asm/flat.lds $<
+
+$(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.elf
+ $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $< $@
+ truncate -s '%4096' $@
+
+$(SNIPPET_DIR)/c/%.elf: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) $(SNIPPET_DIR)/c/flat.lds
+ $(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/c/flat.lds $< $(snippet_lib) $(FLATLIBS)
+
+$(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.elf
+ $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $< $@
+ truncate -s '%4096' $@
+
+%.hdr: %.gbin $(HOST_KEY_DOCUMENT)
+ $(GEN_SE_HEADER) -k $(HOST_KEY_DOCUMENT) -c $<,0x0,0x00000000000000420000000000000000 --psw-addr 0x4000 -o $@
+
+.SECONDARY:
+%.gobj: %.gbin
+ $(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $< $@
+
+.SECONDARY:
+%.hdr.obj: %.hdr
+ $(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $< $@
+
+snippet_clean:
+ $(RM) $(SNIPPET_DIR)/*/*.{o,elf,*bin,*obj,hdr,lds} $(SNIPPET_DIR)/asm/.*.d
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 13/18] s390x/Makefile: Add more comments
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (11 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 12/18] s390x/Makefile: Split snippet makefile rules into new file Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 14/18] s390x: Move SIE assembly into new file Nico Boehr
` (5 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones
Cc: kvm, frankja, imbrenda, Christoph Schlameuss
From: Janosch Frank <frankja@linux.ibm.com>
More comments in Makefiles can only make them more approachable.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Link: https://lore.kernel.org/r/20240806084409.169039-3-frankja@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
s390x/Makefile | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/s390x/Makefile b/s390x/Makefile
index e41a6433..63e96d86 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -51,12 +51,15 @@ pv-tests += $(TEST_DIR)/pv-diags.elf
pv-tests += $(TEST_DIR)/pv-icptcode.elf
pv-tests += $(TEST_DIR)/pv-ipl.elf
+# Add PV host tests if we're able to generate them
+# The host key document and a tool to generate SE headers are the prerequisite
ifneq ($(HOST_KEY_DOCUMENT),)
ifneq ($(GEN_SE_HEADER),)
tests += $(pv-tests)
endif
endif
+# Add binary flat images for use in non-KVM hypervisors
tests_binary = $(patsubst %.elf,%.bin,$(tests))
ifneq ($(HOST_KEY_DOCUMENT),)
tests_pv_binary = $(patsubst %.bin,%.pv.bin,$(tests_binary))
@@ -146,6 +149,7 @@ $(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/loop.gbin
$(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-icpt-vir-timing.gbin
$(TEST_DIR)/pv-ipl.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-308.gbin
+# Add PV tests and snippets if GEN_SE_HEADER is set
ifneq ($(GEN_SE_HEADER),)
snippets += $(pv-snippets)
tests += $(pv-tests)
@@ -154,6 +158,7 @@ else
snippet-hdr-obj =
endif
+# Generate loader script
lds-autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d -MT $@
%.lds: %.lds.S $(asm-offsets)
$(CPP) $(lds-autodepend-flags) $(CPPFLAGS) -P -C -o $@ $<
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 14/18] s390x: Move SIE assembly into new file
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (12 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 13/18] s390x/Makefile: Add more comments Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 15/18] lib: s390x: Split SIE fw structs from lib structs Nico Boehr
` (4 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones
Cc: kvm, frankja, imbrenda, Christoph Schlameuss
From: Janosch Frank <frankja@linux.ibm.com>
In contrast to the other functions in cpu.S it's quite lengthy so
let's split it off.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
Link: https://lore.kernel.org/r/20240806084409.169039-4-frankja@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
s390x/Makefile | 2 +-
s390x/cpu-sie.S | 74 +++++++++++++++++++++++++++++++++++++++++++++++++
s390x/cpu.S | 64 ------------------------------------------
3 files changed, 75 insertions(+), 65 deletions(-)
create mode 100644 s390x/cpu-sie.S
diff --git a/s390x/Makefile b/s390x/Makefile
index 63e96d86..e5572cb6 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -122,7 +122,7 @@ cflatobjs += lib/s390x/fault.o
OBJDIRS += lib/s390x
-asmlib = $(TEST_DIR)/cstart64.o $(TEST_DIR)/cpu.o
+asmlib = $(TEST_DIR)/cstart64.o $(TEST_DIR)/cpu.o $(TEST_DIR)/cpu-sie.o
FLATLIBS = $(libcflat)
diff --git a/s390x/cpu-sie.S b/s390x/cpu-sie.S
new file mode 100644
index 00000000..9370b5c0
--- /dev/null
+++ b/s390x/cpu-sie.S
@@ -0,0 +1,74 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * s390x SIE assembly library
+ *
+ * Copyright (c) 2019 IBM Corp.
+ *
+ * Authors:
+ * Janosch Frank <frankja@linux.ibm.com>
+ */
+#include <asm/asm-offsets.h>
+
+/*
+ * sie64a calling convention:
+ * %r2 pointer to sie control block
+ * %r3 guest register save area
+ */
+.globl sie64a
+sie64a:
+ # Save host grs, fprs, fpc
+ stmg %r0,%r14,SIE_SAVEAREA_HOST_GRS(%r3) # save kernel registers
+ .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+ std \i, \i * 8 + SIE_SAVEAREA_HOST_FPRS(%r3)
+ .endr
+ stfpc SIE_SAVEAREA_HOST_FPC(%r3)
+
+ stctg %c1, %c1, SIE_SAVEAREA_HOST_ASCE(%r3)
+ lctlg %c1, %c1, SIE_SAVEAREA_GUEST_ASCE(%r3)
+
+ # Store scb and save_area pointer into stack frame
+ stg %r2,__SF_SIE_CONTROL(%r15) # save control block pointer
+ stg %r3,__SF_SIE_SAVEAREA(%r15) # save guest register save area
+.globl sie_entry_gregs
+sie_entry_gregs:
+ # Load guest's gprs, fprs and fpc
+ .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+ ld \i, \i * 8 + SIE_SAVEAREA_GUEST_FPRS(%r3)
+ .endr
+ lfpc SIE_SAVEAREA_GUEST_FPC(%r3)
+ lmg %r0,%r13,SIE_SAVEAREA_GUEST_GRS(%r3)
+
+ # Move scb ptr into r14 for the sie instruction
+ lg %r14,__SF_SIE_CONTROL(%r15)
+
+.globl sie_entry
+sie_entry:
+ sie 0(%r14)
+ nopr 7
+ nopr 7
+ nopr 7
+
+.globl sie_exit
+sie_exit:
+ # Load guest register save area
+ lg %r14,__SF_SIE_SAVEAREA(%r15)
+
+ # Restore the host asce
+ lctlg %c1, %c1, SIE_SAVEAREA_HOST_ASCE(%r14)
+
+ # Store guest's gprs, fprs and fpc
+ stmg %r0,%r13,SIE_SAVEAREA_GUEST_GRS(%r14) # save guest gprs 0-13
+ .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+ std \i, \i * 8 + SIE_SAVEAREA_GUEST_FPRS(%r14)
+ .endr
+ stfpc SIE_SAVEAREA_GUEST_FPC(%r14)
+
+ # Restore host's gprs, fprs and fpc
+ .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+ ld \i, \i * 8 + SIE_SAVEAREA_HOST_FPRS(%r14)
+ .endr
+ lfpc SIE_SAVEAREA_HOST_FPC(%r14)
+ lmg %r0,%r14,SIE_SAVEAREA_HOST_GRS(%r14) # restore kernel registers
+.globl sie_exit_gregs
+sie_exit_gregs:
+ br %r14
diff --git a/s390x/cpu.S b/s390x/cpu.S
index 9155b044..2ff4b8e1 100644
--- a/s390x/cpu.S
+++ b/s390x/cpu.S
@@ -62,70 +62,6 @@ smp_cpu_setup_state:
/* If the function returns, just loop here */
0: j 0
-/*
- * sie64a calling convention:
- * %r2 pointer to sie control block
- * %r3 guest register save area
- */
-.globl sie64a
-sie64a:
- # Save host grs, fprs, fpc
- stmg %r0,%r14,SIE_SAVEAREA_HOST_GRS(%r3) # save kernel registers
- .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
- std \i, \i * 8 + SIE_SAVEAREA_HOST_FPRS(%r3)
- .endr
- stfpc SIE_SAVEAREA_HOST_FPC(%r3)
-
- stctg %c1, %c1, SIE_SAVEAREA_HOST_ASCE(%r3)
- lctlg %c1, %c1, SIE_SAVEAREA_GUEST_ASCE(%r3)
-
- # Store scb and save_area pointer into stack frame
- stg %r2,__SF_SIE_CONTROL(%r15) # save control block pointer
- stg %r3,__SF_SIE_SAVEAREA(%r15) # save guest register save area
-.globl sie_entry_gregs
-sie_entry_gregs:
- # Load guest's gprs, fprs and fpc
- .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
- ld \i, \i * 8 + SIE_SAVEAREA_GUEST_FPRS(%r3)
- .endr
- lfpc SIE_SAVEAREA_GUEST_FPC(%r3)
- lmg %r0,%r13,SIE_SAVEAREA_GUEST_GRS(%r3)
-
- # Move scb ptr into r14 for the sie instruction
- lg %r14,__SF_SIE_CONTROL(%r15)
-
-.globl sie_entry
-sie_entry:
- sie 0(%r14)
- nopr 7
- nopr 7
- nopr 7
-
-.globl sie_exit
-sie_exit:
- # Load guest register save area
- lg %r14,__SF_SIE_SAVEAREA(%r15)
-
- # Restore the host asce
- lctlg %c1, %c1, SIE_SAVEAREA_HOST_ASCE(%r14)
-
- # Store guest's gprs, fprs and fpc
- stmg %r0,%r13,SIE_SAVEAREA_GUEST_GRS(%r14) # save guest gprs 0-13
- .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
- std \i, \i * 8 + SIE_SAVEAREA_GUEST_FPRS(%r14)
- .endr
- stfpc SIE_SAVEAREA_GUEST_FPC(%r14)
-
- # Restore host's gprs, fprs and fpc
- .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
- ld \i, \i * 8 + SIE_SAVEAREA_HOST_FPRS(%r14)
- .endr
- lfpc SIE_SAVEAREA_HOST_FPC(%r14)
- lmg %r0,%r14,SIE_SAVEAREA_HOST_GRS(%r14) # restore kernel registers
-.globl sie_exit_gregs
-sie_exit_gregs:
- br %r14
-
.align 8
reset_psw:
.quad 0x0008000180000000
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 15/18] lib: s390x: Split SIE fw structs from lib structs
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (13 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 14/18] s390x: Move SIE assembly into new file Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 16/18] s390x: Support newer version of genprotimg Nico Boehr
` (3 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones
Cc: kvm, frankja, imbrenda, Christoph Schlameuss
From: Janosch Frank <frankja@linux.ibm.com>
The SIE control block is huge and takes up too much space.
Let's split the hardware definitions from sie.h into its own header,
so that sie.h will only contain library functions and structs
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Link: https://lore.kernel.org/r/20240806084409.169039-5-frankja@linux.ibm.com
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
lib/s390x/asm/sie-arch.h | 238 +++++++++++++++++++++++++++++++++++++++
lib/s390x/sie.h | 231 +------------------------------------
2 files changed, 239 insertions(+), 230 deletions(-)
create mode 100644 lib/s390x/asm/sie-arch.h
diff --git a/lib/s390x/asm/sie-arch.h b/lib/s390x/asm/sie-arch.h
new file mode 100644
index 00000000..4911c988
--- /dev/null
+++ b/lib/s390x/asm/sie-arch.h
@@ -0,0 +1,238 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef _S390X_SIE_ARCH_H_
+#define _S390X_SIE_ARCH_H_
+
+#include <stdint.h>
+#include <asm/arch_def.h>
+
+#define CPUSTAT_STOPPED 0x80000000
+#define CPUSTAT_WAIT 0x10000000
+#define CPUSTAT_ECALL_PEND 0x08000000
+#define CPUSTAT_STOP_INT 0x04000000
+#define CPUSTAT_IO_INT 0x02000000
+#define CPUSTAT_EXT_INT 0x01000000
+#define CPUSTAT_RUNNING 0x00800000
+#define CPUSTAT_RETAINED 0x00400000
+#define CPUSTAT_TIMING_SUB 0x00020000
+#define CPUSTAT_SIE_SUB 0x00010000
+#define CPUSTAT_RRF 0x00008000
+#define CPUSTAT_SLSV 0x00004000
+#define CPUSTAT_SLSR 0x00002000
+#define CPUSTAT_ZARCH 0x00000800
+#define CPUSTAT_MCDS 0x00000100
+#define CPUSTAT_KSS 0x00000200
+#define CPUSTAT_SM 0x00000080
+#define CPUSTAT_IBS 0x00000040
+#define CPUSTAT_GED2 0x00000010
+#define CPUSTAT_G 0x00000008
+#define CPUSTAT_GED 0x00000004
+#define CPUSTAT_J 0x00000002
+#define CPUSTAT_P 0x00000001
+
+struct kvm_s390_sie_block {
+ uint32_t cpuflags; /* 0x0000 */
+ uint32_t : 1; /* 0x0004 */
+ uint32_t prefix : 18;
+ uint32_t : 1;
+ uint32_t ibc : 12;
+ uint8_t reserved08[4]; /* 0x0008 */
+#define PROG_IN_SIE (1<<0)
+ uint32_t prog0c; /* 0x000c */
+union {
+ uint8_t reserved10[16]; /* 0x0010 */
+ struct {
+ uint64_t pv_handle_cpu;
+ uint64_t pv_handle_config;
+ };
+ };
+#define PROG_BLOCK_SIE (1<<0)
+#define PROG_REQUEST (1<<1)
+ uint32_t prog20; /* 0x0020 */
+ uint8_t reserved24[4]; /* 0x0024 */
+ uint64_t cputm; /* 0x0028 */
+ uint64_t ckc; /* 0x0030 */
+ uint64_t epoch; /* 0x0038 */
+ uint32_t svcc; /* 0x0040 */
+#define LCTL_CR0 0x8000
+#define LCTL_CR6 0x0200
+#define LCTL_CR9 0x0040
+#define LCTL_CR10 0x0020
+#define LCTL_CR11 0x0010
+#define LCTL_CR14 0x0002
+ uint16_t lctl; /* 0x0044 */
+ int16_t icpua; /* 0x0046 */
+#define ICTL_OPEREXC 0x80000000
+#define ICTL_PINT 0x20000000
+#define ICTL_LPSW 0x00400000
+#define ICTL_STCTL 0x00040000
+#define ICTL_ISKE 0x00004000
+#define ICTL_SSKE 0x00002000
+#define ICTL_RRBE 0x00001000
+#define ICTL_TPROT 0x00000200
+ uint32_t ictl; /* 0x0048 */
+#define ECA_CEI 0x80000000
+#define ECA_IB 0x40000000
+#define ECA_SIGPI 0x10000000
+#define ECA_MVPGI 0x01000000
+#define ECA_AIV 0x00200000
+#define ECA_VX 0x00020000
+#define ECA_PROTEXCI 0x00002000
+#define ECA_APIE 0x00000008
+#define ECA_SII 0x00000001
+ uint32_t eca; /* 0x004c */
+#define ICPT_INST 0x04
+#define ICPT_PROGI 0x08
+#define ICPT_INSTPROGI 0x0C
+#define ICPT_EXTREQ 0x10
+#define ICPT_EXTINT 0x14
+#define ICPT_IOREQ 0x18
+#define ICPT_WAIT 0x1c
+#define ICPT_VALIDITY 0x20
+#define ICPT_STOP 0x28
+#define ICPT_OPEREXC 0x2C
+#define ICPT_PARTEXEC 0x38
+#define ICPT_IOINST 0x40
+#define ICPT_KSS 0x5c
+#define ICPT_INT_ENABLE 0x64
+#define ICPT_PV_INSTR 0x68
+#define ICPT_PV_NOTIFY 0x6c
+#define ICPT_PV_PREF 0x70
+ uint8_t icptcode; /* 0x0050 */
+ uint8_t icptstatus; /* 0x0051 */
+ uint16_t ihcpu; /* 0x0052 */
+ uint8_t reserved54; /* 0x0054 */
+#define IICTL_CODE_NONE 0x00
+#define IICTL_CODE_MCHK 0x01
+#define IICTL_CODE_EXT 0x02
+#define IICTL_CODE_IO 0x03
+#define IICTL_CODE_RESTART 0x04
+#define IICTL_CODE_SPECIFICATION 0x10
+#define IICTL_CODE_OPERAND 0x11
+ uint8_t iictl; /* 0x0055 */
+ uint16_t ipa; /* 0x0056 */
+ uint32_t ipb; /* 0x0058 */
+ uint32_t scaoh; /* 0x005c */
+#define FPF_BPBC 0x20
+ uint8_t fpf; /* 0x0060 */
+#define ECB_GS 0x40
+#define ECB_TE 0x10
+#define ECB_SPECI 0x08
+#define ECB_SRSI 0x04
+#define ECB_HOSTPROTINT 0x02
+ uint8_t ecb; /* 0x0061 */
+#define ECB2_CMMA 0x80
+#define ECB2_IEP 0x20
+#define ECB2_PFMFI 0x08
+#define ECB2_ESCA 0x04
+ uint8_t ecb2; /* 0x0062 */
+#define ECB3_DEA 0x08
+#define ECB3_AES 0x04
+#define ECB3_RI 0x01
+ uint8_t ecb3; /* 0x0063 */
+ uint32_t scaol; /* 0x0064 */
+ uint8_t sdf; /* 0x0068 */
+ uint8_t epdx; /* 0x0069 */
+ uint8_t reserved6a[2]; /* 0x006a */
+ uint32_t todpr; /* 0x006c */
+#define GISA_FORMAT1 0x00000001
+ uint32_t gd; /* 0x0070 */
+ uint8_t reserved74[12]; /* 0x0074 */
+ uint64_t mso; /* 0x0080 */
+ uint64_t msl; /* 0x0088 */
+ struct psw gpsw; /* 0x0090 */
+ uint64_t gg14; /* 0x00a0 */
+ uint64_t gg15; /* 0x00a8 */
+ uint8_t reservedb0[8]; /* 0x00b0 */
+#define HPID_KVM 0x4
+#define HPID_VSIE 0x5
+ uint8_t hpid; /* 0x00b8 */
+ uint8_t reservedb9[7]; /* 0x00b9 */
+ union {
+ struct {
+ uint32_t eiparams; /* 0x00c0 */
+ uint16_t extcpuaddr; /* 0x00c4 */
+ uint16_t eic; /* 0x00c6 */
+ };
+ uint64_t mcic; /* 0x00c0 */
+ } __attribute__ ((__packed__));
+ uint32_t reservedc8; /* 0x00c8 */
+ uint16_t pgmilc; /* 0x00cc */
+ uint16_t iprcc; /* 0x00ce */
+ uint32_t dxc; /* 0x00d0 */
+ uint16_t mcn; /* 0x00d4 */
+ uint8_t perc; /* 0x00d6 */
+ uint8_t peratmid; /* 0x00d7 */
+ uint64_t peraddr; /* 0x00d8 */
+ uint8_t eai; /* 0x00e0 */
+ uint8_t peraid; /* 0x00e1 */
+ uint8_t oai; /* 0x00e2 */
+ uint8_t armid; /* 0x00e3 */
+ uint8_t reservede4[4]; /* 0x00e4 */
+ uint64_t tecmc; /* 0x00e8 */
+ uint8_t reservedf0[12]; /* 0x00f0 */
+#define CRYCB_FORMAT_MASK 0x00000003
+#define CRYCB_FORMAT0 0x00000000
+#define CRYCB_FORMAT1 0x00000001
+#define CRYCB_FORMAT2 0x00000003
+ uint32_t crycbd; /* 0x00fc */
+ uint64_t gcr[16]; /* 0x0100 */
+ union {
+ uint64_t gbea; /* 0x0180 */
+ uint64_t sidad;
+ };
+ uint8_t reserved188[8]; /* 0x0188 */
+ uint64_t sdnxo; /* 0x0190 */
+ uint8_t reserved198[8]; /* 0x0198 */
+ uint32_t fac; /* 0x01a0 */
+ uint8_t reserved1a4[20]; /* 0x01a4 */
+ uint64_t cbrlo; /* 0x01b8 */
+ uint8_t reserved1c0[8]; /* 0x01c0 */
+#define ECD_HOSTREGMGMT 0x20000000
+#define ECD_MEF 0x08000000
+#define ECD_ETOKENF 0x02000000
+#define ECD_ECC 0x00200000
+ uint32_t ecd; /* 0x01c8 */
+ uint8_t reserved1cc[18]; /* 0x01cc */
+ uint64_t pp; /* 0x01de */
+ uint8_t reserved1e6[2]; /* 0x01e6 */
+ uint64_t itdba; /* 0x01e8 */
+ uint64_t riccbd; /* 0x01f0 */
+ uint64_t gvrd; /* 0x01f8 */
+ uint64_t reserved200[48]; /* 0x0200 */
+ uint64_t pv_grregs[16]; /* 0x0380 */
+} __attribute__((packed));
+
+union esca_sigp_ctrl {
+ uint16_t value;
+ struct {
+ uint8_t c : 1;
+ uint8_t reserved: 7;
+ uint8_t scn;
+ };
+};
+
+struct esca_entry {
+ union esca_sigp_ctrl sigp_ctrl;
+ uint16_t reserved1[3];
+ uint64_t sda;
+ uint64_t reserved2[6];
+};
+
+union ipte_control {
+ unsigned long val;
+ struct {
+ unsigned long k : 1;
+ unsigned long kh : 31;
+ unsigned long kg : 32;
+ };
+};
+
+struct esca_block {
+ union ipte_control ipte_control;
+ uint64_t reserved1[7];
+ uint64_t mcn[4];
+ uint64_t reserved2[20];
+ struct esca_entry cpu[256];
+};
+
+#endif /* _S390X_SIE_ARCH_H_ */
diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h
index 53cd767f..3ec49ed0 100644
--- a/lib/s390x/sie.h
+++ b/lib/s390x/sie.h
@@ -4,236 +4,7 @@
#include <stdint.h>
#include <asm/arch_def.h>
-
-#define CPUSTAT_STOPPED 0x80000000
-#define CPUSTAT_WAIT 0x10000000
-#define CPUSTAT_ECALL_PEND 0x08000000
-#define CPUSTAT_STOP_INT 0x04000000
-#define CPUSTAT_IO_INT 0x02000000
-#define CPUSTAT_EXT_INT 0x01000000
-#define CPUSTAT_RUNNING 0x00800000
-#define CPUSTAT_RETAINED 0x00400000
-#define CPUSTAT_TIMING_SUB 0x00020000
-#define CPUSTAT_SIE_SUB 0x00010000
-#define CPUSTAT_RRF 0x00008000
-#define CPUSTAT_SLSV 0x00004000
-#define CPUSTAT_SLSR 0x00002000
-#define CPUSTAT_ZARCH 0x00000800
-#define CPUSTAT_MCDS 0x00000100
-#define CPUSTAT_KSS 0x00000200
-#define CPUSTAT_SM 0x00000080
-#define CPUSTAT_IBS 0x00000040
-#define CPUSTAT_GED2 0x00000010
-#define CPUSTAT_G 0x00000008
-#define CPUSTAT_GED 0x00000004
-#define CPUSTAT_J 0x00000002
-#define CPUSTAT_P 0x00000001
-
-struct kvm_s390_sie_block {
- uint32_t cpuflags; /* 0x0000 */
- uint32_t : 1; /* 0x0004 */
- uint32_t prefix : 18;
- uint32_t : 1;
- uint32_t ibc : 12;
- uint8_t reserved08[4]; /* 0x0008 */
-#define PROG_IN_SIE (1<<0)
- uint32_t prog0c; /* 0x000c */
-union {
- uint8_t reserved10[16]; /* 0x0010 */
- struct {
- uint64_t pv_handle_cpu;
- uint64_t pv_handle_config;
- };
- };
-#define PROG_BLOCK_SIE (1<<0)
-#define PROG_REQUEST (1<<1)
- uint32_t prog20; /* 0x0020 */
- uint8_t reserved24[4]; /* 0x0024 */
- uint64_t cputm; /* 0x0028 */
- uint64_t ckc; /* 0x0030 */
- uint64_t epoch; /* 0x0038 */
- uint32_t svcc; /* 0x0040 */
-#define LCTL_CR0 0x8000
-#define LCTL_CR6 0x0200
-#define LCTL_CR9 0x0040
-#define LCTL_CR10 0x0020
-#define LCTL_CR11 0x0010
-#define LCTL_CR14 0x0002
- uint16_t lctl; /* 0x0044 */
- int16_t icpua; /* 0x0046 */
-#define ICTL_OPEREXC 0x80000000
-#define ICTL_PINT 0x20000000
-#define ICTL_LPSW 0x00400000
-#define ICTL_STCTL 0x00040000
-#define ICTL_ISKE 0x00004000
-#define ICTL_SSKE 0x00002000
-#define ICTL_RRBE 0x00001000
-#define ICTL_TPROT 0x00000200
- uint32_t ictl; /* 0x0048 */
-#define ECA_CEI 0x80000000
-#define ECA_IB 0x40000000
-#define ECA_SIGPI 0x10000000
-#define ECA_MVPGI 0x01000000
-#define ECA_AIV 0x00200000
-#define ECA_VX 0x00020000
-#define ECA_PROTEXCI 0x00002000
-#define ECA_APIE 0x00000008
-#define ECA_SII 0x00000001
- uint32_t eca; /* 0x004c */
-#define ICPT_INST 0x04
-#define ICPT_PROGI 0x08
-#define ICPT_INSTPROGI 0x0C
-#define ICPT_EXTREQ 0x10
-#define ICPT_EXTINT 0x14
-#define ICPT_IOREQ 0x18
-#define ICPT_WAIT 0x1c
-#define ICPT_VALIDITY 0x20
-#define ICPT_STOP 0x28
-#define ICPT_OPEREXC 0x2C
-#define ICPT_PARTEXEC 0x38
-#define ICPT_IOINST 0x40
-#define ICPT_KSS 0x5c
-#define ICPT_INT_ENABLE 0x64
-#define ICPT_PV_INSTR 0x68
-#define ICPT_PV_NOTIFY 0x6c
-#define ICPT_PV_PREF 0x70
- uint8_t icptcode; /* 0x0050 */
- uint8_t icptstatus; /* 0x0051 */
- uint16_t ihcpu; /* 0x0052 */
- uint8_t reserved54; /* 0x0054 */
-#define IICTL_CODE_NONE 0x00
-#define IICTL_CODE_MCHK 0x01
-#define IICTL_CODE_EXT 0x02
-#define IICTL_CODE_IO 0x03
-#define IICTL_CODE_RESTART 0x04
-#define IICTL_CODE_SPECIFICATION 0x10
-#define IICTL_CODE_OPERAND 0x11
- uint8_t iictl; /* 0x0055 */
- uint16_t ipa; /* 0x0056 */
- uint32_t ipb; /* 0x0058 */
- uint32_t scaoh; /* 0x005c */
-#define FPF_BPBC 0x20
- uint8_t fpf; /* 0x0060 */
-#define ECB_GS 0x40
-#define ECB_TE 0x10
-#define ECB_SPECI 0x08
-#define ECB_SRSI 0x04
-#define ECB_HOSTPROTINT 0x02
- uint8_t ecb; /* 0x0061 */
-#define ECB2_CMMA 0x80
-#define ECB2_IEP 0x20
-#define ECB2_PFMFI 0x08
-#define ECB2_ESCA 0x04
- uint8_t ecb2; /* 0x0062 */
-#define ECB3_DEA 0x08
-#define ECB3_AES 0x04
-#define ECB3_RI 0x01
- uint8_t ecb3; /* 0x0063 */
- uint32_t scaol; /* 0x0064 */
- uint8_t sdf; /* 0x0068 */
- uint8_t epdx; /* 0x0069 */
- uint8_t reserved6a[2]; /* 0x006a */
- uint32_t todpr; /* 0x006c */
-#define GISA_FORMAT1 0x00000001
- uint32_t gd; /* 0x0070 */
- uint8_t reserved74[12]; /* 0x0074 */
- uint64_t mso; /* 0x0080 */
- uint64_t msl; /* 0x0088 */
- struct psw gpsw; /* 0x0090 */
- uint64_t gg14; /* 0x00a0 */
- uint64_t gg15; /* 0x00a8 */
- uint8_t reservedb0[8]; /* 0x00b0 */
-#define HPID_KVM 0x4
-#define HPID_VSIE 0x5
- uint8_t hpid; /* 0x00b8 */
- uint8_t reservedb9[7]; /* 0x00b9 */
- union {
- struct {
- uint32_t eiparams; /* 0x00c0 */
- uint16_t extcpuaddr; /* 0x00c4 */
- uint16_t eic; /* 0x00c6 */
- };
- uint64_t mcic; /* 0x00c0 */
- } __attribute__ ((__packed__));
- uint32_t reservedc8; /* 0x00c8 */
- uint16_t pgmilc; /* 0x00cc */
- uint16_t iprcc; /* 0x00ce */
- uint32_t dxc; /* 0x00d0 */
- uint16_t mcn; /* 0x00d4 */
- uint8_t perc; /* 0x00d6 */
- uint8_t peratmid; /* 0x00d7 */
- uint64_t peraddr; /* 0x00d8 */
- uint8_t eai; /* 0x00e0 */
- uint8_t peraid; /* 0x00e1 */
- uint8_t oai; /* 0x00e2 */
- uint8_t armid; /* 0x00e3 */
- uint8_t reservede4[4]; /* 0x00e4 */
- uint64_t tecmc; /* 0x00e8 */
- uint8_t reservedf0[12]; /* 0x00f0 */
-#define CRYCB_FORMAT_MASK 0x00000003
-#define CRYCB_FORMAT0 0x00000000
-#define CRYCB_FORMAT1 0x00000001
-#define CRYCB_FORMAT2 0x00000003
- uint32_t crycbd; /* 0x00fc */
- uint64_t gcr[16]; /* 0x0100 */
- union {
- uint64_t gbea; /* 0x0180 */
- uint64_t sidad;
- };
- uint8_t reserved188[8]; /* 0x0188 */
- uint64_t sdnxo; /* 0x0190 */
- uint8_t reserved198[8]; /* 0x0198 */
- uint32_t fac; /* 0x01a0 */
- uint8_t reserved1a4[20]; /* 0x01a4 */
- uint64_t cbrlo; /* 0x01b8 */
- uint8_t reserved1c0[8]; /* 0x01c0 */
-#define ECD_HOSTREGMGMT 0x20000000
-#define ECD_MEF 0x08000000
-#define ECD_ETOKENF 0x02000000
-#define ECD_ECC 0x00200000
- uint32_t ecd; /* 0x01c8 */
- uint8_t reserved1cc[18]; /* 0x01cc */
- uint64_t pp; /* 0x01de */
- uint8_t reserved1e6[2]; /* 0x01e6 */
- uint64_t itdba; /* 0x01e8 */
- uint64_t riccbd; /* 0x01f0 */
- uint64_t gvrd; /* 0x01f8 */
- uint64_t reserved200[48]; /* 0x0200 */
- uint64_t pv_grregs[16]; /* 0x0380 */
-} __attribute__((packed));
-
-union esca_sigp_ctrl {
- uint16_t value;
- struct {
- uint8_t c : 1;
- uint8_t reserved: 7;
- uint8_t scn;
- };
-};
-
-struct esca_entry {
- union esca_sigp_ctrl sigp_ctrl;
- uint16_t reserved1[3];
- uint64_t sda;
- uint64_t reserved2[6];
-};
-
-union ipte_control {
- unsigned long val;
- struct {
- unsigned long k : 1;
- unsigned long kh : 31;
- unsigned long kg : 32;
- };
-};
-
-struct esca_block {
- union ipte_control ipte_control;
- uint64_t reserved1[7];
- uint64_t mcn[4];
- uint64_t reserved2[20];
- struct esca_entry cpu[256];
-};
+#include <asm/sie-arch.h>
struct vm_uv {
uint64_t vm_handle;
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 16/18] s390x: Support newer version of genprotimg
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (14 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 15/18] lib: s390x: Split SIE fw structs from lib structs Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 17/18] s390x/Makefile: Make sure the linker script is generated in the build directory Nico Boehr
` (2 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda, Marc Hartmayer
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Since s390-tools commit f4cf4ae6ebb1 ("rust: Add a new tool called
'pvimg'") the genprotimg command checks if a given image/kernel is a
s390x Linux kernel, and it does no longer overwrite the output file by
default. Disable the component check, since a KUT test is being
prepared, and use the '--overwrite' option to overwrite the output.
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Link: https://lore.kernel.org/r/20241205160011.100609-1-mhartmay@linux.ibm.com
[ nrb: re-wrapped commit message ]
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
s390x/Makefile | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/s390x/Makefile b/s390x/Makefile
index e5572cb6..8970a85b 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -182,17 +182,26 @@ $(comm-key):
%.bin: %.elf
$(OBJCOPY) -O binary $< $@
+define test_genprotimg_opt
+$(shell $(GENPROTIMG) --help | grep -q -- "$1" && echo yes || echo no)
+endef
+
+GENPROTIMG_DEFAULT_ARGS := --no-verify
+ifneq ($(HOST_KEY_DOCUMENT),)
# The genprotimg arguments for the cck changed over time so we need to
# figure out which argument to use in order to set the cck
-ifneq ($(HOST_KEY_DOCUMENT),)
-GENPROTIMG_HAS_COMM_KEY = $(shell $(GENPROTIMG) --help | grep -q -- --comm-key && echo yes)
-ifeq ($(GENPROTIMG_HAS_COMM_KEY),yes)
+ifeq ($(call test_genprotimg_opt,--comm-key),yes)
GENPROTIMG_COMM_OPTION := --comm-key
else
GENPROTIMG_COMM_OPTION := --x-comm-key
endif
-else
-GENPROTIMG_HAS_COMM_KEY =
+# Newer version of the genprotimg command checks if the given image/kernel is a
+# s390x Linux kernel and it does not overwrite the output file by default.
+# Disable the component check, since a KUT test is being prepared, and always
+# overwrite the output.
+ifeq ($(call test_genprotimg_opt,--overwrite),yes)
+ GENPROTIMG_DEFAULT_ARGS += --overwrite --no-component-check
+endif
endif
ifeq ($(CONFIG_DUMP),yes)
@@ -206,7 +215,7 @@ endif
$(patsubst %.parmfile,%.pv.bin,$(wildcard s390x/*.parmfile)): %.pv.bin: %.parmfile
%.pv.bin: %.bin $(HOST_KEY_DOCUMENT) $(comm-key)
$(eval parmfile_args = $(if $(filter %.parmfile,$^),--parmfile $(filter %.parmfile,$^),))
- $(GENPROTIMG) --host-key-document $(HOST_KEY_DOCUMENT) --no-verify $(GENPROTIMG_COMM_OPTION) $(comm-key) --x-pcf $(GENPROTIMG_PCF) $(parmfile_args) --image $(filter %.bin,$^) -o $@
+ $(GENPROTIMG) $(GENPROTIMG_DEFAULT_ARGS) --host-key-document $(HOST_KEY_DOCUMENT) $(GENPROTIMG_COMM_OPTION) $(comm-key) --x-pcf $(GENPROTIMG_PCF) $(parmfile_args) --image $(filter %.bin,$^) -o $@
$(snippet_asmlib): $$(patsubst %.o,%.S,$$@) $(asm-offsets)
$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 17/18] s390x/Makefile: Make sure the linker script is generated in the build directory
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (15 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 16/18] s390x: Support newer version of genprotimg Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 18/18] s390x/Makefile: Add auxinfo.o to cflatobjs Nico Boehr
2025-02-03 9:11 ` [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Thomas Huth
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda, Marc Hartmayer
From: Marc Hartmayer <mhartmay@linux.ibm.com>
This change makes sure that the 'flat.lds' linker script is actually
generated in the build directory and not source directory - this makes a
difference in case of an out-of-source build.
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Link: https://lore.kernel.org/r/20250128100639.41779-2-mhartmay@linux.ibm.com
[ nrb: use TEST_DIR instead of s390x, wrap commit msg ]
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
s390x/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/s390x/Makefile b/s390x/Makefile
index 8970a85b..eb3d5431 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -167,8 +167,8 @@ lds-autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d -MT $@
$(CC) $(CFLAGS) -c -o $@ $< -DPROGNAME=\"$(@:.aux.o=.elf)\"
.SECONDEXPANSION:
-%.elf: $(FLATLIBS) $(asmlib) $(SRCDIR)/s390x/flat.lds $$(snippets-obj) $$(snippet-hdr-obj) %.o %.aux.o
- @$(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/flat.lds \
+%.elf: $(FLATLIBS) $(asmlib) $(TEST_DIR)/flat.lds $$(snippets-obj) $$(snippet-hdr-obj) %.o %.aux.o
+ @$(CC) $(LDFLAGS) -o $@ -T $(TEST_DIR)/flat.lds \
$(filter %.o, $^) $(FLATLIBS) $(snippets-obj) $(snippet-hdr-obj) || \
{ echo "Failure probably caused by missing definition of gen-se-header executable"; exit 1; }
@chmod a-x $@
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [kvm-unit-tests GIT PULL 18/18] s390x/Makefile: Add auxinfo.o to cflatobjs
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (16 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 17/18] s390x/Makefile: Make sure the linker script is generated in the build directory Nico Boehr
@ 2025-02-03 8:35 ` Nico Boehr
2025-02-03 9:11 ` [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Thomas Huth
18 siblings, 0 replies; 20+ messages in thread
From: Nico Boehr @ 2025-02-03 8:35 UTC (permalink / raw)
To: thuth, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda, Marc Hartmayer
From: Marc Hartmayer <mhartmay@linux.ibm.com>
This makes sure that the file is removed in case of `make clean` as the top
Makefile cleans all objects defined in 'cflagsobjs'.
AFAICT, the computed sh256sum values of the generated .elf and .bin files
did not change.
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Link: https://lore.kernel.org/r/20250128100639.41779-3-mhartmay@linux.ibm.com
[ nrb: remove "Note" in commit msg since it looked like a tag ]
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
s390x/Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/s390x/Makefile b/s390x/Makefile
index eb3d5431..47dda6d2 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -96,6 +96,7 @@ LDFLAGS += -Wl,--build-id=none
asm-offsets = lib/$(ARCH)/asm-offsets.h
include $(SRCDIR)/scripts/asm-offsets.mak
+cflatobjs += lib/auxinfo.o
cflatobjs += lib/util.o
cflatobjs += lib/alloc.o
cflatobjs += lib/alloc_phys.o
--
2.47.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles
2025-02-03 8:35 [kvm-unit-tests GIT PULL 00/18] s390x: new edat, diag258 and STFLE tests; fixes for genprotimg >= 2.36.0; cleanups for snippets and makefiles Nico Boehr
` (17 preceding siblings ...)
2025-02-03 8:35 ` [kvm-unit-tests GIT PULL 18/18] s390x/Makefile: Add auxinfo.o to cflatobjs Nico Boehr
@ 2025-02-03 9:11 ` Thomas Huth
18 siblings, 0 replies; 20+ messages in thread
From: Thomas Huth @ 2025-02-03 9:11 UTC (permalink / raw)
To: Nico Boehr, pbonzini, andrew.jones; +Cc: kvm, frankja, imbrenda
On 03/02/2025 09.35, Nico Boehr wrote:
> Hi Paolo and/or Thomas,
>
> Changes in this pull request:
> - cpacf query function were reworked in the kernel, that fix was
> cherry-picked by Nina. This fixes issues with possible incorrect
> instruction format
> - Claudio extended the edat test for a special case with a 2G page at
> the end of memory to ensure the correct addressing exception happens.
> - I added a test for diag258 where we had some issues with
> virtual-physical address confusion.
> - Nina took the time to add library functions that help exiting from a
> snippet s390x.
> - Nina contributed a test for STFLE interpretive execution. Thank you!
> - Marc did a lot of magic fixing issues in our Makefiles. This fixes
> several issues with out-of-tree-builds. We now also build out-of-tree
> in our downstream CI to avoid unpleasant surprises for maintainers :)
> Marc, thanks for contributing your Makefile knowledge and for turning my
> complaints into something productive
> - Janosch also invested some time to clean up snippets and Makefiles,
> which made the code a lot nicer, thanks for that as well!
> - we have a compatibility issue with genprotimg
> versions >= 2.36.0. Thanks Marc to fixing that. You should upgrade
> kvm-unit-tests if you use genprotimg >= 2.36.0!
>
> Note that there are two checkpatch errors:
>> ERROR: space prohibited before that ':' (ctx:WxW)
> I would suggest to ignore them, the code really looks ugly otherwise.
>
> Thanks
> Nico
Thanks, merged now.
Thomas
^ permalink raw reply [flat|nested] 20+ messages in thread