Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4417509rwd; Tue, 30 May 2023 05:19:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ42aASFhmTNlbN0bNPZbdjW200pVEidMheGRWIPirsSeLRYCH8Ie8UZHF+3attQLJEad4/p X-Received: by 2002:a17:902:a417:b0:1af:babd:7b84 with SMTP id p23-20020a170902a41700b001afbabd7b84mr1977155plq.41.1685449152363; Tue, 30 May 2023 05:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685449152; cv=none; d=google.com; s=arc-20160816; b=z54SwRjU8stJJ0FclBXUs26dBR9OnWqj2u8nMNRRNdnH+8ONiz5zG84N1i9JBl8qZB 4EmjWAOZ1BW5BKOVr2liT7fvBkj3Qo5QANXUwfi3O9lQ/z86HAOLPBq/kVJ+Rp3WvVMC yiLaVea8Qk1RQsMjwid7cQnbsV1tnCnbaX3qr0OzzbgwvNVE/VsCraB7qXNA2ef+bCXj vbhxt8DHhcBCRMS7+Lvs8UvUJA45eSEcHVMF6pt/wASuj8zVNcJ+bthdX8cElPr6PqrD rXq2QH0UGNsL6cpDlSlvC4grfI1RhnXTuHCZRHjVxCRhKjyZ7xL2/3X0ClAV04O3MWPs x1bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=GIcHDRumUz+4RnaCteHomeL6A+mzgofQIzXzKX4JriQ=; b=Tp+JkhT0d424Ot1MruSWF1L1Kc+y+E/R645rDcp0VKLF0WZm1j16s31hFzDQpx5dAP jID1olRDPsuKxUXvhpiSo/DnxUhK3MYNly6y1onvywSiqU/r1Zr922OQiqJb+2b7D4oF omKtdRJ/TaIjYgjuNApEHr+V52cVSKeq+9NQHeRlJUY0qeYfSEDLhUAZYqIaX49xaGIy LDto9ANtw/+4Y0UtVmJZpBzJGE2le5R7KlIUWptPnOpS67GqAhcVl5EK+aFslpEB106l GcpjF3jHywr6mXEnxzdnWyXILudBQaPSpyW0Qg/7nstYUd06Y20al8PK/8Z0djqSci/M NVvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id je1-20020a170903264100b001a6dba52e52si1441790plb.390.2023.05.30.05.18.59; Tue, 30 May 2023 05:19:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230109AbjE3MO7 (ORCPT + 99 others); Tue, 30 May 2023 08:14:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231735AbjE3MOu (ORCPT ); Tue, 30 May 2023 08:14:50 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0345AB0; Tue, 30 May 2023 05:14:48 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 988B3AB6; Tue, 30 May 2023 05:15:33 -0700 (PDT) Received: from [10.57.83.37] (unknown [10.57.83.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5F5DD3F67D; Tue, 30 May 2023 05:14:46 -0700 (PDT) Message-ID: Date: Tue, 30 May 2023 13:14:41 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH 2/2] arm64: Notify on pte permission upgrades Content-Language: en-GB To: Jason Gunthorpe , Alistair Popple Cc: Andrew Morton , will@kernel.org, catalin.marinas@arm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, nicolinc@nvidia.com, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, John Hubbard , zhi.wang.linux@gmail.com, Sean Christopherson References: <3cece716fc09724793aa832e755abfc9d70a8bb3.1684892404.git-series.apopple@nvidia.com> <5d8e1f752051173d2d1b5c3e14b54eb3506ed3ef.1684892404.git-series.apopple@nvidia.com> <87pm6ii6qi.fsf@nvidia.com> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023-05-30 12:54, Jason Gunthorpe wrote: > On Tue, May 30, 2023 at 06:05:41PM +1000, Alistair Popple wrote: >> >>>> As no notification is sent and the SMMU does not snoop TLB invalidates >>>> it will continue to return read-only entries to a device even though >>>> the CPU page table contains a writable entry. This leads to a >>>> continually faulting device and no way of handling the fault. >>> >>> Doesn't the fault generate a PRI/etc? If we get a PRI maybe we should >>> just have the iommu driver push an iotlb invalidation command before >>> it acks it? PRI is already really slow so I'm not sure a pipelined >>> invalidation is going to be a problem? Does the SMMU architecture >>> permit negative caching which would suggest we need it anyhow? >> >> Yes, SMMU architecture (which matches the ARM architecture in regards to >> TLB maintenance requirements) permits negative caching of some mapping >> attributes including the read-only attribute. Hence without the flushing >> we fault continuously. > > Sounds like a straight up SMMU bug, invalidate the cache after > resolving the PRI event. No, if the IOPF handler calls back into the mm layer to resolve the fault, and the mm layer issues an invalidation in the process of that which isn't propagated back to the SMMU (as it would be if BTM were in use), logically that's the mm layer's failing. The SMMU driver shouldn't have to issue extra mostly-redundant invalidations just because different CPU architectures have different idiosyncracies around caching of permissions. Thanks, Robin.