s390/ap: provide F bit parameter for ap_rapq() and ap_zapq()
authorHarald Freudenberger <freude@linux.ibm.com>
Wed, 7 Sep 2022 16:04:03 +0000 (18:04 +0200)
committerHeiko Carstens <hca@linux.ibm.com>
Mon, 20 Mar 2023 10:12:49 +0000 (11:12 +0100)
Extent the ap inline functions ap_rapq() (calls PQAP(RAPQ))
and ap_zapq() (calls PQAP(ZAPQ)) with a new parameter to
enable the new architectured F bit which forces an
unassociate and/or unbind on a secure execution associated
and/or bound queue.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Tony Krowiak <akrowiak@linux.ibm.com>
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/include/asm/ap.h
drivers/s390/crypto/ap_queue.c
drivers/s390/crypto/vfio_ap_ops.c
drivers/s390/crypto/zcrypt_cex2c.c

index ba8da3f..3442e76 100644 (file)
@@ -159,14 +159,18 @@ static inline struct ap_queue_status ap_test_queue(ap_qid_t qid, int tbit,
 /**
  * ap_pqap_rapq(): Reset adjunct processor queue.
  * @qid: The AP queue number
+ * @fbit: if != 0 set F bit
  *
  * Returns AP queue status structure.
  */
-static inline struct ap_queue_status ap_rapq(ap_qid_t qid)
+static inline struct ap_queue_status ap_rapq(ap_qid_t qid, int fbit)
 {
        unsigned long reg0 = qid | (1UL << 24);  /* fc 1UL is RAPQ */
        union ap_queue_status_reg reg1;
 
+       if (fbit)
+               reg0 |= 1UL << 22;
+
        asm volatile(
                "       lgr     0,%[reg0]\n"            /* qid arg into gr0 */
                "       .insn   rre,0xb2af0000,0,0\n"   /* PQAP(RAPQ) */
@@ -180,14 +184,18 @@ static inline struct ap_queue_status ap_rapq(ap_qid_t qid)
 /**
  * ap_pqap_zapq(): Reset and zeroize adjunct processor queue.
  * @qid: The AP queue number
+ * @fbit: if != 0 set F bit
  *
  * Returns AP queue status structure.
  */
-static inline struct ap_queue_status ap_zapq(ap_qid_t qid)
+static inline struct ap_queue_status ap_zapq(ap_qid_t qid, int fbit)
 {
        unsigned long reg0 = qid | (2UL << 24);  /* fc 2UL is ZAPQ */
        union ap_queue_status_reg reg1;
 
+       if (fbit)
+               reg0 |= 1UL << 22;
+
        asm volatile(
                "       lgr     0,%[reg0]\n"            /* qid arg into gr0 */
                "       .insn   rre,0xb2af0000,0,0\n"   /* PQAP(ZAPQ) */
index 1c08b28..8517e1c 100644 (file)
@@ -322,7 +322,7 @@ static enum ap_sm_wait ap_sm_reset(struct ap_queue *aq)
 {
        struct ap_queue_status status;
 
-       status = ap_rapq(aq->qid);
+       status = ap_rapq(aq->qid, 0);
        switch (status.response_code) {
        case AP_RESPONSE_NORMAL:
        case AP_RESPONSE_RESET_IN_PROGRESS:
@@ -936,7 +936,7 @@ void ap_queue_remove(struct ap_queue *aq)
         * to the initial value AP_DEV_STATE_UNINITIATED.
         */
        spin_lock_bh(&aq->lock);
-       ap_zapq(aq->qid);
+       ap_zapq(aq->qid, 0);
        aq->dev_state = AP_DEV_STATE_UNINITIATED;
        spin_unlock_bh(&aq->lock);
 }
index 31de464..cfbcb86 100644 (file)
@@ -1657,7 +1657,7 @@ static int vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q)
        if (!q)
                return 0;
 retry_zapq:
-       status = ap_zapq(q->apqn);
+       status = ap_zapq(q->apqn, 0);
        q->reset_rc = status.response_code;
        switch (status.response_code) {
        case AP_RESPONSE_NORMAL:
index 78f8d68..251b5bd 100644 (file)
@@ -338,7 +338,7 @@ static int zcrypt_cex2c_queue_probe(struct ap_device *ap_dev)
        zq->queue = aq;
        zq->online = 1;
        atomic_set(&zq->load, 0);
-       ap_rapq(aq->qid);
+       ap_rapq(aq->qid, 0);
        rc = zcrypt_cex2c_rng_supported(aq);
        if (rc < 0) {
                zcrypt_queue_free(zq);