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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D133C46CA1 for ; Mon, 18 Sep 2023 16:18:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230183AbjIRQSn (ORCPT ); Mon, 18 Sep 2023 12:18:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230152AbjIRQS1 (ORCPT ); Mon, 18 Sep 2023 12:18:27 -0400 Received: from mail-oi1-x24a.google.com (mail-oi1-x24a.google.com [IPv6:2607:f8b0:4864:20::24a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 224993A8F for ; Mon, 18 Sep 2023 09:02:25 -0700 (PDT) Received: by mail-oi1-x24a.google.com with SMTP id 5614622812f47-3ab7fb11711so7272225b6e.2 for ; Mon, 18 Sep 2023 09:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695052721; x=1695657521; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=sNXD76U7haNeW91VMZlpdLB8TVqFEiovhx95zes76gg=; b=t5mSXj+WYVvGCM7Bn13Zc0YrI90IgYKLjhJOy29Uzxlz4VjGWlWrgGGRHBUEI41Yix 09gsZgKz2yJUQRc4Z/ikMdA4dHELJS8CPcr8XQLa2tooiIKK40DoCjG4QZULgDBCL4ZX 1nTEoce1K+VByHmj8A5tnLnj6dv/U3+wOLkV3UYvR1+DIxAIqw/TCc7XmxTz1IrPxnDw Q20hOdIOLVIkbSCXux3ro+59Y8oHqqVJncd54y+8QTEHVFQXo1a/DlfJVwIID7usHWD2 8EDaXU64SJaG52yrcosMnupQ7IrtWaiIy7g8dT86FCNF/xgOg4zN4U2heze/VgxmAP2t c1jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695052721; x=1695657521; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sNXD76U7haNeW91VMZlpdLB8TVqFEiovhx95zes76gg=; b=sGK6dl3oowjHA3XCjU+DFhx52BkYUKgzg6aEYr4bebQo+MkqlC8Fo3FZI0asXc5o2Q 4FrJY5lwI7aEF1hL1fEBBTG30kgXmy0k43V670WjFGQwhwbK+lSRkIpw6e0m5KL0qxJT 8wQu50TiF0P8wy+6HU1c30dR23NgCfVYQZHdVrT0r+jvlHfyjJ+K8rZVELk49Nm9vEvM LFL2ScnglmHRHAEzMub5dBJPJLobg5Ch9vn5VVhlWALWk9j3nEO+q40By8RdhPQ5Ed/M HPyu2KJTm+vvXpFY3gRIFmJr4i7JSnG3nr2Dkpf+HsvSQZCMgvLmKgfk7MbfwlgWn3qk 36FQ== X-Gm-Message-State: AOJu0YxPVr4iTnIBzL15lJ54KKkXvNu/IpYnQycI7pq9aMl9HoE3JL4h F5VecmUlApnvBSXbnyZ/qPsZ2v8gmH4= X-Google-Smtp-Source: AGHT+IE1DPoRp0N2nDleDeL+nMknRqhKzdJCPwHMJrwMUBjkYLBNjcfJz91+ASKxJdGzFGGlGgloaP/fXoU= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:2411:0:b0:d81:78ec:c403 with SMTP id k17-20020a252411000000b00d8178ecc403mr192905ybk.12.1695052199184; Mon, 18 Sep 2023 08:49:59 -0700 (PDT) Date: Mon, 18 Sep 2023 08:49:57 -0700 In-Reply-To: <20230918152110.GI13795@ziepe.ca> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> <20230916003118.2540661-6-seanjc@google.com> <20230918152110.GI13795@ziepe.ca> Message-ID: Subject: Re: [PATCH 05/26] vfio: KVM: Pass get/put helpers from KVM to VFIO, don't do circular lookup From: Sean Christopherson To: Jason Gunthorpe 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 Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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? > 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). Gah, KVMGT doesn't actually need to call get/put, that can be handled by kvm_page_track_register_notifier(). I am planning on making exports for sub-modules conditional on there actually being submodules, so that's 2 of the 3 gone, but tackling the s390 crypto driver is an entirely different story.