Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp13219536rwl; Wed, 4 Jan 2023 05:20:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXuzy3Ne9pXZRq+u+m88bsvbY/HbXfnp9qzahDd5wGRulWaOhk8jRUsenIWhGsTVqBh3nvmR X-Received: by 2002:a05:6402:538e:b0:48e:bf0d:f3a8 with SMTP id ew14-20020a056402538e00b0048ebf0df3a8mr5497575edb.38.1672838431831; Wed, 04 Jan 2023 05:20:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672838431; cv=none; d=google.com; s=arc-20160816; b=NH9zijjEP6IyR/EdpN9vrEZHHeorQAaQkYmuEan3FyXsyh/X/qvuS5WHMFk4bIhCwT gOZ4aDDr3YvfrtxdK06XJYesJpEiSOKYMqWlWqF42U4vtc8F0awfGNXGQeZHoWrTwag8 Ck69GXC1VTJAmYwQcgV32Nof30XbQYXPyzx611nlos3QKPUQkRzzksNiNBbrkAtfsvzO zLTcvEu1mtUZ2nAyCOrk1PnPH4S58xysy+OTVPMO3UW7qbYkoJPCcOJh+NnoGRQfO/Fl P2oeZX8/0uFtDzzKymxijZYFwe8mzRbCL3rW1QJk/lSy2LckGOwlBPbN5sHHoPh2ksgi DDgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=9rW9D4bKG1AYqSLVRir+QNP3LNiG0x+xb+IzrxVzjqc=; b=GSnqccFwTvy9Cyvw6zaSz8i+nkJeM5ncIyeH/3bfknHq0p3CPl5AIF+MTrVWyl/k7z HZ/vp7+3rE1QbYDVYsLYAR1k7ynfQ8kj5AX4jZavtwyPCivQ6FEoDZ4gvCtmylbQMsE9 fXvBBJyXcQg8hAAFospp3YxXTViCTiP7Rg9ZPTdCWj4u/ODSpHrZ1HWqQ9/DZDtCOVTH 28gmNoe6s2qtmDTe8LEA2Cqol4IWjoazQN3jkPvo90sNARzAlh2ZJ2gSRy7epwCMVxh3 uHcGO74Z0VcQ7TdmHNIbJ7p5FpRLcIxTdzgKKEnhDSWU9d7fGa3g/eO42AF0a9/miAMV s84Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=saSqHReT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s19-20020a056402521300b004855f09023csi26465073edd.231.2023.01.04.05.20.18; Wed, 04 Jan 2023 05:20:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=saSqHReT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239357AbjADNKt (ORCPT + 57 others); Wed, 4 Jan 2023 08:10:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239358AbjADNKZ (ORCPT ); Wed, 4 Jan 2023 08:10:25 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 889F93B921; Wed, 4 Jan 2023 05:08:51 -0800 (PST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 304BevXa002179; Wed, 4 Jan 2023 13:08:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=pp1; bh=9rW9D4bKG1AYqSLVRir+QNP3LNiG0x+xb+IzrxVzjqc=; b=saSqHReT18X5kzdwEgE80spO9akrd1tJRrXgWQI4xphg5AimHdAf5x1zmG1KMldl1X8f vO6+rgqQutKMOnzQYWZRQatdi/Xt8GgOaR/4rR1mJw1iS5DuHKzx+MFJoBJpw++D4WW9 mbYBRDsq+2dMo4ZN7/zFdqfbXGuY2vPTZif+CT2iFMeST4ggkUW2lkTRKN1fSsk6TFGj LYf8DcH/bfsoylgsOpNFDqrP1kmFMeU/lCOfeNxnN1miYNbVqAXxE/1DYtgENgRGDDYI OSnZg5oJQPieZisSnksKOYL2tHnlYuEMof7HRErPq+8BRGLM0vA0rVs68L9X6el+nyZ4 7Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mw83xat49-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Jan 2023 13:08:50 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 304Co51D033666; Wed, 4 Jan 2023 13:08:50 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mw83xat3r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Jan 2023 13:08:50 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 303J3anK006506; Wed, 4 Jan 2023 13:08:47 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma04fra.de.ibm.com (PPS) with ESMTPS id 3mtcq6bw32-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Jan 2023 13:08:47 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 304D8hpj46006752 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Jan 2023 13:08:44 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D6D3F20043; Wed, 4 Jan 2023 13:08:43 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 41CA520040; Wed, 4 Jan 2023 13:08:43 +0000 (GMT) Received: from [9.171.35.166] (unknown [9.171.35.166]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 4 Jan 2023 13:08:43 +0000 (GMT) Message-ID: Subject: Re: [PATCH 1/1] vfio/type1: Respect IOMMU reserved regions in vfio_test_domain_fgsp() From: Niklas Schnelle To: Jason Gunthorpe Cc: Alex Williamson , Cornelia Huck , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, Matthew Rosato , Pierre Morel , Christian =?ISO-8859-1?Q?Borntr=E4ger?= Date: Wed, 04 Jan 2023 14:08:42 +0100 In-Reply-To: References: <20230102093452.761185-1-schnelle@linux.ibm.com> <20230102093452.761185-2-schnelle@linux.ibm.com> <4e8d3f53af2f73a464e4ffc4a9a28c8d31692369.camel@linux.ibm.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.2 (3.46.2-1.fc37) MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: _OXaFNEQjnbWGa5dpbnehKOorelZPU2V X-Proofpoint-GUID: r_yVo2XLt-HKe7O2EE04fC2dJ0P9p6Lt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-04_07,2023-01-04_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 priorityscore=1501 suspectscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 mlxscore=0 mlxlogscore=724 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301040110 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2023-01-04 at 08:16 -0400, Jason Gunthorpe wrote: > On Wed, Jan 04, 2023 at 10:52:55AM +0100, Niklas Schnelle wrote: >=20 > > The problem manifests only with ISM devices which are a special s390 > > virtual PCI device that is implemented in the machine hypervisor. This > > device is used for high speed cross-LPAR (Logical Partition) > > communication, basically it allows two LPARs that previously exchanged > > an authentication token to memcpy between their partitioned memory > > using the virtual device. For copying a receiving LPAR will IOMMU map a > > region of memory for the ISM device that it will allow DMAing into > > (memcpy by the hypervisor). All other regions remain unmapped and thus > > inaccessible. In preparation the device emulation in the machine > > hypervisor intercepts the IOTLB flush and looks at the IOMMU > > translation tables performing e.g. size and alignment checks I presume, > > one of these checks against the start/end DMA boundaries. This check > > fails which leads to the virtual ISM device being put into an error > > state. Being in an error state it then fails to be initialized by the > > guest driver later on. >=20 > You could rephrase this as saying that the S390 map operation doesn't > check for bounds so mapping in a reserved region doesn't fail, but > errors the HW. >=20 > Which seems reasonable to me >=20 > Jason Kind of yes, before the recent IOMMU changes the IOMMU code did check on map failing early but now handles the limits via reserved regions. The IOMMU hardware would only check the limits once an actual DMA uses them but of course no DMA will be triggered for this test mapping. For this specific virtual device though there is an extra check as part of an intercepted IOTLB flush (RPCIT instruction in S390).