Re: [PATCH] KVM: x86: Fix pointer mistmatch warning when patching RET0 static calls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <like.xu.linux@xxxxxxxxx>
> > Reported-by: kernel test robot <lkp@xxxxxxxxx>
> > Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> 
> 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.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux