Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4672466pxj; Tue, 25 May 2021 13:33:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaebClW0su0RpUh43TY08Q8oMAzeimMTOifgbxCG7vqrfe3UNnReIjw+cIBVXAvOWNBJri X-Received: by 2002:a6b:7d03:: with SMTP id c3mr23525101ioq.2.1621974830219; Tue, 25 May 2021 13:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621974830; cv=none; d=google.com; s=arc-20160816; b=EBCsGDSEzjSeJ74NQZNc9LdH6NCVOBAfvwrCg7h/bwWGqw6bbnhMwSfz+wDdliogoK pdw8+Vc06rag1s9BG9U6tMBWMu+3f7L53KHn34GshcTW0ojRvb+EjX0zwNFL3W3tTR1c AIm+hQ1xgaAbY1EC+qK0L0l64efH4zYeANhlWYsR0MnGlHytYYJOI7z2BsOlBEiOLrjv sbIpbqGKbMQJwNSPxydDe3Y+KsWFzJWVLXsqxD1lok0s1ltmPXTHKyRIJytCG3U3vl+A BAb+y/n1vtkiCZS+5pgnwiUz0VqTkW4npG2LrrKiGFejIx4wsax0s7CTsFwIe4CaMWt+ lEfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=qRLgRSBBx/nSGA2WNSV/2YEj8rZP4C8EO+a+X5TvN9s=; b=We70djc2+x002SFPYySVkGrQNw480JRAV1OGFhLoLZMltYCrHeXEK4/tLYq+gK9gVD sQiE27VnpS1KOJQFXX8RCsjEamz40f55eveJRo5V1QSbRbExPMyERp8OHgUOduG9PZbz goz28u/sz/uPWLP30Fm3CVgKziolWnHBHpgU4ItHEUJH4+gtZhqMpxq7Yey6FjMNJUZQ fYsLQma1Ie1LSlU8Zc8Lwc7gtXrQaMmivxHcPxSgw8Y1mMTueW19pZ63bssDlLmPqv9d coZSPbVsnvfzdAtThExr7rAH7BBSVo5ttD1WOx3utPNV1MZzz+aT9osdQ01n31VbdKgY zVoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=cmKWne6c; 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 g15si18091727iln.71.2021.05.25.13.33.36; Tue, 25 May 2021 13:33:50 -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=cmKWne6c; 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 S230054AbhEYPKE (ORCPT + 99 others); Tue, 25 May 2021 11:10:04 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:11672 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229685AbhEYPJ7 (ORCPT ); Tue, 25 May 2021 11:09:59 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14PF4LSY013672; Tue, 25 May 2021 11:08:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=qRLgRSBBx/nSGA2WNSV/2YEj8rZP4C8EO+a+X5TvN9s=; b=cmKWne6cKQR3346roL5fqGZ3c+rVgaRanUI4MWXMauWCnG2J4hhSukIUUwOsTVe5/+Fc qd0ef53PDjdiybN9m/fj8M7N4nl+cKqIQPOkGKuPiAJKYD/WTMSZlPk2s5AFIUXYgmEO P8SfJpAiqct6XoHRu5+OQAxElDegnICVjx46Tmw8gs2gwesRP6sgSQEqzj5l7mxSisZo V86uKEfuKntnBizk3v7DISXFs4CUDRayY3jFaWSY0QT9uR3xPxRg3dywYMISw+eOQ6jg awypFLHFg4EPP/agrCFtc/AezBHhPKUfpPdG6lfHQQ0FNSMn6YRo7lP7rRV+Orm/hk9e 1Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 38s3ja88xy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 May 2021 11:08:27 -0400 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 14PF4TPh014519; Tue, 25 May 2021 11:08:27 -0400 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0b-001b2d01.pphosted.com with ESMTP id 38s3ja88wn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 May 2021 11:08:26 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 14PF49x7027031; Tue, 25 May 2021 15:08:25 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma03wdc.us.ibm.com with ESMTP id 38s1qd0yw2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 May 2021 15:08:25 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 14PF8Oov27984154 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 May 2021 15:08:24 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8916613604F; Tue, 25 May 2021 15:08:24 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 623EF13605D; Tue, 25 May 2021 15:08:23 +0000 (GMT) Received: from cpe-172-100-179-72.stny.res.rr.com (unknown [9.85.177.219]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 25 May 2021 15:08:23 +0000 (GMT) Subject: Re: [PATCH v4 2/2] s390/vfio-ap: control access to PQAP(AQIC) interception handler To: Jason Gunthorpe Cc: jjherne@linux.ibm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, borntraeger@de.ibm.com, cohuck@redhat.com, pasic@linux.vnet.ibm.com, alex.williamson@redhat.com, kwankhede@nvidia.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, hca@linux.ibm.com References: <20210521193648.940864-1-akrowiak@linux.ibm.com> <20210521193648.940864-3-akrowiak@linux.ibm.com> <5d15fdf2-aee8-4e6c-c3e1-f07c76ce5974@linux.ibm.com> <20210525131912.GW1002214@nvidia.com> From: Tony Krowiak Message-ID: <6542986f-b20e-3f41-b96c-70f0ce42af2d@linux.ibm.com> Date: Tue, 25 May 2021 11:08:22 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210525131912.GW1002214@nvidia.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: RzmDespSX7uDTLuxpy86PIMrhSf-_JWy X-Proofpoint-GUID: cpYkhIxpjJys3-oaXi3DyEEXFQtvxcAv X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-05-25_07:2021-05-25,2021-05-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 clxscore=1015 malwarescore=0 bulkscore=0 mlxscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105250092 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/25/21 9:19 AM, Jason Gunthorpe wrote: > On Tue, May 25, 2021 at 09:16:30AM -0400, Tony Krowiak wrote: >> >> On 5/24/21 10:37 AM, Jason J. Herne wrote: >>> On 5/21/21 3:36 PM, Tony Krowiak wrote: >>>> The function pointer to the handler that processes interception of the >>>> PQAP instruction is contained in the mdev. If the mdev is removed and >>>> its storage de-allocated during the processing of the PQAP instruction, >>>> the function pointer could get wiped out before the function is called >>>> because there is currently nothing that controls access to it. >>>> >>>> This patch introduces two new functions: >>>> * The kvm_arch_crypto_register_hook() function registers a function >>>> pointer >>>>    for processing intercepted crypto instructions. >>>> * The kvm_arch_crypto_register_hook() function un-registers a function >>>>    pointer that was previously registered. >>> Typo: You meant kvm_arch_crypto_UNregister_hook() in the second bullet. >>> >>> >>> Just one overall observation on this one. The whole hook system seems >>> kind of over-engineered if this is our only use for it. It looks like a >>> kvm_s390_crypto_hook is meant to link a specific module with a function >>> pointer. Do we really need this concept? >>> >>> I think a simpler design could be to just place a mutex and a function >>> pointer in the kvm_s390_crypto struct. Then you can grab the mutex in >>> vfio_ap_ops.c when registering/unregistering. You would also grab the >>> mutex in priv.c when calling the function pointer. What I am suggesting >>> is essentially the exact same scheme you have implemented here, but >>> simpler and with less infrastructure. >> That would be great, however; when I implemented something similar, it >> resulted in a >> lockdep splat between the lock used to protect the hook and the >> matrix_dev->lock used to >> protect updates to matrix_mdev (including the freeing thereof). After >> pulling what little hair >> I have left out, this seemed like a reasonable solution, over-engineered >> though it may be. >> If somebody has a simpler solution, I'm all ears. > Why can't you put the locks in the right order? It looked trivial, I'm confused. Because the handle_pqap() function in priv.c does not have access to the matrix_dev lock. > > Jason