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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33C9FC433EF for ; Wed, 23 Feb 2022 17:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243647AbiBWR7m (ORCPT ); Wed, 23 Feb 2022 12:59:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233876AbiBWR7i (ORCPT ); Wed, 23 Feb 2022 12:59:38 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 071FC3DA6F for ; Wed, 23 Feb 2022 09:59:11 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id d17so16115399pfl.0 for ; Wed, 23 Feb 2022 09:59:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=i9ZmGUIwkyC7vjnII3cOeTZiB9a3MACRa2J9UXGI/ow=; b=XJHhTu/IhJCZ37/XrmsRBgCMoxE7LQi7Lo2Wi2s9PrXp0NKXlVd6zNTxZYdlTEDAqx L/j6e0Yamrbm7MLR3xgUc3Lw2+IT950x0WmnqU5OXUM//6aHcMBdwkA7rIK6YFT0JUhc sZvfycmuBlW+7vxVI4IDjx+/5a+Tmn8tspepbIAylqOg5aUfL+ulyJwBswjF0ItOtVKO 97WUPmaUab1x3mwDYSGjTBxch3l8b3hxugErDO2pW1LUwJTeMVzMA6djZdYgR5ys3I6O QnwB+tBGJWUDAijMLK5HnyZoR8nHcsOuSTEBguK42TJ00sTtcT0wbBla4qArjLsIo/nN 0v+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=i9ZmGUIwkyC7vjnII3cOeTZiB9a3MACRa2J9UXGI/ow=; b=fgrCi5szHrmU6L1zR4DhpDse7ulHC8cUuTNO604aNm37Jv/f/T5xYZZpIwlN0hWuRh 8PY8lTDvPDvknr7bJM6cT35KEDQ5ky7DFoMJ8sfU92/nO/ND8pFoqNRUC9VNC/xLgnVY iBlRXyajROSUF7QcmRmMN5HFbtpEwCyjSUV3CtFLq9ybptj3+MecY6GGkUFP/FFG3R0W RZJingh63jQReszAa071j1O9jOVm60svbfHx63m2qda907JjbSY7gqWeqOLz379RejtO METw2aBeXMa6MBPOYh2LNQX73VYI6x69Ehj8XK2C/8/d0hToJ2zEJzkisapZ/oQayeK0 NBGA== X-Gm-Message-State: AOAM530Vp1eiwvAyI2osZ1kP0Q0ClzPhWgXu6enA6lvLtApz/KcbV5HU YyTb2RGPWRQoUxCoqKCDMnEvzg== X-Google-Smtp-Source: ABdhPJyWY8cS3LAxq9EqCzdtTUyda9OxIuVZO+b/1nALlGyO7RfH+5KzoRu/A7B8I7ghZ74CG6Bi7Q== X-Received: by 2002:a05:6a00:174e:b0:4e1:7cfb:7a26 with SMTP id j14-20020a056a00174e00b004e17cfb7a26mr928875pfc.50.1645639150179; Wed, 23 Feb 2022 09:59:10 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id h27sm170144pgb.20.2022.02.23.09.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 09:59:09 -0800 (PST) Date: Wed, 23 Feb 2022 17:59:05 +0000 From: Sean Christopherson To: Nathan Chancellor 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: Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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; 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.