From: Janosch Frank <frankja@linux.ibm.com>
To: kvm@vger.kernel.org
Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com,
thuth@redhat.com, david@redhat.com, nsg@linux.ibm.com,
nrb@linux.ibm.com, akrowiak@linux.ibm.com, jjherne@linux.ibm.com
Subject: [kvm-unit-tests PATCH v4 4/7] s390x: ap: Add pqap aqic tests
Date: Fri, 2 Feb 2024 14:59:10 +0000 [thread overview]
Message-ID: <20240202145913.34831-5-frankja@linux.ibm.com> (raw)
In-Reply-To: <20240202145913.34831-1-frankja@linux.ibm.com>
Let's check if we can enable/disable interrupts and if all errors are
reported if we specify bad addresses for the notification indication
byte.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
lib/s390x/ap.c | 35 +++++++++++++++++++++++
lib/s390x/ap.h | 11 ++++++++
s390x/ap.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 120 insertions(+), 1 deletion(-)
diff --git a/lib/s390x/ap.c b/lib/s390x/ap.c
index c85172a8..4e7d3d34 100644
--- a/lib/s390x/ap.c
+++ b/lib/s390x/ap.c
@@ -60,6 +60,41 @@ int ap_pqap_tapq(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw,
return cc;
}
+int ap_pqap_aqic(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw,
+ struct ap_qirq_ctrl aqic, unsigned long addr)
+{
+ uint64_t bogus_cc = 2;
+ struct pqap_r0 r0 = {};
+ int cc;
+
+ /*
+ * AP-Queue Interruption Control
+ *
+ * Enables/disables interrupts for a APQN
+ *
+ * Inputs: 0,1,2
+ * Outputs: 1 (APQSW)
+ * Synchronous
+ */
+ r0.ap = ap;
+ r0.qn = qn;
+ r0.fc = PQAP_QUEUE_INT_CONTRL;
+ asm volatile(
+ " tmll %[bogus_cc],3\n"
+ " lgr 0,%[r0]\n"
+ " lgr 1,%[aqic]\n"
+ " lgr 2,%[addr]\n"
+ " .insn rre,0xb2af0000,0,0\n" /* PQAP */
+ " stg 1, %[apqsw]\n"
+ " ipm %[cc]\n"
+ " srl %[cc],28\n"
+ : [apqsw] "=&T" (*apqsw), [cc] "=&d" (cc)
+ : [r0] "d" (r0), [aqic] "d" (aqic), [addr] "d" (addr), [bogus_cc] "d" (bogus_cc)
+ : "cc", "memory", "0", "2");
+
+ return cc;
+}
+
int ap_pqap_qci(struct ap_config_info *info)
{
struct pqap_r0 r0 = { .fc = PQAP_QUERY_AP_CONF_INFO };
diff --git a/lib/s390x/ap.h b/lib/s390x/ap.h
index 8feca43a..15394d56 100644
--- a/lib/s390x/ap.h
+++ b/lib/s390x/ap.h
@@ -81,6 +81,15 @@ struct pqap_r2 {
} __attribute__((packed)) __attribute__((aligned(8)));
_Static_assert(sizeof(struct pqap_r2) == sizeof(uint64_t), "pqap_r2 size");
+struct ap_qirq_ctrl {
+ uint64_t res0 : 16;
+ uint64_t ir : 1; /* ir flag: enable (1) or disable (0) irq */
+ uint64_t res1 : 44;
+ uint64_t isc : 3; /* irq sub class */
+} __attribute__((packed)) __attribute__((aligned(8)));
+_Static_assert(sizeof(struct ap_qirq_ctrl) == sizeof(uint64_t),
+ "struct ap_qirq_ctrl size");
+
/*
* Maximum number of APQNs that we keep track of.
*
@@ -100,4 +109,6 @@ int ap_setup(uint8_t **ap_array, uint8_t **qn_array, uint8_t *naps, uint8_t *nqn
int ap_pqap_tapq(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw,
struct pqap_r2 *r2);
int ap_pqap_qci(struct ap_config_info *info);
+int ap_pqap_aqic(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw,
+ struct ap_qirq_ctrl aqic, unsigned long addr);
#endif
diff --git a/s390x/ap.c b/s390x/ap.c
index 5c458e7e..6f95a716 100644
--- a/s390x/ap.c
+++ b/s390x/ap.c
@@ -12,10 +12,15 @@
#include <interrupt.h>
#include <bitops.h>
#include <alloc_page.h>
+#include <malloc_io.h>
+#include <asm/page.h>
#include <asm/facility.h>
#include <asm/time.h>
#include <ap.h>
+static uint8_t apn;
+static uint8_t qn;
+
/* For PQAP PGM checks where we need full control over the input */
static void pqap(unsigned long grs[3])
{
@@ -290,9 +295,63 @@ static void test_priv(void)
report_prefix_pop();
}
+static void test_pqap_aqic(void)
+{
+ uint8_t *not_ind_byte = alloc_io_mem(PAGE_SIZE, 0);
+ struct ap_queue_status apqsw = {};
+ struct ap_qirq_ctrl aqic = {};
+ struct pqap_r2 r2 = {};
+ int cc;
+
+ report_prefix_push("aqic");
+ *not_ind_byte = 0;
+
+ aqic.ir = 1;
+ cc = ap_pqap_aqic(apn, qn, &apqsw, aqic, 0);
+ report(cc == 3 && apqsw.rc == 6, "invalid addr 0");
+
+ aqic.ir = 1;
+ cc = ap_pqap_aqic(apn, qn, &apqsw, aqic, -1);
+ report(cc == 3 && apqsw.rc == 6, "invalid addr -1");
+
+ aqic.ir = 0;
+ cc = ap_pqap_aqic(apn, qn, &apqsw, aqic, (uintptr_t)not_ind_byte);
+ report(cc == 3 && apqsw.rc == 7, "disable IRQs while already disabled");
+
+ aqic.ir = 1;
+ cc = ap_pqap_aqic(apn, qn, &apqsw, aqic, (uintptr_t)not_ind_byte);
+ report(cc == 0 && apqsw.rc == 0, "enable IRQs");
+
+ do {
+ mdelay(20);
+ cc = ap_pqap_tapq(apn, qn, &apqsw, &r2);
+ } while (cc == 0 && apqsw.irq_enabled == 0);
+ report(cc == 0 && apqsw.irq_enabled == 1, "enable IRQs tapq data");
+
+ cc = ap_pqap_aqic(apn, qn, &apqsw, aqic, (uintptr_t)not_ind_byte);
+ report(cc == 3 && apqsw.rc == 7, "enable IRQs while already enabled");
+
+ aqic.ir = 0;
+ cc = ap_pqap_aqic(apn, qn, &apqsw, aqic, (uintptr_t)not_ind_byte);
+ report(cc == 0 && apqsw.rc == 0, "disable IRQs");
+
+ do {
+ mdelay(20);
+ cc = ap_pqap_tapq(apn, qn, &apqsw, &r2);
+ } while (cc == 0 && apqsw.irq_enabled == 1);
+ report(cc == 0 && apqsw.irq_enabled == 0, "disable IRQs tapq data");
+
+ report_prefix_pop();
+
+ free_io_mem(not_ind_byte, PAGE_SIZE);
+}
+
int main(void)
{
- int setup_rc = ap_setup(NULL, NULL, NULL, NULL);
+ uint8_t num_ap, num_qn;
+ uint8_t *apns;
+ uint8_t *qns;
+ int setup_rc = ap_setup(&apns, &qns, &num_ap, &num_qn);
report_prefix_push("ap");
if (setup_rc == AP_SETUP_NOINSTR) {
@@ -305,6 +364,20 @@ int main(void)
test_pgms_nqap();
test_pgms_dqap();
+ /* The next tests need queues */
+ if (setup_rc == AP_SETUP_NOAPQN) {
+ report_skip("No APQN available");
+ goto done;
+ }
+ apn = apns[0];
+ qn = qns[0];
+ report_prefix_push("pqap");
+ if (test_facility(65))
+ test_pqap_aqic();
+ else
+ report_skip("no AQIC and reset tests without IRQ support");
+ report_prefix_pop();
+
done:
report_prefix_pop();
return report_summary();
--
2.40.1
next prev parent reply other threads:[~2024-02-02 15:05 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-02 14:59 [kvm-unit-tests PATCH v4 0/7] s390x: Add base AP support Janosch Frank
2024-02-02 14:59 ` [kvm-unit-tests PATCH v4 1/7] lib: s390x: Add ap library Janosch Frank
2024-02-05 18:15 ` Anthony Krowiak
2024-02-06 8:48 ` Harald Freudenberger
2024-02-06 15:45 ` Anthony Krowiak
2024-02-06 13:42 ` Janosch Frank
2024-02-06 15:55 ` Anthony Krowiak
2024-02-07 8:06 ` Harald Freudenberger
2024-02-07 14:30 ` Anthony Krowiak
2024-02-02 14:59 ` [kvm-unit-tests PATCH v4 2/7] s390x: Add guest 2 AP test Janosch Frank
2024-02-20 16:38 ` Anthony Krowiak
2024-02-21 7:57 ` Janosch Frank
2024-02-02 14:59 ` [kvm-unit-tests PATCH v4 3/7] lib: s390x: ap: Add proper ap setup code Janosch Frank
2024-02-02 14:59 ` Janosch Frank [this message]
2024-02-02 14:59 ` [kvm-unit-tests PATCH v4 5/7] s390x: ap: Add reset tests Janosch Frank
2024-02-02 14:59 ` [kvm-unit-tests PATCH v4 6/7] lib: s390x: ap: Add tapq test facility bit Janosch Frank
2024-02-02 14:59 ` [kvm-unit-tests PATCH v4 7/7] s390x: ap: Add nq/dq len test Janosch Frank
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=20240202145913.34831-5-frankja@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=akrowiak@linux.ibm.com \
--cc=david@redhat.com \
--cc=imbrenda@linux.ibm.com \
--cc=jjherne@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=nrb@linux.ibm.com \
--cc=nsg@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