Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp3085776rdb; Fri, 22 Sep 2023 18:56:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfjsyENIbyK35rxYM8SDAFoKczPOEuR0/PcdY/VTqyDB/mlfingbenFkJGJVTMVnFwsONr X-Received: by 2002:a05:6358:341b:b0:133:a8e:6feb with SMTP id h27-20020a056358341b00b001330a8e6febmr1446997rwd.12.1695434174495; Fri, 22 Sep 2023 18:56:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695434174; cv=none; d=google.com; s=arc-20160816; b=kYe+/EMaA5tZR3fuSz+ygR3lfJD976Mrt2/Vvgql6A5GqHlAimupe2gg9FDrvl4JhT QNn/pJHdzf9ViHNFSn3zXvXQG1kXXkk3n+ZYfRt+2eUc+cjWWRufkJPoE4CsqklUOEYM v3n9eLqlTKUFrl8G4yVc/esolztsEwpzwuIhRPK6pZO83ycxKV39Emdx3r8Nt8BzH9O4 wuHqkaS4GimZskxedM8MakjCXbts65+A/vhUURWiW2inesG1NFPUwLk+QobIyX1m8Y/L AQqtzqnaL4kvqQISoOHU0GNf4ynOU2XdcOVYd74t+aR9+e0k+oaH59sKKyLnTNcBqE9H Vcag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+8rKKRCqUyQLWkNEBe6s/yUPdVExxmOivIwMSOHwl/8=; fh=aJf+Ab2DvLiu70HFbcC8kKH8+hnan0+zoD3jBMniAHA=; b=WGAG26PFIXtpnLBJxtnzHGoABlzsMPwVRx90Kolqwun9i3L1AdD55W+f3R/G4hlqPq 0RPX2ekpqaXnREXXBAiHRD5G7/DIKFRXPvspoUVnbG7JQuOTZV5QHXlO0+sfAV4i/TE8 gcgZB9cO/HnlwjGXN//ooOac7bqyAWo04pVuexFqTM2X++CF6/8KDQ3CQUyQmNgbXyw2 oMtNDrne+oCTUpHuYb/vTW9arQzkUoFtgVSYTQS9Ggl+nFqCtAFWq7B9LjsVpLXOYxaZ JrI/7I1mbYQtcwVngMp2QPZ+VpJkRv+awff/rtQR3vXXU5BbNA8IcKdHzw8KMN2zeGgk +3uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=esoDGfRl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id na7-20020a17090b4c0700b0026f4d1e6940si8145803pjb.160.2023.09.22.18.56.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 18:56:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=esoDGfRl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 68E0282A2DB8; Fri, 22 Sep 2023 16:33:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230335AbjIVXdT (ORCPT + 99 others); Fri, 22 Sep 2023 19:33:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230301AbjIVXdS (ORCPT ); Fri, 22 Sep 2023 19:33:18 -0400 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33AFD19E for ; Fri, 22 Sep 2023 16:33:12 -0700 (PDT) Received: by mail-yb1-xb31.google.com with SMTP id 3f1490d57ef6-d81adf0d57fso3544933276.1 for ; Fri, 22 Sep 2023 16:33:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1695425591; x=1696030391; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=+8rKKRCqUyQLWkNEBe6s/yUPdVExxmOivIwMSOHwl/8=; b=esoDGfRl/b0lsZuxZqaRrYraARBiayqHpUe+1x1yIM+09U9/+s4SX6cG1M2z1pJYuy hPXB7axJccYjMv+suop2/Psr+t93JN2nLx10dKL16wLbLSCcO0gq3bwqv3ubUomhT1z2 NnioXkKNMfgqqsg9MOZphrAv7nqiAQiDGdLNOYckooj3s+wYOYGmqMHYuI0eBqgGiSA4 MURQboZHOzR7Q5mRwaiigJ+Bc66mxgeMZ8cL7nUIO3NH8ydSJqP+BZ6leGSDHQ8iJhPq 7TMF2rwq7WRHLbIRP81/7dRbe339HmOjK37FP63DiEQ5FbiYcqk3fNyHgl1Sj4QtUDOp QKNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695425591; x=1696030391; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+8rKKRCqUyQLWkNEBe6s/yUPdVExxmOivIwMSOHwl/8=; b=agt0xvlefms4f3BWwwxhY88P4rmRZcLcS5RDQ3rMgQ8Ij1pA+Y+YmcgLhGCHCqDpG5 uaU0YE+iEv7Z/YNn7oEISmGGzrtIAh79mVCoW1IEzPqYAD4BRoaQA9sMQ31qIrVH6Otp ya6Vahuf7oF3Pw+3BCshYluGuTkprjJWw4ytYsUIRLrRXqRHXqUsStGSNbRfekk944w5 yWCKRGYiHPiKdpO9yMG69W08QaIxitWCcydvPUfGVC47p6KBm1prUYA18bI++FMhXz5q KkK7Nbkk2F+BSGVoKtXmNn86XzYaZ4MhsgZvbP1rR7EWohGRSdhOXJWsdQewTdSb1d6n rS8g== X-Gm-Message-State: AOJu0Yy8wZSVmX1CmfWuNbO7JFccx6yxJhLA21gh/hyHpwbSlCDDZ9Eg kkuvrXkz1hVpJjfntuHKD/lmBLi1IfZB5MYd8m0= X-Received: by 2002:a25:dbcc:0:b0:d81:4168:3a83 with SMTP id g195-20020a25dbcc000000b00d8141683a83mr680844ybf.25.1695425591345; Fri, 22 Sep 2023 16:33:11 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-26-201.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.26.201]) by smtp.gmail.com with ESMTPSA id i15-20020a0cf10f000000b0064f523836fdsm1838074qvl.123.2023.09.22.16.33.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 16:33:10 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1qjpe1-000eFO-UF; Fri, 22 Sep 2023 20:33:09 -0300 Date: Fri, 22 Sep 2023 20:33:09 -0300 From: Jason Gunthorpe To: Robin Murphy Cc: Jean-Philippe Brucker , Niklas Schnelle , Joerg Roedel , Will Deacon , virtualization@lists.linux-foundation.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] iommu/virtio: Make use of ops->iotlb_sync_map Message-ID: <20230922233309.GI13795@ziepe.ca> References: <20230918-viommu-sync-map-v2-0-f33767f6cf7a@linux.ibm.com> <20230918-viommu-sync-map-v2-1-f33767f6cf7a@linux.ibm.com> <20230919081519.GA3860249@myrica> <20230919144649.GT13795@ziepe.ca> <20230922075719.GB1361815@myrica> <20230922124130.GD13795@ziepe.ca> <900b644e-6e21-1038-2252-3dc86cbf0a32@arm.com> <20230922162714.GH13795@ziepe.ca> <123c53c3-d259-9c20-9aa6-0c216d7eb3c0@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <123c53c3-d259-9c20-9aa6-0c216d7eb3c0@arm.com> X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 22 Sep 2023 16:33:25 -0700 (PDT) X-Spam-Level: ** On Fri, Sep 22, 2023 at 07:07:40PM +0100, Robin Murphy wrote: > virtio isn't setting ops->pgsize_bitmap for the sake of direct mappings > either; it sets it once it's discovered any instance, since apparently it's > assuming that all instances must support identical page sizes, and thus once > it's seen one it can work "normally" per the core code's assumptions. It's > also I think the only driver which has a "finalise" bodge but *can* still > properly support map-before-attach, by virtue of having to replay mappings > to every new endpoint anyway. Well it can't quite do that since it doesn't know the geometry - it all is sort of guessing and hoping it doesn't explode on replay. If it knows the geometry it wouldn't need finalize... > > What do you think about something like this to replace > > iommu_create_device_direct_mappings(), that does enforce things > > properly? > > I fail to see how that would make any practical difference. Either the > mappings can be correctly set up in a pagetable *before* the relevant device > is attached to that pagetable, or they can't (if the driver doesn't have > enough information to be able to do so) and we just have to really hope > nothing blows up in the race window between attaching the device to an empty > pagetable and having a second try at iommu_create_device_direct_mappings(). > That's a driver-level issue and has nothing to do with pgsize_bitmap either > way. Except we don't detect this in the core code correctly, that is my point. We should detect the aperture conflict, not pgsize_bitmap to check if it is the first or second try. Jason