[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN PATCH 1/7] xen: add declarations for variables where needed


  • To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 3 Oct 2023 09:18:17 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=I7rl69jIeMBWqT+PDZP16nV3Fk//DKmaif0o/A6sywQ=; b=bZIoCg+7318i6sYSQzDSf/d02R7fA7rsZ9WP8dhPBzVeQlHFk/HvNlU/K0lsqCA8vnP8D5VXLWzXRT1VGyv6FoNntdHbaLFTl+V6SNQ7yE+9VaWpUbqJRQRs+9XDBbR8vMWssBh8Jn4LTeZqhbS/ZS4eCHEqUj6mefbp0f81puHecK8Rmk61NOlxhmjfiZ22/OQnP7eJD450AlK65Rq0BYIZqS+FClyzLRzzhmF0XKabMJAmtoUhTSvUUfLX1bltPzXWW1ZDMuACtHUXRQyt8zA4gwbJdNzTGC0mln/riOPm6zsZLvt5ZzgLTSrriPCZ6UkYg5FBFNwpIH1EvhkmtA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nC+yM5KTgjVGvHt20xwxe7HNum2m5yqiY0fH/DvcrktddJoVlkPJt4IlZtyPArUJ2/bJ89g5pNc1HGn0X2GMX5nD2fH5M9hU01yJ21glMyvA5R7FlN5n2nsEGSi6kCHZy08lNZ176V+VoTi7J5ZndcdNaK54RfU5N4EU0mh4ZJb/5wfsJ4FoQeZTZ4hLZ1kiobokhLatNMqDbluo9RgOMovMUHgGBrAYJguqV2fTIvbejJ57wNNAGHL2ikWSNF6y0VPZEkv/z5uf7WlXQhApXP+zuq0eeVVmlhdJO3QoTgLv9Ux4mTY05S6yzSIF4SM0Ktu7r9tQAGvJa6SgwzpLig==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, sstabellini@xxxxxxxxxx, michal.orzel@xxxxxxx, xenia.ragiadakou@xxxxxxx, ayan.kumar.halder@xxxxxxx, consulting@xxxxxxxxxxx, jbeulich@xxxxxxxx, andrew.cooper3@xxxxxxxxxx, Henry.Wang@xxxxxxx, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 03 Oct 2023 07:18:35 +0000
  • Ironport-data: A9a23:YUeDi6rEzPeGiQVht1pPBB4bR/1eBmIJZRIvgKrLsJaIsI4StFCzt garIBnVaayOYTH0coh3bI2yoEwP75fXmNcyHAY/rSBgH3sXoJuZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbOCYmYpA1Y8FE/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKq04GhwUmAWP6gR5waGzyJNVvrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXABtRdR+clu2o+bb4EcpRheRzcc3hF6pK7xmMzRmBZRonabbqZvyToPN9gnI3jM0IGuvCb c0EbzYpdA7HfxBEJlYQDtQ5gfusgX78NTZfrTp5p4JuuzSVkFM3jeeraYWIEjCJbZw9ckKwv GXJ8n6/GhgHHNee1SCE4jSngeqncSbTAdhJTOLop6Ez6LGV7mtNFjATcFWfmOaapWv9W+BbJ HcrwwN7+MDe82TuFLERRSaQpn+PuRoVHcRdD/c77gClwLfb+AufCS4PSTspQMwrsoo6SCIn0 neNnsj1Hnp/vbuNU3Wf+7yI6zSoNkA9NnQebCUJSQ8E5djLo4wpiB/LCNF5H8adi9z+GTj0h TeQviU6r7wWgYgA0KDT1UDKhTOl4ILAQQ886gzUWX+N5wZ1IoWiYuSA4EnS67BDMYOQVB+Bt XwIltK25eUCS5qKkUSlS+ILB6yt+/eDPxXWnFF0Ep8usT+q/haLf4pd/TV/L0dBKdsfdHniZ 0q7kSNc4oVCekSja6Bfapi0Tc8tyMDIF8nhV/3SRspDZN52bgDv1Ctjf1KK1mbh1k0li7giO IyzeNypS30dDMxP8j2yQOsM1K4x8Qo3z2jTWJPTwgyu1PyVY3v9YagBGEuDaKY+9qzsnenO2 9NWNs/PxxABVuT7O3DT6dRKcg1MKmUnD5frrcARbvSEPgdtBGAmDbnW3K8lfItm2a9Sk48k4 02AZ6OR83Kn7VWvFOlAQioLhG/HNXqnkU8GAA==
  • Ironport-hdrordr: A9a23:DHDx7amxkl3BwyMkQ+JRR1cz8fPpDfLo3DAbv31ZSRFFG/Fw9/ rCoB17726QtN91YhsdcL+7V5VoLUmzyXcX2/hyAV7BZmnbUQKTRekP0WKL+Vbd8kbFh41gPM lbEpSXCLfLfCJHZcSR2njELz73quP3jJxBho3lvghQpRkBUdAF0+/gYDzranGfQmN9dP0EPa vZ3OVrjRy6d08aa8yqb0N1JNQq97Xw5fTbiQdtPW9f1DWz
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Oct 03, 2023 at 09:05:34AM +0200, Nicola Vetrini wrote:
> On 02/10/2023 13:07, Roger Pau Monné wrote:
> > On Mon, Oct 02, 2023 at 09:49:44AM +0200, Nicola Vetrini wrote:
> > > Some variables with external linkage used in C code do not have
> > > a visible declaration where they are defined. Providing such
> > > declaration also resolves violations of MISRA C:2012 Rule 8.4.
> > > 
> > > Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
> > > ---
> > >  xen/arch/arm/include/asm/setup.h  |  3 +++
> > >  xen/arch/arm/include/asm/smp.h    |  3 +++
> > >  xen/arch/x86/cpu/mcheck/mce.c     |  6 +++---
> > >  xen/arch/x86/include/asm/setup.h  |  3 +++
> > >  xen/arch/x86/irq.c                |  2 +-
> > >  xen/arch/x86/platform_hypercall.c |  3 ---
> > >  xen/common/symbols.c              | 17 -----------------
> > >  xen/include/xen/hypercall.h       |  3 +++
> > >  xen/include/xen/symbols.h         | 18 ++++++++++++++++++
> > >  9 files changed, 34 insertions(+), 24 deletions(-)
> > > 
> 
> > > diff --git a/xen/arch/x86/include/asm/setup.h
> > > b/xen/arch/x86/include/asm/setup.h
> > > index dfdd9e555149..3c27fe915ed4 100644
> > > --- a/xen/arch/x86/include/asm/setup.h
> > > +++ b/xen/arch/x86/include/asm/setup.h
> > > @@ -13,8 +13,11 @@ extern char __2M_rwdata_start[], __2M_rwdata_end[];
> > >  extern unsigned long xenheap_initial_phys_start;
> > >  extern uint64_t boot_tsc_stamp;
> > > 
> > > +extern char cpu0_stack[STACK_SIZE];
> > >  extern void *stack_start;
> > > 
> > > +extern unsigned long cr4_pv32_mask;
> > 
> > This one might better go in compat.h, albeit that would require it's
> > setting to be gated to CONFIG_PV32.  setup.h is IMO for init time
> > stuff.
> > 
> 
> Ok
> 
> > > +
> > >  void early_cpu_init(void);
> > >  void early_time_init(void);
> > > 
> > > diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
> > > index 6abfd8162120..604dba94b052 100644
> > > --- a/xen/arch/x86/irq.c
> > > +++ b/xen/arch/x86/irq.c
> > > @@ -43,7 +43,7 @@ int __read_mostly opt_irq_vector_map =
> > > OPT_IRQ_VECTOR_MAP_DEFAULT;
> > >  static unsigned char __read_mostly irq_max_guests;
> > >  integer_param("irq-max-guests", irq_max_guests);
> > > 
> > > -vmask_t global_used_vector_map;
> > > +static vmask_t global_used_vector_map;
> > > 
> > >  struct irq_desc __read_mostly *irq_desc = NULL;
> > > 
> > > diff --git a/xen/arch/x86/platform_hypercall.c
> > > b/xen/arch/x86/platform_hypercall.c
> > > index 9469de9045c7..e4dbec73d784 100644
> > > --- a/xen/arch/x86/platform_hypercall.c
> > > +++ b/xen/arch/x86/platform_hypercall.c
> > > @@ -36,9 +36,6 @@
> > >  #include "cpu/mtrr/mtrr.h"
> > >  #include <xsm/xsm.h>
> > > 
> > > -/* Declarations for items shared with the compat mode handler. */
> > > -extern spinlock_t xenpf_lock;
> > > -
> > >  #define RESOURCE_ACCESS_MAX_ENTRIES 3
> > >  struct resource_access {
> > >      unsigned int nr_done;
> > > diff --git a/xen/common/symbols.c b/xen/common/symbols.c
> > > index 691e61792506..7c3514c65f2e 100644
> > > --- a/xen/common/symbols.c
> > > +++ b/xen/common/symbols.c
> > > @@ -21,23 +21,6 @@
> > >  #include <xen/guest_access.h>
> > >  #include <xen/errno.h>
> > > 
> > > -#ifdef SYMBOLS_ORIGIN
> > > -extern const unsigned int symbols_offsets[];
> > > -#define symbols_address(n) (SYMBOLS_ORIGIN + symbols_offsets[n])
> > > -#else
> > > -extern const unsigned long symbols_addresses[];
> > > -#define symbols_address(n) symbols_addresses[n]
> > > -#endif
> > > -extern const unsigned int symbols_num_syms;
> > > -extern const u8 symbols_names[];
> > > -
> > > -extern const struct symbol_offset symbols_sorted_offsets[];
> > > -
> > > -extern const u8 symbols_token_table[];
> > > -extern const u16 symbols_token_index[];
> > > -
> > > -extern const unsigned int symbols_markers[];
> > > -
> > >  /* expand a compressed symbol data into the resulting uncompressed
> > > string,
> > >     given the offset to where the symbol is in the compressed stream
> > > */
> > >  static unsigned int symbols_expand_symbol(unsigned int off, char
> > > *result)
> > > diff --git a/xen/include/xen/hypercall.h b/xen/include/xen/hypercall.h
> > > index f307dfb59760..12de5a69b5b1 100644
> > > --- a/xen/include/xen/hypercall.h
> > > +++ b/xen/include/xen/hypercall.h
> > > @@ -24,6 +24,9 @@
> > >  /* Needs to be after asm/hypercall.h. */
> > >  #include <xen/hypercall-defs.h>
> > > 
> > > +/* Declarations for items shared with the compat mode handler. */
> > > +extern spinlock_t xenpf_lock;
> > 
> > I'm confused about why this needs to be moved, AFAICT xenpf_lock is
> > only used in platform_hypercall.c, and the declaration is
> > unconditional, so there's no definition without declaration issue.
> > 
> 
> The violation was on ARM code, because of a slight inconsistency:
> xen/arch/arm/platform_hypercall.c:DEFINE_SPINLOCK(xenpf_lock);
> 
> xen/arch/x86/platform_hypercall.c:extern spinlock_t xenpf_lock;
> xen/arch/x86/platform_hypercall.c:DEFINE_SPINLOCK(xenpf_lock);
> 
> therefore, by moving the extern declaration to the common header there
> should be no issue.

Just make xenpf_lock static on arm, that would be a better solution.
The only need for the lock to be global is because of compat code, and
arm doesn't seem to need it.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.