xen/x86: Fix build with Clang 3.5
cover xen/x86: Fix build with Clang 3.5
This is a misc assortment of patches to fix the build with Clang 3.5. The result also appears to function.
Andrew Cooper (8):
xen/lib: Fix ASSERT() to build with clang
xen/misc: Remove or annotate possibly-unused functions xen/x86: Remove %z modifier from inline assembly xen/x86: Fix section type mismatch in mm.c
xen/x86: Improve annotation of autogen_entrypoints[] xen/x86: Avoid overriding initialisers in arrays xen/x86: Fix get_cpu_info() when built with clang x86/efi: Generate uefi_call_wrapper() when compiling with clang
xen/arch/x86/cpu/mtrr/generic.c | 3 +-- xen/arch/x86/mm.c | 2 +- xen/arch/x86/mm/p2m-ept.c | 27 ++++++++++++++++----------- xen/arch/x86/mm/shadow/multi.c | 2 ++ xen/arch/x86/traps.c | 2 +- xen/arch/x86/xen.lds.S | 2 +- xen/arch/x86/xstate.c | 3 ++- xen/common/rcupdate.c | 6 ------ xen/include/asm-x86/current.h | 6 ++++++ xen/include/asm-x86/spinlock.h | 3 ++- xen/include/asm-x86/x86_64/efibind.h | 2 +- xen/include/xen/compat.h | 14 ++++++++------ xen/include/xen/lib.h | 2 +- 13 files changed, 42 insertions(+), 32 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/8 xen/lib: Fix ASSERT() to build with clang
Clang warns about a semicolon immediately following an if() clause as a possible mistake, and recommends putting the semicolon on a new line if it was intentional. A newline is not an option here, so use a set of empty braces instead.
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Ian Campbell <[email protected]>
--- xen/include/xen/lib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/xen/lib.h +1 -1
@@ -32,7 +32,7 @@#define ASSERT_UNREACHABLE () assert_failed("unreachable")#define debug_build () 1#else -#define ASSERT (p) do { if ( 0 && (p) ); } while (0) +#define ASSERT (p) do { if ( 0 && (p) ){} } while (0)#define ASSERT_UNREACHABLE () do { } while (0)#define debug_build () 0#endif
Signature · 1 line
2.1.4
PATCH 2/8 xen/misc: Remove or annotate possibly-unused functions
In reply to Andrew CooperClang notices more unused functions than GCC.
* sh_next_page() is only used at GUEST_PAGING_LEVELS=2, so remove it from the other guest level translation units
* rcu_batch_after() is completely unused.
* Various of the COMPAT() generated functions are used only for their BUILD_BUG_ON() properties. Annotate them all as __maybe_used.
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Ian Campbell <[email protected]>
--- xen/arch/x86/mm/shadow/multi.c | 2 ++ xen/common/rcupdate.c | 6 ------ xen/include/xen/compat.h | 14 ++++++++------ 3 files changed, 10 insertions(+), 12 deletions(-)
xen/arch/x86/mm/shadow/multi.c +2 -0
@@ -436,6 +436,7 @@ sh_cmpxchg_guest_entry(struct vcpu *v, intpte_t *p, intpte_t *old,* space.) */ +#if GUEST_PAGING_LEVELS ==2 /* From one page of a multi-page shadow, find the next one */ static inline mfn_t sh_next_page (mfn_t smfn) {
@@ -454,6 +455,7 @@ static inline mfn_t sh_next_page(mfn_t smfn)ASSERT (!next->u.sh.head); return page_to_mfn(next); } +#endif static inline u32 guest_index (void *ptr)
xen/common/rcupdate.c +0 -6
@@ -141,12 +141,6 @@ static inline int rcu_batch_before(long a, long b)return (a - b) <0 ; } -/* Is batch a after batch b ? */ -static inline int rcu_batch_after (long a,long b) -{ -return (a - b) >0 ; -} -static void force_quiescent_state (struct rcu_data *rdp,struct rcu_ctrlblk *rcp) {
xen/include/xen/compat.h +8 -6
@@ -134,14 +134,16 @@#define CHECK_NAME_ (k, n, tag) __check ## tag ## k ## _ ## n#define CHECK_TYPE (name) \ -static inline int CHECK_NAME(name, T)(xen_ ## name ## _t *x, \ - compat_ ## name ## _t *c) \ +static inline int __maybe_unused \ +CHECK_NAME(name, T)(xen_ ## name ## _t *x, \ + compat_ ## name ## _t *c) \ { \ return x == c; \ }#define CHECK_TYPE_ (k, n) \ -static inline int CHECK_NAME_(k, n, T)(k xen_ ## n *x, \ - k compat_ ## n *c) \ +static inline int __maybe_unused \ +CHECK_NAME_(k, n, T)(k xen_ ## n *x, \ + k compat_ ## n *c) \ { \ return x == c; \ }
@@ -154,14 +156,14 @@ static inline int CHECK_NAME_(k, n, T)(k xen_ ## n *x, \ sizeof(k compat_ ## n)) * 2]#define CHECK_FIELD_COMMON (name, t, f) \ -static inline int name(xen_ ## t ## _t *x, compat_ ## t ## _t *c) \ +static inline int __maybe_unused name(xen_ ## t ## _t *x, compat_ ## t ## _t *c) \ { \ BUILD_BUG_ON(offsetof(xen_ ## t ## _t, f) != \ offsetof(compat_ ## t ## _t, f)); \ return &x->f == &c->f; \ }#define CHECK_FIELD_COMMON_ (k, name, n, f) \ -static inline int name(k xen_ ## n *x, k compat_ ## n *c) \ +static inline int __maybe_unused name(k xen_ ## n *x, k compat_ ## n *c) \ { \ BUILD_BUG_ON(offsetof(k xen_ ## n, f) != \ offsetof(k compat_ ## n, f)); \
Signature · 1 line
2.1.4
Re: [PATCH 2/8] xen/misc: Remove or annotate possibly-unused functions
Quoted 9 lines · Andrew Cooper
Clang notices more unused functions than GCC.
*
sh_next_page()is only used at GUEST_PAGING_LEVELS=2, so remove it from the other guest level translation units
*rcu_batch_after()is completely unused.
* Various of theCOMPAT()generated functions are used only for theirBUILD_BUG_ON()properties. Annotate them all as__maybe_used.Signed-off-by Andrew Cooper <[email protected]>
Shadow stuff Acked-by: Tim Deegan <[email protected]>
Re: [PATCH 2/8] xen/misc: Remove or annotate possibly-unused functions
In reply to Andrew Cooperxen/common/rcupdate.c static inline int rcu_batch_before(long a, long b) · line 148
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 21:01, <[email protected]> wrote:
xen/common/rcupdate.c +0
-5@@ -141,12 +141,6 @@ static inline int rcu_batch_before(long a, long b)return (a - b) <0 ; } -/* Is batch a after batch b ? */ -static inline int rcu_batch_after (long a,long b) -{ -return (a - b) >0 ; -}
To me it is the nature of inline functions that they may or may not be used, regardless of whether they live in a header file (where I would have supposed Clang won't warn about, but the change below makes me assume I'm wrong) or in a source file.
Quoted 30 lines
xen/include/xen/compat.h +7
-5@@ -134,14 +134,16 @@#define CHECK_NAME_ (k, n, tag) __check ## tag ## k ## _ ## n#define CHECK_TYPE (name) \ -static inline int CHECK_NAME(name, T)(xen_ ## name ## _t *x, \ - compat_ ## name ## _t *c) \ +static inline int __maybe_unused \ +CHECK_NAME(name, T)(xen_ ## name ## _t *x, \ + compat_ ## name ## _t *c) \ { \ return x == c; \ }#define CHECK_TYPE_ (k, n) \ -static inline int CHECK_NAME_(k, n, T)(k xen_ ## n *x, \ - k compat_ ## n *c) \ +static inline int __maybe_unused \ +CHECK_NAME_(k, n, T)(k xen_ ## n *x, \ + k compat_ ## n *c) \ { \ return x == c; \ }@@ -154,14 +156,14 @@ static inline int CHECK_NAME_(k, n, T)(k xen_ ## n *x, \ sizeof(k compat_ ## n)) * 2]#define CHECK_FIELD_COMMON (name, t, f) \ -static inline int name(xen_ ## t ## _t *x, compat_ ## t ## _t *c) \ +static inline int __maybe_unused name(xen_ ## t ## _t *x, compat_ ## t ## _t *c) \ { \
xen/include/xen/compat.h static inline int CHECK_NAME_(k, n, T)(k xen_ ## n *x, \ · line 169
Quoted 10 lines
xen/include/xen/compat.h +1
-1BUILD_BUG_ON(offsetof(xen_ ## t ## _t, f) != \ offsetof(compat_ ## t ## _t, f)); \ return &x->f == &c->f; \ }#define CHECK_FIELD_COMMON_ (k, name, n, f) \ -static inline int name(k xen_ ## n *x, k compat_ ## n *c) \ +static inline int __maybe_unused name(k xen_ ## n *x, k compat_ ## n *c) \ { \ BUILD_BUG_ON(offsetof(k xen_ ## n, f) != \ offsetof(k compat_ ## n, f)); \
So if these are all noticed to be unused, why would others in other header files not be? I think there's at the very least some aspect missing in the description, explaining what makes these stand out from the others.
Jan
Re: [PATCH 2/8] xen/misc: Remove or annotate possibly-unused functions
Quoted 43 lines · Jan Beulich
xen/common/rcupdate.c static inline int rcu_batch_before(long a, long b) · line 148
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 21:01, <[email protected]> wrote:
xen/common/rcupdate.c +0
-5@@ -141,12 +141,6 @@ static inline int rcu_batch_before(long a, long b)return (a - b) <0 ; } -/* Is batch a after batch b ? */ -static inline int rcu_batch_after (long a,long b) -{ -return (a - b) >0 ; -}To me it is the nature of inline functions that they may or may not be used, regardless of whether they live in a header file (where I would have supposed Clang won't warn about, but the change below makes me assume I'm wrong) or in a source file.
Quoted 26 lines
xen/include/xen/compat.h +6
-4@@ -134,14 +134,16 @@#define CHECK_NAME_ (k, n, tag) __check ## tag ## k ## _ ## n#define CHECK_TYPE (name) \ -static inline int CHECK_NAME(name, T)(xen_ ## name ## _t *x, \ - compat_ ## name ## _t *c) \ +static inline int __maybe_unused \ +CHECK_NAME(name, T)(xen_ ## name ## _t *x, \ + compat_ ## name ## _t *c) \ { \ return x == c; \ }#define CHECK_TYPE_ (k, n) \ -static inline int CHECK_NAME_(k, n, T)(k xen_ ## n *x, \ - k compat_ ## n *c) \ +static inline int __maybe_unused \ +CHECK_NAME_(k, n, T)(k xen_ ## n *x, \ + k compat_ ## n *c) \ { \ return x == c; \ }@@ -154,14 +156,14 @@ static inline int CHECK_NAME_(k, n, T)(k xen_ ## n *x, \ sizeof(k compat_ ## n)) * 2]
Quoted 16 lines
Quoted 4 lines
xen/include/xen/compat.h +1
-1#define CHECK_FIELD_COMMON (name, t, f) \ -static inline int name(xen_ ## t ## _t *x, compat_ ## t ## _t *c) \ +static inline int __maybe_unused name(xen_ ## t ## _t *x, compat_ ## t ## _t *c) \ { \xen/include/xen/compat.h static inline int CHECK_NAME_(k, n, T)(k xen_ ## n *x, \ · line 169
Quoted 10 lines
xen/include/xen/compat.h +1
-1BUILD_BUG_ON(offsetof(xen_ ## t ## _t, f) != \ offsetof(compat_ ## t ## _t, f)); \ return &x->f == &c->f; \ }#define CHECK_FIELD_COMMON_ (k, name, n, f) \ -static inline int name(k xen_ ## n *x, k compat_ ## n *c) \ +static inline int __maybe_unused name(k xen_ ## n *x, k compat_ ## n *c) \ { \ BUILD_BUG_ON(offsetof(k xen_ ## n, f) != \ offsetof(k compat_ ## n, f)); \So if these are all noticed to be unused, why would others in other header files not be?
Because they are instantiated in translation units, with no callers, by code like common/trace.c:
#ifdef CONFIG_COMPAT
#include <compat/trace.h>
#define xen_t_buf t_bufCHECK_t_buf;
#undef xen_t_buf
#else
#define compat_t_rec t_rec
#endif
This was the first example which blew up.
~Andrew
PATCH 3/8 xen/x86: Remove %z modifier from inline assembly
In reply to Andrew CooperClang doesn't support the %z modifier. Replace both uses with an explicit l suffix, and cover the changes with BUILD_BUG_ON()s
---
CC: Jan Beulich <[email protected]>
--- xen/arch/x86/xstate.c | 3 ++- xen/include/asm-x86/spinlock.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
xen/arch/x86/xstate.c +2 -1
@@ -353,11 +353,12 @@ void xrstor(struct vcpu *v, uint64_t mask) {switch (__builtin_expect (ptr->fpu_sse.x[FPU_WORD_SIZE_OFFSET ],8 ) ) { +BUILD_BUG_ON (sizeof (faults) !=4 );/* Clang doesn't support %z in asm. */ #define XRSTOR (pfx) \ alternative_io("1: .byte " pfx "0x0f,0xae,0x2f\n" \ "3:\n" \ " .section .fixup,\"ax\"\n" \ - "2: inc%z[faults] %[faults]\n" \ + "2: incl %[faults]\n" \ " jmp 3b\n" \ " .previous\n" \ _ASM_EXTABLE(1b, 2b), \
xen/include/asm-x86/spinlock.h +2 -1
@@ -2,7 +2,8 @@#define __ASM_SPINLOCK_H#define _raw_read_unlock (l) \ - asm volatile ( "lock; dec%z0 %0" : "+m" ((l)->lock) :: "memory" ) + BUILD_BUG_ON(sizeof((l)->lock) != 4);/* Clang doesn't support %z in asm. */ \ + asmvolatile ("lock; decl %0" :"+m" ((l)->lock) ::"memory" )/* * On x86 the only reordering is of reads with older writes. In the
Signature · 1 line
2.1.4
Re: [PATCH 3/8] xen/x86: Remove %z modifier from inline assembly
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 21:01, <[email protected]> wrote:
Clang doesn't support the %z modifier. Replace both uses with an explicit l suffix, and cover the changes with BUILD_BUG_ON()s
Ugly. Really ugly. But well - what do you do.
Quoted 1 line
Signed-off-by Andrew Cooper <[email protected]>
PATCH 4/8 xen/x86: Fix section type mismatch in mm.c
In reply to Andrew CooperClang doesn't like mixing const and non-const data in the same section. Move zero_page into .bss.page_aligned.const and wildcard .bss.page_aligned when linking.
---
CC: Jan Beulich <[email protected]>
CC: George Dunlap <[email protected]>
--- xen/arch/x86/mm.c | 2 +- xen/arch/x86/xen.lds.S | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/mm.c +1 -1
@@ -577,7 +577,7 @@ static inline void guest_get_eff_kern_l1e(struct vcpu *v, unsigned long addr,TOGGLE_MODE (); } -static const char __section(".bss.page_aligned") zero_page[PAGE_SIZE]; +static const char __section(".bss.page_aligned.const") zero_page[PAGE_SIZE];static void invalidate_shadow_ldt (struct vcpu *v,int flush) {
xen/arch/x86/xen.lds.S +1 -1
@@ -170,7 +170,7 @@ SECTIONS __bss_start = .; *(.bss.stack_aligned) . = ALIGN(PAGE_SIZE); - *(.bss.page_aligned) + *(.bss.page_aligned*) *(.bss) . = ALIGN(SMP_CACHE_BYTES); __per_cpu_start = .;
Signature · 1 line
2.1.4
Re: [PATCH 4/8] xen/x86: Fix section type mismatch in mm.c
Quoted 5 lines · Andrew Cooper
Clang doesn't like mixing const and non-const data in the same section. Move
zero_pageinto .bss.page_aligned.const and wildcard .bss.page_aligned when linking.Signed-off-by Andrew Cooper <[email protected]>
Quoted 35 lines
---
CC: Jan Beulich <[email protected]>
CC: George Dunlap <[email protected]>--- xen/arch/x86/mm.c | 2 +- xen/arch/x86/xen.lds.S | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)xen/arch/x86/mm.c +1
-1@@ -577,7 +577,7 @@ static inline void guest_get_eff_kern_l1e(struct vcpu *v, unsigned long addr,TOGGLE_MODE (); } -static const char __section(".bss.page_aligned") zero_page[PAGE_SIZE]; +static const char __section(".bss.page_aligned.const") zero_page[PAGE_SIZE];static void invalidate_shadow_ldt (struct vcpu *v,int flush) {xen/arch/x86/xen.lds.S +1
-1@@ -170,7 +170,7 @@ SECTIONS __bss_start = .; *(.bss.stack_aligned) . = ALIGN(PAGE_SIZE); - *(.bss.page_aligned) + *(.bss.page_aligned*) *(.bss) . = ALIGN(SMP_CACHE_BYTES); __per_cpu_start = .;
PATCH 5/8 xen/x86: Improve annotation of autogen_entrypoints[]
In reply to Andrew CooperClang complains that the __used attribute is not applicable to an extern. In this case, the only relevent attribute is that the data is constant.
---
CC: Jan Beulich <[email protected]>
--- xen/arch/x86/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/traps.c +1 -1
@@ -3689,7 +3689,7 @@ void __init init_idt_traps(void)this_cpu (compat_gdt_table) = boot_cpu_compat_gdt_table; } -extern void (*__initconst autogen_entrypoints[NR_VECTORS ])(void ); +extern void (*const autogen_entrypoints[NR_VECTORS ])(void );void __init trap_init (void ) {unsigned int vector;
Signature · 1 line
2.1.4
PATCH 6/8 xen/x86: Avoid overriding initialisers in arrays
In reply to Andrew CooperClang objects to having multiple initialisers when creating an array.
As this warning is useful for spotting obscure bugs, disabling it is unhelpful. Instead, fix our two deliberate usecases.
In the p2m-ept case, pull the array out into a helper function, so the helper can guarentee to cover the NULL pointer case.
No functional change.
---
CC: Jan Beulich <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>
--- xen/arch/x86/cpu/mtrr/generic.c | 3 +-- xen/arch/x86/mm/p2m-ept.c | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 13 deletions(-)
xen/arch/x86/cpu/mtrr/generic.c +1 -2
@@ -91,7 +91,6 @@ static const char *__init mtrr_attrib_to_str(mtrr_type x) {static const char __initconst strings[MTRR_NUM_TYPES ][16 ] = { - [0 ...MTRR_NUM_TYPES -1 ] ="?" , [MTRR_TYPE_UNCACHABLE ] ="uncachable" , [MTRR_TYPE_WRCOMB ] ="write-combining" , [MTRR_TYPE_WRTHROUGH ] ="write-through" ,
@@ -99,7 +98,7 @@ static const char *__init mtrr_attrib_to_str(mtrr_type x) [MTRR_TYPE_WRBACK] = "write-back", }; -return x <MTRR_NUM_TYPES ? strings[x] :"?" ; +return x <MTRR_NUM_TYPES ? (strings[x] ?:"?" ) :"?" ; }static unsigned int __initdata last_fixed_start;
xen/arch/x86/mm/p2m-ept.c +16 -11
@@ -1201,6 +1201,20 @@ void ept_p2m_uninit(struct p2m_domain *p2m)free_cpumask_var (ept->invalidate); } +static const char *memory_type_to_str (unsigned int x) +{ +static const char memory_types[8 ][2 ] = { + [MTRR_TYPE_UNCACHABLE ] ="UC" , + [MTRR_TYPE_WRCOMB ] ="WC" , + [MTRR_TYPE_WRTHROUGH ] ="WT" , + [MTRR_TYPE_WRPROT ] ="WP" , + [MTRR_TYPE_WRBACK ] ="WB" , + [MTRR_NUM_TYPES ] ="??" + }; + +return x <ARRAY_SIZE (memory_types) ? (memory_types[x] ?:"?" ) :"?" ; +} +static void ept_dump_p2m_table (unsigned char key) {struct domain *d;
@@ -1212,15 +1226,6 @@ static void ept_dump_p2m_table(unsigned char key)unsigned long record_counter =0 ;struct p2m_domain *p2m;struct ept_data *ept; -static const char memory_types[8 ][2 ] = { - [0 ...7 ] ="?" , - [MTRR_TYPE_UNCACHABLE ] ="UC" , - [MTRR_TYPE_WRCOMB ] ="WC" , - [MTRR_TYPE_WRTHROUGH ] ="WT" , - [MTRR_TYPE_WRPROT ] ="WP" , - [MTRR_TYPE_WRBACK ] ="WB" , - [MTRR_NUM_TYPES ] ="??" - };for_each_domain (d) {
@@ -1260,8 +1265,8 @@ static void ept_dump_p2m_table(unsigned char key) ept_entry->r ?'r' :' ' , ept_entry->w ?'w' :' ' , ept_entry->x ?'x' :' ' , - memory_types[ept_entry->emt][0 ], - memory_types[ept_entry->emt][1 ] +memory_type_to_str (ept_entry->emt)[0 ], +memory_type_to_str (ept_entry->emt)[1 ] ?: ept_entry->emt +'0' , c ?: ept_entry->ipat ? '!' : ' ');
Signature · 1 line
2.1.4
Re: [PATCH 6/8] xen/x86: Avoid overriding initialisers in arrays
Quoted 11 lines · Andrew Cooper
Clang objects to having multiple initialisers when creating an array.
As this warning is useful for spotting obscure bugs, disabling it is unhelpful. Instead, fix our two deliberate usecases.
In the p2m-ept case, pull the array out into a helper function, so the helper can guarentee to cover the NULL pointer case.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>
Quoted 84 lines
---
CC: Jan Beulich <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>--- xen/arch/x86/cpu/mtrr/generic.c | 3 +-- xen/arch/x86/mm/p2m-ept.c | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 13 deletions(-)xen/arch/x86/cpu/mtrr/generic.c +1
-2@@ -91,7 +91,6 @@ static const char *__init mtrr_attrib_to_str(mtrr_type x) {static const char __initconst strings[MTRR_NUM_TYPES ][16 ] = { - [0 ...MTRR_NUM_TYPES -1 ] ="?" , [MTRR_TYPE_UNCACHABLE ] ="uncachable" , [MTRR_TYPE_WRCOMB ] ="write-combining" , [MTRR_TYPE_WRTHROUGH ] ="write-through" ,@@ -99,7 +98,7 @@ static const char *__init mtrr_attrib_to_str(mtrr_type x) [MTRR_TYPE_WRBACK] = "write-back", }; -return x <MTRR_NUM_TYPES ? strings[x] :"?" ; +return x <MTRR_NUM_TYPES ? (strings[x] ?:"?" ) :"?" ; }static unsigned int __initdata last_fixed_start;xen/arch/x86/mm/p2m-ept.c +16
-11@@ -1201,6 +1201,20 @@ void ept_p2m_uninit(struct p2m_domain *p2m)free_cpumask_var (ept->invalidate); } +static const char *memory_type_to_str (unsigned int x) +{ +static const char memory_types[8 ][2 ] = { + [MTRR_TYPE_UNCACHABLE ] ="UC" , + [MTRR_TYPE_WRCOMB ] ="WC" , + [MTRR_TYPE_WRTHROUGH ] ="WT" , + [MTRR_TYPE_WRPROT ] ="WP" , + [MTRR_TYPE_WRBACK ] ="WB" , + [MTRR_NUM_TYPES ] ="??" + }; + +return x <ARRAY_SIZE (memory_types) ? (memory_types[x] ?:"?" ) :"?" ; +} +static void ept_dump_p2m_table (unsigned char key) {struct domain *d;@@ -1212,15 +1226,6 @@ static void ept_dump_p2m_table(unsigned char key)unsigned long record_counter =0 ;struct p2m_domain *p2m;struct ept_data *ept; -static const char memory_types[8 ][2 ] = { - [0 ...7 ] ="?" , - [MTRR_TYPE_UNCACHABLE ] ="UC" , - [MTRR_TYPE_WRCOMB ] ="WC" , - [MTRR_TYPE_WRTHROUGH ] ="WT" , - [MTRR_TYPE_WRPROT ] ="WP" , - [MTRR_TYPE_WRBACK ] ="WB" , - [MTRR_NUM_TYPES ] ="??" - };for_each_domain (d) {@@ -1260,8 +1265,8 @@ static void ept_dump_p2m_table(unsigned char key) ept_entry->r ?'r' :' ' , ept_entry->w ?'w' :' ' , ept_entry->x ?'x' :' ' , - memory_types[ept_entry->emt][0 ], - memory_types[ept_entry->emt][1 ] +memory_type_to_str (ept_entry->emt)[0 ], +memory_type_to_str (ept_entry->emt)[1 ] ?: ept_entry->emt +'0' , c ?: ept_entry->ipat ? '!' : ' ');
Re: [PATCH 6/8] xen/x86: Avoid overriding initialisers in arrays
In reply to Andrew CooperQuoted 5 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 21:01, <[email protected]> wrote:
Clang objects to having multiple initialisers when creating an array.
As this warning is useful for spotting obscure bugs, disabling it is unhelpful. Instead, fix our two deliberate usecases.
Ugly again, but - well ...
Quoted 8 lines
xen/arch/x86/mm/p2m-ept.c +2
-0@@ -1201,6 +1201,20 @@ void ept_p2m_uninit(struct p2m_domain *p2m)free_cpumask_var (ept->invalidate); } +static const char *memory_type_to_str (unsigned int x) +{
xen/arch/x86/mm/p2m-ept.c void ept_p2m_uninit(struct p2m_domain *p2m) · line 1215
Quoted 10 lines
xen/arch/x86/mm/p2m-ept.c +10
-0+static const char memory_types[8 ][2 ] = { + [MTRR_TYPE_UNCACHABLE ] ="UC" , + [MTRR_TYPE_WRCOMB ] ="WC" , + [MTRR_TYPE_WRTHROUGH ] ="WT" , + [MTRR_TYPE_WRPROT ] ="WP" , + [MTRR_TYPE_WRBACK ] ="WB" , + [MTRR_NUM_TYPES ] ="??" + }; + +return x <ARRAY_SIZE (memory_types) ? (memory_types[x] ?:"?" ) :"?" ;
I think this should really ASSERT() the first condition.
Quoted 17 lines
xen/arch/x86/mm/p2m-ept.c +0
-9@@ -1212,15 +1226,6 @@ static void ept_dump_p2m_table(unsigned char key)unsigned long record_counter =0 ;struct p2m_domain *p2m;struct ept_data *ept; -static const char memory_types[8 ][2 ] = { - [0 ...7 ] ="?" , - [MTRR_TYPE_UNCACHABLE ] ="UC" , - [MTRR_TYPE_WRCOMB ] ="WC" , - [MTRR_TYPE_WRTHROUGH ] ="WT" , - [MTRR_TYPE_WRPROT ] ="WP" , - [MTRR_TYPE_WRBACK ] ="WB" , - [MTRR_NUM_TYPES ] ="??" - };for_each_domain (d) {
xen/arch/x86/mm/p2m-ept.c static void ept_dump_p2m_table(unsigned char key) · line 1271
Quoted 9 lines
xen/arch/x86/mm/p2m-ept.c +2
-2@@ -1260,8 +1265,8 @@ static void ept_dump_p2m_table(unsigned char key) ept_entry->r ?'r' :' ' , ept_entry->w ?'w' :' ' , ept_entry->x ?'x' :' ' , - memory_types[ept_entry->emt][0 ], - memory_types[ept_entry->emt][1 ] +memory_type_to_str (ept_entry->emt)[0 ], +memory_type_to_str (ept_entry->emt)[1 ] ?: ept_entry->emt +'0' , c ?: ept_entry->ipat ? '!' : ' ');
There's actually a bug here, which I think is worth fixing at once:
The default initializer was a string of length 1, resulting in a premature NUL character to get placed into the fully expanded string, causing - afaict - truncation of the intended message. I therefore think the default string should be e.g. "? ".
Jan
Re: [PATCH 6/8] xen/x86: Avoid overriding initialisers in arrays
Quoted 50 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 21:01, <[email protected]> wrote:
Clang objects to having multiple initialisers when creating an array.
As this warning is useful for spotting obscure bugs, disabling it is unhelpful. Instead, fix our two deliberate usecases.
Ugly again, but - well ...
Quoted 8 lines
xen/arch/x86/mm/p2m-ept.c +2
-0@@ -1201,6 +1201,20 @@ void ept_p2m_uninit(struct p2m_domain *p2m)free_cpumask_var (ept->invalidate); } +static const char *memory_type_to_str (unsigned int x) +{xen/arch/x86/mm/p2m-ept.c void ept_p2m_uninit(struct p2m_domain *p2m) · line 1215
Quoted 10 lines
xen/arch/x86/mm/p2m-ept.c +10
-0+static const char memory_types[8 ][2 ] = { + [MTRR_TYPE_UNCACHABLE ] ="UC" , + [MTRR_TYPE_WRCOMB ] ="WC" , + [MTRR_TYPE_WRTHROUGH ] ="WT" , + [MTRR_TYPE_WRPROT ] ="WP" , + [MTRR_TYPE_WRBACK ] ="WB" , + [MTRR_NUM_TYPES ] ="??" + }; + +return x <ARRAY_SIZE (memory_types) ? (memory_types[x] ?:"?" ) :"?" ;I think this should really
ASSERT()the first condition.Quoted 23 lines
xen/arch/x86/mm/p2m-ept.c +1
-11@@ -1212,15 +1226,6 @@ static void ept_dump_p2m_table(unsigned char key)unsigned long record_counter =0 ;struct p2m_domain *p2m;struct ept_data *ept; -static const char memory_types[8 ][2 ] = { - [0 ...7 ] ="?" , - [MTRR_TYPE_UNCACHABLE ] ="UC" , - [MTRR_TYPE_WRCOMB ] ="WC" , - [MTRR_TYPE_WRTHROUGH ] ="WT" , - [MTRR_TYPE_WRPROT ] ="WP" , - [MTRR_TYPE_WRBACK ] ="WB" , - [MTRR_NUM_TYPES ] ="??" - };for_each_domain (d) {@@ -1260,8 +1265,8 @@ static void ept_dump_p2m_table(unsigned char key) ept_entry->r ?'r' :' ' , ept_entry->w ?'w' :' ' , ept_entry->x ?'x' :' ' , - memory_types[ept_entry->emt][0 ], - memory_types[ept_entry->emt][1 ] + memory_type_to_str(ept_entry->emt)[0],
Quoted 8 lines
xen/arch/x86/mm/p2m-ept.c static void ept_dump_p2m_table(unsigned char key) · line 1271
Quoted 3 lines
xen/arch/x86/mm/p2m-ept.c +1
-0+memory_type_to_str (ept_entry->emt)[1 ] ?: ept_entry->emt +'0' , c ?: ept_entry->ipat ? '!' : ' ');There's actually a bug here, which I think is worth fixing at once:
The default initializer was a string of length 1, resulting in a premature NUL character to get placed into the fully expanded string, causing - afaict - truncation of the intended message. I therefore think the default string should be e.g. "? ".
The code is very opaque. However, that appears to be precisely how it is intended to work. (Having said that - it is your code from c/s 90e9c95f).
The following line will only format the raw emt value as a number if there is a NUL character returned from memory_type_to_str(). Putting a space in instead would break this.
~Andrew
Re: [PATCH 6/8] xen/x86: Avoid overriding initialisers in arrays
Quoted 61 lines
Quoted 1 line
Quoted 1 line · On 10.02.16 at 14:50, <[email protected]> wrote:
Quoted 50 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 21:01, <[email protected]> wrote:
Clang objects to having multiple initialisers when creating an array.
As this warning is useful for spotting obscure bugs, disabling it is unhelpful. Instead, fix our two deliberate usecases.
Ugly again, but - well ...
Quoted 8 lines
xen/arch/x86/mm/p2m-ept.c +2
-0@@ -1201,6 +1201,20 @@ void ept_p2m_uninit(struct p2m_domain *p2m)free_cpumask_var (ept->invalidate); } +static const char *memory_type_to_str (unsigned int x) +{xen/arch/x86/mm/p2m-ept.c void ept_p2m_uninit(struct p2m_domain *p2m) · line 1215
Quoted 10 lines
xen/arch/x86/mm/p2m-ept.c +10
-0+static const char memory_types[8 ][2 ] = { + [MTRR_TYPE_UNCACHABLE ] ="UC" , + [MTRR_TYPE_WRCOMB ] ="WC" , + [MTRR_TYPE_WRTHROUGH ] ="WT" , + [MTRR_TYPE_WRPROT ] ="WP" , + [MTRR_TYPE_WRBACK ] ="WB" , + [MTRR_NUM_TYPES ] ="??" + }; + +return x <ARRAY_SIZE (memory_types) ? (memory_types[x] ?:"?" ) :"?" ;I think this should really
ASSERT()the first condition.Quoted 23 lines
xen/arch/x86/mm/p2m-ept.c +1
-11@@ -1212,15 +1226,6 @@ static void ept_dump_p2m_table(unsigned char key)unsigned long record_counter =0 ;struct p2m_domain *p2m;struct ept_data *ept; -static const char memory_types[8 ][2 ] = { - [0 ...7 ] ="?" , - [MTRR_TYPE_UNCACHABLE ] ="UC" , - [MTRR_TYPE_WRCOMB ] ="WC" , - [MTRR_TYPE_WRTHROUGH ] ="WT" , - [MTRR_TYPE_WRPROT ] ="WP" , - [MTRR_TYPE_WRBACK ] ="WB" , - [MTRR_NUM_TYPES ] ="??" - };for_each_domain (d) {@@ -1260,8 +1265,8 @@ static void ept_dump_p2m_table(unsigned char key) ept_entry->r ?'r' :' ' , ept_entry->w ?'w' :' ' , ept_entry->x ?'x' :' ' , - memory_types[ept_entry->emt][0 ], - memory_types[ept_entry->emt][1 ] + memory_type_to_str(ept_entry->emt)[0],Quoted 8 lines
xen/arch/x86/mm/p2m-ept.c static void ept_dump_p2m_table(unsigned char key) · line 1271
Quoted 3 lines
xen/arch/x86/mm/p2m-ept.c +1
-0+memory_type_to_str (ept_entry->emt)[1 ] ?: ept_entry->emt +'0' , c ?: ept_entry->ipat ? '!' : ' ');There's actually a bug here, which I think is worth fixing at once:
The default initializer was a string of length 1, resulting in a premature NUL character to get placed into the fully expanded string, causing - afaict - truncation of the intended message. I therefore think the default string should be e.g. "? ".
Quoted 3 lines
The code is very opaque. However, that appears to be precisely how it is intended to work. (Having said that - it is your code from c/s
90e9c95f).
I know.
Quoted 3 lines
The following line will only format the raw emt value as a number if there is a NUL character returned from
memory_type_to_str(). Putting a space in instead would break this.
Oh, right - this is the operand to a ?:, not by itself passed to printk(). Line breaks like this (to aid people with old editors) are really undesirable in places like this...
Sorry for the noise,
Jan
Re: [PATCH 6/8] xen/x86: Avoid overriding initialisers in arrays
Quoted 67 lines · Jan Beulich
Quoted 61 lines
Quoted 1 line
Quoted 1 line · On 10.02.16 at 14:50, <[email protected]> wrote:
Quoted 50 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 21:01, <[email protected]> wrote:
Clang objects to having multiple initialisers when creating an array.
As this warning is useful for spotting obscure bugs, disabling it is unhelpful. Instead, fix our two deliberate usecases.
Ugly again, but - well ...
Quoted 8 lines
xen/arch/x86/mm/p2m-ept.c +2
-0@@ -1201,6 +1201,20 @@ void ept_p2m_uninit(struct p2m_domain *p2m)free_cpumask_var (ept->invalidate); } +static const char *memory_type_to_str (unsigned int x) +{xen/arch/x86/mm/p2m-ept.c void ept_p2m_uninit(struct p2m_domain *p2m) · line 1215
Quoted 10 lines
xen/arch/x86/mm/p2m-ept.c +10
-0+static const char memory_types[8 ][2 ] = { + [MTRR_TYPE_UNCACHABLE ] ="UC" , + [MTRR_TYPE_WRCOMB ] ="WC" , + [MTRR_TYPE_WRTHROUGH ] ="WT" , + [MTRR_TYPE_WRPROT ] ="WP" , + [MTRR_TYPE_WRBACK ] ="WB" , + [MTRR_NUM_TYPES ] ="??" + }; + +return x <ARRAY_SIZE (memory_types) ? (memory_types[x] ?:"?" ) :"?" ;I think this should really
ASSERT()the first condition.Quoted 23 lines
xen/arch/x86/mm/p2m-ept.c +1
-11@@ -1212,15 +1226,6 @@ static void ept_dump_p2m_table(unsigned char key)unsigned long record_counter =0 ;struct p2m_domain *p2m;struct ept_data *ept; -static const char memory_types[8 ][2 ] = { - [0 ...7 ] ="?" , - [MTRR_TYPE_UNCACHABLE ] ="UC" , - [MTRR_TYPE_WRCOMB ] ="WC" , - [MTRR_TYPE_WRTHROUGH ] ="WT" , - [MTRR_TYPE_WRPROT ] ="WP" , - [MTRR_TYPE_WRBACK ] ="WB" , - [MTRR_NUM_TYPES ] ="??" - };for_each_domain (d) {@@ -1260,8 +1265,8 @@ static void ept_dump_p2m_table(unsigned char key) ept_entry->r ?'r' :' ' , ept_entry->w ?'w' :' ' , ept_entry->x ?'x' :' ' , - memory_types[ept_entry->emt][0 ], - memory_types[ept_entry->emt][1 ] + memory_type_to_str(ept_entry->emt)[0],Quoted 8 lines
xen/arch/x86/mm/p2m-ept.c static void ept_dump_p2m_table(unsigned char key) · line 1271
Quoted 3 lines
xen/arch/x86/mm/p2m-ept.c +1
-0+memory_type_to_str (ept_entry->emt)[1 ] ?: ept_entry->emt +'0' , c ?: ept_entry->ipat ? '!' : ' ');There's actually a bug here, which I think is worth fixing at once:
The default initializer was a string of length 1, resulting in a premature NUL character to get placed into the fully expanded string, causing - afaict - truncation of the intended message. I therefore think the default string should be e.g. "? ".Quoted 3 lines
The code is very opaque. However, that appears to be precisely how it is intended to work. (Having said that - it is your code from c/s
90e9c95f).I know.
Quoted 7 lines
Quoted 3 lines
The following line will only format the raw emt value as a number if there is a NUL character returned from
memory_type_to_str(). Putting a space in instead would break this.Oh, right - this is the operand to a ?:, not by itself passed to
printk(). Line breaks like this (to aid people with old editors) are really undesirable in places like this...
Even more so over-clever undocumented code. If you're going to do things like this, you need to leave a comment near the string definition saying that the second byte being NULL is a flag for the printing routine to print the number, so that people who come along later (maybe even yourself, as in this case) know there's a dependency there.
-George
Re: [PATCH 6/8] xen/x86: Avoid overriding initialisers in arrays
In reply to Andrew CooperQuoted 8 lines
From: Andrew Cooper [mailto:[email protected]]
Sent: Wednesday, February 10, 2016 4:02 AMClang objects to having multiple initialisers when creating an array.
As this warning is useful for spotting obscure bugs, disabling it is unhelpful. Instead, fix our two deliberate usecases.
Quoted 6 lines
In the p2m-ept case, pull the array out into a helper function, so the helper can guarentee to cover the NULL pointer case.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>
PATCH 7/8 xen/x86: Fix get_cpu_info() when built with clang
In reply to Andrew CooperClang understands the GCCism in use here, but still complains that sp is unintialised. In such cases, resort to the older version of this code, which directly reads %rsp into the temporary variable.
Note that we still keep the GCCism in the default case, as it causes GCC to create rather better assembly.
---
CC: Jan Beulich <[email protected]>
--- xen/include/asm-x86/current.h | 6 ++++++ 1 file changed, 6 insertions(+)
xen/include/asm-x86/current.h +6 -0
@@ -47,7 +47,13 @@ struct cpu_info {static inline struct cpu_info *get_cpu_info (void ) { +#ifdef __clang__ +/* Clang complains that sp in the else case is not initialised. */ +unsigned long sp; + asm ("mov %%rsp, %0" :"=r" (sp) ); +#else registerunsigned long sp asm("rsp" ); +#endif return (struct cpu_info *)((sp & ~(STACK_SIZE -1 )) +STACK_SIZE ) -1 ; }
Signature · 1 line
2.1.4
PATCH 8/8 x86/efi: Generate uefi_call_wrapper() when compiling with clang
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
What is the GCC version check supposed to be achieving here? GCC has supported this syntax since 3.0
--- xen/include/asm-x86/x86_64/efibind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/asm-x86/x86_64/efibind.h +1 -1
@@ -274,7 +274,7 @@ typedef uint64_t UINTN;#endif #endif -#if __GNUC__ >4 || (__GNUC__ ==4 && __GNUC_MINOR__ >=4 ) +#if __GNUC__ >4 || (__GNUC__ ==4 && __GNUC_MINOR__ >=4 ) || __clang__#define uefi_call_wrapper (func, va_num, ...) func(__VA_ARGS__)#else /* for x86_64, EFI_FUNCTION_WRAPPER must be defined */
Signature · 1 line
2.1.4
Re: [PATCH 8/8] x86/efi: Generate uefi_call_wrapper() when compiling with clang
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 21:01, <[email protected]> wrote:
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>What is the GCC version check supposed to be achieving here? GCC has supported this syntax since 3.0
This is best answered by looking at where we've got these headers from - the gnu-efi package. It has ...
xen/include/asm-x86/x86_64/efibind.h typedef uint64_t UINTN; · line 280
Quoted 11 lines
xen/include/asm-x86/x86_64/efibind.h +1
-1@@ -274,7 +274,7 @@ typedef uint64_t UINTN;#endif #endif -#if __GNUC__ >4 || (__GNUC__ ==4 && __GNUC_MINOR__ >=4 ) +#if __GNUC__ >4 || (__GNUC__ ==4 && __GNUC_MINOR__ >=4 ) || __clang__#define uefi_call_wrapper (func, va_num, ...) func(__VA_ARGS__)#else /* for x86_64, EFI_FUNCTION_WRAPPER must be defined */
/* for x86_64, EFI_FUNCTION_WRAPPER must be defined */ #if defined(HAVE_USE_MS_ABI)
#define uefi_call_wrapper(func, va_num, ...) func(__VA_ARGS__) #else
UINTN uefi_call_wrapper(void *func, unsigned long va_num, ...); #endif
#define EFI_FUNCTION __attribute__((ms_abi))
I think this makes clear that the needed feature here is the attribute, which certainly wasn't available in older gcc.
With that the question is whether the Clang case won't also need a version check, since I can't imagine them having supported this prior to gcc introducing it.
Jan
Re: [PATCH 8/8] x86/efi: Generate uefi_call_wrapper() when compiling with clang
Quoted 29 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 21:01, <[email protected]> wrote:
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>What is the GCC version check supposed to be achieving here? GCC has supported this syntax since 3.0
This is best answered by looking at where we've got these headers from - the gnu-efi package. It has ...
xen/include/asm-x86/x86_64/efibind.h typedef uint64_t UINTN; · line 280
Quoted 11 lines
xen/include/asm-x86/x86_64/efibind.h +1
-1@@ -274,7 +274,7 @@ typedef uint64_t UINTN;#endif #endif -#if __GNUC__ >4 || (__GNUC__ ==4 && __GNUC_MINOR__ >=4 ) +#if __GNUC__ >4 || (__GNUC__ ==4 && __GNUC_MINOR__ >=4 ) || __clang__#define uefi_call_wrapper (func, va_num, ...) func(__VA_ARGS__)#else /* for x86_64, EFI_FUNCTION_WRAPPER must be defined */ /* for
x86_64,EFI_FUNCTION_WRAPPERmust be defined */ #ifdefined(HAVE_USE_MS_ABI)
#defineuefi_call_wrapper(func, va_num, ...)func(__VA_ARGS__)#else
UINTNuefi_call_wrapper(void *func, unsigned long va_num, ...); #endif
#defineEFI_FUNCTION__attribute__((ms_abi))
Quoted 6 lines
I think this makes clear that the needed feature here is the attribute, which certainly wasn't available in older gcc.
With that the question is whether the Clang case won't also need a version check, since I can't imagine them having supported this prior to gcc introducing it.
Clang has an substantially more sane way than GCC of checking for individual features. I will introduce and use the __has_{attribute,feature}() infrastructure to tests like this.
Experimentally, Clang 3.5 does have ms_abi support
~Andrew
Re: [PATCH 8/8] x86/efi: Generate uefi_call_wrapper() when compiling with clang
Quoted 33 lines · Andrew Cooper
Quoted 32 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 21:01, <[email protected]> wrote:
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>What is the GCC version check supposed to be achieving here? GCC has supported this syntax since 3.0
This is best answered by looking at where we've got these headers from - the gnu-efi package. It has ...
xen/include/asm-x86/x86_64/efibind.h typedef uint64_t UINTN; · line 280
Quoted 11 lines
xen/include/asm-x86/x86_64/efibind.h +1
-1@@ -274,7 +274,7 @@ typedef uint64_t UINTN;#endif #endif -#if __GNUC__ >4 || (__GNUC__ ==4 && __GNUC_MINOR__ >=4 ) +#if __GNUC__ >4 || (__GNUC__ ==4 && __GNUC_MINOR__ >=4 ) || __clang__#define uefi_call_wrapper (func, va_num, ...) func(__VA_ARGS__)#else /* for x86_64, EFI_FUNCTION_WRAPPER must be defined */ /* for
x86_64,EFI_FUNCTION_WRAPPERmust be defined */ #ifdefined(HAVE_USE_MS_ABI)
#defineuefi_call_wrapper(func, va_num, ...)func(__VA_ARGS__)#else
UINTNuefi_call_wrapper(void *func, unsigned long va_num, ...); #endif
#defineEFI_FUNCTION__attribute__((ms_abi))I think this makes clear that the needed feature here is the attribute, which certainly wasn't available in older gcc.
Quoted 8 lines
Quoted 3 lines
With that the question is whether the Clang case won't also need a version check, since I can't imagine them having supported this prior to gcc introducing it.
Clang has an substantially more sane way than GCC of checking for individual features. I will introduce and use the __has_{attribute,feature}() infrastructure to tests like this.
Experimentally, Clang 3.5 does have
ms_abisupport
Looking at it further, this entire block is unsed. Nothing in tree refers to uefi_call_wrapper() or EFI_FUNCTION_WRAPPER other than this small bit; all declarations use EFIABI directly.
i.e. this:
(quoted diff) +0 -0
b/xen/include/asm-x86/x86_64/efibind.h
index af5f424..b013db1 100644
xen/include/asm-x86/x86_64/efibind.h +0 -11
@@ -274,17 +274,6 @@ typedef uint64_t UINTN;#endif #endif -#if __GNUC__ >4 || (__GNUC__ ==4 && __GNUC_MINOR__ >=4 ) -#define uefi_call_wrapper (func, va_num, ...) func(__VA_ARGS__) -#else -/* for x86_64, EFI_FUNCTION_WRAPPER must be defined */ -#ifdef EFI_FUNCTION_WRAPPER -UINTN uefi_call_wrapper (void *func,unsigned long va_num, ...); -#else -#error "EFI_FUNCTION_WRAPPER must be defined for x86_64 architecture" -#endif -#endif -#ifdef _MSC_EXTENSIONS#pragma warning ( disable : 4731 ) // Suppress warnings about
modification of EBP
#endif
works correctly for GCC and clang. Would dropping this completely be acceptable?
~Andrew
Re: [PATCH 8/8] x86/efi: Generate uefi_call_wrapper() when compiling with clang
Quoted 75 lines
Quoted 1 line
Quoted 1 line · On 10.02.16 at 20:11, <[email protected]> wrote:
Quoted 33 lines · Andrew Cooper
Quoted 32 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 21:01, <[email protected]> wrote:
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>What is the GCC version check supposed to be achieving here? GCC has supported this syntax since 3.0
This is best answered by looking at where we've got these headers from - the gnu-efi package. It has ...
xen/include/asm-x86/x86_64/efibind.h typedef uint64_t UINTN; · line 280
Quoted 11 lines
xen/include/asm-x86/x86_64/efibind.h +1
-1@@ -274,7 +274,7 @@ typedef uint64_t UINTN;#endif #endif -#if __GNUC__ >4 || (__GNUC__ ==4 && __GNUC_MINOR__ >=4 ) +#if __GNUC__ >4 || (__GNUC__ ==4 && __GNUC_MINOR__ >=4 ) || __clang__#define uefi_call_wrapper (func, va_num, ...) func(__VA_ARGS__)#else /* for x86_64, EFI_FUNCTION_WRAPPER must be defined */ /* for
x86_64,EFI_FUNCTION_WRAPPERmust be defined */ #ifdefined(HAVE_USE_MS_ABI)
#defineuefi_call_wrapper(func, va_num, ...)func(__VA_ARGS__)#else
UINTNuefi_call_wrapper(void *func, unsigned long va_num, ...); #endif
#defineEFI_FUNCTION__attribute__((ms_abi))I think this makes clear that the needed feature here is the attribute, which certainly wasn't available in older gcc.
Quoted 8 lines
Quoted 3 lines
With that the question is whether the Clang case won't also need a version check, since I can't imagine them having supported this prior to gcc introducing it.
Clang has an substantially more sane way than GCC of checking for individual features. I will introduce and use the __has_{attribute,feature}() infrastructure to tests like this.
Experimentally, Clang 3.5 does have
ms_abisupportLooking at it further, this entire block is unsed. Nothing in tree refers to
uefi_call_wrapper()orEFI_FUNCTION_WRAPPERother than this small bit; all declarations use EFIABI directly.i.e. this:
xen/include/asm-x86/x86_64/efibind.h +0
-11@@ -274,17 +274,6 @@ typedef uint64_t UINTN;#endif #endif -#if __GNUC__ >4 || (__GNUC__ ==4 && __GNUC_MINOR__ >=4 ) -#define uefi_call_wrapper (func, va_num, ...) func(__VA_ARGS__) -#else -/* for x86_64, EFI_FUNCTION_WRAPPER must be defined */ -#ifdef EFI_FUNCTION_WRAPPER -UINTN uefi_call_wrapper (void *func,unsigned long va_num, ...); -#else -#error "EFI_FUNCTION_WRAPPER must be defined for x86_64 architecture" -#endif -#endif -#ifdef _MSC_EXTENSIONS#pragma warning ( disable : 4731 ) // Suppress warnings aboutmodification of EBP
#endif
Quoted 2 lines
works correctly for GCC and clang. Would dropping this completely be acceptable?
We perhaps might as well; I had mainly kept it to stay as close to the original header as possible (without leaving around a latent build breakage).
Jan
Quoted 3 lines · Andrew Cooper
This is a misc assortment of patches to fix the build with Clang 3.5. The result also appears to function.
Manually ran the build here:
https://travis-ci.org/cardoe/xen/builds/108116078
Signature · 1 line
Doug Goldstein
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 1 line · Andrew Cooper
This is a misc assortment of patches to fix the build with Clang 3.5.
FWIW clang 3.5 appears to be in Debian Jessie, which means the path to having a build job in osstest is far shorter than it once was if anyone is interested in adding such a thing.
Ian.