Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4464370rwd; Tue, 30 May 2023 05:57:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51yVVcNAs/+K4O+mmfnMbzQ+4siXJMw57PII1hS8VlqfpJvTywqoMAXhvMcJpLgpnF8DXR X-Received: by 2002:a05:6a20:b916:b0:100:b715:8ab2 with SMTP id fe22-20020a056a20b91600b00100b7158ab2mr2243425pzb.46.1685451452592; Tue, 30 May 2023 05:57:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1685451452; cv=pass; d=google.com; s=arc-20160816; b=pKoW0EGIK0Vt1ZP1ph+NRErRu7eqMKkYV4oLHtqs91/WI3qTSqnd8M9pVYz9SAocvg o9y/3s7NB3YklujMkHVM1JJDETVgasTya4HapqyXRnZ+k/AKKko5/oLHcy/2mQH+Cq8G vWEF6cm+nyaKq5mdrLYNqj1vKfxiDpaY1+7pntL72dBIOk0Cw/Bge7dETkCPmUrn3rXK OkLkWj6vFbw72Leie8gaT2t7c/kbYpQteceV9M91g9/X5LOaiLnJvEwFmbA7x5Q0xwzo b6MNbM9KLLkzHRzw5cHQkxl+OUazeXLm8hsTTU95uZgkkBnQ3YHYHMoFeslLh/1rA9eQ klgw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gOTjVUbkENSjUSTkeOmWH9YX6YWCj1y+LVHKLzlMyvY=; b=bKmXlMYVd3R2vxA337TdHIsDG56rfz9NOWePuIhLD2uZuGFN5O66cuDQ292LZuj8Yt lsYYoTiVuZkzF6JwvdWVIHwQDTb54wnNevdjZ9eT49aBiChtHgM9Mc6pWrgssz8+Te/s gDp3SDFKLHK0pWoSZtettjo2DjLTwsThEBCmT+c4qv6VT0oGtzitPdXq3Pu0mtK+25j3 m9vK7kHSIXJwTgnS435O1ydXq0fjiXtMejaJr1YMbTn5EzppttY/fMvtMOxEtz8Kb8pO J9uWZVXlXGMq+0jatjp6ai/iXhbbIVy3BbYD+l6wZ1IUuqYK6sZfsYdEDRLyIrm6JuDM hBHA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=f+HKngsq; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.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=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b16-20020a637150000000b005346be4ead7si8820124pgn.766.2023.05.30.05.57.20; Tue, 30 May 2023 05:57:32 -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; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=f+HKngsq; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.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=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231896AbjE3Mx3 (ORCPT + 99 others); Tue, 30 May 2023 08:53:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232374AbjE3Mx0 (ORCPT ); Tue, 30 May 2023 08:53:26 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2072.outbound.protection.outlook.com [40.107.220.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9021CE4B; Tue, 30 May 2023 05:53:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SDivpmQghpK1UUf5t8mxaRYl/5zqgTAjnHnja+e63o9wkiFKtnj8JX7CTx99IwqQI5ZdJmEJIgiB3Ef7UxEQHbExRQ8sFhSsAjvkW7zTiIoJynprCrHLryNGspxqCNUuLwFuQzwJMIfg032y+ApS/L9zny6Ybh61dJG2xA7BJAnwmy5jbezF7Xx2kONjaHKhB2CCobZQQJpxQtWa9NMfvCVTkuZun8j80t/9qbgc5rQPY3/E519U/V1MvJyY4KbGUXT+mggCVBWPGsRfGsp9Da+3QVcuPqbFB/nh5Ga/gi422/5TL+aZ524npfYH58r4Ub57DuzMctbEcoERlnxN7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gOTjVUbkENSjUSTkeOmWH9YX6YWCj1y+LVHKLzlMyvY=; b=OIUsj19Ihmr9VlFo48lhUlafMZHRz0S8MMDKdpmgxl0r/iEHSFx2I6+hfaRk6e7er+nOUVTCG6LuDOMHzbtybeo04wSdCYi9hDoreaVxM1cIRYWk5Qt22g0H1aKkmFZaKTCtMjzxQOg2NB/imEIIBSsA1jZ3w8xhBVaJqD1PMozBDgmuMM0LXX7h0xlbvbRNY3pLCbB3poeKwtA6xzOeL1SWWRhSCz3j5EwYi2JGxJaMeX0sG8B68uHrGOcHQ3wWYVTGUPEsbWllgg1vE3Y49337TXt+J8gsnB2oJM3TJ42V2tziHXTvobSbCmb4Nx6whRNK4Uo/M8KFkgF7DGoKkQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gOTjVUbkENSjUSTkeOmWH9YX6YWCj1y+LVHKLzlMyvY=; b=f+HKngsq6psykViI0U/lWN93od4eh9dDCqCgsqq4A73KGmTQpNQo800rZEtAa0wANrIomg5+tuM8wSkI1gyZ01K3rUQhX2JDVk6RJd6vShgx9jAbiSNofDg7yh2aZj50QtTGXj8o0mLRnF5puBb3Bt6k+9x+6BvmC9KnJoYpkLD4Kw/pyS5INhv0+if1FULXU3oxfhKablvYhHIsjBvhSTKmJvW7T/gZ8xy7cGWueOB0+lDRiyUxYj9NdwaaBhEhyV6H2bEKZQ3DwUAMjqHuPIKJfdbNf7I/mC/GA/quBzNHbVI9FH7rxx7VA86SDuuGkrdMK17o63G70Q/pKrltfw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by MW4PR12MB6976.namprd12.prod.outlook.com (2603:10b6:303:20a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Tue, 30 May 2023 12:52:37 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab%6]) with mapi id 15.20.6433.017; Tue, 30 May 2023 12:52:37 +0000 Date: Tue, 30 May 2023 09:52:33 -0300 From: Jason Gunthorpe To: Robin Murphy Cc: Alistair Popple , 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 Subject: Re: [PATCH 2/2] arm64: Notify on pte permission upgrades Message-ID: References: <3cece716fc09724793aa832e755abfc9d70a8bb3.1684892404.git-series.apopple@nvidia.com> <5d8e1f752051173d2d1b5c3e14b54eb3506ed3ef.1684892404.git-series.apopple@nvidia.com> <87pm6ii6qi.fsf@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: SJ0PR13CA0130.namprd13.prod.outlook.com (2603:10b6:a03:2c6::15) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|MW4PR12MB6976:EE_ X-MS-Office365-Filtering-Correlation-Id: 54672bda-2efc-4a0b-7cda-08db610cbe8f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Cgfy64LfmCJ4sRAW2b8QwWt9XTriw/P1zI3ON9Wrt4xYXoBJ1/rbur69ZAAAw1cGjx4RflTl2lYONspEexYSy+MBks0np0wQmHMLmSRKHJTI/ELpTmv3LNCYlmbWyjKhHzuju4+KzyHPA8uh+zFNoIHVI1/BQfbQBtXOaAe1jkuuVN/EAm7edWrM1ecP3f7+b32XTNlkCCxKtSOE7rM2n+fJkSn748MjZAMrCuTreQnNz7P1kmKtJeB2VL+wZRTIKQmoNPPPd03EKUnTxR6iPnm0/np09F9RPiKbQQgh+iA3eHhTlaKZ20enU8LhFWT9NzOf56BKV/TUISMemUBntZ9t1Yzd/mb/fLEKHHvrFAvD1yqr5f6U5jkP5ZLpoPWacsxnBmpCInkMPKzP5DiYI9PnGxtawKTtNrpF3dW1EJMfQBZLoKQKxHS9DVm5oWGUdIW1nEJDWlY9KMcbU/ZAT37u4BrqWTXM6Hpv6+B/amlvD8ZWK0wSV2mVsYDRWSUZ4h7WqiBRYWzNoG6viTpE4l7+ZYYW9gU76l1s6erHRu6oywNsWzv4ap1ruCT5XYpM X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(39860400002)(396003)(376002)(136003)(366004)(451199021)(83380400001)(2616005)(2906002)(186003)(36756003)(38100700002)(41300700001)(316002)(6666004)(6486002)(5660300002)(86362001)(8676002)(8936002)(478600001)(54906003)(4326008)(6916009)(66556008)(66476007)(66946007)(26005)(53546011)(6512007)(6506007)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?vtF8GQfl9cYrgqK0QCcdx5yPA62+HVWCu15E0MMw6+LYSQxrqDdBK5lSiuHR?= =?us-ascii?Q?c4mnLUyjdApvAHNwnrgsU8SUhyk6wrdq5AcdW7bxTSX3BKcvMnIxe/z65v2m?= =?us-ascii?Q?shPYO5xoK5mKIlq5tXIoP38foRK5IIdHjxwXtUdUx2pElPiuvPvm7/oBSu45?= =?us-ascii?Q?YY/wHtytJVy7PaZnXc1SRsChT9DL6Twe1gxEmYLeuQeK7f7EBq+xbRZTlRRz?= =?us-ascii?Q?1YxePvf5HmxgLCdSCrn2GULXfGyCkTCUr9XZz/VbMwZlpVXarYEGsNYj1R4J?= =?us-ascii?Q?QUQsP2Ha9MsOHxfgeI7Q8zWPuwdtNffcb64NCNJKNL37N3xvOdi4+7W7e4qf?= =?us-ascii?Q?7ubwOS3R113vOhgzixDhyPcEfGeyz+6PqgXHq9GxJikMxhMjjVJ5BqxlwU8j?= =?us-ascii?Q?OTqWHQkOJGL0sTvIs91FJ8Xm7WJhVJkGTuao10UACqGeSwluL2C4N7PyDraU?= =?us-ascii?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6Irv8RbUMsl15E0p5AkMzr?= =?us-ascii?Q?URjYyI7geCFlEnoCRQ3JDH8VdHSy1OmNyTTxCEQXEjk2y6S86O88fC8ePTuu?= =?us-ascii?Q?pNnD92b0ofQG6RhD6sdwbQeNZGRYvYKIiaPwwk0/bkngBqJHCscYMLPdaCPs?= =?us-ascii?Q?MXWa5EZXcKnk5p2+PfTpd34d5mY1NsAzOA6gFvBXCAie8fqW3ce4uQofgvdG?= =?us-ascii?Q?XMeolG4hJyNREKaY4k30xRwcNV1DFoB79qhyJ6kD?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54672bda-2efc-4a0b-7cda-08db610cbe8f X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 12:52:36.9412 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: w2LyC9ODDECO+7B1IUuFf5TymVmxl6zdNST+UXzrJhwnzD+lr9Jx2epf12mmtHyZ X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6976 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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 Tue, May 30, 2023 at 01:14:41PM +0100, Robin Murphy wrote: > 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. The mm has a definition for invalidate_range that does not include all the invalidation points SMMU needs. This is difficult to sort out because this is general purpose cross arch stuff. You are right that this is worth optimizing, but right now we have a -rc bug that needs fixing and adding and extra SMMU invalidation is a straightforward -rc friendly way to address it. Jason