Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp297247pxb; Wed, 24 Feb 2021 02:22:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyud/gN7i8rPcETacffLOyzlSGCoVurry4kAVB3N7hS0He2FUhLjzPz+6ESeLEG2TNGbqBj X-Received: by 2002:aa7:cd94:: with SMTP id x20mr12834283edv.53.1614162134957; Wed, 24 Feb 2021 02:22:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614162134; cv=none; d=google.com; s=arc-20160816; b=YPsOUVW17zugfldmWtL3l1dieKKn+atbRPSvDfQWd+ceCrK9xq3A2ijQRiV3vGd7qC kJ5p2ygE+Bn8KFMRNRCHhoHe3ZIJKlo0OuQz2y9gIrOhEgnvuExcU3+OarwwKF4EogDp 9wMLjNKmj/rMhv9XFPKhu7HK+3A606zjR4rdrWAzw7li+5y27OpH6iXxxwOMW2xj72JO at81dvG/tYVtWPOWL+c7cccCdopzbN1KBgGMB5arw+EicljOilXgvt+QeaPD+oXBVa8b t9bSD671rLOT75o8xrPCzDtIGEJ70k17k4GqUF60m+z3uI4zdG0Z7D/076K5ZiorkF0d gIwA== 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=/FE7tvrvqoJrGxZtO1M2WLOCJzVWjV9STY44PZX27ks=; b=wTI3P5BMAruYqfROnywASi0tzFLB3LpqXA4hIxbLQjSarea2d8T7FVPheKWtfLAWGH hFJL+K8DvlZGUvq+4K7LE/iHYIL28K06D0BaQ3D7z8QeTMlN5XOCMym3uFCQENGZZZBj 4raz0U46oT6JDGu1Weu7jummj3y9HHJiEwugdaA7xpn5llZrjDt7Lhnr0+PE32RAWWfH JYSat9ge/zkOygJFM0Vp6+s+kll7MfVqYgswZ1bzFrQu2TPs+3+kMXD8KCLS2Moo+437 6DtUP+Iv2Tv5ZqLNy4xdMxdIBIhDc6K0giBenNatpSJNVWlOyzPG6jRBYnHk6leNx7Dx HKhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I+hKBBRh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si887337edy.117.2021.02.24.02.21.45; Wed, 24 Feb 2021 02:22:14 -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; dkim=pass header.i=@linaro.org header.s=google header.b=I+hKBBRh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234735AbhBXKUe (ORCPT + 99 others); Wed, 24 Feb 2021 05:20:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232560AbhBXKU3 (ORCPT ); Wed, 24 Feb 2021 05:20:29 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78615C061574 for ; Wed, 24 Feb 2021 02:19:47 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id d11so1323681wrj.7 for ; Wed, 24 Feb 2021 02:19:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/FE7tvrvqoJrGxZtO1M2WLOCJzVWjV9STY44PZX27ks=; b=I+hKBBRhc37miRhiK8ZHrqDkDbC9ZQjaR5dVS+zd58oLtjUmKZm5Zq5kbd4+AwzinV L5Mykd0nm3IjEea2Rzw8z3ekuMvJHPInvHCZx/h8DGBqUQooGetyjVlF+7RgyAP8R8hQ mgBlVMqp4d9I1wwMJ7mYi/kTGeFmNrgu9a+43IKP3OYuJ+1N3j2N/z3Y4Wed9txt1qQV YE5Yu0tgHe4NGY6kWQHm/bgOf0NQXzC0aqwOG4C+y0QK0NZCcHJM6aPY6paaRZV5aoBl fG+XXh+JXLPl7e9TwPOy4rAkFYKSXm2aMjZQ50wtP3BngAZEVQIFWHIOI5yBQ9wanzEE VwdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/FE7tvrvqoJrGxZtO1M2WLOCJzVWjV9STY44PZX27ks=; b=hCa9NRJjZHq4dSeltZetgjD33wTdeRJEJZrz4XFHCbtDccepz9WzsJgudC3m7+gyt6 10CmcOPTVXh+Ck25RIqkkvl78KvR/naf0/+l5VcdHSdfNeCnhAPaop/7y/w5gZr+3dnj Yp4h9HA1Uy1+tA4bJs2g0bXIqK3AqtlfOgNrKyx3Gt0gBFlEG4Z5LW9PcjBzPZt0cK72 wI66Qu50/Q8TzV7uL0IMC6XQl8rf6zFxFsHNoiNeruHxvQMOe3We1lmLKVN4hnyYBpr1 W7EwDhWXgEB7cM7Je4u85NOaeoGWL5Hg08n8ZaJ8OMxuZQVlm64yas/v9nA0MElCs04O 39Jw== X-Gm-Message-State: AOAM530rZaoRJNDBJXv3A8hGDNUMaa19acqnwisSQrIanXNbDgOGgEBq XFpw6SWj5uu2ZgWazFTZ0EZ7wg== X-Received: by 2002:adf:f941:: with SMTP id q1mr31859042wrr.189.1614161986271; Wed, 24 Feb 2021 02:19:46 -0800 (PST) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id v5sm2015023wmh.2.2021.02.24.02.19.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 02:19:45 -0800 (PST) Date: Wed, 24 Feb 2021 11:19:27 +0100 From: Jean-Philippe Brucker To: Fenghua Yu Cc: Joerg Roedel , Lu Baolu , Ashok Raj , Jacob Jun Pan , linux-kernel , iommu@lists.linux-foundation.org, zhangfei.gao@foxmail.com, linux-mm@kvack.org Subject: Re: [PATCH v6 08/12] fork: Clear PASID for new mm Message-ID: References: <1594684087-61184-1-git-send-email-fenghua.yu@intel.com> <1594684087-61184-9-git-send-email-fenghua.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1594684087-61184-9-git-send-email-fenghua.yu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? 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? Thanks, Jean > > Signed-off-by: Fenghua Yu > Reviewed-by: Tony Luck > --- > v2: > - Add this patch to initialize PASID value for a new mm. > > include/linux/mm_types.h | 2 ++ > kernel/fork.c | 8 ++++++++ > 2 files changed, 10 insertions(+) > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > index d61285cfe027..d60d2ec10881 100644 > --- a/include/linux/mm_types.h > +++ b/include/linux/mm_types.h > @@ -22,6 +22,8 @@ > #endif > #define AT_VECTOR_SIZE (2*(AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1)) > > +/* Initial PASID value is 0. */ > +#define INIT_PASID 0 > > struct address_space; > struct mem_cgroup; > diff --git a/kernel/fork.c b/kernel/fork.c > index 142b23645d82..43b5f112604d 100644 > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -1007,6 +1007,13 @@ static void mm_init_owner(struct mm_struct *mm, struct task_struct *p) > #endif > } > > +static void mm_init_pasid(struct mm_struct *mm) > +{ > +#ifdef CONFIG_IOMMU_SUPPORT > + mm->pasid = INIT_PASID; > +#endif > +} > + > static void mm_init_uprobes_state(struct mm_struct *mm) > { > #ifdef CONFIG_UPROBES > @@ -1035,6 +1042,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p, > mm_init_cpumask(mm); > mm_init_aio(mm); > mm_init_owner(mm, p); > + mm_init_pasid(mm); > RCU_INIT_POINTER(mm->exe_file, NULL); > mmu_notifier_subscriptions_init(mm); > init_tlb_flush_pending(mm); > -- > 2.19.1 >