0001-sparc-Fix-Wstringop-overflow-warning.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. From deba804c90642c8ed0f15ac1083663976d578f54 Mon Sep 17 00:00:00 2001
  2. From: Orlando Arias <oarias@knights.ucf.edu>
  3. Date: Tue, 16 May 2017 15:34:00 -0400
  4. Subject: [PATCH] sparc: Fix -Wstringop-overflow warning
  5. Greetings,
  6. GCC 7 introduced the -Wstringop-overflow flag to detect buffer overflows
  7. in calls to string handling functions [1][2]. Due to the way
  8. ``empty_zero_page'' is declared in arch/sparc/include/setup.h, this
  9. causes a warning to trigger at compile time in the function mem_init(),
  10. which is subsequently converted to an error. The ensuing patch fixes
  11. this issue and aligns the declaration of empty_zero_page to that of
  12. other architectures. Thank you.
  13. Cheers,
  14. Orlando.
  15. [1] https://gcc.gnu.org/ml/gcc-patches/2016-10/msg02308.html
  16. [2] https://gcc.gnu.org/gcc-7/changes.html
  17. Signed-off-by: Orlando Arias <oarias@knights.ucf.edu>
  18. --------------------------------------------------------------------------------
  19. Signed-off-by: David S. Miller <davem@davemloft.net>
  20. ---
  21. arch/sparc/include/asm/pgtable_32.h | 4 ++--
  22. arch/sparc/include/asm/setup.h | 2 +-
  23. arch/sparc/mm/init_32.c | 2 +-
  24. 3 files changed, 4 insertions(+), 4 deletions(-)
  25. diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
  26. index ce6f569..cf19072 100644
  27. --- a/arch/sparc/include/asm/pgtable_32.h
  28. +++ b/arch/sparc/include/asm/pgtable_32.h
  29. @@ -91,9 +91,9 @@ extern unsigned long pfn_base;
  30. * ZERO_PAGE is a global shared page that is always zero: used
  31. * for zero-mapped memory areas etc..
  32. */
  33. -extern unsigned long empty_zero_page;
  34. +extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
  35. -#define ZERO_PAGE(vaddr) (virt_to_page(&empty_zero_page))
  36. +#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
  37. /*
  38. * In general all page table modifications should use the V8 atomic
  39. diff --git a/arch/sparc/include/asm/setup.h b/arch/sparc/include/asm/setup.h
  40. index 478bf6bb..3fae200 100644
  41. --- a/arch/sparc/include/asm/setup.h
  42. +++ b/arch/sparc/include/asm/setup.h
  43. @@ -16,7 +16,7 @@ extern char reboot_command[];
  44. */
  45. extern unsigned char boot_cpu_id;
  46. -extern unsigned long empty_zero_page;
  47. +extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
  48. extern int serial_console;
  49. static inline int con_is_present(void)
  50. diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
  51. index c6afe98..3bd0d51 100644
  52. --- a/arch/sparc/mm/init_32.c
  53. +++ b/arch/sparc/mm/init_32.c
  54. @@ -290,7 +290,7 @@ void __init mem_init(void)
  55. /* Saves us work later. */
  56. - memset((void *)&empty_zero_page, 0, PAGE_SIZE);
  57. + memset((void *)empty_zero_page, 0, PAGE_SIZE);
  58. i = last_valid_pfn >> ((20 - PAGE_SHIFT) + 5);
  59. i += 1;
  60. --
  61. 2.1.4