From patchwork Fri Feb 2 14:59:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13542984 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43430144627; Fri, 2 Feb 2024 15:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706886302; cv=none; b=DSLYPr+7oNaRVqVAHH4fRe7DUJKozVuwtrEgNAkh8ZpCnm8mLGud7rv7shHa5zr0ozr4iGsZZRfoL5Y/XCVS/bYZr0R51L5EAYyh5CLhiDTy+Fw6gA8rWnAiDUzNQl5CiBCzjrhdmjSYgAToNok/zzKBKHBOtNHyaaz/bBid4Kw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706886302; c=relaxed/simple; bh=x7JE9DASJYozsZKxALLVlIDwl6DgDE+PDvIhIOu9x3M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UYiBQgbzCCM6raLJPAERMfrwqeNegscSj1VmHcVTwm9s+k1B9YNAMt0JEQwE7zrBE/3NGc7DMTjmuJHHhygwqAvCK4xPXkYmJtgoakPxW7N0wLhzi6dSjToSD8Ca0fx1lzETNfbqKl6O/V3hkRp/QLNwCk/I2kEPfffzKwgHe3Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=RUZ+xsU4; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="RUZ+xsU4" Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 412ESufO031624; Fri, 2 Feb 2024 15:04:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=voz/5rT1CNnOTFJsV+PGqPQfIRYtzHgSr+ZPUW6xx5Y=; b=RUZ+xsU4APaREmKpdZLTPq9zSiwc1y0DG/QA+a1mEDWPQjbv+odu//TKWrSIUcPz0aSg +/cvX1QBkgGYqUi4I8CMI6tW2UNkfjqT8dj0ZYDzCZiY+LBt4qUZwIPYxDF1OfzZGle5 GIMH3Gkz6peo6VtmSwDSaQLMZn1BKNlG/cbfLRTkn9Qw8sbZOn91Ge9DaiHN4Q4CLraw EzgJMmgyBVifcJFJzyA3jQrG0vmznAfWhRTunL1ZgIgkr98jXvv2KX0vUskPUHquX6MO SkDH9y/QN1dv5lzDKNd/HY2S+sFxNqIzqet+QlS6efSAf4VnKIrFG0RpORbXwuBaAggh Eg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w126h8v3y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:58 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 412ESrFX031537; Fri, 2 Feb 2024 15:04:58 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w126h8v3j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:58 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 412DAB5L008086; Fri, 2 Feb 2024 15:04:57 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vwdnmku0c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:57 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 412F4sjB18678274 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Feb 2024 15:04:54 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 67D9C20040; Fri, 2 Feb 2024 15:04:54 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 351BE20049; Fri, 2 Feb 2024 15:04:54 +0000 (GMT) Received: from a46lp67.lnxne.boe (unknown [9.152.108.100]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Feb 2024 15:04:54 +0000 (GMT) From: Janosch Frank 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 1/7] lib: s390x: Add ap library Date: Fri, 2 Feb 2024 14:59:07 +0000 Message-Id: <20240202145913.34831-2-frankja@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202145913.34831-1-frankja@linux.ibm.com> References: <20240202145913.34831-1-frankja@linux.ibm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: qvep5Pll98jG3w3Qk2uTF2jS22xxPgpK X-Proofpoint-ORIG-GUID: Imb2og9KbL4iHRFKOTcAJZuL_d6E_hH8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-02_08,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 phishscore=0 suspectscore=0 bulkscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402020109 Add functions and definitions needed to test the Adjunct Processor (AP) crypto interface. Signed-off-by: Janosch Frank --- lib/s390x/ap.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++ lib/s390x/ap.h | 88 +++++++++++++++++++++++++++++++++++++++++++++ s390x/Makefile | 1 + 3 files changed, 186 insertions(+) create mode 100644 lib/s390x/ap.c create mode 100644 lib/s390x/ap.h diff --git a/lib/s390x/ap.c b/lib/s390x/ap.c new file mode 100644 index 00000000..9560ff64 --- /dev/null +++ b/lib/s390x/ap.c @@ -0,0 +1,97 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * AP crypto functions + * + * Some parts taken from the Linux AP driver. + * + * Copyright IBM Corp. 2024 + * Author: Janosch Frank + * Tony Krowiak + * Martin Schwidefsky + * Harald Freudenberger + */ + +#include +#include +#include +#include +#include + +int ap_pqap_tapq(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw, + struct pqap_r2 *r2) +{ + struct pqap_r0 r0 = { + .ap = ap, + .qn = qn, + .fc = PQAP_TEST_APQ + }; + uint64_t bogus_cc = 2; + int cc; + + /* + * Test AP Queue + * + * Writes AP configuration information to the memory pointed + * at by GR2. + * + * Inputs: GR0 + * Outputs: GR1 (APQSW), GR2 (tapq data) + * Synchronous + */ + asm volatile( + " tmll %[bogus_cc],3\n" + " lgr 0,%[r0]\n" + " .insn rre,0xb2af0000,0,0\n" /* PQAP */ + " stg 1,%[apqsw]\n" + " stg 2,%[r2]\n" + " ipm %[cc]\n" + " srl %[cc],28\n" + : [apqsw] "=&T" (*apqsw), [r2] "=&T" (*r2), [cc] "=&d" (cc) + : [r0] "d" (r0), [bogus_cc] "d" (bogus_cc)); + + return cc; +} + +int ap_pqap_qci(struct ap_config_info *info) +{ + struct pqap_r0 r0 = { .fc = PQAP_QUERY_AP_CONF_INFO }; + uint64_t bogus_cc = 2; + int cc; + + /* + * Query AP Configuration Information + * + * Writes AP configuration information to the memory pointed + * at by GR2. + * + * Inputs: GR0, GR2 (QCI block address) + * Outputs: memory at GR2 address + * Synchronous + */ + asm volatile( + " tmll %[bogus_cc],3\n" + " lgr 0,%[r0]\n" + " lgr 2,%[info]\n" + " .insn rre,0xb2af0000,0,0\n" /* PQAP */ + " ipm %[cc]\n" + " srl %[cc],28\n" + : [cc] "=&d" (cc) + : [r0] "d" (r0), [info] "d" (info), [bogus_cc] "d" (bogus_cc) + : "cc", "memory", "0", "2"); + + return cc; +} + +/* Will later be extended to a proper setup function */ +bool ap_setup(void) +{ + /* + * Base AP support has no STFLE or SCLP feature bit but the + * PQAP QCI support is indicated via stfle bit 12. As this + * library relies on QCI we bail out if it's not available. + */ + if (!test_facility(12)) + return false; + + return true; +} diff --git a/lib/s390x/ap.h b/lib/s390x/ap.h new file mode 100644 index 00000000..b806513f --- /dev/null +++ b/lib/s390x/ap.h @@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * AP definitions + * + * Some parts taken from the Linux AP driver. + * + * Copyright IBM Corp. 2024 + * Author: Janosch Frank + * Tony Krowiak + * Martin Schwidefsky + * Harald Freudenberger + */ + +#ifndef _S390X_AP_H_ +#define _S390X_AP_H_ + +enum PQAP_FC { + PQAP_TEST_APQ, + PQAP_RESET_APQ, + PQAP_ZEROIZE_APQ, + PQAP_QUEUE_INT_CONTRL, + PQAP_QUERY_AP_CONF_INFO, + PQAP_QUERY_AP_COMP_TYPE, + PQAP_BEST_AP, +}; + +struct ap_queue_status { + uint32_t pad0; /* Ignored padding for zArch */ + uint32_t empty : 1; + uint32_t replies_waiting: 1; + uint32_t full : 1; + uint32_t pad1 : 4; + uint32_t irq_enabled : 1; + uint32_t rc : 8; + uint32_t pad2 : 16; +} __attribute__((packed)) __attribute__((aligned(8))); +_Static_assert(sizeof(struct ap_queue_status) == sizeof(uint64_t), "APQSW size"); + +struct ap_config_info { + uint8_t apsc : 1; /* S bit */ + uint8_t apxa : 1; /* N bit */ + uint8_t qact : 1; /* C bit */ + uint8_t rc8a : 1; /* R bit */ + uint8_t l : 1; /* L bit */ + uint8_t lext : 3; /* Lext bits */ + uint8_t reserved2[3]; + uint8_t Na; /* max # of APs - 1 */ + uint8_t Nd; /* max # of Domains - 1 */ + uint8_t reserved6[10]; + uint32_t apm[8]; /* AP ID mask */ + uint32_t aqm[8]; /* AP (usage) queue mask */ + uint32_t adm[8]; /* AP (control) domain mask */ + uint8_t _reserved4[16]; +} __attribute__((aligned(8))) __attribute__ ((__packed__)); +_Static_assert(sizeof(struct ap_config_info) == 128, "PQAP QCI size"); + +struct pqap_r0 { + uint32_t pad0; + uint8_t fc; + uint8_t t : 1; /* Test facilities (TAPQ)*/ + uint8_t pad1 : 7; + uint8_t ap; + uint8_t qn; +} __attribute__((packed)) __attribute__((aligned(8))); + +struct pqap_r2 { + uint8_t s : 1; /* Special Command facility */ + uint8_t m : 1; /* AP4KM */ + uint8_t c : 1; /* AP4KC */ + uint8_t cop : 1; /* AP is in coprocessor mode */ + uint8_t acc : 1; /* AP is in accelerator mode */ + uint8_t xcp : 1; /* AP is in XCP-mode */ + uint8_t n : 1; /* AP extended addressing facility */ + uint8_t pad_0 : 1; + uint8_t pad_1[3]; + uint8_t at; + uint8_t nd; + uint8_t pad_6; + uint8_t pad_7 : 4; + uint8_t qd : 4; +} __attribute__((packed)) __attribute__((aligned(8))); +_Static_assert(sizeof(struct pqap_r2) == sizeof(uint64_t), "pqap_r2 size"); + +bool ap_setup(void); +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); +#endif diff --git a/s390x/Makefile b/s390x/Makefile index 7fce9f9d..4f6c627d 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -110,6 +110,7 @@ cflatobjs += lib/s390x/malloc_io.o cflatobjs += lib/s390x/uv.o cflatobjs += lib/s390x/sie.o cflatobjs += lib/s390x/fault.o +cflatobjs += lib/s390x/ap.o OBJDIRS += lib/s390x From patchwork Fri Feb 2 14:59:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13542987 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3BF0145328; Fri, 2 Feb 2024 15:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706886302; cv=none; b=abuZJTagtAPSHWVQPpp8I3xgWZqKXFotjTr4zSKgvQ9wH+P5yz6dHrazoCtHtJmlFnuyRTnmn5YE5RtZIeNis19LBnGCdJafILANkisVrP2c7bqhyMVitcDzv5ETHNSGsgtYDTF7FQb37ekYMcZJSKO3bVazJCE/6JiF9KIDZo8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706886302; c=relaxed/simple; bh=zCso99M9a1qyL0jm4xlACxx+HLW2uGX84k1uSSZhPGs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kZdvxzcJXH917gfBrmRi7BD4sf6A84oqx8GpquYAfjCXcX/WG/DCROUAV8v/eLtIzNeY9TC55KM2G/fzhNyhv98Fp4ovYnDHgf1lRTseo7LV7/VrdEatwN/cDH2RXBQWjZBii2LeByPJ+sfzR8FoWP6Sz0ClEUMfSn7ZsWFkXHM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=tU36jqF7; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="tU36jqF7" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 412DRJYK008982; Fri, 2 Feb 2024 15:05:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=CRhOrZKd7zsvbBX2wbnVjqeQRkqFJiW13gJswaKAOxE=; b=tU36jqF7eBncZ0CX//MzI6CYjL7xk34qHCo7PpBSM7duTUVlFtuDq2Al65m4Lc0LcRp/ UoKOS6XVCvaoN0+rj9M6fs6/sPuJwxSFEw2lRyFtu9D+avPoqrAus9sUqL4JSG/tSSNH NQUUlSJEQeFVED8+Q3UKus8WzSL4aO336KFezLtuNzav4TgMzJJkPKspK6sSr2MkCTjm Wvx7KBSKewdzLuvY3uRWzImBPl8g8g3tnAjwtRMYaDpBG3KAKI5DSwKDDb0QU5vHwXjt 7F0HJVptLFWuSsthck15jbSHL5sfaKK+hSIskSNt76oxoW6M22OVhcQDYf7p8Zx8jbCV Cg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w119t2fba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:59 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 412Eo9Qv029557; Fri, 2 Feb 2024 15:04:59 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w119t2fat-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:59 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 412CpGlc010569; Fri, 2 Feb 2024 15:04:57 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vwd5pby3b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:57 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 412F4sxr18678276 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Feb 2024 15:04:54 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AA85C20049; Fri, 2 Feb 2024 15:04:54 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6F72F2004B; Fri, 2 Feb 2024 15:04:54 +0000 (GMT) Received: from a46lp67.lnxne.boe (unknown [9.152.108.100]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Feb 2024 15:04:54 +0000 (GMT) From: Janosch Frank 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 2/7] s390x: Add guest 2 AP test Date: Fri, 2 Feb 2024 14:59:08 +0000 Message-Id: <20240202145913.34831-3-frankja@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202145913.34831-1-frankja@linux.ibm.com> References: <20240202145913.34831-1-frankja@linux.ibm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: VXsZL3v6HCI6XomHemb09IgcdjWKKtXZ X-Proofpoint-GUID: J9uibLZAep8YqF9TzMPaKnKqT-aeSNNM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-02_08,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 mlxlogscore=775 impostorscore=0 spamscore=0 suspectscore=0 bulkscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402020109 Add a test that checks the exceptions for the PQAP, NQAP and DQAP adjunct processor (AP) crypto instructions. Since triggering the exceptions doesn't require actual AP hardware, this test can run without complicated setup. Signed-off-by: Janosch Frank Acked-by: Anthony Krowiak --- s390x/Makefile | 1 + s390x/ap.c | 309 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 + 3 files changed, 313 insertions(+) create mode 100644 s390x/ap.c diff --git a/s390x/Makefile b/s390x/Makefile index 4f6c627d..6d28a5bf 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -42,6 +42,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)/ap.elf pv-tests += $(TEST_DIR)/pv-diags.elf pv-tests += $(TEST_DIR)/pv-icptcode.elf diff --git a/s390x/ap.c b/s390x/ap.c new file mode 100644 index 00000000..b3cee37a --- /dev/null +++ b/s390x/ap.c @@ -0,0 +1,309 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * AP instruction G2 tests + * + * Copyright (c) 2024 IBM Corp + * + * Authors: + * Janosch Frank + */ + +#include +#include +#include +#include +#include +#include +#include + +/* For PQAP PGM checks where we need full control over the input */ +static void pqap(unsigned long grs[3]) +{ + asm volatile( + " lgr 0,%[r0]\n" + " lgr 1,%[r1]\n" + " lgr 2,%[r2]\n" + " .insn rre,0xb2af0000,0,0\n" /* PQAP */ + :: [r0] "d" (grs[0]), [r1] "d" (grs[1]), [r2] "d" (grs[2]) + : "cc", "memory", "0", "1", "2"); +} + +static void test_pgms_pqap(void) +{ + unsigned long grs[3] = {}; + struct pqap_r0 *r0 = (struct pqap_r0 *)grs; + uint8_t *data = alloc_page(); + uint16_t pgm; + int fails = 0; + int i; + + report_prefix_push("pqap"); + + /* Wrong FC code */ + report_prefix_push("invalid fc"); + r0->fc = 42; + expect_pgm_int(); + pqap(grs); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + memset(grs, 0, sizeof(grs)); + report_prefix_pop(); + + report_prefix_push("invalid gr0 bits"); + /* + * GR0 bits 41 - 47 are defined 0 and result in a + * specification exception if set to 1. + */ + for (i = 0; i < 48 - 41; i++) { + grs[0] = BIT(63 - 47 + i); + + expect_pgm_int(); + pqap(grs); + pgm = clear_pgm_int(); + + if (pgm != PGM_INT_CODE_SPECIFICATION) { + report_fail("fail on bit %d", 42 + i); + fails++; + } + } + report(!fails, "All bits tested"); + memset(grs, 0, sizeof(grs)); + fails = 0; + report_prefix_pop(); + + report_prefix_push("alignment"); + report_prefix_push("fc=4"); + r0->fc = PQAP_QUERY_AP_CONF_INFO; + grs[2] = (unsigned long)data; + for (i = 1; i < 8; i++) { + expect_pgm_int(); + grs[2]++; + pqap(grs); + pgm = clear_pgm_int(); + if (pgm != PGM_INT_CODE_SPECIFICATION) { + report_fail("fail on bit %d", i); + fails++; + } + } + report(!fails, "All alignments tested"); + report_prefix_pop(); + report_prefix_push("fc=6"); + r0->fc = PQAP_BEST_AP; + grs[2] = (unsigned long)data; + for (i = 1; i < 8; i++) { + expect_pgm_int(); + grs[2]++; + pqap(grs); + pgm = clear_pgm_int(); + if (pgm != PGM_INT_CODE_SPECIFICATION) { + report_fail("fail on bit %d", i); + fails++; + } + } + report(!fails, "All alignments tested"); + report_prefix_pop(); + report_prefix_pop(); + + free_page(data); + report_prefix_pop(); +} + +static void test_pgms_nqap(void) +{ + uint8_t gr0_zeroes_bits[] = { + 32, 34, 35, 40 + }; + uint64_t gr0; + bool fail; + int i; + + report_prefix_push("nqap"); + + /* Registers 0 and 1 are always used, the others are even/odd pairs */ + report_prefix_push("spec"); + report_prefix_push("r1"); + expect_pgm_int(); + asm volatile ( + ".insn rre,0xb2ad0000,3,6\n" + : : : "cc", "memory", "0", "1", "2", "3", "4", "6", "7"); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + report_prefix_pop(); + + report_prefix_push("r2"); + expect_pgm_int(); + asm volatile ( + ".insn rre,0xb2ad0000,2,7\n" + : : : "cc", "memory", "0", "1", "2", "3", "4", "6", "7"); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + report_prefix_pop(); + + report_prefix_push("both"); + expect_pgm_int(); + asm volatile ( + ".insn rre,0xb2ad0000,3,7\n" + : : : "cc", "memory", "0", "1", "2", "3", "4", "6", "7"); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + report_prefix_pop(); + + report_prefix_push("len==0"); + expect_pgm_int(); + asm volatile ( + "xgr 0,0\n" + "xgr 5,5\n" + ".insn rre,0xb2ad0000,2,4\n" + : : : "cc", "memory", "0", "1", "2", "3", "4", "5", "6", "7"); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + report_prefix_pop(); + + report_prefix_push("gr0_zero_bits"); + fail = false; + for (i = 0; i < ARRAY_SIZE(gr0_zeroes_bits); i++) { + expect_pgm_int(); + gr0 = BIT_ULL(63 - gr0_zeroes_bits[i]); + asm volatile ( + "xgr 5,5\n" + "lghi 5, 128\n" + "lg 0, 0(%[val])\n" + ".insn rre,0xb2ad0000,2,4\n" + : : [val] "a" (&gr0) + : "cc", "memory", "0", "1", "2", "3", "4", "5", "6", "7"); + if (clear_pgm_int() != PGM_INT_CODE_SPECIFICATION) { + report_fail("setting gr0 bit %d did not result in a spec exception", + gr0_zeroes_bits[i]); + fail = true; + } + } + report(!fail, "set bit gr0 pgms"); + report_prefix_pop(); + + report_prefix_pop(); + report_prefix_pop(); +} + +static void test_pgms_dqap(void) +{ + uint8_t gr0_zeroes_bits[] = { + 33, 34, 35, 40, 41 + }; + uint64_t gr0; + bool fail; + int i; + + report_prefix_push("dqap"); + + /* Registers 0 and 1 are always used, the others are even/odd pairs */ + report_prefix_push("spec"); + report_prefix_push("r1"); + expect_pgm_int(); + asm volatile ( + ".insn rre,0xb2ae0000,3,6\n" + : : : "cc", "memory", "0", "1", "2", "3", "4", "6", "7"); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + report_prefix_pop(); + + report_prefix_push("r2"); + expect_pgm_int(); + asm volatile ( + ".insn rre,0xb2ae0000,2,7\n" + : : : "cc", "memory", "0", "1", "2", "3", "4", "6", "7"); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + report_prefix_pop(); + + report_prefix_push("both"); + expect_pgm_int(); + asm volatile ( + ".insn rre,0xb2ae0000,3,7\n" + : : : "cc", "memory", "0", "1", "2", "3", "4", "6", "7"); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + report_prefix_pop(); + + report_prefix_push("len==0"); + expect_pgm_int(); + asm volatile ( + "xgr 0,0\n" + "xgr 5,5\n" + ".insn rre,0xb2ae0000,2,4\n" + : : : "cc", "memory", "0", "1", "2", "3", "4", "5", "6", "7"); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + report_prefix_pop(); + + report_prefix_push("gr0_zero_bits"); + fail = false; + for (i = 0; i < ARRAY_SIZE(gr0_zeroes_bits); i++) { + expect_pgm_int(); + gr0 = BIT_ULL(63 - gr0_zeroes_bits[i]); + asm volatile ( + "xgr 5,5\n" + "lghi 5, 128\n" + "lg 0, 0(%[val])\n" + ".insn rre,0xb2ae0000,2,4\n" + : : [val] "a" (&gr0) + : "cc", "memory", "0", "1", "2", "3", "4", "5", "6", "7"); + if (clear_pgm_int() != PGM_INT_CODE_SPECIFICATION) { + report_info("setting gr0 bit %d did not result in a spec exception", + gr0_zeroes_bits[i]); + fail = true; + } + } + report(!fail, "set bit pgms"); + report_prefix_pop(); + + report_prefix_pop(); + report_prefix_pop(); +} + +static void test_priv(void) +{ + struct ap_config_info info = {}; + + report_prefix_push("privileged"); + + report_prefix_push("pqap"); + expect_pgm_int(); + enter_pstate(); + ap_pqap_qci(&info); + check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); + report_prefix_pop(); + + /* + * Enqueue and dequeue take too many registers so a simple + * inline assembly makes more sense than using the library + * functions. + */ + report_prefix_push("nqap"); + expect_pgm_int(); + enter_pstate(); + asm volatile ( + ".insn rre,0xb2ad0000,0,2\n" + : : : "cc", "memory", "0", "1", "2", "3"); + check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); + report_prefix_pop(); + + report_prefix_push("dqap"); + expect_pgm_int(); + enter_pstate(); + asm volatile ( + ".insn rre,0xb2ae0000,0,2\n" + : : : "cc", "memory", "0", "1", "2", "3"); + check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); + report_prefix_pop(); + + report_prefix_pop(); +} + +int main(void) +{ + report_prefix_push("ap"); + if (!ap_check()) { + report_skip("AP instructions not available"); + goto done; + } + + test_priv(); + test_pgms_pqap(); + test_pgms_nqap(); + test_pgms_dqap(); + +done: + report_prefix_pop(); + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 018e4129..578375e4 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -386,3 +386,6 @@ file = sie-dat.elf [pv-attest] file = pv-attest.elf + +[ap] +file = ap.elf From patchwork Fri Feb 2 14:59:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13542985 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAD24144636; Fri, 2 Feb 2024 15:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706886302; cv=none; b=oil6/swI1ED+Cd4pzWnR1SzrOq8QYhuHrYOfTYPtKWxfxLKgobpBfNe9vYRpVloVLCJZHvuFBJNxXR3vHM5JmZ1ubA8iXedZ7wzmWeIaxmTlYjIQ58GVPevUcw4yj2buHgEN4K3rJxc4Th9Mhuu2++2y+BH2OuobLm+Bhj9UXlw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706886302; c=relaxed/simple; bh=7ZsC+e0vsm/1YAntHM0K/eR5e8WTd5p7YdVzQHYQcFg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s3fObgkMcfrhLlAuTZUQSWhuweb4m5SjNlvm1lapZJZxnlf7yKFQUKGwH7POeT0r+etNXIXFqCs9PPjJsgD3l6zh4/GEzHP/i0/k6wVHBDIcook9ACCc6cmLm/YCLssWPJxVaw6Gk2qOo0E4aL45ZnUe06l9reUq+cBpMXd0+hE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=GANkYRDd; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="GANkYRDd" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 412EQ6IB025828; Fri, 2 Feb 2024 15:05:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=PJii8eqAgh7vyiuiy/+5zpmkAQQ4wcReDrFT5R7mCs8=; b=GANkYRDdb2Tqg0qbGlq8mwMLKNBh1sB9aDbOf8RZoYefCC08fOK6BkIFB4q/OktcqTpV Sb9kNf6shQ6LjS0p/srZuqk8QFDBZ8PGsgBuZVy7lrP1CeRNDWsXJ2NcLSNWDVA1wFvk X+5sXh0ARQ17eJwrDCSB+NSE8CxXvLHvcsHw3H5Cl/aarB1A9yzsFFf9EPUEisO5q3PS qAQdoRkOoyMXzuhH9V6fQtCmAvG4hvTXiJJaJM1pEJo3w58FWZGLrOQw5EMb/pgM3Zum 6E4JmMaWrGZ719tLiWtXUHJBf6Vcezs3/Dl59k3cFJ68IFdW2Z+LVONxafWnJviQAyOV Qw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w11xrh80c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:59 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 412EsFn1020426; Fri, 2 Feb 2024 15:04:59 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w11xrh7yt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:59 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 412DAB5N008086; Fri, 2 Feb 2024 15:04:58 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vwdnmku0g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:58 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 412F4tpx39256660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Feb 2024 15:04:55 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E316420049; Fri, 2 Feb 2024 15:04:54 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B15A32004D; Fri, 2 Feb 2024 15:04:54 +0000 (GMT) Received: from a46lp67.lnxne.boe (unknown [9.152.108.100]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Feb 2024 15:04:54 +0000 (GMT) From: Janosch Frank 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 3/7] lib: s390x: ap: Add proper ap setup code Date: Fri, 2 Feb 2024 14:59:09 +0000 Message-Id: <20240202145913.34831-4-frankja@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202145913.34831-1-frankja@linux.ibm.com> References: <20240202145913.34831-1-frankja@linux.ibm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: NjsVL2pp4DYDCq6c3vzgtcPoBGHO31on X-Proofpoint-GUID: P8c4-KXgEHCPAdgXztj8gzQXmg5KIO6n X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-02_08,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 bulkscore=0 suspectscore=0 spamscore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402020109 For the next tests we need a valid queue which means we need to grab the qci info and search the first set bit in the ap and aq masks. Let's move from the stfle 12 check to proper setup code that also returns arrays for the aps and qns. Signed-off-by: Janosch Frank --- lib/s390x/ap.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++--- lib/s390x/ap.h | 17 +++++++++- s390x/ap.c | 4 ++- 3 files changed, 105 insertions(+), 6 deletions(-) diff --git a/lib/s390x/ap.c b/lib/s390x/ap.c index 9560ff64..c85172a8 100644 --- a/lib/s390x/ap.c +++ b/lib/s390x/ap.c @@ -13,10 +13,18 @@ #include #include +#include +#include #include #include #include +static uint8_t num_ap; +static uint8_t num_queue; +static uint8_t *array_ap; +static uint8_t *array_queue; +static struct ap_config_info qci; + int ap_pqap_tapq(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw, struct pqap_r2 *r2) { @@ -82,16 +90,90 @@ int ap_pqap_qci(struct ap_config_info *info) return cc; } -/* Will later be extended to a proper setup function */ -bool ap_setup(void) +static int get_entry(uint8_t *ptr, int i, size_t len) { + /* Skip over the last entry */ + if (i) + i++; + + for (; i < 8 * len; i++) { + /* Do we even need to check the byte? */ + if (!ptr[i / 8]) { + i += 7; + continue; + } + + /* Check the bit in big-endian order */ + if (ptr[i / 8] & BIT(7 - (i % 8))) + return i; + } + return -1; +} + +static void setup_info(void) +{ + int i, entry = 0; + + ap_pqap_qci(&qci); + + for (i = 0; i < AP_ARRAY_MAX_NUM; i++) { + entry = get_entry((uint8_t *)qci.apm, entry, sizeof(qci.apm)); + if (entry == -1) + break; + + if (!num_ap) { + /* + * We have at least one AP, time to + * allocate the queue arrays + */ + array_ap = malloc(AP_ARRAY_MAX_NUM); + array_queue = malloc(AP_ARRAY_MAX_NUM); + } + array_ap[num_ap] = entry; + num_ap += 1; + } + + /* Without an AP we don't even need to look at the queues */ + if (!num_ap) + return; + + entry = 0; + for (i = 0; i < AP_ARRAY_MAX_NUM; i++) { + entry = get_entry((uint8_t *)qci.aqm, entry, sizeof(qci.aqm)); + if (entry == -1) + return; + + array_queue[num_queue] = entry; + num_queue += 1; + } + +} + +int ap_setup(uint8_t **ap_array, uint8_t **qn_array, uint8_t *naps, uint8_t *nqns) +{ + assert(!num_ap); + /* * Base AP support has no STFLE or SCLP feature bit but the * PQAP QCI support is indicated via stfle bit 12. As this * library relies on QCI we bail out if it's not available. */ if (!test_facility(12)) - return false; + return AP_SETUP_NOINSTR; - return true; + /* Setup ap and queue arrays */ + setup_info(); + + if (!num_ap) + return AP_SETUP_NOAPQN; + + /* Only provide the data if the caller actually needs it. */ + if (ap_array && qn_array && naps && nqns) { + *ap_array = array_ap; + *qn_array = array_queue; + *naps = num_ap; + *nqns = num_queue; + } + + return AP_SETUP_READY; } diff --git a/lib/s390x/ap.h b/lib/s390x/ap.h index b806513f..8feca43a 100644 --- a/lib/s390x/ap.h +++ b/lib/s390x/ap.h @@ -81,7 +81,22 @@ struct pqap_r2 { } __attribute__((packed)) __attribute__((aligned(8))); _Static_assert(sizeof(struct pqap_r2) == sizeof(uint64_t), "pqap_r2 size"); -bool ap_setup(void); +/* + * Maximum number of APQNs that we keep track of. + * + * This value is already way larger than the number of APQNs a AP test + * is probably going to use. + */ +#define AP_ARRAY_MAX_NUM 16 + +/* Return values of ap_setup() */ +enum { + AP_SETUP_NOINSTR, /* AP instructions not available */ + AP_SETUP_NOAPQN, /* Instructions available but no APQNs */ + AP_SETUP_READY /* Full setup complete, at least one APQN */ +}; + +int ap_setup(uint8_t **ap_array, uint8_t **qn_array, uint8_t *naps, uint8_t *nqns); 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); diff --git a/s390x/ap.c b/s390x/ap.c index b3cee37a..5c458e7e 100644 --- a/s390x/ap.c +++ b/s390x/ap.c @@ -292,8 +292,10 @@ static void test_priv(void) int main(void) { + int setup_rc = ap_setup(NULL, NULL, NULL, NULL); + report_prefix_push("ap"); - if (!ap_check()) { + if (setup_rc == AP_SETUP_NOINSTR) { report_skip("AP instructions not available"); goto done; } From patchwork Fri Feb 2 14:59:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13542988 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BA1414532F; Fri, 2 Feb 2024 15:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706886302; cv=none; b=tmULkPCQODdJdzGf1SIVNfomYpVeTl6JyT3JRgW/KWaZcyn5g9NnrnyFM48RG3ey+Ycea4o2Ev6FWD0HAzOg24Kt7LHHcpkAS/KtbMkU7lhJT5OFAhcFpsHd/vvpYQwJYr4P36d9PLE0+tPpcFcP+SvNlka8AQ5KtJQJ40TloYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706886302; c=relaxed/simple; bh=panHm4zVut/UkEbKj8tX2qEd5loaII6ZngoJDwNsZB4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y6xby+M6v+QGLj3zla5iMgWhbeMoUmsdItSsVDc5rYwRhfmTA/rCg1ydgvsSCyoUyFHiETOAMlqUJLUmlfdoqayY0aRES/+KLsSDWpx+vFUj+dfnv8qbgOLDyInrIsNAme06zOZnZfkui3pBEcPOd2RML6Otyw5aGJoM6PpD47I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=jq1K6tBQ; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="jq1K6tBQ" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 412EbPMj002743; Fri, 2 Feb 2024 15:05:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=WFxjai1+iiCYjwANt4Zuw89dNfb3lF7ItBOSYloffPs=; b=jq1K6tBQJc7UHbTOQwqwg6QLHjcZ/M8FZHR4558CwmSSVQr4ZkxUSOPWG2rmX9o9JSeG 22sVFizzDukg7e8Im5yFh1m8e9ypeIU0GfRd0l0Xi35dn2U1sqel/31xtNk0stUDCyZF nZJXOsyNrbe7ToR/irqTCXNEgTAzhOPqoYVlShbzG8mIPPZ4gTlmrGzlBK9KZBLVNFrL 7IyOvwlZxwMenvFY5/SwtSw0rED7GIEmalU+hKNshujb5+L77VYLzroYOrQLIkjVmbM+ GRVF9xN0Ap3hYx6Q/FGIU+1l60P3VAlVc1fC3MqkR8LVB/9qFtbsrYBYTrXOX71B1pyP Pg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w107047dy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:59 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 412EcXHB006032; Fri, 2 Feb 2024 15:04:59 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w107047dn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:59 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 412D1hQc011067; Fri, 2 Feb 2024 15:04:58 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vwd5pby3g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:58 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 412F4tbG39256664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Feb 2024 15:04:55 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2812720040; Fri, 2 Feb 2024 15:04:55 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EA7A22004B; Fri, 2 Feb 2024 15:04:54 +0000 (GMT) Received: from a46lp67.lnxne.boe (unknown [9.152.108.100]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Feb 2024 15:04:54 +0000 (GMT) From: Janosch Frank 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 Message-Id: <20240202145913.34831-5-frankja@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202145913.34831-1-frankja@linux.ibm.com> References: <20240202145913.34831-1-frankja@linux.ibm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: gI_UGhRkyPO9NxKSQmAMmr8ONWVGhyYn X-Proofpoint-ORIG-GUID: 88JB_q1w1l0Pm33U6Ma31pAY9pRQWrjg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-02_08,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 clxscore=1015 adultscore=0 priorityscore=1501 malwarescore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402020109 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 --- 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 #include #include +#include +#include #include #include #include +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(); From patchwork Fri Feb 2 14:59:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13542986 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3B9814463E; Fri, 2 Feb 2024 15:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706886302; cv=none; b=u9g9rMjCX4drRHFT6AvxW6AcW21xNz8pO9IU/E22dD8Q+1dFCw3brzxcfidR4wYZRYnINkRAcJ3fUqb6+S7R9ShheO3gKYABDR3OdWdPOXE1yaDtiNdgac9Q/xuJT3dkDGIFb/IEx41xLQWrSv4jh7zFZ9SSM2D+JnCEq2sjYeE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706886302; c=relaxed/simple; bh=IiP1DapoCYTLX94TDLO8I003YHeSMNoiEAnvhhKzTPI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o5tDNR3XkJP+94FNo5chzVabq2JjY/zjBPZMFp13wQJSsJuYmPtWTfozRFvZzpv+ojFMxkVFnJOxbUOBbPiC8bS9E9IxY9sTO0iU/fcQsUCvcpUeGy0BDFpFxY9UDspiQczlnZOevOAjJtSn4De9ORvUNm/9X8hhs+GsyKnEX34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=RkjRuu+g; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="RkjRuu+g" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 412EQAln026156; Fri, 2 Feb 2024 15:05:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=f0FWtmWoIIp/Jg0gGG+86/YfdxPjxR8tjIohKEC++YQ=; b=RkjRuu+gQV6ke0YOc9SCJngtCkTU9Lh8qmOuBfm8xLcvdeMP2eh5M/jwmcWple/Cvp0w nTxNdhzAZe20qP9nFXOE/0EVDv5qOTHAu/1cSwbkGXNlzUBZjvoFBZB5G+ZpOtdYDKf+ RrRZu2M01osZm8cDMSyLD13pPqvvaIwNZHIQh1uCk/13V99mkVzanfF+mtI/I5P/CQfI dDPPdPZnIPwc9bLnRXXNIcc6lWEDTbsKc5E0LtSWhJZOhoBaMkmoInhA51iKM9FNQJbs K822HZxa8HdYudYciYv+K1fKBhHvtWp5qP6CrjVFrCiIwlp/hX7SySyN1/M9xiLAzNlI sQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w11xrh807-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:59 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 412EQSkW027851; Fri, 2 Feb 2024 15:04:59 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w11xrh7yw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:59 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 412CAAsq002319; Fri, 2 Feb 2024 15:04:58 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3vwc5tv76s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:58 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 412F4tFD39256666 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Feb 2024 15:04:55 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6178920040; Fri, 2 Feb 2024 15:04:55 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F75220049; Fri, 2 Feb 2024 15:04:55 +0000 (GMT) Received: from a46lp67.lnxne.boe (unknown [9.152.108.100]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Feb 2024 15:04:55 +0000 (GMT) From: Janosch Frank 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 5/7] s390x: ap: Add reset tests Date: Fri, 2 Feb 2024 14:59:11 +0000 Message-Id: <20240202145913.34831-6-frankja@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202145913.34831-1-frankja@linux.ibm.com> References: <20240202145913.34831-1-frankja@linux.ibm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: eHxIy8wRR5zrLFhgCFCEl71WWkTcIynU X-Proofpoint-GUID: AnbvCq2efQUda3dsGuPpH5PhD_Ss1Z_y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-02_08,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 bulkscore=0 suspectscore=0 spamscore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402020109 Test if the IRQ enablement is turned off on a reset or zeroize PQAP. Signed-off-by: Janosch Frank --- lib/s390x/ap.c | 71 +++++++++++++++++++++++++++++++++++++++++++ lib/s390x/ap.h | 4 +++ s390x/ap.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 154 insertions(+), 2 deletions(-) diff --git a/lib/s390x/ap.c b/lib/s390x/ap.c index 4e7d3d34..0f92739d 100644 --- a/lib/s390x/ap.c +++ b/lib/s390x/ap.c @@ -125,6 +125,77 @@ int ap_pqap_qci(struct ap_config_info *info) return cc; } +static int pqap_reset(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw, + bool zeroize) +{ + uint64_t bogus_cc = 2; + struct pqap_r0 r0 = {}; + int cc; + + /* + * Reset/zeroize AP Queue + * + * Resets/zeroizes a queue and disables IRQs + * + * Inputs: GR0 + * Outputs: GR1 (APQSW) + * Asynchronous + */ + r0.ap = ap; + r0.qn = qn; + r0.fc = zeroize ? PQAP_ZEROIZE_APQ : PQAP_RESET_APQ; + asm volatile( + " tmll %[bogus_cc],3\n" + " lgr 0,%[r0]\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), [bogus_cc] "d" (bogus_cc) + : "memory"); + + return cc; +} + +static int pqap_reset_wait(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw, + bool zeroize) +{ + struct pqap_r2 r2 = {}; + int cc; + + cc = pqap_reset(ap, qn, apqsw, zeroize); + + /* On a cc == 3 / error we don't need to wait */ + if (cc) + return cc; + + /* + * TAPQ returns AP_RC_RESET_IN_PROGRESS if a reset is being + * processed + */ + do { + /* Give it some time to process before the retry */ + mdelay(20); + cc = ap_pqap_tapq(ap, qn, apqsw, &r2); + } while (apqsw->rc == AP_RC_RESET_IN_PROGRESS); + + if (apqsw->rc) + printf("Wait for reset failed on ap %d queue %d with tapq rc %d.", + ap, qn, apqsw->rc); + return cc; +} + +int ap_pqap_reset(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw) +{ + return pqap_reset_wait(ap, qn, apqsw, false); +} + +int ap_pqap_reset_zeroize(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw) +{ + return pqap_reset_wait(ap, qn, apqsw, true); +} + static int get_entry(uint8_t *ptr, int i, size_t len) { /* Skip over the last entry */ diff --git a/lib/s390x/ap.h b/lib/s390x/ap.h index 15394d56..dbdb55c4 100644 --- a/lib/s390x/ap.h +++ b/lib/s390x/ap.h @@ -14,6 +14,8 @@ #ifndef _S390X_AP_H_ #define _S390X_AP_H_ +#define AP_RC_RESET_IN_PROGRESS 0x02 + enum PQAP_FC { PQAP_TEST_APQ, PQAP_RESET_APQ, @@ -108,6 +110,8 @@ enum { int ap_setup(uint8_t **ap_array, uint8_t **qn_array, uint8_t *naps, uint8_t *nqns); int ap_pqap_tapq(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw, struct pqap_r2 *r2); +int ap_pqap_reset(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw); +int ap_pqap_reset_zeroize(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw); 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); diff --git a/s390x/ap.c b/s390x/ap.c index 6f95a716..38be03eb 100644 --- a/s390x/ap.c +++ b/s390x/ap.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -346,6 +347,80 @@ static void test_pqap_aqic(void) free_io_mem(not_ind_byte, PAGE_SIZE); } +static void test_pqap_resets(void) +{ + uint8_t *not_ind_byte = alloc_io_mem(sizeof(*not_ind_byte), 0); + struct ap_queue_status apqsw = {}; + struct ap_qirq_ctrl aqic = {}; + struct pqap_r2 r2 = {}; + + int cc; + + report_prefix_push("rapq"); + + /* Enable IRQs which the resets will disable */ + aqic.ir = 1; + cc = ap_pqap_aqic(apn, qn, &apqsw, aqic, (uintptr_t)not_ind_byte); + report(cc == 0 && apqsw.rc == 0, "enable IRQs for reset tests"); + + do { + mdelay(20); + cc = ap_pqap_tapq(apn, qn, &apqsw, &r2); + } while (cc == 0 && apqsw.irq_enabled == 0); + report(apqsw.irq_enabled == 1, "IRQs enabled tapq data"); + + ap_pqap_reset(apn, qn, &apqsw); + cc = ap_pqap_tapq(apn, qn, &apqsw, &r2); + assert(!cc); + report(apqsw.irq_enabled == 0, "IRQs have been disabled via reset"); + + report_prefix_pop(); + + report_prefix_push("zapq"); + + /* Enable IRQs which the resets will disable */ + aqic.ir = 1; + cc = ap_pqap_aqic(apn, qn, &apqsw, aqic, (uintptr_t)not_ind_byte); + report(cc == 0 && apqsw.rc == 0, "enable IRQs for reset tests"); + + do { + mdelay(20); + cc = ap_pqap_tapq(apn, qn, &apqsw, &r2); + } while (cc == 0 && apqsw.irq_enabled == 0); + report(apqsw.irq_enabled == 1, "IRQs enabled tapq data"); + + ap_pqap_reset_zeroize(apn, qn, &apqsw); + cc = ap_pqap_tapq(apn, qn, &apqsw, &r2); + assert(!cc); + report(apqsw.irq_enabled == 0, "IRQs have been disabled via reset"); + + report_prefix_pop(); + /* + * This is a wrinkle in the architecture for PV guests. + * + * The notification byte is pinned shared for PV guests. + * RAPQ, ZAPQ and AQIC can all disable IRQs but there's no + * intercept for resets triggered by a PV guests. Hence the + * host keeps the notification byte page pinned UNTIL IRQs are + * disabled via AQIC. + * + * Firmware will not generate an intercept if the IRQs have + * already been disabled via a reset. Therefore we need to + * enable AND disable to achieve a disable. + */ + if (uv_os_is_guest()) { + aqic.ir = 1; + cc = ap_pqap_aqic(apn, qn, &apqsw, aqic, + (uintptr_t)not_ind_byte); + assert(cc == 0 && apqsw.rc == 0); + aqic.ir = 0; + cc = ap_pqap_aqic(apn, qn, &apqsw, aqic, + (uintptr_t)not_ind_byte); + assert(cc == 0 && apqsw.rc == 0); + } + free_io_mem(not_ind_byte, sizeof(*not_ind_byte)); +} + int main(void) { uint8_t num_ap, num_qn; @@ -372,10 +447,12 @@ int main(void) apn = apns[0]; qn = qns[0]; report_prefix_push("pqap"); - if (test_facility(65)) + if (test_facility(65)) { test_pqap_aqic(); - else + test_pqap_resets(); + } else { report_skip("no AQIC and reset tests without IRQ support"); + } report_prefix_pop(); done: From patchwork Fri Feb 2 14:59:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13542989 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5093314460C; Fri, 2 Feb 2024 15:05:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706886302; cv=none; b=nc2C88/YSvER1xflZXX5nHbOmcayiAOBnfw18jLcisx828pP2t1Sa/ywTKyx8gFhGYTXQ5EIqARO9WFg8ppX9mnMoLwvB3ySzl35L/oXvzdTLM7PgtFH5qR/NJ6zmJZ2WfNQP/fTDHHoJVIlfy8LIZdSjAr+5jz2zVUDwTLmP0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706886302; c=relaxed/simple; bh=5DykbETaFC8/kXeuRlJdARzFuxa9jHVckC26OSsoB1g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Mvd1ddIsWEF5FAYKr+5a1Psj0bq9OGc7Lt0hrgB5Kf3NMT6cQ88tyeHzGGS+D8Vz9SGSqb6vmT2HTXvwZvUZgO0Daeq9O0dBK+qmoE0vIyxwpC2nTRX9NDVopc9XxsnVl9dptdpsd2gmLdf30CJ19myzIVdpR1Leg8SsueYOzLU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=TlaThN+h; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="TlaThN+h" Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 412ESufP031624; Fri, 2 Feb 2024 15:05:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=G+LQT30CZNgtSLOdDA0EJOZIFJnT7ca3g4mM8ucJEu4=; b=TlaThN+h2UNKzplTz6ARxNFwLgFpb960ySYN4Vwbcry2UTP6fYUHK5y7YS+mfj+9Efku GVySyAUnoZp/K0MhvmdmZWKXFTSLTp5UiHsF4dxgIcoAuVdCDr8DkNO0Q75zV4sz7Oxt 557YCd2NT4oMEnPoU8Xx2v4DagkDiPsK7f4hKGOaJ980b7PlsCfMdHLyCAu+8nLZEGFX +sY8S26OF62606l+EpUwiydIAQ4LICdDzOgDz0LpVEXYWtrQr94b3pdHsB+78xAuhbOi I6eECWKUUNDsvQAohWVE9uEHe2hW9nPOUFHYlKTtrK2f5oPWCJ08Dx9sFLgKnmLirNN3 3A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w126h8v4a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:59 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 412EtDiI030218; Fri, 2 Feb 2024 15:04:59 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w126h8v42-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:59 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 412E7SAx011266; Fri, 2 Feb 2024 15:04:58 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3vwecm3nrh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:58 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 412F4toG39256668 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Feb 2024 15:04:55 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9A5AA20040; Fri, 2 Feb 2024 15:04:55 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 689C12004B; Fri, 2 Feb 2024 15:04:55 +0000 (GMT) Received: from a46lp67.lnxne.boe (unknown [9.152.108.100]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Feb 2024 15:04:55 +0000 (GMT) From: Janosch Frank 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 6/7] lib: s390x: ap: Add tapq test facility bit Date: Fri, 2 Feb 2024 14:59:12 +0000 Message-Id: <20240202145913.34831-7-frankja@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202145913.34831-1-frankja@linux.ibm.com> References: <20240202145913.34831-1-frankja@linux.ibm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: UIX90UWWKwA_bF8mJ_khizgpaPTfjxm6 X-Proofpoint-ORIG-GUID: kXfGID948-HF8jlQuVwW_YG5th6n64GG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-02_08,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 phishscore=0 suspectscore=0 bulkscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402020109 When the t bit is one the first 32 bits of register 2 are populated on a tapq. Those bits tell us in which mode the queu is and which facilities it supports. Signed-off-by: Janosch Frank --- lib/s390x/ap.c | 5 +++-- lib/s390x/ap.h | 2 +- s390x/ap.c | 12 ++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/s390x/ap.c b/lib/s390x/ap.c index 0f92739d..64705a56 100644 --- a/lib/s390x/ap.c +++ b/lib/s390x/ap.c @@ -26,11 +26,12 @@ static uint8_t *array_queue; static struct ap_config_info qci; int ap_pqap_tapq(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw, - struct pqap_r2 *r2) + struct pqap_r2 *r2, bool t) { struct pqap_r0 r0 = { .ap = ap, .qn = qn, + .t = t, .fc = PQAP_TEST_APQ }; uint64_t bogus_cc = 2; @@ -177,7 +178,7 @@ static int pqap_reset_wait(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw do { /* Give it some time to process before the retry */ mdelay(20); - cc = ap_pqap_tapq(ap, qn, apqsw, &r2); + cc = ap_pqap_tapq(ap, qn, apqsw, &r2, false); } while (apqsw->rc == AP_RC_RESET_IN_PROGRESS); if (apqsw->rc) diff --git a/lib/s390x/ap.h b/lib/s390x/ap.h index dbdb55c4..eecb39be 100644 --- a/lib/s390x/ap.h +++ b/lib/s390x/ap.h @@ -109,7 +109,7 @@ enum { int ap_setup(uint8_t **ap_array, uint8_t **qn_array, uint8_t *naps, uint8_t *nqns); int ap_pqap_tapq(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw, - struct pqap_r2 *r2); + struct pqap_r2 *r2, bool t); int ap_pqap_reset(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw); int ap_pqap_reset_zeroize(uint8_t ap, uint8_t qn, struct ap_queue_status *apqsw); int ap_pqap_qci(struct ap_config_info *info); diff --git a/s390x/ap.c b/s390x/ap.c index 38be03eb..0f2d03c2 100644 --- a/s390x/ap.c +++ b/s390x/ap.c @@ -325,7 +325,7 @@ static void test_pqap_aqic(void) do { mdelay(20); - cc = ap_pqap_tapq(apn, qn, &apqsw, &r2); + cc = ap_pqap_tapq(apn, qn, &apqsw, &r2, false); } while (cc == 0 && apqsw.irq_enabled == 0); report(cc == 0 && apqsw.irq_enabled == 1, "enable IRQs tapq data"); @@ -338,7 +338,7 @@ static void test_pqap_aqic(void) do { mdelay(20); - cc = ap_pqap_tapq(apn, qn, &apqsw, &r2); + cc = ap_pqap_tapq(apn, qn, &apqsw, &r2, false); } while (cc == 0 && apqsw.irq_enabled == 1); report(cc == 0 && apqsw.irq_enabled == 0, "disable IRQs tapq data"); @@ -365,12 +365,12 @@ static void test_pqap_resets(void) do { mdelay(20); - cc = ap_pqap_tapq(apn, qn, &apqsw, &r2); + cc = ap_pqap_tapq(apn, qn, &apqsw, &r2, false); } while (cc == 0 && apqsw.irq_enabled == 0); report(apqsw.irq_enabled == 1, "IRQs enabled tapq data"); ap_pqap_reset(apn, qn, &apqsw); - cc = ap_pqap_tapq(apn, qn, &apqsw, &r2); + cc = ap_pqap_tapq(apn, qn, &apqsw, &r2, false); assert(!cc); report(apqsw.irq_enabled == 0, "IRQs have been disabled via reset"); @@ -385,12 +385,12 @@ static void test_pqap_resets(void) do { mdelay(20); - cc = ap_pqap_tapq(apn, qn, &apqsw, &r2); + cc = ap_pqap_tapq(apn, qn, &apqsw, &r2, false); } while (cc == 0 && apqsw.irq_enabled == 0); report(apqsw.irq_enabled == 1, "IRQs enabled tapq data"); ap_pqap_reset_zeroize(apn, qn, &apqsw); - cc = ap_pqap_tapq(apn, qn, &apqsw, &r2); + cc = ap_pqap_tapq(apn, qn, &apqsw, &r2, false); assert(!cc); report(apqsw.irq_enabled == 0, "IRQs have been disabled via reset"); From patchwork Fri Feb 2 14:59:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13542990 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99DBB145346; Fri, 2 Feb 2024 15:05:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706886303; cv=none; b=spbVLI32ZSn0P0HCR45suVfVzmbL0vusgYCpT86Ni7QPPVCyNjDREpT83in8Wz6S7dfIGlD2GtCAgQL3Pwk+Xj2XhHQonwilK+CH8NI2hAQGxj1TfRT18SaZ7Q4iw21XRPt5Nqc8atRriF1Hjb2Xy2NMLULdqwTMQGrFh9FWMqg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706886303; c=relaxed/simple; bh=MmHFruIEQPPNV6IzR8a9y1V2kpuZAhG2jGPaYq6CLUQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jR++jaMTEEOBoTxmgjSPC5zWtVBkzAu0hW1pgDHCQHm8o8dD1rwJb6eol4L+gUvgKM/nfo51AoR+V7L7lZqlIzvHM6ZOfQeIoVTe+OKlj/By4GV1Y9jlYrtIfMYaZn8mXK3tiamFmoN7Ro0D5CTVIaE8//hPMQgP/UIflSDxzFk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=jUdx4xjU; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="jUdx4xjU" Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 412DlEmQ028249; Fri, 2 Feb 2024 15:05:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=PlxEm0GI6NfvVvLPF4GC52hpl5uvmNkqBPfzvMvCxpc=; b=jUdx4xjUD2+GbZ/ont1s/53HxYsuGvMgsBccpayCs2p12O/3xgAipNJlNzIN2B0SLZQw hLdtP89EjqY01//pnWqYxpfDhOhQNaWx53HrY893HdSxr2vf+7WJbk/a0NHeqSvmguvV 31dhQ/CHVFggPvgYBg1+05WeFC6n4itqBi+9Bd9CndSDnpqg0kSoQNZZWV4UCx1E8C1Z kqymWm3ytS74snDhJ/ykw7D+V8diBs+yIdkBP0gBDC0CkTIzHiQdUVDf4d+qU2dmi4er REUWizGm2ODiyCEbcPn7TifOBZvcAOp/vyUCy+PnO4NqKK0XMI8dbCU7wPkbmy+tMztq Ew== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w11k0t01e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:05:00 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 412ExjWN019791; Fri, 2 Feb 2024 15:04:59 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w11k0t011-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:59 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 412DZDFM007188; Fri, 2 Feb 2024 15:04:58 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3vwev2ujpf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Feb 2024 15:04:58 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 412F4t5Y39256670 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Feb 2024 15:04:56 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D3BA92004B; Fri, 2 Feb 2024 15:04:55 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A1C1720049; Fri, 2 Feb 2024 15:04:55 +0000 (GMT) Received: from a46lp67.lnxne.boe (unknown [9.152.108.100]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Feb 2024 15:04:55 +0000 (GMT) From: Janosch Frank 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 7/7] s390x: ap: Add nq/dq len test Date: Fri, 2 Feb 2024 14:59:13 +0000 Message-Id: <20240202145913.34831-8-frankja@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202145913.34831-1-frankja@linux.ibm.com> References: <20240202145913.34831-1-frankja@linux.ibm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: QZN35oTWpnaN1SopNV_bX_iFmPxdVnb9 X-Proofpoint-ORIG-GUID: lfGUVY64yK9SIsMQ1Wj2tQ4Wumrbw2T2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-02_08,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 suspectscore=0 impostorscore=0 phishscore=0 malwarescore=0 adultscore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402020109 For years the nqap/dqap max length was 12KB but with a recent machine extended message length support was introduced. The support is AP type and generation specific, so it can vary from card to card which complicates testing by a lot. This test will use the APQN that all other tests use no matter if there's extended length support or not. But if longer messages are supported by the APQN we need to adapt our tests. Signed-off-by: Janosch Frank --- lib/s390x/ap.h | 3 +- s390x/ap.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 1 deletion(-) diff --git a/lib/s390x/ap.h b/lib/s390x/ap.h index eecb39be..792149ea 100644 --- a/lib/s390x/ap.h +++ b/lib/s390x/ap.h @@ -77,7 +77,8 @@ struct pqap_r2 { uint8_t pad_1[3]; uint8_t at; uint8_t nd; - uint8_t pad_6; + uint8_t pad_6 : 4; + uint8_t ml : 4; uint8_t pad_7 : 4; uint8_t qd : 4; } __attribute__((packed)) __attribute__((aligned(8))); diff --git a/s390x/ap.c b/s390x/ap.c index 0f2d03c2..edb4943b 100644 --- a/s390x/ap.c +++ b/s390x/ap.c @@ -257,6 +257,106 @@ static void test_pgms_dqap(void) report_prefix_pop(); } +/* + * For years the nqap/dqap max length was 12KB but with a recent + * machine extended message length support was introduced. The support + * is AP type and generation specific, so it can vary from card to + * card. + * + * This test will use the APQN that all other tests use no matter if + * there's extended length support or not. But if longer messages are + * supported by the APQN we need to adapt our tests. + */ +static void test_pgms_nqdq_len(void) +{ + struct ap_queue_status apqsw = {}; + struct pqap_r2 r2 = {}; + uint64_t len, mlen; + bool fail; + int i; + + /* Extended message support is reported via tapq with T=1 */ + ap_pqap_tapq(apn, qn, &apqsw, &r2, true); + /* < 3 means 3 because of backwards compatibility */ + mlen = r2.ml ? r2.ml : 3; + /* Len is reported in pages */ + mlen *= PAGE_SIZE; + + report_prefix_push("nqap"); + report_prefix_push("spec"); + + report_prefix_push("len + 1"); + expect_pgm_int(); + len = mlen + 1; + asm volatile ( + "lg 5, 0(%[len])\n" + ".insn rre,0xb2ae0000,2,4\n" + : : [len] "a" (&len) + : "cc", "memory", "0", "1", "2", "3", "4", "5", "6", "7"); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + report_prefix_pop(); + + report_prefix_push("len bits"); + fail = false; + for (i = 12; i < 63; i++) { + len = BIT(i); + if (len < mlen) + continue; + expect_pgm_int(); + asm volatile ( + "lg 5, 0(%[len])\n" + ".insn rre,0xb2ae0000,2,4\n" + : : [len] "a" (&len) + : "cc", "memory", "0", "1", "2", "3", "4", "5", "6", "7"); + if (clear_pgm_int() != PGM_INT_CODE_SPECIFICATION) { + report_fail("setting len to %lx did not result in a spec exception", + len); + fail = true; + } + } + report(!fail, "length pgms"); + report_prefix_pop(); + report_prefix_pop(); + report_prefix_pop(); + + report_prefix_push("dqap"); + report_prefix_push("spec"); + + report_prefix_push("len + 1"); + expect_pgm_int(); + len = mlen + 1; + asm volatile ( + "lg 5, 0(%[len])\n" + ".insn rre,0xb2ae0000,2,4\n" + : : [len] "a" (&len) + : "cc", "memory", "0", "1", "2", "3", "4", "5", "6", "7"); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + report_prefix_pop(); + + report_prefix_push("len bits"); + fail = false; + for (i = 12; i < 63; i++) { + len = BIT(i); + if (len < mlen) + continue; + expect_pgm_int(); + asm volatile ( + "lg 5, 0(%[len])\n" + ".insn rre,0xb2ae0000,2,4\n" + : : [len] "a" (&len) + : "cc", "memory", "0", "1", "2", "3", "4", "5", "6", "7"); + if (clear_pgm_int() != PGM_INT_CODE_SPECIFICATION) { + report_fail("setting len to %lx did not result in a spec exception", + len); + fail = true; + } + } + report(!fail, "length pgms"); + report_prefix_pop(); + report_prefix_pop(); + report_prefix_pop(); +} + static void test_priv(void) { struct ap_config_info info = {}; @@ -446,6 +546,9 @@ int main(void) } apn = apns[0]; qn = qns[0]; + + test_pgms_nqdq_len(); + report_prefix_push("pqap"); if (test_facility(65)) { test_pqap_aqic();