Make xen build with clang/LLVM again
PATCH v2 1/1 Make xen build with clang/LLVM again
This series makes the hypervisor build with clang/LLVM again, after a certain amount of bit-rot.
Since v1:
- Changed an xmalloc+memset pair to xzalloc in the memset patch
- Reworked the spinlock patch not to touch gcc builds
- Added a patch to indirect all __section__ directives through a macro.
- Commented up the ugly __attribute__((used)) change and moved it into the definition of __section().
PATCH v2 1/1 xen: Add -Wno-unused-value to the clang CFLAGS
# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1333640955 -3600
# Node ID 7922a921d2034930780e41f1bc71d2c4ddb3b782 # Parent d690c7e896a26c54a5ab85458824059de72d5cba
xen: Add -Wno-unused-value to the clang CFLAGS
clang complains about a lot of functions and macros whose return value is unused. I started on patches to drop some functions' return values and scatter (void)s around callers, but it was getting too messy. Just turn off the warning instead.
Config.mk +2 -1
@@ -159,7 +159,8 @@ CFLAGS += -Wall -Wstrict-prototypes # Clang complains about macros that expand to 'if ( ( foo == bar ) ) ...' # and is over-zealous with the printf format lint -CFLAGS-$(clang) += -Wno-parentheses -Wno-format +# and is a bit too fierce about unused return values +CFLAGS-$(clang) += -Wno-parentheses -Wno-format -Wno-unused-value $(call cc-option-add,HOSTCFLAGS,HOSTCC,-Wdeclaration-after-statement) $(call cc-option-add,CFLAGS,CC,-Wdeclaration-after-statement)
PATCH v2 1/1 x86/mm: Another couple of comparisons of unsigned vars with < 0
In reply to Tim Deegan# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1333640955 -3600
# Node ID 08612e81926857363618746fd01f9b08b7c3ac73
# Parent 7922a921d2034930780e41f1bc71d2c4ddb3b782 x86/mm: Another couple of comparisons of unsigned vars with < 0.
Adding the explicit (unsigned) casts in case enums ever end up signed.
xen/arch/x86/mm/p2m.c +2 -2
@@ -1305,7 +1305,7 @@ int p2m_set_mem_access(struct domain *d, p2m->default_access, }; -if ( access >= HVMMEM_access_default || access <0 ) +if ( (unsigned ) access >= HVMMEM_access_default )return -EINVAL ; a = memaccess[access];
@@ -1367,7 +1367,7 @@ int p2m_get_mem_access(struct domain *d,if (mfn_x (mfn) ==INVALID_MFN )return -ESRCH ; -if ( a >=ARRAY_SIZE (memaccess) || a <0 ) +if ( (unsigned ) a >=ARRAY_SIZE (memaccess) )return -ERANGE ; *access = memaccess[a];
PATCH v2 1/1 x86: fix logical ANDs used to mask bitfields
In reply to Tim Deegan# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1333640955 -3600
# Node ID 4674ce03c62a3e916954fd445b4510ffe72e64f4 # Parent 08612e81926857363618746fd01f9b08b7c3ac73
x86: fix logical ANDs used to mask bitfields.
xen/arch/x86/hvm/svm/svm.c +1 -1
@@ -752,7 +752,7 @@ static void svm_lwp_interrupt(struct cpuack_APIC_irq ();vlapic_set_irq (vcpu_vlapic (curr), - (curr->arch.hvm_svm.guest_lwp_cfg >>40 ) &&0xff , + (curr->arch.hvm_svm.guest_lwp_cfg >>40 ) &0xff ,0 ); }
xen/arch/x86/hvm/vmx/vmx.c +2 -2
@@ -1382,7 +1382,7 @@ void vmx_inject_extint(int trap)if (nestedhvm_vcpu_in_guestmode (v) ) { pin_based_cntrl =__get_vvmcs (vcpu_nestedhvm (v).nv_vvmcx,PIN_BASED_VM_EXEC_CONTROL ); -if ( pin_based_cntrl &&PIN_BASED_EXT_INTR_MASK ) { +if ( pin_based_cntrl &PIN_BASED_EXT_INTR_MASK ) {nvmx_enqueue_n2_exceptions (v,INTR_INFO_VALID_MASK | (X86_EVENTTYPE_EXT_INTR <<8 ) | trap,HVM_DELIVER_NO_ERROR_CODE );
@@ -1401,7 +1401,7 @@ void vmx_inject_nmi(void)if (nestedhvm_vcpu_in_guestmode (v) ) { pin_based_cntrl =__get_vvmcs (vcpu_nestedhvm (v).nv_vvmcx,PIN_BASED_VM_EXEC_CONTROL ); -if ( pin_based_cntrl &&PIN_BASED_NMI_EXITING ) { +if ( pin_based_cntrl &PIN_BASED_NMI_EXITING ) {nvmx_enqueue_n2_exceptions (v,INTR_INFO_VALID_MASK | (X86_EVENTTYPE_NMI <<8 ) | TRAP_nmi,HVM_DELIVER_NO_ERROR_CODE );
PATCH v2 1/1 x86: fix memset(ptr, 0, sizeof ptr)
In reply to Tim Deegan# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1333640955 -3600
# Node ID a93381049790e4f8a02f2322851f78175c254c5b # Parent 4674ce03c62a3e916954fd445b4510ffe72e64f4
x86: fix memset(ptr, 0, sizeof ptr).
xen/arch/x86/cpu/mcheck/amd_f10.c +2 -2
@@ -73,9 +73,9 @@ amd_f10_handler(struct mc_info *mi, uintreturn NULL ; } -memset (mc_ext,0 ,sizeof (mc_ext)); +memset (mc_ext,0 ,sizeof (*mc_ext)); mc_ext->common.type =MC_TYPE_EXTENDED ; - mc_ext->common.size =sizeof (mc_ext); + mc_ext->common.size =sizeof (*mc_ext); mc_ext->mc_msrs =3 ; mc_ext->mc_msr[0 ].reg =MSR_F10_MC4_MISC1 ;
xen/arch/x86/mm/p2m.c +1 -2
@@ -1232,11 +1232,10 @@ bool_t p2m_mem_access_check(unsigned lon } *req_ptr =NULL ; - req =xmalloc (mem_event_request_t); + req =xzalloc (mem_event_request_t);if ( req ) { *req_ptr = req; -memset (req,0 ,sizeof (req)); req->reason =MEM_EVENT_REASON_VIOLATION ;/* Pause the current VCPU */
Re: [PATCH 4 of 7 v2] x86: fix memset(ptr, 0, sizeof ptr)
Quoted 9 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1333640955 -3600
# Node IDa93381049790e4f8a02f2322851f78175c254c5b# Parent4674ce03c62a3e916954fd445b4510ffe72e64f4
x86: fixmemset(ptr, 0, sizeof ptr).Signed-off-by Tim Deegan <[email protected]>
Quoted 36 lines
diff -r
4674ce03c62a-ra93381049790xen/arch/x86/cpu/mcheck/amd_f10.cxen/arch/x86/cpu/mcheck/amd_f10.c +2
-2@@ -73,9 +73,9 @@ amd_f10_handler(struct mc_info *mi, uintreturn NULL ; } -memset (mc_ext,0 ,sizeof (mc_ext)); +memset (mc_ext,0 ,sizeof (*mc_ext)); mc_ext->common.type =MC_TYPE_EXTENDED ; - mc_ext->common.size =sizeof (mc_ext); + mc_ext->common.size =sizeof (*mc_ext); mc_ext->mc_msrs =3 ; mc_ext->mc_msr[0 ].reg =MSR_F10_MC4_MISC1 ;diff -r
4674ce03c62a-ra93381049790xen/arch/x86/mm/p2m.cxen/arch/x86/mm/p2m.c +1
-2@@ -1232,11 +1232,10 @@ bool_t p2m_mem_access_check(unsigned lon } *req_ptr =NULL ; - req =xmalloc (mem_event_request_t); + req =xzalloc (mem_event_request_t);if ( req ) { *req_ptr = req; -memset (req,0 ,sizeof (req)); req->reason =MEM_EVENT_REASON_VIOLATION ;/* Pause the current VCPU */ _______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 4 of 7 v2] x86: fix memset(ptr, 0, sizeof ptr)
In reply to Tim DeeganQuoted 8 lines · Tim Deegan
# HG changeset patch
# User Tim Deegan<[email protected]>
# Date 1333640955 -3600
# Node IDa93381049790e4f8a02f2322851f78175c254c5b# Parent4674ce03c62a3e916954fd445b4510ffe72e64f4
x86: fixmemset(ptr, 0, sizeof ptr).Signed-off-by Tim Deegan<[email protected]>
Quoted 38 lines
diff -r
4674ce03c62a-ra93381049790xen/arch/x86/cpu/mcheck/amd_f10.cxen/arch/x86/cpu/mcheck/amd_f10.c +2
-2@@ -73,9 +73,9 @@ amd_f10_handler(struct mc_info *mi, uintreturn NULL ; } -memset (mc_ext,0 ,sizeof (mc_ext)); +memset (mc_ext,0 ,sizeof (*mc_ext)); mc_ext->common.type =MC_TYPE_EXTENDED ; - mc_ext->common.size =sizeof (mc_ext); + mc_ext->common.size =sizeof (*mc_ext); mc_ext->mc_msrs =3 ; mc_ext->mc_msr[0 ].reg =MSR_F10_MC4_MISC1 ;diff -r
4674ce03c62a-ra93381049790xen/arch/x86/mm/p2m.cxen/arch/x86/mm/p2m.c +1
-2@@ -1232,11 +1232,10 @@ bool_t p2m_mem_access_check(unsigned lon } *req_ptr =NULL ; - req =xmalloc (mem_event_request_t); + req =xzalloc (mem_event_request_t);if ( req ) { *req_ptr = req; -memset (req,0 ,sizeof (req)); req->reason =MEM_EVENT_REASON_VIOLATION ;/* Pause the current VCPU */ _______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85689 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
PATCH v2 1/1 x86: don't use .subsection when compiling with clang
In reply to Tim Deegan# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1333640955 -3600
# Node ID 0908535327a5b01e49b69cd96db464be21ff3ee6 # Parent a93381049790e4f8a02f2322851f78175c254c5b
x86: don't use .subsection when compiling with clang
LLVM's assembler doesn't support the .subsection directive, so put the out-of-line failure path in .fixup instead.
xen/include/asm-x86/spinlock.h +8 -0
@@ -45,11 +45,19 @@ static always_inline int _raw_read_trylo asmvolatile ( " lock; decl %0 \n" " jns 2f \n" +#ifdef __clang__ /* clang's builtin assember can't do .subsection */ + "1: .pushsection .fixup,\"ax\"\n" +#else "1: .subsection 1 \n" +#endif "2: lock; incl %0 \n" " decl %1 \n" " jmp 1b \n" +#ifdef __clang__ + " .popsection \n" +#else" .subsection 0 \n" +#endif :"=m" (rw->lock),"=r" (acquired) :"1" (1 ) :"memory" );return acquired;
Re: [PATCH 5 of 7 v2] x86: don't use .subsection when compiling with clang
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1333640955 -3600
# Node ID0908535327a5b01e49b69cd96db464be21ff3ee6# Parenta93381049790e4f8a02f2322851f78175c254c5b
x86: don't use .subsection when compiling with clangLLVM's assembler doesn't support the .subsection directive, so put the out-of-line failure path in .fixup instead.
Given that it's a single place only, addressing this inline rather than creating a proper abstraction is probably fine, so ...
Quoted 1 line
Signed-off-by Tim Deegan <[email protected]>
Quoted 28 lines
diff -r
a93381049790-r0908535327a5xen/include/asm-x86/spinlock.hxen/include/asm-x86/spinlock.h +8
-0@@ -45,11 +45,19 @@ static always_inline int _raw_read_trylo asmvolatile ( " lock; decl %0 \n" " jns 2f \n" +#ifdef __clang__ /* clang's builtin assember can't do .subsection */ + "1: .pushsection .fixup,\"ax\"\n" +#else "1: .subsection 1 \n" +#endif "2: lock; incl %0 \n" " decl %1 \n" " jmp 1b \n" +#ifdef __clang__ + " .popsection \n" +#else" .subsection 0 \n" +#endif :"=m" (rw->lock),"=r" (acquired) :"1" (1 ) :"memory" );return acquired;_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v2 1/1 xen: define __section() and friends and use them for section annotations
In reply to Tim Deegan# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1333640955 -3600
# Node ID fba1917c638768c0a4e45c507c29f1020e08dfc1
# Parent 0908535327a5b01e49b69cd96db464be21ff3ee6
xen: define __section() and friends and use them for section annotations.
By itself this is just code-tidying, but it's also useful for the following patch, which will adjust __section() for clang compiles.
xen/include/asm-arm/cache.h +1 -1
@@ -7,7 +7,7 @@#define L1_CACHE_SHIFT (CONFIG_ARM_L1_CACHE_SHIFT)#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) -#define __read_mostly __attribute__((__section__(".data.read_mostly"))) +#define __read_mostly __section(".data.read_mostly")#endif /*
xen/include/asm-arm/percpu.h +1 -1
@@ -8,7 +8,7 @@ void percpu_init_areas(void);/* Separate out the type, so (int[3], foo) works. */ #define __DEFINE_PER_CPU (type, name, suffix) \ - __attribute__((__section__(".bss.percpu" #suffix))) \ + __section(".bss.percpu" #suffix) \ __typeof__(type) per_cpu_##name
xen/include/asm-x86/cache.h +1 -1
@@ -10,6 +10,6 @@#define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) -#define __read_mostly __attribute__((__section__(".data.read_mostly"))) +#define __read_mostly __section(".data.read_mostly")#endif
xen/include/asm-x86/percpu.h +1 -1
@@ -9,7 +9,7 @@ void percpu_init_areas(void);/* Separate out the type, so (int[3], foo) works. */ #define __DEFINE_PER_CPU (type, name, suffix) \ - __attribute__((__section__(".bss.percpu" #suffix))) \ + __section(".bss.percpu" #suffix) \ __typeof__(type) per_cpu_##name/* var is in discarded region: offset to particular copy we want */
xen/include/xen/compiler.h +4 -0
@@ -14,6 +14,10 @@#define always_inline __inline__ __attribute__ ((always_inline))#define noinline __attribute__((noinline)) +#define __section (s) __attribute__((__section__(s))) +#define __used_section (s) __attribute_used__ __attribute__((__section__(s))) +#define __text_section (s) __attribute__((__section__(s))) +#ifdef INIT_SECTIONS_ONLY /* * For sources indicated to have only init code, make sure even
xen/include/xen/init.h +8 -15
@@ -7,20 +7,13 @@* Mark functions and data as being only used at initialization * or exit time. */ -#define __init \ - __attribute__ ((__section__ (".init.text"))) -#define __exit \ - __attribute_used__ __attribute__ ((__section__(".exit.text"))) -#define __initdata \ - __attribute__ ((__section__ (".init.data"))) -#define __exitdata \ - __attribute_used__ __attribute__ ((__section__ (".exit.data"))) -#define __initsetup \ - __attribute_used__ __attribute__ ((__section__ (".init.setup"))) -#define __init_call (lvl) \ - __attribute_used__ __attribute__ ((__section__ (".initcall" lvl ".init"))) -#define __exit_call \ - __attribute_used__ __attribute__ ((__section__ (".exitcall.exit"))) +#define __init __text_section(".init.text") +#define __exit __text_section(".exit.text") +#define __initdata __section(".init.data") +#define __exitdata __used_section(".exit.data") +#define __initsetup __used_section(".init.setup") +#define __init_call (lvl) __used_section(".initcall" lvl ".init") +#define __exit_call __used_section(".exitcall.exit")/* These macros are used to mark some functions or * initialized data (doesn't apply to uninitialized data)
@@ -95,7 +88,7 @@ struct kernel_param {extern struct kernel_param __setup_start, __setup_end;#define __setup_str static __initdata __attribute__((__aligned__(1))) char -#define __kparam static __attribute_used__ __initsetup struct kernel_param +#define __kparam static __initsetup struct kernel_param#define custom_param (_name, _var) \ __setup_str __setup_str_##_var[] = _name; \
xen/include/xen/spinlock.h +2 -2
@@ -77,8 +77,8 @@ struct lock_profile_qhead {#define _LOCK_PROFILE (name) { 0, #name, &name, 0, 0, 0, 0, 0 }#define _LOCK_PROFILE_PTR (name) \ - static struct lock_profile *__lock_profile_##name __attribute_used__ \ - __attribute__ ((__section__(".lockprofile.data"))) = \ + static struct lock_profile *__lock_profile_##name \ + __used_section(".lockprofile.data") = \ &__lock_profile_data_##name#define _SPIN_LOCK_UNLOCKED (x) { _RAW_SPIN_LOCK_UNLOCKED, 0xfffu, 0, \ _LOCK_DEBUG, x }
xen/include/xsm/xsm.h +1 -1
@@ -44,7 +44,7 @@ extern xsm_initcall_t __xsm_initcall_sta#define xsm_initcall (fn) \ static xsm_initcall_t __initcall_##fn \ - __attribute_used__ __attribute__((__section__(".xsm_initcall.init"))) = fn + __used_section(".xsm_initcall.init") = fnstruct xsm_operations { void (*security_domaininfo) (struct domain *d,
PATCH v2 1/1 x86: explicitly mark __initdata variables as used when building with clang
In reply to Tim Deegan# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1333640955 -3600
# Node ID 51174f350092962ad36e406adf7ae1f173330a37
# Parent fba1917c638768c0a4e45c507c29f1020e08dfc1
x86: explicitly mark __initdata variables as used when building with clang.
This stops LLVM from replacing it with a different, auto-generated variable as part of an optimization. (The auto-generated variable ends up in the normal data section.)
Remove stray __read_mostly annotations on declarations that this unmasked.
xen/arch/x86/oprofile/op_x86_model.h +1 -1
@@ -53,6 +53,6 @@ extern struct op_x86_model_spec const opvoid arch_perfmon_setup_counters (void );extern int ppro_has_global_ctrl; -extern struct op_x86_model_spec const *__read_mostly model; +extern struct op_x86_model_spec const *model;#endif /* OP_X86_MODEL_H */
xen/include/acpi/cpufreq/cpufreq.h +1 -1
@@ -22,7 +22,7 @@DECLARE_PER_CPU (spinlock_t, cpufreq_statistic_lock); -extern bool_t __read_mostly cpufreq_verbose; +extern bool_t cpufreq_verbose;struct cpufreq_governor ;
xen/include/xen/compiler.h +6 -0
@@ -14,7 +14,13 @@#define always_inline __inline__ __attribute__ ((always_inline))#define noinline __attribute__((noinline)) +#ifdef __clang__ +/* Clang can replace some vars with new automatic ones that go in .data; +* mark all explicit-segment vars 'used' to prevent that. */ +#define __section (s) __attribute_used__ __attribute__((__section__(s))) +#else #define __section (s) __attribute__((__section__(s))) +#endif #define __used_section (s) __attribute_used__ __attribute__((__section__(s)))#define __text_section (s) __attribute__((__section__(s)))
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
This series makes the hypervisor build with clang/LLVM again, after a certain amount of bit-rot.
I ack-ed the ones I uesfully can; the rest looks good to me too but may need an ack from Keir.
Jan
Quoted 12 lines
Since v1:
- Changed an xmalloc+memset pair to xzalloc in the memset patch
- Reworked the spinlock patch not to touch gcc builds
- Added a patch to indirect all__section__directives through a macro.
- Commented up the ugly __attribute__((used)) change and moved it into the definition of__section()._______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Keir Fraser
Acked-byQuoted 6 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
This series makes the hypervisor build with clang/LLVM again, after a certain amount of bit-rot.
I ack-ed the ones I uesfully can; the rest looks good to me too but may need an ack from Keir.
I acked already, I think, but just in case
Quoted 22 lines
Jan
Quoted 8 lines
Since v1:
- Changed an xmalloc+memset pair to xzalloc in the memset patch
- Reworked the spinlock patch not to touch gcc builds
- Added a patch to indirect all__section__directives through a macro.
- Commented up the ugly __attribute__((used)) change and moved it into the definition of__section().Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel