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

RE: [PATCH] xen/arm: setup: nr_banks should be unsigned int


  • To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Wei Chen <Wei.Chen@xxxxxxx>
  • Date: Tue, 24 May 2022 01:07:03 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=LYzxOUjOLbqe1e4CwOaHvw457RqSw57OYffXqwCDFb4=; b=Q5ljafge0kBYeifk8TkJKrB0DBDMzFs1NlHxW+BllHAqOsY/d9ogh9xhMeSh0q6S13k5Hz2ZuPsx+qqzG3LYs9wsrce2eVAr42CsxF1Ynz93NsbvRflig0xhzvJxATjOm8YwapLLbfchlzNi8MfhB1T5O8RejS8XyVWPlMO0ykRN1Vtptu1z8OevdEE53iA3SuMczywdEmcwoM0bysEsG8kjWwyndReo0/DQKKQa7nBmrWYP46DmamcDbpQhssOjIZVYzRtD/UsB9u0U0VAMLBGcEhEG9J08QCKG1OL6TA0yj6TZGFrqhV6Q/GgGksFyKH5zbzf2zP6uOyE20KHHEQ==
  • 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=LYzxOUjOLbqe1e4CwOaHvw457RqSw57OYffXqwCDFb4=; b=B17AUycGTJQ7F3y4gvu8bzVeSvnMHNYcYLMMn6AQFY8zRCorNapCV9PPTkPQqFxpdTu8qTQlKlvib1Hswv3ECy/09RAIJRjwkJG0P6Idhg54ruq3HmToWdYt4PKAwQERtdCbiG4AGowHuINCS6NIEkOnc5IvQHHZq0dXzJreJNLiyoaKIrU9byLGAzyilPCy4lI/bBMbmxCc1IpTN94bBQ3IpXsTt5u62iX8XZ2yFrKeBIiBtl21AuTPi+/SaWijq/PqNfl0Ck4OYkW6+ikvtlTmFDNV08rbkL6AVRQciLOha3e0odWfDjWPxolSwES/Sjq9tGV3zf41hGYJpSsy4g==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=RGtmHxPrpVmv1a5V+RKyWVhLtf4STmBHvBO1sPRvHKgaWxtbWz3TZ9Ka7aG6SQ22g9jok2tebX3pWPqS/9NZei61O1apyVv2LSx9YB8fK+lxboYFNGU9kU3T4gCFk/enPG7Q+l2wavn7Agtd68aNarampI+UX1Z6VU38eTGpzxMqp2ZG4G4w7oLD4e9DKll+pVqfjOV8oeygKzmFTbqybne1iut0Igb5leog8I6DNMxC/BEhhdW+ycdoa9SuHFC9FsTzmfuLGpg16vOMVCJKn5QMOSnecWYjQzid/8fxe01gTAtwJ++pgb3kvH7HbJvTQU26CfnS9lFI/9QSzxhlHw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ql51eOi3LOrcdG9m/9zbJz0YfV+sKUY0dcxrk+ifIEuUzPLUmAkGm/lT8bTJufe2W9aiZ8kOyU9PAFK6+R08QdZmrZklrQTZPYqFk5avguYZo2KUUaVO0NFQl8Ht9FHmRjIbPpUDGAhoCmOIUb2m7de6i2+//dUSD6MT/bblk3eu7nAJaMg+vzsp4JWr1qqTV+KKo2gZQalWDgNb2XtH4++DfAPp2+Ykp2oof13nB3h6WGMpDcoiGxwjGFO2SwjSC4NatkCJR0nyn0PXVjXzjgwd7pATC8zblQ2QoGu/CBMMaA7oKrmDFcvDawclRCKa1Pequ2pje381UE80zzOX8A==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Michal Orzel <Michal.Orzel@xxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 24 May 2022 01:07:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYbt36sziAOg4NNEauktgt4qmeGq0tNzTA
  • Thread-topic: [PATCH] xen/arm: setup: nr_banks should be unsigned int

Hi Julien,

