Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp319313rdg; Thu, 12 Oct 2023 06:43:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEctMtaa35vGrC8evJUsakpfD5YjozMKS0At87nfWeLXPcULTwJMxUaBZts7jQmzjH5KtS1 X-Received: by 2002:a17:902:db0c:b0:1c9:e53b:7216 with SMTP id m12-20020a170902db0c00b001c9e53b7216mr1114490plx.43.1697118202204; Thu, 12 Oct 2023 06:43:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697118202; cv=none; d=google.com; s=arc-20160816; b=N2y1sG8jHclOQNttpou+nnbbDMgwpOt372UryufjbktZjE/VIX4QhTBtDuX/ZSIKV+ +IL6oH27Q6wScD/N1oe7SgXu3Lh03kIXydKV2tdcrmqPc4S7aWVJDLIoLWzngyB4ygy9 0+lmDCfTG968YB/V3nyLbVCfS510TeSCHzqa3YPNRS+1EkYUOHzA85ann03dTgVwJXNh ++dxWG+l5T2biQDYZd6/Iu4Uq7aIE9fF7glHBnb/ZtzxfhH7dcCijkWmQYvN5uCE4g0D MNVEAf74UmerodW2JZ+4RgEuR8C2XmaLqA9z/ClLe9MR5ov7E02wJc8mq4JwoBWhna9o AbtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MluVB4G/OSSjJ/0d/xLFgibgQBCCZLZ69FsduH+Fl7s=; fh=LhC5CLeotquy0uZQgO3iWx+MDADYBp/b6uwrtNzW/jI=; b=zBx8dEkJxsefqOnq9BgvnHZysPxx7bFbk4/onYMuyI2FpDDV9FAgU75GPZhKJWg6Ts TAjNDHQc0ydVq+IRv4TxI/HUg/V6mZvyR6bAFfNIvuQqIC0lPSdoZja/nc7HpqrvvTjN r9Be0u4UWN/f5Rqh6fsKk1CYCwFUzJa3Z9DIlEjxrIvRgIj42QQ8c21Yu3TRNyKxrXpr IW7paODwaXkuZ+KkifGxei8zZSFSfi236eg8b5seKNXcVRPK7ZtrOPLbe4PDmPWoA2Nk ujMkXPVJVs4VdKkvCgCkoQA2r6qncJM27/ITm1inggvQlSfIvuLoMubKDLjqvNg3X62j IXXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=ZmH0R9ul; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id h12-20020a170902748c00b001c9d358b3ccsi2132680pll.243.2023.10.12.06.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 06:43:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=ZmH0R9ul; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id EEE5F809FA71; Thu, 12 Oct 2023 06:43:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347166AbjJLNnO (ORCPT + 99 others); Thu, 12 Oct 2023 09:43:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233757AbjJLNnN (ORCPT ); Thu, 12 Oct 2023 09:43:13 -0400 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 329C591 for ; Thu, 12 Oct 2023 06:43:12 -0700 (PDT) Received: by mail-qt1-x836.google.com with SMTP id d75a77b69052e-41811e7ac3dso5789201cf.2 for ; Thu, 12 Oct 2023 06:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1697118191; x=1697722991; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=MluVB4G/OSSjJ/0d/xLFgibgQBCCZLZ69FsduH+Fl7s=; b=ZmH0R9ul7CeOHiByc5T+DmW7pX3ndWagE3zVRCuVEeYL4Wh+5sW5SHZUvQ+yCJAdBX 0cwuwElulLbDbKEWsm8kKd0JPmf8qc/nKPu1QPvMGvuFQX0qfpp5h0udpRZzLJzgScth H5LW9oHG/u2FRX80CuBwfo6HIo3h4ElKtrns47/jnxN1y9yqO9V3skDZQLhMTZrWkGke LrbhuX2hSUnGn9dOnFk7Jii4tvLVz2rPu/jY4AWsFLJSGkKdvhH4OkauHy7lDaBpu1NP gFvuwvA5pGVr0t27inoOZqxWg0oibvsvsQnXZnsbY+xaArUYXmBhYhiLbkhvH6u16crV 3bZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697118191; x=1697722991; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MluVB4G/OSSjJ/0d/xLFgibgQBCCZLZ69FsduH+Fl7s=; b=T2d0KjgFI3hl0y5g+7RvalWxhejMMYm9k3awGMxCWhEd1M3golOhydwTzuXKZkbPP3 0xSCzSb2Jjx34sbLmGIQ0nEgP4kFFpGYwKlslBJw0QkJ1sNMXLC4UfrjVT3IMC5CPzGW sDayzETqBT1pbFbbwSiPUoetFeR2PLgXTvWcKxUvDMRSKNoCgp+lBFYph64phjljEiEh JvtOaI/Q7uAbA8Qjv+PxjWovk8nqLQ52vlrS6aFoS55/AiMTPUU2kN0UoZCtDv7MP4uI 2dJlPKq02J3p6sBRmNrHhZTTp+UfjAS5rwf0BXC42c9x/G4RnlL9R1AYjs8r/MdkE6j/ wSEA== X-Gm-Message-State: AOJu0YwzQL8BjeXCXeNt1eq2qcpOi/kfbjPF4qOPTEehtN8npDUyKyD9 X/pt5LWRJO+jQqJ0Aglix2T7OQ== X-Received: by 2002:a05:622a:130b:b0:419:a2c6:8207 with SMTP id v11-20020a05622a130b00b00419a2c68207mr30087662qtk.22.1697118191240; Thu, 12 Oct 2023 06:43:11 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-26-201.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.26.201]) by smtp.gmail.com with ESMTPSA id f27-20020a05622a1a1b00b00419b5274381sm6198340qtb.94.2023.10.12.06.43.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 06:43:10 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1qqvy2-0018hm-48; Thu, 12 Oct 2023 10:43:10 -0300 Date: Thu, 12 Oct 2023 10:43:10 -0300 From: Jason Gunthorpe To: Tina Zhang Cc: Kevin Tian , Lu Baolu , Michael Shavit , Vasant Hegde , "Nicolin Chen ^C-cc=iommu @ lists . linux . dev" , linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 4/5] iommu: Support mm PASID 1:n with sva domains Message-ID: <20231012134310.GI55194@ziepe.ca> References: <20231012030112.82270-1-tina.zhang@intel.com> <20231012030112.82270-5-tina.zhang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231012030112.82270-5-tina.zhang@intel.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 12 Oct 2023 06:43:20 -0700 (PDT) On Thu, Oct 12, 2023 at 11:01:11AM +0800, Tina Zhang wrote: > @@ -1188,15 +1193,26 @@ static inline bool tegra_dev_iommu_get_stream_id(struct device *dev, u32 *stream > #ifdef CONFIG_IOMMU_SVA > static inline void mm_pasid_init(struct mm_struct *mm) > { > - mm->pasid = IOMMU_PASID_INVALID; > + /* > + * During dup_mm(), a new mm will be memcpy'd from an old one and that makes > + * the new mm and the old one point to a same iommu_mm instance. When either > + * one of the two mms gets released, the iommu_mm instance is freed, leaving > + * the other mm running into a use-after-free/double-free problem. To avoid > + * the problem, zeroing the iommu_mm pointer of a new mm is needed here. > + */ > + mm->iommu_mm = NULL; > } newlines after all the }, between functions doesn't checkpatch complain? IMHO this hunk should be moved to the prior patch. But it all looks good to me now Thanks, Jason