From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71AE0C46467 for ; Tue, 10 Jan 2023 17:07:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234629AbjAJRHD (ORCPT ); Tue, 10 Jan 2023 12:07:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238817AbjAJRGz (ORCPT ); Tue, 10 Jan 2023 12:06:55 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAF8BBC2B; Tue, 10 Jan 2023 09:06:52 -0800 (PST) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30AGi0x5030801; Tue, 10 Jan 2023 17:06:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=JEZKDsHye+5DNZwvd4SgqJv6bDzIu4dPvAE9HnYNqTA=; b=XVuxvV/fSAs7q3f1RbDPpgTFJRSeK8DJfgGZOoH521ZBlywXTDRRHUozLrwVbFiI1ZZM Y0vK63JzDTd1MmHXkZo++Xh5NEasd0Q1kbCemJO5jA+Nd+rbNrihz89L5tlB33B6XoV5 Sk/EOauVxYfTTVAjyLFuB16MbACM5GcKKL8w06cjG53wzbpJSQqTJzlvHuA3Scargztx WGNzYhZtA4mlNTh25RglMVx8zZppr8PfOpviogBUKx4OqyZcjxTkWxFzh3mZXpuXvHot 55foCz8cAJIveA95i7ph4g0mBKt0dSwcdGQlW7zcsOMVi0Fy4YsJvv5c07cqQ6K3ian6 rg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n1bsyrju5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Jan 2023 17:06:51 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 30AGjA4G000557; Tue, 10 Jan 2023 17:06:51 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n1bsyrjtm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Jan 2023 17:06:51 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30AF0u9A029629; Tue, 10 Jan 2023 17:06:50 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([9.208.130.97]) by ppma03dal.us.ibm.com (PPS) with ESMTPS id 3my0c7qk21-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Jan 2023 17:06:50 +0000 Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30AH6nEr44696300 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Jan 2023 17:06:49 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F7B358058; Tue, 10 Jan 2023 17:06:49 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D78F5805D; Tue, 10 Jan 2023 17:06:48 +0000 (GMT) Received: from [9.60.89.243] (unknown [9.60.89.243]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 10 Jan 2023 17:06:47 +0000 (GMT) Message-ID: Date: Tue, 10 Jan 2023 12:06:47 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH v3 1/1] vfio/type1: Respect IOMMU reserved regions in vfio_test_domain_fgsp() To: Niklas Schnelle , Alex Williamson , Cornelia Huck Cc: Jason Gunthorpe , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, Pierre Morel , =?UTF-8?Q?Christian_Borntr=c3=a4ger?= References: <20230110164427.4051938-1-schnelle@linux.ibm.com> <20230110164427.4051938-2-schnelle@linux.ibm.com> Content-Language: en-US From: Matthew Rosato In-Reply-To: <20230110164427.4051938-2-schnelle@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: JWHntO9-_doEBCU1__hDZwU8bA9svm6- X-Proofpoint-ORIG-GUID: vMTb1Q7sOUbGAzmomPq14DrYSdMMqn1s 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-10_06,2023-01-10_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 suspectscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 spamscore=0 phishscore=0 adultscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301100104 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On 1/10/23 11:44 AM, Niklas Schnelle wrote: > Since commit cbf7827bc5dc ("iommu/s390: Fix potential s390_domain > aperture shrinking") the s390 IOMMU driver uses reserved regions for the > system provided DMA ranges of PCI devices. Previously it reduced the > size of the IOMMU aperture and checked it on each mapping operation. > On current machines the system denies use of DMA addresses below 2^32 for > all PCI devices. > > Usually mapping IOVAs in a reserved regions is harmless until a DMA > actually tries to utilize the mapping. However on s390 there is > a virtual PCI device called ISM which is implemented in firmware and > used for cross LPAR communication. Unlike real PCI devices this device > does not use the hardware IOMMU but inspects IOMMU translation tables > directly on IOTLB flush (s390 RPCIT instruction). If it detects IOVA > mappings outside the allowed ranges it goes into an error state. This > error state then causes the device to be unavailable to the KVM guest. > > Analysing this we found that vfio_test_domain_fgsp() maps 2 pages at DMA > address 0 irrespective of the IOMMUs reserved regions. Even if usually > harmless this seems wrong in the general case so instead go through the > freshly updated IOVA list and try to find a range that isn't reserved, > and fits 2 pages, is PAGE_SIZE * 2 aligned. If found use that for > testing for fine grained super pages. > > Fixes: af029169b8fd ("vfio/type1: Check reserved region conflict and update iova list") > Signed-off-by: Niklas Schnelle Looks good to me still (also re-tested ISM passthrough on s390). Thanks! Reviewed-by: Matthew Rosato