Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1730893

"KVM: x86: generalize guest_cpuid_has_ helpers" breaks clang

From Dmitry Vyukov <dvyukov@google.com>
Newsgroups linux.kernel
Subject "KVM: x86: generalize guest_cpuid_has_ helpers" breaks clang
Date 2017-09-12 16:50 +0200
Message-ID <uoUFH-2tx-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

"KVM: x86: generalize guest_cpuid_has_ helpers" breaks clang Dmitry Vyukov <dvyukov@google.com> - 2017-09-12 16:50 +0200
  Re: "KVM: x86: generalize guest_cpuid_has_ helpers" breaks clang Radim Krčmář <rkrcmar@redhat.com> - 2017-09-12 17:20 +0200
    Re: "KVM: x86: generalize guest_cpuid_has_ helpers" breaks clang Dmitry Vyukov <dvyukov@google.com> - 2017-09-12 18:00 +0200
      Re: "KVM: x86: generalize guest_cpuid_has_ helpers" breaks clang Paolo Bonzini <pbonzini@redhat.com> - 2017-09-12 18:10 +0200
        Re: "KVM: x86: generalize guest_cpuid_has_ helpers" breaks clang Dmitry Vyukov <dvyukov@google.com> - 2017-09-12 18:20 +0200
          Re: "KVM: x86: generalize guest_cpuid_has_ helpers" breaks clang Paolo Bonzini <pbonzini@redhat.com> - 2017-09-12 18:40 +0200
            Re: "KVM: x86: generalize guest_cpuid_has_ helpers" breaks clang Dmitry Vyukov <dvyukov@google.com> - 2017-09-12 19:40 +0200
      Re: "KVM: x86: generalize guest_cpuid_has_ helpers" breaks clang Radim Krčmář <rkrcmar@redhat.com> - 2017-09-13 13:00 +0200
    Re: "KVM: x86: generalize guest_cpuid_has_ helpers" breaks clang Dmitry Vyukov <dvyukov@google.com> - 2017-09-12 18:00 +0200

csiph-web