Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2445198imm; Mon, 24 Sep 2018 04:37:46 -0700 (PDT) X-Google-Smtp-Source: ACcGV60Yok+MEcAzMpZ+XyRZW6EsNZcl18JPz35xNatNOVLcGfhtwS5BEK0u3KbZivqb5YvHGPtv X-Received: by 2002:a63:9c19:: with SMTP id f25-v6mr9244263pge.447.1537789065988; Mon, 24 Sep 2018 04:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537789065; cv=none; d=google.com; s=arc-20160816; b=o6WGcEc312uo6dKf5mkIIR+AzINZ54zHl9UzliON0DWq/7DCNJcoGxjmx0bNDUWyyB tznKdWL1OFpB7zWBliAWxiBbp9paPaYMqeVO8RZUItGWtSQbF2ffyjqe3+ZA9IsGWIsd 4RY9iJDkyyYcaeip6P9IUfQz/Lu++gKVmCT9BU9b78eaFo0HB1lz5d+I3+rFEpzAIEUF NrfzuoyjlStFb5AzZVyrlGOqrKf/Nh1+QGRfU8SfnQcBZHxtM5snbDa4OCutGpYQKWtx 9qD9tmekInn4S915QolAG0eoimgcBcB7xyfoFZU8fof2aq90HSol1ckzfPGKwAMb3qC9 SdjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=HS0dluvgc/38BCX2nqJUst0lP0Vx1oTxQ2bJeYjRpzA=; b=y5Fyv4ygFpwMpG1yRETBmFGNflqVkmO23uwfYU9vuOxQ31dZdaIWtgSCZwaezurWjR Atb6OY3mZ/eUNAvw6k6GL3MyeSa0haGepsODJE/2dB59Yr5Tktbl2q8hng1IJ11p3E32 vLNYzdz8fDbSnwQx29qdCBLJsHf+Z3PAmxaPXT1P2EBL466rFiuSX9I9gDt+g/NvL3fq vw2QwHBgNajCoTMhXqVBuPuk5EPBwoyWOEggVD1D4pl9RlzjFACG5PMWwYqINILIuh2s TjSkuLD3i33gseMb39gSsL7nm54JJWgFTmsM3llgeJv+2XcYGzfGhqwl0gvwW3YsueFY Ni3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v39-v6si14036904pgn.646.2018.09.24.04.37.30; Mon, 24 Sep 2018 04:37:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728530AbeIXRiC (ORCPT + 99 others); Mon, 24 Sep 2018 13:38:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42018 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728397AbeIXRiC (ORCPT ); Mon, 24 Sep 2018 13:38:02 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3F90308421A; Mon, 24 Sep 2018 11:36:23 +0000 (UTC) Received: from gondolin (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id C482A9CBC; Mon, 24 Sep 2018 11:36:13 +0000 (UTC) Date: Mon, 24 Sep 2018 13:36:11 +0200 From: Cornelia Huck To: Tony Krowiak Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, freude@de.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, borntraeger@de.ibm.com, kwankhede@nvidia.com, bjsdjshi@linux.vnet.ibm.com, pbonzini@redhat.com, alex.williamson@redhat.com, pmorel@linux.vnet.ibm.com, alifm@linux.vnet.ibm.com, mjrosato@linux.vnet.ibm.com, jjherne@linux.vnet.ibm.com, thuth@redhat.com, pasic@linux.vnet.ibm.com, berrange@redhat.com, fiuczy@linux.vnet.ibm.com, buendgen@de.ibm.com, frankja@linux.ibm.com, Tony Krowiak Subject: Re: [PATCH v10 13/26] s390: vfio-ap: zeroize the AP queues Message-ID: <20180924133611.01fef50e.cohuck@redhat.com> In-Reply-To: <1536781396-13601-14-git-send-email-akrowiak@linux.vnet.ibm.com> References: <1536781396-13601-1-git-send-email-akrowiak@linux.vnet.ibm.com> <1536781396-13601-14-git-send-email-akrowiak@linux.vnet.ibm.com> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 24 Sep 2018 11:36:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 12 Sep 2018 15:43:03 -0400 Tony Krowiak wrote: > From: Tony Krowiak > > Let's call PAPQ(ZAPQ) to zeroize a queue for each queue configured > for a mediated matrix device when it is released. > > Zeroizing a queue resets the queue, clears all pending > messages for the queue entries and disables adapter interruptions > associated with the queue. > > Signed-off-by: Tony Krowiak > Reviewed-by: Halil Pasic > Tested-by: Michael Mueller > Tested-by: Farhan Ali > Signed-off-by: Christian Borntraeger > --- > drivers/s390/crypto/vfio_ap_ops.c | 44 +++++++++++++++++++++++++++++++++++++ > 1 files changed, 44 insertions(+), 0 deletions(-) > > diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c > index f8b276a..48b1b78 100644 > --- a/drivers/s390/crypto/vfio_ap_ops.c > +++ b/drivers/s390/crypto/vfio_ap_ops.c > @@ -829,6 +829,49 @@ static int vfio_ap_mdev_group_notifier(struct notifier_block *nb, > return NOTIFY_OK; > } > > +static int vfio_ap_mdev_reset_queue(unsigned int apid, unsigned int apqi, > + unsigned int retry) > +{ > + struct ap_queue_status status; > + > + do { > + status = ap_zapq(AP_MKQID(apid, apqi)); > + switch (status.response_code) { > + case AP_RESPONSE_NORMAL: > + return 0; > + case AP_RESPONSE_RESET_IN_PROGRESS: > + case AP_RESPONSE_BUSY: > + msleep(20); > + break; > + default: > + /* things are really broken, give up */ > + return -EIO; > + } > + } while (retry--); > + > + return -EBUSY; So, this function may either return 0, -EIO (things are really broken), or -EBUSY (still busy after multiple tries)... > +} > + > +static int vfio_ap_mdev_reset_queues(struct mdev_device *mdev) > +{ > + int ret; > + int rc = 0; > + unsigned long apid, apqi; > + struct ap_matrix_mdev *matrix_mdev = mdev_get_drvdata(mdev); > + > + for_each_set_bit_inv(apid, matrix_mdev->matrix.apm, > + matrix_mdev->matrix.apm_max + 1) { > + for_each_set_bit_inv(apqi, matrix_mdev->matrix.aqm, > + matrix_mdev->matrix.aqm_max + 1) { > + ret = vfio_ap_mdev_reset_queue(apid, apqi, 1); > + if (ret) > + rc = ret; ...and here, we return the last error of any of the resets. Two questions: - Does it make sense to continue if we get -EIO? IOW, does "really broken" only refer to a certain tuple and other tuples still can/need to be reset? - Is the return code useful in any way, as we don't know which tuple it refers to? > + } > + } > + > + return rc; > +} > + > static int vfio_ap_mdev_open(struct mdev_device *mdev) > { > struct ap_matrix_mdev *matrix_mdev = mdev_get_drvdata(mdev); > @@ -859,6 +902,7 @@ static void vfio_ap_mdev_release(struct mdev_device *mdev) > if (matrix_mdev->kvm) > kvm_arch_crypto_clear_masks(matrix_mdev->kvm); > > + vfio_ap_mdev_reset_queues(mdev); > vfio_unregister_notifier(mdev_dev(mdev), VFIO_GROUP_NOTIFY, > &matrix_mdev->group_notifier); > matrix_mdev->kvm = NULL;