0008-arm-fix-build-with-gcc-7.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. From 9d3011bd1cd29f8f3841bf1b64d5ead9ed1434e8 Mon Sep 17 00:00:00 2001
  2. From: Jan Beulich <jbeulich@suse.com>
  3. Date: Fri, 19 May 2017 10:12:08 +0200
  4. Subject: [PATCH] arm: fix build with gcc 7
  5. The compiler dislikes duplicate "const", and the ones it complains
  6. about look like they we in fact meant to be placed differently.
  7. Also fix array_access_okay() (just like on x86), despite the construct
  8. being unused on ARM: -Wint-in-bool-context, enabled by default in
  9. gcc 7, doesn't like multiplication in conditional operators. "Hide" it,
  10. at the risk of the next compiler version becoming smarter and
  11. recognizing even that. (The hope is that added smartness then would
  12. also better deal with legitimate cases like the one here.) The change
  13. could have been done in access_ok(), but I think we better keep it at
  14. the place the compiler is actually unhappy about.
  15. Signed-off-by: Jan Beulich <jbeulich@suse.com>
  16. Reviewed-by: Julien Grall <julien.grall@arm.com>
  17. Release-acked-by: Julien Grall <julien.grall@arm.com>
  18. Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
  19. ---
  20. xen/arch/arm/platforms/brcm.c | 2 +-
  21. xen/arch/arm/platforms/rcar2.c | 2 +-
  22. xen/include/asm-arm/guest_access.h | 3 ++-
  23. 3 files changed, 4 insertions(+), 3 deletions(-)
  24. diff --git a/xen/arch/arm/platforms/brcm.c b/xen/arch/arm/platforms/brcm.c
  25. index 6d8b5b9175..d481b2c60f 100644
  26. --- a/xen/arch/arm/platforms/brcm.c
  27. +++ b/xen/arch/arm/platforms/brcm.c
  28. @@ -271,7 +271,7 @@ static __init int brcm_init(void)
  29. return brcm_populate_plat_regs();
  30. }
  31. -static const char const *brcm_dt_compat[] __initconst =
  32. +static const char *const brcm_dt_compat[] __initconst =
  33. {
  34. "brcm,bcm7445d0",
  35. NULL
  36. diff --git a/xen/arch/arm/platforms/rcar2.c b/xen/arch/arm/platforms/rcar2.c
  37. index bb25751109..df0ac84709 100644
  38. --- a/xen/arch/arm/platforms/rcar2.c
  39. +++ b/xen/arch/arm/platforms/rcar2.c
  40. @@ -46,7 +46,7 @@ static int __init rcar2_smp_init(void)
  41. return 0;
  42. }
  43. -static const char const *rcar2_dt_compat[] __initdata =
  44. +static const char *const rcar2_dt_compat[] __initconst =
  45. {
  46. "renesas,lager",
  47. NULL
  48. diff --git a/xen/include/asm-arm/guest_access.h b/xen/include/asm-arm/guest_access.h
  49. index 5876988b23..421bca5f36 100644
  50. --- a/xen/include/asm-arm/guest_access.h
  51. +++ b/xen/include/asm-arm/guest_access.h
  52. @@ -8,7 +8,8 @@
  53. #define access_ok(addr,size) (1)
  54. #define array_access_ok(addr,count,size) \
  55. - (likely(count < (~0UL/size)) && access_ok(addr,count*size))
  56. + (likely((count) < (~0UL / (size))) && \
  57. + access_ok(addr, 0 + (count) * (size)))
  58. unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len);
  59. unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from,
  60. --
  61. 2.11.0