X-Received: by 2002:a65:604a:0:b0:375:5cc8:7458 with SMTP id a10-20020a65604a000000b003755cc87458mr1427952pgp.205.1645656187579; Wed, 23 Feb 2022 14:43:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645656187; cv=none; d=google.com; s=arc-20160816; b=eUKdVVxVdE86/15ND46uBDQfef747WhUmXyV9tOY8hRGsEDOQd9mn9UUWOskO/WujP osW3GjDetG6u38pfhv+iJmSXF0Iox/OhBh4irJgSH0u6c730sYNPShF3dOvxNHc1/wwm ixPGkkVp3wmpIHbj88CK1XnaopjYaEKYwxSdqgqj+UbS0Yy/IzlOfgaT3Du5QmYpNkLn uedgeFgggsBkVNuoJN8wF6dtSIlt5kBDBrb1gz3EAcQnaB4SjpkDM9/0SlVTLGA2GSbc fnch3BoSDoso/FiO//k4yI2X2HOPqPkamEPjBe2p2tI5XY4lQIQwmMguDZrDT2mR33bV qLzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sPTAwY5cZ4IgOuhd/i845lJyA87yJGnhn6HPgLx8deo=; b=noQOc/OnKsPTQu+7KI6UK64clkMpq4bGFxwVbNglxlAU25wW6CweRAJPA+HDp4UU7Z W/EmhnXvjx/axcahpUAl7UNvj7y7flOgSeRBljIHtAplFdI5lkYkmEX9RjOHuGbuegGQ xGFp4DjKTEzsaCirRnC1I0vQ1HGBSVrwIpX9cWqqm7UDdV3tEny3hAnbUdXLmFeK6oW5 kiI/tmjHClNC2pAAzH8eF3RHGSEl1cJQ3tlQ0zSLsXRWa4TLWmtE1Qw5quPqt9v9aZmT tvge7facFSa9tW92IoVGkM4OYXmmKXfABYdfdQ21iFPrrKpz00DYkYiVh64a61MRxwCP G6xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FQmygXJJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m10si789063pjf.137.2022.02.23.14.42.51; Wed, 23 Feb 2022 14:43:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FQmygXJJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243403AbiBWR2Y (ORCPT + 99 others); Wed, 23 Feb 2022 12:28:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237738AbiBWR2X (ORCPT ); Wed, 23 Feb 2022 12:28:23 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9966A47388; Wed, 23 Feb 2022 09:27:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4C620B8210A; Wed, 23 Feb 2022 17:27:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCDDCC340E7; Wed, 23 Feb 2022 17:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645637273; bh=BZ72Cv96SDULoZqRBhdwvA8X1c4BIfcsSZ5Rny2PuLM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FQmygXJJt2g54V+d9trXkiWWQ7HNa3uYnsgmfTn6/B4dZ5SMh4YaGrrt7GRNds8ZH ca94NfYv9xzDeUgKAYn/mqUPhvs9wEgDQiy99FDhAToFjjXygK6KA5tHDwXET17R8J hnpD2jrwkrz1jh5ZXtC8WX04Ts76+WfixivAPUt+DFgzd1sW4Gi3qmGOwnloxEyMJM E5LK4j8dUD6tK9xdFNsM8ZvmzDx4RmaQuNGu9DESaHaqoN7eYNMs1kIN2Iufkwdv0V xaCpPFNhNQWPQyVz1MncyaBU8arQl/1WA01U6Cjjr0wmX/xgLJqjIsNYfMbilN4xLd 5fsrqlEinDLPg== Date: Wed, 23 Feb 2022 10:27:47 -0700 From: Nathan Chancellor To: Sean Christopherson Cc: Paolo Bonzini , Nick Desaulniers , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Like Xu Subject: Re: [PATCH] KVM: x86: Fix pointer mistmatch warning when patching RET0 static calls Message-ID: References: <20220223162355.3174907-1-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220223162355.3174907-1-seanjc@google.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sean, On Wed, Feb 23, 2022 at 04:23:55PM +0000, Sean Christopherson wrote: > Cast kvm_x86_ops.func to 'void *' when updating KVM static calls that are > conditionally patched to __static_call_return0(). clang complains about > using mismatching pointers in the ternary operator, which breaks the > build when compiling with CONFIG_KVM_WERROR=y. > > >> arch/x86/include/asm/kvm-x86-ops.h:82:1: warning: pointer type mismatch > ('bool (*)(struct kvm_vcpu *)' and 'void *') [-Wpointer-type-mismatch] > > Fixes: 5be2226f417d ("KVM: x86: allow defining return-0 static calls") > Reported-by: Like Xu > Reported-by: kernel test robot > Signed-off-by: Sean Christopherson Thank you for the patch! Is this a bug in clang? I ended up creating a small reproducer in case we need to file a bug with clang upstream: https://godbolt.org/z/P7nEdzejE This does shut up the warning and I can still spawn guests on my AMD and Intel systems so: Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor > --- > arch/x86/include/asm/kvm_host.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index 713e08f62385..f285ddb8b66b 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1547,8 +1547,8 @@ static inline void kvm_ops_static_call_update(void) > WARN_ON(!kvm_x86_ops.func); __KVM_X86_OP(func) > #define KVM_X86_OP_OPTIONAL __KVM_X86_OP > #define KVM_X86_OP_OPTIONAL_RET0(func) \ > - static_call_update(kvm_x86_##func, kvm_x86_ops.func ? : \ > - (void *) __static_call_return0); > + static_call_update(kvm_x86_##func, (void *)kvm_x86_ops.func ? : \ > + (void *)__static_call_return0); > #include > #undef __KVM_X86_OP > } > > base-commit: f4bc051fc91ab9f1d5225d94e52d369ef58bec58 > -- > 2.35.1.473.g83b2b277ed-goog >