From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B5DB4CB41 for ; Thu, 30 Nov 2023 02:02:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="skm/gwk3" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-5ca2a6f07b6so8070657b3.2 for ; Wed, 29 Nov 2023 18:02:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701309730; x=1701914530; darn=lists.linux.dev; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=p5qGWsyuSpyUxVCjDr7Vtr3DU5QXEtFZRiCX/LhUA7Q=; b=skm/gwk3XUw/H5xoqSviVKmD3TnyuI1Hs+sG+eg+SE6OxgzXFOR41qECfD28s9QChg 4e6c5Fkf9cuIims/NJkpXhonUG3Uqk8ygJBf6yJu92BfVWhsNmNX7Z0XAKZdg7MapbQB zYi0Af8ooETm+MtcJbX7MsDS3A9/YhTvTaq/dUT5evqo5uuNaBhFJ8QkILuqWXJHcq2x j41f86mm6KZ95WSnT51PLXQQOtPkt012/2EBG2H3XJ1oVMn10zrZxfSN10e9HY5Dddtx vIXAqutW65K+8lN4Q0sU1/FqRf+lz/vld6VlhuJki9+WATbAisV+1dxrmM5JxtSghp0e b9gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701309730; x=1701914530; 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=p5qGWsyuSpyUxVCjDr7Vtr3DU5QXEtFZRiCX/LhUA7Q=; b=Lfpwbb8XMbuUSKvuy6IHR02mRlivNRMsylzBTHTEj5XhioRSRlNFynC+CtxShXXPUz wYsY8DNpxFI5SHmuLZom0WzgB+OT6V+CP5cF5BmMT+wswUCViY/V4GkCsg3BxDMx8LmI Z83qRqr5fF/hgq4WkHoupy5tY3x0k9UDgYrgCn7ZLrsd5JLxlUnm0wd0zEwzithtm5rp R2m+yTsrLobS/iYQXOSUdI7Uh2xytjaiwmIUcScVM/UL97g/92v2WlUVdQYvuspX/x8x uGlIvV2Ls+69rEfnrlPrSv7r/+GOR25Ysl+EXFmrBZqnQPVzIfLJYn5zLodAKBnF0bKO thzA== X-Gm-Message-State: AOJu0YyS9lZXK6gij7PY9s6EJ6eNfWFaL5Vathg+eWe0Aorg4vTgj8NT yyifWSvfvGAuKau5Jv2BTGeZO6uf8j8= X-Google-Smtp-Source: AGHT+IFFDXNizpZ3vuH6xJBBRUPvzbuvqFOYFoh+t1YBbvxwcXUL+r5zJu2BpTJXrcb2S71zCUhlon51++M= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:690c:ec5:b0:5ca:321f:a368 with SMTP id cs5-20020a05690c0ec500b005ca321fa368mr767996ywb.7.1701309730213; Wed, 29 Nov 2023 18:02:10 -0800 (PST) Date: Wed, 29 Nov 2023 18:02:08 -0800 In-Reply-To: <20231130011650.GD1389974@nvidia.com> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <0-v1-08396538817d+13c5-vfio_kvm_kconfig_jgg@nvidia.com> <87edgy87ig.fsf@mail.lhotse> <875y1k3nm9.fsf@mail.lhotse> <20231130011650.GD1389974@nvidia.com> Message-ID: Subject: Re: Ping? Re: [PATCH rc] kvm: Prevent compiling virt/kvm/vfio.c unless VFIO is selected From: Sean Christopherson To: Jason Gunthorpe Cc: Michael Ellerman , Paolo Bonzini , 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 Content-Type: text/plain; charset="us-ascii" On Wed, Nov 29, 2023, Jason Gunthorpe wrote: > On Wed, Nov 29, 2023 at 05:07:45PM -0800, Sean Christopherson wrote: > > On Wed, Nov 29, 2023, Michael Ellerman wrote: > > > 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. > > > > Ah, it's the same warning, I just missed the CONFIG_MODULES=n requirement. > > Oh, wait, doesn't that mean the approach won't work? IIRC doesn't > symbol_get turn into just &fn when non-modular turning this into a > link failure without the kconfig part? Yes, but it doesn't cause linker errors. IIUC, because the extern declaration is tagged "weak", a dummy default is used. E.g. on x86, this is what is generated with VFIO=y fn = symbol_get(vfio_file_is_valid); if (!fn) 0xffffffff810396c5 <+5>: mov $0xffffffff81829230,%rax 0xffffffff810396cc <+12>: test %rax,%rax whereas VFIO=n gets fn = symbol_get(vfio_file_is_valid); if (!fn) 0xffffffff810396c5 <+5>: mov $0x0,%rax 0xffffffff810396cc <+12>: test %rax,%rax I have no idea if the fact that symbol_get() generates '0', i.e. the !NULL checks work as expected, is intentional or if KVM works by sheer dumb luck. I'm not entirely sure I want to find out, though it's definitely extra motiviation to get the KVM mess fixed sooner than later. 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 C2226C4167B for ; Thu, 30 Nov 2023 02:03:06 +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=nZ9XVw0K; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Sgfbs3HjRz3cXd for ; Thu, 30 Nov 2023 13:03:05 +1100 (AEDT) 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=nZ9XVw0K; 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::114a; helo=mail-yw1-x114a.google.com; envelope-from=3iu1nzqykdm0bxt62vz77z4x.v75416dg88v-wxe41bcb.7i4tub.7az@flex--seanjc.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) (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 4SgfZt1D9dz2yDS for ; Thu, 30 Nov 2023 13:02:12 +1100 (AEDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5cef61289fdso8216347b3.1 for ; Wed, 29 Nov 2023 18:02:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701309730; x=1701914530; 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=p5qGWsyuSpyUxVCjDr7Vtr3DU5QXEtFZRiCX/LhUA7Q=; b=nZ9XVw0KMvJkmJ00XwuQPLZ263li0bz3ZRUvPd1kJVdLRQusZYRPlkoAafJjbaGoYp I+11OWa9FPDOkxBrlha2e+VGcsFAougCR/KyHfmfvnS6b8EpTiJgT2LW0JxDiL7g416h gq82UJZfDdyTskKp+M8fnhpfAmhouT79JWuvO8rQ2BKO2znejU8Z5L77fnFFSyk77wOL gqbgxK6zodxV+DlFrbpqsccJnxAXKGpBwhImq4R9GsvhGIqJ+WQmXWEvIVaQsTWGbSxF XPtOG1p2P1oKigy6jfe6z865YmoVJwbWdo5jJ8qx4uExd5ol7CSlJX76tBWNt9MpD2Hm VD3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701309730; x=1701914530; 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=p5qGWsyuSpyUxVCjDr7Vtr3DU5QXEtFZRiCX/LhUA7Q=; b=pd7G8YX5CmNes/CQMZUm9M4E6/T58wN6HM15K5BGtzHQRKhbKPDFI+bpcoREpjzMs9 IXyYHeBMT9mONZPrBzzsUJFO+eVndJ/Mu4jpJoTP8BoWzDkv6RULiJgBeeQ+4la8fHgb RtNesBMteTYW456OyyqZRVzu2c1IQX8A0wRYjl5iJ8FzFH3OjLXdcuFrUlTVDSzVmqGa h9LWoShCTne0Ejx19ru0Iu8stX3dbohtJhQ5IC2JaaDUhIatr3M38cCoRSddFTXoR9Wl TUz5Aq51GR4P0AJEIgHl8RoBKdS8DA6SbdzMUrqwEv3DlWjqli35FPwD9NA+kIRGnG13 jI0w== X-Gm-Message-State: AOJu0YyWa3sQaizvERxE4o00RUQSlO4J3kj0VSFc90K0+/TRcrZXNJXG 0Uq+QbjqegDMj5sqaCFb2lZGl5WGtNU= X-Google-Smtp-Source: AGHT+IFFDXNizpZ3vuH6xJBBRUPvzbuvqFOYFoh+t1YBbvxwcXUL+r5zJu2BpTJXrcb2S71zCUhlon51++M= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:690c:ec5:b0:5ca:321f:a368 with SMTP id cs5-20020a05690c0ec500b005ca321fa368mr767996ywb.7.1701309730213; Wed, 29 Nov 2023 18:02:10 -0800 (PST) Date: Wed, 29 Nov 2023 18:02:08 -0800 In-Reply-To: <20231130011650.GD1389974@nvidia.com> Mime-Version: 1.0 References: <0-v1-08396538817d+13c5-vfio_kvm_kconfig_jgg@nvidia.com> <87edgy87ig.fsf@mail.lhotse> <875y1k3nm9.fsf@mail.lhotse> <20231130011650.GD1389974@nvidia.com> Message-ID: Subject: Re: Ping? Re: [PATCH rc] kvm: Prevent compiling virt/kvm/vfio.c unless VFIO is selected 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: kvm@vger.kernel.org, David Hildenbrand , Catalin Marinas , Dave Hansen , "H. Peter Anvin" , Alexander Gordeev , Claudio Imbrenda , Will Deacon , linux-s390@vger.kernel.org, Janosch Frank , x86@kernel.org, Ingo Molnar , Zenghui Yu , Christian Borntraeger , Vasily Gorbik , Suzuki K Poulose , Heiko Carstens , Nicholas Piggin , Borislav Petkov , kvmarm@lists.linux.dev, Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Oliver Upton , James Morse , Sven Schnelle , Marc Zyngier , Paolo Bonzini , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Wed, Nov 29, 2023, Jason Gunthorpe wrote: > On Wed, Nov 29, 2023 at 05:07:45PM -0800, Sean Christopherson wrote: > > On Wed, Nov 29, 2023, Michael Ellerman wrote: > > > 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. > > > > Ah, it's the same warning, I just missed the CONFIG_MODULES=n requirement. > > Oh, wait, doesn't that mean the approach won't work? IIRC doesn't > symbol_get turn into just &fn when non-modular turning this into a > link failure without the kconfig part? Yes, but it doesn't cause linker errors. IIUC, because the extern declaration is tagged "weak", a dummy default is used. E.g. on x86, this is what is generated with VFIO=y fn = symbol_get(vfio_file_is_valid); if (!fn) 0xffffffff810396c5 <+5>: mov $0xffffffff81829230,%rax 0xffffffff810396cc <+12>: test %rax,%rax whereas VFIO=n gets fn = symbol_get(vfio_file_is_valid); if (!fn) 0xffffffff810396c5 <+5>: mov $0x0,%rax 0xffffffff810396cc <+12>: test %rax,%rax I have no idea if the fact that symbol_get() generates '0', i.e. the !NULL checks work as expected, is intentional or if KVM works by sheer dumb luck. I'm not entirely sure I want to find out, though it's definitely extra motiviation to get the KVM mess fixed sooner than later. 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 A3F34C4167B for ; Thu, 30 Nov 2023 02:02:37 +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:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ynrT6rMN/tYgr1o1rMY1qwo9z9lGPEKPmquqRzS7t4M=; b=QNuliDe0yw5cRbx/pDHtMZ9Qqi E8IdTRJr+gXMmUoxOw6Vk5WGd/NQmzyWn9y5Pq4k6J8qSleJ6z7427i/XqOeEH1qOe3SaMoIZmQft UipnRMUs5lwl40RzQbdiLs3WfIjLVkxF3oZwXuceUTs15T6nWcec+kXsM1c/GHpy7qxluABJdDDZt by52VGFdovJh4rUOOjHRH1oZ4+Mq3yHhFk5nlERTaBDOhkuEGV6JwGXs1/nZyKjIKbk7LFnzr395d HGupg3rIf83aULstidjSFZ/MtNcXWemVM3+8o0OSwR2ejhUKV3x0jNeLt4jcIi9c000/GVow1PR34 aJgoTVUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8WNZ-009iqI-30; Thu, 30 Nov 2023 02:02:13 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8WNX-009ipr-37 for linux-arm-kernel@lists.infradead.org; Thu, 30 Nov 2023 02:02:13 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5cef61289fdso8216367b3.1 for ; Wed, 29 Nov 2023 18:02:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701309730; x=1701914530; darn=lists.infradead.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=p5qGWsyuSpyUxVCjDr7Vtr3DU5QXEtFZRiCX/LhUA7Q=; b=oMmi3OnCw3A2AwcUgRR1qWfKPxN5RIlQqVLfyiiX7jRbBHuNphLTTGgKwSgsP0FMvb iSeALdPBCkg72cpg9QL/S2if6H30L/dQ2nr+XlcR1vVXTGArGCnTdjZuxh2guW9Zw5mP AatsEWrAlKyjAe+b5NMc9+H6E7uaj/Ra+BR8RBSkNuoFpubTOOXKlUj/+d1+HMU2clsA 6PWv1ouzTorNmhCtlgo2ckSUl5suHO9FwP6XhYx4SxvPTtvU4zeFjeC6Jn117+t8qwZH NZLcmGkY6Rvlc/RpCfwuZKNCy7mAKpJWRXWJCqx6yXkiBeCVY5UIUHsC6MUQeDpzl1IU x6Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701309730; x=1701914530; 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=p5qGWsyuSpyUxVCjDr7Vtr3DU5QXEtFZRiCX/LhUA7Q=; b=wCQ4XzsTDl+/XtyascB3mzooCyzCCEHMXtPm0JSIxTNtiUSJg4jKnO6ozCNqwxX0gB YQ1Ouu3tKy5SjO+Qk9PbJrlQXe9LAPjKQVgpjQ89GA1PKYMEbfdQ0oStLwg5amYiYDOs wvyrAhUMW1kjoLv5XXSWWbDzb0539/ClDidaO1MHn85sNz+rCh8eysuLNRcAXd9RMWLf Xb80+hymo92UHoMkDnCO3N6eg+4co/dBwf6EEHqeCoeNBVjDgSIIVO5DbJj6UYh9yQn2 zsE3dCrXVmxUJOBtLjfIwSzlUb8DLVYBrhyWTAokcBDhS0XDbpE9+np9BjUx99CwCzPY 9l9w== X-Gm-Message-State: AOJu0Yw5oOzaE4XNfGIP5bhljGTcakh4i0GB2BBHdFGpmun55CjOG/rb HK4V1AlUNnHGmlA74d3MXjXJ+7nt9GU= X-Google-Smtp-Source: AGHT+IFFDXNizpZ3vuH6xJBBRUPvzbuvqFOYFoh+t1YBbvxwcXUL+r5zJu2BpTJXrcb2S71zCUhlon51++M= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:690c:ec5:b0:5ca:321f:a368 with SMTP id cs5-20020a05690c0ec500b005ca321fa368mr767996ywb.7.1701309730213; Wed, 29 Nov 2023 18:02:10 -0800 (PST) Date: Wed, 29 Nov 2023 18:02:08 -0800 In-Reply-To: <20231130011650.GD1389974@nvidia.com> Mime-Version: 1.0 References: <0-v1-08396538817d+13c5-vfio_kvm_kconfig_jgg@nvidia.com> <87edgy87ig.fsf@mail.lhotse> <875y1k3nm9.fsf@mail.lhotse> <20231130011650.GD1389974@nvidia.com> Message-ID: Subject: Re: Ping? Re: [PATCH rc] kvm: Prevent compiling virt/kvm/vfio.c unless VFIO is selected From: Sean Christopherson To: Jason Gunthorpe Cc: Michael Ellerman , Paolo Bonzini , 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231129_180212_008392_A4A75750 X-CRM114-Status: GOOD ( 26.88 ) 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 On Wed, Nov 29, 2023, Jason Gunthorpe wrote: > On Wed, Nov 29, 2023 at 05:07:45PM -0800, Sean Christopherson wrote: > > On Wed, Nov 29, 2023, Michael Ellerman wrote: > > > 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. > > > > Ah, it's the same warning, I just missed the CONFIG_MODULES=n requirement. > > Oh, wait, doesn't that mean the approach won't work? IIRC doesn't > symbol_get turn into just &fn when non-modular turning this into a > link failure without the kconfig part? Yes, but it doesn't cause linker errors. IIUC, because the extern declaration is tagged "weak", a dummy default is used. E.g. on x86, this is what is generated with VFIO=y fn = symbol_get(vfio_file_is_valid); if (!fn) 0xffffffff810396c5 <+5>: mov $0xffffffff81829230,%rax 0xffffffff810396cc <+12>: test %rax,%rax whereas VFIO=n gets fn = symbol_get(vfio_file_is_valid); if (!fn) 0xffffffff810396c5 <+5>: mov $0x0,%rax 0xffffffff810396cc <+12>: test %rax,%rax I have no idea if the fact that symbol_get() generates '0', i.e. the !NULL checks work as expected, is intentional or if KVM works by sheer dumb luck. I'm not entirely sure I want to find out, though it's definitely extra motiviation to get the KVM mess fixed sooner than later. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel