All of lore.kernel.org
 help / color / mirror / Atom feed
* "KVM: x86: generalize guest_cpuid_has_ helpers" breaks clang
@ 2017-09-12 14:42 Dmitry Vyukov
  2017-09-12 15:18 ` Radim Krčmář
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Vyukov @ 2017-09-12 14:42 UTC (permalink / raw)
  To: Radim Krčmář,
	David Hildenbrand, Paolo Bonzini, LKML, KVM list
  Cc: llvmlinux, Alexander Potapenko, andreyknvl, Michael Davidson,
	Greg Hackmann, Nick Desaulniers

Hi Radim,

I've just noticed that your commit "KVM: x86: generalize
guest_cpuid_has_ helpers" breaks clang build on this assert:

static __always_inline struct cpuid_reg x86_feature_cpuid(unsigned x86_feature)
{
    unsigned x86_leaf = x86_feature / 32;

    BUILD_BUG_ON(!__builtin_constant_p(x86_leaf));


In clang __builtin_constant_p is never true for function arguments,
it's true only for compile-time constants (what you can use as stack
array size, or C++ template argument). What would work is an
additional macro along the lines of:

#define x86_feature_cpuid(x) (BUILD_BUG_ON(!__builtin_constant_p(x),
__x86_feature_cpuid(x))

But again assuming that caller pass the constant directly.

Could you please fix it?

Thanks

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-09-13 10:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-12 14:42 "KVM: x86: generalize guest_cpuid_has_ helpers" breaks clang Dmitry Vyukov
2017-09-12 15:18 ` Radim Krčmář
2017-09-12 15:51   ` Dmitry Vyukov
2017-09-12 15:54     ` Dmitry Vyukov
2017-09-12 16:03       ` Paolo Bonzini
2017-09-12 16:16         ` Dmitry Vyukov
2017-09-12 16:33           ` Paolo Bonzini
2017-09-12 17:33             ` Dmitry Vyukov
2017-09-13 10:58       ` Radim Krčmář

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.