From nobody Tue May 7 19:00:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1591088769; cv=none; d=zohomail.com; s=zohoarc; b=dd5NcakxrzX+ZRNg4JwavJwGqXMc6O/W1d76D1Kt7SSpmDBFmJ8arZFr5Zoubd6zjmw72ADv20lgcA8FgiPHKByDtZpfJwcRQhmBbPxi9XqsGL/4ENU5/pmjOKaKvRau0TPKcn0qbH6HQFWwPIKaNyOA0x65xRR3UL3QKr7wnuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591088769; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=VYwHdcBbOtApBtpxKsf/p0HmY13rUEqLYfKSLXwRRNc=; b=XnCDjd+atazn6cAY4NzLMkHtXp7t27a0MPv/IMxDnXIkzi5A6eE27dYCL/aKnxWga0lo0v9eccjI8jtcNfU7tpOyEp7Hfh42Yhdp492ildYcOiv2W2EEvrYJAM1nqOXEJU1BKbxsXsxLA+oHkYbFY/Xvet0VErvizHlbFpuJmdE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1591088769565512.1624525168393; Tue, 2 Jun 2020 02:06:09 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jg2rs-0003NQ-O2; Tue, 02 Jun 2020 09:05:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jg2rr-0003NK-AT for xen-devel@lists.xenproject.org; Tue, 02 Jun 2020 09:05:55 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 43733ab4-a4b0-11ea-81bc-bc764e2007e4; Tue, 02 Jun 2020 09:05:54 +0000 (UTC) X-Inumbo-ID: 43733ab4-a4b0-11ea-81bc-bc764e2007e4 Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: kJuVVCqWaC1yKgF0MoFq3FN+IQNKhZXJa/N49pGfOOE/yUUZ4DCgg2cf5ie6lmdLvDW5SmXl+S ggcxJv+6eAPKZPrTRRWrHAj586Godgjp+LqQzKRw1EHueIin6j0i7JRjjpP5PllP653lyHJoPX JJPpefpzpElyLvM2r74A6mKV7ftrec8Xe6NgzzZfD2bCys5wCL8kMH2kKjgEz3LXMHV+v5y8hH 9/VD+H/q56btrB9bIItjoBuTCQsZdKglxd9VoaCxytSQi7PaWrd0sciJiAHY5Vu33eohWWGjNg 32U= X-SBRS: 2.7 X-MesageID: 19253843 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,463,1583211600"; d="scan'208";a="19253843" From: Roger Pau Monne To: Subject: [PATCH for-4.14] x86/cpu: fix build with clang 3.5 Date: Tue, 2 Jun 2020 11:05:36 +0200 Message-ID: <20200602090536.38064-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Roger Pau Monne , Wei Liu , Jan Beulich , paul@xen.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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_H= IDE' ({ 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=C3=A9 Acked-by: Andrew Cooper Reviewed-by: Wei Liu --- 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 =3D smp_processor_id(); unsigned long stack_bottom =3D get_stack_bottom(), stack_top =3D 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 =3D &this_cpu(tss_page); =20 /* The TSS may be live. Disuade any clever optimisations. */ - volatile struct tss64 *tss =3D &this_cpu(tss_page).tss; + volatile struct tss64 *tss =3D &tss_page->tss; seg_desc_t *gdt =3D this_cpu(gdt) - FIRST_RESERVED_GDT_ENTRY; =20 @@ -783,15 +788,14 @@ void load_system_tables(void) * volatile qualifier. */ if (cpu_has_xen_shstk) { - volatile uint64_t *ist_ssp =3D this_cpu(tss_page).ist_ssp; + volatile uint64_t *ist_ssp =3D tss_page->ist_ssp; =20 ist_ssp[0] =3D 0x8600111111111111ul; ist_ssp[IST_MCE] =3D stack_top + (IST_MCE * IST_SHSTK_SIZE) - 8; ist_ssp[IST_NMI] =3D stack_top + (IST_NMI * IST_SHSTK_SIZE) - 8; ist_ssp[IST_DB] =3D stack_top + (IST_DB * IST_SHSTK_SIZE) - 8; ist_ssp[IST_DF] =3D stack_top + (IST_DF * IST_SHSTK_SIZE) - 8; - for ( i =3D IST_DF + 1; - i < ARRAY_SIZE(this_cpu(tss_page).ist_ssp); ++i ) + for ( i =3D IST_DF + 1; i < ARRAY_SIZE(tss_page->ist_ssp); ++i ) ist_ssp[i] =3D 0x8600111111111111ul; =20 wrmsrl(MSR_INTERRUPT_SSP_TABLE, (unsigned long)ist_ssp); --=20 2.26.2