Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1064752pxj; Tue, 18 May 2021 20:52:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKNvIFjqY/C5XS79g++9ls4xp3/HMXB2uzZA+bDiAyVAa+Apq3L2qooFHgGSOoZxvGgbpy X-Received: by 2002:a50:ab52:: with SMTP id t18mr11654833edc.188.1621396373977; Tue, 18 May 2021 20:52:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621396373; cv=none; d=google.com; s=arc-20160816; b=JVnGmAKVrhZpbYUVh75jYQrAVHkgfUrnU+TBm5TqA+qI7cCdeI43tta1ieTzDbOeZx TP2kV/mjdETH6tg4xA5LIIGwv/keMF5nWt06sVA5RRoSSFurFsF7ssFlk5f2nN/1a6Ze wXkqDp2tweqT6GAv43uXdiraOp0c3sHrcpP8KvHjQ9rBe0/XsZwJzQRZlTMXqn2mJ3wV eQ4+yQs1VjNn8Emk/+rYTuu68Jh09RJmqeQjF/mRHHTHFdQqvZZNLrczPdaX0li/9DHn RieGZj+GpoPRCTkDoCZAy+FRgR78SHoXb+R93pM+wucSCof08lb+/dqiEhPC+hsyZFfK n5LA== 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=yVUetkYEiFWNQbksMN2LECKU8E/3DZW0wv9MrLiGJjw=; b=hdG+tVo66SUTKSBDeeWMEMjWvE9QV5/Fw0Z3Uvu1OWiQp/ht90t8qOI9o4Xw5ilCYr m+SnQj1roUjlYeOFkKUxqoG0XePIzI93xSqSwGdTFs4HnJMW3EHDHnPvcTvuZA7+6/Xd Y+RWmQZS/6GW7xhCqAnocl5X+UAKmfj09FE5InSvca3FZmJNbjYPNmRhtFJXpKpESJO9 YOvaz1gxDIEFsNvQDkrJohZo7srdu/SAaunZVAvgEAqTKi1ykAcLjhYVxMkPr1cMBcRU 4jBRs5CtQzZiK0xNqoxRacjPKTSNADxdZ/UI6xpmZiqL74QY4J+M95v8RlGtgtCksufd rKSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=n0HWRM77; 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 s19si5529751edd.347.2021.05.18.20.52.31; Tue, 18 May 2021 20:52:53 -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=n0HWRM77; 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 S237812AbhEQUJm (ORCPT + 99 others); Mon, 17 May 2021 16:09:42 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39698 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237721AbhEQUJZ (ORCPT ); Mon, 17 May 2021 16:09:25 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14HK3d07196371; Mon, 17 May 2021 16:08:08 -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=yVUetkYEiFWNQbksMN2LECKU8E/3DZW0wv9MrLiGJjw=; b=n0HWRM774Gq5DtLOMIW56Z4nex7EiS32VCj6ZVvabPKdZLQhC3kW+lRgZGLvYl41g8VM tLZqTetrbp/Ng2o11myH4oIaW7fQKFtwJ5Ynb/zdsdhnI7CoDYWducCrY0t2swkvXvOl 8wKhUHwFURtIdP9fLmX7PcsdSSUDk8wjdlGZNUK1c3ACZVCJRxe3DN6cDH0kPc+KSxs6 /E3lVAk3LJwmvoVLruC9yuVcwSokPIohJ5cfBRmCbRTU2TAcZdHeL+j6f06uYHcEvKys L5JA2WbEa8eAMrQycqkLunf0SyOWfWqIUn8/ZKSNIvG/JuwDQYrUs+Cy4ZL6T4+y8elA rA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 38kxwgrgyd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 May 2021 16:08:08 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 14HK4rbk007214; Mon, 17 May 2021 16:08:08 -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 38kxwgrgxb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 May 2021 16:08:07 -0400 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 14HK7VS7017865; Mon, 17 May 2021 20:08:05 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma05fra.de.ibm.com with ESMTP id 38j5x8gkb0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 May 2021 20:08:05 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 14HK82Ps26018058 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 May 2021 20:08:02 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 19FAA52051; Mon, 17 May 2021 20:08:02 +0000 (GMT) Received: from ibm-vm.ibmuc.com (unknown [9.145.14.34]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id A7B1F52059; Mon, 17 May 2021 20:08:01 +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 Subject: [PATCH v1 06/11] KVM: s390: pv: usage counter instead of flag Date: Mon, 17 May 2021 22:07:53 +0200 Message-Id: <20210517200758.22593-7-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517200758.22593-1-imbrenda@linux.ibm.com> References: <20210517200758.22593-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: xOdjBrgt5lN6fgIHz64jzLF8Z6mjmVfK X-Proofpoint-ORIG-GUID: bfTr9DfDO-Bu2sDmnuGPzZ_IJmNgYIM0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-05-17_08:2021-05-17,2021-05-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 priorityscore=1501 bulkscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105170140 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 --- 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 c3f9f30d2ed4..59039b8a7be7 100644 --- a/arch/s390/kvm/pv.c +++ b/arch/s390/kvm/pv.c @@ -218,7 +218,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 */ @@ -259,11 +260,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; @@ -286,8 +290,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