s390/ap: new low level inline functions ap_bapq() and ap_aapq()
authorHarald Freudenberger <freude@linux.ibm.com>
Wed, 7 Sep 2022 17:05:18 +0000 (19:05 +0200)
committerHeiko Carstens <hca@linux.ibm.com>
Mon, 20 Mar 2023 10:12:49 +0000 (11:12 +0100)
Introduce two new low level functions ap_bapq() (calls
PQAP(BAPQ)) and ap_aapq (calls PQAP(AAPQ)). Both functions
are only meant to be used in SE environment with the SE
AP binding facility available.

Signed-off-by: Harald Freudenberger <freude@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

index 3442e76d5e3db151eabdecb79b66db9ee33e7386..92b04d66d69a11e7ea2cf978960f840f13c0b795 100644 (file)
@@ -354,6 +354,59 @@ static inline struct ap_queue_status ap_qact(ap_qid_t qid, int ifbit,
        return reg1.status;
 }
 
+/*
+ * ap_bapq(): SE bind AP queue.
+ * @qid: The AP queue number
+ *
+ * Returns AP queue status structure.
+ *
+ * Invoking this function in a non-SE environment
+ * may case a specification exception.
+ */
+static inline struct ap_queue_status ap_bapq(ap_qid_t qid)
+{
+       unsigned long reg0 = qid | (7UL << 24);  /* fc 7 is BAPQ */
+       union ap_queue_status_reg reg1;
+
+       asm volatile(
+               "       lgr     0,%[reg0]\n"            /* qid arg into gr0 */
+               "       .insn   rre,0xb2af0000,0,0\n"   /* PQAP(BAPQ) */
+               "       lgr     %[reg1],1\n"            /* gr1 (status) into reg1 */
+               : [reg1] "=&d" (reg1.value)
+               : [reg0] "d" (reg0)
+               : "cc", "0", "1");
+
+       return reg1.status;
+}
+
+/*
+ * ap_aapq(): SE associate AP queue.
+ * @qid: The AP queue number
+ * @sec_idx: The secret index
+ *
+ * Returns AP queue status structure.
+ *
+ * Invoking this function in a non-SE environment
+ * may case a specification exception.
+ */
+static inline struct ap_queue_status ap_aapq(ap_qid_t qid, unsigned int sec_idx)
+{
+       unsigned long reg0 = qid | (8UL << 24);  /* fc 8 is AAPQ */
+       unsigned long reg2 = sec_idx;
+       union ap_queue_status_reg reg1;
+
+       asm volatile(
+               "       lgr     0,%[reg0]\n"            /* qid arg into gr0 */
+               "       lgr     2,%[reg2]\n"            /* secret index into gr2 */
+               "       .insn   rre,0xb2af0000,0,0\n"   /* PQAP(AAPQ) */
+               "       lgr     %[reg1],1\n"            /* gr1 (status) into reg1 */
+               : [reg1] "=&d" (reg1.value)
+               : [reg0] "d" (reg0), [reg2] "d" (reg2)
+               : "cc", "0", "1", "2");
+
+       return reg1.status;
+}
+
 /**
  * ap_nqap(): Send message to adjunct processor queue.
  * @qid: The AP queue number