310-no_highpage.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From: Jeff Hansen <jhansen@cardaccess-inc.com>
  2. Subject: [PATCH] no highpage
  3. On ASUS WL-500gP there are many unexpected "Segmentation fault"s that
  4. seem to be caused by a kernel. They can be avoided by:
  5. 1) Disabling highpage
  6. 2) Using flush_cache_mm in flush_cache_dup_mm
  7. For details see OpenWrt ticket #2035 https://dev.openwrt.org/ticket/2035
  8. ---
  9. --- a/arch/mips/include/asm/page.h
  10. +++ b/arch/mips/include/asm/page.h
  11. @@ -71,6 +71,7 @@ static inline unsigned int page_size_ftl
  12. #endif /* CONFIG_MIPS_HUGE_TLB_SUPPORT */
  13. #include <linux/pfn.h>
  14. +#include <asm/cpu-features.h>
  15. extern void build_clear_page(void);
  16. extern void build_copy_page(void);
  17. @@ -105,11 +106,16 @@ static inline void clear_user_page(void
  18. flush_data_cache_page((unsigned long)addr);
  19. }
  20. -struct vm_area_struct;
  21. -extern void copy_user_highpage(struct page *to, struct page *from,
  22. - unsigned long vaddr, struct vm_area_struct *vma);
  23. +static inline void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
  24. + struct page *to)
  25. +{
  26. + extern void (*flush_data_cache_page)(unsigned long addr);
  27. -#define __HAVE_ARCH_COPY_USER_HIGHPAGE
  28. + copy_page(vto, vfrom);
  29. + if (!cpu_has_ic_fills_f_dc ||
  30. + pages_do_alias((unsigned long)vto, vaddr & PAGE_MASK))
  31. + flush_data_cache_page((unsigned long)vto);
  32. +}
  33. /*
  34. * These are used to make use of C type-checking..
  35. --- a/arch/mips/mm/init.c
  36. +++ b/arch/mips/mm/init.c
  37. @@ -158,30 +158,6 @@ void kunmap_coherent(void)
  38. preempt_enable();
  39. }
  40. -void copy_user_highpage(struct page *to, struct page *from,
  41. - unsigned long vaddr, struct vm_area_struct *vma)
  42. -{
  43. - void *vfrom, *vto;
  44. -
  45. - vto = kmap_atomic(to);
  46. - if (cpu_has_dc_aliases && cpu_use_kmap_coherent &&
  47. - page_mapped(from) && !Page_dcache_dirty(from)) {
  48. - vfrom = kmap_coherent(from, vaddr);
  49. - copy_page(vto, vfrom);
  50. - kunmap_coherent();
  51. - } else {
  52. - vfrom = kmap_atomic(from);
  53. - copy_page(vto, vfrom);
  54. - kunmap_atomic(vfrom);
  55. - }
  56. - if ((!cpu_has_ic_fills_f_dc) ||
  57. - pages_do_alias((unsigned long)vto, vaddr & PAGE_MASK))
  58. - flush_data_cache_page((unsigned long)vto);
  59. - kunmap_atomic(vto);
  60. - /* Make sure this page is cleared on other CPU's too before using it */
  61. - smp_wmb();
  62. -}
  63. -
  64. void copy_to_user_page(struct vm_area_struct *vma,
  65. struct page *page, unsigned long vaddr, void *dst, const void *src,
  66. unsigned long len)