> -----Original Message-----
> From: Xen-devel <xen-devel-bounces@xxxxxxxxxxxxxxxxxxxx> On Behalf Of
> Julien Grall
> Sent: 2022年5月24日 3:47
> To: xen-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Michal Orzel <Michal.Orzel@xxxxxxx>; Julien Grall <jgrall@xxxxxxxxxx>;
> Stefano Stabellini <sstabellini@xxxxxxxxxx>; Julien Grall <julien@xxxxxxx>;
> Bertrand Marquis <Bertrand.Marquis@xxxxxxx>; Volodymyr Babchuk
> <Volodymyr_Babchuk@xxxxxxxx>
> Subject: [PATCH] xen/arm: setup: nr_banks should be unsigned int
> 
> From: Julien Grall <jgrall@xxxxxxxxxx>
> 
> It is not possible to have a negative number of banks. So switch
> to unsigned int.
> 
> The type change is also propagated to any users of nr_banks that
> were using "int" (there are not that many).
> 
> Note that fdt_num_mem_rsv() can actually returns a negative value
> in case of an error. So the return should be checked before assigning
> the result to an unsigned variable.
> 
> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
> ---
>  xen/arch/arm/domain_build.c      |  9 +++++----
>  xen/arch/arm/efi/efi-dom0.c      |  4 ++--
>  xen/arch/arm/include/asm/setup.h |  6 +++---
>  xen/arch/arm/setup.c             | 17 +++++++++++++----
>  4 files changed, 23 insertions(+), 13 deletions(-)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index aa777741bdd0..6ecb6673a3cd 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -111,7 +111,8 @@ static bool __init insert_11_bank(struct domain *d,
>                                    struct page_info *pg,
>                                    unsigned int order)
>  {
> -    int res, i;
> +    unsigned int i;
> +    int res;
>      mfn_t smfn;
>      paddr_t start, size;
> 
> @@ -264,7 +265,7 @@ static void __init allocate_memory_11(struct domain *d,
>      const unsigned int min_order = get_order_from_bytes(MB(4));
>      struct page_info *pg;
>      unsigned int order = get_allocation_size(kinfo->unassigned_mem);
> -    int i;
> +    unsigned int i;
> 
>      bool lowmem = true;
>      unsigned int lowmem_bitsize = min(32U, arch_get_dma_bitsize());
> @@ -1022,8 +1023,8 @@ static int __init make_memory_node(const struct
> domain *d,
>                                     int addrcells, int sizecells,
>                                     struct meminfo *mem)
>  {
> -    int res, i;
> -    int reg_size = addrcells + sizecells;
> +    unsigned int i;
> +    int res, reg_size = addrcells + sizecells;
>      int nr_cells = 0;
>      /* Placeholder for memory@ + a 64-bit number + \0 */
>      char buf[24];
> diff --git a/xen/arch/arm/efi/efi-dom0.c b/xen/arch/arm/efi/efi-dom0.c
> index 494420eaa23e..aae0f979112a 100644
> --- a/xen/arch/arm/efi/efi-dom0.c
> +++ b/xen/arch/arm/efi/efi-dom0.c
> @@ -34,14 +34,14 @@
>  /* Constant to indicate "Xen" in unicode u16 format */
>  static const CHAR16 xen_efi_fw_vendor[] = {0x0058, 0x0065, 0x006E,
> 0x0000};
> 
> -size_t __init estimate_efi_size(int mem_nr_banks)
> +size_t __init estimate_efi_size(unsigned int mem_nr_banks)
>  {
>      size_t size;
>      size_t est_size = sizeof(EFI_SYSTEM_TABLE);
>      size_t ect_size = sizeof(EFI_CONFIGURATION_TABLE);
>      size_t emd_size = sizeof(EFI_MEMORY_DESCRIPTOR);
>      size_t fw_vendor_size = sizeof(xen_efi_fw_vendor);
> -    int acpi_mem_nr_banks = 0;
> +    unsigned int acpi_mem_nr_banks = 0;
> 
>      if ( !acpi_disabled )
>          acpi_mem_nr_banks = bootinfo.acpi.nr_banks;
> diff --git a/xen/arch/arm/include/asm/setup.h
> b/xen/arch/arm/include/asm/setup.h
> index 7a1e1d67989c..2bb01ecfa88f 100644
> --- a/xen/arch/arm/include/asm/setup.h
> +++ b/xen/arch/arm/include/asm/setup.h
> @@ -30,7 +30,7 @@ struct membank {
>  };
> 
>  struct meminfo {
> -    int nr_banks;
> +    unsigned int nr_banks;
>      struct membank bank[NR_MEM_BANKS];
>  };
> 
> @@ -93,7 +93,7 @@ extern domid_t max_init_domid;
> 
>  void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len);
> 
> -size_t estimate_efi_size(int mem_nr_banks);
> +size_t estimate_efi_size(unsigned int mem_nr_banks);
> 
>  void acpi_create_efi_system_table(struct domain *d,
>                                    struct membank tbl_add[]);
> @@ -109,7 +109,7 @@ void create_dom0(void);
> 
>  void discard_initial_modules(void);
>  void fw_unreserved_regions(paddr_t s, paddr_t e,
> -                           void (*cb)(paddr_t, paddr_t), int first);
> +                           void (*cb)(paddr_t, paddr_t), unsigned int
> first);
> 
>  size_t boot_fdt_info(const void *fdt, paddr_t paddr);
>  const char *boot_fdt_cmdline(const void *fdt);
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index db1768c03f03..b30bccbaa7df 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -201,9 +201,17 @@ static void __init processor_id(void)
> 
>  static void __init dt_unreserved_regions(paddr_t s, paddr_t e,
>                                           void (*cb)(paddr_t, paddr_t),
> -                                         int first)
> +                                         unsigned int first)
>  {
> -    int i, nr = fdt_num_mem_rsv(device_tree_flattened);
> +    unsigned int i, nr;
> +    int rc;
> +
> +    rc = fdt_num_mem_rsv(device_tree_flattened);
> +    if ( rc < 0 )
> +        panic("Unable to retrieve the number of reserved regions
> (rc=%d)\n",
> +              rc);
> +
> +    nr = rc;
> 
>      for ( i = first; i < nr ; i++ )
>      {
> @@ -249,7 +257,8 @@ static void __init dt_unreserved_regions(paddr_t s,
> paddr_t e,
>  }
> 
>  void __init fw_unreserved_regions(paddr_t s, paddr_t e,
> -                                  void (*cb)(paddr_t, paddr_t), int first)
> +                                  void (*cb)(paddr_t, paddr_t),
> +                                  unsigned int first)
>  {
>      if ( acpi_disabled )
>          dt_unreserved_regions(s, e, cb, first);
> @@ -693,7 +702,7 @@ static void __init setup_mm(void)
>      paddr_t ram_start, ram_end, ram_size, e;
>      unsigned long ram_pages;
>      unsigned long heap_pages, xenheap_pages, domheap_pages;
> -    int i;
> +    unsigned int i;
>      const uint32_t ctr = READ_CP32(CTR);
> 
>      if ( !bootinfo.mem.nr_banks )

Reviewed-by: Wei Chen <Wei.Chen@xxxxxxx>

> --
> 2.32.0
> 


 


Rackspace

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