Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1701525imm; Thu, 12 Jul 2018 06:31:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdrWm2Fk6b7zC+i7Vzy7QzFZlOEsC32Nmc3GmbvkOX+ysyYa45RI9CGy5RvM4DNgPyBTUHA X-Received: by 2002:a17:902:205:: with SMTP id 5-v6mr2174764plc.301.1531402266936; Thu, 12 Jul 2018 06:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531402266; cv=none; d=google.com; s=arc-20160816; b=sFg2z3joET5CxatEPgaoRMMQ/uQWm9+5MxOvcdR4Whz+81QkzmlKvZKufuMD+I6fOW sK9x5kiDdUfWYzEx+8+/BzsFhjFtajxIxqhi9YNUZXwo7lgeIQhcQ/gciFvQV52cb3fV VuJHwaC+YlEZ8aHJupA3P69PQ3WGGF4dkJinWgSfOet/NjoKpsSzCL0gUvbYLrmW/URb taoXKCXe04wOd+k+RKnW2wu1yb2T8tm6yryfDZMh8xr1yqeOuJtBX1jqr+g6GEcemSIO Olyvs9CyUtpi5RwIaPaWHQbGw5hLNZM5y2SoWy+jb0xe5NSlps5vTW2C03W7S/v3ek2k KvKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date:from :references:cc:to:subject:arc-authentication-results; bh=aT0UoflaI3aOTVl8mpDUpUERy0fmrlLChbdp27vZoCM=; b=FmOglfc7/bRqIva9JGn0T8xtWOWpT6urg3uE2GpcHOKkGNJ4shTHFW8T4fXm1K/18/ KR6Hhhoyv67TWFwsQUSfqZFbxt1h3VWxhJhB+qvNpab9BQ4KbYkqzMoL2gJHtk4Cph76 1Y7FuA5c7NzqZzJaY4UobQ340cL64iD2nbMmhrntM7HN3OyL82cmH1JNYC5rlH24Am0R yEDwbAcx95JDwFfodiRL6W9xJjX+qeJVSmOGPEt5MToEfK6F1PGrmUY38W+cOumCJ2oU atVKxj0b7TLDJAE4luunAXYtv6YHBpXfynI8qWWq37LdimhSm+cpajut5C1fziRAno56 hv2g== 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9-v6si20140503pgl.568.2018.07.12.06.30.45; Thu, 12 Jul 2018 06:31:06 -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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727057AbeGLNi3 (ORCPT + 99 others); Thu, 12 Jul 2018 09:38:29 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40742 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726762AbeGLNi2 (ORCPT ); Thu, 12 Jul 2018 09:38:28 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6CDOSWc096688 for ; Thu, 12 Jul 2018 09:28:54 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2k66fjmf5m-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 12 Jul 2018 09:28:53 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Jul 2018 14:28:52 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 12 Jul 2018 14:28:48 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6CDSksr21495968 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 12 Jul 2018 13:28:46 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AFB5BA4057; Thu, 12 Jul 2018 16:29:07 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F2F50A404D; Thu, 12 Jul 2018 16:29:06 +0100 (BST) Received: from oc0155643701.ibm.com (unknown [9.152.224.111]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 12 Jul 2018 16:29:06 +0100 (BST) Subject: Re: [PATCH v6 15/21] s390: vfio-ap: configure the guest's AP matrix To: Tony Krowiak , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: freude@de.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, borntraeger@de.ibm.com, cohuck@redhat.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, Tony Krowiak References: <1530306683-7270-1-git-send-email-akrowiak@linux.vnet.ibm.com> <1530306683-7270-16-git-send-email-akrowiak@linux.vnet.ibm.com> From: Halil Pasic Date: Thu, 12 Jul 2018 15:28:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1530306683-7270-16-git-send-email-akrowiak@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 18071213-0012-0000-0000-0000028978BA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18071213-0013-0000-0000-000020BB20D4 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-12_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=927 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807120142 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/29/2018 11:11 PM, Tony Krowiak wrote: > From: Tony Krowiak > > Configures the AP adapters, usage domains and control domains for the [..] > +static inline void kvm_ap_clear_crycb_masks(struct ap_matrix_mdev *matrix_mdev) > +{ > + memset(&matrix_mdev->kvm->arch.crypto.crycb->apcb0, 0, > + sizeof(matrix_mdev->kvm->arch.crypto.crycb->apcb0)); > + memset(&matrix_mdev->kvm->arch.crypto.crycb->apcb1, 0, > + sizeof(matrix_mdev->kvm->arch.crypto.crycb->apcb1)); > +} > + > +static void kvm_ap_set_crycb_masks(struct ap_matrix_mdev *matrix_mdev) > +{ > + int nbytes; > + unsigned long *apm, *aqm, *adm; > + > + kvm_ap_clear_crycb_masks(matrix_mdev); > + > + apm = kvm_ap_get_crycb_apm(matrix_mdev); > + aqm = kvm_ap_get_crycb_aqm(matrix_mdev); > + adm = kvm_ap_get_crycb_adm(matrix_mdev); > + > + nbytes = KVM_AP_MASK_BYTES(matrix_mdev->matrix.apm_max + 1); > + memcpy(apm, matrix_mdev->matrix.apm, nbytes); > + > + nbytes = KVM_AP_MASK_BYTES(matrix_mdev->matrix.aqm_max + 1); > + memcpy(aqm, matrix_mdev->matrix.aqm, nbytes); > + > + /* > + * Merge the AQM and ADM since the ADM is a superset of the > + * AQM by agreed-upon convention. > + */ > + bitmap_or(adm, matrix_mdev->matrix.adm, matrix_mdev->matrix.aqm, > + matrix_mdev->matrix.adm_max + 1); > +} > + [..] > + > +static int kvm_ap_configure_matrix(struct ap_matrix_mdev *matrix_mdev) > +{ > + int ret = 0; > + > + mutex_lock(&matrix_mdev->kvm->lock); > + > + ret = kvm_ap_validate_queue_sharing(matrix_mdev); > + if (ret) > + goto done; > + > + kvm_ap_set_crycb_masks(matrix_mdev); > + > +done: > + mutex_unlock(&matrix_mdev->kvm->lock); > + > + return ret; > +} > + > +void kvm_ap_deconfigure_matrix(struct ap_matrix_mdev *matrix_mdev) > +{ > + mutex_lock(&matrix_mdev->kvm->lock); > + kvm_ap_clear_crycb_masks(matrix_mdev); The guest may be running at this point of time, or? I think you need our safe update operation that we used to use for the initial set too, but then somebody was like it ain't necessary because we don't support hotplug (yet). Regards, Halil > + mutex_unlock(&matrix_mdev->kvm->lock); > +} > +