Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3419673pxf; Mon, 29 Mar 2021 01:31:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxmBOZ1mIqJHBNEHL028n3uyKqfbecCeWyPaiXHWdUEeviE/yKiCMixZkl/b2MGt0FIl5X X-Received: by 2002:a05:6402:518c:: with SMTP id q12mr15280198edd.11.1617006660154; Mon, 29 Mar 2021 01:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617006660; cv=none; d=google.com; s=arc-20160816; b=DMDoJcnFMrI6H0xEL3vXZkVe0+RHb3mWff3xrPXzdHb7GDJb8pkElsoOQAbFwQ/0n2 IZYzKUz/FQmtD5qkwEOKerw4Xw38HZuHGE+dYaIxqDurUorl/sm2Z/S/fPxjKFxGfubT V9BPz8VTSVdF1keevh+CT2xOfnsmihQkzbVf4Ih23CqgTUa8Hq75VdJXiCIcC5+I4dkc fcm+iwJhwUJXEFaiMvFz5yLARJm8oG4JEnEIOKdxIiDy6rFUKris91H7bn9x3IimUwLF p2eGffXZAeN+qedS20WEBAyYMopY8mNcufkkLBGOna9ZjfxueyZdXEJiYLmy6w/5NpJk VMdw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Lo28pncAOSIBNFfin9uC23j8WQbN/mWm95b2pjav2vg=; b=Eq2r4slJ+QxKZoDXBMF5kiH5x3X6Js313+S1m9WMwRJX+mEqV6JufsvucQnsCDtbpK 8okZORxOIhudrCVuJo4Hmd59VzmVe8kJtr6RWGc/z2XaK9xgGHOqRUeheUgl2W2a02g5 m8GKtJavQ8sKvkRzB+EcVloMYpG31M2jGvpyTFMYfoMbHQsRb3fBzfy5IY55sH6YSPJ3 Ap/fsN0regcFt22eg9fwv280HbdnaA1ogQCXSTx/XWAmvePhmV2svTaOdJNVVYthoziF VUIsqF/QHhZ/yqUV0lwiX50sALLDd2zHDzVrCSYl9CilehsEZ0BpVPODrOinBj2Hk/kf jrAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rjhdF3IJ; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p18si12753488edx.311.2021.03.29.01.30.37; Mon, 29 Mar 2021 01:31:00 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=rjhdF3IJ; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233262AbhC2I31 (ORCPT + 99 others); Mon, 29 Mar 2021 04:29:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:34298 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232298AbhC2ISt (ORCPT ); Mon, 29 Mar 2021 04:18:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AC2F561580; Mon, 29 Mar 2021 08:18:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617005929; bh=bezWuvKKjJyUVUS4m+Azpk96eTuvitpgqODjRa0cNIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rjhdF3IJbXUzY95tfuk/m6jj8TusxKDKdSmtAp2lv0aA9Tv69i0bCDkKwqd8Y2+A7 6fQjSfTaCdWxrqte5BfnMdmKkRTg3s9Cpb/Jvj5wAAdtNGiPP0oeyoK91YgerI0wwD /JZu18PJXUTp+64Kzcr983VGn80gKLfpN2I4VBSE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fenghua Yu , Jean-Philippe Brucker , Tony Luck , Jacob Pan , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.10 054/221] mm/fork: clear PASID for new mm Date: Mon, 29 Mar 2021 09:56:25 +0200 Message-Id: <20210329075630.992429766@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fenghua Yu [ Upstream commit 82e69a121be4b1597ce758534816a8ee04c8b761 ] 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. This patch was part of the series introducing mm->pasid, but got lost along the way [1]. It still makes sense to have it, because each address space has a different PASID. And the IOMMU code in iommu_sva_alloc_pasid() expects the pasid field of a new mm struct to be cleared. [1] https://lore.kernel.org/linux-iommu/YDgh53AcQHT+T3L0@otcwcpicx3.sc.intel.com/ Link: https://lkml.kernel.org/r/20210302103837.2562625-1-jean-philippe@linaro.org Signed-off-by: Fenghua Yu Signed-off-by: Jean-Philippe Brucker Reviewed-by: Tony Luck Cc: Jacob Pan Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- include/linux/mm_types.h | 1 + kernel/fork.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 915f4f100383..3433ecc9c1f7 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -23,6 +23,7 @@ #endif #define AT_VECTOR_SIZE (2*(AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1)) +#define INIT_PASID 0 struct address_space; struct mem_cgroup; diff --git a/kernel/fork.c b/kernel/fork.c index c675fdbd3dce..7c044d377926 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -992,6 +992,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 @@ -1022,6 +1029,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.30.1