Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7014645rwr; Tue, 2 May 2023 08:22:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6T0K59Ji7p9vH14FCIAcJWOAX52JrCXs7gkZEhDVX+r75nD2lMM+Ho12E963N2dm+O4z9h X-Received: by 2002:a17:902:ecc2:b0:1a5:1842:f7da with SMTP id a2-20020a170902ecc200b001a51842f7damr26576864plh.6.1683040957760; Tue, 02 May 2023 08:22:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683040957; cv=pass; d=google.com; s=arc-20160816; b=EIsCZarOwwv0JC/90vqfuRq+PnwTLId+UWWZNDuKlzb4Ga3h2ZbX4m/SxzHyrto2Ps QwjbD66YxTVHKUmMAJoAkcRu5lja5GMO5egPcIQUf4eCVQ4KZtPllnCufLDvMUi2hQW4 EATpNfSmu0iANLUJyRquiYCIL8gkF5coDX4WJh4IrMOX0ETjREaB2/jfU2B7VXv6OR3c 3IKqeIRhpgaCHoSEQ+HC8oe+JbWFVfJO3XBPPDH94ZCqlJYVBXWU/ZaB5+er6H7RX4FQ Fndh6ZItCG+W7upT8f8xZuTbb/ABY8oug9CO6Soj9rEFok+l+VMX3OG0GOi6Ysc0fkxL 99SA== 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=cXHZRDDY1/oONO5YkSIVHScmleT+xOQGcl34AU5PV74=; b=sky/OvKvvT772lcuszDnTtQ/eUSnoxKYgRH2gtqHiN+aAvvUV+Q5Q1ojzC32iAU+cH oM3X/OM3Iu47OPQzZHB+b9TVuBNRq2Tl3kasTzTTt7ZeY7vt7dKgn/dCUS14GLrsx32z RjQYcG8tjMgpVpnM9VyEQD7c/ky44cgTRo1Sd92RiXv6rfCPRpMw+nqeAIHr+hBowlVq BU3TGKDYax68ZhMGfIKpQTO3HV10nVQjmO7HwoCtR7AO8YMX3s894OQiZtYxBxrB+HEY 6QV2avyhNMP50ynGBky45Ig4NhD68BKluHEZY7MmdGSI1s7UFuIcAsYaYP+rrKsFFP9w MTsw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=jw6MPqt2; 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 h15-20020a170902ac8f00b001a99b965c47si16544755plr.411.2023.05.02.08.22.22; Tue, 02 May 2023 08:22:37 -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=jw6MPqt2; 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 S234127AbjEBPVF (ORCPT + 99 others); Tue, 2 May 2023 11:21:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233560AbjEBPVD (ORCPT ); Tue, 2 May 2023 11:21:03 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2072.outbound.protection.outlook.com [40.107.223.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E13D2268F; Tue, 2 May 2023 08:20:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l8160N8ibt6lLcXDFZnlSaXUYMlveK+H07OKXxPvgH3kABh+cKAkmmBc0WWZlHRWFjLwkoVQnYJFHy8SivTSdr3FLvaTTsYU+OeZAiCS56TFCe4ZtvspJvEbo7gR/QbQ9TMBkmaDZOd1RWbQ49Tc6A9jfRMfLhm7f8EmFDbQ2RkF2bnRgpswjij8wmxZkN3pQZ9hqD6GM4Pjvesn3r50zkCtOMy1ITHTdRPpsO4wChDPfN71AfDFk3lEbYXP/5+uMEFdd0jA9tGN69bYf2G4eH47rtSKwXRPbt5dOuwxgesc1rzmPv91PnOzR76YlwaM3D7ShO234EbLiimUOMTriA== 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=cXHZRDDY1/oONO5YkSIVHScmleT+xOQGcl34AU5PV74=; b=oMOBoJL0eSuxHYD9u8+6WzAa2b1BjWA4TOxFkChhzEWXMDAkfQdb4svHPW0FOzJ67OOIk/JTMEUtDrxiE3Hdzz45KrDWv81AgaIb+DLQ4gYHF5WKbpQghOfVCDScCPco43uzi1v76TBdLxTc1nyPdZxkyscvoCcxfIK43dj5Nqjq7NtvmHXmqK5Sw4GGTEi/LsQkVfggd3E075pj1SGGVgDFsrKF7Vf3s5HG46rGEf/3xifQHSchQtblZ8Q8O9lbkuajoKTYn9ZlBUcPHY5wz83bW8LiS5UGzyAf0HaOzQTJ1x9MG+ipkAGUMk5JbFixNHS/Om2xV/fh7n0TmXgBbw== 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=cXHZRDDY1/oONO5YkSIVHScmleT+xOQGcl34AU5PV74=; b=jw6MPqt2CsvojX/JU01Z6V06zM/+eEk/st6xEugG9wdFVo6nwM2e/8LjXdnY2qNFm743sbN0MjSHm2xCepsqZxL60c6KeeT/tGuoLctHSPW5gdrJCdydS1OIU9vBaayZN9LsviTjckbJH8zRqZZbzBwLNVsl3LBol31Rvr3hqfjP+dwQUB7jqsQLECuAOTkVQNiPEdca4SduY5FDLMkUr7AW08O18rORVWNi9iLVh2/Bv1ohmDKlOKGzUSA9rwyM9iI1jGYd6HWmiKlIIR4gu3ybiA2dJxtYZAlp5c4u5tB8xzX4fLG9/i1CoCNNPfkFGjXB4nKhtbct4Rap1yhwqQ== 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 MW3PR12MB4507.namprd12.prod.outlook.com (2603:10b6:303:2c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.30; Tue, 2 May 2023 15:20:48 +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.6340.030; Tue, 2 May 2023 15:20:48 +0000 Date: Tue, 2 May 2023 12:20:46 -0300 From: Jason Gunthorpe To: Matthew Rosato Cc: David Hildenbrand , Christian Borntraeger , Lorenzo Stoakes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Jens Axboe , Matthew Wilcox , Dennis Dalessandro , Leon Romanovsky , Christian Benvenuti , Nelson Escobar , Bernard Metzler , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Bjorn Topel , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Brauner , Richard Cochran , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , linux-fsdevel@vger.kernel.org, linux-perf-users@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Oleg Nesterov , John Hubbard , Jan Kara , "Kirill A . Shutemov" , Pavel Begunkov , Mika Penttila , Dave Chinner , Theodore Ts'o , Peter Xu Subject: Re: [PATCH v6 3/3] mm/gup: disallow FOLL_LONGTERM GUP-fast writing to file-backed mappings Message-ID: References: <1ffbbfb7-6bca-0ab0-1a96-9ca81d5fa373@redhat.com> <3c17e07a-a7f9-18fc-fa99-fa55a5920803@linux.ibm.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3c17e07a-a7f9-18fc-fa99-fa55a5920803@linux.ibm.com> X-ClientProxiedBy: MN2PR15CA0057.namprd15.prod.outlook.com (2603:10b6:208:237::26) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|MW3PR12MB4507:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e42af9d-8900-47ce-3ae1-08db4b20ce40 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GMtG+ai+89aB4xwBtJ/7Yvk6WsBL3AJRFDnwwNDwyDO7ExTQMBkeAob7SJhBMOL8TTSDt9ZCb5e0PgJq0qkvo1uFHHoqkuC8Temt38YY2ezv1/jgxAUSsdOyEkEbJ1wnDJLXiUYMHrPES9JD738Dtog/ERqnLnqhN3dONw00tuOXP/9c7FywSj/+/hVD2uKUmr5fj/5IKRdhbU8bTHAkGo3TB9R9KHEg5P5YWrt5BmG2J+pkoJ9adAbTtgVYM6DdQ/1Sibb5oFyfYktcix0JXryqbtWN2AME3Wg5bOPzPtiYg+HClvoEInMHlSxpLsvJB+CoTty/yOtN9ebMjMIPxxUEueNuliWzk7I2dh65pdI+GRpFtA+fbbA4gtekQpMoEIdoSF+shHLcu3LZBaCQxNV81z4lyAda67JD3Ob9h05JYSEyltS1VB9UVpvsVNiqAveG2dt41xp+IyE4S+33pH2Gl98opm7btx/Ep/kIJsmniouC6pbUZUdyTh9H/rSYiBZ4l4S0Xn9KWuWwgG4hmH95Y3aDJEkUl8RaXWbMIfZWs3R4M6JgGKZZkCLEYS13 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)(366004)(39860400002)(136003)(376002)(396003)(346002)(451199021)(36756003)(86362001)(38100700002)(8676002)(66946007)(66476007)(5660300002)(8936002)(4326008)(7416002)(7406005)(6916009)(41300700001)(316002)(66556008)(2906002)(2616005)(6486002)(54906003)(478600001)(6506007)(186003)(6512007)(26005)(83380400001)(53546011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?jAuMTJR2d7EFrznZ/OIIARXRPFfZ+XTWlquCeVGKRMtTcgLfkDnWGyXYMzV9?= =?us-ascii?Q?2/M2svGAekNq/igDWTAaeLdBaQ8X0I+f/ub/601MkYfZhbdzJ16tSLV7GZGp?= =?us-ascii?Q?mcud+G9VNoSEGH/Q0J33vg/dHbBRREfRu25G08xtUpfJWMM2NqFKu9xR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ChnPBRqJVvmng8o5wSXaB1A4?= =?us-ascii?Q?hvSg5rwMmajtzooeEkDMcGh7aRReQUPz8A7TAXTmS22wJfzALrhyMQgiBcCR?= =?us-ascii?Q?gtmIB4ClVfk+X1QWNzxOFc2Y+7MsBWJM6dPidPSz+mmSGafkn8plFgz36KNW?= =?us-ascii?Q?mDFrcnQC/zjlqkhP3MfE1VqgWofH4Kd/oRgv/K1kt/OgN83LWo4665CYI+WD?= =?us-ascii?Q?1p4LXhCMhY+aDFEHfSaIU4nT2WOgY01mi/cVNDOy8KNnxyMy/I31EkNN9zdC?= =?us-ascii?Q?MClumMte3gc3iONSMjVkBC4tVQKDmU4ZwweGsAFo0xQ7vYljRL5x3HsCG8Yo?= =?us-ascii?Q?i1n6dXLZQ/nGYXN8zepWZVqEW1JpXSvLFOiJnJ7eV94qqb18mDsNV1DJsAW2?= =?us-ascii?Q?/i6JtHRQrSNfU5PcyWLhwM6Pw9vNzdNLldO3an7a8/kUVZGxqgnX1x9eaWa1?= =?us-ascii?Q?ENlFd/PgBEtlwLbrOziVJ35KUjahARz3b50KFQCBzijhZuSUQtptog6lw1yO?= =?us-ascii?Q?kQv5321rdp8OXQgEgKoUnhy8tt0nLm8cDqwuFx84?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e42af9d-8900-47ce-3ae1-08db4b20ce40 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 May 2023 15:20:47.7078 (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: sCXdf9/uZoM5Ip2lsfQeqcV+r5kegVrjbAJeEtdiGwUs2iQVj1AVjAO6uH24wDTi X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4507 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 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 02, 2023 at 10:54:35AM -0400, Matthew Rosato wrote: > On 5/2/23 10:15 AM, David Hildenbrand wrote: > > On 02.05.23 16:04, Jason Gunthorpe wrote: > >> On Tue, May 02, 2023 at 03:57:30PM +0200, David Hildenbrand wrote: > >>> On 02.05.23 15:50, Jason Gunthorpe wrote: > >>>> On Tue, May 02, 2023 at 03:47:43PM +0200, David Hildenbrand wrote: > >>>>>> Eventually we want to implement a mechanism where we can dynamically pin in response to RPCIT. > >>>>> > >>>>> Okay, so IIRC we'll fail starting the domain early, that's good. And if we > >>>>> pin all guest memory (instead of small pieces dynamically), there is little > >>>>> existing use for file-backed RAM in such zPCI configurations (because memory > >>>>> cannot be reclaimed either way if it's all pinned), so likely there are no > >>>>> real existing users. > >>>> > >>>> Right, this is VFIO, the physical HW can't tolerate not having pinned > >>>> memory, so something somewhere is always pinning it. > >>>> > >>>> Which, again, makes it weird/wrong that this KVM code is pinning it > >>>> again :\ > >>> > >>> IIUC, that pinning is not for ordinary IOMMU / KVM memory access. It's for > >>> passthrough of (adapter) interrupts. > >>> > >>> I have to speculate, but I guess for hardware to forward interrupts to the > >>> VM, it has to pin the special guest memory page that will receive the > >>> indications, to then configure (interrupt) hardware to target the interrupt > >>> indications to that special guest page (using a host physical address). > >> > >> Either the emulated access is "CPU" based happening through the KVM > >> page table so it should use mmu_notifier locking. > >> > >> Or it is "DMA" and should go through an IOVA through iommufd pinning > >> and locking. > >> > >> There is no other ground, nothing in KVM should be inventing its own > >> access methodology. > > > > I might be wrong, but this seems to be a bit different. > > > > It cannot tolerate page faults (needs a host physical address), so > > memory notifiers don't really apply. (as a side note, KVM on s390x > > does not use mmu notifiers as we know them) > > The host physical address is one shared between underlying firmware > and the host kvm. Either might make changes to the referenced page > and then issue an alert to the guest via a mechanism called GISA, > giving impetus to the guest to look at that page and process the > event. As you say, firmware can't tolerate the page being > unavailable; it's expecting that once we feed it that location it's > always available until we remove it (kvm_s390_pci_aif_disable). That is a CPU access delegated to the FW without any locking scheme to make it safe with KVM :\ It would have been better if FW could inject it through the kvm page tables so it has some coherency. Otherwise you have to call this "DMA", I think. How does s390 avoid mmu notifiers without having lots of problems?? It is not really optional to hook the invalidations if you need to build a shadow page table.. Jason