Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1774739imm; Thu, 12 Jul 2018 07:39:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe/Qqb7dsiVKxUdCVtpzklph7PlfbKcvZ4hv5VHC6pfQpV+EMHGqHJ4o9X2mEznLWoS8Oov X-Received: by 2002:a63:6c05:: with SMTP id h5-v6mr2378858pgc.367.1531406341884; Thu, 12 Jul 2018 07:39:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531406341; cv=none; d=google.com; s=arc-20160816; b=PrsrH20N3fIj41sz33v4hA1lWGES/oIkmIyJVJpgIsMd3qTm79+7ovH1JSxP9E4BOA o1/EU9hCrnAkuMWLbgTc9B+RL3HVZVCPBkJbzr5kgTo2+iOaR6fcOYgBO0qziI8zXlN2 Z5AjoxVecG9K1kF2McSM8uFVO0PWFrSD/ZtD1f5M/apzms+cX1koeDmj8udc+bnZnaAk vHfX6uI1ViXo3782o+u9aYMC1rJXkI8PE2ZJdDdJw85+15dUfT39EpxeZJvidw4Y0Rby oA4PKiTp/0tFPTSgsFcwZN60T98p7ktQ3DJoQXLZmOf64ji4GwQz8Njf60ZwNWujVAIW g7gw== 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-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :from:references:cc:to:subject:arc-authentication-results; bh=IiDsmYLW04XAEAc9QBUDRtu0N+o9fODF9+yfc/JuuTU=; b=OtcqYm3wdbfiDr8nXeMLfLDNTcxjuBGpjipnG4mR3bfFt+jJM+9xSnECDZ3LJrRDL0 FGPbUQKXowSAk4XH6k8f53Mr3Ay4KXeanN4QZvdxYzXIr7j4Ft4eI2FfiJ7RYiG74k+/ QlcZcXsBl4OY/mwbxThya4fG9h7M1ijMn7dxl9myDzmj1JJh3zB1VKOa25gSeOz/n/zd sVrhjntN/QCpdJnKduovpowws/Kk1+xhBvfCFUxiQ0qM7Iojykp83YsmccZ3KUpairrN /dx+KepVz65KzM4XgFFmeFIsJ58CqhHKK4kxXfME1hrYLRI2I/tANo+0TTWEHtopDhS3 2HVw== 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 k38-v6si21515163pgm.335.2018.07.12.07.38.45; Thu, 12 Jul 2018 07:39:01 -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 S1732578AbeGLOrQ (ORCPT + 99 others); Thu, 12 Jul 2018 10:47:16 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:58028 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732385AbeGLOrP (ORCPT ); Thu, 12 Jul 2018 10:47:15 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6CEYrGB058352 for ; Thu, 12 Jul 2018 10:37:24 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0b-001b2d01.pphosted.com with ESMTP id 2k66ft7ffk-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 12 Jul 2018 10:37:24 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Jul 2018 08:37:23 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e36.co.us.ibm.com (192.168.1.136) 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 08:37:19 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6CEbGJp12976498 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 12 Jul 2018 07:37:16 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A0F65C6059; Thu, 12 Jul 2018 08:37:16 -0600 (MDT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD982C6055; Thu, 12 Jul 2018 08:37:12 -0600 (MDT) Received: from oc8043147753.ibm.com (unknown [9.152.224.124]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 12 Jul 2018 08:37:12 -0600 (MDT) Subject: Re: [PATCH v6 15/21] s390: vfio-ap: configure the guest's AP matrix To: Halil Pasic , 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 References: <1530306683-7270-1-git-send-email-akrowiak@linux.vnet.ibm.com> <1530306683-7270-16-git-send-email-akrowiak@linux.vnet.ibm.com> From: Tony Krowiak Date: Thu, 12 Jul 2018 16:37:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18071214-0020-0000-0000-00000E3D0246 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009357; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01060298; UDB=6.00544246; IPR=6.00838216; MB=3.00022117; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-12 14:37:21 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18071214-0021-0000-0000-00006241CF1F Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-12_06:,, 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=983 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807120153 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/12/2018 03:28 PM, Halil Pasic wrote: > > > 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). I agree. > > > > Regards, > Halil > >> + mutex_unlock(&matrix_mdev->kvm->lock); >> +} >> +