From patchwork Sat Sep 16 00:30:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13387982 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 50577CD37B0 for ; Sat, 16 Sep 2023 00:32:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tFEmZ9K50OtNsAsQdcz70otBJZoJJFXnHK95glXKq74=; b=3P+MXQuhpsN2/Y AszOulv5C9f2tiiqClKpnu691yQMYAO1ro/VqaGCC2RiLDB0iM9kYHOXwJBcRP7HgFB891/WkZjcG 33k3ZHsGAhcQPPxtmLGQwMWUL3gfDCPo+dQ5IEHybL7TaR6sKY8GebVin8napC2MO+HSYCA+TVQ4t yxXWMLbUORNMuRdCXZY2z9fVTEzV+wH1cDceSLKRBqcYWXWWmV+v+NidQkA+uSj5v4FvyK8HO4X/D 9XJfMsm00jO3D73Ipm9z7I8d6O6E3sPpxKPSJdPs8ZCZeB/BI8IqyUicYWvtnX0vqs8B92s6a6Hv2 d/RChsKfPu5tQQW82Ryg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDw-00Bclk-1F; Sat, 16 Sep 2023 00:31:48 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDc-00BcOw-0G for linux-arm-kernel@lists.infradead.org; Sat, 16 Sep 2023 00:31:31 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d7e79ec07b4so3171275276.0 for ; Fri, 15 Sep 2023 17:31:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824286; x=1695429086; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=nWWn+h7amRZMBDw3vQNPHGAGWvxVaFdsCPW0ONMozkY=; b=Au/whQJEbAz+tOQ0jTzYnTHaUFqhk5Pgnrngt42R++heKHXOJ2U0YqnWh0A650p1pa PgbaR8YETO7ZKMYj3h4ONGnm912OY1X6nLqjUcHYZw2SCfppPlE9QI2MsrQBEt75JnUC id4P01cAv4bW2aLSS66YB0WfN9NrUSsO4HoyRU+POe5EIZ7yVc+3t4OXLj8PN8fDq6JE c1c2P6OXojAgG+hgLNLnSW9HWM9GkahkdPQXAfN7FUfYqpv0WvPKm9erEu/ZABleqTqp zYfI7WBh8dzi1TGBAWipfQzZdZFRePBIBZjwqD125053Cb0+8X4DsgJKIjfE45v20PE2 j8FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824286; x=1695429086; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nWWn+h7amRZMBDw3vQNPHGAGWvxVaFdsCPW0ONMozkY=; b=fAaSn4H79J79wb+yTbLxQKdowkMaPykfXyze7bdDAS9z7M5fAlQ4sn6y2I81emH7an BEeIPgCPz96XCeDnhVFEugsWTfXpSwrC2W1RKS13oyvsZyTchd5jar0THIwJgpc3qGCu c6+9XqiDoprrkVuk8AN1jdqKc9stQqJXkhQ6H4+SxXZ046repdjgFZCzfjczgmpD/sE3 f+G8ZcJglEOPQ2aE1a3tsRQLFB4r6do/RewgYeTXn9GiI4TODGFWGMJtnm6xn08kLQ71 DBEhtB702NHTvv6uodV8uR+g/X1qcWi0cu+DdU1+PQKdoUfUTFYPBEerBwQeuh0EDiPg Qssw== X-Gm-Message-State: AOJu0Yytqi4tp2470yrlDAu0KCBe3vqHPjx06w3mDWhyxYu2xmDe2jp9 1IF3OU+wEmpSoZZbG+2txLEcufzOIyE= X-Google-Smtp-Source: AGHT+IEq7PdKxRZn76T8dxJekIJKystQKt2vwlGFVVGJbIP+fTzk72beaUliTqaKSj/nh0feFGYdLVI2swc= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:98b:b0:d81:5948:970 with SMTP id bv11-20020a056902098b00b00d8159480970mr72987ybb.13.1694824286666; Fri, 15 Sep 2023 17:31:26 -0700 (PDT) Date: Fri, 15 Sep 2023 17:30:55 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-4-seanjc@google.com> Subject: [PATCH 03/26] virt: Declare and define vfio_file_set_kvm() iff CONFIG_KVM is enabled From: Sean Christopherson To: 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 , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_173128_122333_88717A63 X-CRM114-Status: GOOD ( 13.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hide vfio_file_set_kvm() and its unique helpers if KVM is not enabled, nothing else in the kernel (or out of the kernel) should be using a KVM specific helper. Signed-off-by: Sean Christopherson Reviewed-by: Jason Gunthorpe Reviewed-by: Alex Williamson --- drivers/vfio/vfio_main.c | 2 +- include/linux/vfio.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c index 6368eed7b7b2..124cc88966a7 100644 --- a/drivers/vfio/vfio_main.c +++ b/drivers/vfio/vfio_main.c @@ -1352,7 +1352,6 @@ void vfio_device_put_kvm(struct vfio_device *device) clear: device->kvm = NULL; } -#endif static void vfio_device_file_set_kvm(struct file *file, struct kvm *kvm) { @@ -1388,6 +1387,7 @@ void vfio_file_set_kvm(struct file *file, struct kvm *kvm) vfio_device_file_set_kvm(file, kvm); } EXPORT_SYMBOL_GPL(vfio_file_set_kvm); +#endif /* * Sub-module support diff --git a/include/linux/vfio.h b/include/linux/vfio.h index 454e9295970c..e80955de266c 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -311,7 +311,9 @@ static inline bool vfio_file_has_dev(struct file *file, struct vfio_device *devi #endif bool vfio_file_is_valid(struct file *file); bool vfio_file_enforced_coherent(struct file *file); +#if IS_ENABLED(CONFIG_KVM) void vfio_file_set_kvm(struct file *file, struct kvm *kvm); +#endif #define VFIO_PIN_PAGES_MAX_ENTRIES (PAGE_SIZE/sizeof(unsigned long))