* [PATCH for-4.14] x86/cpu: fix build with clang 3.5
@ 2020-06-02 9:05 Roger Pau Monne
2020-06-02 9:21 ` Paul Durrant
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Roger Pau Monne @ 2020-06-02 9:05 UTC (permalink / raw)
To: xen-devel; +Cc: Andrew Cooper, Roger Pau Monne, Wei Liu, Jan Beulich, paul
Clang 3.5 complains with:
common.c:794:24: error: statement expression not allowed at file scope
i < ARRAY_SIZE(this_cpu(tss_page).ist_ssp); ++i )
^
/build/xen/include/asm/percpu.h:14:7: note: expanded from macro 'this_cpu'
(*RELOC_HIDE(&per_cpu__##var, get_cpu_info()->per_cpu_offset))
^
/build/xen/include/xen/compiler.h:104:3: note: expanded from macro 'RELOC_HIDE'
({ unsigned long __ptr; \
^
/build/xen/include/xen/lib.h:68:69: note: expanded from macro 'ARRAY_SIZE'
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]) + __must_be_array(x))
^
/build/xen/include/xen/compiler.h:85:57: note: expanded from macro '__must_be_array'
BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
^
/build/xen/include/xen/lib.h:39:57: note: expanded from macro 'BUILD_BUG_ON_ZERO'
#define BUILD_BUG_ON_ZERO(cond) sizeof(struct { int:-!!(cond); })
^
Workaround this by defining the tss_page as a local variable. Adjust
other users of the per-cpu tss_page to also use the newly introduced
local variable.
No functional change expected.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
xen/arch/x86/cpu/common.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index 58f0876180..da74172776 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -738,9 +738,14 @@ void load_system_tables(void)
unsigned int i, cpu = smp_processor_id();
unsigned long stack_bottom = get_stack_bottom(),
stack_top = stack_bottom & ~(STACK_SIZE - 1);
+ /*
+ * NB: define tss_page as a local variable because clang 3.5 doesn't
+ * support using ARRAY_SIZE against per-cpu variables.
+ */
+ struct tss_page *tss_page = &this_cpu(tss_page);
/* The TSS may be live. Disuade any clever optimisations. */
- volatile struct tss64 *tss = &this_cpu(tss_page).tss;
+ volatile struct tss64 *tss = &tss_page->tss;
seg_desc_t *gdt =
this_cpu(gdt) - FIRST_RESERVED_GDT_ENTRY;
@@ -783,15 +788,14 @@ void load_system_tables(void)
* volatile qualifier.
*/
if (cpu_has_xen_shstk) {
- volatile uint64_t *ist_ssp = this_cpu(tss_page).ist_ssp;
+ volatile uint64_t *ist_ssp = tss_page->ist_ssp;
ist_ssp[0] = 0x8600111111111111ul;
ist_ssp[IST_MCE] = stack_top + (IST_MCE * IST_SHSTK_SIZE) - 8;
ist_ssp[IST_NMI] = stack_top + (IST_NMI * IST_SHSTK_SIZE) - 8;
ist_ssp[IST_DB] = stack_top + (IST_DB * IST_SHSTK_SIZE) - 8;
ist_ssp[IST_DF] = stack_top + (IST_DF * IST_SHSTK_SIZE) - 8;
- for ( i = IST_DF + 1;
- i < ARRAY_SIZE(this_cpu(tss_page).ist_ssp); ++i )
+ for ( i = IST_DF + 1; i < ARRAY_SIZE(tss_page->ist_ssp); ++i )
ist_ssp[i] = 0x8600111111111111ul;
wrmsrl(MSR_INTERRUPT_SSP_TABLE, (unsigned long)ist_ssp);
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH for-4.14] x86/cpu: fix build with clang 3.5
2020-06-02 9:05 [PATCH for-4.14] x86/cpu: fix build with clang 3.5 Roger Pau Monne
@ 2020-06-02 9:21 ` Paul Durrant
2020-06-02 9:22 ` Wei Liu
2020-06-02 9:49 ` Andrew Cooper
2 siblings, 0 replies; 4+ messages in thread
From: Paul Durrant @ 2020-06-02 9:21 UTC (permalink / raw)
To: 'Roger Pau Monne', xen-devel
Cc: 'Andrew Cooper', 'Wei Liu', 'Jan Beulich'
> -----Original Message-----
> From: Roger Pau Monne <roger.pau@citrix.com>
> Sent: 02 June 2020 10:06
> To: xen-devel@lists.xenproject.org
> Cc: paul@xen.org; Roger Pau Monne <roger.pau@citrix.com>; Jan Beulich <jbeulich@suse.com>; Andrew
> Cooper <andrew.cooper3@citrix.com>; Wei Liu <wl@xen.org>
> Subject: [PATCH for-4.14] x86/cpu: fix build with clang 3.5
>
> Clang 3.5 complains with:
>
> common.c:794:24: error: statement expression not allowed at file scope
> i < ARRAY_SIZE(this_cpu(tss_page).ist_ssp); ++i )
> ^
> /build/xen/include/asm/percpu.h:14:7: note: expanded from macro 'this_cpu'
> (*RELOC_HIDE(&per_cpu__##var, get_cpu_info()->per_cpu_offset))
> ^
> /build/xen/include/xen/compiler.h:104:3: note: expanded from macro 'RELOC_HIDE'
> ({ unsigned long __ptr; \
> ^
> /build/xen/include/xen/lib.h:68:69: note: expanded from macro 'ARRAY_SIZE'
> #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]) + __must_be_array(x))
> ^
> /build/xen/include/xen/compiler.h:85:57: note: expanded from macro '__must_be_array'
> BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
> ^
> /build/xen/include/xen/lib.h:39:57: note: expanded from macro 'BUILD_BUG_ON_ZERO'
> #define BUILD_BUG_ON_ZERO(cond) sizeof(struct { int:-!!(cond); })
> ^
>
> Workaround this by defining the tss_page as a local variable. Adjust
> other users of the per-cpu tss_page to also use the newly introduced
> local variable.
>
> No functional change expected.
>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Release-acked-by: Paul Durrant <paul@xen.org>
> ---
> xen/arch/x86/cpu/common.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
> index 58f0876180..da74172776 100644
> --- a/xen/arch/x86/cpu/common.c
> +++ b/xen/arch/x86/cpu/common.c
> @@ -738,9 +738,14 @@ void load_system_tables(void)
> unsigned int i, cpu = smp_processor_id();
> unsigned long stack_bottom = get_stack_bottom(),
> stack_top = stack_bottom & ~(STACK_SIZE - 1);
> + /*
> + * NB: define tss_page as a local variable because clang 3.5 doesn't
> + * support using ARRAY_SIZE against per-cpu variables.
> + */
> + struct tss_page *tss_page = &this_cpu(tss_page);
>
> /* The TSS may be live. Disuade any clever optimisations. */
> - volatile struct tss64 *tss = &this_cpu(tss_page).tss;
> + volatile struct tss64 *tss = &tss_page->tss;
> seg_desc_t *gdt =
> this_cpu(gdt) - FIRST_RESERVED_GDT_ENTRY;
>
> @@ -783,15 +788,14 @@ void load_system_tables(void)
> * volatile qualifier.
> */
> if (cpu_has_xen_shstk) {
> - volatile uint64_t *ist_ssp = this_cpu(tss_page).ist_ssp;
> + volatile uint64_t *ist_ssp = tss_page->ist_ssp;
>
> ist_ssp[0] = 0x8600111111111111ul;
> ist_ssp[IST_MCE] = stack_top + (IST_MCE * IST_SHSTK_SIZE) - 8;
> ist_ssp[IST_NMI] = stack_top + (IST_NMI * IST_SHSTK_SIZE) - 8;
> ist_ssp[IST_DB] = stack_top + (IST_DB * IST_SHSTK_SIZE) - 8;
> ist_ssp[IST_DF] = stack_top + (IST_DF * IST_SHSTK_SIZE) - 8;
> - for ( i = IST_DF + 1;
> - i < ARRAY_SIZE(this_cpu(tss_page).ist_ssp); ++i )
> + for ( i = IST_DF + 1; i < ARRAY_SIZE(tss_page->ist_ssp); ++i )
> ist_ssp[i] = 0x8600111111111111ul;
>
> wrmsrl(MSR_INTERRUPT_SSP_TABLE, (unsigned long)ist_ssp);
> --
> 2.26.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH for-4.14] x86/cpu: fix build with clang 3.5
2020-06-02 9:05 [PATCH for-4.14] x86/cpu: fix build with clang 3.5 Roger Pau Monne
2020-06-02 9:21 ` Paul Durrant
@ 2020-06-02 9:22 ` Wei Liu
2020-06-02 9:49 ` Andrew Cooper
2 siblings, 0 replies; 4+ messages in thread
From: Wei Liu @ 2020-06-02 9:22 UTC (permalink / raw)
To: Roger Pau Monne; +Cc: xen-devel, Andrew Cooper, Wei Liu, Jan Beulich, paul
On Tue, Jun 02, 2020 at 11:05:36AM +0200, Roger Pau Monne wrote:
> Clang 3.5 complains with:
>
> common.c:794:24: error: statement expression not allowed at file scope
> i < ARRAY_SIZE(this_cpu(tss_page).ist_ssp); ++i )
> ^
> /build/xen/include/asm/percpu.h:14:7: note: expanded from macro 'this_cpu'
> (*RELOC_HIDE(&per_cpu__##var, get_cpu_info()->per_cpu_offset))
> ^
> /build/xen/include/xen/compiler.h:104:3: note: expanded from macro 'RELOC_HIDE'
> ({ unsigned long __ptr; \
> ^
> /build/xen/include/xen/lib.h:68:69: note: expanded from macro 'ARRAY_SIZE'
> #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]) + __must_be_array(x))
> ^
> /build/xen/include/xen/compiler.h:85:57: note: expanded from macro '__must_be_array'
> BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
> ^
> /build/xen/include/xen/lib.h:39:57: note: expanded from macro 'BUILD_BUG_ON_ZERO'
> #define BUILD_BUG_ON_ZERO(cond) sizeof(struct { int:-!!(cond); })
> ^
>
> Workaround this by defining the tss_page as a local variable. Adjust
> other users of the per-cpu tss_page to also use the newly introduced
> local variable.
>
> No functional change expected.
>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Wei Liu <wl@xen.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH for-4.14] x86/cpu: fix build with clang 3.5
2020-06-02 9:05 [PATCH for-4.14] x86/cpu: fix build with clang 3.5 Roger Pau Monne
2020-06-02 9:21 ` Paul Durrant
2020-06-02 9:22 ` Wei Liu
@ 2020-06-02 9:49 ` Andrew Cooper
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2020-06-02 9:49 UTC (permalink / raw)
To: Roger Pau Monne, xen-devel; +Cc: Wei Liu, Jan Beulich, paul
On 02/06/2020 10:05, Roger Pau Monne wrote:
> Clang 3.5 complains with:
>
> common.c:794:24: error: statement expression not allowed at file scope
> i < ARRAY_SIZE(this_cpu(tss_page).ist_ssp); ++i )
> ^
> /build/xen/include/asm/percpu.h:14:7: note: expanded from macro 'this_cpu'
> (*RELOC_HIDE(&per_cpu__##var, get_cpu_info()->per_cpu_offset))
> ^
> /build/xen/include/xen/compiler.h:104:3: note: expanded from macro 'RELOC_HIDE'
> ({ unsigned long __ptr; \
> ^
> /build/xen/include/xen/lib.h:68:69: note: expanded from macro 'ARRAY_SIZE'
> #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]) + __must_be_array(x))
> ^
> /build/xen/include/xen/compiler.h:85:57: note: expanded from macro '__must_be_array'
> BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
> ^
> /build/xen/include/xen/lib.h:39:57: note: expanded from macro 'BUILD_BUG_ON_ZERO'
> #define BUILD_BUG_ON_ZERO(cond) sizeof(struct { int:-!!(cond); })
> ^
>
> Workaround this by defining the tss_page as a local variable. Adjust
> other users of the per-cpu tss_page to also use the newly introduced
> local variable.
>
> No functional change expected.
>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Sorry for more carnage.
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-02 9:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02 9:05 [PATCH for-4.14] x86/cpu: fix build with clang 3.5 Roger Pau Monne
2020-06-02 9:21 ` Paul Durrant
2020-06-02 9:22 ` Wei Liu
2020-06-02 9:49 ` Andrew Cooper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).