Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp122163rdb; Mon, 18 Sep 2023 09:50:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGF/QascSYzLOMvw3JJ2W/w7cLCoxfP5NZt7prGnviJJFi8Yj8Bw+FVyKJcOYgAUhSeKzjl X-Received: by 2002:a17:90a:9b02:b0:26d:4ab3:fe11 with SMTP id f2-20020a17090a9b0200b0026d4ab3fe11mr6973474pjp.24.1695055820456; Mon, 18 Sep 2023 09:50:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695055820; cv=none; d=google.com; s=arc-20160816; b=KHmqtaER7kW6Ne3nbiolKSG7cwMAkM0RJXW9HTAkTi45zR5pIVS5ZcQw/na6WFjyOW VHXiV0+0TlqJKKN4YUYiN0H42Hxtnxc4fx9vGY/3a8yr2xntU2P9VJYxsO31AZ5lIKv5 eJasE1p9j9KiVftgo+rMCJJ5u9LjfbIZf3Ta7CIvU7d4WRuosT45dgGk+iOCzLjLPG8/ 6No7SLhATf9qP1GTlTtrLHmgipXp+CmZppuqa0gtPRZ1K2IqTGOgMAHrLn5Pv9a5CxMH 2ci22VBRVIGcy2rUzE46h92ZChrwky5OhSDurb8puuQLpRuLilBM3U0rCQErU7WwuIb8 hFJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=sNXD76U7haNeW91VMZlpdLB8TVqFEiovhx95zes76gg=; fh=AghDzVtIMQbD5leC+cJqzX02jv06w/vPh/87V9gVQzM=; b=jsi2+1w/dzqblnUKeQtux34pAJ+FQxXkYqaRP/bDugkGr39UCwJim9geWHel5SQN9O KEcU2ch0xEUQC2i9I3RN+ln4BzSG9Ljf7L8kgkSUQjwO1RcAE30qyPLO+imbcRZ5OxIx MjegwLx7rBXKKn60MmmLV1ms1L0r2Hld4OAU0vxLQ4vUUDXrqXlgA45CVqsljduuU2LN sDfsV0JNAHDOK4DzNKDs/em8deKG8PdunfzUzCHbUAMMUdLAH5v6+aWcF5fZtpm5JFhg uLUoxeyv9iM5My2C39erlHymqkQhRtZNas/gkalUgY7SUv9iT2S5t9uoiBexbBJMjHOb 2w1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=XT4hOZ7j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id k22-20020a17090a591600b00271a453203esi10256349pji.130.2023.09.18.09.50.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 09:50:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=XT4hOZ7j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 51D608099CC0; Mon, 18 Sep 2023 09:36:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230352AbjIRQfy (ORCPT + 99 others); Mon, 18 Sep 2023 12:35:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229954AbjIRQfa (ORCPT ); Mon, 18 Sep 2023 12:35:30 -0400 Received: from mail-ot1-x34a.google.com (mail-ot1-x34a.google.com [IPv6:2607:f8b0:4864:20::34a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE43E11A for ; Mon, 18 Sep 2023 09:19:37 -0700 (PDT) Received: by mail-ot1-x34a.google.com with SMTP id 46e09a7af769-6c46114573fso39839a34.3 for ; Mon, 18 Sep 2023 09:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695053977; x=1695658777; 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=XT4hOZ7jBUJ/HmcWfgW+s/dDRbl/7htOsH2NkGps9qE5Z1ImL49wk4xDD15aoBNCx0 qvLbAHeM4e2Y5QGFdnG9zCcH5IK8nhEqK5t8ExM8pC9PkyGSEiCbBiFWQVEwMuo1YWwM AEst/M0v7L+JEiRalzoSRENagMo52/t23h6rqIN0KHUxh+uQ7jfoveu6eFgB+LzftNm5 aOIHWMdhzy/Ei/qRVCedE8R3VnYl9CQWE3HU9a2JC3y7g40XAuQ/wk2hEqa9EnkXHiZ/ jB5Z28H48T+jnfhYDG1akZ/StInGFYITYuOx+Uhn4/UE/84XXGyAUBUZ9df8mg3eAPIk z5oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695053977; x=1695658777; 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=X6taDowNfSpJw/vV8sy25Jpv6VOSakn4HPLnY0XJhmUsbZymKfDcfFmi+em4ozXyMl v3ZsCCoZaB6Im/AhjyWQysjlM6JFTV1szv3U6Aier234VuD1SuzIfgk85IJp9qGfVf7V Dr1wyJT0o7mRiJ+85kzIRn1JiZpwerwcyAXptdVMdL/zeXleCfnP3hP120NqpMaREf0I AdtpEkjJBDQiZrzl9VthoqkB2AdaJrFLEDXgq8RHG3DCGXy0MTfiHCpH6HXE5QZ5+XrZ iI2MUaFiJ+UqowXGRDlTgjtf9U2+ov/LG7Mcb0fhZuKYl/C+LOIalkyrKYwjqhcpT+3Q lkiQ== X-Gm-Message-State: AOJu0YwZYYNqXtHCqO7983JWzbaXl9E/a5zKt/WfwkOrRGhIl2oYHUx2 3RdOkdbVqQFdKAzAffN0iLRaxWzcxLE= 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" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 18 Sep 2023 09:36:21 -0700 (PDT) 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.