diff mbox series

[1/2] KVM: selftests: Fix KVM_EXCEPTION_MAGIC build with Clang

Message ID 20220722234838.2160385-2-dmatlack@google.com (mailing list archive)
State New, archived
Headers show
Series KVM: selftests: Fix Clang build issues in KVM_ASM_SAFE() | expand

Commit Message

David Matlack July 22, 2022, 11:48 p.m. UTC
Change KVM_EXCEPTION_MAGIC to use the all-caps "ULL", rather than lower
case. This fixes a build failure with Clang:

  In file included from x86_64/hyperv_features.c:13:
  include/x86_64/processor.h:825:9: error: unexpected token in argument list
          return kvm_asm_safe("wrmsr", "a"(val & -1u), "d"(val >> 32), "c"(msr));
                 ^
  include/x86_64/processor.h:802:15: note: expanded from macro 'kvm_asm_safe'
          asm volatile(KVM_ASM_SAFE(insn)                 \
                       ^
  include/x86_64/processor.h:785:2: note: expanded from macro 'KVM_ASM_SAFE'
          "mov $" __stringify(KVM_EXCEPTION_MAGIC) ", %%r9\n\t"   \
          ^
  <inline asm>:1:18: note: instantiated into assembly here
          mov $0xabacadabaull, %r9
                          ^

Fixes: 3b23054cd3f5 ("KVM: selftests: Add x86-64 support for exception fixup")
Signed-off-by: David Matlack <dmatlack@google.com>
---
 tools/testing/selftests/kvm/include/x86_64/processor.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sean Christopherson July 23, 2022, 12:01 a.m. UTC | #1
On Fri, Jul 22, 2022, David Matlack wrote:
> Change KVM_EXCEPTION_MAGIC to use the all-caps "ULL", rather than lower
> case. This fixes a build failure with Clang:
> 
>   In file included from x86_64/hyperv_features.c:13:
>   include/x86_64/processor.h:825:9: error: unexpected token in argument list
>           return kvm_asm_safe("wrmsr", "a"(val & -1u), "d"(val >> 32), "c"(msr));
>                  ^
>   include/x86_64/processor.h:802:15: note: expanded from macro 'kvm_asm_safe'
>           asm volatile(KVM_ASM_SAFE(insn)                 \
>                        ^
>   include/x86_64/processor.h:785:2: note: expanded from macro 'KVM_ASM_SAFE'
>           "mov $" __stringify(KVM_EXCEPTION_MAGIC) ", %%r9\n\t"   \
>           ^
>   <inline asm>:1:18: note: instantiated into assembly here
>           mov $0xabacadabaull, %r9
>                           ^
> 
> Fixes: 3b23054cd3f5 ("KVM: selftests: Add x86-64 support for exception fixup")
> Signed-off-by: David Matlack <dmatlack@google.com>
> ---

Reviewed-by: Sean Christopherson <seanjc@google.com>

>  tools/testing/selftests/kvm/include/x86_64/processor.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h
> index 45edf45821d0..51c6661aca77 100644
> --- a/tools/testing/selftests/kvm/include/x86_64/processor.h
> +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h
> @@ -754,7 +754,7 @@ void vm_install_exception_handler(struct kvm_vm *vm, int vector,
>  			void (*handler)(struct ex_regs *));
>  
>  /* If a toddler were to say "abracadabra". */
> -#define KVM_EXCEPTION_MAGIC 0xabacadabaull
> +#define KVM_EXCEPTION_MAGIC 0xabacadabaULL

Really?!?!?! That's what makes clang happy?!?!?
David Matlack July 23, 2022, 12:07 a.m. UTC | #2
On Fri, Jul 22, 2022 at 5:01 PM Sean Christopherson <seanjc@google.com> wrote:
>
> On Fri, Jul 22, 2022, David Matlack wrote:
> > Change KVM_EXCEPTION_MAGIC to use the all-caps "ULL", rather than lower
> > case. This fixes a build failure with Clang:
> >
> >   In file included from x86_64/hyperv_features.c:13:
> >   include/x86_64/processor.h:825:9: error: unexpected token in argument list
> >           return kvm_asm_safe("wrmsr", "a"(val & -1u), "d"(val >> 32), "c"(msr));
> >                  ^
> >   include/x86_64/processor.h:802:15: note: expanded from macro 'kvm_asm_safe'
> >           asm volatile(KVM_ASM_SAFE(insn)                 \
> >                        ^
> >   include/x86_64/processor.h:785:2: note: expanded from macro 'KVM_ASM_SAFE'
> >           "mov $" __stringify(KVM_EXCEPTION_MAGIC) ", %%r9\n\t"   \
> >           ^
> >   <inline asm>:1:18: note: instantiated into assembly here
> >           mov $0xabacadabaull, %r9
> >                           ^
> >
> > Fixes: 3b23054cd3f5 ("KVM: selftests: Add x86-64 support for exception fixup")
> > Signed-off-by: David Matlack <dmatlack@google.com>
> > ---
>
> Reviewed-by: Sean Christopherson <seanjc@google.com>
>
> >  tools/testing/selftests/kvm/include/x86_64/processor.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h
> > index 45edf45821d0..51c6661aca77 100644
> > --- a/tools/testing/selftests/kvm/include/x86_64/processor.h
> > +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h
> > @@ -754,7 +754,7 @@ void vm_install_exception_handler(struct kvm_vm *vm, int vector,
> >                       void (*handler)(struct ex_regs *));
> >
> >  /* If a toddler were to say "abracadabra". */
> > -#define KVM_EXCEPTION_MAGIC 0xabacadabaull
> > +#define KVM_EXCEPTION_MAGIC 0xabacadabaULL
>
> Really?!?!?! That's what makes clang happy?!?!?

Heh, yup. I was surprised when it worked.

Hopefully some of the Clang folks CC'd can shed some light on why.
diff mbox series

Patch

diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h
index 45edf45821d0..51c6661aca77 100644
--- a/tools/testing/selftests/kvm/include/x86_64/processor.h
+++ b/tools/testing/selftests/kvm/include/x86_64/processor.h
@@ -754,7 +754,7 @@  void vm_install_exception_handler(struct kvm_vm *vm, int vector,
 			void (*handler)(struct ex_regs *));
 
 /* If a toddler were to say "abracadabra". */
-#define KVM_EXCEPTION_MAGIC 0xabacadabaull
+#define KVM_EXCEPTION_MAGIC 0xabacadabaULL
 
 /*
  * KVM selftest exception fixup uses registers to coordinate with the exception