Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp462581pxb; Wed, 18 Aug 2021 06:30:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQysNQ+3KdqlBSmA8LYukONMCcDochQdYaynoUMR8OQzpcB12Y8EtOnRLmlcOadXhKX4NQ X-Received: by 2002:a17:906:3745:: with SMTP id e5mr9780050ejc.400.1629293434147; Wed, 18 Aug 2021 06:30:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629293434; cv=none; d=google.com; s=arc-20160816; b=h7VT5ced1Iz0j5CUhGJqkTx8+9SKyg5KVy7cANWFdQbizSw/tu+k21M7g+XnjmoT2z CM4dD3AC8n2+XDjQGJ3CHYhUh2nZJQvavS0WOWeTwhgKS7EDZb4if/s9gXsmxocBkF0j 4WwN6ruJYnR50FfLUae4MCFCg0npvBA+RWML9fuVH7AM51iaT6yr4EsnAp+DAcTgkezc Je2FtrG6az4oTAO4rAtYtyMd0cNlOgxMWhuEsGq67lP9A7eieHPeZon52M8jAh0pZt8A NRIeodcz965ME3pEp7BCl+NGEL1vk4t7oSnOaD3QQx4uY/xt7fw0fbQ6dgSwCx10xB4L urTg== 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=KdeuplIWL0yvHPhuRCDrsa36wNsnUMau9TWkeKkHYU8=; b=qnDOJBf8QNc5xE4+ZU3QoFEjJF3VYH8zSgJJF3l2mlTlM6u6Lb0F2UBXmNq7zdbHR5 AfEsPWMJOpRiFvR1kmthzGKrOjTQXjv+a5zYkd8dQkBBFMtyKYm96Wt1jj56QpuOMWHy QCgVxIuAKK3lBe5LZfI+5PMk0Ot6+Ztjk5VD5cXd5PHUby6RxDPNvkC203m8wK/ko/9X irT7Q0J/psn75x3BcpURnswCDC2k1tJCKPj2Ti4k96z3Q9K4eXDRsntrcmuKPhv1rbK7 6uygw50Bf38AbYJfWQNTKda+hXy+r5xb+2u7ODFkbWzGtbRutz0LpyCeGd6IdSbvKgHR wtCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Bnm4H5RQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c6si5339057ede.289.2021.08.18.06.30.11; Wed, 18 Aug 2021 06:30:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Bnm4H5RQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238406AbhHRN2I (ORCPT + 99 others); Wed, 18 Aug 2021 09:28:08 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52918 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237204AbhHRN1J (ORCPT ); Wed, 18 Aug 2021 09:27:09 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 17ID3Uc5061051; Wed, 18 Aug 2021 09:26:35 -0400 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=KdeuplIWL0yvHPhuRCDrsa36wNsnUMau9TWkeKkHYU8=; b=Bnm4H5RQFeAfMZTpuvYDD4+BUSJWv3LnbJQIqPZuROAMdoFY5S0X0w/iiSY8LcZcuMHK 12vBt0Zn05mt6l7G0OPiA650iZPeecwZ9SCAOg69dLU1d0KVeGJPB0RPLMs2f7ahhB+I WhR5VLegFRhAzzNUExdIHq6k64btIG4Ae9GqvdHkpwwNr0wmxGp1B45BaRON9Haj42wW dKjvMQKMdgW7PugnFv2zjK/7Rj23qz73jNQKxSN33EHeA3xZZmPbWbXEnchamYuGTtCg ykfcaywbtrp0oSlbD2azzXF6jeeBYT51/bezhQ+u43O/ALZ3HejgsuexrMwUK9aRKmYt jQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3agcvs5e35-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Aug 2021 09:26:35 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 17ID3WMq061295; Wed, 18 Aug 2021 09:26:34 -0400 Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 3agcvs5e27-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Aug 2021 09:26:34 -0400 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 17IDCWhL013669; Wed, 18 Aug 2021 13:26:32 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma05fra.de.ibm.com with ESMTP id 3afwrhtehp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Aug 2021 13:26:32 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 17IDQRQa47382988 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Aug 2021 13:26:27 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C15D84C05A; Wed, 18 Aug 2021 13:26:27 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3DDBE4C04A; Wed, 18 Aug 2021 13:26:27 +0000 (GMT) Received: from p-imbrenda.bredband2.com (unknown [9.145.14.177]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 18 Aug 2021 13:26:27 +0000 (GMT) From: Claudio Imbrenda To: kvm@vger.kernel.org Cc: cohuck@redhat.com, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, david@redhat.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Ulrich.Weigand@de.ibm.com Subject: [PATCH v4 10/14] KVM: s390: pv: usage counter instead of flag Date: Wed, 18 Aug 2021 15:26:16 +0200 Message-Id: <20210818132620.46770-11-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210818132620.46770-1-imbrenda@linux.ibm.com> References: <20210818132620.46770-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: qrSPjza_ZCwLS8MZleOMMBK2SKl4bnGS X-Proofpoint-GUID: 15aZ8CguMVlm90cJWt_DrUI2kpIjcJeF X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-08-18_04:2021-08-17,2021-08-18 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 suspectscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108180082 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the is_protected field as a counter instead of a flag. This will be used in upcoming patches. Increment the counter when a secure configuration is created, and decrement it when it is destroyed. Previously the flag was set when the set secure parameters UVC was performed. Signed-off-by: Claudio Imbrenda Acked-by: Janosch Frank --- arch/s390/kvm/pv.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/s390/kvm/pv.c b/arch/s390/kvm/pv.c index 47db80003ea0..ee11ff6afc4f 100644 --- a/arch/s390/kvm/pv.c +++ b/arch/s390/kvm/pv.c @@ -173,7 +173,8 @@ int kvm_s390_pv_deinit_vm(struct kvm *kvm, u16 *rc, u16 *rrc) cc = uv_cmd_nodata(kvm_s390_pv_get_handle(kvm), UVC_CMD_DESTROY_SEC_CONF, rc, rrc); WRITE_ONCE(kvm->arch.gmap->guest_handle, 0); - atomic_set(&kvm->mm->context.is_protected, 0); + if (!cc) + atomic_dec(&kvm->mm->context.is_protected); KVM_UV_EVENT(kvm, 3, "PROTVIRT DESTROY VM: rc %x rrc %x", *rc, *rrc); WARN_ONCE(cc, "protvirt destroy vm failed rc %x rrc %x", *rc, *rrc); /* Intended memory leak on "impossible" error */ @@ -214,11 +215,14 @@ int kvm_s390_pv_init_vm(struct kvm *kvm, u16 *rc, u16 *rrc) /* Outputs */ kvm->arch.pv.handle = uvcb.guest_handle; + atomic_inc(&kvm->mm->context.is_protected); if (cc) { - if (uvcb.header.rc & UVC_RC_NEED_DESTROY) + if (uvcb.header.rc & UVC_RC_NEED_DESTROY) { kvm_s390_pv_deinit_vm(kvm, &dummy, &dummy); - else + } else { + atomic_dec(&kvm->mm->context.is_protected); kvm_s390_pv_dealloc_vm(kvm); + } return -EIO; } kvm->arch.gmap->guest_handle = uvcb.guest_handle; @@ -241,8 +245,6 @@ int kvm_s390_pv_set_sec_parms(struct kvm *kvm, void *hdr, u64 length, u16 *rc, *rrc = uvcb.header.rrc; KVM_UV_EVENT(kvm, 3, "PROTVIRT VM SET PARMS: rc %x rrc %x", *rc, *rrc); - if (!cc) - atomic_set(&kvm->mm->context.is_protected, 1); return cc ? -EINVAL : 0; } -- 2.31.1