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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E38AAC46CA1 for ; Mon, 18 Sep 2023 15:50:58 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=pzJ/o8mW; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Rq8Qn43gtz3c8q for ; Tue, 19 Sep 2023 01:50:57 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=pzJ/o8mW; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--seanjc.bounces.google.com (client-ip=2607:f8b0:4864:20::b4a; helo=mail-yb1-xb4a.google.com; envelope-from=3p3eizqykdnooa6jf8ckkcha.8kihejqtll8-9arheopo.kvh67o.knc@flex--seanjc.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Rq8Pm2skVz3bZ1 for ; Tue, 19 Sep 2023 01:50:02 +1000 (AEST) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d8153284d6eso5253761276.3 for ; Mon, 18 Sep 2023 08:50:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695052199; x=1695656999; darn=lists.ozlabs.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=pzJ/o8mW7IunGPP9qVv0bFIiJZy6tpfBkOlUQlQfFg4mxIWPEPox0hsVHf+oLFsgtJ zPLIZRQCdOksxUtvPg2L4oPBbNTVAdiNDjM6cEnD05r3odUsFp1yzgBCDH0eWHjh1wk2 lO1umolrCukVPgtNfAYQ8LZ+7ce9UanMmJ98jqTjycDmPa/2ciNf3+0zISbEOtjjNA3+ fkj9HEiHsHN0zR54I2ltWugPPsq5WaphE9tFUIGqurt+X2dhYe7w6eXQULGPHlXVBi2e GJsAdAwZBK/VuGcd7xoX8UN8jCz9Honap4zTypuHPYSZM3+sPUGLtDGyBZ9tszpViEQn GTEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695052199; x=1695656999; 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=qF3kHv5Wqd/U2qpHa5DNdjn4PiTPueEyuachR0K06FuZEHmjKnJcD0Unu9lKYLt5Ix 6PjBZFepflPJJzgA8hfCXx+LyuW5fq/O6w5maFdRlgSzVfKMbF4gnNo7fWMpjccpxzlw xkX0aC3TYgEhzwKt/xFEf5hZIJrjJx1LH3mRu+wbZAvRgtfqiywve5Zw5jmKBr2ZkjMt jAi5GgG/ncWpDgiuCfN0xpCijBgNSwuW/h6sHZzmWbITnQuUeq7utcDaj120fvjRb0lf RXUzTKtP38WR30jgaZRLAeB9gFpyF6IxvSgCJkQNqcdBzYTiWSk7fgTNhFCT3wz3W3En Sv5w== X-Gm-Message-State: AOJu0YypD+8S/Bx8Lwnp5GjdrkS+BWjoSj1Zrn8lKrPkZE2tLcsnRRsk 73+mv87kK3qLbwha+GXBpWL5yJRoMvU= 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 Content-Type: text/plain; charset="us-ascii" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: x86@kernel.org, kvm@vger.kernel.org, Peter Zijlstra , Catalin Marinas , Dave Hansen , linux-kernel@vger.kernel.org, Alexander Gordeev , Claudio Imbrenda , Will Deacon , linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, Janosch Frank , Harald Freudenberger , Marc Zyngier , Huacai Chen , Halil Pasic , Andrew Thornton , Ingo Molnar , Christian Borntraeger , Jason Herne , Albert Ou , Vasily Gorbik , Venkatesh Srinivas , Heiko Carstens , Arnaldo Carvalho de Melo , Alex Williamson , Borislav Petkov , And y Lutomirski , Paul Walmsley , kvmarm@lists.linux.dev, Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Tony Krowiak , Anish Ghulati , linux-mips@vger.kernel.org, Oliver Upton , linux-perf-users@vger.kernel.org, Palmer Dabbelt , kvm-riscv@lists.infradead.org, Anup Patel , Paolo Bonzini , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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.