1. 26 Aug, 2021 5 commits
    • Vineet Gupta's avatar
      ARC: mm: vmalloc sync from kernel to user table to update PMD ... · 56809a28
      Vineet Gupta authored
      ... not PGD
      
      vmalloc() sets up the kernel page table (starting from @swapper_pg_dir).
      But when vmalloc area is accessed in context of a user task, say opening
      terminal in n_tty_open(), the user page tables need to be synced from
      kernel page tables so that TLB entry is created in "user context".
      
      The old code was doing this incorrectly, as it was updating the user pgd
      entry (first level itself) to point to kernel pud table (2nd level),
      effectively yanking away the entire user space translation with kernel one.
      
      The correct way to do this is to ONLY update a user space pgd/pud/pmd entry
      if it is not popluated already. This ensures that only the missing leaf
      pmd entry gets updated to point to relevant kernel pte table.
      
      From code change pov, we are chaging the pattern:
      
      	p4d = p4d_offset(pgd, address);
      	p4d_k = p4d_offset(pgd_k, address);
      	if (!p4d_present(*p4d_k))
      		goto bad_area;
      	set_p4d(p4d, *p4d_k);
      
      with
      	p4d = p4d_offset(pgd, address);
      	p4d_k = p4d_offset(pgd_k, address);
      	if (p4d_none(*p4d_k))
      		goto bad_area;
      	if (!p4d_present(*p4d))
      		set_p4d(p4d, *p4d_k);
      Signed-off-by: default avatarVineet Gupta <vgupta@kernel.org>
      56809a28
    • Vineet Gupta's avatar
      8747ff70
    • Vineet Gupta's avatar
      ARC: mm: support 3 levels of page tables · 2dde02ab
      Vineet Gupta authored
      ARCv2 MMU is software walked and Linux implements 2 levels of paging: pgd/pte.
      Forthcoming hw will have multiple levels, so this change preps mm code
      for same. It is also fun to try multi levels even on soft-walked code to
      ensure generic mm code is robust to handle.
      
      overview
      ________
      
      2 levels {pgd, pte} : pmd is folded but pmd_* macros are valid and operate on pgd
      3 levels {pgd, pmd, pte}:
        - pud is folded and pud_* macros point to pgd
        - pmd_* macros operate on actual pmd
      
      code changes
      ____________
      
      1. #include <asm-generic/pgtable-nopud.h>
      
      2. Define CONFIG_PGTABLE_LEVELS 3
      
      3a. Define PMD_SHIFT, PMD_SIZE, PMD_MASK, pmd_t
      3b. Define pmd_val() which actually deals with pmd
          (pmd_offset(), pmd_index() are provided by generic code)
      3c. pmd_alloc_one()/pmd_free() also provided by generic code
          (pmd_populate/pmd_free already exist)
      
      4. Define pud_none(), pud_bad() macros based on generic pud_val() which
         internally pertains to pgd now.
      4b. define pud_populate() to just setup pgd
      Acked-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarVineet Gupta <vgupta@kernel.org>
      2dde02ab
    • Vineet Gupta's avatar
      ARC: mm: switch to asm-generic/pgalloc.h · 9f3c76ae
      Vineet Gupta authored
      With previous patch ARC pgalloc functions are same as generic, hence
      switch to that.
      Suggested-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Acked-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarVineet Gupta <vgupta@kernel.org>
      9f3c76ae
    • Vineet Gupta's avatar
      ARC: mm: switch pgtable_t back to struct page * · d9820ff7
      Vineet Gupta authored
      So far ARC pgtable_t has not been struct page based to avoid extra
      page_address() calls involved. However the differences are down to
      noise and get in the way of using generic code, hence this patch.
      
      This also allows us to reuse generic THP depost/withdraw code.
      
      There's some additional consideration for PGDIR_SHIFT in 4K page config.
      Now due to page tables being PAGE_SIZE deep only, the address split
      can't be really arbitrary.
      Tested-by: default avatarkernel test robot <lkp@intel.com>
      Suggested-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Acked-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarVineet Gupta <vgupta@kernel.org>
      d9820ff7
  2. 25 Aug, 2021 3 commits
  3. 24 Aug, 2021 25 commits
  4. 22 Aug, 2021 2 commits
  5. 21 Aug, 2021 5 commits