Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1056783pxm; Wed, 23 Feb 2022 17:01:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpQfrRIJCtVV8mpsbBBMhnreeHosXe3E9syGbv2TUtFUFHNbcwLMslpefnupRMuEoOtioZ X-Received: by 2002:a17:90a:588c:b0:1b8:91a6:6cdf with SMTP id j12-20020a17090a588c00b001b891a66cdfmr225056pji.239.1645664510426; Wed, 23 Feb 2022 17:01:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645664510; cv=none; d=google.com; s=arc-20160816; b=kVWzHn0SIbUp1sRnN/1zoqwCliNweEWujLZri1x+8doWWP05Y6gRmU0E7ZyICfHzmI tB8Lny3uPNrvaB/cNCR52i1Ce7G0/Xm8iHnc8tUmEadzgsW4FCBq2meDgWXBFgzk0YNE zDKNSO6O1eo3nt5aqaIZUcP4uya2s9yEpSLCZncTXUvdCoLthAgztcbTyQOmP8O9ZhSz k96an+3KaM1H/yNivEo/BoL2whYQ8ZOvsyjGMHxIr89nkphmxXIGasc+QpiP3ZHlVYBy MNbB/HE0gwb/nYI/PHhqYBnMUBjYrBq67QE7jXX0uChE1kF2Z8vFwedGNXmpaif2DNUy aGQA== 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=vxAXTPTZ/ki8aLIWzLktN6jQe8Oj68Y4Hafy9UUE/k4=; b=S3Zscu7FlHWt+sNRjAoSfph5FEQe1FUnZmtkM59MpUPukG/TE3s+bpJxK3eWIBkAzI CeNbsgFSvFlFgzsSXQyStTr7sEdCnujCsvb38bbnY+eYS1fyiTNVExdCnle7D5yi4926 VtoFXxt3PX44q4vJyTXPq6oR+C67JD51j8L7vl7TwrZbSPdDHWOc41nwK4gqhSyPq7zP do5OAJf6bc2MhmFPqm12ElDyCGsSWt5oA5jYEbFy+/ADTaZlpfoal+qMk7ikbzdLgaN5 E1WAE70lIZLfuJ8iiLWlBaGRSKwRF/mbTfiy6TCKqc5EpvAyhQFpN0RlqlvN2akZkTsp QnRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=So3I9zMv; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id p21si1046056plr.574.2022.02.23.17.01.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 17:01:50 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=So3I9zMv; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5F02D136ED9; Wed, 23 Feb 2022 16:52:33 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243790AbiBWSN6 (ORCPT + 99 others); Wed, 23 Feb 2022 13:13:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243783AbiBWSN4 (ORCPT ); Wed, 23 Feb 2022 13:13:56 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3811348315; Wed, 23 Feb 2022 10:13:29 -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 dfw.source.kernel.org (Postfix) with ESMTPS id C83DD61580; Wed, 23 Feb 2022 18:13:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 138E8C340E7; Wed, 23 Feb 2022 18:13:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645640008; bh=puW8dgOC6u58SDIMkZaeJA/5QfThrRACFwNlmW5mRnU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=So3I9zMvNKYHhpDsnpmxh7H1xHymIHJtd0I1kFTMKLG3PcYYnkVIOgEvEVbOJP7Gp 7zsdrFI0DtUsX5Vu0KX5cNfb8+J9nqNgLa/fA9/IO3FR1CGfGLIqgGpFdb27XmczlL a4/hDIjCMJt0DptTo2hW+PEA7JGrZDCqo5triI9Q1kEoGiP0xQTdzXgd2IUkHOJ716 ugklpcYNY4F9G2vPdoA0+/ud4Cpx8bJV9xF2VwoSjOn9LWLHUYB5SmHzmr8+AGvS/6 LbVmtF+30SRWWojGh6bMk/8or0GQsjt6lZ7GfhFVN4cc+DkmD1MnlqZnFPw58zoxJL +iNR9hqLLePAA== Date: Wed, 23 Feb 2022 11:13:23 -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: X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Wed, Feb 23, 2022 at 05:59:05PM +0000, Sean Christopherson wrote: > On Wed, Feb 23, 2022, Nathan Chancellor wrote: > > 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? > > IMO, no. I think it's completely reasonable for the compiler to complain that KVM > is generating two different pointer types out of a ternary operator. > > clang is somewhat inconsistent, though it may be deliberate. clang doesn't complain > about implicitly casting a 'void *' to another data type, e.g. this complies clean, > where "data" is a 'void *' > > struct kvm_vcpu *x = vcpu ? : data; Right, I would assume this is deliberate. I think warning in this case might be quite noisy, as the kernel implicitly converts 'void *' to typed pointers for certain function pointer callbacks (although this particular case is probably pretty rare). > But changing it to a function on the lhs triggers the warn: > > typeof(kvm_x86_ops.vcpu_run) x = kvm_x86_ops.vcpu_run ? : data; > > Again, complaining in the function pointer case seems reasonable. Ack, thank you for the clarification and explanation! Cheers, Nathan