From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20F7BC001DF for ; Wed, 19 Jul 2023 05:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Mime-Version:References:In-Reply-To: Message-Id:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kjayGqmDcVN/dIk5qZSG8rucJ2wPq3m4LpPVdjPRYY4=; b=RvqHtbUQfwjpJu kpzfJLWo6kRZs5fnZzYl2MtboAbc79OiMvqmByLorSQA1cDznzQ6+cDtAfQRTe3HC2haWx9jjCziA B8ccPoKC4l4ZZAyYL+c7k22bjJtmBl/UnS7ZNm26y+TTUkxzOhcyxjC3r7egEvMy0IclXvOPGBKCL yzUxaHt6xbtPIMpCeYuXwkyCY5tv5jyAvp6KwVo0yg2GfjwMslvVlv2tywzAmnVfp2AoAiZ2mStd9 LK2Gt1V0J2WpUXiihoWoPFCJzfLGz6AT9Uurpr9ZNtEIFCLU4CIuzhkhgpBEnXh50bSbAvnpQ4zul 9EZgs8xSA7IRg27mdoIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qM0BZ-005TWk-19; Wed, 19 Jul 2023 05:57:17 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qM0BM-005TOL-0S for linux-arm-kernel@bombadil.infradead.org; Wed, 19 Jul 2023 05:57:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :Mime-Version:References:In-Reply-To:Message-Id:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=a1bIpMgG1zI6JwKodCNWlBnTaKXYcih1lskBJDBEehY=; b=i/X7pgsDgx4T1NZ09e94+CZDKV VtCMvbhleph9073mQwt4RS5w0OiKuzFlEpi8mOK4pdjVPJV8LNfGlqrUdxWaHh2APMNDpD/mPBtUG Oti9UzCcY4TXLcWqSchC0jGcvdSoBiN/DP60b5QVSZW6/UhGDPpUoYJW0sWcN8Z3B52whwFCd6a1T frtNPSu73xqlfJb7gB87YCC9ATLfBHU6BsnRe94ZkOwSI2S8rlb5S7B9ZNcFc2Kv2K713cb/uGLCm OWAKgEYyxtTpm55WA9XbtfN5cJeP6qR6DkhVr5Q8hjnuTAUWOVAZy+2lD1WcFbwSdbmzX3DRt8ru0 mGz+4QmQ==; Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qLpGx-00Bs5B-2m for linux-arm-kernel@lists.infradead.org; Tue, 18 Jul 2023 18:18:09 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AFA64616A9; Tue, 18 Jul 2023 18:18:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A5D3C433C7; Tue, 18 Jul 2023 18:18:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1689704281; bh=d+shrDRi9kk42aZV2mW7vxjklY0jpOFHpDdmUYO9Dqc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=FNRlqRi1A1ztUfMn/6WIB9xmZD59uhsQOC2e0G2SWRRwPvCu2EckzeGu+U4WeGeZ/ VsDlgtsZpKDhvdZQNN+yppX82+DGNSCBhGzBVek50PYsACLJGww+19Xlciuyn3Ijbt xwmFaowIPLHn3A3F4NP+KAhTWKUGxgd/oAcDp/U0= Date: Tue, 18 Jul 2023 11:17:59 -0700 From: Andrew Morton To: Alistair Popple Cc: ajd@linux.ibm.com, catalin.marinas@arm.com, fbarrat@linux.ibm.com, iommu@lists.linux.dev, jgg@ziepe.ca, jhubbard@nvidia.com, kevin.tian@intel.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au, nicolinc@nvidia.com, npiggin@gmail.com, robin.murphy@arm.com, seanjc@google.com, will@kernel.org, x86@kernel.org, zhi.wang.linux@gmail.com Subject: Re: [PATCH 3/4] mmu_notifiers: Call arch_invalidate_secondary_tlbs() when invalidating TLBs Message-Id: <20230718111759.5642b4c4ffd72ddd9c8aa29f@linux-foundation.org> In-Reply-To: <791a6c1c4a79de6f99bffc594b53a39a6234e87f.1689666760.git-series.apopple@nvidia.com> References: <791a6c1c4a79de6f99bffc594b53a39a6234e87f.1689666760.git-series.apopple@nvidia.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230718_191808_121627_1368175C X-CRM114-Status: GOOD ( 20.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 18 Jul 2023 17:56:17 +1000 Alistair Popple wrote: > The arch_invalidate_secondary_tlbs() is an architecture specific mmu > notifier used to keep the TLB of secondary MMUs such as an IOMMU in > sync with the CPU page tables. Currently it is called from separate > code paths to the main CPU TLB invalidations. This can lead to a > secondary TLB not getting invalidated when required and makes it hard > to reason about when exactly the secondary TLB is invalidated. > > To fix this move the notifier call to the architecture specific TLB > maintenance functions for architectures that have secondary MMUs > requiring explicit software invalidations. > > This fixes a SMMU bug on ARM64. On ARM64 PTE permission upgrades > require a TLB invalidation. This invalidation is done by the > architecutre specific ptep_set_access_flags() which calls > flush_tlb_page() if required. However this doesn't call the notifier > resulting in infinite faults being generated by devices using the SMMU > if it has previously cached a read-only PTE in it's TLB. This sounds like a pretty serious bug. Can it happen in current released kernels? If so, is a -stable backport needed? > Moving the invalidations into the TLB invalidation functions ensures > all invalidations happen at the same time as the CPU invalidation. The > architecture specific flush_tlb_all() routines do not call the > notifier as none of the IOMMUs require this. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel