Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4237637pxb; Tue, 2 Mar 2021 09:54:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwYqcbzI8Otz90KXZmI4j0/NUUPLiZzBKIjgdZ+SMwDqN+LDYn0+ycDxC5a+DecrxnO/9YY X-Received: by 2002:a17:906:12d2:: with SMTP id l18mr21358330ejb.308.1614707662423; Tue, 02 Mar 2021 09:54:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614707662; cv=none; d=google.com; s=arc-20160816; b=vk/26WDsfkuadRVgc/nDyadk/irNcubq+Gcu38zAEUT5XVg+CXqTq86PM4ScFTcP2K 1Ik4lCfzVyNaSkVbVzyZwfLKoBrIhcddkDKIPMKW2W8En685+bV7J1ZxlUgWf5pwUD98 6Pa3DZHiFh13cKYLKZY8SBDs7zm/O/juFodx4mvIgUSDhlXYAKsJxUqXKe3YDo6a86xP LInnpUeC4gATJA8fiwdOIqbl5pub94bDHT0R4tQXT5T8rBM5vJ/ZmkVgwThAmFMbguou RF7HVC+tIpe12dmgbh2Abtn6Y03T9dIn0b2g/FnA+YqqJPkUEKNlsn8OTtpPJVN2Y7uK hrgA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:ironport-sdr:ironport-sdr; bh=KewXe3Vd0QbWQ6O1jNty2kZjLjnvXrhca0GRAaX9+bg=; b=l3qiDs6LD4qYpLBtvvnHO1g+XoD4wE3bQ+UM/hoEOCCvhWSIe6VQnWmhYScS89aS1c 7ZnyJxQB5UzsKM7j2JOVx7UqTZJvsuTVULBk+PpNiYXDZtu8gjs3wyxGUaHF48JFyE5q JDTWiMXBYKB4/DiErCNXJ3up7PRjNVfOHi9daqgXAS594Uz37d51cI+SDIIlYJTEk5ox QB6Q9FgODW80LzhyQwxACgPmqn/tBjXkc48UuuN2Uy8pL5qI24oWb9geTr46xVtGYQ09 CorHsGnYp97szpKYWV+D6b93OIvGhdLUZTAVRvBEwXuO/PYx7iRagp7aZRO4g8k2zDnU D62A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l1si12968578ejb.137.2021.03.02.09.53.58; Tue, 02 Mar 2021 09:54:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1575506AbhCBD42 (ORCPT + 99 others); Mon, 1 Mar 2021 22:56:28 -0500 Received: from mga07.intel.com ([134.134.136.100]:52009 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241841AbhCAW7U (ORCPT ); Mon, 1 Mar 2021 17:59:20 -0500 IronPort-SDR: IBfFtAt6njIT235hj8F62Gx16GCujXyz62MgZ/ThCFZ0BxS6raO2eTFkkGvUUaovHU/4se27DI 4UmHfG4WqTqQ== X-IronPort-AV: E=McAfee;i="6000,8403,9910"; a="250671443" X-IronPort-AV: E=Sophos;i="5.81,216,1610438400"; d="scan'208";a="250671443" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2021 14:57:57 -0800 IronPort-SDR: tJve8x1cqIyj1Zp29MjKeC6e8QzZkBYQiEg5LY5/Q2mEq6QeMUgOU1orgYtb4aPV0pYaO/g7ns twgRDb4Xl6sA== X-IronPort-AV: E=Sophos;i="5.81,216,1610438400"; d="scan'208";a="368758360" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2021 14:57:57 -0800 Date: Mon, 1 Mar 2021 15:00:11 -0800 From: Jacob Pan To: Fenghua Yu Cc: Jean-Philippe Brucker , Joerg Roedel , Lu Baolu , Ashok Raj , linux-kernel , , , , jacob.jun.pan@intel.com Subject: Re: [PATCH v6 08/12] fork: Clear PASID for new mm Message-ID: <20210301150011.766e70a3@jacob-builder> In-Reply-To: References: <1594684087-61184-1-git-send-email-fenghua.yu@intel.com> <1594684087-61184-9-git-send-email-fenghua.yu@intel.com> Organization: OTC X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Fenghua, On Thu, 25 Feb 2021 22:17:11 +0000, Fenghua Yu wrote: > Hi, Jean, > > On Wed, Feb 24, 2021 at 11:19:27AM +0100, Jean-Philippe Brucker wrote: > > Hi Fenghua, > > > > [Trimmed the Cc list] > > > > On Mon, Jul 13, 2020 at 04:48:03PM -0700, Fenghua Yu wrote: > > > When a new mm is created, its PASID should be cleared, i.e. the PASID > > > is initialized to its init state 0 on both ARM and X86. > > > > I just noticed this patch was dropped in v7, and am wondering whether we > > could still upstream it. Does x86 need a child with a new address space > > (!CLONE_VM) to inherit the PASID of the parent? That doesn't make much > > sense with regard to IOMMU structures - same PASID indexing multiple > > PGDs? > > You are right: x86 should clear mm->pasid when a new mm is created. > This patch somehow is losted:( > > > > > Currently iommu_sva_alloc_pasid() assumes mm->pasid is always > > initialized to 0 and fails on forked tasks. I'm trying to figure out > > how to fix this. Could we clear the pasid on fork or does it break the > > x86 model? > > x86 calls ioasid_alloc() instead of iommu_sva_alloc_pasid(). So We should consolidate at some point, there is no need to store pasid in two places. > functionality is not a problem without this patch on x86. But I think I feel the reason that x86 doesn't care is that mm->pasid is not used unless bind_mm is called. For the fork children even mm->pasid is non-zero, it has no effect since it is not loaded onto MSRs. Perhaps you could also add a check or WARN_ON(!mm->pasid) in load_pasid()? > we do need to have this patch in the kernel because PASID is per addr > space and two addr spaces shouldn't have the same PASID. > Agreed. > Who will accept this patch? > > Thanks. > > -Fenghua Thanks, Jacob