Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8109530rwl; Tue, 10 Jan 2023 09:08:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXuAYQ4ML7Y7HM/8YbNkHp8Uy6Y4qr6RqO8IkAt7VjiQoYCELqvKG2XAhiuQNqofiu6sObCv X-Received: by 2002:a05:6402:b31:b0:497:948b:e8 with SMTP id bo17-20020a0564020b3100b00497948b00e8mr11718502edb.6.1673370523817; Tue, 10 Jan 2023 09:08:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673370523; cv=none; d=google.com; s=arc-20160816; b=qd8EtYT/xPXN4gegkTMf+MQX74AHdjik51S2v/kYufUC+BowPLHiFnSQux+Jg+0y1S gz1SrYZkYL1KAqPdwMOo73wb05O2uNr0fgQo/MC0x6Fq1r5EefZ9QGrM+DEnltNczkt8 kXC6q7ju+FchqZSVJLykMfgrldflMZW8ElGTbEG/py7PLN7O1TtDs+pM7QtlFxeCQFly vK63vNdMWJAemz24bZQ1d6eb/BuJcP2aUXsho46US3oeZrI69oo0bREjxop6D1GbFGgt TYKpTn8YpGLuBPLYA/+JAbm0bNfEH+b5o0/IUEV33az9It8rvtgKpkxYC5g/OB+F7vDd ZsZg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Mm7QiQfcrQlNd7aT1hRWE0ugWylBhxP28PV93dzYYoU=; b=D+LqNI2kuLV650Vz2uaKHL1Vy9+7FZ0gwIaedNucQDjCq13MjxIgZTKy6Ibk0dfSVH mBbEyHEkunV2Ud3EFk7oEfH2srw/GEI8bVLNZ27uLNkcqRKEfVgSHxKxbwYcOpWOw0zk lHi9cvQ2FZkHLrgPikioBgrbb9PrZwzpwdcb95gyUw7XR3k7Tr3kfyXBu8UpfUl1o4TU 1ARbhhkP+To1aEgo/mJ3XVD47aJ+cWfbyy8baXVdnMOHONJY9hW/AAHhvpHIADrN3GrC cdFJOQfZAAC79JvZRw7PiDB5EuedT8j3to4NMHerRHBck+zPuek+MmqfvcF0LrgKWMOY 58cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=EJZEVBUm; 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 o7-20020a056402038700b0049335011180si10350115edv.111.2023.01.10.09.08.31; Tue, 10 Jan 2023 09:08:43 -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=EJZEVBUm; 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 S230322AbjAJQon (ORCPT + 53 others); Tue, 10 Jan 2023 11:44:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233940AbjAJQof (ORCPT ); Tue, 10 Jan 2023 11:44:35 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA00A5133B; Tue, 10 Jan 2023 08:44:34 -0800 (PST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30AFsx4p008198; Tue, 10 Jan 2023 16:44:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=Mm7QiQfcrQlNd7aT1hRWE0ugWylBhxP28PV93dzYYoU=; b=EJZEVBUm3trPACAm/3U9Vs4ue8TxyysUTVDuTMAJsz6Kwhr2/8SDB5qkMu19nTNEdeqU w1eARs6n+m3us13rTe8ibxdsArVhEzSuFQ7MjUsswhsa6j9xa4IUYbg+EwtKN6A+7zfY qThSLI2Dbr7Y4iIKaOb9VPefpVBl2P7g8EgBsTImUhtnqm0xkahhF3J7PgxJsLQ5fQW2 YzlQ9kx9I8iWhgAZynsvtcaRp+KAI1CkXX3kQvbyHvvYpkFwzbq5YVFIbvtji7jbAbUa O8XadmLNIorzvtyHLkTNRkRso5u/z4dwP3Xjw6rNvd1v4wxQkJzGf52XNNYVnE+MmGGd OA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3n1b339dc2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Jan 2023 16:44:33 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 30AFu1Ft012082; Tue, 10 Jan 2023 16:44:33 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3n1b339dbj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Jan 2023 16:44:33 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30A83ahp014076; Tue, 10 Jan 2023 16:44:31 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3my00fn750-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Jan 2023 16:44:31 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30AGiRVM51511614 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Jan 2023 16:44:27 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC3D82004F; Tue, 10 Jan 2023 16:44:27 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EC0A20043; Tue, 10 Jan 2023 16:44:27 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 10 Jan 2023 16:44:27 +0000 (GMT) From: Niklas Schnelle To: Alex Williamson , Cornelia Huck Cc: Jason Gunthorpe , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, Matthew Rosato , Pierre Morel , =?UTF-8?q?Christian=20Borntr=C3=A4ger?= Subject: [PATCH v3 0/1] vfio/type1: Fix vfio-pci pass-through of ISM devices Date: Tue, 10 Jan 2023 17:44:26 +0100 Message-Id: <20230110164427.4051938-1-schnelle@linux.ibm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: hWDIigv2QrdBU7DJ_jTp_MdeZKvfnCnq X-Proofpoint-ORIG-GUID: qWBQ2p0Jec6qGatUywr1X1RA7NBi3YaU 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 adultscore=0 suspectscore=0 bulkscore=0 clxscore=1015 mlxscore=0 malwarescore=0 spamscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301100104 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,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 Hi Alex, This is v2 of my attempt of fixing an issue we have on s390 with vfio-pci pass-through of the s390 specific virtual PCI device called ISM and used for cross LPAR communication. As the patch tries to explain the fact that vfio_test_domain_fgsp() uses an IOMMU mapping at IOVA 0 irrespective of any reserved regions causes the ISM device to go into an error state and thus becomes unusable for a KVM guest breaking pass-through. I tried to improve the background and explanation compared to v1 hope its more clear now. As for testing, I tested this based on current master on both on s390 where it skips the reserved 0x0-0x100000000 range and on an AMD Ryzen 3990X where it continues to do the test on DMA address 0 and sets domain->fgsp to true. Thanks, Niklas Schnelle Changes since v2: - Don't require region->start to be aligned but instead just that we can fit an aligned allocation (Alex) - Use Fixes tag for the introduction of reserved regions as that came after the fine grained super pages test (Alex) Changes since v1: - Reworded commit message to hopefully explain things a bit better and highlight that usually just mapping but not issuing DMAs for IOVAs in a resverved region is harmless but still breaks things with ISM devices. - Added a check for PAGE_SIZE * 2 alignment (Jason) Niklas Schnelle (1): vfio/type1: Respect IOMMU reserved regions in vfio_test_domain_fgsp() drivers/vfio/vfio_iommu_type1.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) -- 2.34.1