Message ID | 20231018133829.147226-3-akrowiak@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4800426vqb; Wed, 18 Oct 2023 06:44:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+2CS4evmsHm8zWdJBnseBporI5B0D1vq4SeIqyxCONESWhL0K2utlaoenZHB6GAbWAPvn X-Received: by 2002:a05:6830:6e9a:b0:6c7:aab5:6e50 with SMTP id ed26-20020a0568306e9a00b006c7aab56e50mr6902639otb.2.1697636647168; Wed, 18 Oct 2023 06:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697636647; cv=none; d=google.com; s=arc-20160816; b=wDxQWDchmcFf6h+XyHojq2a6eetd9RgunCl1x76bkickv1kc04SjHDmfzfTWJfZLBj NAvNlP8TayMSPgYxErHjYPqIbsgb7FqT4ZYoEZarxEGPH2JQpIIipZjxHvgHrnM068lA rEINFtxszmQFCveRxGpyZWIR9FvbZg8c7GNVGujeqm4tsowjYz3SAx96OPTFOKUdgyy9 MBfzm+egkDd9lLuQ5ARlr3WkgM4Ad2/Z9f+BaRU7MF089w9NUK8eFa9XW6i3VMmhF9N0 dzy8d+QkmVmd+fOPe5cTlF9wqTonia63GpGuajaN4kN/d5gg/i1B1t0zr8rymtElBUgw rk2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X8kIrslWDOXWhoHJov+e3SPTeZxOhaqsDjB2N84baz0=; fh=08nkjaW8CDtRXYyXjnJwUEKm1JSc9mnBVUEbsbJeqHQ=; b=ZaCe9UBsKSVF1EFq7yWnUz54n/3GtOx9lbrXEd2/nhtbgG8yFdkENSXQBnHLLcXVPN dkXu0CyoNl3aJrF/MydGN2HNaczr1Jpm1yS87fYKD9z6OX8rToPDqU1ey13h8oM8LoTV KM8aJSG6jeXu/UmZlOzjvbTRnM3ODheYAnl93GfGL+i5DcFtSIrcikdFWPAVXT5p+waO 8NOSevMJTZyti8DTTZpZINkXl+XJwqaYTpVXaP/mEsuDSGAZJ2OfGlCik2Jaw1Bzb1Lb ixMG2s7MR6A6or0Gf7836H5NA3sFoF/QllFpA587anqVx+JROyLBIgym3hji96/Ca5az dxzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=F9RHt7sh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id g4-20020a056a001a0400b006be2ee8929csi4138160pfv.313.2023.10.18.06.44.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 06:44:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=F9RHt7sh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id DAEC5801C08B; Wed, 18 Oct 2023 06:44:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344751AbjJRNn7 (ORCPT <rfc822;zwp10758@gmail.com> + 23 others); Wed, 18 Oct 2023 09:43:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344752AbjJRNn4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 18 Oct 2023 09:43:56 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25DBF11B; Wed, 18 Oct 2023 06:43:54 -0700 (PDT) Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39IDfDg0005623; Wed, 18 Oct 2023 13:43: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=X8kIrslWDOXWhoHJov+e3SPTeZxOhaqsDjB2N84baz0=; b=F9RHt7sh0W3fogKes8yrJE3m+aIO5w4Yz3ffzWhYaajVWLmvmYpCAYawIHQtSPgLONTw IqWq+AGXNZzlfq4GvlxirnPW4Wso9Jiuqnl0U2yjeDoK0+j6rZei50eL1nJQwY3efWKO UuXOqyypHm0JRMJAev4T0sgXKee0iWHqhg2Dv4IMgozhdSxzO+/t5/Y1tuEN2Qjiu3pr 3zqbeUY74gqIwhnCzi22btWhSeKxdGttxrvGbTlXr8qNczg7mLEsQ9sxLugkFv1iBaFw KAbOdUv+VFt0Vs5Kqv0RmCKQ0ZNAjwCGKxuf5z6EE1sy6upyrPuehdSPCNUyiSI0A+/K RA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ttg4b92qu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Oct 2023 13:43:50 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 39IDgKoj011264; Wed, 18 Oct 2023 13:43:45 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ttg4b921k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Oct 2023 13:43:45 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 39IDLQvR030742; Wed, 18 Oct 2023 13:38:35 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3tr7hjrdsx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Oct 2023 13:38:35 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 39IDcYsG19858052 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Oct 2023 13:38:34 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3806A58052; Wed, 18 Oct 2023 13:38:34 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2315758045; Wed, 18 Oct 2023 13:38:33 +0000 (GMT) Received: from li-2c1e724c-2c76-11b2-a85c-ae42eaf3cb3d.ibm.com.com (unknown [9.61.47.87]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 18 Oct 2023 13:38:33 +0000 (GMT) From: Tony Krowiak <akrowiak@linux.ibm.com> To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: jjherne@linux.ibm.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, david@redhat.com, Anthony Krowiak <akrowiak@linux.ibm.com> Subject: [PATCH v2 2/3] s390/vfio-ap: set status response code to 06 on gisc registration failure Date: Wed, 18 Oct 2023 09:38:24 -0400 Message-ID: <20231018133829.147226-3-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018133829.147226-1-akrowiak@linux.ibm.com> References: <20231018133829.147226-1-akrowiak@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: jQx168nVdQ3x0oyq_7GuxS--V6M-belu X-Proofpoint-ORIG-GUID: vV0iWP7sobZ11OQO7qgNgKmawz0IGUI6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-18_12,2023-10-18_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310180114 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 18 Oct 2023 06:44:04 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780101045022415196 X-GMAIL-MSGID: 1780101045022415196 |
Series |
a couple of corrections to the IRQ enablement function
|
|
Commit Message
Anthony Krowiak
Oct. 18, 2023, 1:38 p.m. UTC
From: Anthony Krowiak <akrowiak@linux.ibm.com> The interception handler for the PQAP(AQIC) command calls the kvm_s390_gisc_register function to register the guest ISC with the channel subsystem. If that call fails, the status response code 08 - indicating Invalid ZONE/GISA designation - is returned to the guest. This response code does not make sense because the non-zero return code from the kvm_s390_gisc_register function can be due one of two things: Either the ISC passed as a parameter by the guest to the PQAP(AQIC) command is greater than the maximum ISC value allowed, or the guest is not using a GISA. Since this scenario is very unlikely to happen and there is no status response code to indicate an invalid ISC value, let's set the response code to 06 indicating 'Invalid address of AP-queue notification byte'. While this is not entirely accurate, it is better than indicating that the ZONE/GISA designation is invalid which is something the guest can do nothing about since those values are set by the hypervisor. Signed-off-by: Anthony Krowiak <akrowiak@linux.ibm.com> Suggested-by: Halil Pasic <pasic@linux.ibm.com> --- drivers/s390/crypto/vfio_ap_ops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On Wed, 18 Oct 2023 09:38:24 -0400 Tony Krowiak <akrowiak@linux.ibm.com> wrote: > From: Anthony Krowiak <akrowiak@linux.ibm.com> > > The interception handler for the PQAP(AQIC) command calls the > kvm_s390_gisc_register function to register the guest ISC with the channel > subsystem. If that call fails, the status response code 08 - indicating > Invalid ZONE/GISA designation - is returned to the guest. This response > code does not make sense because the non-zero return code from the > kvm_s390_gisc_register function can be due one of two things: Either the > ISC passed as a parameter by the guest to the PQAP(AQIC) command is greater > than the maximum ISC value allowed, or the guest is not using a GISA. The "ISC passed as a parameter by the guest to the PQAP(AQIC) command is greater than the maximum ISC value allowed" is not possible. The isc is 3 bits wide and all 8 values that can be represented on 3 bits are valid. This is only possible if the hypervisor was to mess up, or if the machine was broken. > > Since this scenario is very unlikely to happen and there is no status > response code to indicate an invalid ISC value, let's set the > response code to 06 indicating 'Invalid address of AP-queue notification > byte'. While this is not entirely accurate, it is better than indicating > that the ZONE/GISA designation is invalid which is something the guest > can do nothing about since those values are set by the hypervisor. > > Signed-off-by: Anthony Krowiak <akrowiak@linux.ibm.com> > Suggested-by: Halil Pasic <pasic@linux.ibm.com> > --- > drivers/s390/crypto/vfio_ap_ops.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c > index 9cb28978c186..25d7ce2094f8 100644 > --- a/drivers/s390/crypto/vfio_ap_ops.c > +++ b/drivers/s390/crypto/vfio_ap_ops.c > @@ -393,8 +393,8 @@ static int ensure_nib_shared(unsigned long addr, struct gmap *gmap) > * Register the guest ISC to GIB interface and retrieve the > * host ISC to issue the host side PQAP/AQIC > * > - * Response.status may be set to AP_RESPONSE_INVALID_ADDRESS in case the > - * vfio_pin_pages failed. > + * status.response_code may be set to AP_RESPONSE_INVALID_ADDRESS in case the > + * vfio_pin_pages or kvm_s390_gisc_register failed. > * > * Otherwise return the ap_queue_status returned by the ap_aqic(), > * all retry handling will be done by the guest. > @@ -458,7 +458,7 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q, > __func__, nisc, isc, q->apqn); > > vfio_unpin_pages(&q->matrix_mdev->vdev, nib, 1); > - status.response_code = AP_RESPONSE_INVALID_GISA; > + status.response_code = AP_RESPONSE_INVALID_ADDRESS; > return status; > } >
On 10/27/23 06:56, Halil Pasic wrote: > On Wed, 18 Oct 2023 09:38:24 -0400 > Tony Krowiak <akrowiak@linux.ibm.com> wrote: > >> From: Anthony Krowiak <akrowiak@linux.ibm.com> >> >> The interception handler for the PQAP(AQIC) command calls the >> kvm_s390_gisc_register function to register the guest ISC with the channel >> subsystem. If that call fails, the status response code 08 - indicating >> Invalid ZONE/GISA designation - is returned to the guest. This response >> code does not make sense because the non-zero return code from the >> kvm_s390_gisc_register function can be due one of two things: Either the >> ISC passed as a parameter by the guest to the PQAP(AQIC) command is greater >> than the maximum ISC value allowed, or the guest is not using a GISA. > > The "ISC passed as a parameter by the guest to the PQAP(AQIC) command is > greater than the maximum ISC value allowed" is not possible. The isc is > 3 bits wide and all 8 values that can be represented on 3 bits are valid. > > This is only possible if the hypervisor was to mess up, or if the machine > was broken. kvm_s390_gisc_register(struct kvm *kvm, u32 gisc) { struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; if (!gi->origin) return -ENODEV; if (gisc > MAX_ISC) return -ERANGE; ... Just quoting what is in the code. > >> >> Since this scenario is very unlikely to happen and there is no status >> response code to indicate an invalid ISC value, let's set the >> response code to 06 indicating 'Invalid address of AP-queue notification >> byte'. While this is not entirely accurate, it is better than indicating >> that the ZONE/GISA designation is invalid which is something the guest >> can do nothing about since those values are set by the hypervisor. >> >> Signed-off-by: Anthony Krowiak <akrowiak@linux.ibm.com> >> Suggested-by: Halil Pasic <pasic@linux.ibm.com> > > >> --- >> drivers/s390/crypto/vfio_ap_ops.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c >> index 9cb28978c186..25d7ce2094f8 100644 >> --- a/drivers/s390/crypto/vfio_ap_ops.c >> +++ b/drivers/s390/crypto/vfio_ap_ops.c >> @@ -393,8 +393,8 @@ static int ensure_nib_shared(unsigned long addr, struct gmap *gmap) >> * Register the guest ISC to GIB interface and retrieve the >> * host ISC to issue the host side PQAP/AQIC >> * >> - * Response.status may be set to AP_RESPONSE_INVALID_ADDRESS in case the >> - * vfio_pin_pages failed. >> + * status.response_code may be set to AP_RESPONSE_INVALID_ADDRESS in case the >> + * vfio_pin_pages or kvm_s390_gisc_register failed. >> * >> * Otherwise return the ap_queue_status returned by the ap_aqic(), >> * all retry handling will be done by the guest. >> @@ -458,7 +458,7 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q, >> __func__, nisc, isc, q->apqn); >> >> vfio_unpin_pages(&q->matrix_mdev->vdev, nib, 1); >> - status.response_code = AP_RESPONSE_INVALID_GISA; >> + status.response_code = AP_RESPONSE_INVALID_ADDRESS; >> return status; >> } >> >
On Fri, 27 Oct 2023 09:36:26 -0400 Tony Krowiak <akrowiak@linux.ibm.com> wrote: > >> The interception handler for the PQAP(AQIC) command calls the > >> kvm_s390_gisc_register function to register the guest ISC with the channel > >> subsystem. If that call fails, the status response code 08 - indicating > >> Invalid ZONE/GISA designation - is returned to the guest. This response > >> code does not make sense because the non-zero return code from the > >> kvm_s390_gisc_register function can be due one of two things: Either the > >> ISC passed as a parameter by the guest to the PQAP(AQIC) command is greater > >> than the maximum ISC value allowed, or the guest is not using a GISA. > > > > The "ISC passed as a parameter by the guest to the PQAP(AQIC) command is > > greater than the maximum ISC value allowed" is not possible. The isc is > > 3 bits wide and all 8 values that can be represented on 3 bits are valid. > > > > This is only possible if the hypervisor was to mess up, or if the machine > > was broken. > > kvm_s390_gisc_register(struct kvm *kvm, u32 gisc) > { > struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; > > if (!gi->origin) > return -ENODEV; > if (gisc > MAX_ISC) > return -ERANGE; > ... > > Just quoting what is in the code. Right! But it is not the guest that calls this function directly. This function is called by the vfio_ap code. The guest passes ISC in bits 61, 62 and 63 of GR1. So the guest can't give you an invalid value. Regards, Halil
On 10/27/23 10:03, Halil Pasic wrote: > On Fri, 27 Oct 2023 09:36:26 -0400 > Tony Krowiak <akrowiak@linux.ibm.com> wrote: > >>>> The interception handler for the PQAP(AQIC) command calls the >>>> kvm_s390_gisc_register function to register the guest ISC with the channel >>>> subsystem. If that call fails, the status response code 08 - indicating >>>> Invalid ZONE/GISA designation - is returned to the guest. This response >>>> code does not make sense because the non-zero return code from the >>>> kvm_s390_gisc_register function can be due one of two things: Either the >>>> ISC passed as a parameter by the guest to the PQAP(AQIC) command is greater >>>> than the maximum ISC value allowed, or the guest is not using a GISA. >>> >>> The "ISC passed as a parameter by the guest to the PQAP(AQIC) command is >>> greater than the maximum ISC value allowed" is not possible. The isc is >>> 3 bits wide and all 8 values that can be represented on 3 bits are valid. >>> >>> This is only possible if the hypervisor was to mess up, or if the machine >>> was broken. >> >> kvm_s390_gisc_register(struct kvm *kvm, u32 gisc) >> { >> struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; >> >> if (!gi->origin) >> return -ENODEV; >> if (gisc > MAX_ISC) >> return -ERANGE; >> ... >> >> Just quoting what is in the code. > > Right! But it is not the guest that calls this function directly. This > function is called by the vfio_ap code. > > The guest passes ISC in bits 61, 62 and 63 of GR1. > > So the guest can't give you an invalid value. Yes, I got it the first time you said that. > > Regards, > Halil
diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 9cb28978c186..25d7ce2094f8 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -393,8 +393,8 @@ static int ensure_nib_shared(unsigned long addr, struct gmap *gmap) * Register the guest ISC to GIB interface and retrieve the * host ISC to issue the host side PQAP/AQIC * - * Response.status may be set to AP_RESPONSE_INVALID_ADDRESS in case the - * vfio_pin_pages failed. + * status.response_code may be set to AP_RESPONSE_INVALID_ADDRESS in case the + * vfio_pin_pages or kvm_s390_gisc_register failed. * * Otherwise return the ap_queue_status returned by the ap_aqic(), * all retry handling will be done by the guest. @@ -458,7 +458,7 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q, __func__, nisc, isc, q->apqn); vfio_unpin_pages(&q->matrix_mdev->vdev, nib, 1); - status.response_code = AP_RESPONSE_INVALID_GISA; + status.response_code = AP_RESPONSE_INVALID_ADDRESS; return status; }