360-Revert-MIPS-mm-kmalloc-tlb_vpn-array-to-avoid-stack-.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Hauke Mehrtens <[email protected]>
  3. Date: Mon, 15 Dec 2025 01:45:07 +0100
  4. Subject: Revert "MIPS: mm: kmalloc tlb_vpn array to avoid stack overflow"
  5. This reverts commit 63a93d1cd6077d79735f804f5a4957bfb240280c.
  6. ---
  7. arch/mips/mm/tlb-r4k.c | 18 ++----------------
  8. 1 file changed, 2 insertions(+), 16 deletions(-)
  9. --- a/arch/mips/mm/tlb-r4k.c
  10. +++ b/arch/mips/mm/tlb-r4k.c
  11. @@ -12,7 +12,6 @@
  12. #include <linux/init.h>
  13. #include <linux/sched.h>
  14. #include <linux/smp.h>
  15. -#include <linux/memblock.h>
  16. #include <linux/mm.h>
  17. #include <linux/hugetlb.h>
  18. #include <linux/export.h>
  19. @@ -523,26 +522,17 @@ static int r4k_vpn_cmp(const void *a, co
  20. * Initialise all TLB entries with unique values that do not clash with
  21. * what we have been handed over and what we'll be using ourselves.
  22. */
  23. -static void __ref r4k_tlb_uniquify(void)
  24. +static void r4k_tlb_uniquify(void)
  25. {
  26. + unsigned long tlb_vpns[1 << MIPS_CONF1_TLBS_SIZE];
  27. int tlbsize = current_cpu_data.tlbsize;
  28. - bool use_slab = slab_is_available();
  29. int start = num_wired_entries();
  30. - phys_addr_t tlb_vpn_size;
  31. - unsigned long *tlb_vpns;
  32. unsigned long vpn_mask;
  33. int cnt, ent, idx, i;
  34. vpn_mask = GENMASK(cpu_vmbits - 1, 13);
  35. vpn_mask |= IS_ENABLED(CONFIG_64BIT) ? 3ULL << 62 : 1 << 31;
  36. - tlb_vpn_size = tlbsize * sizeof(*tlb_vpns);
  37. - tlb_vpns = (use_slab ?
  38. - kmalloc(tlb_vpn_size, GFP_KERNEL) :
  39. - memblock_alloc_raw(tlb_vpn_size, sizeof(*tlb_vpns)));
  40. - if (WARN_ON(!tlb_vpns))
  41. - return; /* Pray local_flush_tlb_all() is good enough. */
  42. -
  43. htw_stop();
  44. for (i = start, cnt = 0; i < tlbsize; i++, cnt++) {
  45. @@ -595,10 +585,6 @@ static void __ref r4k_tlb_uniquify(void)
  46. tlbw_use_hazard();
  47. htw_start();
  48. flush_micro_tlb();
  49. - if (use_slab)
  50. - kfree(tlb_vpns);
  51. - else
  52. - memblock_free(tlb_vpns, tlb_vpn_size);
  53. }
  54. /*