Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1463891 > unrolled thread

[PATCH] mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping

Started byCatalin Marinas <catalin.marinas@arm.com>
First post2016-08-16 17:30 +0200
Last post2016-08-17 22:40 +0200
Articles 9 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping Catalin Marinas <catalin.marinas@arm.com> - 2016-08-16 17:30 +0200
    Re: [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't  have a lowmem mapping kbuild test robot <lkp@intel.com> - 2016-08-16 19:20 +0200
      Re: [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't  have a lowmem mapping Catalin Marinas <catalin.marinas@arm.com> - 2016-08-16 19:40 +0200
    Re: [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't  have a lowmem mapping kbuild test robot <lkp@intel.com> - 2016-08-16 19:30 +0200
    Re: [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't  have a lowmem mapping Catalin Marinas <catalin.marinas@arm.com> - 2016-08-16 19:40 +0200
    Re: [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't  have a lowmem mapping kbuild test robot <lkp@intel.com> - 2016-08-16 19:50 +0200
    Re: [lkp] [mm]  122708b1b9: PANIC: early exception Catalin Marinas <catalin.marinas@arm.com> - 2016-08-17 18:20 +0200
      Re: [lkp] [mm]  122708b1b9: PANIC: early exception Andrew Morton <akpm@linux-foundation.org> - 2016-08-17 21:20 +0200
        Re: [lkp] [mm]  122708b1b9: PANIC: early exception Catalin Marinas <catalin.marinas@arm.com> - 2016-08-17 22:40 +0200

#1463891 — [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping

FromCatalin Marinas <catalin.marinas@arm.com>
Date2016-08-16 17:30 +0200
Subject[PATCH] mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping
Message-ID<s6Ots-4M4-9@gated-at.bofh.it>
Some of the kmemleak_*() callbacks in memblock, bootmem, CMA convert a
physical address to a virtual one using __va(). However, such physical
addresses may sometimes be located in highmem and using __va() is
incorrect, leading to inconsistent object tracking in kmemleak.

The following functions have been added to the kmemleak API and they
take a physical address as the object pointer. They only perform the
corresponding action if the address has a lowmem mapping:

kmemleak_alloc_phys
kmemleak_free_part_phys
kmemleak_not_leak_phys
kmemleak_ignore_phys

The affected calling places have been updated to use the new kmemleak API.

Reported-by: Vignesh R <vigneshr@ti.com>
Tested-by: Vignesh R <vigneshr@ti.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
---

Not entirely sure about cc'ing stable though. This bug has been around
since the beginnings of kmemleak and I only now got a bug report. It's
either because the preconditions are hard to meet or/and people don't
enable kmemleak very often. Once this patch hits mainline, I can send it
separately to linux-stable for versions we can reproduce the issue on
(4.4 seems to be one of them).

 Documentation/kmemleak.txt |  9 +++++++++
 include/linux/kmemleak.h   | 26 ++++++++++++++++++++++++++
 mm/bootmem.c               |  6 +++---
 mm/cma.c                   |  2 +-
 mm/memblock.c              |  8 ++++----
 mm/nobootmem.c             |  2 +-
 6 files changed, 44 insertions(+), 9 deletions(-)

diff --git a/Documentation/kmemleak.txt b/Documentation/kmemleak.txt
index 18e24abb3ecf..35e1a8891e3a 100644
--- a/Documentation/kmemleak.txt
+++ b/Documentation/kmemleak.txt
@@ -155,6 +155,15 @@ kmemleak_erase		 - erase an old value in a pointer variable
 kmemleak_alloc_recursive - as kmemleak_alloc but checks the recursiveness
 kmemleak_free_recursive	 - as kmemleak_free but checks the recursiveness
 
+The following functions take a physical address as the object pointer
+and only perform the corresponding action if the address has a lowmem
+mapping:
+
+kmemleak_alloc_phys
+kmemleak_free_part_phys
+kmemleak_not_leak_phys
+kmemleak_ignore_phys
+
 Dealing with false positives/negatives
 --------------------------------------
 
diff --git a/include/linux/kmemleak.h b/include/linux/kmemleak.h
index 4894c6888bc6..380f72bc3657 100644
--- a/include/linux/kmemleak.h
+++ b/include/linux/kmemleak.h
@@ -21,6 +21,7 @@
 #ifndef __KMEMLEAK_H
 #define __KMEMLEAK_H
 
+#include <linux/mm.h>
 #include <linux/slab.h>
 
 #ifdef CONFIG_DEBUG_KMEMLEAK
@@ -109,4 +110,29 @@ static inline void kmemleak_no_scan(const void *ptr)
 
 #endif	/* CONFIG_DEBUG_KMEMLEAK */
 
+static inline void kmemleak_alloc_phys(phys_addr_t phys, size_t size,
+				       int min_count, gfp_t gfp)
+{
+	if (!IS_ENABLED(CONFIG_HIGHMEM) || phys < __pa(high_memory))
+		kmemleak_alloc(__va(phys), size, min_count, gfp);
+}
+
+static inline void kmemleak_free_part_phys(phys_addr_t phys, size_t size)
+{
+	if (!IS_ENABLED(CONFIG_HIGHMEM) || phys < __pa(high_memory))
+		kmemleak_free_part(__va(phys), size);
+}
+
+static inline void kmemleak_not_leak_phys(phys_addr_t phys)
+{
+	if (!IS_ENABLED(CONFIG_HIGHMEM) || phys < __pa(high_memory))
+		kmemleak_not_leak(__va(phys));
+}
+
+static inline void kmemleak_ignore_phys(phys_addr_t phys)
+{
+	if (!IS_ENABLED(CONFIG_HIGHMEM) || phys < __pa(high_memory))
+		kmemleak_ignore(__va(phys));
+}
+
 #endif	/* __KMEMLEAK_H */
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 0aa7dda52402..80f1d70bad2d 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -158,7 +158,7 @@ void __init free_bootmem_late(unsigned long physaddr, unsigned long size)
 {
 	unsigned long cursor, end;
 
-	kmemleak_free_part(__va(physaddr), size);
+	kmemleak_free_part_phys(physaddr, size);
 
 	cursor = PFN_UP(physaddr);
 	end = PFN_DOWN(physaddr + size);
@@ -402,7 +402,7 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
 {
 	unsigned long start, end;
 
-	kmemleak_free_part(__va(physaddr), size);
+	kmemleak_free_part_phys(physaddr, size);
 
 	start = PFN_UP(physaddr);
 	end = PFN_DOWN(physaddr + size);
@@ -423,7 +423,7 @@ void __init free_bootmem(unsigned long physaddr, unsigned long size)
 {
 	unsigned long start, end;
 
-	kmemleak_free_part(__va(physaddr), size);
+	kmemleak_free_part_phys(physaddr, size);
 
 	start = PFN_UP(physaddr);
 	end = PFN_DOWN(physaddr + size);
diff --git a/mm/cma.c b/mm/cma.c
index bd0e1412475e..384c2cb51b56 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -336,7 +336,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
 		 * kmemleak scans/reads tracked objects for pointers to other
 		 * objects but this address isn't mapped and accessible
 		 */
-		kmemleak_ignore(phys_to_virt(addr));
+		kmemleak_ignore_phys(addr);
 		base = addr;
 	}
 
diff --git a/mm/memblock.c b/mm/memblock.c
index 483197ef613f..30ecea7b45d1 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -723,7 +723,7 @@ int __init_memblock memblock_free(phys_addr_t base, phys_addr_t size)
 		     (unsigned long long)base + size - 1,
 		     (void *)_RET_IP_);
 
-	kmemleak_free_part(__va(base), size);
+	kmemleak_free_part_phys(base, size);
 	return memblock_remove_range(&memblock.reserved, base, size);
 }
 
@@ -1152,7 +1152,7 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size,
 		 * The min_count is set to 0 so that memblock allocations are
 		 * never reported as leaks.
 		 */
-		kmemleak_alloc(__va(found), size, 0, 0);
+		kmemleak_alloc_phys(found, size, 0, 0);
 		return found;
 	}
 	return 0;
@@ -1399,7 +1399,7 @@ void __init __memblock_free_early(phys_addr_t base, phys_addr_t size)
 	memblock_dbg("%s: [%#016llx-%#016llx] %pF\n",
 		     __func__, (u64)base, (u64)base + size - 1,
 		     (void *)_RET_IP_);
-	kmemleak_free_part(__va(base), size);
+	kmemleak_free_part_phys(base, size);
 	memblock_remove_range(&memblock.reserved, base, size);
 }
 
@@ -1419,7 +1419,7 @@ void __init __memblock_free_late(phys_addr_t base, phys_addr_t size)
 	memblock_dbg("%s: [%#016llx-%#016llx] %pF\n",
 		     __func__, (u64)base, (u64)base + size - 1,
 		     (void *)_RET_IP_);
-	kmemleak_free_part(__va(base), size);
+	kmemleak_free_part_phys(base, size);
 	cursor = PFN_UP(base);
 	end = PFN_DOWN(base + size);
 
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index bd05a70f44b9..a056d31dff7e 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -81,7 +81,7 @@ void __init free_bootmem_late(unsigned long addr, unsigned long size)
 {
 	unsigned long cursor, end;
 
-	kmemleak_free_part(__va(addr), size);
+	kmemleak_free_part_phys(addr, size);
 
 	cursor = PFN_UP(addr);
 	end = PFN_DOWN(addr + size);

[toc] | [next] | [standalone]


#1463955 — Re: [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping

Fromkbuild test robot <lkp@intel.com>
Date2016-08-16 19:20 +0200
SubjectRe: [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping
Message-ID<s6QbU-5V1-35@gated-at.bofh.it>
In reply to#1463891

[Multipart message — attachments visible in raw view] — view raw

Hi Catalin,

[auto build test ERROR on mmotm/master]
[also build test ERROR on v4.8-rc2 next-20160816]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Catalin-Marinas/mm-kmemleak-Avoid-using-__va-on-addresses-that-don-t-have-a-lowmem-mapping/20160816-232733
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: tile-tilegx_defconfig (attached as .config)
compiler: tilegx-linux-gcc (GCC) 4.6.2
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=tile 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/kmemleak.h:24:0,
   from include/linux/slab.h:117,
   from arch/tile/include/asm/pgtable.h:27,
   from mm/init-mm.c:9:
   include/linux/mm.h: In function 'is_vmalloc_addr':
   include/linux/mm.h:486:17: error: 'VMALLOC_START' undeclared (first use in this function)
   include/linux/mm.h:486:17: note: each undeclared identifier is reported only once for each function it appears in
   include/linux/mm.h:486:41: error: 'VMALLOC_END' undeclared (first use in this function)
   include/linux/mm.h: In function 'maybe_mkwrite':
   include/linux/mm.h:624:3: error: implicit declaration of function 'pte_mkwrite'
   include/linux/mm.h:624:7: error: incompatible types when assigning to type 'pte_t' from type 'int'
   In file included from include/linux/kmemleak.h:24:0,
   from include/linux/slab.h:117,
   from arch/tile/include/asm/pgtable.h:27,
   from mm/init-mm.c:9:
   include/linux/mm.h: At top level:
>> include/linux/mm.h:1572:39: error: unknown type name 'pud_t'
   include/linux/mm.h:1603:1: error: unknown type name 'pud_t'
   include/linux/mm.h: In function 'pud_alloc':
   include/linux/mm.h:1605:2: error: implicit declaration of function 'pgd_none'
   include/linux/mm.h:1606:3: error: implicit declaration of function 'pud_offset'
   include/linux/mm.h:1606:7: warning: pointer/integer type mismatch in conditional expression [enabled by default]
   include/linux/mm.h: At top level:
   include/linux/mm.h:1609:54: error: unknown type name 'pud_t'
   include/linux/mm.h: In function 'pte_lockptr':
>> include/linux/mm.h:1648:2: error: implicit declaration of function 'pmd_page'
>> include/linux/mm.h:1648:2: warning: passing argument 1 of 'ptlock_ptr' makes pointer from integer without a cast [enabled by default]
   include/linux/mm.h:1640:27: note: expected 'struct page but argument is of type 'int'
   include/linux/mm.h: In function 'pgtable_init':
   include/linux/mm.h:1690:2: error: implicit declaration of function 'pgtable_cache_init'
   In file included from include/linux/kmemleak.h:24:0,
   from include/linux/slab.h:117,
   from arch/tile/include/asm/pgtable.h:27,
   from mm/init-mm.c:9:
   include/linux/mm.h: At top level:
   include/linux/mm.h:2330:1: error: unknown type name 'pud_t'
   include/linux/mm.h:2331:29: error: unknown type name 'pud_t'
   In file included from mm/init-mm.c:9:0:
>> arch/tile/include/asm/pgtable.h:66:13: warning: conflicting types for 'pgtable_cache_init' [enabled by default]
   include/linux/mm.h:1690:2: note: previous implicit declaration of 'pgtable_cache_init' was here
   In file included from arch/tile/include/asm/pgtable_64.h:62:0,
   from arch/tile/include/asm/pgtable.h:359,
   from mm/init-mm.c:9:
>> include/asm-generic/pgtable-nopud.h:25:19: error: static declaration of 'pgd_none' follows non-static declaration
   include/linux/mm.h:1605:10: note: previous implicit declaration of 'pgd_none' was here
>> include/asm-generic/pgtable-nopud.h:38:23: error: conflicting types for 'pud_offset'
   include/linux/mm.h:1606:9: note: previous implicit declaration of 'pud_offset' was here
   cc1: some warnings being treated as errors

vim +/pud_t +1572 include/linux/mm.h

dc6c9a35 Kirill A. Shutemov 2015-02-11  1566  }
dc6c9a35 Kirill A. Shutemov 2015-02-11  1567  
dc6c9a35 Kirill A. Shutemov 2015-02-11  1568  static inline void mm_inc_nr_pmds(struct mm_struct *mm) {}
dc6c9a35 Kirill A. Shutemov 2015-02-11  1569  static inline void mm_dec_nr_pmds(struct mm_struct *mm) {}
dc6c9a35 Kirill A. Shutemov 2015-02-11  1570  
5f22df00 Nick Piggin        2007-05-06  1571  #else
1bb3630e Hugh Dickins       2005-10-29 @1572  int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
dc6c9a35 Kirill A. Shutemov 2015-02-11  1573  
2d2f5119 Kirill A. Shutemov 2015-02-12  1574  static inline void mm_nr_pmds_init(struct mm_struct *mm)
2d2f5119 Kirill A. Shutemov 2015-02-12  1575  {
2d2f5119 Kirill A. Shutemov 2015-02-12  1576  	atomic_long_set(&mm->nr_pmds, 0);
2d2f5119 Kirill A. Shutemov 2015-02-12  1577  }
2d2f5119 Kirill A. Shutemov 2015-02-12  1578  
dc6c9a35 Kirill A. Shutemov 2015-02-11  1579  static inline unsigned long mm_nr_pmds(struct mm_struct *mm)
dc6c9a35 Kirill A. Shutemov 2015-02-11  1580  {
dc6c9a35 Kirill A. Shutemov 2015-02-11  1581  	return atomic_long_read(&mm->nr_pmds);
dc6c9a35 Kirill A. Shutemov 2015-02-11  1582  }
dc6c9a35 Kirill A. Shutemov 2015-02-11  1583  
dc6c9a35 Kirill A. Shutemov 2015-02-11  1584  static inline void mm_inc_nr_pmds(struct mm_struct *mm)
dc6c9a35 Kirill A. Shutemov 2015-02-11  1585  {
dc6c9a35 Kirill A. Shutemov 2015-02-11  1586  	atomic_long_inc(&mm->nr_pmds);
dc6c9a35 Kirill A. Shutemov 2015-02-11  1587  }
dc6c9a35 Kirill A. Shutemov 2015-02-11  1588  
dc6c9a35 Kirill A. Shutemov 2015-02-11  1589  static inline void mm_dec_nr_pmds(struct mm_struct *mm)
dc6c9a35 Kirill A. Shutemov 2015-02-11  1590  {
dc6c9a35 Kirill A. Shutemov 2015-02-11  1591  	atomic_long_dec(&mm->nr_pmds);
dc6c9a35 Kirill A. Shutemov 2015-02-11  1592  }
5f22df00 Nick Piggin        2007-05-06  1593  #endif
5f22df00 Nick Piggin        2007-05-06  1594  
3ed3a4f0 Kirill A. Shutemov 2016-03-17  1595  int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address);
1bb3630e Hugh Dickins       2005-10-29  1596  int __pte_alloc_kernel(pmd_t *pmd, unsigned long address);
1bb3630e Hugh Dickins       2005-10-29  1597  
^1da177e Linus Torvalds     2005-04-16  1598  /*
^1da177e Linus Torvalds     2005-04-16  1599   * The following ifdef needed to get the 4level-fixup.h header to work.
^1da177e Linus Torvalds     2005-04-16  1600   * Remove it when 4level-fixup.h has been removed.
^1da177e Linus Torvalds     2005-04-16  1601   */
1bb3630e Hugh Dickins       2005-10-29  1602  #if defined(CONFIG_MMU) && !defined(__ARCH_HAS_4LEVEL_HACK)
^1da177e Linus Torvalds     2005-04-16 @1603  static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
^1da177e Linus Torvalds     2005-04-16  1604  {
1bb3630e Hugh Dickins       2005-10-29  1605  	return (unlikely(pgd_none(*pgd)) && __pud_alloc(mm, pgd, address))?
1bb3630e Hugh Dickins       2005-10-29  1606  		NULL: pud_offset(pgd, address);
^1da177e Linus Torvalds     2005-04-16  1607  }
^1da177e Linus Torvalds     2005-04-16  1608  
^1da177e Linus Torvalds     2005-04-16  1609  static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
^1da177e Linus Torvalds     2005-04-16  1610  {
1bb3630e Hugh Dickins       2005-10-29  1611  	return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
1bb3630e Hugh Dickins       2005-10-29  1612  		NULL: pmd_offset(pud, address);
^1da177e Linus Torvalds     2005-04-16  1613  }
1bb3630e Hugh Dickins       2005-10-29  1614  #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
1bb3630e Hugh Dickins       2005-10-29  1615  
57c1ffce Kirill A. Shutemov 2013-11-14  1616  #if USE_SPLIT_PTE_PTLOCKS
597d795a Kirill A. Shutemov 2013-12-20  1617  #if ALLOC_SPLIT_PTLOCKS
b35f1819 Kirill A. Shutemov 2014-01-21  1618  void __init ptlock_cache_init(void);
539edb58 Peter Zijlstra     2013-11-14  1619  extern bool ptlock_alloc(struct page *page);
539edb58 Peter Zijlstra     2013-11-14  1620  extern void ptlock_free(struct page *page);
539edb58 Peter Zijlstra     2013-11-14  1621  
539edb58 Peter Zijlstra     2013-11-14  1622  static inline spinlock_t *ptlock_ptr(struct page *page)
539edb58 Peter Zijlstra     2013-11-14  1623  {
539edb58 Peter Zijlstra     2013-11-14  1624  	return page->ptl;
539edb58 Peter Zijlstra     2013-11-14  1625  }
597d795a Kirill A. Shutemov 2013-12-20  1626  #else /* ALLOC_SPLIT_PTLOCKS */
b35f1819 Kirill A. Shutemov 2014-01-21  1627  static inline void ptlock_cache_init(void)
b35f1819 Kirill A. Shutemov 2014-01-21  1628  {
b35f1819 Kirill A. Shutemov 2014-01-21  1629  }
b35f1819 Kirill A. Shutemov 2014-01-21  1630  
49076ec2 Kirill A. Shutemov 2013-11-14  1631  static inline bool ptlock_alloc(struct page *page)
49076ec2 Kirill A. Shutemov 2013-11-14  1632  {
49076ec2 Kirill A. Shutemov 2013-11-14  1633  	return true;
49076ec2 Kirill A. Shutemov 2013-11-14  1634  }
539edb58 Peter Zijlstra     2013-11-14  1635  
49076ec2 Kirill A. Shutemov 2013-11-14  1636  static inline void ptlock_free(struct page *page)
49076ec2 Kirill A. Shutemov 2013-11-14  1637  {
49076ec2 Kirill A. Shutemov 2013-11-14  1638  }
49076ec2 Kirill A. Shutemov 2013-11-14  1639  
49076ec2 Kirill A. Shutemov 2013-11-14  1640  static inline spinlock_t *ptlock_ptr(struct page *page)
49076ec2 Kirill A. Shutemov 2013-11-14  1641  {
539edb58 Peter Zijlstra     2013-11-14  1642  	return &page->ptl;
49076ec2 Kirill A. Shutemov 2013-11-14  1643  }
597d795a Kirill A. Shutemov 2013-12-20  1644  #endif /* ALLOC_SPLIT_PTLOCKS */
49076ec2 Kirill A. Shutemov 2013-11-14  1645  
49076ec2 Kirill A. Shutemov 2013-11-14  1646  static inline spinlock_t *pte_lockptr(struct mm_struct *mm, pmd_t *pmd)
49076ec2 Kirill A. Shutemov 2013-11-14  1647  {
49076ec2 Kirill A. Shutemov 2013-11-14 @1648  	return ptlock_ptr(pmd_page(*pmd));
49076ec2 Kirill A. Shutemov 2013-11-14  1649  }
49076ec2 Kirill A. Shutemov 2013-11-14  1650  
49076ec2 Kirill A. Shutemov 2013-11-14  1651  static inline bool ptlock_init(struct page *page)

:::::: The code at line 1572 was first introduced by commit
:::::: 1bb3630e89cb8a7b3d3807629c20c5bad88290ff [PATCH] mm: ptd_alloc inline and out

:::::: TO: Hugh Dickins <hugh@veritas.com>
:::::: CC: Linus Torvalds <torvalds@g5.osdl.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [prev] | [next] | [standalone]


#1463960 — Re: [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping

FromCatalin Marinas <catalin.marinas@arm.com>
Date2016-08-16 19:40 +0200
SubjectRe: [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping
Message-ID<s6Qvf-61D-1@gated-at.bofh.it>
In reply to#1463955
On Wed, Aug 17, 2016 at 01:15:53AM +0800, kbuild test robot wrote:
> [auto build test ERROR on mmotm/master]
> [also build test ERROR on v4.8-rc2 next-20160816]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> 
> url:    https://github.com/0day-ci/linux/commits/Catalin-Marinas/mm-kmemleak-Avoid-using-__va-on-addresses-that-don-t-have-a-lowmem-mapping/20160816-232733
> base:   git://git.cmpxchg.org/linux-mmotm.git master
> config: tile-tilegx_defconfig (attached as .config)
> compiler: tilegx-linux-gcc (GCC) 4.6.2
> reproduce:
>         wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         make.cross ARCH=tile 
> 
> All error/warnings (new ones prefixed by >>):
> 
>    In file included from include/linux/kmemleak.h:24:0,
>    from include/linux/slab.h:117,
>    from arch/tile/include/asm/pgtable.h:27,
>    from mm/init-mm.c:9:
>    include/linux/mm.h: In function 'is_vmalloc_addr':
>    include/linux/mm.h:486:17: error: 'VMALLOC_START' undeclared (first use in this function)
>    include/linux/mm.h:486:17: note: each undeclared identifier is reported only once for each function it appears in
>    include/linux/mm.h:486:41: error: 'VMALLOC_END' undeclared (first use in this function)
>    include/linux/mm.h: In function 'maybe_mkwrite':
>    include/linux/mm.h:624:3: error: implicit declaration of function 'pte_mkwrite'
>    include/linux/mm.h:624:7: error: incompatible types when assigning to type 'pte_t' from type 'int'
>    In file included from include/linux/kmemleak.h:24:0,
>    from include/linux/slab.h:117,
>    from arch/tile/include/asm/pgtable.h:27,
>    from mm/init-mm.c:9:

It looks like some architectures don't really like including linux/mm.h
from linux/kmemleak.h. I'll change the patch to avoid this include and
explicitly declare high_memory in kmemleak.h

-- 
Catalin

[toc] | [prev] | [next] | [standalone]


#1463959 — Re: [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping

Fromkbuild test robot <lkp@intel.com>
Date2016-08-16 19:30 +0200
SubjectRe: [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping
Message-ID<s6QlA-5Yr-19@gated-at.bofh.it>
In reply to#1463891

[Multipart message — attachments visible in raw view] — view raw

Hi Catalin,

[auto build test ERROR on mmotm/master]
[also build test ERROR on v4.8-rc2 next-20160816]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Catalin-Marinas/mm-kmemleak-Avoid-using-__va-on-addresses-that-don-t-have-a-lowmem-mapping/20160816-232733
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: mn10300-asb2364_defconfig (attached as .config)
compiler: am33_2.0-linux-gcc (GCC) 4.9.0
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=mn10300 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/kmemleak.h:24:0,
                    from include/linux/slab.h:117,
                    from arch/mn10300/include/asm/pgtable.h:33,
                    from mm/init-mm.c:9:
   include/linux/mm.h: In function 'is_vmalloc_addr':
>> include/linux/mm.h:486:17: error: 'VMALLOC_START' undeclared (first use in this function)
     return addr >= VMALLOC_START && addr < VMALLOC_END;
                    ^
   include/linux/mm.h:486:17: note: each undeclared identifier is reported only once for each function it appears in
>> include/linux/mm.h:486:41: error: 'VMALLOC_END' undeclared (first use in this function)
     return addr >= VMALLOC_START && addr < VMALLOC_END;
                                            ^
   include/linux/mm.h: In function 'maybe_mkwrite':
>> include/linux/mm.h:624:3: error: implicit declaration of function 'pte_mkwrite' [-Werror=implicit-function-declaration]
      pte = pte_mkwrite(pte);
      ^
>> include/linux/mm.h:624:7: error: incompatible types when assigning to type 'pte_t' from type 'int'
      pte = pte_mkwrite(pte);
          ^
   In file included from include/linux/kmemleak.h:24:0,
                    from include/linux/slab.h:117,
                    from arch/mn10300/include/asm/pgtable.h:33,
                    from mm/init-mm.c:9:
   include/linux/mm.h: In function 'pgtable_init':
>> include/linux/mm.h:1690:2: error: implicit declaration of function 'pgtable_cache_init' [-Werror=implicit-function-declaration]
     pgtable_cache_init();
     ^
   In file included from mm/init-mm.c:9:0:
   arch/mn10300/include/asm/pgtable.h: At top level:
>> arch/mn10300/include/asm/pgtable.h:47:13: warning: conflicting types for 'pgtable_cache_init'
    extern void pgtable_cache_init(void);
                ^
   In file included from include/linux/kmemleak.h:24:0,
                    from include/linux/slab.h:117,
                    from arch/mn10300/include/asm/pgtable.h:33,
                    from mm/init-mm.c:9:
   include/linux/mm.h:1690:2: note: previous implicit declaration of 'pgtable_cache_init' was here
     pgtable_cache_init();
     ^
   In file included from mm/init-mm.c:9:0:
>> arch/mn10300/include/asm/pgtable.h:272:21: error: conflicting types for 'pte_mkwrite'
    static inline pte_t pte_mkwrite(pte_t pte)
                        ^
   In file included from include/linux/kmemleak.h:24:0,
                    from include/linux/slab.h:117,
                    from arch/mn10300/include/asm/pgtable.h:33,
                    from mm/init-mm.c:9:
   include/linux/mm.h:624:9: note: previous implicit declaration of 'pte_mkwrite' was here
      pte = pte_mkwrite(pte);
            ^
   cc1: some warnings being treated as errors

vim +/VMALLOC_START +486 include/linux/mm.h

0738c4bb8 Paul Mundt             2008-03-12  480   */
bb00a789e Yaowei Bai             2016-05-19  481  static inline bool is_vmalloc_addr(const void *x)
9e2779fa2 Christoph Lameter      2008-02-04  482  {
0738c4bb8 Paul Mundt             2008-03-12  483  #ifdef CONFIG_MMU
9e2779fa2 Christoph Lameter      2008-02-04  484  	unsigned long addr = (unsigned long)x;
9e2779fa2 Christoph Lameter      2008-02-04  485  
9e2779fa2 Christoph Lameter      2008-02-04 @486  	return addr >= VMALLOC_START && addr < VMALLOC_END;
0738c4bb8 Paul Mundt             2008-03-12  487  #else
bb00a789e Yaowei Bai             2016-05-19  488  	return false;
8ca3ed87d David Howells          2008-02-23  489  #endif
0738c4bb8 Paul Mundt             2008-03-12  490  }
81ac3ad90 KAMEZAWA Hiroyuki      2009-09-22  491  #ifdef CONFIG_MMU
81ac3ad90 KAMEZAWA Hiroyuki      2009-09-22  492  extern int is_vmalloc_or_module_addr(const void *x);
81ac3ad90 KAMEZAWA Hiroyuki      2009-09-22  493  #else
934831d06 David Howells          2009-09-24  494  static inline int is_vmalloc_or_module_addr(const void *x)
81ac3ad90 KAMEZAWA Hiroyuki      2009-09-22  495  {
81ac3ad90 KAMEZAWA Hiroyuki      2009-09-22  496  	return 0;
81ac3ad90 KAMEZAWA Hiroyuki      2009-09-22  497  }
81ac3ad90 KAMEZAWA Hiroyuki      2009-09-22  498  #endif
9e2779fa2 Christoph Lameter      2008-02-04  499  
39f1f78d5 Al Viro                2014-05-06  500  extern void kvfree(const void *addr);
39f1f78d5 Al Viro                2014-05-06  501  
53f9263ba Kirill A. Shutemov     2016-01-15  502  static inline atomic_t *compound_mapcount_ptr(struct page *page)
53f9263ba Kirill A. Shutemov     2016-01-15  503  {
53f9263ba Kirill A. Shutemov     2016-01-15  504  	return &page[1].compound_mapcount;
53f9263ba Kirill A. Shutemov     2016-01-15  505  }
53f9263ba Kirill A. Shutemov     2016-01-15  506  
53f9263ba Kirill A. Shutemov     2016-01-15  507  static inline int compound_mapcount(struct page *page)
53f9263ba Kirill A. Shutemov     2016-01-15  508  {
5f527c2b3 Andrea Arcangeli       2016-05-20  509  	VM_BUG_ON_PAGE(!PageCompound(page), page);
53f9263ba Kirill A. Shutemov     2016-01-15  510  	page = compound_head(page);
53f9263ba Kirill A. Shutemov     2016-01-15  511  	return atomic_read(compound_mapcount_ptr(page)) + 1;
53f9263ba Kirill A. Shutemov     2016-01-15  512  }
53f9263ba Kirill A. Shutemov     2016-01-15  513  
ccaafd7fd Joonsoo Kim            2015-02-10  514  /*
70b50f94f Andrea Arcangeli       2011-11-02  515   * The atomic page->_mapcount, starts from -1: so that transitions
70b50f94f Andrea Arcangeli       2011-11-02  516   * both from it and to it can be tracked, using atomic_inc_and_test
70b50f94f Andrea Arcangeli       2011-11-02  517   * and atomic_add_negative(-1).
70b50f94f Andrea Arcangeli       2011-11-02  518   */
22b751c3d Mel Gorman             2013-02-22  519  static inline void page_mapcount_reset(struct page *page)
70b50f94f Andrea Arcangeli       2011-11-02  520  {
70b50f94f Andrea Arcangeli       2011-11-02  521  	atomic_set(&(page)->_mapcount, -1);
70b50f94f Andrea Arcangeli       2011-11-02  522  }
70b50f94f Andrea Arcangeli       2011-11-02  523  
b20ce5e03 Kirill A. Shutemov     2016-01-15  524  int __page_mapcount(struct page *page);
b20ce5e03 Kirill A. Shutemov     2016-01-15  525  
70b50f94f Andrea Arcangeli       2011-11-02  526  static inline int page_mapcount(struct page *page)
70b50f94f Andrea Arcangeli       2011-11-02  527  {
1d148e218 Wang, Yalin            2015-02-11  528  	VM_BUG_ON_PAGE(PageSlab(page), page);
53f9263ba Kirill A. Shutemov     2016-01-15  529  
b20ce5e03 Kirill A. Shutemov     2016-01-15  530  	if (unlikely(PageCompound(page)))
b20ce5e03 Kirill A. Shutemov     2016-01-15  531  		return __page_mapcount(page);
b20ce5e03 Kirill A. Shutemov     2016-01-15  532  	return atomic_read(&page->_mapcount) + 1;
53f9263ba Kirill A. Shutemov     2016-01-15  533  }
b20ce5e03 Kirill A. Shutemov     2016-01-15  534  
b20ce5e03 Kirill A. Shutemov     2016-01-15  535  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
b20ce5e03 Kirill A. Shutemov     2016-01-15  536  int total_mapcount(struct page *page);
6d0a07edd Andrea Arcangeli       2016-05-12  537  int page_trans_huge_mapcount(struct page *page, int *total_mapcount);
b20ce5e03 Kirill A. Shutemov     2016-01-15  538  #else
b20ce5e03 Kirill A. Shutemov     2016-01-15  539  static inline int total_mapcount(struct page *page)
b20ce5e03 Kirill A. Shutemov     2016-01-15  540  {
b20ce5e03 Kirill A. Shutemov     2016-01-15  541  	return page_mapcount(page);
70b50f94f Andrea Arcangeli       2011-11-02  542  }
6d0a07edd Andrea Arcangeli       2016-05-12  543  static inline int page_trans_huge_mapcount(struct page *page,
6d0a07edd Andrea Arcangeli       2016-05-12  544  					   int *total_mapcount)
6d0a07edd Andrea Arcangeli       2016-05-12  545  {
6d0a07edd Andrea Arcangeli       2016-05-12  546  	int mapcount = page_mapcount(page);
6d0a07edd Andrea Arcangeli       2016-05-12  547  	if (total_mapcount)
6d0a07edd Andrea Arcangeli       2016-05-12  548  		*total_mapcount = mapcount;
6d0a07edd Andrea Arcangeli       2016-05-12  549  	return mapcount;
6d0a07edd Andrea Arcangeli       2016-05-12  550  }
b20ce5e03 Kirill A. Shutemov     2016-01-15  551  #endif
70b50f94f Andrea Arcangeli       2011-11-02  552  
b49af68ff Christoph Lameter      2007-05-06  553  static inline struct page *virt_to_head_page(const void *x)
b49af68ff Christoph Lameter      2007-05-06  554  {
b49af68ff Christoph Lameter      2007-05-06  555  	struct page *page = virt_to_page(x);
ccaafd7fd Joonsoo Kim            2015-02-10  556  
1d798ca3f Kirill A. Shutemov     2015-11-06  557  	return compound_head(page);
b49af68ff Christoph Lameter      2007-05-06  558  }
b49af68ff Christoph Lameter      2007-05-06  559  
ddc58f27f Kirill A. Shutemov     2016-01-15  560  void __put_page(struct page *page);
ddc58f27f Kirill A. Shutemov     2016-01-15  561  
1d7ea7324 Alexander Zarochentsev 2006-08-13  562  void put_pages_list(struct list_head *pages);
^1da177e4 Linus Torvalds         2005-04-16  563  
8dfcc9ba2 Nick Piggin            2006-03-22  564  void split_page(struct page *page, unsigned int order);
8dfcc9ba2 Nick Piggin            2006-03-22  565  
^1da177e4 Linus Torvalds         2005-04-16  566  /*
33f2ef89f Andy Whitcroft         2006-12-06  567   * Compound pages have a destructor function.  Provide a
33f2ef89f Andy Whitcroft         2006-12-06  568   * prototype for that function and accessor functions.
f1e61557f Kirill A. Shutemov     2015-11-06  569   * These are _only_ valid on the head of a compound page.
33f2ef89f Andy Whitcroft         2006-12-06  570   */
f1e61557f Kirill A. Shutemov     2015-11-06  571  typedef void compound_page_dtor(struct page *);
f1e61557f Kirill A. Shutemov     2015-11-06  572  
f1e61557f Kirill A. Shutemov     2015-11-06  573  /* Keep the enum in sync with compound_page_dtors array in mm/page_alloc.c */
f1e61557f Kirill A. Shutemov     2015-11-06  574  enum compound_dtor_id {
f1e61557f Kirill A. Shutemov     2015-11-06  575  	NULL_COMPOUND_DTOR,
f1e61557f Kirill A. Shutemov     2015-11-06  576  	COMPOUND_PAGE_DTOR,
f1e61557f Kirill A. Shutemov     2015-11-06  577  #ifdef CONFIG_HUGETLB_PAGE
f1e61557f Kirill A. Shutemov     2015-11-06  578  	HUGETLB_PAGE_DTOR,
f1e61557f Kirill A. Shutemov     2015-11-06  579  #endif
9a982250f Kirill A. Shutemov     2016-01-15  580  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
9a982250f Kirill A. Shutemov     2016-01-15  581  	TRANSHUGE_PAGE_DTOR,
9a982250f Kirill A. Shutemov     2016-01-15  582  #endif
f1e61557f Kirill A. Shutemov     2015-11-06  583  	NR_COMPOUND_DTORS,
f1e61557f Kirill A. Shutemov     2015-11-06  584  };
f1e61557f Kirill A. Shutemov     2015-11-06  585  extern compound_page_dtor * const compound_page_dtors[];
33f2ef89f Andy Whitcroft         2006-12-06  586  
33f2ef89f Andy Whitcroft         2006-12-06  587  static inline void set_compound_page_dtor(struct page *page,
f1e61557f Kirill A. Shutemov     2015-11-06  588  		enum compound_dtor_id compound_dtor)
33f2ef89f Andy Whitcroft         2006-12-06  589  {
f1e61557f Kirill A. Shutemov     2015-11-06  590  	VM_BUG_ON_PAGE(compound_dtor >= NR_COMPOUND_DTORS, page);
f1e61557f Kirill A. Shutemov     2015-11-06  591  	page[1].compound_dtor = compound_dtor;
33f2ef89f Andy Whitcroft         2006-12-06  592  }
33f2ef89f Andy Whitcroft         2006-12-06  593  
33f2ef89f Andy Whitcroft         2006-12-06  594  static inline compound_page_dtor *get_compound_page_dtor(struct page *page)
33f2ef89f Andy Whitcroft         2006-12-06  595  {
f1e61557f Kirill A. Shutemov     2015-11-06  596  	VM_BUG_ON_PAGE(page[1].compound_dtor >= NR_COMPOUND_DTORS, page);
f1e61557f Kirill A. Shutemov     2015-11-06  597  	return compound_page_dtors[page[1].compound_dtor];
33f2ef89f Andy Whitcroft         2006-12-06  598  }
33f2ef89f Andy Whitcroft         2006-12-06  599  
d00181b96 Kirill A. Shutemov     2015-11-06  600  static inline unsigned int compound_order(struct page *page)
d85f33855 Christoph Lameter      2007-05-06  601  {
6d7779538 Christoph Lameter      2007-05-06  602  	if (!PageHead(page))
d85f33855 Christoph Lameter      2007-05-06  603  		return 0;
e4b294c2d Kirill A. Shutemov     2015-02-11  604  	return page[1].compound_order;
d85f33855 Christoph Lameter      2007-05-06  605  }
d85f33855 Christoph Lameter      2007-05-06  606  
f1e61557f Kirill A. Shutemov     2015-11-06  607  static inline void set_compound_order(struct page *page, unsigned int order)
d85f33855 Christoph Lameter      2007-05-06  608  {
e4b294c2d Kirill A. Shutemov     2015-02-11  609  	page[1].compound_order = order;
d85f33855 Christoph Lameter      2007-05-06  610  }
d85f33855 Christoph Lameter      2007-05-06  611  
9a982250f Kirill A. Shutemov     2016-01-15  612  void free_compound_page(struct page *page);
9a982250f Kirill A. Shutemov     2016-01-15  613  
3dece370e Michal Simek           2011-01-21  614  #ifdef CONFIG_MMU
33f2ef89f Andy Whitcroft         2006-12-06  615  /*
14fd403f2 Andrea Arcangeli       2011-01-13  616   * Do pte_mkwrite, but only if the vma says VM_WRITE.  We do this when
14fd403f2 Andrea Arcangeli       2011-01-13  617   * servicing faults for write access.  In the normal case, do always want
14fd403f2 Andrea Arcangeli       2011-01-13  618   * pte_mkwrite.  But get_user_pages can cause write faults for mappings
14fd403f2 Andrea Arcangeli       2011-01-13  619   * that do not have writing enabled, when used by access_process_vm.
14fd403f2 Andrea Arcangeli       2011-01-13  620   */
14fd403f2 Andrea Arcangeli       2011-01-13  621  static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)
14fd403f2 Andrea Arcangeli       2011-01-13  622  {
14fd403f2 Andrea Arcangeli       2011-01-13  623  	if (likely(vma->vm_flags & VM_WRITE))
14fd403f2 Andrea Arcangeli       2011-01-13 @624  		pte = pte_mkwrite(pte);
14fd403f2 Andrea Arcangeli       2011-01-13  625  	return pte;
14fd403f2 Andrea Arcangeli       2011-01-13  626  }
8c6e50b02 Kirill A. Shutemov     2014-04-07  627  

:::::: The code at line 486 was first introduced by commit
:::::: 9e2779fa281cfda13ac060753d674bbcaa23367e is_vmalloc_addr(): Check if an address is within the vmalloc boundaries

:::::: TO: Christoph Lameter <clameter@sgi.com>
:::::: CC: Linus Torvalds <torvalds@woody.linux-foundation.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [prev] | [next] | [standalone]


#1463961 — Re: [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping

FromCatalin Marinas <catalin.marinas@arm.com>
Date2016-08-16 19:40 +0200
SubjectRe: [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping
Message-ID<s6Qvf-61D-5@gated-at.bofh.it>
In reply to#1463891
On Tue, Aug 16, 2016 at 04:20:56PM +0100, Catalin Marinas wrote:
> diff --git a/include/linux/kmemleak.h b/include/linux/kmemleak.h
> index 4894c6888bc6..380f72bc3657 100644
> --- a/include/linux/kmemleak.h
> +++ b/include/linux/kmemleak.h
> @@ -21,6 +21,7 @@
>  #ifndef __KMEMLEAK_H
>  #define __KMEMLEAK_H
>  
> +#include <linux/mm.h>

Given the kbuild-robot reports, this #include doesn't go well on some
architectures.

>  #include <linux/slab.h>
>  
>  #ifdef CONFIG_DEBUG_KMEMLEAK
> @@ -109,4 +110,29 @@ static inline void kmemleak_no_scan(const void *ptr)
>  
>  #endif	/* CONFIG_DEBUG_KMEMLEAK */
>  
> +static inline void kmemleak_alloc_phys(phys_addr_t phys, size_t size,
> +				       int min_count, gfp_t gfp)
> +{
> +	if (!IS_ENABLED(CONFIG_HIGHMEM) || phys < __pa(high_memory))
> +		kmemleak_alloc(__va(phys), size, min_count, gfp);
> +}
> +
> +static inline void kmemleak_free_part_phys(phys_addr_t phys, size_t size)
> +{
> +	if (!IS_ENABLED(CONFIG_HIGHMEM) || phys < __pa(high_memory))
> +		kmemleak_free_part(__va(phys), size);
> +}
> +
> +static inline void kmemleak_not_leak_phys(phys_addr_t phys)
> +{
> +	if (!IS_ENABLED(CONFIG_HIGHMEM) || phys < __pa(high_memory))
> +		kmemleak_not_leak(__va(phys));
> +}
> +
> +static inline void kmemleak_ignore_phys(phys_addr_t phys)
> +{
> +	if (!IS_ENABLED(CONFIG_HIGHMEM) || phys < __pa(high_memory))
> +		kmemleak_ignore(__va(phys));
> +}

I'll move these functions out of line and re-post the patch.

-- 
Catalin

[toc] | [prev] | [next] | [standalone]


#1463973 — Re: [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping

Fromkbuild test robot <lkp@intel.com>
Date2016-08-16 19:50 +0200
SubjectRe: [PATCH] mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping
Message-ID<s6QEV-64O-17@gated-at.bofh.it>
In reply to#1463891

[Multipart message — attachments visible in raw view] — view raw

Hi Catalin,

[auto build test ERROR on mmotm/master]
[also build test ERROR on v4.8-rc2 next-20160816]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Catalin-Marinas/mm-kmemleak-Avoid-using-__va-on-addresses-that-don-t-have-a-lowmem-mapping/20160816-232733
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: frv-defconfig (attached as .config)
compiler: frv-linux-gcc (GCC) 4.9.0
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=frv 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/kmemleak.h:24:0,
                    from include/linux/slab.h:117,
                    from arch/frv/include/asm/pgtable.h:25,
                    from mm/init-mm.c:9:
   include/linux/mm.h: In function 'maybe_mkwrite':
   include/linux/mm.h:624:3: error: implicit declaration of function 'pte_mkwrite' [-Werror=implicit-function-declaration]
      pte = pte_mkwrite(pte);
      ^
   include/linux/mm.h:624:7: error: incompatible types when assigning to type 'pte_t' from type 'int'
      pte = pte_mkwrite(pte);
          ^
   In file included from include/linux/kmemleak.h:24:0,
                    from include/linux/slab.h:117,
                    from arch/frv/include/asm/pgtable.h:25,
                    from mm/init-mm.c:9:
   include/linux/mm.h: In function 'mm_nr_pmds_init':
>> include/linux/mm.h:1576:21: error: 'struct mm_struct' has no member named 'nr_pmds'
     atomic_long_set(&mm->nr_pmds, 0);
                        ^
   include/linux/mm.h: In function 'mm_nr_pmds':
   include/linux/mm.h:1581:29: error: 'struct mm_struct' has no member named 'nr_pmds'
     return atomic_long_read(&mm->nr_pmds);
                                ^
   include/linux/mm.h: In function 'mm_inc_nr_pmds':
   include/linux/mm.h:1586:21: error: 'struct mm_struct' has no member named 'nr_pmds'
     atomic_long_inc(&mm->nr_pmds);
                        ^
   include/linux/mm.h: In function 'mm_dec_nr_pmds':
   include/linux/mm.h:1591:21: error: 'struct mm_struct' has no member named 'nr_pmds'
     atomic_long_dec(&mm->nr_pmds);
                        ^
   include/linux/mm.h: In function 'pud_alloc':
>> include/linux/mm.h:1605:2: error: implicit declaration of function 'pgd_none' [-Werror=implicit-function-declaration]
     return (unlikely(pgd_none(*pgd)) && __pud_alloc(mm, pgd, address))?
     ^
>> include/linux/mm.h:1606:3: error: implicit declaration of function 'pud_offset' [-Werror=implicit-function-declaration]
      NULL: pud_offset(pgd, address);
      ^
>> include/linux/mm.h:1606:7: warning: pointer/integer type mismatch in conditional expression
      NULL: pud_offset(pgd, address);
          ^
   include/linux/mm.h: In function 'pmd_alloc':
>> include/linux/mm.h:1611:2: error: implicit declaration of function 'pud_none' [-Werror=implicit-function-declaration]
     return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
     ^
>> include/linux/mm.h:1612:3: error: implicit declaration of function 'pmd_offset' [-Werror=implicit-function-declaration]
      NULL: pmd_offset(pud, address);
      ^
   include/linux/mm.h:1612:7: warning: pointer/integer type mismatch in conditional expression
      NULL: pmd_offset(pud, address);
          ^
   include/linux/mm.h: In function 'pgtable_init':
   include/linux/mm.h:1690:2: error: implicit declaration of function 'pgtable_cache_init' [-Werror=implicit-function-declaration]
     pgtable_cache_init();
     ^
   In file included from mm/init-mm.c:9:0:
   arch/frv/include/asm/pgtable.h: At top level:
>> arch/frv/include/asm/pgtable.h:196:19: error: static declaration of 'pgd_none' follows non-static declaration
    static inline int pgd_none(pgd_t pgd)  { return 0; }
                      ^
   In file included from include/uapi/linux/stddef.h:1:0,
                    from include/linux/stddef.h:4,
                    from include/uapi/linux/posix_types.h:4,
                    from include/uapi/linux/types.h:13,
                    from include/linux/types.h:5,
                    from include/linux/mm_types.h:5,
                    from mm/init-mm.c:1:
   include/linux/mm.h:1605:19: note: previous implicit declaration of 'pgd_none' was here
     return (unlikely(pgd_none(*pgd)) && __pud_alloc(mm, pgd, address))?
                      ^
   include/linux/compiler.h:168:42: note: in definition of macro 'unlikely'
    # define unlikely(x) __builtin_expect(!!(x), 0)
                                             ^
   In file included from mm/init-mm.c:9:0:
>> arch/frv/include/asm/pgtable.h:212:22: error: conflicting types for 'pud_offset'
    static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
                         ^
   In file included from include/linux/kmemleak.h:24:0,
                    from include/linux/slab.h:117,
                    from arch/frv/include/asm/pgtable.h:25,
                    from mm/init-mm.c:9:
   include/linux/mm.h:1606:9: note: previous implicit declaration of 'pud_offset' was here
      NULL: pud_offset(pgd, address);
            ^
   In file included from mm/init-mm.c:9:0:
>> arch/frv/include/asm/pgtable.h:233:19: error: static declaration of 'pud_none' follows non-static declaration
    static inline int pud_none(pud_t pud)  { return 0; }
                      ^
   In file included from include/uapi/linux/stddef.h:1:0,
                    from include/linux/stddef.h:4,
                    from include/uapi/linux/posix_types.h:4,
                    from include/uapi/linux/types.h:13,
                    from include/linux/types.h:5,
                    from include/linux/mm_types.h:5,
                    from mm/init-mm.c:1:
   include/linux/mm.h:1611:19: note: previous implicit declaration of 'pud_none' was here
     return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
                      ^
   include/linux/compiler.h:168:42: note: in definition of macro 'unlikely'
    # define unlikely(x) __builtin_expect(!!(x), 0)
                                             ^
   In file included from mm/init-mm.c:9:0:
>> arch/frv/include/asm/pgtable.h:262:22: error: conflicting types for 'pmd_offset'
    static inline pmd_t *pmd_offset(pud_t *dir, unsigned long address)
                         ^
   In file included from include/linux/kmemleak.h:24:0,
                    from include/linux/slab.h:117,
                    from arch/frv/include/asm/pgtable.h:25,
                    from mm/init-mm.c:9:
   include/linux/mm.h:1612:9: note: previous implicit declaration of 'pmd_offset' was here
      NULL: pmd_offset(pud, address);
            ^
   In file included from mm/init-mm.c:9:0:
>> arch/frv/include/asm/pgtable.h:385:21: error: conflicting types for 'pte_mkwrite'
    static inline pte_t pte_mkwrite(pte_t pte) { (pte).pte &= ~_PAGE_WP; return pte; }
                        ^
   In file included from include/linux/kmemleak.h:24:0,
                    from include/linux/slab.h:117,
                    from arch/frv/include/asm/pgtable.h:25,
                    from mm/init-mm.c:9:
   include/linux/mm.h:624:9: note: previous implicit declaration of 'pte_mkwrite' was here
      pte = pte_mkwrite(pte);
            ^
   In file included from mm/init-mm.c:9:0:
>> arch/frv/include/asm/pgtable.h:517:20: warning: conflicting types for 'pgtable_cache_init'
    extern void __init pgtable_cache_init(void);
                       ^
   In file included from include/linux/kmemleak.h:24:0,
                    from include/linux/slab.h:117,
                    from arch/frv/include/asm/pgtable.h:25,
                    from mm/init-mm.c:9:
   include/linux/mm.h:1690:2: note: previous implicit declaration of 'pgtable_cache_init' was here
     pgtable_cache_init();
     ^
   cc1: some warnings being treated as errors

vim +1576 include/linux/mm.h

dc6c9a35 Kirill A. Shutemov 2015-02-11  1570  
5f22df00 Nick Piggin        2007-05-06  1571  #else
1bb3630e Hugh Dickins       2005-10-29  1572  int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
dc6c9a35 Kirill A. Shutemov 2015-02-11  1573  
2d2f5119 Kirill A. Shutemov 2015-02-12  1574  static inline void mm_nr_pmds_init(struct mm_struct *mm)
2d2f5119 Kirill A. Shutemov 2015-02-12  1575  {
2d2f5119 Kirill A. Shutemov 2015-02-12 @1576  	atomic_long_set(&mm->nr_pmds, 0);
2d2f5119 Kirill A. Shutemov 2015-02-12  1577  }
2d2f5119 Kirill A. Shutemov 2015-02-12  1578  
dc6c9a35 Kirill A. Shutemov 2015-02-11  1579  static inline unsigned long mm_nr_pmds(struct mm_struct *mm)
dc6c9a35 Kirill A. Shutemov 2015-02-11  1580  {
dc6c9a35 Kirill A. Shutemov 2015-02-11  1581  	return atomic_long_read(&mm->nr_pmds);
dc6c9a35 Kirill A. Shutemov 2015-02-11  1582  }
dc6c9a35 Kirill A. Shutemov 2015-02-11  1583  
dc6c9a35 Kirill A. Shutemov 2015-02-11  1584  static inline void mm_inc_nr_pmds(struct mm_struct *mm)
dc6c9a35 Kirill A. Shutemov 2015-02-11  1585  {
dc6c9a35 Kirill A. Shutemov 2015-02-11 @1586  	atomic_long_inc(&mm->nr_pmds);
dc6c9a35 Kirill A. Shutemov 2015-02-11  1587  }
dc6c9a35 Kirill A. Shutemov 2015-02-11  1588  
dc6c9a35 Kirill A. Shutemov 2015-02-11  1589  static inline void mm_dec_nr_pmds(struct mm_struct *mm)
dc6c9a35 Kirill A. Shutemov 2015-02-11  1590  {
dc6c9a35 Kirill A. Shutemov 2015-02-11 @1591  	atomic_long_dec(&mm->nr_pmds);
dc6c9a35 Kirill A. Shutemov 2015-02-11  1592  }
5f22df00 Nick Piggin        2007-05-06  1593  #endif
5f22df00 Nick Piggin        2007-05-06  1594  
3ed3a4f0 Kirill A. Shutemov 2016-03-17  1595  int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address);
1bb3630e Hugh Dickins       2005-10-29  1596  int __pte_alloc_kernel(pmd_t *pmd, unsigned long address);
1bb3630e Hugh Dickins       2005-10-29  1597  
^1da177e Linus Torvalds     2005-04-16  1598  /*
^1da177e Linus Torvalds     2005-04-16  1599   * The following ifdef needed to get the 4level-fixup.h header to work.
^1da177e Linus Torvalds     2005-04-16  1600   * Remove it when 4level-fixup.h has been removed.
^1da177e Linus Torvalds     2005-04-16  1601   */
1bb3630e Hugh Dickins       2005-10-29  1602  #if defined(CONFIG_MMU) && !defined(__ARCH_HAS_4LEVEL_HACK)
^1da177e Linus Torvalds     2005-04-16  1603  static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
^1da177e Linus Torvalds     2005-04-16  1604  {
1bb3630e Hugh Dickins       2005-10-29 @1605  	return (unlikely(pgd_none(*pgd)) && __pud_alloc(mm, pgd, address))?
1bb3630e Hugh Dickins       2005-10-29 @1606  		NULL: pud_offset(pgd, address);
^1da177e Linus Torvalds     2005-04-16  1607  }
^1da177e Linus Torvalds     2005-04-16  1608  
^1da177e Linus Torvalds     2005-04-16  1609  static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
^1da177e Linus Torvalds     2005-04-16  1610  {
1bb3630e Hugh Dickins       2005-10-29 @1611  	return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
1bb3630e Hugh Dickins       2005-10-29 @1612  		NULL: pmd_offset(pud, address);
^1da177e Linus Torvalds     2005-04-16  1613  }
1bb3630e Hugh Dickins       2005-10-29  1614  #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
1bb3630e Hugh Dickins       2005-10-29  1615  

:::::: The code at line 1576 was first introduced by commit
:::::: 2d2f5119b8bb057595e18f5b2f07aa097ea1b233 mm: do not use mm->nr_pmds on !MMU configurations

:::::: TO: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [prev] | [next] | [standalone]


#1464639 — Re: [lkp] [mm] 122708b1b9: PANIC: early exception

FromCatalin Marinas <catalin.marinas@arm.com>
Date2016-08-17 18:20 +0200
SubjectRe: [lkp] [mm] 122708b1b9: PANIC: early exception
Message-ID<s7bJn-3pe-5@gated-at.bofh.it>
In reply to#1463891
On Wed, Aug 17, 2016 at 11:51:41PM +0800, kernel test robot wrote:
> FYI, we noticed the following commit:
> 
> https://github.com/0day-ci/linux Catalin-Marinas/mm-kmemleak-Avoid-using-__va-on-addresses-that-don-t-have-a-lowmem-mapping/20160816-232733
> commit 122708b1b91eb3d253baf86a263ead0f1f5cac78 ("mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping")
> 
> in testcase: boot
> 
> on test machine: 1 threads qemu-system-i386 -enable-kvm with 320M memory
> 
> caused below changes:
> 
> +--------------------------------+------------+------------+
> |                                | 304bec1b1d | 122708b1b9 |
> +--------------------------------+------------+------------+
> | boot_successes                 | 3          | 0          |
> | boot_failures                  | 5          | 8          |
> | invoked_oom-killer:gfp_mask=0x | 1          |            |
> | Mem-Info                       | 1          |            |
> | BUG:kernel_test_crashed        | 4          |            |
> | PANIC:early_exception          | 0          | 8          |
> | EIP_is_at__phys_addr           | 0          | 8          |
> | BUG:kernel_hang_in_boot_stage  | 0          | 2          |
> | BUG:kernel_boot_hang           | 0          | 6          |
> +--------------------------------+------------+------------+

Please disregard this patch. I posted v2 here:

http://lkml.kernel.org/g/1471426130-21330-1-git-send-email-catalin.marinas@arm.com

(and I'm eager to see the kbuild/kernel test robot results ;))

-- 
Catalin

[toc] | [prev] | [next] | [standalone]


#1464728 — Re: [lkp] [mm] 122708b1b9: PANIC: early exception

FromAndrew Morton <akpm@linux-foundation.org>
Date2016-08-17 21:20 +0200
SubjectRe: [lkp] [mm] 122708b1b9: PANIC: early exception
Message-ID<s7exz-5ga-3@gated-at.bofh.it>
In reply to#1464639
On Wed, 17 Aug 2016 17:10:28 +0100 Catalin Marinas <catalin.marinas@arm.com> wrote:

> On Wed, Aug 17, 2016 at 11:51:41PM +0800, kernel test robot wrote:
> > FYI, we noticed the following commit:
> > 
> > https://github.com/0day-ci/linux Catalin-Marinas/mm-kmemleak-Avoid-using-__va-on-addresses-that-don-t-have-a-lowmem-mapping/20160816-232733
> > commit 122708b1b91eb3d253baf86a263ead0f1f5cac78 ("mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping")
> > 
> > in testcase: boot
> > 
> > on test machine: 1 threads qemu-system-i386 -enable-kvm with 320M memory
> > 
> > caused below changes:
> > 
> > +--------------------------------+------------+------------+
> > |                                | 304bec1b1d | 122708b1b9 |
> > +--------------------------------+------------+------------+
> > | boot_successes                 | 3          | 0          |
> > | boot_failures                  | 5          | 8          |
> > | invoked_oom-killer:gfp_mask=0x | 1          |            |
> > | Mem-Info                       | 1          |            |
> > | BUG:kernel_test_crashed        | 4          |            |
> > | PANIC:early_exception          | 0          | 8          |
> > | EIP_is_at__phys_addr           | 0          | 8          |
> > | BUG:kernel_hang_in_boot_stage  | 0          | 2          |
> > | BUG:kernel_boot_hang           | 0          | 6          |
> > +--------------------------------+------------+------------+
> 
> Please disregard this patch. I posted v2 here:
> 
> http://lkml.kernel.org/g/1471426130-21330-1-git-send-email-catalin.marinas@arm.com
> 
> (and I'm eager to see the kbuild/kernel test robot results ;))

I don't see how the v1->v2 changes could fix a panic?

[toc] | [prev] | [next] | [standalone]


#1464790 — Re: [lkp] [mm] 122708b1b9: PANIC: early exception

FromCatalin Marinas <catalin.marinas@arm.com>
Date2016-08-17 22:40 +0200
SubjectRe: [lkp] [mm] 122708b1b9: PANIC: early exception
Message-ID<s7fN0-62b-15@gated-at.bofh.it>
In reply to#1464728
On Wed, Aug 17, 2016 at 12:18:08PM -0700, Andrew Morton wrote:
> On Wed, 17 Aug 2016 17:10:28 +0100 Catalin Marinas <catalin.marinas@arm.com> wrote:
> > On Wed, Aug 17, 2016 at 11:51:41PM +0800, kernel test robot wrote:
> > > FYI, we noticed the following commit:
> > > 
> > > https://github.com/0day-ci/linux Catalin-Marinas/mm-kmemleak-Avoid-using-__va-on-addresses-that-don-t-have-a-lowmem-mapping/20160816-232733
> > > commit 122708b1b91eb3d253baf86a263ead0f1f5cac78 ("mm: kmemleak: Avoid using __va() on addresses that don't have a lowmem mapping")
> > > 
> > > in testcase: boot
> > > 
> > > on test machine: 1 threads qemu-system-i386 -enable-kvm with 320M memory
> > > 
> > > caused below changes:
> > > 
> > > +--------------------------------+------------+------------+
> > > |                                | 304bec1b1d | 122708b1b9 |
> > > +--------------------------------+------------+------------+
> > > | boot_successes                 | 3          | 0          |
> > > | boot_failures                  | 5          | 8          |
> > > | invoked_oom-killer:gfp_mask=0x | 1          |            |
> > > | Mem-Info                       | 1          |            |
> > > | BUG:kernel_test_crashed        | 4          |            |
> > > | PANIC:early_exception          | 0          | 8          |
> > > | EIP_is_at__phys_addr           | 0          | 8          |
> > > | BUG:kernel_hang_in_boot_stage  | 0          | 2          |
> > > | BUG:kernel_boot_hang           | 0          | 6          |
> > > +--------------------------------+------------+------------+
> > 
> > Please disregard this patch. I posted v2 here:
> > 
> > http://lkml.kernel.org/g/1471426130-21330-1-git-send-email-catalin.marinas@arm.com
> > 
> > (and I'm eager to see the kbuild/kernel test robot results ;))
> 
> I don't see how the v1->v2 changes could fix a panic?

This particular panic is avoided (rather than fixed) in v2 because the
config used above has kmemleak disabled, hence there is no
__pa(high_memory) call.

But you are right, it is likely to trigger once kmemleak is enabled, I
think because __pa(high_memory) use isn't valid. I need to reproduce it
tomorrow (UK time) but a workaround is to test against __pa(high_memory
- 1) or (max_low_pfn << PAGE_SHIFT).

-- 
Catalin

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web