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 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 C3D06C4167B for ; Wed, 29 Nov 2023 09:39:47 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=08v8sk25FgGfvRriyzoKNLgKWtjqb6ZmFwe+Y4kSleM=; b=gGI+eOAORK/Au5 pkArx7bgunE8J6O261BGfK+au/vxz0oDhNCwIB4+eCCHBgb6bBTjuYwU+JtwKBgWrmwKE9TqM28BM KJ+ozNks9jTwWTbsVSscT1OeBQIq1EAUWX62yVdHjsy9AjK3/rcM/FcZCO911LUh+A3OdjXf2MVFF 9HSxWS+dtNrQRgVczn2YiSMQ1BzrPluv8T7yIH/H10HYirerdVxbUSI+Vzil/x3pRo1yaOnUaVnqT zejFYoJs4LHRghVYLY28ZRKnsUOC9PseRWr50kBBlzXS7Hu6ptVPFQ6As4xaISpUY7H0W8QVBzbU1 7VSDk1r5Gccey9qVZQ2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8H2M-007hXz-0j; Wed, 29 Nov 2023 09:39:18 +0000 Received: from mail.ozlabs.org ([2404:9400:2221:ea00::3] helo=gandalf.ozlabs.org) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8H2G-007hQb-0k for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2023 09:39:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1701250743; bh=vsrPdG817FSeXCk8MleL83TvHrXPh57pIp04z21H6/U=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=myoOwtYnCMYNkSic9zkY8PttdYTgpbf4PL7ltVmiCcjFDDHamvpvFsbPNb5ijDUmL /TpbvQtdmVfVWR+njBWEGRP92NjOV5+MZQaX+tT89yOGy8xnklIfEunWGvAO7qhC8O gT3a7LpOh5roXxVSpgc34BoYlbs1qN2ZqeqB+tkQi/cq/vRGIdQ6gtBxxE68+B6k4i bYNiLeavOIdFfO73cqyMi9+84hbh5vDQJZlxxEqHgEVKoICfhApON15kYD+5UgsOr+ 89EIItQ+H6NgAGLE4Ijuygow0sOrow+YyHqye6OErP4sEbng//26tIroIU1W0W/3dG Dt/Jm7l9QS0Ow== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4SgDmP5ZxZz4xSy; Wed, 29 Nov 2023 20:39:01 +1100 (AEDT) From: Michael Ellerman To: Sean Christopherson Cc: Paolo Bonzini , Jason Gunthorpe , Alexander Gordeev , Christian Borntraeger , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dave Hansen , David Hildenbrand , Janosch Frank , Vasily Gorbik , Heiko Carstens , "H. Peter Anvin" , Claudio Imbrenda , James Morse , kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Marc Zyngier , Ingo Molnar , Nicholas Piggin , Oliver Upton , Suzuki K Poulose , Sven Schnelle , Thomas Gleixner , Will Deacon , x86@kernel.org, Zenghui Yu Subject: Re: Ping? Re: [PATCH rc] kvm: Prevent compiling virt/kvm/vfio.c unless VFIO is selected In-Reply-To: References: <0-v1-08396538817d+13c5-vfio_kvm_kconfig_jgg@nvidia.com> <87edgy87ig.fsf@mail.lhotse> Date: Wed, 29 Nov 2023 20:38:54 +1100 Message-ID: <875y1k3nm9.fsf@mail.lhotse> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231129_013912_638460_CDF91FC3 X-CRM114-Status: GOOD ( 26.25 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Sean Christopherson writes: > On Fri, Nov 10, 2023, Michael Ellerman wrote: >> Jason Gunthorpe writes: >> > There are a bunch of reported randconfig failures now because of this, >> > something like: >> > >> >>> arch/powerpc/kvm/../../../virt/kvm/vfio.c:89:7: warning: attribute declaration must precede definition [-Wignored-attributes] >> > fn = symbol_get(vfio_file_iommu_group); >> > ^ >> > include/linux/module.h:805:60: note: expanded from macro 'symbol_get' >> > #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak,visibility("hidden"))); &(x); }) >> > >> > It happens because the arch forces KVM_VFIO without knowing if VFIO is >> > even enabled. >> >> This is still breaking some builds. Can we get this fix in please? >> >> cheers >> >> > Split the kconfig so the arch selects the usual HAVE_KVM_ARCH_VFIO and >> > then KVM_VFIO is only enabled if the arch wants it and VFIO is turned on. > > Heh, so I was trying to figure out why things like vfio_file_set_kvm() aren't > problematic, i.e. why the existing mess didn't cause failures. I can't repro the > warning (requires clang-16?), but IIUC the reason only the group code is problematic > is that vfio.h creates a stub for vfio_file_iommu_group() and thus there's no symbol, > whereas vfio.h declares vfio_file_set_kvm() unconditionally. That warning I'm unsure about. But the final report linked in Jason's mail shows a different one: In file included from arch/powerpc/kvm/../../../virt/kvm/vfio.c:17: include/linux/vfio.h: In function 'kvm_vfio_file_iommu_group': include/linux/vfio.h:294:35: error: weak declaration of 'vfio_file_iommu_group' being applied to a already existing, static definition 294 | static inline struct iommu_group *vfio_file_iommu_group(struct file *file) | ^~~~~~~~~~~~~~~~~~~~~ Which is simple to reproduce, just build ppc64le_defconfig and then turn off CONFIG_MODULES (I'm using GCC 13, the report is for GCC 12). > Because KVM is doing symbol_get() and not taking a direct dependency, the lack of > an exported symbol doesn't cause problems, i.e. simply declaring the symbol makes > the compiler happy. > > Given that the vfio_file_iommu_group() stub shouldn't exist (KVM is the only user, > and so if I'm correct the stub is worthless), what about this as a temporary "fix"? > > I'm 100% on-board with fixing KVM properly, my motivation is purely to minimize > the total amount of churn. E.g. if this works, then the only extra churn is to > move the declaration of vfio_file_iommu_group() back under the #if, versus having > to churn all of the KVM Kconfigs twice (once now, and again for the full cleanup). Fine by me. > diff --git a/include/linux/vfio.h b/include/linux/vfio.h > index 454e9295970c..a65b2513f8cd 100644 > --- a/include/linux/vfio.h > +++ b/include/linux/vfio.h > @@ -289,16 +289,12 @@ void vfio_combine_iova_ranges(struct rb_root_cached *root, u32 cur_nodes, > /* > * External user API > */ > -#if IS_ENABLED(CONFIG_VFIO_GROUP) > struct iommu_group *vfio_file_iommu_group(struct file *file); > + > +#if IS_ENABLED(CONFIG_VFIO_GROUP) > bool vfio_file_is_group(struct file *file); > bool vfio_file_has_dev(struct file *file, struct vfio_device *device); > #else > -static inline struct iommu_group *vfio_file_iommu_group(struct file *file) > -{ > - return NULL; > -} > - > static inline bool vfio_file_is_group(struct file *file) > { > return false; That fixes the build for me. Tested-by: Michael Ellerman cheers _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel