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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC190C7EE23 for ; Tue, 30 May 2023 12:14:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 354D56B0072; Tue, 30 May 2023 08:14:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DC306B0074; Tue, 30 May 2023 08:14:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17F63900002; Tue, 30 May 2023 08:14:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 041626B0072 for ; Tue, 30 May 2023 08:14:52 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7D6431401F7 for ; Tue, 30 May 2023 12:14:51 +0000 (UTC) X-FDA: 80846815182.07.52A2D1D Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf01.hostedemail.com (Postfix) with ESMTP id 70BE84001A for ; Tue, 30 May 2023 12:14:49 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of robin.murphy@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=robin.murphy@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685448889; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GIcHDRumUz+4RnaCteHomeL6A+mzgofQIzXzKX4JriQ=; b=1pKct5myvDMdGQHsy2BSBS4FXZ384YXtcRCteBtzXkFI6dLeUp1II0BIBY2pcHIxPzbBys bFxYUAgTstkYwwnIDMTSDuuLKufDQhvMqaoSkdWrNgc3lasXkIym+IQlK86v01Q5MdP2Yj y0lRHWCaWDJn6O7LQbNT9fCmp51cqiU= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of robin.murphy@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=robin.murphy@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685448889; a=rsa-sha256; cv=none; b=evniVK80g/8t5RrClEb2RV1SFVb1tJjHvByymq6tFyUgeHjb4MqyOK63JsVRJawb0VR5Di 7hvA7HXVDXyKLIcXVABVuDpeMgbNW34icvy3WACi8NDK3fjBiR+NbiUNGOssz/FAGjaxsH bFWPVcTPZtzPnakBeOkUukcwlkm5nF8= 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-Rspamd-Queue-Id: 70BE84001A X-Rspam-User: X-Stat-Signature: mac9wzaxyba51ho97q84xib1ngfrbbcn X-Rspamd-Server: rspam01 X-HE-Tag: 1685448889-333655 X-HE-Meta: U2FsdGVkX1/ds4A1LPpjGJAopJcNLMKcMKrDFcqk07A0r5tvch5vci3goTA7NQqvjpVwsWbQRSU7+PA4xCq3yldnY+nb6cBKecetnbiV7mC5Owqlxoz3D99zkd6JsS4Z54wt2r13nK+F1GPB62q5SIsNeavPzHLoYgEjM/zS9dPqz3Z2KAW9ePuynIkesvSMIp+DxYGkWahN+EEytwgsM7jHlovHLlTdBZrbFHGwvPy9d+8cOqDgL1daUqNXAMBGVqo9vs9a60/T7NlocPjLwbCD/uangCaATFO21OwNmTK+GM0drhTO0HQQBf5wvG77myF4BHTzjpH4GCJoWabQUr+8Pyh+hQkPaoXvW1U33B46RoiSwJkDVAdklEhFZV03q33d6cFkZLcinfmZIE6YarI7krqDmeRvVIzHiQ2zLgUVbObkzkTEhZi4ODyL+RaH1eMQK0rHAh6EhogmmxViGsrDdyLvWQaOxCAzFv8FkqVzGAUyXsek8U+1mtAEXTxmAEmFlE8A21z1Jg+Oqc9I/hdjyQC8B7tHBdQ5B6EesEegfJrhobdloQz26p3G+L2lujCP/Tcrr8gAa2IzJnlgKNGJEhEGKaqbGlPTiZ885arvxnESZ+TocWOK3oTfsI1mLlCrkiBMQfGYSw2yzeJO41SUNn62zIo4XtsEffr4ZfM8KOF2Q7pm53LAWGUXPNfd8kxUdf8XvS7U8rlEY1mYw1XFUaMsGrWQhPHBY5fDyW6m1CqKX0o/evql2xqWWmVk+1knseJ8ClEsTeuTSt0CI4MYcwLZP1gBNdpwVgQCi/RV9k6OaOC8t25h0GVr6Al/S3yVYQd5tNszyvtUq4QH9nuD11s7oikH6X2fUGwTsQsNqBNWd7TJ0SqQ/n6sOV1vIi6xRCnTfQFwRA3wDAYgXaNyFzDYNrR0UociPZAPYZSMRKLnD/90Pvk7onwlSFvOKjUZbpF1UbHzLIzNgBG KRprxlO9 x0BGu3gAExzVyPzc89+2PsH/5p83X2k/LemmgYiyFZOVp8qzhwf0hiXUWL8AhHUqddkJmY4EPABROv6xlz6+yNwRz+yeOJ+0AZgmLpN7gujTqwqvzfMaOidgUguIzzpfGMdJZm3BsxhBqAAkC7taD9MT58QNsdO63wUn2Vc/33/ZyUk/8h6SU9hY83A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.