From patchwork Wed Nov 16 17:16:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Schnelle X-Patchwork-Id: 21199 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp263618wru; Wed, 16 Nov 2022 09:27:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf4jT0jW0psU5+cRtMqSO3kf3m6g4sm0HX51okr+MZ0cOC1TqTSpH9732Pkl5CzMltnyd/DA X-Received: by 2002:a63:1802:0:b0:476:d22c:bdf7 with SMTP id y2-20020a631802000000b00476d22cbdf7mr6100609pgl.279.1668619656586; Wed, 16 Nov 2022 09:27:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668619656; cv=none; d=google.com; s=arc-20160816; b=gnN1FKbYzZPK1aaX5CvxiyGY1OnVCFWNxm7zPlGNOnGxpaN7vJ9LnSQetf3nK0P1uR X4BN8Nnu++3aJG9WCBgPMxbLz00GchWeHkxosUCu0akcZrbYPQKDGnvVSNx68WEugGmt MY0GV6Nma8XvkEnyiccvdB5clnsHt+xZiJUoCHJL1GuyvdHmgTC6d3wOT0G8Wwvdm+3M pcRp4hgtI5c4ZcbT6XFJEAxQtl548H1s71Q+p79GhKq35zFX4+drVxjpAHVb/2ljmTN1 TXeGpooiifaUTgjOD8N2gpgPbURvcX2eMqvwbFYT5F2wWx7jgKwQ5WX3wQ7COrZ8SnnN cMHg== 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=DesZm6hVauGJ5jEKwYVVgM1CsFnIzR6FUV6dd8h3oPU=; b=BFmi6kFgKnW8kGeIckzRdWTteFxFgHK1fy7G3qzhhFZ7bfInRLdJE7iQ+Q78Tw62wB lb/wAehN2Ao1tPzwagCzt5Ccncdemnhvy+zMKqF70Kf1bIqbUnQbr6YwEQqy95Hp5iXd Feeq95WWcos8Ry7RqTgAGsLoG3B2ag8hkTDerd5Z+sLFXE0lJW7SUQwHZFmvI22JU1jT 1WapwQrkDjactMkrW99hCVaAjisHZeDoeWWW3/zOgygCW+IYKisc5LPfOkCbLJnkkOEZ 60OpJj7UtKnBskhKILGs0nuQ8aJv2SpOOcVod0YzlBko52Fx5pefNXubfTkj7BTsO2gS n05A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="Opmw8G/V"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q19-20020a056a00089300b00562331a3562si16917936pfj.130.2022.11.16.09.27.23; Wed, 16 Nov 2022 09:27:36 -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="Opmw8G/V"; 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 S233605AbiKPRRU (ORCPT + 99 others); Wed, 16 Nov 2022 12:17:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbiKPRRT (ORCPT ); Wed, 16 Nov 2022 12:17:19 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE50E4731C; Wed, 16 Nov 2022 09:17:18 -0800 (PST) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AGHDJHH005207; Wed, 16 Nov 2022 17:17:05 GMT 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=DesZm6hVauGJ5jEKwYVVgM1CsFnIzR6FUV6dd8h3oPU=; b=Opmw8G/V3dRoyOOSGVdh+czxS74TKiVkIlbiAvymk1v5SGU2j7vxqY9dw7z8eA5cEo/l LFJXRolPGu46ib3tkLFCCAhkjCghXY7YryLjWADW4te3jHsOme0M9Y1hxEV7BGXtIQ2l N91Qs6PqvlYi2bLUud6/3HufTLz9crz+rJ9FMnePH5QIwI/N2VF0qeu5I79h8Fyd9Rnt JJTnGAjotrOcuCPcQ8IJ2n/1zc17QWHimsFEtqjigSVjzcu+Y/MXKOXQVrRfJ2rluM53 5to8DBwGv4zJXk7FoKRcFhG3eW5/DqbC4sk/YfyT+QUJUv9xPd6lTRmTmiYOP/kbw1XJ XQ== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kw3qe8say-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Nov 2022 17:17:04 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AGH5llf024480; Wed, 16 Nov 2022 17:17:02 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04ams.nl.ibm.com with ESMTP id 3kt348x9jy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Nov 2022 17:17:02 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AGHGxwi38928914 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 17:16:59 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 41D3F5204F; Wed, 16 Nov 2022 17:16:59 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id AC39452054; Wed, 16 Nov 2022 17:16:58 +0000 (GMT) From: Niklas Schnelle To: Matthew Rosato , Gerd Bayer , iommu@lists.linux.dev, Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Wenjia Zhang Cc: Pierre Morel , linux-s390@vger.kernel.org, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, linux-kernel@vger.kernel.org, Julian Ruess Subject: [PATCH v2 4/7] iommu: Let iommu.strict override ops->def_domain_type Date: Wed, 16 Nov 2022 18:16:53 +0100 Message-Id: <20221116171656.4128212-5-schnelle@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221116171656.4128212-1-schnelle@linux.ibm.com> References: <20221116171656.4128212-1-schnelle@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Gop84IsW_vCOuB5QmJucy4dagLgXcyIS X-Proofpoint-GUID: Gop84IsW_vCOuB5QmJucy4dagLgXcyIS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-16_03,2022-11-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 impostorscore=0 phishscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211160119 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749674524708715786?= X-GMAIL-MSGID: =?utf-8?q?1749674524708715786?= When iommu.strict=1 is set or iommu_set_dma_strict() was called we should use IOMMU_DOMAIN_DMA irrespective of ops->def_domain_type. Signed-off-by: Niklas Schnelle --- drivers/iommu/iommu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 65a3b3d886dc..d9bf94d198df 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1562,6 +1562,9 @@ static int iommu_get_def_domain_type(struct device *dev) { const struct iommu_ops *ops = dev_iommu_ops(dev); + if (iommu_dma_strict) + return IOMMU_DOMAIN_DMA; + if (dev_is_pci(dev) && to_pci_dev(dev)->untrusted) return IOMMU_DOMAIN_DMA;