1. 06 1月, 2022 3 次提交
  2. 11 12月, 2021 12 次提交
  3. 07 12月, 2021 1 次提交
    • V
      percpu: km: ensure it is used with NOMMU (either UP or SMP) · 3583521a
      Vladimir Murzin 提交于
      Currently, NOMMU pull km allocator via !SMP dependency because most of
      them are UP, yet for SMP+NOMMU vm allocator gets pulled which:
      
      * may lead to broken build [1]
      * ...or not working runtime due to [2]
      
      It looks like SMP+NOMMU case was overlooked in bbddff05 ("percpu:
      use percpu allocator on UP too") so restore that.
      
      [1]
      For ARM SMP+NOMMU (R-class cores)
      
      arm-none-linux-gnueabihf-ld: mm/percpu.o: in function `pcpu_post_unmap_tlb_flush':
      mm/percpu-vm.c:188: undefined reference to `flush_tlb_kernel_range'
      
      [2]
      static inline
      int vmap_pages_range_noflush(unsigned long addr, unsigned long end,
                      pgprot_t prot, struct page **pages, unsigned int page_shift)
      {
             return -EINVAL;
      }
      Signed-off-by: NVladimir Murzin <vladimir.murzin@arm.com>
      Tested-by: NRob Landley <rob@landley.net>
      Tested-by: NRich Felker <dalias@libc.org>
      [Dennis: use depends instead of default for condition]
      Signed-off-by: NDennis Zhou <dennis@kernel.org>
      3583521a
  4. 04 12月, 2021 1 次提交
  5. 23 11月, 2021 2 次提交
    • N
      hugetlbfs: flush before unlock on move_hugetlb_page_tables() · 13e4ad2c
      Nadav Amit 提交于
      We must flush the TLB before releasing i_mmap_rwsem to avoid the
      potential reuse of an unshared PMDs page.  This is not true in the case
      of move_hugetlb_page_tables().  The last reference on the page table can
      therefore be dropped before the TLB flush took place.
      
      Prevent it by reordering the operations and flushing the TLB before
      releasing i_mmap_rwsem.
      
      Fixes: 550a7d60 ("mm, hugepages: add mremap() support for hugepage backed vma")
      Signed-off-by: NNadav Amit <namit@vmware.com>
      Reviewed-by: NMike Kravetz <mike.kravetz@oracle.com>
      Cc: Mina Almasry <almasrymina@google.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      13e4ad2c
    • N
      hugetlbfs: flush TLBs correctly after huge_pmd_unshare · a4a118f2
      Nadav Amit 提交于
      When __unmap_hugepage_range() calls to huge_pmd_unshare() succeed, a TLB
      flush is missing.  This TLB flush must be performed before releasing the
      i_mmap_rwsem, in order to prevent an unshared PMDs page from being
      released and reused before the TLB flush took place.
      
      Arguably, a comprehensive solution would use mmu_gather interface to
      batch the TLB flushes and the PMDs page release, however it is not an
      easy solution: (1) try_to_unmap_one() and try_to_migrate_one() also call
      huge_pmd_unshare() and they cannot use the mmu_gather interface; and (2)
      deferring the release of the page reference for the PMDs page until
      after i_mmap_rwsem is dropeed can confuse huge_pmd_unshare() into
      thinking PMDs are shared when they are not.
      
      Fix __unmap_hugepage_range() by adding the missing TLB flush, and
      forcing a flush when unshare is successful.
      
      Fixes: 24669e58 ("hugetlb: use mmu_gather instead of a temporary linked list for accumulating pages)" # 3.6
      Signed-off-by: NNadav Amit <namit@vmware.com>
      Reviewed-by: NMike Kravetz <mike.kravetz@oracle.com>
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a4a118f2
  6. 21 11月, 2021 8 次提交
  7. 19 11月, 2021 1 次提交
  8. 17 11月, 2021 3 次提交
  9. 14 11月, 2021 1 次提交
  10. 12 11月, 2021 6 次提交
  11. 11 11月, 2021 1 次提交
  12. 10 11月, 2021 1 次提交
    • D
      kernel/resource: disallow access to exclusive system RAM regions · a9e7b8d4
      David Hildenbrand 提交于
      virtio-mem dynamically exposes memory inside a device memory region as
      system RAM to Linux, coordinating with the hypervisor which parts are
      actually "plugged" and consequently usable/accessible.
      
      On the one hand, the virtio-mem driver adds/removes whole memory blocks,
      creating/removing busy IORESOURCE_SYSTEM_RAM resources, on the other
      hand, it logically (un)plugs memory inside added memory blocks,
      dynamically either exposing them to the buddy or hiding them from the
      buddy and marking them PG_offline.
      
      In contrast to physical devices, like a DIMM, the virtio-mem driver is
      required to actually make use of any of the device-provided memory,
      because it performs the handshake with the hypervisor.  virtio-mem
      memory cannot simply be access via /dev/mem without a driver.
      
      There is no safe way to:
      a) Access plugged memory blocks via /dev/mem, as they might contain
         unplugged holes or might get silently unplugged by the virtio-mem
         driver and consequently turned inaccessible.
      b) Access unplugged memory blocks via /dev/mem because the virtio-mem
         driver is required to make them actually accessible first.
      
      The virtio-spec states that unplugged memory blocks MUST NOT be written,
      and only selected unplugged memory blocks MAY be read.  We want to make
      sure, this is the case in sane environments -- where the virtio-mem driver
      was loaded.
      
      We want to make sure that in a sane environment, nobody "accidentially"
      accesses unplugged memory inside the device managed region.  For example,
      a user might spot a memory region in /proc/iomem and try accessing it via
      /dev/mem via gdb or dumping it via something else.  By the time the mmap()
      happens, the memory might already have been removed by the virtio-mem
      driver silently: the mmap() would succeeed and user space might
      accidentially access unplugged memory.
      
      So once the driver was loaded and detected the device along the
      device-managed region, we just want to disallow any access via /dev/mem to
      it.
      
      In an ideal world, we would mark the whole region as busy ("owned by a
      driver") and exclude it; however, that would be wrong, as we don't really
      have actual system RAM at these ranges added to Linux ("busy system RAM").
      Instead, we want to mark such ranges as "not actual busy system RAM but
      still soft-reserved and prepared by a driver for future use."
      
      Let's teach iomem_is_exclusive() to reject access to any range with
      "IORESOURCE_SYSTEM_RAM | IORESOURCE_EXCLUSIVE", even if not busy and even
      if "iomem=relaxed" is set.  Introduce EXCLUSIVE_SYSTEM_RAM to make it
      easier for applicable drivers to depend on this setting in their Kconfig.
      
      For now, there are no applicable ranges and we'll modify virtio-mem next
      to properly set IORESOURCE_EXCLUSIVE on the parent resource container it
      creates to contain all actual busy system RAM added via
      add_memory_driver_managed().
      
      Link: https://lkml.kernel.org/r/20210920142856.17758-3-david@redhat.comSigned-off-by: NDavid Hildenbrand <david@redhat.com>
      Reviewed-by: NDan Williams <dan.j.williams@intel.com>
      Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Hanjun Guo <guohanjun@huawei.com>
      Cc: Jason Wang <jasowang@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a9e7b8d4