From patchwork Fri Feb 4 21:15:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BA61C433EF for ; Fri, 4 Feb 2022 21:15:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240956AbiBDVPu (ORCPT ); Fri, 4 Feb 2022 16:15:50 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:16526 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240851AbiBDVPt (ORCPT ); Fri, 4 Feb 2022 16:15:49 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214IXY89027237; Fri, 4 Feb 2022 21:15:48 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=1xVZwa3vwt/HF1lclyXphUXAO+MGMYBvVG9KsrIDc3c=; b=cE96uiK8yOCE7D+hi09nSNWzzPmXcu/84NJ0yHRsPqmtDxCb7WDhY6XuhgHU49U6nokk bVNyuSxkeaZrFfa/quZ3siy6qvQKYdOPWSp9B5VB0SH6FqiTHGQrhqP2xt/kkQtg1LnU VAXZhcD3lkW6qAz+Lgk3XG/pcKMMFEPtsGGbzTn+VJAIDu5Kqnpu2IZSV0NjkYYjOpI6 vOHymvYkwJiJEFoDhAN/sQAz0LFpAtT7VkRhJ8XYN+tezNBjOGM4mfpYBHL2PoGz7fER OZemUugvY7gl6poE0OTBTyN+TpLh+qCCwUDufHTje9O3rB+0VVzXo9OhUG1pLGHq2b2H Nw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0rt5nmj7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:48 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214LBZeJ011250; Fri, 4 Feb 2022 21:15:48 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0rt5nmhv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:48 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCaZY021807; Fri, 4 Feb 2022 21:15:47 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma03dal.us.ibm.com with ESMTP id 3e0r0k7ghy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:47 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LFjdJ17695016 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:15:45 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2848213605D; Fri, 4 Feb 2022 21:15:45 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 47B73136053; Fri, 4 Feb 2022 21:15:43 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:15:43 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Christian Borntraeger Subject: [PATCH v3 01/30] s390/sclp: detect the zPCI load/store interpretation facility Date: Fri, 4 Feb 2022 16:15:07 -0500 Message-Id: <20220204211536.321475-2-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: yFLQEomQFqZ8xFQI04Yn3vCevkehWrob X-Proofpoint-ORIG-GUID: JZYJugefJUlewIszMQ47XAFzk8b6PfeT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 adultscore=0 phishscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Detect the zPCI Load/Store Interpretation facility. Reviewed-by: Eric Farman Reviewed-by: Christian Borntraeger Reviewed-by: Claudio Imbrenda Signed-off-by: Matthew Rosato --- arch/s390/include/asm/sclp.h | 1 + drivers/s390/char/sclp_early.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/s390/include/asm/sclp.h b/arch/s390/include/asm/sclp.h index c68ea35de498..58a4d3d354b7 100644 --- a/arch/s390/include/asm/sclp.h +++ b/arch/s390/include/asm/sclp.h @@ -88,6 +88,7 @@ struct sclp_info { unsigned char has_diag318 : 1; unsigned char has_sipl : 1; unsigned char has_dirq : 1; + unsigned char has_zpci_lsi : 1; unsigned int ibc; unsigned int mtid; unsigned int mtid_cp; diff --git a/drivers/s390/char/sclp_early.c b/drivers/s390/char/sclp_early.c index e9943a86c361..b88dd0da1231 100644 --- a/drivers/s390/char/sclp_early.c +++ b/drivers/s390/char/sclp_early.c @@ -45,6 +45,7 @@ static void __init sclp_early_facilities_detect(void) sclp.has_gisaf = !!(sccb->fac118 & 0x08); sclp.has_hvs = !!(sccb->fac119 & 0x80); sclp.has_kss = !!(sccb->fac98 & 0x01); + sclp.has_zpci_lsi = !!(sccb->fac118 & 0x01); if (sccb->fac85 & 0x02) S390_lowcore.machine_flags |= MACHINE_FLAG_ESOP; if (sccb->fac91 & 0x40) From patchwork Fri Feb 4 21:15:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 795ECC43217 for ; Fri, 4 Feb 2022 21:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241174AbiBDVP4 (ORCPT ); Fri, 4 Feb 2022 16:15:56 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:18540 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240981AbiBDVPv (ORCPT ); Fri, 4 Feb 2022 16:15:51 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214JbI6m017318; Fri, 4 Feb 2022 21:15:50 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=OShdjVsFdq8pPbyHlzBZuQcciLXc3V5VtNf4P65ZqMQ=; b=IAv4rTNSqUTyLNA7lCjqAznmWcxnrs4C9yCxjFFSiTVMpaEUVixposKJxCdvWhp6hcar EbCproS8qPqI40+vh7X+3/GOu9pSUEZANnS1iP9tHJ09E+2PVzkKP5JSCHP1buDaE3k+ jjcJaKpXm/wY5kYi5LxOh6ZRmV6WnAnvseqBJ02QNrT0rF/+mHw+S5q675DJszU5qctU 1iUCapq9Jv6AlRgLVkfw4BfrZQiSraEc75cITUZZ5IftvsPye05P7t7v0W9nMCx5XeGn S92Wlq7ul4F257J4JcRfZeJeuEEcnF+LMD7jYLvGT4GD6zPZ39haFc4nv5k7KJj3P8Pv +Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx9evpg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:50 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214L3orA018555; Fri, 4 Feb 2022 21:15:49 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx9evp8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:49 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LDGcs029628; Fri, 4 Feb 2022 21:15:49 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma04wdc.us.ibm.com with ESMTP id 3e0r0vaunn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:49 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LFlWk12059080 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:15:47 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 462E813605D; Fri, 4 Feb 2022 21:15:47 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C3E1136051; Fri, 4 Feb 2022 21:15:45 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:15:45 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Christian Borntraeger Subject: [PATCH v3 02/30] s390/sclp: detect the AISII facility Date: Fri, 4 Feb 2022 16:15:08 -0500 Message-Id: <20220204211536.321475-3-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: U96u-8TWyCWCmzx0oHT5lwXdW8j3VHuA X-Proofpoint-ORIG-GUID: El_EZEMk01pzoaCntE925DPXW_tkcHhh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 spamscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=881 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Detect the Adapter Interruption Source ID Interpretation facility. Reviewed-by: Eric Farman Reviewed-by: Christian Borntraeger Reviewed-by: Claudio Imbrenda Signed-off-by: Matthew Rosato --- arch/s390/include/asm/sclp.h | 1 + drivers/s390/char/sclp_early.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/s390/include/asm/sclp.h b/arch/s390/include/asm/sclp.h index 58a4d3d354b7..8b56ac5ae496 100644 --- a/arch/s390/include/asm/sclp.h +++ b/arch/s390/include/asm/sclp.h @@ -89,6 +89,7 @@ struct sclp_info { unsigned char has_sipl : 1; unsigned char has_dirq : 1; unsigned char has_zpci_lsi : 1; + unsigned char has_aisii : 1; unsigned int ibc; unsigned int mtid; unsigned int mtid_cp; diff --git a/drivers/s390/char/sclp_early.c b/drivers/s390/char/sclp_early.c index b88dd0da1231..29fee179e197 100644 --- a/drivers/s390/char/sclp_early.c +++ b/drivers/s390/char/sclp_early.c @@ -45,6 +45,7 @@ static void __init sclp_early_facilities_detect(void) sclp.has_gisaf = !!(sccb->fac118 & 0x08); sclp.has_hvs = !!(sccb->fac119 & 0x80); sclp.has_kss = !!(sccb->fac98 & 0x01); + sclp.has_aisii = !!(sccb->fac118 & 0x40); sclp.has_zpci_lsi = !!(sccb->fac118 & 0x01); if (sccb->fac85 & 0x02) S390_lowcore.machine_flags |= MACHINE_FLAG_ESOP; From patchwork Fri Feb 4 21:15:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735648 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B46C8C433F5 for ; Fri, 4 Feb 2022 21:15:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241399AbiBDVP5 (ORCPT ); Fri, 4 Feb 2022 16:15:57 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:23834 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241056AbiBDVPx (ORCPT ); Fri, 4 Feb 2022 16:15:53 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214KdQtG026460; Fri, 4 Feb 2022 21:15:53 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=n1nLl74XPlYJotGlgTzMIMN6FGGU2TFWaA4eTx5Ggx8=; b=OL3Os5Kf83scRjvUG7lUXa25tJU7d/F5XA9VSpY08By485IYdyhYWRi3FgCCtub2lz3S 4CFxx3Fp9M3R48vFejixw4mkOZKXGvXJ8zOHYDQtEn+Lpjx4G9Nu8aYRcxUuSuefDG7c Ld0YyY0aZq1QPeutJxHP7M1KF/h4uP0P2N/UWJuTbyERGcc5Xfqo5AHtbr70mnsnl0tN Fd1r+yFFmwJLWujOzT0DwpmuhNmwGl/26pIg9LMMpvgMMQeuQixBHMAdGZhTU61uqiD4 jo0+kVMlS9iiW3PA983utHgAsPHlc4jErVVxLN8vw1UOAKKFVvDsi2jMpGHzwxWn50Gn uw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0w6tsqsk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:52 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214Kl2sA031523; Fri, 4 Feb 2022 21:15:52 GMT Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0w6tsqsb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:52 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCpXY008584; Fri, 4 Feb 2022 21:15:51 GMT Received: from b03cxnp07027.gho.boulder.ibm.com (b03cxnp07027.gho.boulder.ibm.com [9.17.130.14]) by ppma02dal.us.ibm.com with ESMTP id 3e0r0pyewc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:51 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LFngW28443102 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:15:49 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4CC6E136053; Fri, 4 Feb 2022 21:15:49 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7363313606A; Fri, 4 Feb 2022 21:15:47 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:15:47 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 03/30] s390/sclp: detect the AENI facility Date: Fri, 4 Feb 2022 16:15:09 -0500 Message-Id: <20220204211536.321475-4-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Lk8904PsrTv-r6MxqBBfkKvI_swgK-nt X-Proofpoint-ORIG-GUID: c7YrkTn0z1Gcm1l-rN_ujYHj0sPoFuYt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 mlxlogscore=982 lowpriorityscore=0 mlxscore=0 clxscore=1015 malwarescore=0 bulkscore=0 spamscore=0 priorityscore=1501 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Detect the Adapter Event Notification Interpretation facility. Reviewed-by: Eric Farman Reviewed-by: Christian Borntraeger Reviewed-by: Claudio Imbrenda Signed-off-by: Matthew Rosato --- arch/s390/include/asm/sclp.h | 1 + drivers/s390/char/sclp_early.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/s390/include/asm/sclp.h b/arch/s390/include/asm/sclp.h index 8b56ac5ae496..8c2e142000d4 100644 --- a/arch/s390/include/asm/sclp.h +++ b/arch/s390/include/asm/sclp.h @@ -90,6 +90,7 @@ struct sclp_info { unsigned char has_dirq : 1; unsigned char has_zpci_lsi : 1; unsigned char has_aisii : 1; + unsigned char has_aeni : 1; unsigned int ibc; unsigned int mtid; unsigned int mtid_cp; diff --git a/drivers/s390/char/sclp_early.c b/drivers/s390/char/sclp_early.c index 29fee179e197..e9af01b4c97a 100644 --- a/drivers/s390/char/sclp_early.c +++ b/drivers/s390/char/sclp_early.c @@ -46,6 +46,7 @@ static void __init sclp_early_facilities_detect(void) sclp.has_hvs = !!(sccb->fac119 & 0x80); sclp.has_kss = !!(sccb->fac98 & 0x01); sclp.has_aisii = !!(sccb->fac118 & 0x40); + sclp.has_aeni = !!(sccb->fac118 & 0x20); sclp.has_zpci_lsi = !!(sccb->fac118 & 0x01); if (sccb->fac85 & 0x02) S390_lowcore.machine_flags |= MACHINE_FLAG_ESOP; From patchwork Fri Feb 4 21:15:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33E9DC433F5 for ; Fri, 4 Feb 2022 21:16:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241517AbiBDVP6 (ORCPT ); Fri, 4 Feb 2022 16:15:58 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:46858 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241118AbiBDVPz (ORCPT ); Fri, 4 Feb 2022 16:15:55 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214KOw3d011613; Fri, 4 Feb 2022 21:15:55 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=tHpyg0lf5dv+bNJqi732xFzvwsPLsdw4+g52/oHOOkw=; b=T/QJRDs4bUcRmgIXP5dO1OtOo7b6q9YcgFrGhEmelyIDZejCIaXVp7OOqjNKV5jAUxRT PFMiBp15xozfF3UPEvHHvDJ3iHjNRa+5la5smPIuuPWIvBcLpsHJ+jNQlA1bOhIBzSoX ds3TgpF3BbIA42/4Id1TY/MjhXh1SwujrlTamw+GuixMRB2B4Pl89PNlj4h2ytN1rard 1WmiX5AMsCEMm+HHHKBGXiQBDVAn+wxqOA5ngoRa4iPPZAIHQNPrMWoZaQ500+4BQ0Nb 8r9QFRk/ItW88g7E3sITH0nU3amW1/gPvoZwjtHNSg8ejXENsdzaRD/IV7b7NKD4u1V7 Zg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0qxg73nd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:54 +0000 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214L1Al6028077; Fri, 4 Feb 2022 21:15:54 GMT Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0qxg73n7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:54 +0000 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCfsw011943; Fri, 4 Feb 2022 21:15:53 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma05wdc.us.ibm.com with ESMTP id 3e0r0m2w81-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:53 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LFp5D35717522 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:15:51 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A6E313606A; Fri, 4 Feb 2022 21:15:51 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 706F5136060; Fri, 4 Feb 2022 21:15:49 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:15:49 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 04/30] s390/sclp: detect the AISI facility Date: Fri, 4 Feb 2022 16:15:10 -0500 Message-Id: <20220204211536.321475-5-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: q17O_2e-y0evuXwiI2hoQ7Sk8wZDriJW X-Proofpoint-ORIG-GUID: qFrixvf2rIcIg7_4-A3-FNi7XyASloos X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 mlxlogscore=883 clxscore=1015 lowpriorityscore=0 adultscore=0 mlxscore=0 spamscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Detect the Adapter Interruption Suppression Interpretation facility. Reviewed-by: Eric Farman Reviewed-by: Christian Borntraeger Reviewed-by: Claudio Imbrenda Signed-off-by: Matthew Rosato --- arch/s390/include/asm/sclp.h | 1 + drivers/s390/char/sclp_early.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/s390/include/asm/sclp.h b/arch/s390/include/asm/sclp.h index 8c2e142000d4..33b174007848 100644 --- a/arch/s390/include/asm/sclp.h +++ b/arch/s390/include/asm/sclp.h @@ -91,6 +91,7 @@ struct sclp_info { unsigned char has_zpci_lsi : 1; unsigned char has_aisii : 1; unsigned char has_aeni : 1; + unsigned char has_aisi : 1; unsigned int ibc; unsigned int mtid; unsigned int mtid_cp; diff --git a/drivers/s390/char/sclp_early.c b/drivers/s390/char/sclp_early.c index e9af01b4c97a..c13e55cc4a5d 100644 --- a/drivers/s390/char/sclp_early.c +++ b/drivers/s390/char/sclp_early.c @@ -47,6 +47,7 @@ static void __init sclp_early_facilities_detect(void) sclp.has_kss = !!(sccb->fac98 & 0x01); sclp.has_aisii = !!(sccb->fac118 & 0x40); sclp.has_aeni = !!(sccb->fac118 & 0x20); + sclp.has_aisi = !!(sccb->fac118 & 0x10); sclp.has_zpci_lsi = !!(sccb->fac118 & 0x01); if (sccb->fac85 & 0x02) S390_lowcore.machine_flags |= MACHINE_FLAG_ESOP; From patchwork Fri Feb 4 21:15:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735650 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16A76C4332F for ; Fri, 4 Feb 2022 21:16:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241102AbiBDVQC (ORCPT ); Fri, 4 Feb 2022 16:16:02 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:10848 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241241AbiBDVP6 (ORCPT ); Fri, 4 Feb 2022 16:15:58 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214JY6PY032202; Fri, 4 Feb 2022 21:15:57 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=VrPyiB5S6LWwYpvukcpd/2m9aAwyBbFn7IUsYdyHw/U=; b=N/L+9/PdP6+2m6vZHfbAo7RR3XmAQaSuyOlZO14PBpPeCkVXSDv9V2lbqai+tNRnSO+W DntlDmucguvXq/3sWfw8Qjo3YOiAvVel4ZvfDd5RAykfhpVyYryp7vM2Ti3gNluCxA3d 5zzj5ddb45wq0pxb1lrd+BdnUxXqDxprGwfVl+mNm7GOBMH2JNd1R6oFnR03SmG9q2n0 XEePgOpDxBaeVwnEltboy0jJC+IBpShERox3AwJ8Snz2/C77OrM9iAYcrl5ntQzh9Vhy Jg6qfiQrClPLHVhH+3+9py53UqenUulWI3A4acOEGiVEj3UvcCgeTerQ351Vs7JM3vxj hQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e109f6whe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:57 +0000 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214LFu2h022238; Fri, 4 Feb 2022 21:15:56 GMT Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e109f6wh5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:56 +0000 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LDP6Y003716; Fri, 4 Feb 2022 21:15:56 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma01wdc.us.ibm.com with ESMTP id 3e0r0xtty5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:56 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LFrc928705042 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:15:53 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F497136067; Fri, 4 Feb 2022 21:15:53 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 75441136060; Fri, 4 Feb 2022 21:15:51 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:15:51 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 05/30] s390/airq: pass more TPI info to airq handlers Date: Fri, 4 Feb 2022 16:15:11 -0500 Message-Id: <20220204211536.321475-6-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 02HI6Ot598E1JZug9Opa4zID1IjLzQf9 X-Proofpoint-ORIG-GUID: wSPruGchUGmNAefQhgBPZ4xLSPLAZH2O X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=983 clxscore=1015 phishscore=0 impostorscore=0 malwarescore=0 mlxscore=0 adultscore=0 priorityscore=1501 spamscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org A subsequent patch will introduce an airq handler that requires additional TPI information beyond directed vs floating, so pass the entire tpi_info structure via the handler. Only pci actually uses this information today, for the other airq handlers this is effectively a no-op. Reviewed-by: Eric Farman Reviewed-by: Claudio Imbrenda Reviewed-by: Pierre Morel Reviewed-by: Thomas Huth Acked-by: Christian Borntraeger Signed-off-by: Matthew Rosato Acked-by: Cornelia Huck --- arch/s390/include/asm/airq.h | 3 ++- arch/s390/kvm/interrupt.c | 4 +++- arch/s390/pci/pci_irq.c | 9 +++++++-- drivers/s390/cio/airq.c | 2 +- drivers/s390/cio/qdio_thinint.c | 6 ++++-- drivers/s390/crypto/ap_bus.c | 9 ++++++--- drivers/s390/virtio/virtio_ccw.c | 4 +++- 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/arch/s390/include/asm/airq.h b/arch/s390/include/asm/airq.h index 01936fdfaddb..7918a7d09028 100644 --- a/arch/s390/include/asm/airq.h +++ b/arch/s390/include/asm/airq.h @@ -12,10 +12,11 @@ #include #include +#include struct airq_struct { struct hlist_node list; /* Handler queueing. */ - void (*handler)(struct airq_struct *airq, bool floating); + void (*handler)(struct airq_struct *airq, struct tpi_info *tpi_info); u8 *lsi_ptr; /* Local-Summary-Indicator pointer */ u8 lsi_mask; /* Local-Summary-Indicator mask */ u8 isc; /* Interrupt-subclass */ diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c index db933c252dbc..65e75ca2fc5d 100644 --- a/arch/s390/kvm/interrupt.c +++ b/arch/s390/kvm/interrupt.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "kvm-s390.h" #include "gaccess.h" #include "trace-s390.h" @@ -3269,7 +3270,8 @@ int kvm_s390_gisc_unregister(struct kvm *kvm, u32 gisc) } EXPORT_SYMBOL_GPL(kvm_s390_gisc_unregister); -static void gib_alert_irq_handler(struct airq_struct *airq, bool floating) +static void gib_alert_irq_handler(struct airq_struct *airq, + struct tpi_info *tpi_info) { inc_irq_stat(IRQIO_GAL); process_gib_alert_list(); diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c index 2b6062c486f5..cc4c8d7c8f5c 100644 --- a/arch/s390/pci/pci_irq.c +++ b/arch/s390/pci/pci_irq.c @@ -11,6 +11,7 @@ #include #include +#include static enum {FLOATING, DIRECTED} irq_delivery; @@ -216,8 +217,11 @@ static void zpci_handle_fallback_irq(void) } } -static void zpci_directed_irq_handler(struct airq_struct *airq, bool floating) +static void zpci_directed_irq_handler(struct airq_struct *airq, + struct tpi_info *tpi_info) { + bool floating = !tpi_info->directed_irq; + if (floating) { inc_irq_stat(IRQIO_PCF); zpci_handle_fallback_irq(); @@ -227,7 +231,8 @@ static void zpci_directed_irq_handler(struct airq_struct *airq, bool floating) } } -static void zpci_floating_irq_handler(struct airq_struct *airq, bool floating) +static void zpci_floating_irq_handler(struct airq_struct *airq, + struct tpi_info *tpi_info) { unsigned long si, ai; struct airq_iv *aibv; diff --git a/drivers/s390/cio/airq.c b/drivers/s390/cio/airq.c index e56535c99888..2f2226786319 100644 --- a/drivers/s390/cio/airq.c +++ b/drivers/s390/cio/airq.c @@ -99,7 +99,7 @@ static irqreturn_t do_airq_interrupt(int irq, void *dummy) rcu_read_lock(); hlist_for_each_entry_rcu(airq, head, list) if ((*airq->lsi_ptr & airq->lsi_mask) != 0) - airq->handler(airq, !tpi_info->directed_irq); + airq->handler(airq, tpi_info); rcu_read_unlock(); return IRQ_HANDLED; diff --git a/drivers/s390/cio/qdio_thinint.c b/drivers/s390/cio/qdio_thinint.c index 8e09bf3a2fcd..9b9335dd06db 100644 --- a/drivers/s390/cio/qdio_thinint.c +++ b/drivers/s390/cio/qdio_thinint.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "cio.h" #include "ioasm.h" @@ -93,9 +94,10 @@ static inline u32 clear_shared_ind(void) /** * tiqdio_thinint_handler - thin interrupt handler for qdio * @airq: pointer to adapter interrupt descriptor - * @floating: flag to recognize floating vs. directed interrupts (unused) + * @tpi_info: interrupt information (e.g. floating vs directed -- unused) */ -static void tiqdio_thinint_handler(struct airq_struct *airq, bool floating) +static void tiqdio_thinint_handler(struct airq_struct *airq, + struct tpi_info *tpi_info) { u64 irq_time = S390_lowcore.int_clock; u32 si_used = clear_shared_ind(); diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index 1986243f9cd3..df1a038442db 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -129,7 +130,8 @@ static int ap_max_adapter_id = 63; static struct bus_type ap_bus_type; /* Adapter interrupt definitions */ -static void ap_interrupt_handler(struct airq_struct *airq, bool floating); +static void ap_interrupt_handler(struct airq_struct *airq, + struct tpi_info *tpi_info); static bool ap_irq_flag; @@ -442,9 +444,10 @@ static enum hrtimer_restart ap_poll_timeout(struct hrtimer *unused) /** * ap_interrupt_handler() - Schedule ap_tasklet on interrupt * @airq: pointer to adapter interrupt descriptor - * @floating: ignored + * @tpi_info: ignored */ -static void ap_interrupt_handler(struct airq_struct *airq, bool floating) +static void ap_interrupt_handler(struct airq_struct *airq, + struct tpi_info *tpi_info) { inc_irq_stat(IRQIO_APB); tasklet_schedule(&ap_tasklet); diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c index d35e7a3f7067..52c376d15978 100644 --- a/drivers/s390/virtio/virtio_ccw.c +++ b/drivers/s390/virtio/virtio_ccw.c @@ -33,6 +33,7 @@ #include #include #include +#include /* * virtio related functions @@ -203,7 +204,8 @@ static void drop_airq_indicator(struct virtqueue *vq, struct airq_info *info) write_unlock_irqrestore(&info->lock, flags); } -static void virtio_airq_handler(struct airq_struct *airq, bool floating) +static void virtio_airq_handler(struct airq_struct *airq, + struct tpi_info *tpi_info) { struct airq_info *info = container_of(airq, struct airq_info, airq); unsigned long ai; From patchwork Fri Feb 4 21:15:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 709FFC43219 for ; Fri, 4 Feb 2022 21:16:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241894AbiBDVQE (ORCPT ); Fri, 4 Feb 2022 16:16:04 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:32728 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241509AbiBDVP7 (ORCPT ); Fri, 4 Feb 2022 16:15:59 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214KiRMI017395; Fri, 4 Feb 2022 21:15:58 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=WZmggvKpHkUoOLBW9Y1LTJB4zL1N+uLWpFuqCWAzlac=; b=OzYpxAKUqXTp/BmikbCpanBBv46wK+3y24jaccyJngcuxIBn5s8E0fomkf+99peH+d/K Y4eLoSwBEmr5AAsSdnfxZnvsVzyNDdqB+c2+LMjoIgtTcAHv+PWDK9KPhLXmgsd7vib+ qCxAD4Hd71IaffKKwZNGJj7liE2KoLuhDCmSO9MDTzWfYtQ2h69KM602uBcN1g5rnWdK 5pw2Umnwkf8waSnpHLBBubr81/FoF+dG9/yq8hAsFrn20KTGAE/lPWQhm7DgMlMFU+XW /oCFo5u3czZy/0CnCPDO60HbOxeUOMzMuLxY5ZEUsPbG+I7O9ATJWLjYcJtW5Y0F2FoD 7A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx9evry-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:58 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214L8DT4008133; Fri, 4 Feb 2022 21:15:57 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx9evrq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:57 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LDEMu029603; Fri, 4 Feb 2022 21:15:57 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma04wdc.us.ibm.com with ESMTP id 3e0r0vaur7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:15:57 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LFtVf16777618 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:15:55 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6230E136066; Fri, 4 Feb 2022 21:15:55 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 84EF013606A; Fri, 4 Feb 2022 21:15:53 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:15:53 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 06/30] s390/airq: allow for airq structure that uses an input vector Date: Fri, 4 Feb 2022 16:15:12 -0500 Message-Id: <20220204211536.321475-7-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: FnnxqcV5eG3U7WCFI49W4Y92ZosuQlVn X-Proofpoint-ORIG-GUID: OG5GSo5lfMgWfvrAvlTSlVk4Ds6zigu6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 spamscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=992 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When doing device passthrough where interrupts are being forwarded from host to guest, we wish to use a pinned section of guest memory as the vector (the same memory used by the guest as the vector). To accomplish this, add a new parameter for airq_iv_create which allows passing an existing vector to be used instead of allocating a new one. The caller is responsible for ensuring the vector is pinned in memory as well as for unpinning the memory when the vector is no longer needed. A subsequent patch will use this new parameter for zPCI interpretation. Reviewed-by: Pierre Morel Signed-off-by: Matthew Rosato Acked-by: Cornelia Huck Reviewed-by: Claudio Imbrenda --- arch/s390/include/asm/airq.h | 4 +++- arch/s390/pci/pci_irq.c | 8 ++++---- drivers/s390/cio/airq.c | 10 +++++++--- drivers/s390/virtio/virtio_ccw.c | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/arch/s390/include/asm/airq.h b/arch/s390/include/asm/airq.h index 7918a7d09028..e82e5626e139 100644 --- a/arch/s390/include/asm/airq.h +++ b/arch/s390/include/asm/airq.h @@ -47,8 +47,10 @@ struct airq_iv { #define AIRQ_IV_PTR 4 /* Allocate the ptr array */ #define AIRQ_IV_DATA 8 /* Allocate the data array */ #define AIRQ_IV_CACHELINE 16 /* Cacheline alignment for the vector */ +#define AIRQ_IV_GUESTVEC 32 /* Vector is a pinned guest page */ -struct airq_iv *airq_iv_create(unsigned long bits, unsigned long flags); +struct airq_iv *airq_iv_create(unsigned long bits, unsigned long flags, + unsigned long *vec); void airq_iv_release(struct airq_iv *iv); unsigned long airq_iv_alloc(struct airq_iv *iv, unsigned long num); void airq_iv_free(struct airq_iv *iv, unsigned long bit, unsigned long num); diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c index cc4c8d7c8f5c..0d0a02a9fbbf 100644 --- a/arch/s390/pci/pci_irq.c +++ b/arch/s390/pci/pci_irq.c @@ -296,7 +296,7 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) zdev->aisb = bit; /* Create adapter interrupt vector */ - zdev->aibv = airq_iv_create(msi_vecs, AIRQ_IV_DATA | AIRQ_IV_BITLOCK); + zdev->aibv = airq_iv_create(msi_vecs, AIRQ_IV_DATA | AIRQ_IV_BITLOCK, NULL); if (!zdev->aibv) return -ENOMEM; @@ -419,7 +419,7 @@ static int __init zpci_directed_irq_init(void) union zpci_sic_iib iib = {{0}}; unsigned int cpu; - zpci_sbv = airq_iv_create(num_possible_cpus(), 0); + zpci_sbv = airq_iv_create(num_possible_cpus(), 0, NULL); if (!zpci_sbv) return -ENOMEM; @@ -441,7 +441,7 @@ static int __init zpci_directed_irq_init(void) zpci_ibv[cpu] = airq_iv_create(cache_line_size() * BITS_PER_BYTE, AIRQ_IV_DATA | AIRQ_IV_CACHELINE | - (!cpu ? AIRQ_IV_ALLOC : 0)); + (!cpu ? AIRQ_IV_ALLOC : 0), NULL); if (!zpci_ibv[cpu]) return -ENOMEM; } @@ -458,7 +458,7 @@ static int __init zpci_floating_irq_init(void) if (!zpci_ibv) return -ENOMEM; - zpci_sbv = airq_iv_create(ZPCI_NR_DEVICES, AIRQ_IV_ALLOC); + zpci_sbv = airq_iv_create(ZPCI_NR_DEVICES, AIRQ_IV_ALLOC, NULL); if (!zpci_sbv) goto out_free; diff --git a/drivers/s390/cio/airq.c b/drivers/s390/cio/airq.c index 2f2226786319..375a58b1c838 100644 --- a/drivers/s390/cio/airq.c +++ b/drivers/s390/cio/airq.c @@ -122,10 +122,12 @@ static inline unsigned long iv_size(unsigned long bits) * airq_iv_create - create an interrupt vector * @bits: number of bits in the interrupt vector * @flags: allocation flags + * @vec: pointer to pinned guest memory if AIRQ_IV_GUESTVEC * * Returns a pointer to an interrupt vector structure */ -struct airq_iv *airq_iv_create(unsigned long bits, unsigned long flags) +struct airq_iv *airq_iv_create(unsigned long bits, unsigned long flags, + unsigned long *vec) { struct airq_iv *iv; unsigned long size; @@ -146,6 +148,8 @@ struct airq_iv *airq_iv_create(unsigned long bits, unsigned long flags) &iv->vector_dma); if (!iv->vector) goto out_free; + } else if (flags & AIRQ_IV_GUESTVEC) { + iv->vector = vec; } else { iv->vector = cio_dma_zalloc(size); if (!iv->vector) @@ -185,7 +189,7 @@ struct airq_iv *airq_iv_create(unsigned long bits, unsigned long flags) kfree(iv->avail); if (iv->flags & AIRQ_IV_CACHELINE && iv->vector) dma_pool_free(airq_iv_cache, iv->vector, iv->vector_dma); - else + else if (!(iv->flags & AIRQ_IV_GUESTVEC)) cio_dma_free(iv->vector, size); kfree(iv); out: @@ -204,7 +208,7 @@ void airq_iv_release(struct airq_iv *iv) kfree(iv->bitlock); if (iv->flags & AIRQ_IV_CACHELINE) dma_pool_free(airq_iv_cache, iv->vector, iv->vector_dma); - else + else if (!(iv->flags & AIRQ_IV_GUESTVEC)) cio_dma_free(iv->vector, iv_size(iv->bits)); kfree(iv->avail); kfree(iv); diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c index 52c376d15978..410498d693f8 100644 --- a/drivers/s390/virtio/virtio_ccw.c +++ b/drivers/s390/virtio/virtio_ccw.c @@ -241,7 +241,7 @@ static struct airq_info *new_airq_info(int index) return NULL; rwlock_init(&info->lock); info->aiv = airq_iv_create(VIRTIO_IV_BITS, AIRQ_IV_ALLOC | AIRQ_IV_PTR - | AIRQ_IV_CACHELINE); + | AIRQ_IV_CACHELINE, NULL); if (!info->aiv) { kfree(info); return NULL; From patchwork Fri Feb 4 21:15:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8172CC433F5 for ; Fri, 4 Feb 2022 21:16:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241937AbiBDVQO (ORCPT ); Fri, 4 Feb 2022 16:16:14 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49966 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241770AbiBDVQE (ORCPT ); Fri, 4 Feb 2022 16:16:04 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214JT0Ft017358; Fri, 4 Feb 2022 21:16:03 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=mABYJ/U84DxwmA1qI7uP960sK3LdiJd9FRSuKu7NiZk=; b=rjw8+HP8VTANYLEeYNgdSXoUlkLo5czmDZBtuAgv6VwcZ9jfE6QRwS9XSXTkRNH4cqXo V8x8SpOYqoPjMLIw1QiTornJvnXrt+J4iUJuzsFydHRfLOa39uWtFDal6Js6IksJtEl6 j2Jy6LIAfwDxnyUEE/oQXeoyFXJgWujf1niSbnlZc2epcC/yCN3Zwx5AvAy9ZnTwmmFp b434ycXcm9SSWVnfPuOe0RsmyzayPWmhDP/7qO1/PdWMgYTrXvf15nR8jN8+WzQ0aN8U sg8s4Zy8OsgIRcfCSGIyOpdSYqmwGCh8gSqrLTB1oUC93Ozndb14JSKNh4lnSaguReSg kw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx9evtx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:03 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214LFTLm013090; Fri, 4 Feb 2022 21:16:02 GMT Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx9evtk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:02 +0000 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LD0qu000711; Fri, 4 Feb 2022 21:16:02 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma04dal.us.ibm.com with ESMTP id 3e0r0rydh3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:01 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LFv1M25690372 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:15:57 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 72DFC136051; Fri, 4 Feb 2022 21:15:57 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9025E136061; Fri, 4 Feb 2022 21:15:55 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:15:55 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 07/30] s390/pci: externalize the SIC operation controls and routine Date: Fri, 4 Feb 2022 16:15:13 -0500 Message-Id: <20220204211536.321475-8-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: vi0lIE0vHlibeGCjLqRcNXfqQdR_LAct X-Proofpoint-ORIG-GUID: RitUCfAI21ssosk3syFLTanFB2o9Mzlb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 spamscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=800 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org A subsequent patch will be issuing SIC from KVM -- export the necessary routine and make the operation control definitions available from a header. Because the routine will now be exported, let's rename __zpci_set_irq_ctrl to zpci_set_irq_ctrl and get rid of the zero'd iib wrapper function of the same name. Reviewed-by: Niklas Schnelle Reviewed-by: Claudio Imbrenda Reviewed-by: Pierre Morel Signed-off-by: Matthew Rosato --- arch/s390/include/asm/pci_insn.h | 17 +++++++++-------- arch/s390/pci/pci_insn.c | 3 ++- arch/s390/pci/pci_irq.c | 26 ++++++++++++-------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/arch/s390/include/asm/pci_insn.h b/arch/s390/include/asm/pci_insn.h index 61cf9531f68f..5331082fa516 100644 --- a/arch/s390/include/asm/pci_insn.h +++ b/arch/s390/include/asm/pci_insn.h @@ -98,6 +98,14 @@ struct zpci_fib { u32 gd; } __packed __aligned(8); +/* Set Interruption Controls Operation Controls */ +#define SIC_IRQ_MODE_ALL 0 +#define SIC_IRQ_MODE_SINGLE 1 +#define SIC_IRQ_MODE_DIRECT 4 +#define SIC_IRQ_MODE_D_ALL 16 +#define SIC_IRQ_MODE_D_SINGLE 17 +#define SIC_IRQ_MODE_SET_CPU 18 + /* directed interruption information block */ struct zpci_diib { u32 : 1; @@ -134,13 +142,6 @@ int __zpci_store(u64 data, u64 req, u64 offset); int zpci_store(const volatile void __iomem *addr, u64 data, unsigned long len); int __zpci_store_block(const u64 *data, u64 req, u64 offset); void zpci_barrier(void); -int __zpci_set_irq_ctrl(u16 ctl, u8 isc, union zpci_sic_iib *iib); - -static inline int zpci_set_irq_ctrl(u16 ctl, u8 isc) -{ - union zpci_sic_iib iib = {{0}}; - - return __zpci_set_irq_ctrl(ctl, isc, &iib); -} +int zpci_set_irq_ctrl(u16 ctl, u8 isc, union zpci_sic_iib *iib); #endif diff --git a/arch/s390/pci/pci_insn.c b/arch/s390/pci/pci_insn.c index 4dd58b196cea..2a47b3936e44 100644 --- a/arch/s390/pci/pci_insn.c +++ b/arch/s390/pci/pci_insn.c @@ -97,7 +97,7 @@ int zpci_refresh_trans(u64 fn, u64 addr, u64 range) } /* Set Interruption Controls */ -int __zpci_set_irq_ctrl(u16 ctl, u8 isc, union zpci_sic_iib *iib) +int zpci_set_irq_ctrl(u16 ctl, u8 isc, union zpci_sic_iib *iib) { if (!test_facility(72)) return -EIO; @@ -108,6 +108,7 @@ int __zpci_set_irq_ctrl(u16 ctl, u8 isc, union zpci_sic_iib *iib) return 0; } +EXPORT_SYMBOL_GPL(zpci_set_irq_ctrl); /* PCI Load */ static inline int ____pcilg(u64 *data, u64 req, u64 offset, u8 *status) diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c index 0d0a02a9fbbf..2f675355fd0c 100644 --- a/arch/s390/pci/pci_irq.c +++ b/arch/s390/pci/pci_irq.c @@ -15,13 +15,6 @@ static enum {FLOATING, DIRECTED} irq_delivery; -#define SIC_IRQ_MODE_ALL 0 -#define SIC_IRQ_MODE_SINGLE 1 -#define SIC_IRQ_MODE_DIRECT 4 -#define SIC_IRQ_MODE_D_ALL 16 -#define SIC_IRQ_MODE_D_SINGLE 17 -#define SIC_IRQ_MODE_SET_CPU 18 - /* * summary bit vector * FLOATING - summary bit per function @@ -154,6 +147,7 @@ static struct irq_chip zpci_irq_chip = { static void zpci_handle_cpu_local_irq(bool rescan) { struct airq_iv *dibv = zpci_ibv[smp_processor_id()]; + union zpci_sic_iib iib = {{0}}; unsigned long bit; int irqs_on = 0; @@ -165,7 +159,7 @@ static void zpci_handle_cpu_local_irq(bool rescan) /* End of second scan with interrupts on. */ break; /* First scan complete, reenable interrupts. */ - if (zpci_set_irq_ctrl(SIC_IRQ_MODE_D_SINGLE, PCI_ISC)) + if (zpci_set_irq_ctrl(SIC_IRQ_MODE_D_SINGLE, PCI_ISC, &iib)) break; bit = 0; continue; @@ -193,6 +187,7 @@ static void zpci_handle_remote_irq(void *data) static void zpci_handle_fallback_irq(void) { struct cpu_irq_data *cpu_data; + union zpci_sic_iib iib = {{0}}; unsigned long cpu; int irqs_on = 0; @@ -203,7 +198,7 @@ static void zpci_handle_fallback_irq(void) /* End of second scan with interrupts on. */ break; /* First scan complete, reenable interrupts. */ - if (zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, PCI_ISC)) + if (zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, PCI_ISC, &iib)) break; cpu = 0; continue; @@ -234,6 +229,7 @@ static void zpci_directed_irq_handler(struct airq_struct *airq, static void zpci_floating_irq_handler(struct airq_struct *airq, struct tpi_info *tpi_info) { + union zpci_sic_iib iib = {{0}}; unsigned long si, ai; struct airq_iv *aibv; int irqs_on = 0; @@ -247,7 +243,7 @@ static void zpci_floating_irq_handler(struct airq_struct *airq, /* End of second scan with interrupts on. */ break; /* First scan complete, reenable interrupts. */ - if (zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, PCI_ISC)) + if (zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, PCI_ISC, &iib)) break; si = 0; continue; @@ -407,11 +403,12 @@ static struct airq_struct zpci_airq = { static void __init cpu_enable_directed_irq(void *unused) { union zpci_sic_iib iib = {{0}}; + union zpci_sic_iib ziib = {{0}}; iib.cdiib.dibv_addr = (u64) zpci_ibv[smp_processor_id()]->vector; - __zpci_set_irq_ctrl(SIC_IRQ_MODE_SET_CPU, 0, &iib); - zpci_set_irq_ctrl(SIC_IRQ_MODE_D_SINGLE, PCI_ISC); + zpci_set_irq_ctrl(SIC_IRQ_MODE_SET_CPU, 0, &iib); + zpci_set_irq_ctrl(SIC_IRQ_MODE_D_SINGLE, PCI_ISC, &ziib); } static int __init zpci_directed_irq_init(void) @@ -426,7 +423,7 @@ static int __init zpci_directed_irq_init(void) iib.diib.isc = PCI_ISC; iib.diib.nr_cpus = num_possible_cpus(); iib.diib.disb_addr = virt_to_phys(zpci_sbv->vector); - __zpci_set_irq_ctrl(SIC_IRQ_MODE_DIRECT, 0, &iib); + zpci_set_irq_ctrl(SIC_IRQ_MODE_DIRECT, 0, &iib); zpci_ibv = kcalloc(num_possible_cpus(), sizeof(*zpci_ibv), GFP_KERNEL); @@ -471,6 +468,7 @@ static int __init zpci_floating_irq_init(void) int __init zpci_irq_init(void) { + union zpci_sic_iib iib = {{0}}; int rc; irq_delivery = sclp.has_dirq ? DIRECTED : FLOATING; @@ -502,7 +500,7 @@ int __init zpci_irq_init(void) * Enable floating IRQs (with suppression after one IRQ). When using * directed IRQs this enables the fallback path. */ - zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, PCI_ISC); + zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, PCI_ISC, &iib); return 0; out_airq: From patchwork Fri Feb 4 21:15:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735652 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A21AC433FE for ; Fri, 4 Feb 2022 21:16:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242146AbiBDVQL (ORCPT ); Fri, 4 Feb 2022 16:16:11 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:20310 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241692AbiBDVQD (ORCPT ); Fri, 4 Feb 2022 16:16:03 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214KjJA0011444; Fri, 4 Feb 2022 21:16:03 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=2hpO6Ze2kln0T95EMFtTPhiqenn+79q5JMR7e85bp6g=; b=NPfyni+lunbIR3ZN6JO1vFZK3l3mRBkqxmL3L0S57dbzujSpzJfoGUkGMEe+rZunV05Q XB2aU/pRUgaS/tZJoxQ8ZL94zCdkqv/AcUq0QbnaX3yDlzScDtfvaAzh/6BTknju1nOn wFc8GoUoBVu2/os0oVpk7+rBlaUFwO9pUdlMZPzd/7KttYoy4E19V9eoSiincGywLkQA I4+QdGVvBIrKy3RyfNso+IkGOno2k3CnVT4cSS4ywdLKgiLYZmpCk15Af89u+/EaKA4O ifA+jrheHUsOLk/9dL3EovqnStxGvg5gDS4hu5Y95EUx2h5qCxHb191RXFHS70usGdzB kg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx0xs7u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:02 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214KAd4j026083; Fri, 4 Feb 2022 21:16:02 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx0xs7a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:02 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LDHTx029643; Fri, 4 Feb 2022 21:16:01 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma04wdc.us.ibm.com with ESMTP id 3e0r0vaus7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:00 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LFxwb27984204 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:15:59 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6B62E13605D; Fri, 4 Feb 2022 21:15:59 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 96776136061; Fri, 4 Feb 2022 21:15:57 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:15:57 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Christian Borntraeger Subject: [PATCH v3 08/30] s390/pci: stash associated GISA designation Date: Fri, 4 Feb 2022 16:15:14 -0500 Message-Id: <20220204211536.321475-9-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 01RlsTiHBwliwWXvTTHWBB3iMpgXsss6 X-Proofpoint-ORIG-GUID: THmuQnR3_8039a1xx0Gb5z2K6sCMDCJC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 mlxlogscore=841 suspectscore=0 spamscore=0 malwarescore=0 phishscore=0 priorityscore=1501 impostorscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org For passthrough devices, we will need to know the GISA designation of the guest if interpretation facilities are to be used. Setup to stash this in the zdev and set a default of 0 (no GISA designation) for now; a subsequent patch will set a valid GISA designation for passthrough devices. Also, extend mpcific routines to specify this stashed designation as part of the mpcific command. Reviewed-by: Niklas Schnelle Reviewed-by: Christian Borntraeger Reviewed-by: Eric Farman Reviewed-by: Pierre Morel Signed-off-by: Matthew Rosato --- arch/s390/include/asm/pci.h | 1 + arch/s390/include/asm/pci_clp.h | 3 ++- arch/s390/pci/pci.c | 6 ++++++ arch/s390/pci/pci_clp.c | 1 + arch/s390/pci/pci_irq.c | 5 +++++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index 90824be5ce9a..d07d7c3205de 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -123,6 +123,7 @@ struct zpci_dev { enum zpci_state state; u32 fid; /* function ID, used by sclp */ u32 fh; /* function handle, used by insn's */ + u32 gisa; /* GISA designation for passthrough */ u16 vfn; /* virtual function number */ u16 pchid; /* physical channel ID */ u8 pfgid; /* function group ID */ diff --git a/arch/s390/include/asm/pci_clp.h b/arch/s390/include/asm/pci_clp.h index 1f4b666e85ee..f3286bc5ba6e 100644 --- a/arch/s390/include/asm/pci_clp.h +++ b/arch/s390/include/asm/pci_clp.h @@ -173,7 +173,8 @@ struct clp_req_set_pci { u16 reserved2; u8 oc; /* operation controls */ u8 ndas; /* number of dma spaces */ - u64 reserved3; + u32 reserved3; + u32 gisa; /* GISA designation */ } __packed; /* Set PCI function response */ diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 792f8e0f2178..ca9c29386de6 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -119,6 +119,7 @@ int zpci_register_ioat(struct zpci_dev *zdev, u8 dmaas, fib.pba = base; fib.pal = limit; fib.iota = iota | ZPCI_IOTA_RTTO_FLAG; + fib.gd = zdev->gisa; cc = zpci_mod_fc(req, &fib, &status); if (cc) zpci_dbg(3, "reg ioat fid:%x, cc:%d, status:%d\n", zdev->fid, cc, status); @@ -132,6 +133,8 @@ int zpci_unregister_ioat(struct zpci_dev *zdev, u8 dmaas) struct zpci_fib fib = {0}; u8 cc, status; + fib.gd = zdev->gisa; + cc = zpci_mod_fc(req, &fib, &status); if (cc) zpci_dbg(3, "unreg ioat fid:%x, cc:%d, status:%d\n", zdev->fid, cc, status); @@ -159,6 +162,7 @@ int zpci_fmb_enable_device(struct zpci_dev *zdev) atomic64_set(&zdev->unmapped_pages, 0); fib.fmb_addr = virt_to_phys(zdev->fmb); + fib.gd = zdev->gisa; cc = zpci_mod_fc(req, &fib, &status); if (cc) { kmem_cache_free(zdev_fmb_cache, zdev->fmb); @@ -177,6 +181,8 @@ int zpci_fmb_disable_device(struct zpci_dev *zdev) if (!zdev->fmb) return -EINVAL; + fib.gd = zdev->gisa; + /* Function measurement is disabled if fmb address is zero */ cc = zpci_mod_fc(req, &fib, &status); if (cc == 3) /* Function already gone. */ diff --git a/arch/s390/pci/pci_clp.c b/arch/s390/pci/pci_clp.c index be077b39da33..4dcc37ddeeaf 100644 --- a/arch/s390/pci/pci_clp.c +++ b/arch/s390/pci/pci_clp.c @@ -240,6 +240,7 @@ static int clp_set_pci_fn(struct zpci_dev *zdev, u32 *fh, u8 nr_dma_as, u8 comma rrb->request.fh = zdev->fh; rrb->request.oc = command; rrb->request.ndas = nr_dma_as; + rrb->request.gisa = zdev->gisa; rc = clp_req(rrb, CLP_LPS_PCI); if (rrb->response.hdr.rsp == CLP_RC_SETPCIFN_BUSY) { diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c index 2f675355fd0c..a19ac0282929 100644 --- a/arch/s390/pci/pci_irq.c +++ b/arch/s390/pci/pci_irq.c @@ -43,6 +43,7 @@ static int zpci_set_airq(struct zpci_dev *zdev) fib.fmt0.aibvo = 0; /* each zdev has its own interrupt vector */ fib.fmt0.aisb = virt_to_phys(zpci_sbv->vector) + (zdev->aisb / 64) * 8; fib.fmt0.aisbo = zdev->aisb & 63; + fib.gd = zdev->gisa; return zpci_mod_fc(req, &fib, &status) ? -EIO : 0; } @@ -54,6 +55,8 @@ static int zpci_clear_airq(struct zpci_dev *zdev) struct zpci_fib fib = {0}; u8 cc, status; + fib.gd = zdev->gisa; + cc = zpci_mod_fc(req, &fib, &status); if (cc == 3 || (cc == 1 && status == 24)) /* Function already gone or IRQs already deregistered. */ @@ -72,6 +75,7 @@ static int zpci_set_directed_irq(struct zpci_dev *zdev) fib.fmt = 1; fib.fmt1.noi = zdev->msi_nr_irqs; fib.fmt1.dibvo = zdev->msi_first_bit; + fib.gd = zdev->gisa; return zpci_mod_fc(req, &fib, &status) ? -EIO : 0; } @@ -84,6 +88,7 @@ static int zpci_clear_directed_irq(struct zpci_dev *zdev) u8 cc, status; fib.fmt = 1; + fib.gd = zdev->gisa; cc = zpci_mod_fc(req, &fib, &status); if (cc == 3 || (cc == 1 && status == 24)) /* Function already gone or IRQs already deregistered. */ From patchwork Fri Feb 4 21:15:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735654 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D251C4332F for ; Fri, 4 Feb 2022 21:16:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242599AbiBDVQT (ORCPT ); Fri, 4 Feb 2022 16:16:19 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:9264 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242019AbiBDVQF (ORCPT ); Fri, 4 Feb 2022 16:16:05 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214HpQpS026488; Fri, 4 Feb 2022 21:16:05 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=Rtp8aoY8IjDkoknKIiXv/jqG9AOPBTMUfzg+ttPtn0Q=; b=QmWmSFrZWQwwEFtEVyZ50pC3P2lsThSalEDSY9hbUmLBPhz0fFvGa7AEwm/coOYbugdK Zpe66+bcDDPUkWNmkkOjOV9VYFjdsqEIgish7L1COihi82S8gSMvHScjsS2SVgKfHg9f 8VQRlCwGbu67hNQnLyWt27mGGTZO5y3XzjHb8yQPdS4vgKyq6R9KU//zTxd8zF1t3/2f h/yDf1C8oySaWUhr9uBvq/I/jz0kgP13oRyRKoxidRyKmx3jMvxKp+3JUV0JtoLsrqEp dae1hroK77G2GHGsKllQjWnDQL600jKaQj79Bk0E0sISQqbTOCy9OqV9oDGrhGUzcaam zg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx1ppjy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:05 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214KxH89001144; Fri, 4 Feb 2022 21:16:05 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx1ppjr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:05 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LD5Ui009663; Fri, 4 Feb 2022 21:16:04 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma01dal.us.ibm.com with ESMTP id 3e0r0syem1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:04 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LG1se16646596 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:01 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8A77B136060; Fri, 4 Feb 2022 21:16:01 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 98DE8136063; Fri, 4 Feb 2022 21:15:59 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:15:59 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Christian Borntraeger Subject: [PATCH v3 09/30] s390/pci: export some routines related to RPCIT processing Date: Fri, 4 Feb 2022 16:15:15 -0500 Message-Id: <20220204211536.321475-10-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 0gXt0S2YqQNiqSo_RPAKPqJV55b3TuZM X-Proofpoint-GUID: NKLqWxNQkvE6YQcb4h5WCcUD1dylgRX_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 mlxlogscore=994 adultscore=0 mlxscore=0 malwarescore=0 clxscore=1015 impostorscore=0 phishscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org KVM will re-use dma_walk_cpu_trans to walk the host shadow table and will also need to be able to call zpci_refresh_trans to re-issue a RPCIT. Reviewed-by: Niklas Schnelle Reviewed-by: Pierre Morel Acked-by: Christian Borntraeger Signed-off-by: Matthew Rosato --- arch/s390/pci/pci_dma.c | 1 + arch/s390/pci/pci_insn.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c index f46833a25526..a81de48d5ea7 100644 --- a/arch/s390/pci/pci_dma.c +++ b/arch/s390/pci/pci_dma.c @@ -116,6 +116,7 @@ unsigned long *dma_walk_cpu_trans(unsigned long *rto, dma_addr_t dma_addr) px = calc_px(dma_addr); return &pto[px]; } +EXPORT_SYMBOL_GPL(dma_walk_cpu_trans); void dma_update_cpu_trans(unsigned long *entry, phys_addr_t page_addr, int flags) { diff --git a/arch/s390/pci/pci_insn.c b/arch/s390/pci/pci_insn.c index 2a47b3936e44..0509554301c7 100644 --- a/arch/s390/pci/pci_insn.c +++ b/arch/s390/pci/pci_insn.c @@ -95,6 +95,7 @@ int zpci_refresh_trans(u64 fn, u64 addr, u64 range) return (cc) ? -EIO : 0; } +EXPORT_SYMBOL_GPL(zpci_refresh_trans); /* Set Interruption Controls */ int zpci_set_irq_ctrl(u16 ctl, u8 isc, union zpci_sic_iib *iib) From patchwork Fri Feb 4 21:15:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735656 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2493EC433EF for ; Fri, 4 Feb 2022 21:16:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241199AbiBDVQb (ORCPT ); Fri, 4 Feb 2022 16:16:31 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38594 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241566AbiBDVQI (ORCPT ); Fri, 4 Feb 2022 16:16:08 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214KcQiw016182; Fri, 4 Feb 2022 21:16:08 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=DX9MZNZ18y3gzoPge8ogZkIpv/kD4afpB3w01BFLXBA=; b=fgf0tUyFPvMQ6ju8pFp1QquFTDoc/e3ImUvLM2x4hRznYDUJvIKFqgktKjHRNKr60fMN kh/whfgVajX0tHpD0ituNwmbAppCTb9Hh0SQLATbnIy9qxZRWjbmd3WiRNzRwS2qLzW9 GxQEtWyWjOWJG0S6nRHvZ+tqYYh7mJHv24XK3/rczaUJHFDUIX1Zy8Qr/YXFV3U8zNUt uBe7aj7vqSkglyzMmfnrqfw7z8py/2QCHWJiOe9wikYWfwcVsnerqupFsIRvD1mZg5Bb GX/USmlEmtGC2UJ6gH32VkAo+miQeopPsHgreUV6ScSraTbaFsks4q9vpHjOWuwleDRe 8w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0rt5nmrf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:07 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214KkdD1000672; Fri, 4 Feb 2022 21:16:07 GMT Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0rt5nmr4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:07 +0000 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LDNI0003458; Fri, 4 Feb 2022 21:16:06 GMT Received: from b03cxnp07027.gho.boulder.ibm.com (b03cxnp07027.gho.boulder.ibm.com [9.17.130.14]) by ppma01wdc.us.ibm.com with ESMTP id 3e0r0xtu27-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:06 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LG3ZS22217156 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:03 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B424C136060; Fri, 4 Feb 2022 21:16:03 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B7993136063; Fri, 4 Feb 2022 21:16:01 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:01 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Christian Borntraeger Subject: [PATCH v3 10/30] s390/pci: stash dtsm and maxstbl Date: Fri, 4 Feb 2022 16:15:16 -0500 Message-Id: <20220204211536.321475-11-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: XqYoI8sfqXvYYnHkBX5YH7fe3YviZrNm X-Proofpoint-ORIG-GUID: sXaseCocX9kiWyEPGPG7nfrjfmRMJqPQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 adultscore=0 phishscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Store information about what IOAT designation types are supported by underlying hardware as well as the largest store block size allowed. These values will be needed by passthrough. Reviewed-by: Niklas Schnelle Reviewed-by: Pierre Morel Reviewed-by: Christian Borntraeger Signed-off-by: Matthew Rosato --- arch/s390/include/asm/pci.h | 2 ++ arch/s390/include/asm/pci_clp.h | 6 ++++-- arch/s390/pci/pci_clp.c | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index d07d7c3205de..7ee52a70a96f 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -126,9 +126,11 @@ struct zpci_dev { u32 gisa; /* GISA designation for passthrough */ u16 vfn; /* virtual function number */ u16 pchid; /* physical channel ID */ + u16 maxstbl; /* Maximum store block size */ u8 pfgid; /* function group ID */ u8 pft; /* pci function type */ u8 port; + u8 dtsm; /* Supported DT mask */ u8 rid_available : 1; u8 has_hp_slot : 1; u8 has_resources : 1; diff --git a/arch/s390/include/asm/pci_clp.h b/arch/s390/include/asm/pci_clp.h index f3286bc5ba6e..d6189ed14f84 100644 --- a/arch/s390/include/asm/pci_clp.h +++ b/arch/s390/include/asm/pci_clp.h @@ -153,9 +153,11 @@ struct clp_rsp_query_pci_grp { u8 : 6; u8 frame : 1; u8 refresh : 1; /* TLB refresh mode */ - u16 reserved2; + u16 : 3; + u16 maxstbl : 13; /* Maximum store block size */ u16 mui; - u16 : 16; + u8 dtsm; /* Supported DT mask */ + u8 reserved3; u16 maxfaal; u16 : 4; u16 dnoi : 12; diff --git a/arch/s390/pci/pci_clp.c b/arch/s390/pci/pci_clp.c index 4dcc37ddeeaf..dc733b58e74f 100644 --- a/arch/s390/pci/pci_clp.c +++ b/arch/s390/pci/pci_clp.c @@ -103,6 +103,8 @@ static void clp_store_query_pci_fngrp(struct zpci_dev *zdev, zdev->max_msi = response->noi; zdev->fmb_update = response->mui; zdev->version = response->version; + zdev->maxstbl = response->maxstbl; + zdev->dtsm = response->dtsm; switch (response->version) { case 1: From patchwork Fri Feb 4 21:15:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C131C433FE for ; Fri, 4 Feb 2022 21:16:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230387AbiBDVQ2 (ORCPT ); Fri, 4 Feb 2022 16:16:28 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52064 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241582AbiBDVQI (ORCPT ); Fri, 4 Feb 2022 16:16:08 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214HpnUl010449; Fri, 4 Feb 2022 21:16:08 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=QfeB28pJr8D7CfHJ69dZVIPLPRYRUPBbGl8sdkItch4=; b=DH6Pitngv6peuTyHVXnXe6CGLB7bYMqjRQNm7YpV/hXOjv92yKK9r9/c2rAMFAyG4SHH AbPbh2hXjUAksZIErUGfK0HyDrY9syuZJeIEQNgmd7bz9Iso9OaAJosmswzOWYvC/RBq aSiyX2fTQR4NGv8h67WE/mEOR23H4N+fIRtab+4PYqfrKXHEksHLws1Z7FISCRdbu4MV R6KhhhgQR05xldJpfhNhJdKUzi/b1SbUBCIcD82nVE6L0Y9z/IezMe3tfEfMFrYk26PK YO4KoZyf8PfN9PHOVgrPOSMIIJ/5w3vz/8guDmLHx4xmV8K/XVfCkCh6PpHpkLGAau5i Cw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e109f6wn1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:08 +0000 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214L8B4O012836; Fri, 4 Feb 2022 21:16:07 GMT Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e109f6wmu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:07 +0000 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCfEN011934; Fri, 4 Feb 2022 21:16:07 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma05wdc.us.ibm.com with ESMTP id 3e0r0m2wc4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:07 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LG5vf18678160 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:05 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B65F6136063; Fri, 4 Feb 2022 21:16:05 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D739C136055; Fri, 4 Feb 2022 21:16:03 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:03 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Christian Borntraeger Subject: [PATCH v3 11/30] s390/pci: add helper function to find device by handle Date: Fri, 4 Feb 2022 16:15:17 -0500 Message-Id: <20220204211536.321475-12-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 7oHTsjnQX8Fxf40J73cpYANDkVLjmfjC X-Proofpoint-ORIG-GUID: LI3PZL3S4wrlGDonn-RvloY9zYQ3Ocut X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=849 clxscore=1015 phishscore=0 impostorscore=0 malwarescore=0 mlxscore=0 adultscore=0 priorityscore=1501 spamscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Intercepted zPCI instructions will specify the desired function via a function handle. Add a routine to find the device with the specified handle. Acked-by: Niklas Schnelle Reviewed-by: Christian Borntraeger Reviewed-by: Eric Farman Reviewed-by: Pierre Morel Signed-off-by: Matthew Rosato --- arch/s390/include/asm/pci.h | 1 + arch/s390/pci/pci.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index 7ee52a70a96f..3c0b9986dcdc 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -275,6 +275,7 @@ static inline struct zpci_dev *to_zpci_dev(struct device *dev) } struct zpci_dev *get_zdev_by_fid(u32); +struct zpci_dev *get_zdev_by_fh(u32 fh); /* DMA */ int zpci_dma_init(void); diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index ca9c29386de6..04c16312ad54 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -76,6 +76,22 @@ struct zpci_dev *get_zdev_by_fid(u32 fid) return zdev; } +struct zpci_dev *get_zdev_by_fh(u32 fh) +{ + struct zpci_dev *tmp, *zdev = NULL; + + spin_lock(&zpci_list_lock); + list_for_each_entry(tmp, &zpci_list, entry) { + if (tmp->fh == fh) { + zdev = tmp; + break; + } + } + spin_unlock(&zpci_list_lock); + return zdev; +} +EXPORT_SYMBOL_GPL(get_zdev_by_fh); + void zpci_remove_reserved_devices(void) { struct zpci_dev *tmp, *zdev; From patchwork Fri Feb 4 21:15:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D85F9C433F5 for ; Fri, 4 Feb 2022 21:16:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233413AbiBDVQj (ORCPT ); Fri, 4 Feb 2022 16:16:39 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:62560 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S242135AbiBDVQL (ORCPT ); Fri, 4 Feb 2022 16:16:11 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214K08NQ003319; Fri, 4 Feb 2022 21:16:10 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=Yh7aAYl9nehFzILhLmRaOMjsAZGm+FYiJQywVPp+8Nk=; b=YbmyHRH/xhXlxmDVtXafsxhclzUACD/e855dOjryKyGqi6DohTdACVVU/jAtyk/heo00 ugiWqPriOpnRh7+qKf8V5wDUOyltmFg2fKSO8SHfRF6jB4AcnmVryQC7LmCKpHr5CyBI lNevnL5kJ0+uWJOsHgMDOsody6WsmjU8UB5O8p/+S5otqw1RyTylQliJitsnGn+61Rru Ezfnl0c8u4dNr+KnRLrtUS6M64mkgh2HVbUgBgGjbnWELh7+jXN7OZ5dBzp09s91RTPj RO9hhTV1Po5OTFX2g7DuwElQuXn6jiChY1iJ7aXTCkb2ZNJBcyE+5JUbFpabKIWSXPnm EA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0rt5nmsd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:10 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214LGAOY002791; Fri, 4 Feb 2022 21:16:10 GMT Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0rt5nms2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:10 +0000 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCa9b022102; Fri, 4 Feb 2022 21:16:09 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma02wdc.us.ibm.com with ESMTP id 3e0r0kav5h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:09 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LG7nE37552574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:07 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A46FD136060; Fri, 4 Feb 2022 21:16:07 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D9E68136066; Fri, 4 Feb 2022 21:16:05 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:05 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 12/30] s390/pci: get SHM information from list pci Date: Fri, 4 Feb 2022 16:15:18 -0500 Message-Id: <20220204211536.321475-13-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: M3mwsdhdp7s_aqzvsiUUEgY07m8drPY5 X-Proofpoint-ORIG-GUID: 28QxcQMTzWsK1imgHtOdPXtYewTbJcd- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 adultscore=0 phishscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org KVM will need information on the special handle mask used to indicate emulated devices. In order to obtain this, a new type of list pci call must be made to gather the information. Extend clp_list_pci_req to also fetch the model-dependent-data field that holds this mask. Reviewed-by: Niklas Schnelle Signed-off-by: Matthew Rosato Acked-by: Pierre Morel --- arch/s390/include/asm/pci.h | 1 + arch/s390/include/asm/pci_clp.h | 2 +- arch/s390/pci/pci_clp.c | 25 ++++++++++++++++++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index 3c0b9986dcdc..e8a3fd5bc169 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -227,6 +227,7 @@ int clp_enable_fh(struct zpci_dev *zdev, u32 *fh, u8 nr_dma_as); int clp_disable_fh(struct zpci_dev *zdev, u32 *fh); int clp_get_state(u32 fid, enum zpci_state *state); int clp_refresh_fh(u32 fid, u32 *fh); +int zpci_get_mdd(u32 *mdd); /* UID */ void update_uid_checking(bool new); diff --git a/arch/s390/include/asm/pci_clp.h b/arch/s390/include/asm/pci_clp.h index d6189ed14f84..dc2041e97de4 100644 --- a/arch/s390/include/asm/pci_clp.h +++ b/arch/s390/include/asm/pci_clp.h @@ -76,7 +76,7 @@ struct clp_req_list_pci { struct clp_rsp_list_pci { struct clp_rsp_hdr hdr; u64 resume_token; - u32 reserved2; + u32 mdd; u16 max_fn; u8 : 7; u8 uid_checking : 1; diff --git a/arch/s390/pci/pci_clp.c b/arch/s390/pci/pci_clp.c index dc733b58e74f..7477956be632 100644 --- a/arch/s390/pci/pci_clp.c +++ b/arch/s390/pci/pci_clp.c @@ -328,7 +328,7 @@ int clp_disable_fh(struct zpci_dev *zdev, u32 *fh) } static int clp_list_pci_req(struct clp_req_rsp_list_pci *rrb, - u64 *resume_token, int *nentries) + u64 *resume_token, int *nentries, u32 *mdd) { int rc; @@ -354,6 +354,8 @@ static int clp_list_pci_req(struct clp_req_rsp_list_pci *rrb, *nentries = (rrb->response.hdr.len - LIST_PCI_HDR_LEN) / rrb->response.entry_size; *resume_token = rrb->response.resume_token; + if (mdd) + *mdd = rrb->response.mdd; return rc; } @@ -365,7 +367,7 @@ static int clp_list_pci(struct clp_req_rsp_list_pci *rrb, void *data, int nentries, i, rc; do { - rc = clp_list_pci_req(rrb, &resume_token, &nentries); + rc = clp_list_pci_req(rrb, &resume_token, &nentries, NULL); if (rc) return rc; for (i = 0; i < nentries; i++) @@ -383,7 +385,7 @@ static int clp_find_pci(struct clp_req_rsp_list_pci *rrb, u32 fid, int nentries, i, rc; do { - rc = clp_list_pci_req(rrb, &resume_token, &nentries); + rc = clp_list_pci_req(rrb, &resume_token, &nentries, NULL); if (rc) return rc; fh_list = rrb->response.fh_list; @@ -468,6 +470,23 @@ int clp_get_state(u32 fid, enum zpci_state *state) return rc; } +int zpci_get_mdd(u32 *mdd) +{ + struct clp_req_rsp_list_pci *rrb; + u64 resume_token = 0; + int nentries, rc; + + rrb = clp_alloc_block(GFP_KERNEL); + if (!rrb) + return -ENOMEM; + + rc = clp_list_pci_req(rrb, &resume_token, &nentries, mdd); + + clp_free_block(rrb); + return rc; +} +EXPORT_SYMBOL_GPL(zpci_get_mdd); + static int clp_base_slpc(struct clp_req *req, struct clp_req_rsp_slpc *lpcb) { unsigned long limit = PAGE_SIZE - sizeof(lpcb->request); From patchwork Fri Feb 4 21:15:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735658 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3BB8C433EF for ; Fri, 4 Feb 2022 21:16:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242141AbiBDVQn (ORCPT ); Fri, 4 Feb 2022 16:16:43 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:9190 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242234AbiBDVQN (ORCPT ); Fri, 4 Feb 2022 16:16:13 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214JQBKB022463; Fri, 4 Feb 2022 21:16:12 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=c+/z/nGdUo/eAT2rhuk32NdGy9vuZBQEad2crmImLoA=; b=f6ym4TqCiPZNl+sY+W1Jd5o/JtHDvYUJ5ArLoqzdIjWt4yetrrEvtI8XP38yuGWmBvE2 PVbTAMiZvVvGZY97zcXw20d1YCceU0KvqQHIZ+DjoIBLxaawbgyGE5/PXSFkqTP9bMM+ A/N7WGxUrvJpjZYYy8kMOpX8Sv29pY1C34cg1ufOUhB+EDvy+jX4tEFpzq0q499ldVbF ZjIKpMDp7f0jz6wVPlL8wGR5x/f7rcKBtdV1Nmle3AO1o/y4HxlZwHh4eAme0wnjeSFp QNF5WN5y7TVblRWYXPqhlhklxpkeNlIjuSu/Mf3AfHjobSROLj9WjqMW7IMD2EOElzyC fw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0rj5x300-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:12 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214KvGUi026184; Fri, 4 Feb 2022 21:16:12 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0rj5x2ys-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:11 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LDHUJ029643; Fri, 4 Feb 2022 21:16:11 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma04wdc.us.ibm.com with ESMTP id 3e0r0vauv6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:11 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LG9F627328890 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:09 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 92DDE136063; Fri, 4 Feb 2022 21:16:09 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C8122136065; Fri, 4 Feb 2022 21:16:07 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:07 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 13/30] s390/pci: return status from zpci_refresh_trans Date: Fri, 4 Feb 2022 16:15:19 -0500 Message-Id: <20220204211536.321475-14-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: FRyjFzOPmYczC_0N7fz7T0e_Y3oERJu3 X-Proofpoint-GUID: WMDW8qu5Ut-HIBTZwz7J87qNFbuwhFUG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 phishscore=0 spamscore=0 malwarescore=0 clxscore=1015 mlxlogscore=999 impostorscore=0 bulkscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Current callers of zpci_refresh_trans don't need to interrogate the status returned from the underlying instructions. However, a subsequent patch will add a KVM caller that needs this information. Add a new argument to zpci_refresh_trans to pass the address of a status byte and update existing call sites to provide it. Reviewed-by: Pierre Morel Reviewed-by: Claudio Imbrenda Reviewed-by: Niklas Schnelle Signed-off-by: Matthew Rosato --- arch/s390/include/asm/pci_insn.h | 2 +- arch/s390/pci/pci_dma.c | 6 ++++-- arch/s390/pci/pci_insn.c | 10 +++++----- drivers/iommu/s390-iommu.c | 4 +++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/arch/s390/include/asm/pci_insn.h b/arch/s390/include/asm/pci_insn.h index 5331082fa516..32759c407b8f 100644 --- a/arch/s390/include/asm/pci_insn.h +++ b/arch/s390/include/asm/pci_insn.h @@ -135,7 +135,7 @@ union zpci_sic_iib { DECLARE_STATIC_KEY_FALSE(have_mio); u8 zpci_mod_fc(u64 req, struct zpci_fib *fib, u8 *status); -int zpci_refresh_trans(u64 fn, u64 addr, u64 range); +int zpci_refresh_trans(u64 fn, u64 addr, u64 range, u8 *status); int __zpci_load(u64 *data, u64 req, u64 offset); int zpci_load(u64 *data, const volatile void __iomem *addr, unsigned long len); int __zpci_store(u64 data, u64 req, u64 offset); diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c index a81de48d5ea7..b0a2380bcad8 100644 --- a/arch/s390/pci/pci_dma.c +++ b/arch/s390/pci/pci_dma.c @@ -23,8 +23,9 @@ static u32 s390_iommu_aperture_factor = 1; static int zpci_refresh_global(struct zpci_dev *zdev) { + u8 status; return zpci_refresh_trans((u64) zdev->fh << 32, zdev->start_dma, - zdev->iommu_pages * PAGE_SIZE); + zdev->iommu_pages * PAGE_SIZE, &status); } unsigned long *dma_alloc_cpu_table(void) @@ -183,6 +184,7 @@ static int __dma_purge_tlb(struct zpci_dev *zdev, dma_addr_t dma_addr, size_t size, int flags) { unsigned long irqflags; + u8 status; int ret; /* @@ -201,7 +203,7 @@ static int __dma_purge_tlb(struct zpci_dev *zdev, dma_addr_t dma_addr, } ret = zpci_refresh_trans((u64) zdev->fh << 32, dma_addr, - PAGE_ALIGN(size)); + PAGE_ALIGN(size), &status); if (ret == -ENOMEM && !s390_iommu_strict) { /* enable the hypervisor to free some resources */ if (zpci_refresh_global(zdev)) diff --git a/arch/s390/pci/pci_insn.c b/arch/s390/pci/pci_insn.c index 0509554301c7..ca6399d52767 100644 --- a/arch/s390/pci/pci_insn.c +++ b/arch/s390/pci/pci_insn.c @@ -77,20 +77,20 @@ static inline u8 __rpcit(u64 fn, u64 addr, u64 range, u8 *status) return cc; } -int zpci_refresh_trans(u64 fn, u64 addr, u64 range) +int zpci_refresh_trans(u64 fn, u64 addr, u64 range, u8 *status) { - u8 cc, status; + u8 cc; do { - cc = __rpcit(fn, addr, range, &status); + cc = __rpcit(fn, addr, range, status); if (cc == 2) udelay(ZPCI_INSN_BUSY_DELAY); } while (cc == 2); if (cc) - zpci_err_insn(cc, status, addr, range); + zpci_err_insn(cc, *status, addr, range); - if (cc == 1 && (status == 4 || status == 16)) + if (cc == 1 && (*status == 4 || *status == 16)) return -ENOMEM; return (cc) ? -EIO : 0; diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c index 50860ebdd087..845bb99c183e 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -214,6 +214,7 @@ static int s390_iommu_update_trans(struct s390_domain *s390_domain, unsigned long irq_flags, nr_pages, i; unsigned long *entry; int rc = 0; + u8 status; if (dma_addr < s390_domain->domain.geometry.aperture_start || dma_addr + size > s390_domain->domain.geometry.aperture_end) @@ -238,7 +239,8 @@ static int s390_iommu_update_trans(struct s390_domain *s390_domain, spin_lock(&s390_domain->list_lock); list_for_each_entry(domain_device, &s390_domain->devices, list) { rc = zpci_refresh_trans((u64) domain_device->zdev->fh << 32, - start_dma_addr, nr_pages * PAGE_SIZE); + start_dma_addr, nr_pages * PAGE_SIZE, + &status); if (rc) break; } From patchwork Fri Feb 4 21:15:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 127F9C433F5 for ; Fri, 4 Feb 2022 21:16:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242455AbiBDVQp (ORCPT ); Fri, 4 Feb 2022 16:16:45 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:33384 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242337AbiBDVQP (ORCPT ); Fri, 4 Feb 2022 16:16:15 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214IqL25018551; Fri, 4 Feb 2022 21:16:15 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=qp9vVYG5GckGz0KgYpMV5xbXAc7dfA7b91vH4eOYxz0=; b=T/VFX5/FgEZX0TyLEqU5l1zTvEjLGxYBb9InKleFundN2R/rtOPnGSAdANvQ7Gg/PM+Y fO+2gVB9bvrHCdKyzrqnNyKac7qtvSfS1THGc4d0Q5jU8gDvZv5w5SvmzVYRAulRmI1s 2blM3U5kqD/4J1IfIsdfLtkpSy4xEkeovyvNq5gvTsG3n5SxufnQfgWjh/kywWjuiOim f4dUerpcgoADHTLoCoZWptePsDflgfvebP6I1lH7uNhbw0T98ovAsv/c7g1I68h+8sPW JiYVYFKCRk/NLMI6HBCL5pimEvZShU+2ydkZFlQNJFfOW61XvX6WEpJvVI4KB4ndAGDC dA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0w6tsr0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:15 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214Kkwbu031278; Fri, 4 Feb 2022 21:16:14 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0w6tsr07-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:14 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCaPj021810; Fri, 4 Feb 2022 21:16:13 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma03dal.us.ibm.com with ESMTP id 3e0r0k7gtq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:13 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGB6B14680428 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:11 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 95E6F136065; Fri, 4 Feb 2022 21:16:11 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B5FA1136051; Fri, 4 Feb 2022 21:16:09 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:09 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 14/30] vfio/pci: re-introduce CONFIG_VFIO_PCI_ZDEV Date: Fri, 4 Feb 2022 16:15:20 -0500 Message-Id: <20220204211536.321475-15-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: gWAAlVQpNS8VAb-Jm6rSSunD9GyKDJT6 X-Proofpoint-ORIG-GUID: 5oQEpu00hLVdSPDCQSWRl07QNHpM8t1H X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 mlxscore=0 clxscore=1015 malwarescore=0 bulkscore=0 spamscore=0 priorityscore=1501 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This was previously removed as unnecessary; while that was true, subsequent changes will make KVM an additional required component for vfio-pci-zdev. Let's re-introduce CONFIG_VFIO_PCI_ZDEV as now there is actually a reason to say 'n' for it (when not planning to CONFIG_KVM). Signed-off-by: Matthew Rosato --- drivers/vfio/pci/Kconfig | 11 +++++++++++ drivers/vfio/pci/Makefile | 2 +- include/linux/vfio_pci_core.h | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig index 860424ccda1b..fedd1d4cb592 100644 --- a/drivers/vfio/pci/Kconfig +++ b/drivers/vfio/pci/Kconfig @@ -42,5 +42,16 @@ config VFIO_PCI_IGD and LPC bridge config space. To enable Intel IGD assignment through vfio-pci, say Y. + +config VFIO_PCI_ZDEV + bool "VFIO PCI extensions for s390x KVM passthrough" + depends on S390 && KVM + default y + help + Support s390x-specific extensions to enable support for enhancements + to KVM passthrough capabilities, such as interpretive execution of + zPCI instructions. + + To enable s390x KVM vfio-pci extensions, say Y. endif endif diff --git a/drivers/vfio/pci/Makefile b/drivers/vfio/pci/Makefile index 349d68d242b4..01b1f83d83d7 100644 --- a/drivers/vfio/pci/Makefile +++ b/drivers/vfio/pci/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only vfio-pci-core-y := vfio_pci_core.o vfio_pci_intrs.o vfio_pci_rdwr.o vfio_pci_config.o -vfio-pci-core-$(CONFIG_S390) += vfio_pci_zdev.o +vfio-pci-core-$(CONFIG_VFIO_PCI_ZDEV) += vfio_pci_zdev.o obj-$(CONFIG_VFIO_PCI_CORE) += vfio-pci-core.o vfio-pci-y := vfio_pci.o diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h index ef9a44b6cf5d..5e2bca3b89db 100644 --- a/include/linux/vfio_pci_core.h +++ b/include/linux/vfio_pci_core.h @@ -195,7 +195,7 @@ static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev) } #endif -#ifdef CONFIG_S390 +#ifdef CONFIG_VFIO_PCI_ZDEV extern int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, struct vfio_info_cap *caps); #else From patchwork Fri Feb 4 21:15:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735660 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7849C433FE for ; Fri, 4 Feb 2022 21:16:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243984AbiBDVQq (ORCPT ); Fri, 4 Feb 2022 16:16:46 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:17462 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242519AbiBDVQS (ORCPT ); Fri, 4 Feb 2022 16:16:18 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214JT7YM001661; Fri, 4 Feb 2022 21:16:18 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=CZzB9rRtEpapWdmcf1wnwL9Cq8Gl2MEwRRLww4IebgY=; b=EYGDvdvWy7D1yxlysaXWODy3WSC0GOYhtvVVg/QOyYK5yz0YY2orob9gBSOH6FrrX7of nZb4w+Dj6PixzfsVkql4gKeBFJhvsi5p3J0onakY3+TJQRBLlEEwSO4rh07FgLQ+tEsk ojRD65ynZXbvSdHIIPi9N0U/7ZimYm+Rb9aBR9LQLKM/RtHakgim/RDDyvRwl4MhxA6L kcJ07ekUfATToVmEkTgxTFjKfFreVbl34wFOyvg83+jQqU2UZcCYVX6yxrns11uUBRIR E7VnZoer6iSl8SDVYduasFxrBOU5/7kObHrOItdSOl9qXUQ7meLduYML7sA9bsP0VsWM lQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx3frkt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:18 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214KxUOt025295; Fri, 4 Feb 2022 21:16:17 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx3frkg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:17 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCaPr021810; Fri, 4 Feb 2022 21:16:16 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma03dal.us.ibm.com with ESMTP id 3e0r0k7guy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:16 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGDQc37617922 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:13 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A589136060; Fri, 4 Feb 2022 21:16:13 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B9DB3136053; Fri, 4 Feb 2022 21:16:11 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:11 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 15/30] KVM: s390: pci: add basic kvm_zdev structure Date: Fri, 4 Feb 2022 16:15:21 -0500 Message-Id: <20220204211536.321475-16-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: PzaE6hUkSK6BIFEFrJ90gEwpb4corLdY X-Proofpoint-GUID: 6C1FNCFQQRVxB0er_EjlFNQZRI8Bs22C X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=943 priorityscore=1501 malwarescore=0 bulkscore=0 impostorscore=0 spamscore=0 phishscore=0 adultscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This structure will be used to carry kvm passthrough information related to zPCI devices. Reviewed-by: Pierre Morel Signed-off-by: Matthew Rosato --- arch/s390/include/asm/kvm_pci.h | 27 +++++++++++++++++++++++ arch/s390/include/asm/pci.h | 3 +++ arch/s390/kvm/Makefile | 1 + arch/s390/kvm/pci.c | 38 +++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 arch/s390/include/asm/kvm_pci.h create mode 100644 arch/s390/kvm/pci.c diff --git a/arch/s390/include/asm/kvm_pci.h b/arch/s390/include/asm/kvm_pci.h new file mode 100644 index 000000000000..ef10f9e46e37 --- /dev/null +++ b/arch/s390/include/asm/kvm_pci.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * KVM PCI Passthrough for virtual machines on s390 + * + * Copyright IBM Corp. 2021 + * + * Author(s): Matthew Rosato + */ + +#ifndef ASM_KVM_PCI_H +#define ASM_KVM_PCI_H + +#include +#include +#include +#include +#include + +struct kvm_zdev { + struct zpci_dev *zdev; + struct kvm *kvm; +}; + +int kvm_s390_pci_dev_open(struct zpci_dev *zdev); +void kvm_s390_pci_dev_release(struct zpci_dev *zdev); + +#endif /* ASM_KVM_PCI_H */ diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index e8a3fd5bc169..4faff673078b 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -97,6 +97,7 @@ struct zpci_bar_struct { }; struct s390_domain; +struct kvm_zdev; #define ZPCI_FUNCTIONS_PER_BUS 256 struct zpci_bus { @@ -190,6 +191,8 @@ struct zpci_dev { struct dentry *debugfs_dev; struct s390_domain *s390_domain; /* s390 IOMMU domain data */ + + struct kvm_zdev *kzdev; /* passthrough data */ }; static inline bool zdev_enabled(struct zpci_dev *zdev) diff --git a/arch/s390/kvm/Makefile b/arch/s390/kvm/Makefile index 26f4a74e5ce4..b8263a160df8 100644 --- a/arch/s390/kvm/Makefile +++ b/arch/s390/kvm/Makefile @@ -10,4 +10,5 @@ ccflags-y := -Ivirt/kvm -Iarch/s390/kvm kvm-y += kvm-s390.o intercept.o interrupt.o priv.o sigp.o kvm-y += diag.o gaccess.o guestdbg.o vsie.o pv.o +kvm-$(CONFIG_VFIO_PCI_ZDEV) += pci.o obj-$(CONFIG_KVM) += kvm.o diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c new file mode 100644 index 000000000000..bc1b7a564e55 --- /dev/null +++ b/arch/s390/kvm/pci.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * s390 kvm PCI passthrough support + * + * Copyright IBM Corp. 2021 + * + * Author(s): Matthew Rosato + */ + +#include +#include +#include + +int kvm_s390_pci_dev_open(struct zpci_dev *zdev) +{ + struct kvm_zdev *kzdev; + + kzdev = kzalloc(sizeof(struct kvm_zdev), GFP_KERNEL); + if (!kzdev) + return -ENOMEM; + + kzdev->zdev = zdev; + zdev->kzdev = kzdev; + + return 0; +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_dev_open); + +void kvm_s390_pci_dev_release(struct zpci_dev *zdev) +{ + struct kvm_zdev *kzdev; + + kzdev = zdev->kzdev; + WARN_ON(kzdev->zdev != zdev); + zdev->kzdev = 0; + kfree(kzdev); +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_dev_release); From patchwork Fri Feb 4 21:15:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D925C43219 for ; Fri, 4 Feb 2022 21:16:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244216AbiBDVQs (ORCPT ); Fri, 4 Feb 2022 16:16:48 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:65168 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242657AbiBDVQU (ORCPT ); Fri, 4 Feb 2022 16:16:20 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214KoNZA022056; Fri, 4 Feb 2022 21:16:19 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=rARsvRjpMPuwie20iXfgoemc7FX7o9IME7kZd0342bc=; b=ETI9xViuHdG3i1DErbMm6FDx6OzzL6h59oTRrx0vpVmt7TCTGMQ3WsEwHMnSa8nbcHPg M3iv7bnJafuYzuGezS+4m21w9hb4WOqc8elTPW0vp3eWtV7Cao/BmQTiPk6oK4nn/5M+ JuDRIk6uuNBAhljhpu+ZJ1eTHy4U+pBAEP5ysXxshsApN9RCCDqTZujXzFd/JLnpFyPf Hm8UNlh/pEzinkAqmXyyDjpmHm+EXk6Nir0Hq0CVm5U5KMQGPiQjg7+EHhZLHWnkfp4r DMYyQHDMOg9zxXle/f2TDLxZ78BzUD1u8h+KgInMI6FTKzeDdKpnBLMZioxBNGR3FiCh MA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0rj5x32a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:19 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214KxmbC010309; Fri, 4 Feb 2022 21:16:19 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0rj5x31p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:19 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LD56r009665; Fri, 4 Feb 2022 21:16:18 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma01dal.us.ibm.com with ESMTP id 3e0r0syern-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:18 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGFnr18350368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:15 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6DC16136055; Fri, 4 Feb 2022 21:16:15 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A72FB136059; Fri, 4 Feb 2022 21:16:13 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:13 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 16/30] KVM: s390: pci: do initial setup for AEN interpretation Date: Fri, 4 Feb 2022 16:15:22 -0500 Message-Id: <20220204211536.321475-17-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: MzQYhYsJMF4LWY0-cSpkyqUSkjsw1wDM X-Proofpoint-GUID: xBM6fPY3wHJvtSgzKftXSPbWdmwLOMkS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 phishscore=0 spamscore=0 malwarescore=0 clxscore=1015 mlxlogscore=999 impostorscore=0 bulkscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Initial setup for Adapter Event Notification Interpretation for zPCI passthrough devices. Specifically, allocate a structure for forwarding of adapter events and pass the address of this structure to firmware. Signed-off-by: Matthew Rosato --- arch/s390/include/asm/pci.h | 4 + arch/s390/include/asm/pci_insn.h | 12 +++ arch/s390/kvm/interrupt.c | 14 +++ arch/s390/kvm/kvm-s390.c | 9 ++ arch/s390/kvm/pci.c | 154 +++++++++++++++++++++++++++++++ arch/s390/kvm/pci.h | 42 +++++++++ arch/s390/pci/pci.c | 6 ++ 7 files changed, 241 insertions(+) create mode 100644 arch/s390/kvm/pci.h diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index 4faff673078b..1ae49330d1c8 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #define PCIBIOS_MIN_IO 0x1000 @@ -204,6 +205,9 @@ extern const struct attribute_group *zpci_attr_groups[]; extern unsigned int s390_pci_force_floating __initdata; extern unsigned int s390_pci_no_rid; +extern union zpci_sic_iib *zpci_aipb; +extern struct airq_iv *zpci_aif_sbv; + /* ----------------------------------------------------------------------------- Prototypes ----------------------------------------------------------------------------- */ diff --git a/arch/s390/include/asm/pci_insn.h b/arch/s390/include/asm/pci_insn.h index 32759c407b8f..ad9000295c82 100644 --- a/arch/s390/include/asm/pci_insn.h +++ b/arch/s390/include/asm/pci_insn.h @@ -101,6 +101,7 @@ struct zpci_fib { /* Set Interruption Controls Operation Controls */ #define SIC_IRQ_MODE_ALL 0 #define SIC_IRQ_MODE_SINGLE 1 +#define SIC_SET_AENI_CONTROLS 2 #define SIC_IRQ_MODE_DIRECT 4 #define SIC_IRQ_MODE_D_ALL 16 #define SIC_IRQ_MODE_D_SINGLE 17 @@ -127,9 +128,20 @@ struct zpci_cdiib { u64 : 64; } __packed __aligned(8); +/* adapter interruption parameters block */ +struct zpci_aipb { + u64 faisb; + u64 gait; + u16 : 13; + u16 afi : 3; + u32 : 32; + u16 faal; +} __packed __aligned(8); + union zpci_sic_iib { struct zpci_diib diib; struct zpci_cdiib cdiib; + struct zpci_aipb aipb; }; DECLARE_STATIC_KEY_FALSE(have_mio); diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c index 65e75ca2fc5d..5e638f7c86f8 100644 --- a/arch/s390/kvm/interrupt.c +++ b/arch/s390/kvm/interrupt.c @@ -32,6 +32,7 @@ #include "kvm-s390.h" #include "gaccess.h" #include "trace-s390.h" +#include "pci.h" #define PFAULT_INIT 0x0600 #define PFAULT_DONE 0x0680 @@ -3286,6 +3287,11 @@ void kvm_s390_gib_destroy(void) { if (!gib) return; + if (IS_ENABLED(CONFIG_VFIO_PCI_ZDEV) && sclp.has_aeni && aift) { + mutex_lock(&aift->aift_lock); + kvm_s390_pci_aen_exit(); + mutex_unlock(&aift->aift_lock); + } chsc_sgib(0); unregister_adapter_interrupt(&gib_alert_irq); free_page((unsigned long)gib); @@ -3323,6 +3329,14 @@ int kvm_s390_gib_init(u8 nisc) goto out_unreg_gal; } + if (IS_ENABLED(CONFIG_VFIO_PCI_ZDEV) && sclp.has_aeni) { + if (kvm_s390_pci_aen_init(nisc)) { + pr_err("Initializing AEN for PCI failed\n"); + rc = -EIO; + goto out_unreg_gal; + } + } + KVM_EVENT(3, "gib 0x%pK (nisc=%d) initialized", gib, gib->nisc); goto out; diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 577f1ead6a51..dd4f4bfb326b 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -48,6 +48,7 @@ #include #include "kvm-s390.h" #include "gaccess.h" +#include "pci.h" #define CREATE_TRACE_POINTS #include "trace.h" @@ -503,6 +504,14 @@ int kvm_arch_init(void *opaque) goto out; } + if (IS_ENABLED(CONFIG_VFIO_PCI_ZDEV)) { + rc = kvm_s390_pci_init(); + if (rc) { + pr_err("Unable to allocate AIFT for PCI\n"); + goto out; + } + } + rc = kvm_s390_gib_init(GAL_ISC); if (rc) goto out; diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c index bc1b7a564e55..9b8390133e15 100644 --- a/arch/s390/kvm/pci.c +++ b/arch/s390/kvm/pci.c @@ -10,6 +10,148 @@ #include #include #include +#include +#include +#include "pci.h" + +struct zpci_aift *aift; + +static inline int __set_irq_noiib(u16 ctl, u8 isc) +{ + union zpci_sic_iib iib = {{0}}; + + return zpci_set_irq_ctrl(ctl, isc, &iib); +} + +/* Caller must hold the aift lock before calling this function */ +void kvm_s390_pci_aen_exit(void) +{ + unsigned long flags; + struct kvm_zdev **gait_kzdev; + + /* + * Contents of the aipb remain registered for the life of the host + * kernel, the information preserved in zpci_aipb and zpci_aif_sbv + * in case we insert the KVM module again later. Clear the AIFT + * information and free anything not registered with underlying + * firmware. + */ + spin_lock_irqsave(&aift->gait_lock, flags); + gait_kzdev = aift->kzdev; + aift->gait = 0; + aift->sbv = 0; + aift->kzdev = 0; + spin_unlock_irqrestore(&aift->gait_lock, flags); + + kfree(gait_kzdev); +} + +static int zpci_setup_aipb(u8 nisc) +{ + struct page *page; + int size, rc; + + zpci_aipb = kzalloc(sizeof(union zpci_sic_iib), GFP_KERNEL); + if (!zpci_aipb) + return -ENOMEM; + + aift->sbv = airq_iv_create(ZPCI_NR_DEVICES, AIRQ_IV_ALLOC, 0); + if (!aift->sbv) { + rc = -ENOMEM; + goto free_aipb; + } + zpci_aif_sbv = aift->sbv; + size = get_order(PAGE_ALIGN(ZPCI_NR_DEVICES * + sizeof(struct zpci_gaite))); + page = alloc_pages(GFP_KERNEL | __GFP_ZERO, size); + if (!page) { + rc = -ENOMEM; + goto free_sbv; + } + aift->gait = (struct zpci_gaite *)page_to_phys(page); + + zpci_aipb->aipb.faisb = virt_to_phys(aift->sbv->vector); + zpci_aipb->aipb.gait = virt_to_phys(aift->gait); + zpci_aipb->aipb.afi = nisc; + zpci_aipb->aipb.faal = ZPCI_NR_DEVICES; + + /* Setup Adapter Event Notification Interpretation */ + if (zpci_set_irq_ctrl(SIC_SET_AENI_CONTROLS, 0, zpci_aipb)) { + rc = -EIO; + goto free_gait; + } + + return 0; + +free_gait: + size = get_order(PAGE_ALIGN(ZPCI_NR_DEVICES * + sizeof(struct zpci_gaite))); + free_pages((unsigned long)aift->gait, size); +free_sbv: + airq_iv_release(aift->sbv); + zpci_aif_sbv = 0; +free_aipb: + kfree(zpci_aipb); + zpci_aipb = 0; + + return rc; +} + +static int zpci_reset_aipb(u8 nisc) +{ + /* + * AEN registration can only happen once per system boot. If + * an aipb already exists then AEN was already registered and + * we can re-use the aipb contents. This can only happen if + * the KVM module was removed and re-inserted. + */ + if (zpci_aipb->aipb.faal != ZPCI_NR_DEVICES || + zpci_aipb->aipb.afi != nisc) { + return -EINVAL; + } + aift->sbv = zpci_aif_sbv; + aift->gait = (struct zpci_gaite *)zpci_aipb->aipb.gait; + + return 0; +} + +int kvm_s390_pci_aen_init(u8 nisc) +{ + int rc = 0; + + /* If already enabled for AEN, bail out now */ + if (aift->gait || aift->sbv) + return -EPERM; + + mutex_lock(&aift->aift_lock); + aift->kzdev = kcalloc(ZPCI_NR_DEVICES, sizeof(struct kvm_zdev), + GFP_KERNEL); + if (!aift->kzdev) { + rc = -ENOMEM; + goto unlock; + } + + if (!zpci_aipb) + rc = zpci_setup_aipb(nisc); + else + rc = zpci_reset_aipb(nisc); + if (rc) + goto free_zdev; + + /* Enable floating IRQs */ + if (__set_irq_noiib(SIC_IRQ_MODE_SINGLE, nisc)) { + rc = -EIO; + kvm_s390_pci_aen_exit(); + } + + goto unlock; + +free_zdev: + kfree(aift->kzdev); +unlock: + mutex_unlock(&aift->aift_lock); + return rc; +} int kvm_s390_pci_dev_open(struct zpci_dev *zdev) { @@ -36,3 +178,15 @@ void kvm_s390_pci_dev_release(struct zpci_dev *zdev) kfree(kzdev); } EXPORT_SYMBOL_GPL(kvm_s390_pci_dev_release); + +int kvm_s390_pci_init(void) +{ + aift = kzalloc(sizeof(struct zpci_aift), GFP_KERNEL); + if (!aift) + return -ENOMEM; + + spin_lock_init(&aift->gait_lock); + mutex_init(&aift->aift_lock); + + return 0; +} diff --git a/arch/s390/kvm/pci.h b/arch/s390/kvm/pci.h new file mode 100644 index 000000000000..53e9968707c8 --- /dev/null +++ b/arch/s390/kvm/pci.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * s390 kvm PCI passthrough support + * + * Copyright IBM Corp. 2021 + * + * Author(s): Matthew Rosato + */ + +#ifndef __KVM_S390_PCI_H +#define __KVM_S390_PCI_H + +#include +#include +#include +#include + +struct zpci_gaite { + u32 gisa; + u8 gisc; + u8 count; + u8 reserved; + u8 aisbo; + u64 aisb; +}; + +struct zpci_aift { + struct zpci_gaite *gait; + struct airq_iv *sbv; + struct kvm_zdev **kzdev; + spinlock_t gait_lock; /* Protects the gait, used during AEN forward */ + struct mutex aift_lock; /* Protects the other structures in aift */ +}; + +extern struct zpci_aift *aift; + +int kvm_s390_pci_aen_init(u8 nisc); +void kvm_s390_pci_aen_exit(void); + +int kvm_s390_pci_init(void); + +#endif /* __KVM_S390_PCI_H */ diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 04c16312ad54..13033717cd4e 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -61,6 +61,12 @@ DEFINE_STATIC_KEY_FALSE(have_mio); static struct kmem_cache *zdev_fmb_cache; +/* AEN structures that must be preserved over KVM module re-insertion */ +union zpci_sic_iib *zpci_aipb; +EXPORT_SYMBOL_GPL(zpci_aipb); +struct airq_iv *zpci_aif_sbv; +EXPORT_SYMBOL_GPL(zpci_aif_sbv); + struct zpci_dev *get_zdev_by_fid(u32 fid) { struct zpci_dev *tmp, *zdev = NULL; From patchwork Fri Feb 4 21:15:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735663 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C890C433EF for ; Fri, 4 Feb 2022 21:17:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242439AbiBDVQ7 (ORCPT ); Fri, 4 Feb 2022 16:16:59 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:64684 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242764AbiBDVQV (ORCPT ); Fri, 4 Feb 2022 16:16:21 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214KH1bg006848; Fri, 4 Feb 2022 21:16:21 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=Rycd5dNw/e2/SCZSphz5BmRMDR5VqLX+6o01l5Tl6/E=; b=VM3F1pcEDB0783IMcDNXTjDfRT8zGcG0Nr77IqRN3aeF4bIbkPhg++3FLJ9BSeLsvdfO P+zBz8ZQlDlRw/hL7jjKduFu3j5Zya1x2+GI9PB609OWcEhAixxotz0udf+v7ZXUYC9c eJF51Th3zUfED4fSX8sj8muVoQV6fxugGgEKIIOXz3r1qxYSzJ2Z+B8P1OOYtBfF7Zbe wnZ2mj8izyf/0kTbjUEjf7qj9VV9JrL8pu/dPdtrPTvwmAaBtCAlVhOGEvHTgUpQH3ic DCNvPK2FseyPJQLPovz1qa1HJGAkISQS9Tl2g2cn/2rvX3hxk/nWzb3BscFwkqOjOugX sg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx0xsdw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:21 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214L1xjc016240; Fri, 4 Feb 2022 21:16:21 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx0xsdj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:21 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LD5BI009647; Fri, 4 Feb 2022 21:16:20 GMT Received: from b03cxnp07027.gho.boulder.ibm.com (b03cxnp07027.gho.boulder.ibm.com [9.17.130.14]) by ppma01dal.us.ibm.com with ESMTP id 3e0r0syese-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:19 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGHVl24052098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:17 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5DD85136060; Fri, 4 Feb 2022 21:16:17 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D0BF13606A; Fri, 4 Feb 2022 21:16:15 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:15 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 17/30] KVM: s390: pci: enable host forwarding of Adapter Event Notifications Date: Fri, 4 Feb 2022 16:15:23 -0500 Message-Id: <20220204211536.321475-18-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: PL-IpC44wHVA6JrYcfwAnxoJ_lL89jgv X-Proofpoint-ORIG-GUID: poa0D5MzdaO-RsAG7RKExnwbQp7arQSq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 spamscore=0 malwarescore=0 phishscore=0 priorityscore=1501 impostorscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org In cases where interrupts are not forwarded to the guest via firmware, KVM is responsible for ensuring delivery. When an interrupt presents with the forwarding bit, we must process the forwarding tables until all interrupts are delivered. Signed-off-by: Matthew Rosato --- arch/s390/include/asm/kvm_host.h | 1 + arch/s390/include/asm/tpi.h | 13 ++++++ arch/s390/kvm/interrupt.c | 77 +++++++++++++++++++++++++++++++- arch/s390/kvm/kvm-s390.c | 3 +- arch/s390/kvm/pci.h | 10 +++++ 5 files changed, 102 insertions(+), 2 deletions(-) diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h index a22c9266ea05..b468d3a2215e 100644 --- a/arch/s390/include/asm/kvm_host.h +++ b/arch/s390/include/asm/kvm_host.h @@ -757,6 +757,7 @@ struct kvm_vm_stat { u64 inject_pfault_done; u64 inject_service_signal; u64 inject_virtio; + u64 aen_forward; }; struct kvm_arch_memory_slot { diff --git a/arch/s390/include/asm/tpi.h b/arch/s390/include/asm/tpi.h index 1ac538b8cbf5..f76e5fdff23a 100644 --- a/arch/s390/include/asm/tpi.h +++ b/arch/s390/include/asm/tpi.h @@ -19,6 +19,19 @@ struct tpi_info { u32 :12; } __packed __aligned(4); +/* I/O-Interruption Code as stored by TPI for an Adapter I/O */ +struct tpi_adapter_info { + u32 aism:8; + u32 :22; + u32 error:1; + u32 forward:1; + u32 reserved; + u32 adapter_IO:1; + u32 directed_irq:1; + u32 isc:3; + u32 :27; +} __packed __aligned(4); + #endif /* __ASSEMBLY__ */ #endif /* _ASM_S390_TPI_H */ diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c index 5e638f7c86f8..74a549d3d1e4 100644 --- a/arch/s390/kvm/interrupt.c +++ b/arch/s390/kvm/interrupt.c @@ -3271,11 +3271,86 @@ int kvm_s390_gisc_unregister(struct kvm *kvm, u32 gisc) } EXPORT_SYMBOL_GPL(kvm_s390_gisc_unregister); +static void aen_host_forward(unsigned long si) +{ + struct kvm_s390_gisa_interrupt *gi; + struct zpci_gaite *gaite; + struct kvm *kvm; + + gaite = (struct zpci_gaite *)aift->gait + + (si * sizeof(struct zpci_gaite)); + if (gaite->count == 0) + return; + if (gaite->aisb != 0) + set_bit_inv(gaite->aisbo, (unsigned long *)gaite->aisb); + + kvm = kvm_s390_pci_si_to_kvm(aift, si); + if (kvm == 0) + return; + gi = &kvm->arch.gisa_int; + + if (!(gi->origin->g1.simm & AIS_MODE_MASK(gaite->gisc)) || + !(gi->origin->g1.nimm & AIS_MODE_MASK(gaite->gisc))) { + gisa_set_ipm_gisc(gi->origin, gaite->gisc); + if (hrtimer_active(&gi->timer)) + hrtimer_cancel(&gi->timer); + hrtimer_start(&gi->timer, 0, HRTIMER_MODE_REL); + kvm->stat.aen_forward++; + } +} + +static void aen_process_gait(u8 isc) +{ + bool found = false, first = true; + union zpci_sic_iib iib = {{0}}; + unsigned long si, flags; + + spin_lock_irqsave(&aift->gait_lock, flags); + + if (!aift->gait) { + spin_unlock_irqrestore(&aift->gait_lock, flags); + return; + } + + for (si = 0;;) { + /* Scan adapter summary indicator bit vector */ + si = airq_iv_scan(aift->sbv, si, airq_iv_end(aift->sbv)); + if (si == -1UL) { + if (first || found) { + /* Reenable interrupts. */ + if (zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, isc, + &iib)) + break; + first = found = false; + } else { + /* Interrupts on and all bits processed */ + break; + } + found = false; + si = 0; + continue; + } + found = true; + aen_host_forward(si); + } + + spin_unlock_irqrestore(&aift->gait_lock, flags); +} + static void gib_alert_irq_handler(struct airq_struct *airq, struct tpi_info *tpi_info) { + struct tpi_adapter_info *info = (struct tpi_adapter_info *)tpi_info; + inc_irq_stat(IRQIO_GAL); - process_gib_alert_list(); + + if (IS_ENABLED(CONFIG_VFIO_PCI_ZDEV) && + (info->forward || info->error)) { + aen_process_gait(info->isc); + if (info->aism != 0) + process_gib_alert_list(); + } else + process_gib_alert_list(); } static struct airq_struct gib_alert_irq = { diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index dd4f4bfb326b..24837d6050dc 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -65,7 +65,8 @@ const struct _kvm_stats_desc kvm_vm_stats_desc[] = { STATS_DESC_COUNTER(VM, inject_float_mchk), STATS_DESC_COUNTER(VM, inject_pfault_done), STATS_DESC_COUNTER(VM, inject_service_signal), - STATS_DESC_COUNTER(VM, inject_virtio) + STATS_DESC_COUNTER(VM, inject_virtio), + STATS_DESC_COUNTER(VM, aen_forward) }; const struct kvm_stats_header kvm_vm_stats_header = { diff --git a/arch/s390/kvm/pci.h b/arch/s390/kvm/pci.h index 53e9968707c8..4d3db58beb74 100644 --- a/arch/s390/kvm/pci.h +++ b/arch/s390/kvm/pci.h @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -34,6 +35,15 @@ struct zpci_aift { extern struct zpci_aift *aift; +static inline struct kvm *kvm_s390_pci_si_to_kvm(struct zpci_aift *aift, + unsigned long si) +{ + if (!IS_ENABLED(CONFIG_VFIO_PCI_ZDEV) || aift->kzdev == 0 || + aift->kzdev[si] == 0) + return 0; + return aift->kzdev[si]->kvm; +}; + int kvm_s390_pci_aen_init(u8 nisc); void kvm_s390_pci_aen_exit(void); From patchwork Fri Feb 4 21:15:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735662 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE505C433FE for ; Fri, 4 Feb 2022 21:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242532AbiBDVQ5 (ORCPT ); Fri, 4 Feb 2022 16:16:57 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:45148 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234625AbiBDVQW (ORCPT ); Fri, 4 Feb 2022 16:16:22 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214KwNtU011886; Fri, 4 Feb 2022 21:16:22 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=OjHCdLS4xobQYmfhl2UiVVz0dW3vHl/eDvYM38A6J3U=; b=H3BGo892ckSF2F76fHAtdUUWlk5jTPLjnpjYZgi9oARoTs6WWv/RgeXI4bRki99oHh6+ RPAyrgtCBHcF13laEJ/+jyCYJ4KO0A+k1S7WRWlcQ437xJ0XOVD7QPJZ0Tc6ptAtJ0Jf sMz9IcQGKYBKp22vykVHelCawoDcf426jhz2cdoSB0AV6h4nS1EMslmo1VVA9UYxLOl5 rvG+3WEBv5znplVTUXpW9QgRj32/Ignef5R2osA/O+VrDsf1WFRWZb3M3v5Yn/xDTtxT DxHiy3zW0uPLLUrBgPTxB/yk40spmdcjdco2NPXI2Jk16ZJ4u+vfGO1xL19mGFTEY2H7 ew== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0vrs2gpn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:21 +0000 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214LDkC8028403; Fri, 4 Feb 2022 21:16:21 GMT Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0vrs2gpf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:21 +0000 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LDNC1006312; Fri, 4 Feb 2022 21:16:20 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma03wdc.us.ibm.com with ESMTP id 3e0r0yavyy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:20 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGJwQ36045256 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:19 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4FCBF136051; Fri, 4 Feb 2022 21:16:19 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8A821136063; Fri, 4 Feb 2022 21:16:17 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:17 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 18/30] KVM: s390: mechanism to enable guest zPCI Interpretation Date: Fri, 4 Feb 2022 16:15:24 -0500 Message-Id: <20220204211536.321475-19-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: qHFwUgj1SmHc0pmoocVZr8MubmgNarrp X-Proofpoint-ORIG-GUID: Pqq75zanxkSXxt49WRdu2S10YEBvu1ik X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 suspectscore=0 impostorscore=0 bulkscore=0 clxscore=1015 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The guest must have access to certain facilities in order to allow interpretive execution of zPCI instructions and adapter event notifications. However, there are some cases where a guest might disable interpretation -- provide a mechanism via which we can defer enabling the associated zPCI interpretation facilities until the guest indicates it wishes to use them. Signed-off-by: Matthew Rosato Acked-by: Pierre Morel --- arch/s390/include/asm/kvm_host.h | 4 ++++ arch/s390/kvm/kvm-s390.c | 40 ++++++++++++++++++++++++++++++++ arch/s390/kvm/kvm-s390.h | 10 ++++++++ 3 files changed, 54 insertions(+) diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h index b468d3a2215e..bf61ab05f98c 100644 --- a/arch/s390/include/asm/kvm_host.h +++ b/arch/s390/include/asm/kvm_host.h @@ -252,7 +252,10 @@ struct kvm_s390_sie_block { #define ECB2_IEP 0x20 #define ECB2_PFMFI 0x08 #define ECB2_ESCA 0x04 +#define ECB2_ZPCI_LSI 0x02 __u8 ecb2; /* 0x0062 */ +#define ECB3_AISI 0x20 +#define ECB3_AISII 0x10 #define ECB3_DEA 0x08 #define ECB3_AES 0x04 #define ECB3_RI 0x01 @@ -938,6 +941,7 @@ struct kvm_arch{ int use_cmma; int use_pfmfi; int use_skf; + int use_zpci_interp; int user_cpu_state_ctrl; int user_sigp; int user_stsi; diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 24837d6050dc..208b09d08385 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -1029,6 +1029,44 @@ static int kvm_s390_vm_set_crypto(struct kvm *kvm, struct kvm_device_attr *attr) return 0; } +static void kvm_s390_vcpu_pci_setup(struct kvm_vcpu *vcpu) +{ + /* Only set the ECB bits after guest requests zPCI interpretation */ + if (!vcpu->kvm->arch.use_zpci_interp) + return; + + vcpu->arch.sie_block->ecb2 |= ECB2_ZPCI_LSI; + vcpu->arch.sie_block->ecb3 |= ECB3_AISII + ECB3_AISI; +} + +void kvm_s390_vcpu_pci_enable_interp(struct kvm *kvm) +{ + struct kvm_vcpu *vcpu; + unsigned long i; + + /* + * If host is configured for PCI and the necessary facilities are + * available, turn on interpretation for the life of this guest + */ + if (!IS_ENABLED(CONFIG_VFIO_PCI_ZDEV) || !sclp.has_zpci_lsi || + !sclp.has_aisii || !sclp.has_aeni || !sclp.has_aisi) + return; + + mutex_lock(&kvm->lock); + + kvm->arch.use_zpci_interp = 1; + + kvm_s390_vcpu_block_all(kvm); + + kvm_for_each_vcpu(i, vcpu, kvm) { + kvm_s390_vcpu_pci_setup(vcpu); + kvm_s390_sync_request(KVM_REQ_VSIE_RESTART, vcpu); + } + + kvm_s390_vcpu_unblock_all(kvm); + mutex_unlock(&kvm->lock); +} + static void kvm_s390_sync_request_broadcast(struct kvm *kvm, int req) { unsigned long cx; @@ -3236,6 +3274,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) kvm_s390_vcpu_crypto_setup(vcpu); + kvm_s390_vcpu_pci_setup(vcpu); + mutex_lock(&vcpu->kvm->lock); if (kvm_s390_pv_is_protected(vcpu->kvm)) { rc = kvm_s390_pv_create_cpu(vcpu, &uvrc, &uvrrc); diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h index 098831e815e6..14bb2539f837 100644 --- a/arch/s390/kvm/kvm-s390.h +++ b/arch/s390/kvm/kvm-s390.h @@ -496,6 +496,16 @@ void kvm_s390_reinject_machine_check(struct kvm_vcpu *vcpu, */ void kvm_s390_vcpu_crypto_reset_all(struct kvm *kvm); +/** + * kvm_s390_vcpu_pci_enable_interp + * + * Set the associated PCI attributes for each vcpu to allow for zPCI Load/Store + * interpretation as well as adapter interruption forwarding. + * + * @kvm: the KVM guest + */ +void kvm_s390_vcpu_pci_enable_interp(struct kvm *kvm); + /** * diag9c_forwarding_hz * From patchwork Fri Feb 4 21:15:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735664 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 768B4C433FE for ; Fri, 4 Feb 2022 21:17:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243137AbiBDVRR (ORCPT ); Fri, 4 Feb 2022 16:17:17 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54872 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243096AbiBDVQZ (ORCPT ); Fri, 4 Feb 2022 16:16:25 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214JxBRV017309; Fri, 4 Feb 2022 21:16:24 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=BHrYgIH1G5YQBgkXUTVvN2xQbz46N+yXKMrEuyz4n0Q=; b=p+7fcUgoMrHlBVVIuDMYGCVFD5674rmHSvcZ/NFyt6GJcDxUWygrme9xj+r8bfM9UMTb /zczWXTrxWpHyekgoIXa3YKeuZripfCUkfX/iQQeSJjVUIWtbw5MjLecEcWV0QaEM3KS MetP9QX+cPkmcdiE+H8837HFdNfjL1LujWEzEl9HdUrc0vEK5LtazPwdFa7t+PbeWG+Q 2CN/ibgo//LVAq0GrN6Rjhrd/0wf+S5gvqhjEkIIayiaPQzPU6+pXyARd4q4q5fV7SgA LpeuoHu3No5DbmymDqZEC53Ux/gHBPa7VWJ6WsGFw0bKm9a0WqlcQxSZ7JBKjPbnGfXE Sw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx9ew2n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:24 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214L3orC018555; Fri, 4 Feb 2022 21:16:24 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx9ew1w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:24 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCaGl021806; Fri, 4 Feb 2022 21:16:23 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma03dal.us.ibm.com with ESMTP id 3e0r0k7gx7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:23 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGLok37421482 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:21 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 41431136060; Fri, 4 Feb 2022 21:16:21 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 71FA6136055; Fri, 4 Feb 2022 21:16:19 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:19 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 19/30] KVM: s390: pci: provide routines for enabling/disabling interpretation Date: Fri, 4 Feb 2022 16:15:25 -0500 Message-Id: <20220204211536.321475-20-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: z-IsFruyxBsj1cc6oxF-ijN4SE8Hird2 X-Proofpoint-ORIG-GUID: uUj4ybssPPMD4kK4xu27gEFBlnvQJc9w X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 spamscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org These routines will be wired into the vfio_pci_zdev ioctl handlers to respond to requests to enable / disable a device for zPCI Load/Store interpretation. The first time such a request is received, enable the necessary facilities for the guest. Signed-off-by: Matthew Rosato Reviewed-by: Pierre Morel --- arch/s390/include/asm/kvm_pci.h | 4 ++ arch/s390/kvm/pci.c | 102 ++++++++++++++++++++++++++++++++ arch/s390/pci/pci.c | 3 + 3 files changed, 109 insertions(+) diff --git a/arch/s390/include/asm/kvm_pci.h b/arch/s390/include/asm/kvm_pci.h index ef10f9e46e37..422701d526dd 100644 --- a/arch/s390/include/asm/kvm_pci.h +++ b/arch/s390/include/asm/kvm_pci.h @@ -24,4 +24,8 @@ struct kvm_zdev { int kvm_s390_pci_dev_open(struct zpci_dev *zdev); void kvm_s390_pci_dev_release(struct zpci_dev *zdev); +int kvm_s390_pci_interp_probe(struct zpci_dev *zdev); +int kvm_s390_pci_interp_enable(struct zpci_dev *zdev); +int kvm_s390_pci_interp_disable(struct zpci_dev *zdev); + #endif /* ASM_KVM_PCI_H */ diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c index 9b8390133e15..16bef3935284 100644 --- a/arch/s390/kvm/pci.c +++ b/arch/s390/kvm/pci.c @@ -12,7 +12,9 @@ #include #include #include +#include #include "pci.h" +#include "kvm-s390.h" struct zpci_aift *aift; @@ -153,6 +155,106 @@ int kvm_s390_pci_aen_init(u8 nisc) return rc; } +int kvm_s390_pci_interp_probe(struct zpci_dev *zdev) +{ + /* Must have appropriate hardware facilities */ + if (!sclp.has_zpci_lsi || !sclp.has_aisii || !sclp.has_aeni || + !sclp.has_aisi || !test_facility(69) || !test_facility(70) || + !test_facility(71) || !test_facility(72)) { + return -EINVAL; + } + + /* Must have a KVM association registered */ + if (!zdev->kzdev || !zdev->kzdev->kvm) + return -EINVAL; + + return 0; +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_interp_probe); + +int kvm_s390_pci_interp_enable(struct zpci_dev *zdev) +{ + u32 gisa; + int rc; + + if (!zdev->kzdev || !zdev->kzdev->kvm) + return -EINVAL; + + /* + * If this is the first request to use an interpreted device, make the + * necessary vcpu changes + */ + if (!zdev->kzdev->kvm->arch.use_zpci_interp) + kvm_s390_vcpu_pci_enable_interp(zdev->kzdev->kvm); + + /* + * In the event of a system reset in userspace, the GISA designation + * may still be assigned because the device is still enabled. + * Verify it's the same guest before proceeding. + */ + gisa = (u32)virt_to_phys(&zdev->kzdev->kvm->arch.sie_page2->gisa); + if (zdev->gisa != 0 && zdev->gisa != gisa) + return -EPERM; + + if (zdev_enabled(zdev)) { + zdev->gisa = 0; + rc = zpci_disable_device(zdev); + if (rc) + return rc; + } + + /* + * Store information about the identity of the kvm guest allowed to + * access this device via interpretation to be used by host CLP + */ + zdev->gisa = gisa; + + rc = zpci_enable_device(zdev); + if (rc) + goto err; + + /* Re-register the IOMMU that was already created */ + rc = zpci_register_ioat(zdev, 0, zdev->start_dma, zdev->end_dma, + virt_to_phys(zdev->dma_table)); + if (rc) + goto err; + + return rc; + +err: + zdev->gisa = 0; + return rc; +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_interp_enable); + +int kvm_s390_pci_interp_disable(struct zpci_dev *zdev) +{ + int rc; + + if (zdev->gisa == 0) + return -EINVAL; + + /* Remove the host CLP guest designation */ + zdev->gisa = 0; + + if (zdev_enabled(zdev)) { + rc = zpci_disable_device(zdev); + if (rc) + return rc; + } + + rc = zpci_enable_device(zdev); + if (rc) + return rc; + + /* Re-register the IOMMU that was already created */ + rc = zpci_register_ioat(zdev, 0, zdev->start_dma, zdev->end_dma, + virt_to_phys(zdev->dma_table)); + + return rc; +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_interp_disable); + int kvm_s390_pci_dev_open(struct zpci_dev *zdev) { struct kvm_zdev *kzdev; diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 13033717cd4e..5dbe49ec325e 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -147,6 +147,7 @@ int zpci_register_ioat(struct zpci_dev *zdev, u8 dmaas, zpci_dbg(3, "reg ioat fid:%x, cc:%d, status:%d\n", zdev->fid, cc, status); return cc; } +EXPORT_SYMBOL_GPL(zpci_register_ioat); /* Modify PCI: Unregister I/O address translation parameters */ int zpci_unregister_ioat(struct zpci_dev *zdev, u8 dmaas) @@ -727,6 +728,7 @@ int zpci_enable_device(struct zpci_dev *zdev) zpci_update_fh(zdev, fh); return rc; } +EXPORT_SYMBOL_GPL(zpci_enable_device); int zpci_disable_device(struct zpci_dev *zdev) { @@ -750,6 +752,7 @@ int zpci_disable_device(struct zpci_dev *zdev) } return rc; } +EXPORT_SYMBOL_GPL(zpci_disable_device); /** * zpci_hot_reset_device - perform a reset of the given zPCI function From patchwork Fri Feb 4 21:15:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 949CFC43217 for ; Fri, 4 Feb 2022 21:17:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245490AbiBDVRS (ORCPT ); Fri, 4 Feb 2022 16:17:18 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:29354 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241678AbiBDVQ1 (ORCPT ); Fri, 4 Feb 2022 16:16:27 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214KKx4n005571; Fri, 4 Feb 2022 21:16:26 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=h3FKPKin2SVg5XJRUV66QBhHu5Fva/dFwXTOoBi64M8=; b=DXm+DoNjYqRsFxpBmg/SHhZHA70x97EiqRds1zYWSMqqZeUjxrt9qEtevFr4b935MySc xJZiI+f+yqo56uwUOzxr/QgG/Wtkmc12u3Vx0gRcPUPNLi36euk+C7lmvDyFfYQA5Bes rAXUiuNCfmyKfMvFsMpn+yZntQN6txNwrl6HB8J6/l0HrPPpYduMwxXAhaoYwGwhG7Hj sOZboGr0tR5yD72N5EeXH7r/jkRrjHcAy7JCIWROnO+Vfpm1B7xde/ISMOcW5iT8Zvg3 +HROdTFV01/seFFG40/tKDW3Lz9isDh9WvpxFJI47xsrOwzPviXia/RJRvmTa+GPl0hQ CA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0r12pbmd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:26 +0000 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214LGQtQ021787; Fri, 4 Feb 2022 21:16:26 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0r12pbm1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:26 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCc7q021946; Fri, 4 Feb 2022 21:16:25 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma03dal.us.ibm.com with ESMTP id 3e0r0k7gxs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:25 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGNAn32178490 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:23 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 35FDD136055; Fri, 4 Feb 2022 21:16:23 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 64D7F13606F; Fri, 4 Feb 2022 21:16:21 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:21 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 20/30] KVM: s390: pci: provide routines for enabling/disabling interrupt forwarding Date: Fri, 4 Feb 2022 16:15:26 -0500 Message-Id: <20220204211536.321475-21-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 8ywpZxeX8Uq5H2rdEnCdiMKsGObnoMOo X-Proofpoint-ORIG-GUID: 68vekUC4Sao2n5RjwAe7v3294NQYR1Zb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 impostorscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 suspectscore=0 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org These routines will be wired into the vfio_pci_zdev ioctl handlers to respond to requests to enable / disable a device for Adapter Event Notifications / Adapter Interuption Forwarding. Signed-off-by: Matthew Rosato --- arch/s390/include/asm/kvm_pci.h | 9 +- arch/s390/kvm/pci.c | 217 +++++++++++++++++++++++++++++++- arch/s390/pci/pci_insn.c | 1 + 3 files changed, 225 insertions(+), 2 deletions(-) diff --git a/arch/s390/include/asm/kvm_pci.h b/arch/s390/include/asm/kvm_pci.h index 422701d526dd..377eebcba2d1 100644 --- a/arch/s390/include/asm/kvm_pci.h +++ b/arch/s390/include/asm/kvm_pci.h @@ -15,17 +15,24 @@ #include #include #include +#include struct kvm_zdev { struct zpci_dev *zdev; struct kvm *kvm; + struct zpci_fib fib; }; int kvm_s390_pci_dev_open(struct zpci_dev *zdev); void kvm_s390_pci_dev_release(struct zpci_dev *zdev); +int kvm_s390_pci_aif_probe(struct zpci_dev *zdev); +int kvm_s390_pci_aif_enable(struct zpci_dev *zdev, struct zpci_fib *fib, + bool assist); +int kvm_s390_pci_aif_disable(struct zpci_dev *zdev, bool force); + int kvm_s390_pci_interp_probe(struct zpci_dev *zdev); int kvm_s390_pci_interp_enable(struct zpci_dev *zdev); -int kvm_s390_pci_interp_disable(struct zpci_dev *zdev); +int kvm_s390_pci_interp_disable(struct zpci_dev *zdev, bool force); #endif /* ASM_KVM_PCI_H */ diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c index 16bef3935284..8e9044a7bce7 100644 --- a/arch/s390/kvm/pci.c +++ b/arch/s390/kvm/pci.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "pci.h" #include "kvm-s390.h" @@ -155,6 +156,216 @@ int kvm_s390_pci_aen_init(u8 nisc) return rc; } +/* Modify PCI: Register floating adapter interruption forwarding */ +static int kvm_zpci_set_airq(struct zpci_dev *zdev) +{ + u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_REG_INT); + struct zpci_fib fib = {}; + u8 status; + + fib.fmt0.isc = zdev->kzdev->fib.fmt0.isc; + fib.fmt0.sum = 1; /* enable summary notifications */ + fib.fmt0.noi = airq_iv_end(zdev->aibv); + fib.fmt0.aibv = virt_to_phys(zdev->aibv->vector); + fib.fmt0.aibvo = 0; + fib.fmt0.aisb = virt_to_phys(aift->sbv->vector + (zdev->aisb / 64) * 8); + fib.fmt0.aisbo = zdev->aisb & 63; + fib.gd = zdev->gisa; + + return zpci_mod_fc(req, &fib, &status) ? -EIO : 0; +} + +/* Modify PCI: Unregister floating adapter interruption forwarding */ +static int kvm_zpci_clear_airq(struct zpci_dev *zdev) +{ + u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_DEREG_INT); + struct zpci_fib fib = {}; + u8 cc, status; + + fib.gd = zdev->gisa; + + cc = zpci_mod_fc(req, &fib, &status); + if (cc == 3 || (cc == 1 && status == 24)) + /* Function already gone or IRQs already deregistered. */ + cc = 0; + + return cc ? -EIO : 0; +} + +int kvm_s390_pci_aif_probe(struct zpci_dev *zdev) +{ + /* Must have appropriate hardware facilities */ + if (!(sclp.has_aeni && test_facility(71))) + return -EINVAL; + + /* Must have a KVM association registered */ + if (!zdev->kzdev || !zdev->kzdev->kvm) + return -EINVAL; + + return 0; +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_aif_probe); + +int kvm_s390_pci_aif_enable(struct zpci_dev *zdev, struct zpci_fib *fib, + bool assist) +{ + struct page *aibv_page, *aisb_page = NULL; + unsigned int msi_vecs, idx; + struct zpci_gaite *gaite; + unsigned long bit; + struct kvm *kvm; + phys_addr_t gaddr; + int rc = 0, gisc; + + /* + * Interrupt forwarding is only applicable if the device is already + * enabled for interpretation + */ + if (zdev->gisa == 0) + return -EINVAL; + + kvm = zdev->kzdev->kvm; + msi_vecs = min_t(unsigned int, fib->fmt0.noi, zdev->max_msi); + + /* Get the associated forwarding ISC - if invalid, return the error */ + gisc = kvm_s390_gisc_register(kvm, fib->fmt0.isc); + if (gisc < 0) + return gisc; + + /* Replace AIBV address */ + idx = srcu_read_lock(&kvm->srcu); + aibv_page = gfn_to_page(kvm, gpa_to_gfn((gpa_t)fib->fmt0.aibv)); + srcu_read_unlock(&kvm->srcu, idx); + if (is_error_page(aibv_page)) { + rc = -EIO; + goto out; + } + gaddr = page_to_phys(aibv_page) + (fib->fmt0.aibv & ~PAGE_MASK); + fib->fmt0.aibv = gaddr; + + /* Pin the guest AISB if one was specified */ + if (fib->fmt0.sum == 1) { + idx = srcu_read_lock(&kvm->srcu); + aisb_page = gfn_to_page(kvm, gpa_to_gfn((gpa_t)fib->fmt0.aisb)); + srcu_read_unlock(&kvm->srcu, idx); + if (is_error_page(aisb_page)) { + rc = -EIO; + goto unpin1; + } + } + + /* AISB must be allocated before we can fill in GAITE */ + mutex_lock(&aift->aift_lock); + bit = airq_iv_alloc_bit(aift->sbv); + if (bit == -1UL) + goto unpin2; + zdev->aisb = bit; /* store the summary bit number */ + zdev->aibv = airq_iv_create(msi_vecs, AIRQ_IV_DATA | + AIRQ_IV_BITLOCK | + AIRQ_IV_GUESTVEC, + phys_to_virt(fib->fmt0.aibv)); + + spin_lock_irq(&aift->gait_lock); + gaite = (struct zpci_gaite *)aift->gait + (zdev->aisb * + sizeof(struct zpci_gaite)); + + /* If assist not requested, host will get all alerts */ + if (assist) + gaite->gisa = (u32)virt_to_phys(&kvm->arch.sie_page2->gisa); + else + gaite->gisa = 0; + + gaite->gisc = fib->fmt0.isc; + gaite->count++; + gaite->aisbo = fib->fmt0.aisbo; + gaite->aisb = virt_to_phys(page_address(aisb_page) + (fib->fmt0.aisb & + ~PAGE_MASK)); + aift->kzdev[zdev->aisb] = zdev->kzdev; + spin_unlock_irq(&aift->gait_lock); + + /* Update guest FIB for re-issue */ + fib->fmt0.aisbo = zdev->aisb & 63; + fib->fmt0.aisb = virt_to_phys(aift->sbv->vector + (zdev->aisb / 64) * 8); + fib->fmt0.isc = gisc; + + /* Save some guest fib values in the host for later use */ + zdev->kzdev->fib.fmt0.isc = fib->fmt0.isc; + zdev->kzdev->fib.fmt0.aibv = fib->fmt0.aibv; + mutex_unlock(&aift->aift_lock); + + /* Issue the clp to setup the irq now */ + rc = kvm_zpci_set_airq(zdev); + return rc; + +unpin2: + mutex_unlock(&aift->aift_lock); + if (fib->fmt0.sum == 1) { + gaddr = page_to_phys(aisb_page); + kvm_release_pfn_dirty(gaddr >> PAGE_SHIFT); + } +unpin1: + kvm_release_pfn_dirty(fib->fmt0.aibv >> PAGE_SHIFT); +out: + return rc; +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_aif_enable); + +int kvm_s390_pci_aif_disable(struct zpci_dev *zdev, bool force) +{ + struct kvm_zdev *kzdev = zdev->kzdev; + struct zpci_gaite *gaite; + int rc; + u8 isc; + + if (zdev->gisa == 0) + return -EINVAL; + + mutex_lock(&aift->aift_lock); + + /* + * If the clear fails due to an error, leave now unless we know this + * device is about to go away (force) -- In that case clear the GAITE + * regardless. + */ + rc = kvm_zpci_clear_airq(zdev); + if (rc && !force) + goto out; + + if (zdev->kzdev->fib.fmt0.aibv == 0) + goto out; + spin_lock_irq(&aift->gait_lock); + gaite = (struct zpci_gaite *)aift->gait + (zdev->aisb * + sizeof(struct zpci_gaite)); + isc = gaite->gisc; + gaite->count--; + if (gaite->count == 0) { + /* Release guest AIBV and AISB */ + kvm_release_pfn_dirty(kzdev->fib.fmt0.aibv >> PAGE_SHIFT); + if (gaite->aisb != 0) + kvm_release_pfn_dirty(gaite->aisb >> PAGE_SHIFT); + /* Clear the GAIT entry */ + gaite->aisb = 0; + gaite->gisc = 0; + gaite->aisbo = 0; + gaite->gisa = 0; + aift->kzdev[zdev->aisb] = 0; + /* Clear zdev info */ + airq_iv_free_bit(aift->sbv, zdev->aisb); + airq_iv_release(zdev->aibv); + zdev->aisb = 0; + zdev->aibv = NULL; + } + spin_unlock_irq(&aift->gait_lock); + kvm_s390_gisc_unregister(kzdev->kvm, isc); + kzdev->fib.fmt0.isc = 0; + kzdev->fib.fmt0.aibv = 0; +out: + mutex_unlock(&aift->aift_lock); + + return rc; +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_aif_disable); + int kvm_s390_pci_interp_probe(struct zpci_dev *zdev) { /* Must have appropriate hardware facilities */ @@ -227,13 +438,17 @@ int kvm_s390_pci_interp_enable(struct zpci_dev *zdev) } EXPORT_SYMBOL_GPL(kvm_s390_pci_interp_enable); -int kvm_s390_pci_interp_disable(struct zpci_dev *zdev) +int kvm_s390_pci_interp_disable(struct zpci_dev *zdev, bool force) { int rc; if (zdev->gisa == 0) return -EINVAL; + /* Forwarding must be turned off before interpretation */ + if (zdev->kzdev->fib.fmt0.aibv != 0) + kvm_s390_pci_aif_disable(zdev, force); + /* Remove the host CLP guest designation */ zdev->gisa = 0; diff --git a/arch/s390/pci/pci_insn.c b/arch/s390/pci/pci_insn.c index ca6399d52767..f7d0e29bbf0b 100644 --- a/arch/s390/pci/pci_insn.c +++ b/arch/s390/pci/pci_insn.c @@ -59,6 +59,7 @@ u8 zpci_mod_fc(u64 req, struct zpci_fib *fib, u8 *status) return cc; } +EXPORT_SYMBOL_GPL(zpci_mod_fc); /* Refresh PCI Translations */ static inline u8 __rpcit(u64 fn, u64 addr, u64 range, u8 *status) From patchwork Fri Feb 4 21:15:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735666 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1D40C433FE for ; Fri, 4 Feb 2022 21:17:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242050AbiBDVRU (ORCPT ); Fri, 4 Feb 2022 16:17:20 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:29900 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241622AbiBDVQ3 (ORCPT ); Fri, 4 Feb 2022 16:16:29 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214L2tMp015915; Fri, 4 Feb 2022 21:16:29 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=bL0tk3lLqAggK8Z5WMLaCYQCJPhbjjqs32HKAtitwj8=; b=lN3M6Qz3NAobQqnQdVQ8RCPQyMDjQ7LpBqLXtXF8hkUPQK/XKYqAR4T0gGRFR2zP1PtX 1uoEjOjUL1EhZnDJ+ubk8zWRG65b1c8Nv2dg6z91D7ed/aErvsOn6PmUjXxk8dQri4GY HPvM2iYRP4UVCFJ53J9654IqwoIfR2UjtiY+mDFmdR41ZW9SEuzCgUq2QBttpdlpSa+c srmIdTBDJ/QNt3NPvhZ0vtNJjLl48x8yq1eA1PvNYHxCQWChogk40mykime+KtsQt7Id VnbCp5tP44zIcLFcMpHL2nYQhkxwGIkFqDeWYr+hH6MhAgTWOip29ZV0uoqeWyjiVvhC 7Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0rt5nn0a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:29 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214LGSbO003916; Fri, 4 Feb 2022 21:16:28 GMT Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0rt5nmyx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:28 +0000 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LDNQn006172; Fri, 4 Feb 2022 21:16:28 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma03wdc.us.ibm.com with ESMTP id 3e0r0yaw2q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:28 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGPjX16384314 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:25 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A905136066; Fri, 4 Feb 2022 21:16:25 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 635E9136055; Fri, 4 Feb 2022 21:16:23 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:23 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 21/30] KVM: s390: pci: provide routines for enabling/disabling IOAT assist Date: Fri, 4 Feb 2022 16:15:27 -0500 Message-Id: <20220204211536.321475-22-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: UCFS3e6dX3-19Fc3x_CN7KSryGV9VAsA X-Proofpoint-ORIG-GUID: Pn9dJu1eJlpzO3IfvmUmD6HI3PM5rYrB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 adultscore=0 phishscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org These routines will be wired into the vfio_pci_zdev ioctl handlers to respond to requests to enable / disable a device for PCI I/O Address Translation assistance. Signed-off-by: Matthew Rosato --- arch/s390/include/asm/kvm_pci.h | 15 ++++ arch/s390/include/asm/pci_dma.h | 2 + arch/s390/kvm/pci.c | 142 ++++++++++++++++++++++++++++++++ arch/s390/kvm/pci.h | 2 + 4 files changed, 161 insertions(+) diff --git a/arch/s390/include/asm/kvm_pci.h b/arch/s390/include/asm/kvm_pci.h index 377eebcba2d1..370d6ba041fe 100644 --- a/arch/s390/include/asm/kvm_pci.h +++ b/arch/s390/include/asm/kvm_pci.h @@ -15,11 +15,21 @@ #include #include #include +#include #include +#include + +struct kvm_zdev_ioat { + unsigned long *head[ZPCI_TABLE_PAGES]; + unsigned long **seg; + unsigned long ***pt; + struct mutex ioat_lock; /* Must be held when modifying head/seg/pt */ +}; struct kvm_zdev { struct zpci_dev *zdev; struct kvm *kvm; + struct kvm_zdev_ioat ioat; struct zpci_fib fib; }; @@ -31,6 +41,11 @@ int kvm_s390_pci_aif_enable(struct zpci_dev *zdev, struct zpci_fib *fib, bool assist); int kvm_s390_pci_aif_disable(struct zpci_dev *zdev, bool force); +int kvm_s390_pci_ioat_probe(struct zpci_dev *zdev); +int kvm_s390_pci_ioat_enable(struct zpci_dev *zdev, u64 iota); +int kvm_s390_pci_ioat_disable(struct zpci_dev *zdev); +u8 kvm_s390_pci_get_dtsm(struct zpci_dev *zdev); + int kvm_s390_pci_interp_probe(struct zpci_dev *zdev); int kvm_s390_pci_interp_enable(struct zpci_dev *zdev); int kvm_s390_pci_interp_disable(struct zpci_dev *zdev, bool force); diff --git a/arch/s390/include/asm/pci_dma.h b/arch/s390/include/asm/pci_dma.h index 91e63426bdc5..69e616d0712c 100644 --- a/arch/s390/include/asm/pci_dma.h +++ b/arch/s390/include/asm/pci_dma.h @@ -50,6 +50,8 @@ enum zpci_ioat_dtype { #define ZPCI_TABLE_ALIGN ZPCI_TABLE_SIZE #define ZPCI_TABLE_ENTRY_SIZE (sizeof(unsigned long)) #define ZPCI_TABLE_ENTRIES (ZPCI_TABLE_SIZE / ZPCI_TABLE_ENTRY_SIZE) +#define ZPCI_TABLE_PAGES (ZPCI_TABLE_SIZE >> PAGE_SHIFT) +#define ZPCI_TABLE_ENTRIES_PAGES (ZPCI_TABLE_ENTRIES * ZPCI_TABLE_PAGES) #define ZPCI_TABLE_BITS 11 #define ZPCI_PT_BITS 8 diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c index 8e9044a7bce7..fa9d6ac1755b 100644 --- a/arch/s390/kvm/pci.c +++ b/arch/s390/kvm/pci.c @@ -13,12 +13,15 @@ #include #include #include +#include #include #include "pci.h" #include "kvm-s390.h" struct zpci_aift *aift; +#define shadow_ioat_init zdev->kzdev->ioat.head[0] + static inline int __set_irq_noiib(u16 ctl, u8 isc) { union zpci_sic_iib iib = {{0}}; @@ -366,6 +369,138 @@ int kvm_s390_pci_aif_disable(struct zpci_dev *zdev, bool force) } EXPORT_SYMBOL_GPL(kvm_s390_pci_aif_disable); +int kvm_s390_pci_ioat_probe(struct zpci_dev *zdev) +{ + /* + * Using the IOAT assist is only valid for a device with a KVM guest + * registered + */ + if (!zdev->kzdev->kvm) + return -EINVAL; + + return 0; +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_ioat_probe); + +int kvm_s390_pci_ioat_enable(struct zpci_dev *zdev, u64 iota) +{ + gpa_t gpa = (gpa_t)(iota & ZPCI_RTE_ADDR_MASK); + struct kvm_zdev_ioat *ioat; + struct page *page; + struct kvm *kvm; + unsigned int idx; + void *iaddr; + int i, rc; + + if (shadow_ioat_init) + return -EINVAL; + + /* Ensure supported type specified */ + if ((iota & ZPCI_IOTA_RTTO_FLAG) != ZPCI_IOTA_RTTO_FLAG) + return -EINVAL; + + kvm = zdev->kzdev->kvm; + ioat = &zdev->kzdev->ioat; + mutex_lock(&ioat->ioat_lock); + idx = srcu_read_lock(&kvm->srcu); + for (i = 0; i < ZPCI_TABLE_PAGES; i++) { + page = gfn_to_page(kvm, gpa_to_gfn(gpa)); + if (is_error_page(page)) { + srcu_read_unlock(&kvm->srcu, idx); + rc = -EIO; + goto unpin; + } + iaddr = page_to_virt(page) + (gpa & ~PAGE_MASK); + ioat->head[i] = (unsigned long *)iaddr; + gpa += PAGE_SIZE; + } + srcu_read_unlock(&kvm->srcu, idx); + + ioat->seg = kcalloc(ZPCI_TABLE_ENTRIES_PAGES, sizeof(unsigned long *), + GFP_KERNEL); + if (!ioat->seg) + goto unpin; + ioat->pt = kcalloc(ZPCI_TABLE_ENTRIES, sizeof(unsigned long **), + GFP_KERNEL); + if (!ioat->pt) + goto free_seg; + + mutex_unlock(&ioat->ioat_lock); + return 0; + +free_seg: + kfree(ioat->seg); + rc = -ENOMEM; +unpin: + for (i = 0; i < ZPCI_TABLE_PAGES; i++) { + kvm_release_pfn_dirty((u64)ioat->head[i] >> PAGE_SHIFT); + ioat->head[i] = 0; + } + mutex_unlock(&ioat->ioat_lock); + return rc; +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_ioat_enable); + +static void free_pt_entry(struct kvm_zdev_ioat *ioat, int st, int pt) +{ + if (!ioat->pt[st][pt]) + return; + + kvm_release_pfn_dirty((u64)ioat->pt[st][pt]); +} + +static void free_seg_entry(struct kvm_zdev_ioat *ioat, int entry) +{ + int i, st, count = 0; + + for (i = 0; i < ZPCI_TABLE_PAGES; i++) { + if (ioat->seg[entry + i]) { + kvm_release_pfn_dirty((u64)ioat->seg[entry + i]); + count++; + } + } + + if (count == 0) + return; + + st = entry / ZPCI_TABLE_PAGES; + for (i = 0; i < ZPCI_TABLE_ENTRIES; i++) + free_pt_entry(ioat, st, i); + kfree(ioat->pt[st]); +} + +int kvm_s390_pci_ioat_disable(struct zpci_dev *zdev) +{ + struct kvm_zdev_ioat *ioat; + int i; + + if (!shadow_ioat_init) + return -EINVAL; + + ioat = &zdev->kzdev->ioat; + mutex_lock(&ioat->ioat_lock); + for (i = 0; i < ZPCI_TABLE_PAGES; i++) { + kvm_release_pfn_dirty((u64)ioat->head[i] >> PAGE_SHIFT); + ioat->head[i] = 0; + } + + for (i = 0; i < ZPCI_TABLE_ENTRIES_PAGES; i += ZPCI_TABLE_PAGES) + free_seg_entry(ioat, i); + + kfree(ioat->seg); + kfree(ioat->pt); + mutex_unlock(&ioat->ioat_lock); + + return 0; +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_ioat_disable); + +u8 kvm_s390_pci_get_dtsm(struct zpci_dev *zdev) +{ + return (zdev->dtsm & KVM_S390_PCI_DTSM_MASK); +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_get_dtsm); + int kvm_s390_pci_interp_probe(struct zpci_dev *zdev) { /* Must have appropriate hardware facilities */ @@ -449,6 +584,10 @@ int kvm_s390_pci_interp_disable(struct zpci_dev *zdev, bool force) if (zdev->kzdev->fib.fmt0.aibv != 0) kvm_s390_pci_aif_disable(zdev, force); + /* If we are using the IOAT assist, disable it now */ + if (zdev->kzdev->ioat.head[0]) + kvm_s390_pci_ioat_disable(zdev); + /* Remove the host CLP guest designation */ zdev->gisa = 0; @@ -478,6 +617,8 @@ int kvm_s390_pci_dev_open(struct zpci_dev *zdev) if (!kzdev) return -ENOMEM; + mutex_init(&kzdev->ioat.ioat_lock); + kzdev->zdev = zdev; zdev->kzdev = kzdev; @@ -492,6 +633,7 @@ void kvm_s390_pci_dev_release(struct zpci_dev *zdev) kzdev = zdev->kzdev; WARN_ON(kzdev->zdev != zdev); zdev->kzdev = 0; + mutex_destroy(&kzdev->ioat.ioat_lock); kfree(kzdev); } EXPORT_SYMBOL_GPL(kvm_s390_pci_dev_release); diff --git a/arch/s390/kvm/pci.h b/arch/s390/kvm/pci.h index 4d3db58beb74..0fa0e3d61aaa 100644 --- a/arch/s390/kvm/pci.h +++ b/arch/s390/kvm/pci.h @@ -16,6 +16,8 @@ #include #include +#define KVM_S390_PCI_DTSM_MASK 0x40 + struct zpci_gaite { u32 gisa; u8 gisc; From patchwork Fri Feb 4 21:15:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735668 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4ABFFC433FE for ; Fri, 4 Feb 2022 21:17:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241589AbiBDVRY (ORCPT ); Fri, 4 Feb 2022 16:17:24 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48400 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235523AbiBDVQa (ORCPT ); Fri, 4 Feb 2022 16:16:30 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214Jx4el016005; Fri, 4 Feb 2022 21:16:30 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=hmcK15jmALasJ7KT7q+FT1Rdo+H8SgNMDwkoL8KHQaE=; b=DzAnGAs7xAGV592O2X6ej+o3meh9M6LjhL7rfebZcRNRFtRbO9teibG4xnjc8+6NqJUs 01jlFQqqQ8qnguD/gfzTcfQBFj5GDPCSD8y42Qjx4X0NX19jzoJKQzuwJ54pz5KhkYjF pZI6a4YYQpiEYCFYlvTRyYhVlpGEztTacrVKlKkzhxY2pBKaPGa1VL+szHvU5t9bJHX9 D5A5eCMm1bFmc3nT8AU5Q2x9l8nCpIJ8ElYRUwRCd7LL+UbRNyqoinvT0fIELgVFcMBN YYs7wmde2x/WdJLaYpko5F2EURVar94br1679tiUJ18dB3zqhJ0kubDaNhYC6YkGjHX5 hw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0rt5nn0n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:29 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214LDP3b016537; Fri, 4 Feb 2022 21:16:29 GMT Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0rt5nn09-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:29 +0000 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCf8U011927; Fri, 4 Feb 2022 21:16:28 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma05wdc.us.ibm.com with ESMTP id 3e0r0m2wk5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:28 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGRA931785378 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:27 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 15C0F136065; Fri, 4 Feb 2022 21:16:27 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 59823136055; Fri, 4 Feb 2022 21:16:25 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:25 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 22/30] KVM: s390: pci: handle refresh of PCI translations Date: Fri, 4 Feb 2022 16:15:28 -0500 Message-Id: <20220204211536.321475-23-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: x4oF1JHi-K5m-tIH3gbYPqXqq3uaw-D3 X-Proofpoint-ORIG-GUID: otz9KLY0R_XXqStTwBTvwgWglrlWq4YT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 adultscore=0 phishscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add a routine that will perform a shadow operation between a guest and host IOAT. A subsequent patch will invoke this in response to an 04 RPCIT instruction intercept. Signed-off-by: Matthew Rosato --- arch/s390/include/asm/kvm_pci.h | 1 + arch/s390/include/asm/pci_dma.h | 1 + arch/s390/kvm/pci.c | 201 +++++++++++++++++++++++++++++++- arch/s390/kvm/pci.h | 8 +- 4 files changed, 209 insertions(+), 2 deletions(-) diff --git a/arch/s390/include/asm/kvm_pci.h b/arch/s390/include/asm/kvm_pci.h index 370d6ba041fe..e4696f5592e1 100644 --- a/arch/s390/include/asm/kvm_pci.h +++ b/arch/s390/include/asm/kvm_pci.h @@ -29,6 +29,7 @@ struct kvm_zdev_ioat { struct kvm_zdev { struct zpci_dev *zdev; struct kvm *kvm; + u64 rpcit_count; struct kvm_zdev_ioat ioat; struct zpci_fib fib; }; diff --git a/arch/s390/include/asm/pci_dma.h b/arch/s390/include/asm/pci_dma.h index 69e616d0712c..38004e0a4383 100644 --- a/arch/s390/include/asm/pci_dma.h +++ b/arch/s390/include/asm/pci_dma.h @@ -52,6 +52,7 @@ enum zpci_ioat_dtype { #define ZPCI_TABLE_ENTRIES (ZPCI_TABLE_SIZE / ZPCI_TABLE_ENTRY_SIZE) #define ZPCI_TABLE_PAGES (ZPCI_TABLE_SIZE >> PAGE_SHIFT) #define ZPCI_TABLE_ENTRIES_PAGES (ZPCI_TABLE_ENTRIES * ZPCI_TABLE_PAGES) +#define ZPCI_TABLE_ENTRIES_PER_PAGE (ZPCI_TABLE_ENTRIES / ZPCI_TABLE_PAGES) #define ZPCI_TABLE_BITS 11 #define ZPCI_PT_BITS 8 diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c index fa9d6ac1755b..6e1bd20d3552 100644 --- a/arch/s390/kvm/pci.c +++ b/arch/s390/kvm/pci.c @@ -159,6 +159,201 @@ int kvm_s390_pci_aen_init(u8 nisc) return rc; } +static int dma_shadow_cpu_trans(struct kvm_vcpu *vcpu, unsigned long *entry, + unsigned long *gentry) +{ + phys_addr_t gaddr = 0; + unsigned long idx; + struct page *page; + kvm_pfn_t pfn; + gpa_t addr; + int rc = 0; + + if (pt_entry_isvalid(*gentry)) { + /* pin and validate */ + addr = *gentry & ZPCI_PTE_ADDR_MASK; + idx = srcu_read_lock(&vcpu->kvm->srcu); + page = gfn_to_page(vcpu->kvm, gpa_to_gfn(addr)); + srcu_read_unlock(&vcpu->kvm->srcu, idx); + if (is_error_page(page)) + return -EIO; + gaddr = page_to_phys(page) + (addr & ~PAGE_MASK); + } + + if (pt_entry_isvalid(*entry)) { + /* Either we are invalidating, replacing or no-op */ + if (gaddr != 0) { + if ((*entry & ZPCI_PTE_ADDR_MASK) == gaddr) { + /* Duplicate */ + kvm_release_pfn_dirty(*entry >> PAGE_SHIFT); + } else { + /* Replace */ + pfn = (*entry >> PAGE_SHIFT); + invalidate_pt_entry(entry); + set_pt_pfaa(entry, gaddr); + validate_pt_entry(entry); + kvm_release_pfn_dirty(pfn); + rc = 1; + } + } else { + /* Invalidate */ + pfn = (*entry >> PAGE_SHIFT); + invalidate_pt_entry(entry); + kvm_release_pfn_dirty(pfn); + rc = 1; + } + } else if (gaddr != 0) { + /* New Entry */ + set_pt_pfaa(entry, gaddr); + validate_pt_entry(entry); + } + + return rc; +} + +static unsigned long *dma_walk_guest_cpu_trans(struct kvm_vcpu *vcpu, + struct kvm_zdev_ioat *ioat, + dma_addr_t dma_addr) +{ + unsigned long *rto, *sto, *pto; + unsigned int rtx, rts, sx, px, idx; + struct page *page; + gpa_t addr; + int i; + + /* Pin guest segment table if needed */ + rtx = calc_rtx(dma_addr); + rto = ioat->head[(rtx / ZPCI_TABLE_ENTRIES_PER_PAGE)]; + rts = rtx * ZPCI_TABLE_PAGES; + if (!ioat->seg[rts]) { + if (!reg_entry_isvalid(rto[rtx % ZPCI_TABLE_ENTRIES_PER_PAGE])) + return NULL; + sto = get_rt_sto(rto[rtx % ZPCI_TABLE_ENTRIES_PER_PAGE]); + addr = ((u64)sto & ZPCI_RTE_ADDR_MASK); + idx = srcu_read_lock(&vcpu->kvm->srcu); + for (i = 0; i < ZPCI_TABLE_PAGES; i++) { + page = gfn_to_page(vcpu->kvm, gpa_to_gfn(addr)); + if (is_error_page(page)) { + srcu_read_unlock(&vcpu->kvm->srcu, idx); + return NULL; + } + ioat->seg[rts + i] = page_to_virt(page) + + (addr & ~PAGE_MASK); + addr += PAGE_SIZE; + } + srcu_read_unlock(&vcpu->kvm->srcu, idx); + } + + /* Allocate pin pointers for another segment table if needed */ + if (!ioat->pt[rtx]) { + ioat->pt[rtx] = kcalloc(ZPCI_TABLE_ENTRIES, + (sizeof(unsigned long *)), GFP_KERNEL); + if (!ioat->pt[rtx]) + return NULL; + } + /* Pin guest page table if needed */ + sx = calc_sx(dma_addr); + sto = ioat->seg[(rts + (sx / ZPCI_TABLE_ENTRIES_PER_PAGE))]; + if (!ioat->pt[rtx][sx]) { + if (!reg_entry_isvalid(sto[sx % ZPCI_TABLE_ENTRIES_PER_PAGE])) + return NULL; + pto = get_st_pto(sto[sx % ZPCI_TABLE_ENTRIES_PER_PAGE]); + if (!pto) + return NULL; + addr = ((u64)pto & ZPCI_STE_ADDR_MASK); + idx = srcu_read_lock(&vcpu->kvm->srcu); + page = gfn_to_page(vcpu->kvm, gpa_to_gfn(addr)); + srcu_read_unlock(&vcpu->kvm->srcu, idx); + if (is_error_page(page)) + return NULL; + ioat->pt[rtx][sx] = page_to_virt(page) + (addr & ~PAGE_MASK); + } + pto = ioat->pt[rtx][sx]; + + /* Return guest PTE */ + px = calc_px(dma_addr); + return &pto[px]; +} + + +static int dma_table_shadow(struct kvm_vcpu *vcpu, struct zpci_dev *zdev, + dma_addr_t dma_addr, size_t size) +{ + unsigned int nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; + struct kvm_zdev *kzdev = zdev->kzdev; + unsigned long *entry, *gentry; + int i, rc = 0, rc2; + + if (!nr_pages || !kzdev) + return -EINVAL; + + mutex_lock(&kzdev->ioat.ioat_lock); + if (!zdev->dma_table || !kzdev->ioat.head[0]) { + rc = -EINVAL; + goto out_unlock; + } + + for (i = 0; i < nr_pages; i++) { + gentry = dma_walk_guest_cpu_trans(vcpu, &kzdev->ioat, dma_addr); + if (!gentry) + continue; + entry = dma_walk_cpu_trans(zdev->dma_table, dma_addr); + + if (!entry) { + rc = -ENOMEM; + goto out_unlock; + } + + rc2 = dma_shadow_cpu_trans(vcpu, entry, gentry); + if (rc2 < 0) { + rc = -EIO; + goto out_unlock; + } + dma_addr += PAGE_SIZE; + rc += rc2; + } + +out_unlock: + mutex_unlock(&kzdev->ioat.ioat_lock); + return rc; +} + +int kvm_s390_pci_refresh_trans(struct kvm_vcpu *vcpu, unsigned long req, + unsigned long start, unsigned long size, + u8 *status) +{ + struct zpci_dev *zdev; + u32 fh = req >> 32; + int rc; + + /* Make sure this is a valid device associated with this guest */ + zdev = get_zdev_by_fh(fh); + if (!zdev || !zdev->kzdev || zdev->kzdev->kvm != vcpu->kvm) { + *status = 0; + return -EINVAL; + } + + /* Only proceed if the device is using the assist */ + if (zdev->kzdev->ioat.head[0] == 0) + return -EOPNOTSUPP; + + rc = dma_table_shadow(vcpu, zdev, start, size); + if (rc < 0) { + /* + * If errors encountered during shadow operations, we must + * fabricate status to present to the guest + */ + *status = KVM_S390_RPCIT_INS_RES; + } else if (rc > 0) { + /* Host RPCIT must be issued */ + rc = zpci_refresh_trans((u64) zdev->fh << 32, start, size, + status); + } + zdev->kzdev->rpcit_count++; + + return rc; +} + /* Modify PCI: Register floating adapter interruption forwarding */ static int kvm_zpci_set_airq(struct zpci_dev *zdev) { @@ -640,6 +835,8 @@ EXPORT_SYMBOL_GPL(kvm_s390_pci_dev_release); int kvm_s390_pci_init(void) { + int rc; + aift = kzalloc(sizeof(struct zpci_aift), GFP_KERNEL); if (!aift) return -ENOMEM; @@ -647,5 +844,7 @@ int kvm_s390_pci_init(void) spin_lock_init(&aift->gait_lock); mutex_init(&aift->aift_lock); - return 0; + rc = zpci_get_mdd(&aift->mdd); + + return rc; } diff --git a/arch/s390/kvm/pci.h b/arch/s390/kvm/pci.h index 0fa0e3d61aaa..a409680a1dc2 100644 --- a/arch/s390/kvm/pci.h +++ b/arch/s390/kvm/pci.h @@ -18,6 +18,9 @@ #define KVM_S390_PCI_DTSM_MASK 0x40 +#define KVM_S390_RPCIT_INS_RES 0x10 +#define KVM_S390_RPCIT_ERR 0x28 + struct zpci_gaite { u32 gisa; u8 gisc; @@ -33,6 +36,7 @@ struct zpci_aift { struct kvm_zdev **kzdev; spinlock_t gait_lock; /* Protects the gait, used during AEN forward */ struct mutex aift_lock; /* Protects the other structures in aift */ + u32 mdd; }; extern struct zpci_aift *aift; @@ -48,7 +52,9 @@ static inline struct kvm *kvm_s390_pci_si_to_kvm(struct zpci_aift *aift, int kvm_s390_pci_aen_init(u8 nisc); void kvm_s390_pci_aen_exit(void); - +int kvm_s390_pci_refresh_trans(struct kvm_vcpu *vcpu, unsigned long req, + unsigned long start, unsigned long end, + u8 *status); int kvm_s390_pci_init(void); #endif /* __KVM_S390_PCI_H */ From patchwork Fri Feb 4 21:15:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB512C433EF for ; Fri, 4 Feb 2022 21:17:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343832AbiBDVRW (ORCPT ); Fri, 4 Feb 2022 16:17:22 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59548 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S243339AbiBDVQd (ORCPT ); Fri, 4 Feb 2022 16:16:33 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214KwNtZ011886; Fri, 4 Feb 2022 21:16:32 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=T5ZAceHFx/43XZIeTUGrJt+q9LFObpveQIP+e7NjlYM=; b=Zh9hq0I/TYOuGsVcfBscyqIrzKzo9ayGistdvMc8huaeqWboqBRb576sQsRoLasflhs2 LW43pm7xR6VUPqvkg3cgGq/mPSYxGC4ZmKL4cNSLX+QmiReO2rIbIuYDVJSpRZYctScc rONyCZXLqCr+fq07z2i9z8QdDZ7RZrw+xWP5dPk4GfIkCTQ1UksMrAX0UCOoMiR7hGUE MKQTyI986PD7tkJacYMcw4wvOxHdivjueku0cBHOL0ZrPMJoD9XTlmfr5Ox8idpRLRTn GoSKUXIUoKMjGzARQKFjrwq2d57KIn3gOGKmIEqfs+Uot1U36GnD7JG6gCtsRsXTCN2V Tw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0vrs2guc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:32 +0000 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214LGWRQ004452; Fri, 4 Feb 2022 21:16:32 GMT Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0vrs2gtv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:32 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCoEI008508; Fri, 4 Feb 2022 21:16:31 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma02dal.us.ibm.com with ESMTP id 3e0r0pyfd6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:31 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGTK719726636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:29 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2958E13605D; Fri, 4 Feb 2022 21:16:29 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 428CA136053; Fri, 4 Feb 2022 21:16:27 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:27 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 23/30] KVM: s390: intercept the rpcit instruction Date: Fri, 4 Feb 2022 16:15:29 -0500 Message-Id: <20220204211536.321475-24-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 1laRQgiM-Sj1rfn533qjOehWHIwsToGa X-Proofpoint-ORIG-GUID: N6x5EjlZEqlDRtp_7C7UJU5hToZ8NIxc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 mlxlogscore=989 priorityscore=1501 phishscore=0 suspectscore=0 impostorscore=0 bulkscore=0 clxscore=1015 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org For faster handling of PCI translation refreshes, intercept in KVM and call the associated handler. Signed-off-by: Matthew Rosato --- arch/s390/kvm/priv.c | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c index 417154b314a6..d6a5784d8dde 100644 --- a/arch/s390/kvm/priv.c +++ b/arch/s390/kvm/priv.c @@ -29,6 +29,7 @@ #include #include "gaccess.h" #include "kvm-s390.h" +#include "pci.h" #include "trace.h" static int handle_ri(struct kvm_vcpu *vcpu) @@ -335,6 +336,52 @@ static int handle_rrbe(struct kvm_vcpu *vcpu) return 0; } +static int handle_rpcit(struct kvm_vcpu *vcpu) +{ + int reg1, reg2; + u8 status; + int rc; + + if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) + return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); + + /* + * If the host doesn't support PCI passthrough interpretation, it must + * be an emulated device. + */ + if (!IS_ENABLED(CONFIG_VFIO_PCI_ZDEV)) + return -EOPNOTSUPP; + + kvm_s390_get_regs_rre(vcpu, ®1, ®2); + + /* If the device has a SHM bit on, let userspace take care of this */ + if (((vcpu->run->s.regs.gprs[reg1] >> 32) & aift->mdd) != 0) + return -EOPNOTSUPP; + + rc = kvm_s390_pci_refresh_trans(vcpu, vcpu->run->s.regs.gprs[reg1], + vcpu->run->s.regs.gprs[reg2], + vcpu->run->s.regs.gprs[reg2 + 1], + &status); + + switch (rc) { + case 0: + kvm_s390_set_psw_cc(vcpu, 0); + break; + case -EOPNOTSUPP: + return -EOPNOTSUPP; + default: + vcpu->run->s.regs.gprs[reg1] &= 0xffffffff00ffffffUL; + vcpu->run->s.regs.gprs[reg1] |= (u64)status << 24; + if (status != 0) + kvm_s390_set_psw_cc(vcpu, 1); + else + kvm_s390_set_psw_cc(vcpu, 3); + break; + } + + return 0; +} + #define SSKE_NQ 0x8 #define SSKE_MR 0x4 #define SSKE_MC 0x2 @@ -1275,6 +1322,8 @@ int kvm_s390_handle_b9(struct kvm_vcpu *vcpu) return handle_essa(vcpu); case 0xaf: return handle_pfmf(vcpu); + case 0xd3: + return handle_rpcit(vcpu); default: return -EOPNOTSUPP; } From patchwork Fri Feb 4 21:15:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 020A5C433EF for ; Fri, 4 Feb 2022 21:17:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344838AbiBDVR1 (ORCPT ); Fri, 4 Feb 2022 16:17:27 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:18408 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243400AbiBDVQf (ORCPT ); Fri, 4 Feb 2022 16:16:35 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214I1G7g032196; Fri, 4 Feb 2022 21:16:35 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=2kW2+VEK6gOx/vl99AVl6Dc7lZkmeAzJHvn2DcPvZKQ=; b=Xwnly80bJgqHkeWQsAHeTdMGfsCQ0ggWW+TBAWEju2YU2i0XLpKJ4ielPtvNtk6oIbc7 Q18m/RMISeEImIyLIwi2qlKYl2yz6L7xbkYOIqpdUCaZsNlbP5OUyW05NCOmorgOjSBG v2jETTUv9833UzJiUu6/wsml55UgzEx5czrckiHWNyyK2K6kWCuqVAGdhIJ+oxJZwVex +ulgRdsCg0v2mfeQCHP/w1l62mgkpsxSODUBLCKsc5kzx75nBdnhqjTlLKcZJj+/2Xx2 nE76QQsw7dj2eBSEGwER7hM9adEYKNwjBeWPtDW3LUmkqtbuv/fEdPXR1haFlObL6N5h AQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx0xskm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:34 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214L6bYw007736; Fri, 4 Feb 2022 21:16:34 GMT Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx0xsjs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:34 +0000 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCgn0011957; Fri, 4 Feb 2022 21:16:32 GMT Received: from b03cxnp07027.gho.boulder.ibm.com (b03cxnp07027.gho.boulder.ibm.com [9.17.130.14]) by ppma05wdc.us.ibm.com with ESMTP id 3e0r0m2wn1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:32 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGVIM30671110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:31 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 294A3136067; Fri, 4 Feb 2022 21:16:31 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 57421136055; Fri, 4 Feb 2022 21:16:29 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:29 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 24/30] vfio-pci/zdev: wire up group notifier Date: Fri, 4 Feb 2022 16:15:30 -0500 Message-Id: <20220204211536.321475-25-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 9M9dsVg6DDpmuvSggcuuNcUJlbiFRzNK X-Proofpoint-ORIG-GUID: RCcr-FADDJov24cZplzEhFJb9OGT2JMi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 spamscore=0 malwarescore=0 phishscore=0 priorityscore=1501 impostorscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org KVM zPCI passthrough device logic will need a reference to the associated kvm guest that has access to the device. Let's register a group notifier for VFIO_GROUP_NOTIFY_SET_KVM to catch this information in order to create an association between a kvm guest and the host zdev. Signed-off-by: Matthew Rosato --- arch/s390/include/asm/kvm_pci.h | 2 ++ drivers/vfio/pci/vfio_pci_core.c | 2 ++ drivers/vfio/pci/vfio_pci_zdev.c | 46 ++++++++++++++++++++++++++++++++ include/linux/vfio_pci_core.h | 10 +++++++ 4 files changed, 60 insertions(+) diff --git a/arch/s390/include/asm/kvm_pci.h b/arch/s390/include/asm/kvm_pci.h index e4696f5592e1..16290b4cf2a6 100644 --- a/arch/s390/include/asm/kvm_pci.h +++ b/arch/s390/include/asm/kvm_pci.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -32,6 +33,7 @@ struct kvm_zdev { u64 rpcit_count; struct kvm_zdev_ioat ioat; struct zpci_fib fib; + struct notifier_block nb; }; int kvm_s390_pci_dev_open(struct zpci_dev *zdev); diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index f948e6cd2993..fc57d4d0abbe 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -452,6 +452,7 @@ void vfio_pci_core_close_device(struct vfio_device *core_vdev) vfio_pci_vf_token_user_add(vdev, -1); vfio_spapr_pci_eeh_release(vdev->pdev); + vfio_pci_zdev_release(vdev); vfio_pci_core_disable(vdev); mutex_lock(&vdev->igate); @@ -470,6 +471,7 @@ EXPORT_SYMBOL_GPL(vfio_pci_core_close_device); void vfio_pci_core_finish_enable(struct vfio_pci_core_device *vdev) { vfio_pci_probe_mmaps(vdev); + vfio_pci_zdev_open(vdev); vfio_spapr_pci_eeh_open(vdev->pdev); vfio_pci_vf_token_user_add(vdev, 1); } diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c index ea4c0d2b0663..9f8284499111 100644 --- a/drivers/vfio/pci/vfio_pci_zdev.c +++ b/drivers/vfio/pci/vfio_pci_zdev.c @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -136,3 +137,48 @@ int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, return ret; } + +static int vfio_pci_zdev_group_notifier(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct kvm_zdev *kzdev = container_of(nb, struct kvm_zdev, nb); + + if (action == VFIO_GROUP_NOTIFY_SET_KVM) { + if (!data || !kzdev->zdev) + return NOTIFY_DONE; + kzdev->kvm = data; + } + + return NOTIFY_OK; +} + +void vfio_pci_zdev_open(struct vfio_pci_core_device *vdev) +{ + unsigned long events = VFIO_GROUP_NOTIFY_SET_KVM; + struct zpci_dev *zdev = to_zpci(vdev->pdev); + + if (!zdev) + return; + + if (kvm_s390_pci_dev_open(zdev)) + return; + + zdev->kzdev->nb.notifier_call = vfio_pci_zdev_group_notifier; + + if (vfio_register_notifier(vdev->vdev.dev, VFIO_GROUP_NOTIFY, + &events, &zdev->kzdev->nb)) + kvm_s390_pci_dev_release(zdev); +} + +void vfio_pci_zdev_release(struct vfio_pci_core_device *vdev) +{ + struct zpci_dev *zdev = to_zpci(vdev->pdev); + + if (!zdev || !zdev->kzdev) + return; + + vfio_unregister_notifier(vdev->vdev.dev, VFIO_GROUP_NOTIFY, + &zdev->kzdev->nb); + + kvm_s390_pci_dev_release(zdev); +} diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h index 5e2bca3b89db..05287f8ac855 100644 --- a/include/linux/vfio_pci_core.h +++ b/include/linux/vfio_pci_core.h @@ -198,12 +198,22 @@ static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev) #ifdef CONFIG_VFIO_PCI_ZDEV extern int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, struct vfio_info_cap *caps); +void vfio_pci_zdev_open(struct vfio_pci_core_device *vdev); +void vfio_pci_zdev_release(struct vfio_pci_core_device *vdev); #else static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, struct vfio_info_cap *caps) { return -ENODEV; } + +static inline void vfio_pci_zdev_open(struct vfio_pci_core_device *vdev) +{ +} + +static inline void vfio_pci_zdev_release(struct vfio_pci_core_device *vdev) +{ +} #endif /* Will be exported for vfio pci drivers usage */ From patchwork Fri Feb 4 21:15:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735670 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F134FC433EF for ; Fri, 4 Feb 2022 21:17:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243591AbiBDVRj (ORCPT ); Fri, 4 Feb 2022 16:17:39 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:25744 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S243426AbiBDVQh (ORCPT ); Fri, 4 Feb 2022 16:16:37 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214Krg6e009305; Fri, 4 Feb 2022 21:16:36 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=EOtUC6dQklxXDOE8x+vZzu96i5OdOYuE8kOaBsL4Z2U=; b=lpP7ZQgrug9qfQr0W8AYHEcABgd8lz3ivWxzkVtfvN08zAezRPNgsrFyd+loQ9fWfnTl IWSIocCyS88XIzDtkm1qKbrk08QkUnOR83gM7tmHTqm1S8EbQ81PJ2gOZz8oT34RxmIR NkOcedOP4erbFOKoKAWKe5i0b7SH6nfCmQr4sihyiXLg1S5gHLjbp3fDJYl3CNfaIQF1 90xxaq/1ir7H3Z7unSB1ltgcZHbulOnE4CHji0WdYofrGVmbWXFh3qN6Nf/Jfa58dZJJ sDVz6y22ABljbMCG0ar5AFBRfqOzukNzLbaqQT++b+DZFBNhfkF5dWrLF5o9qru0gS5L Qw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0yu5q4b1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:36 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214LDQSW000919; Fri, 4 Feb 2022 21:16:35 GMT Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0yu5q4ad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:35 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCpCA008674; Fri, 4 Feb 2022 21:16:35 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma02dal.us.ibm.com with ESMTP id 3e0r0pyffa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:35 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGXCY36045070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:33 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 240E4136055; Fri, 4 Feb 2022 21:16:33 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4CB6C13604F; Fri, 4 Feb 2022 21:16:31 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:31 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 25/30] vfio-pci/zdev: wire up zPCI interpretive execution support Date: Fri, 4 Feb 2022 16:15:31 -0500 Message-Id: <20220204211536.321475-26-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: y2OyeQZonDhcU58faN7YwvElfkvZN9ww X-Proofpoint-GUID: MQo4qWrfTCse2b5dBC_iQdp-4iEUKE6M X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 phishscore=0 clxscore=1015 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 lowpriorityscore=0 adultscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Introduce support for VFIO_DEVICE_FEATURE_ZPCI_INTERP, which is a new VFIO_DEVICE_FEATURE ioctl. This interface is used to indicate that an s390x vfio-pci device wishes to enable/disable zPCI interpretive execution, which allows zPCI instructions to be executed directly by underlying firmware without KVM involvement. Signed-off-by: Matthew Rosato --- arch/s390/include/asm/kvm_pci.h | 1 + drivers/vfio/pci/vfio_pci_core.c | 2 + drivers/vfio/pci/vfio_pci_zdev.c | 73 ++++++++++++++++++++++++++++++++ include/linux/vfio_pci_core.h | 10 +++++ include/uapi/linux/vfio.h | 7 +++ include/uapi/linux/vfio_zdev.h | 15 +++++++ 6 files changed, 108 insertions(+) diff --git a/arch/s390/include/asm/kvm_pci.h b/arch/s390/include/asm/kvm_pci.h index 16290b4cf2a6..8f7d371e3e59 100644 --- a/arch/s390/include/asm/kvm_pci.h +++ b/arch/s390/include/asm/kvm_pci.h @@ -34,6 +34,7 @@ struct kvm_zdev { struct kvm_zdev_ioat ioat; struct zpci_fib fib; struct notifier_block nb; + bool interpretation; }; int kvm_s390_pci_dev_open(struct zpci_dev *zdev); diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index fc57d4d0abbe..2b2d64a2190c 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -1172,6 +1172,8 @@ long vfio_pci_core_ioctl(struct vfio_device *core_vdev, unsigned int cmd, mutex_unlock(&vdev->vf_token->lock); return 0; + case VFIO_DEVICE_FEATURE_ZPCI_INTERP: + return vfio_pci_zdev_feat_interp(vdev, feature, arg); default: return -ENOTTY; } diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c index 9f8284499111..71cc1eb8085f 100644 --- a/drivers/vfio/pci/vfio_pci_zdev.c +++ b/drivers/vfio/pci/vfio_pci_zdev.c @@ -54,6 +54,10 @@ static int zpci_group_cap(struct zpci_dev *zdev, struct vfio_info_cap *caps) .version = zdev->version }; + /* Some values are different for interpreted devices */ + if (zdev->kzdev && zdev->kzdev->interpretation) + cap.maxstbl = zdev->maxstbl; + return vfio_info_add_capability(caps, &cap.header, sizeof(cap)); } @@ -138,6 +142,67 @@ int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, return ret; } +int vfio_pci_zdev_feat_interp(struct vfio_pci_core_device *vdev, + struct vfio_device_feature feature, + unsigned long arg) +{ + struct zpci_dev *zdev = to_zpci(vdev->pdev); + struct vfio_device_zpci_interp *data; + struct vfio_device_feature *feat; + unsigned long minsz; + int size, rc; + + if (!zdev || !zdev->kzdev) + return -EINVAL; + + /* If PROBE specified, return probe results immediately */ + if (feature.flags & VFIO_DEVICE_FEATURE_PROBE) + return kvm_s390_pci_interp_probe(zdev); + + size = sizeof(*feat) + sizeof(*data); + feat = kzalloc(size, GFP_KERNEL); + if (!feat) + return -ENOMEM; + + data = (struct vfio_device_zpci_interp *)&feat->data; + minsz = offsetofend(struct vfio_device_feature, flags); + + if (feature.argsz < minsz + sizeof(*data)) + return -EINVAL; + + /* Get the rest of the payload for GET/SET */ + rc = copy_from_user(data, (void __user *)(arg + minsz), + sizeof(*data)); + if (rc) + rc = -EINVAL; + + if (feature.flags & VFIO_DEVICE_FEATURE_GET) { + if (zdev->gisa != 0) + data->flags = VFIO_DEVICE_ZPCI_FLAG_INTERP; + else + data->flags = 0; + data->fh = zdev->fh; + /* userspace is using host fh, give interpreted clp values */ + zdev->kzdev->interpretation = true; + + if (copy_to_user((void __user *)arg, feat, size)) + rc = -EFAULT; + } else if (feature.flags & VFIO_DEVICE_FEATURE_SET) { + if (data->flags == VFIO_DEVICE_ZPCI_FLAG_INTERP) + rc = kvm_s390_pci_interp_enable(zdev); + else if (data->flags == 0) + rc = kvm_s390_pci_interp_disable(zdev, false); + else + rc = -EINVAL; + } else { + /* Neither GET nor SET were specified */ + rc = -EINVAL; + } + + kfree(feat); + return rc; +} + static int vfio_pci_zdev_group_notifier(struct notifier_block *nb, unsigned long action, void *data) { @@ -164,6 +229,7 @@ void vfio_pci_zdev_open(struct vfio_pci_core_device *vdev) return; zdev->kzdev->nb.notifier_call = vfio_pci_zdev_group_notifier; + zdev->kzdev->interpretation = false; if (vfio_register_notifier(vdev->vdev.dev, VFIO_GROUP_NOTIFY, &events, &zdev->kzdev->nb)) @@ -180,5 +246,12 @@ void vfio_pci_zdev_release(struct vfio_pci_core_device *vdev) vfio_unregister_notifier(vdev->vdev.dev, VFIO_GROUP_NOTIFY, &zdev->kzdev->nb); + /* + * If the device was using interpretation, don't trust that userspace + * did the appropriate cleanup + */ + if (zdev->gisa != 0) + kvm_s390_pci_interp_disable(zdev, true); + kvm_s390_pci_dev_release(zdev); } diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h index 05287f8ac855..0db2b1051931 100644 --- a/include/linux/vfio_pci_core.h +++ b/include/linux/vfio_pci_core.h @@ -198,6 +198,9 @@ static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev) #ifdef CONFIG_VFIO_PCI_ZDEV extern int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, struct vfio_info_cap *caps); +int vfio_pci_zdev_feat_interp(struct vfio_pci_core_device *vdev, + struct vfio_device_feature feature, + unsigned long arg); void vfio_pci_zdev_open(struct vfio_pci_core_device *vdev); void vfio_pci_zdev_release(struct vfio_pci_core_device *vdev); #else @@ -207,6 +210,13 @@ static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, return -ENODEV; } +static inline int vfio_pci_zdev_feat_interp(struct vfio_pci_core_device *vdev, + struct vfio_device_feature feature, + unsigned long arg) +{ + return -ENOTTY; +} + static inline void vfio_pci_zdev_open(struct vfio_pci_core_device *vdev) { } diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index ef33ea002b0b..b9a75485b8e7 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -1002,6 +1002,13 @@ struct vfio_device_feature { */ #define VFIO_DEVICE_FEATURE_PCI_VF_TOKEN (0) +/* + * Provide support for enabling interpretation of zPCI instructions. This + * feature is only valid for s390x PCI devices. Data provided when setting + * and getting this feature is futher described in vfio_zdev.h + */ +#define VFIO_DEVICE_FEATURE_ZPCI_INTERP (1) + /* -------- API for Type1 VFIO IOMMU -------- */ /** diff --git a/include/uapi/linux/vfio_zdev.h b/include/uapi/linux/vfio_zdev.h index b4309397b6b2..575f0410dc66 100644 --- a/include/uapi/linux/vfio_zdev.h +++ b/include/uapi/linux/vfio_zdev.h @@ -75,4 +75,19 @@ struct vfio_device_info_cap_zpci_pfip { __u8 pfip[]; }; +/** + * VFIO_DEVICE_FEATURE_ZPCI_INTERP + * + * This feature is used for enabling zPCI instruction interpretation for a + * device. No data is provided when setting this feature. When getting + * this feature, the following structure is provided which details whether + * or not interpretation is active and provides the guest with host device + * information necessary to enable interpretation. + */ +struct vfio_device_zpci_interp { + __u64 flags; +#define VFIO_DEVICE_ZPCI_FLAG_INTERP 1 + __u32 fh; /* Host device function handle */ +}; + #endif From patchwork Fri Feb 4 21:15:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 872DAC433EF for ; Fri, 4 Feb 2022 21:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242281AbiBDVRy (ORCPT ); Fri, 4 Feb 2022 16:17:54 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36692 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242261AbiBDVQk (ORCPT ); Fri, 4 Feb 2022 16:16:40 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214JISBS014077; Fri, 4 Feb 2022 21:16:40 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=FWjFSaRPht29NMO90t+5jrhFSHKPxQTtRHppwgqjTJk=; b=pm3sXTdlvdJEIzp/h8x6WsAamwrkoCSn/vhOpEXLFUo/og9scxOo64eIfSXJaFegjxnM aPMs/yJtfy3e+AjT/v1qqhA1HeyeLh6c9uP1pUHSN39IZSO9/jLdCNJfySs3TODenlQy smY9bnLNbFFcYazK5NVeS9gKxqU7LDJ7DQFWslnNY7KQPbcAVXnc6/9bA/iJkkWizyjh S4vha/0VPT7ktO4zWGc3zkXFARF6v+dQqmAGdsjc/IECg9hjrw8xbhWBHHozFBJ0Mwoa lw14qlN4UQGfc+8ynnl77yJ6ww1XC3GxO/HuPEGmpnQTDt+J7tOw8H80dQ4QqS3lbxFu Mw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx2xbx4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:39 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214L59Yt017923; Fri, 4 Feb 2022 21:16:38 GMT Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx2xbvq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:38 +0000 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCfF4011934; Fri, 4 Feb 2022 21:16:36 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma05wdc.us.ibm.com with ESMTP id 3e0r0m2wps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:36 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGZ6K31588750 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:35 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1F210136051; Fri, 4 Feb 2022 21:16:35 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 46FC813604F; Fri, 4 Feb 2022 21:16:33 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:33 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 26/30] vfio-pci/zdev: wire up zPCI adapter interrupt forwarding support Date: Fri, 4 Feb 2022 16:15:32 -0500 Message-Id: <20220204211536.321475-27-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: h-teyLXKmtKY9AidnMW7LiRhLkdw8x7U X-Proofpoint-GUID: YRNINeFJgNaul2_ZnHlh3doTX8eQZvyO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 mlxscore=0 priorityscore=1501 clxscore=1015 phishscore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Introduce support for VFIO_DEVICE_FEATURE_ZPCI_AIF, which is a new VFIO_DEVICE_FEATURE ioctl. This interface is used to indicate that an s390x vfio-pci device wishes to enable/disable zPCI adapter interrupt forwarding, which allows underlying firmware to deliver interrupts directly to the associated kvm guest. Signed-off-by: Matthew Rosato Reviewed-by: Pierre Morel --- arch/s390/include/asm/kvm_pci.h | 2 + drivers/vfio/pci/vfio_pci_core.c | 2 + drivers/vfio/pci/vfio_pci_zdev.c | 93 +++++++++++++++++++++++++++++++- include/linux/vfio_pci_core.h | 10 ++++ include/uapi/linux/vfio.h | 7 +++ include/uapi/linux/vfio_zdev.h | 20 +++++++ 6 files changed, 133 insertions(+), 1 deletion(-) diff --git a/arch/s390/include/asm/kvm_pci.h b/arch/s390/include/asm/kvm_pci.h index 8f7d371e3e59..93b61e61dc7f 100644 --- a/arch/s390/include/asm/kvm_pci.h +++ b/arch/s390/include/asm/kvm_pci.h @@ -35,6 +35,8 @@ struct kvm_zdev { struct zpci_fib fib; struct notifier_block nb; bool interpretation; + bool aif_float; /* Enabled for floating interrupt assist */ + bool aif_host; /* Require host delivery */ }; int kvm_s390_pci_dev_open(struct zpci_dev *zdev); diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index 2b2d64a2190c..01658de660bd 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -1174,6 +1174,8 @@ long vfio_pci_core_ioctl(struct vfio_device *core_vdev, unsigned int cmd, return 0; case VFIO_DEVICE_FEATURE_ZPCI_INTERP: return vfio_pci_zdev_feat_interp(vdev, feature, arg); + case VFIO_DEVICE_FEATURE_ZPCI_AIF: + return vfio_pci_zdev_feat_aif(vdev, feature, arg); default: return -ENOTTY; } diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c index 71cc1eb8085f..74508bdc5f88 100644 --- a/drivers/vfio/pci/vfio_pci_zdev.c +++ b/drivers/vfio/pci/vfio_pci_zdev.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -203,6 +204,94 @@ int vfio_pci_zdev_feat_interp(struct vfio_pci_core_device *vdev, return rc; } +int vfio_pci_zdev_feat_aif(struct vfio_pci_core_device *vdev, + struct vfio_device_feature feature, + unsigned long arg) +{ + struct zpci_dev *zdev = to_zpci(vdev->pdev); + struct vfio_device_zpci_aif *data; + struct vfio_device_feature *feat; + unsigned long minsz; + int size, rc = 0; + + if (!zdev || !zdev->kzdev) + return -EINVAL; + + /* If PROBE specified, return probe results immediately */ + if (feature.flags & VFIO_DEVICE_FEATURE_PROBE) + return kvm_s390_pci_aif_probe(zdev); + + size = sizeof(*feat) + sizeof(*data); + feat = kzalloc(size, GFP_KERNEL); + if (!feat) + return -ENOMEM; + + data = (struct vfio_device_zpci_aif *)&feat->data; + minsz = offsetofend(struct vfio_device_feature, flags); + + if (feature.argsz < minsz + sizeof(*data)) + return -EINVAL; + + /* Get the rest of the payload for GET/SET */ + rc = copy_from_user(data, (void __user *)(arg + minsz), + sizeof(*data)); + if (rc) + rc = -EINVAL; + + if (feature.flags & VFIO_DEVICE_FEATURE_GET) { + if (zdev->kzdev->aif_float) + data->flags = VFIO_DEVICE_ZPCI_FLAG_AIF_FLOAT; + if (zdev->kzdev->aif_host) + data->flags |= VFIO_DEVICE_ZPCI_FLAG_AIF_HOST; + + if (copy_to_user((void __user *)arg, feat, size)) + rc = -EFAULT; + } else if (feature.flags & VFIO_DEVICE_FEATURE_SET) { + if (data->flags & VFIO_DEVICE_ZPCI_FLAG_AIF_FLOAT) { + /* create a guest fib */ + struct zpci_fib fib; + + fib.fmt0.aibv = data->ibv; + fib.fmt0.isc = data->isc; + fib.fmt0.noi = data->noi; + if (data->sb != 0) { + fib.fmt0.aisb = data->sb; + fib.fmt0.aisbo = data->sbo; + fib.fmt0.sum = 1; + } else { + fib.fmt0.aisb = 0; + fib.fmt0.aisbo = 0; + fib.fmt0.sum = 0; + } + if (data->flags & VFIO_DEVICE_ZPCI_FLAG_AIF_HOST) { + rc = kvm_s390_pci_aif_enable(zdev, &fib, false); + if (!rc) { + zdev->kzdev->aif_float = true; + zdev->kzdev->aif_host = true; + } + } else { + rc = kvm_s390_pci_aif_enable(zdev, &fib, true); + if (!rc) + zdev->kzdev->aif_float = true; + } + } else if (data->flags == 0) { + rc = kvm_s390_pci_aif_disable(zdev, false); + if (!rc) { + zdev->kzdev->aif_float = false; + zdev->kzdev->aif_host = false; + } + } else { + rc = -EINVAL; + } + } else { + /* Neither GET nor SET were specified */ + rc = -EINVAL; + } + + kfree(feat); + return rc; +} + static int vfio_pci_zdev_group_notifier(struct notifier_block *nb, unsigned long action, void *data) { @@ -250,8 +339,10 @@ void vfio_pci_zdev_release(struct vfio_pci_core_device *vdev) * If the device was using interpretation, don't trust that userspace * did the appropriate cleanup */ - if (zdev->gisa != 0) + if (zdev->gisa != 0) { + kvm_s390_pci_aif_disable(zdev, true); kvm_s390_pci_interp_disable(zdev, true); + } kvm_s390_pci_dev_release(zdev); } diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h index 0db2b1051931..7ec5e82e7933 100644 --- a/include/linux/vfio_pci_core.h +++ b/include/linux/vfio_pci_core.h @@ -201,6 +201,9 @@ extern int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, int vfio_pci_zdev_feat_interp(struct vfio_pci_core_device *vdev, struct vfio_device_feature feature, unsigned long arg); +int vfio_pci_zdev_feat_aif(struct vfio_pci_core_device *vdev, + struct vfio_device_feature feature, + unsigned long arg); void vfio_pci_zdev_open(struct vfio_pci_core_device *vdev); void vfio_pci_zdev_release(struct vfio_pci_core_device *vdev); #else @@ -217,6 +220,13 @@ static inline int vfio_pci_zdev_feat_interp(struct vfio_pci_core_device *vdev, return -ENOTTY; } +static inline int vfio_pci_zdev_feat_aif(struct vfio_pci_core_device *vdev, + struct vfio_device_feature feature, + unsigned long arg) +{ + return -ENOTTY; +} + static inline void vfio_pci_zdev_open(struct vfio_pci_core_device *vdev) { } diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index b9a75485b8e7..fe3bfd99bf50 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -1009,6 +1009,13 @@ struct vfio_device_feature { */ #define VFIO_DEVICE_FEATURE_ZPCI_INTERP (1) +/* + * Provide support for enbaling adapter interruption forwarding for zPCI + * devices. This feature is only valid for s390x PCI devices. Data provided + * when setting and getting this feature is further described in vfio_zdev.h + */ +#define VFIO_DEVICE_FEATURE_ZPCI_AIF (2) + /* -------- API for Type1 VFIO IOMMU -------- */ /** diff --git a/include/uapi/linux/vfio_zdev.h b/include/uapi/linux/vfio_zdev.h index 575f0410dc66..09f413dfb1c3 100644 --- a/include/uapi/linux/vfio_zdev.h +++ b/include/uapi/linux/vfio_zdev.h @@ -90,4 +90,24 @@ struct vfio_device_zpci_interp { __u32 fh; /* Host device function handle */ }; +/** + * VFIO_DEVICE_FEATURE_ZPCI_AIF + * + * This feature is used for enabling forwarding of adapter interrupts directly + * from firmware to the guest. When setting this feature, the flags indicate + * whether to enable/disable the feature and the structure defined below is + * used to setup the forwarding structures. When getting this feature, only + * the flags are used to indicate the current state. + */ +struct vfio_device_zpci_aif { + __u64 flags; +#define VFIO_DEVICE_ZPCI_FLAG_AIF_FLOAT 1 /* Enable floating interrupts */ +#define VFIO_DEVICE_ZPCI_FLAG_AIF_HOST 2 /* Force host delivery */ + __u64 ibv; /* Address of guest interrupt bit vector */ + __u64 sb; /* Address of guest summary bit */ + __u32 noi; /* Number of interrupts */ + __u8 isc; /* Guest interrupt subclass */ + __u8 sbo; /* Offset of guest summary bit vector */ +}; + #endif From patchwork Fri Feb 4 21:15:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FD80C4332F for ; Fri, 4 Feb 2022 21:18:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348628AbiBDVSA (ORCPT ); Fri, 4 Feb 2022 16:18:00 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:18788 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S242343AbiBDVQp (ORCPT ); Fri, 4 Feb 2022 16:16:45 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214J0Q8S021613; Fri, 4 Feb 2022 21:16:45 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=O7FjG5eS9FZfC0fhCqpIIfObuAaH9atDc97Q4yFriuk=; b=FloYcqdO65lWm12l93p8AdyiELZ9DERNajWzmPuWRoaMnn1bDMtSYlxXqTQzt9LRnTlm EUdAfELS5RBb9jgDg9qzKTzxp0yR3DRxRgtjV3jbAP0PgR4Eluj1lne4iXgQvvpXR7Sy EdlpBnNCNzE6QkvE/n/GwpxjdgA50bzuSYJ5SPjbkkAoajha32Da0b3KfDOOTQ2lFxsm aW9bb/6q3s8YNe8h0U58opvB8Y6ZzV5hQiS3HLmMty5rQB4mX1pRCcOod0b3CRNJJ0UG KG4t4jXNrLxpLNTJ7VMnRjapYosimVVdnBFQnH7WJMJ9HqydmNXb6Onf1vEVDZSIzhFP YA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0vrs2h43-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:44 +0000 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214LGii8008651; Fri, 4 Feb 2022 21:16:44 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0vrs2h2x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:44 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LD6GO009805; Fri, 4 Feb 2022 21:16:43 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma01dal.us.ibm.com with ESMTP id 3e0r0syf5d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:42 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGbTd10682856 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:37 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 14DDF136067; Fri, 4 Feb 2022 21:16:37 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4CF12136055; Fri, 4 Feb 2022 21:16:35 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:35 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 27/30] vfio-pci/zdev: wire up zPCI IOAT assist support Date: Fri, 4 Feb 2022 16:15:33 -0500 Message-Id: <20220204211536.321475-28-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: faDg9QKgv1C3ZEcPH9zrlpq8Ka3mWygU X-Proofpoint-ORIG-GUID: WIYIs5fiYQDnG-WU7KYYh7k1kw72uxIe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 mlxlogscore=913 priorityscore=1501 phishscore=0 suspectscore=0 impostorscore=0 bulkscore=0 clxscore=1015 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Introduce support for VFIO_DEVICE_FEATURE_ZPCI_IOAT, which is a new VFIO_DEVICE_FEATURE ioctl. This interface is used to indicate that an s390x vfio-pci device wishes to enable/disable zPCI I/O Address Translation assistance, allowing the host to perform address translation and shadowing. Reviewed-by: Pierre Morel Signed-off-by: Matthew Rosato --- arch/s390/include/asm/kvm_pci.h | 1 + drivers/vfio/pci/vfio_pci_core.c | 2 ++ drivers/vfio/pci/vfio_pci_zdev.c | 58 ++++++++++++++++++++++++++++++++ include/linux/vfio_pci_core.h | 10 ++++++ include/uapi/linux/vfio.h | 8 +++++ include/uapi/linux/vfio_zdev.h | 13 +++++++ 6 files changed, 92 insertions(+) diff --git a/arch/s390/include/asm/kvm_pci.h b/arch/s390/include/asm/kvm_pci.h index 93b61e61dc7f..71d27863ab97 100644 --- a/arch/s390/include/asm/kvm_pci.h +++ b/arch/s390/include/asm/kvm_pci.h @@ -31,6 +31,7 @@ struct kvm_zdev { struct zpci_dev *zdev; struct kvm *kvm; u64 rpcit_count; + u64 iota; struct kvm_zdev_ioat ioat; struct zpci_fib fib; struct notifier_block nb; diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index 01658de660bd..709d9ba22a60 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -1176,6 +1176,8 @@ long vfio_pci_core_ioctl(struct vfio_device *core_vdev, unsigned int cmd, return vfio_pci_zdev_feat_interp(vdev, feature, arg); case VFIO_DEVICE_FEATURE_ZPCI_AIF: return vfio_pci_zdev_feat_aif(vdev, feature, arg); + case VFIO_DEVICE_FEATURE_ZPCI_IOAT: + return vfio_pci_zdev_feat_ioat(vdev, feature, arg); default: return -ENOTTY; } diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c index 74508bdc5f88..f0a6e0f0e4b0 100644 --- a/drivers/vfio/pci/vfio_pci_zdev.c +++ b/drivers/vfio/pci/vfio_pci_zdev.c @@ -292,6 +292,63 @@ int vfio_pci_zdev_feat_aif(struct vfio_pci_core_device *vdev, return rc; } +int vfio_pci_zdev_feat_ioat(struct vfio_pci_core_device *vdev, + struct vfio_device_feature feature, + unsigned long arg) +{ + struct zpci_dev *zdev = to_zpci(vdev->pdev); + struct vfio_device_zpci_ioat *data; + struct vfio_device_feature *feat; + unsigned long minsz; + int size, rc = 0; + + if (!zdev || !zdev->kzdev) + return -EINVAL; + + /* If PROBE specified, return probe results immediately */ + if (feature.flags & VFIO_DEVICE_FEATURE_PROBE) + return kvm_s390_pci_ioat_probe(zdev); + + size = sizeof(*feat) + sizeof(*data); + feat = kzalloc(size, GFP_KERNEL); + if (!feat) + return -ENOMEM; + + data = (struct vfio_device_zpci_ioat *)&feat->data; + minsz = offsetofend(struct vfio_device_feature, flags); + + if (feature.argsz < minsz + sizeof(*data)) + return -EINVAL; + + /* Get the rest of the payload for GET/SET */ + rc = copy_from_user(data, (void __user *)(arg + minsz), + sizeof(*data)); + if (rc) + rc = -EINVAL; + + if (feature.flags & VFIO_DEVICE_FEATURE_GET) { + data->iota = (u64)zdev->kzdev->iota; + if (copy_to_user((void __user *)arg, feat, size)) + rc = -EFAULT; + } else if (feature.flags & VFIO_DEVICE_FEATURE_SET) { + if (data->iota != 0) { + rc = kvm_s390_pci_ioat_enable(zdev, data->iota); + if (!rc) + zdev->kzdev->iota = data->iota; + } else if (zdev->kzdev->iota != 0) { + rc = kvm_s390_pci_ioat_disable(zdev); + if (!rc) + zdev->kzdev->iota = 0; + } + } else { + /* Neither GET nor SET were specified */ + rc = -EINVAL; + } + + kfree(feat); + return rc; +} + static int vfio_pci_zdev_group_notifier(struct notifier_block *nb, unsigned long action, void *data) { @@ -341,6 +398,7 @@ void vfio_pci_zdev_release(struct vfio_pci_core_device *vdev) */ if (zdev->gisa != 0) { kvm_s390_pci_aif_disable(zdev, true); + kvm_s390_pci_ioat_disable(zdev); kvm_s390_pci_interp_disable(zdev, true); } diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h index 7ec5e82e7933..f17d761ae14e 100644 --- a/include/linux/vfio_pci_core.h +++ b/include/linux/vfio_pci_core.h @@ -204,6 +204,9 @@ int vfio_pci_zdev_feat_interp(struct vfio_pci_core_device *vdev, int vfio_pci_zdev_feat_aif(struct vfio_pci_core_device *vdev, struct vfio_device_feature feature, unsigned long arg); +int vfio_pci_zdev_feat_ioat(struct vfio_pci_core_device *vdev, + struct vfio_device_feature feature, + unsigned long arg); void vfio_pci_zdev_open(struct vfio_pci_core_device *vdev); void vfio_pci_zdev_release(struct vfio_pci_core_device *vdev); #else @@ -227,6 +230,13 @@ static inline int vfio_pci_zdev_feat_aif(struct vfio_pci_core_device *vdev, return -ENOTTY; } +static inline int vfio_pci_zdev_feat_ioat(struct vfio_pci_core_device *vdev, + struct vfio_device_feature feature, + unsigned long arg) +{ + return -ENOTTY; +} + static inline void vfio_pci_zdev_open(struct vfio_pci_core_device *vdev) { } diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index fe3bfd99bf50..32c687388f48 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -1016,6 +1016,14 @@ struct vfio_device_feature { */ #define VFIO_DEVICE_FEATURE_ZPCI_AIF (2) +/* + * Provide support for enabling guest I/O address translation assistance for + * zPCI devices. This feature is only valid for s390x PCI devices. Data + * provided when setting and getting this feature is further described in + * vfio_zdev.h + */ +#define VFIO_DEVICE_FEATURE_ZPCI_IOAT (3) + /* -------- API for Type1 VFIO IOMMU -------- */ /** diff --git a/include/uapi/linux/vfio_zdev.h b/include/uapi/linux/vfio_zdev.h index 09f413dfb1c3..b77e6ef355cb 100644 --- a/include/uapi/linux/vfio_zdev.h +++ b/include/uapi/linux/vfio_zdev.h @@ -110,4 +110,17 @@ struct vfio_device_zpci_aif { __u8 sbo; /* Offset of guest summary bit vector */ }; +/** + * VFIO_DEVICE_FEATURE_ZPCI_IOAT + * + * This feature is used for enabling guest I/O translation assistance for + * passthrough zPCI devices using instruction interpretation. When setting + * this feature, the iota specifies a KVM guest I/O translation anchor. When + * getting this feature, the most recently set anchor (or 0) is returned in + * iota. + */ +struct vfio_device_zpci_ioat { + __u64 iota; +}; + #endif From patchwork Fri Feb 4 21:15:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735672 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20BABC4332F for ; Fri, 4 Feb 2022 21:18:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348265AbiBDVR7 (ORCPT ); Fri, 4 Feb 2022 16:17:59 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:45524 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241693AbiBDVQm (ORCPT ); Fri, 4 Feb 2022 16:16:42 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214KZ2o6006899; Fri, 4 Feb 2022 21:16:42 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=geW5tDJ/mjJpnu+nHkdNdvQlMidXOhTFHIvUZbI4T9c=; b=B0vImhAdYmky1Su6oY/NpJNhNE73WbYmo84plP8XuBFvBKY+wRN7e6Sr5NoBkjYIgHBu cxXx34Yfe/V7KrmzD7At42QQ517b6fdQeA7/fIMQsVun5N1DlSSCuDPYkGwdVwwaJOKA aTYNmfwfJo3BMP0SAlYre2/ehT3XD4thQrQlSWeA42CrwqpSMlswxlrZDfNXnxx8EGQe Btd/GdqYVOc2GZUuicZ5RrD+iyYydWLum3fFZNcSqM4MS7idNvkrUHmTfFLo1IWC9lSm 2R/xzYrv5iT/fKC9AdC+kWZrPs5k0g3zqHUEPPePame0tN6obcQSlslFmqSgLe8jicCf GQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx0xssx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:42 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214LGg2M031331; Fri, 4 Feb 2022 21:16:42 GMT Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx0xsrp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:42 +0000 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCbuU022181; Fri, 4 Feb 2022 21:16:40 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma02wdc.us.ibm.com with ESMTP id 3e0r0kavgk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:40 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGdoQ33751498 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:39 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 11279136067; Fri, 4 Feb 2022 21:16:39 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 39B9213606A; Fri, 4 Feb 2022 21:16:37 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:37 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 28/30] vfio-pci/zdev: add DTSM to clp group capability Date: Fri, 4 Feb 2022 16:15:34 -0500 Message-Id: <20220204211536.321475-29-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: _2WOctQ82_wJ_o4bRkUS3wzboPNLoKF_ X-Proofpoint-ORIG-GUID: K4AwFV2SZJKDM3eA7y0UukPXQC3fPBUf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 spamscore=0 malwarescore=0 phishscore=0 priorityscore=1501 impostorscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The DTSM, or designation type supported mask, indicates what IOAT formats are available to the guest. For an interpreted device, userspace will not know what format(s) the IOAT assist supports, so pass it via the capability chain. Since the value belongs to the Query PCI Function Group clp, let's extend the existing capability with a new version. Reviewed-by: Pierre Morel Signed-off-by: Matthew Rosato --- drivers/vfio/pci/vfio_pci_zdev.c | 9 ++++++--- include/uapi/linux/vfio_zdev.h | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c index f0a6e0f0e4b0..046d91085358 100644 --- a/drivers/vfio/pci/vfio_pci_zdev.c +++ b/drivers/vfio/pci/vfio_pci_zdev.c @@ -45,19 +45,22 @@ static int zpci_group_cap(struct zpci_dev *zdev, struct vfio_info_cap *caps) { struct vfio_device_info_cap_zpci_group cap = { .header.id = VFIO_DEVICE_INFO_CAP_ZPCI_GROUP, - .header.version = 1, + .header.version = 2, .dasm = zdev->dma_mask, .msi_addr = zdev->msi_addr, .flags = VFIO_DEVICE_INFO_ZPCI_FLAG_REFRESH, .mui = zdev->fmb_update, .noi = zdev->max_msi, .maxstbl = ZPCI_MAX_WRITE_SIZE, - .version = zdev->version + .version = zdev->version, + .dtsm = 0 }; /* Some values are different for interpreted devices */ - if (zdev->kzdev && zdev->kzdev->interpretation) + if (zdev->kzdev && zdev->kzdev->interpretation) { cap.maxstbl = zdev->maxstbl; + cap.dtsm = kvm_s390_pci_get_dtsm(zdev); + } return vfio_info_add_capability(caps, &cap.header, sizeof(cap)); } diff --git a/include/uapi/linux/vfio_zdev.h b/include/uapi/linux/vfio_zdev.h index b77e6ef355cb..133df1002ecb 100644 --- a/include/uapi/linux/vfio_zdev.h +++ b/include/uapi/linux/vfio_zdev.h @@ -47,6 +47,9 @@ struct vfio_device_info_cap_zpci_group { __u16 noi; /* Maximum number of MSIs */ __u16 maxstbl; /* Maximum Store Block Length */ __u8 version; /* Supported PCI Version */ + /* End of version 1 */ + __u8 dtsm; /* Supported IOAT Designations */ + /* End of version 2 */ }; /** From patchwork Fri Feb 4 21:15:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61109C4332F for ; Fri, 4 Feb 2022 21:18:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350243AbiBDVSK (ORCPT ); Fri, 4 Feb 2022 16:18:10 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34486 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S242369AbiBDVQp (ORCPT ); Fri, 4 Feb 2022 16:16:45 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214JoGju011703; Fri, 4 Feb 2022 21:16:45 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=EY7GBAQzsJxHyryhFNTgz1vz0vozbo4MD1PfSNi+/9M=; b=YGzdIGRd2C0qcn0pp+1H195z/raNEzEUDhHrTaEK3PatugYPFsHjBP/7WNLLYIoGYksc D2LZF8bHTgX3UXnofkY5eofyxgRZjgVfh+z690jqlh4yGSDSMpvtoSQE5vu7DdbBcqnb Wu+vxAxrhHyhz3GGs8l431l7UanGcZ+KSc3ylMV2kFj38XxCr5Yo082gYqWEOI0vsGyd LYERuaC00ckvbgdZmZCdCiULgTY0F9E/dl1sb4muKWOij7sJLiriPPdMJLjWNgTpYcQ5 zNgqVVhpBitLX3E6YJ/jxyJTwIylQVOUFZIV4CucF8PwH9LtUQpfUt8/ZiopFIA1U6wS /A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0qxg748u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:44 +0000 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214LGiY2013327; Fri, 4 Feb 2022 21:16:44 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0qxg7483-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:44 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LCaHC021806; Fri, 4 Feb 2022 21:16:43 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma03dal.us.ibm.com with ESMTP id 3e0r0k7hab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:43 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGfZ538207870 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:41 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0A7D613604F; Fri, 4 Feb 2022 21:16:41 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 32D4C13606E; Fri, 4 Feb 2022 21:16:39 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:39 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 29/30] KVM: s390: introduce CPU feature for zPCI Interpretation Date: Fri, 4 Feb 2022 16:15:35 -0500 Message-Id: <20220204211536.321475-30-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ciK73k16nUAl3qjdoIbrRlqL0UuZ3X1F X-Proofpoint-ORIG-GUID: P6TF5QrwvcbRtXSrmYeLUt3TcQJxg9fP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 mlxlogscore=999 clxscore=1015 lowpriorityscore=0 adultscore=0 mlxscore=0 spamscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org KVM_S390_VM_CPU_FEAT_ZPCI_INTERP relays whether zPCI interpretive execution is possible based on the available hardware facilities. Signed-off-by: Matthew Rosato Reviewed-by: Pierre Morel --- arch/s390/include/uapi/asm/kvm.h | 1 + arch/s390/kvm/kvm-s390.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/arch/s390/include/uapi/asm/kvm.h b/arch/s390/include/uapi/asm/kvm.h index 7a6b14874d65..ed06458a871f 100644 --- a/arch/s390/include/uapi/asm/kvm.h +++ b/arch/s390/include/uapi/asm/kvm.h @@ -130,6 +130,7 @@ struct kvm_s390_vm_cpu_machine { #define KVM_S390_VM_CPU_FEAT_PFMFI 11 #define KVM_S390_VM_CPU_FEAT_SIGPIF 12 #define KVM_S390_VM_CPU_FEAT_KSS 13 +#define KVM_S390_VM_CPU_FEAT_ZPCI_INTERP 14 struct kvm_s390_vm_cpu_feat { __u64 feat[16]; }; diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 208b09d08385..e20d9ac1935d 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -434,6 +434,11 @@ static void kvm_s390_cpu_feat_init(void) if (test_facility(151)) /* DFLTCC */ __insn32_query(INSN_DFLTCC, kvm_s390_available_subfunc.dfltcc); + /* zPCI Interpretation */ + if (IS_ENABLED(CONFIG_VFIO_PCI_ZDEV) && test_facility(69) && + test_facility(70) && test_facility(71) && test_facility(72)) + allow_cpu_feat(KVM_S390_VM_CPU_FEAT_ZPCI_INTERP); + if (MACHINE_HAS_ESOP) allow_cpu_feat(KVM_S390_VM_CPU_FEAT_ESOP); /* From patchwork Fri Feb 4 21:15:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 12735674 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4D1BC433F5 for ; Fri, 4 Feb 2022 21:18:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349620AbiBDVSH (ORCPT ); Fri, 4 Feb 2022 16:18:07 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:61692 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244092AbiBDVQr (ORCPT ); Fri, 4 Feb 2022 16:16:47 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 214IGOd6028429; Fri, 4 Feb 2022 21:16:47 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=yeoBPLQAylIMFufLgBsfkVzGHAJfiDsHxuQ1N+MmstE=; b=LacBLyky1yrdBBz8X+L6NS3meAV5WY8YsvApV1AK6WUYt9pWwiAKJ7aFa7fns3tJ4g2A c63TrKKMYvmLXBfE1CPVBoMQwEOsFSMGRwwgMlmZHsDCfZn2zQy3RrA2QPLLUvT/ddvQ WjZ8LoRhNWpa2W8i/goeFPpKJGhlhvQA7QL8oyNhacEDozBZ5IXXi7IMQaniDqAFZJrK lCYR7E0SitU29RdiQjYZdbhP8QpQaMQ1spxsoIYc9cWSay6dGJ1MN9baMhkDN/Qc8ZSS PkVbmPTbTue8ssx05fy0vWyZYYnBbgRCJtVv1S39meingD0iamYznd/q0cngzebMlW0w fA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx470w4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:47 +0000 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 214LG02S000394; Fri, 4 Feb 2022 21:16:46 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e0qx470us-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:46 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214LDEYk029537; Fri, 4 Feb 2022 21:16:45 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma04wdc.us.ibm.com with ESMTP id 3e0r0vavbn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 21:16:45 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214LGhE311403940 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 21:16:43 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C96B136065; Fri, 4 Feb 2022 21:16:43 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3799B13604F; Fri, 4 Feb 2022 21:16:41 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.82.52]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 21:16:41 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Christian Borntraeger Subject: [PATCH v3 30/30] MAINTAINERS: additional files related kvm s390 pci passthrough Date: Fri, 4 Feb 2022 16:15:36 -0500 Message-Id: <20220204211536.321475-31-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220204211536.321475-1-mjrosato@linux.ibm.com> References: <20220204211536.321475-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: RPT6B_-v7dqIMpR5oz7ERx1qMWuK9te- X-Proofpoint-GUID: iz4MJ6VoawHyuYZ4noK-qxfZD0ybiVKO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_07,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=984 lowpriorityscore=0 phishscore=0 clxscore=1015 impostorscore=0 adultscore=0 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040117 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add entries from the s390 kvm subdirectory related to pci passthrough. Acked-by: Christian Borntraeger Signed-off-by: Matthew Rosato --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index bb83dcbcb619..2762295ad85e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16900,6 +16900,8 @@ M: Eric Farman L: linux-s390@vger.kernel.org L: kvm@vger.kernel.org S: Supported +F: arch/s390/include/asm/kvm_pci.h +F: arch/s390/kvm/pci* F: drivers/vfio/pci/vfio_pci_zdev.c F: include/uapi/linux/vfio_zdev.h