Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp228475rdb; Mon, 18 Sep 2023 13:11:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEMUfHCNdKQRrtHfe/NHpXzDIXDe0LLz/9cqahYOZAH2Z9UrSNdN84W1aE+tMFjiBnX3lt X-Received: by 2002:a05:6a20:734c:b0:140:cb66:73aa with SMTP id v12-20020a056a20734c00b00140cb6673aamr13444397pzc.3.1695067919321; Mon, 18 Sep 2023 13:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695067919; cv=none; d=google.com; s=arc-20160816; b=eIJ2hcUVJrhcBi5Y168hSKTHTOICw6nqWFVilD14SDh2YavvWKBdQWYbkfvn6hq0wu ph1iG+QpTrXCaz/yWik6YNfRa3Yambd7Hkh5ayX4nRPoNzNYfGD1A9Ru+MsK0T7EY6DK P1XcDZTQYpCgQ8RQdA4Zgqga64rbDgSduyW8h7utabgFBbex0dlxZm8RQca+P+zu9KpU GLs69rBNdGpBmux6EVslEH1p+FCS9CxGg3kRT0DIHlRHv9d4DUSZ0WAMoTDlyjJWxb5T fwoux3dVS5fzx6sfh7p95JQ6JZrTdj+dVmcEuXRYRv6/474GM85Ussu24iBcOKqBRRIF W6rg== 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=1AtaBW2SsBllDiJ99v10Ny7HNDE5iUEtI8mOBYM/rVQ=; fh=LvR0iFQNUCFuLf0e0dfpbwu/ZRO+ihf5gBz7bBaQp/0=; b=WSfbFVuilmnz/AsiRGanlHmf2eJHWbaiWRWgNW3ItoKn0GKQnGBZMqAeWBbIaZBPYw AEbRslS/MMG4UshzUGQDMYTmWEYqbRIUtITrdL+WMdQVMU+q3SpAbTjq3n+FrytH6dmI t3cifNIpVJozP+YvVjAeofPp0ipDSvAqg4MvTdS79Dna/pk6XsLureTi9FemRld2w/ex lsZ/mN6UDRc+WMNAmN4DHeuAZn1L2iZkQEN8EZA+l79wuXm74oHW4njgvjXfZI1V5KA2 K8tE28XbYzQI3C68h8OnGB7RgMJIjDuUGr7bS6shoBNra8gpe35lLNKglD5f1+t1skqX 60mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=d9w1x2Da; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id j191-20020a6380c8000000b00578afd89baasi158688pgd.744.2023.09.18.13.11.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 13:11:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=d9w1x2Da; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 78DAA80CD70F; Mon, 18 Sep 2023 09:21:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229771AbjIRQVH (ORCPT + 99 others); Mon, 18 Sep 2023 12:21:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbjIRQUg (ORCPT ); Mon, 18 Sep 2023 12:20:36 -0400 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CA404C25 for ; Mon, 18 Sep 2023 09:10:01 -0700 (PDT) Received: by mail-qv1-xf33.google.com with SMTP id 6a1803df08f44-65631aa8b93so21259496d6.3 for ; Mon, 18 Sep 2023 09:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1695053400; x=1695658200; 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=1AtaBW2SsBllDiJ99v10Ny7HNDE5iUEtI8mOBYM/rVQ=; b=d9w1x2DafiFWS1X+tXpeHKZyk+0zrDy4/DOPTAbRW1eQlyABQj+3gJRwYAvYxomyJX W0Wdc/6urVKFdO58XqHZRgaRMKo7PvMvb8xf6zSftKjAvo4IKrZAJLKUiZf8jBLHeqbM QKKmwreOa45F3Xhwn//4xTHXTAbzSZLKM5jwqgam+8RVUxsf73JBmmd0iI6jRA+DvbTF lXZAX0jMitLfWT5zHhXCKvpWo/YDgtrDDbbYto0VQpFmytRtTKhmtYdh+z3TC8ZUQDPr lxl4IUxRdoD9Qk0FR2NHs1dT2vKekO/NRUKzEvIbormZ022mVs3J1F7qOX7GWTyQyvqo 2RpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695053400; x=1695658200; 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=1AtaBW2SsBllDiJ99v10Ny7HNDE5iUEtI8mOBYM/rVQ=; b=qXQW80i0uYhehMvptXk70WniZOuDzlurH9hvzHeWbpG3XOsKHewYOQbVjJ98K92xwc rmNy1vJt+F0+72qQU6A0rMk5ytY/2CQz5GE2UhciPL6WaqfWaMdVaToKnP2yyRTAcTfE ckHUcXYKUeRabubdP28evHfbbRoVuErh0cVX6EccSrjwuFVBj93fi+gaG9mUKtCEjXaF HCh/nLSTWndulPqXrifPO9YVZLp/0tLaOOQmLLQu0a7xdfab6W69hB3SHZHj+lQHO+I5 eOIkkUJlGTus/K66zjBKo6P93Noin31q8oKFtzrAEBXngsIAev1/LMfRUqk1D525aGSG zplw== X-Gm-Message-State: AOJu0Yx3+nWSKrhBnonBmJiGrd/38D096H6Eg3Iw3HTBMoG2rgigFs8t xcjRupfLyxbTsiUr6ghXTfCtS8kcD6FWfV8xH/0= X-Received: by 2002:a0c:eacf:0:b0:655:78f5:bef7 with SMTP id y15-20020a0ceacf000000b0065578f5bef7mr9471806qvp.21.1695052995341; Mon, 18 Sep 2023 09:03:15 -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 u20-20020a0cdd14000000b006581e82a628sm989437qvk.134.2023.09.18.09.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 09:03:14 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1qiGiA-0005k6-DG; Mon, 18 Sep 2023 13:02:58 -0300 Date: Mon, 18 Sep 2023 13:02:58 -0300 From: Jason Gunthorpe To: Sean Christopherson Cc: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton Subject: Re: [PATCH 05/26] vfio: KVM: Pass get/put helpers from KVM to VFIO, don't do circular lookup Message-ID: <20230918160258.GL13795@ziepe.ca> References: <20230916003118.2540661-1-seanjc@google.com> <20230916003118.2540661-6-seanjc@google.com> <20230918152110.GI13795@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 18 Sep 2023 09:21:14 -0700 (PDT) On Mon, Sep 18, 2023 at 08:49:57AM -0700, Sean Christopherson wrote: > On Mon, Sep 18, 2023, Jason Gunthorpe wrote: > > On Fri, Sep 15, 2023 at 05:30:57PM -0700, Sean Christopherson wrote: > > > Explicitly pass KVM's get/put helpers to VFIO when attaching a VM to > > > VFIO instead of having VFIO do a symbol lookup back into KVM. Having both > > > KVM and VFIO do symbol lookups increases the overall complexity and places > > > an unnecessary dependency on KVM (from VFIO) without adding any value. > > > > > > Signed-off-by: Sean Christopherson > > > --- > > > drivers/vfio/vfio.h | 2 ++ > > > drivers/vfio/vfio_main.c | 74 +++++++++++++++++++--------------------- > > > include/linux/vfio.h | 4 ++- > > > virt/kvm/vfio.c | 9 +++-- > > > 4 files changed, 47 insertions(+), 42 deletions(-) > > > > I don't mind this, but Christoph had disliked my prior attempt to do > > this with function pointers.. > > > > The get can be inlined, IIRC, what about putting a pointer to the put > > inside the kvm struct? > > That wouldn't allow us to achieve our goal, which is to hide the details of > "struct kvm" from VFIO (and the rest of the kernel). > What's the objection to handing VFIO a function pointer? Hmm, looks like it was this thread: https://lore.kernel.org/r/0-v1-33906a626da1+16b0-vfio_kvm_no_group_jgg@nvidia.com Your rational looks a little better to me. > > The the normal kvm get/put don't have to exported symbols at all? > > The export of kvm_get_kvm_safe() can go away (I forgot to do that in this series), > but kvm_get_kvm() will hang around as it's needed by KVM sub-modules (PPC and x86), > KVMGT (x86), and drivers/s390/crypto/vfio_ap_ops.c (no idea what to call that beast). My thought would be to keep it as an inline, there should be some way to do that without breaking your desire to hide the bulk of the kvm struct content. Like put the refcount as the first element in the struct and just don't ifdef it away?. Jason