]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branch 's390/features'
authorStephen Rothwell <sfr@canb.auug.org.au>
Wed, 4 Nov 2015 23:40:45 +0000 (10:40 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 4 Nov 2015 23:40:45 +0000 (10:40 +1100)
1  2 
arch/x86/include/asm/pgtable.h
include/asm-generic/pgtable.h
include/linux/compiler.h

index c0b41f111a9a4d19eac4b05723b33e6fcd2893c1,81e144dad4052e18b1368fc2084fd817c177eb45..6ec0c8b2e9df5b1d4c7702fd7f1d96c2c24db5d4
  #include <asm/x86_init.h>
  
  void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd);
 +void ptdump_walk_pgd_level_checkwx(void);
 +
 +#ifdef CONFIG_DEBUG_WX
 +#define debug_checkwx() ptdump_walk_pgd_level_checkwx()
 +#else
 +#define debug_checkwx() do { } while (0)
 +#endif
  
  /*
   * ZERO_PAGE is a global shared page that is always zero: used
@@@ -149,12 -142,12 +149,12 @@@ static inline unsigned long pte_pfn(pte
  
  static inline unsigned long pmd_pfn(pmd_t pmd)
  {
 -      return (pmd_val(pmd) & PTE_PFN_MASK) >> PAGE_SHIFT;
 +      return (pmd_val(pmd) & pmd_pfn_mask(pmd)) >> PAGE_SHIFT;
  }
  
  static inline unsigned long pud_pfn(pud_t pud)
  {
 -      return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
 +      return (pud_val(pud) & pud_pfn_mask(pud)) >> PAGE_SHIFT;
  }
  
  #define pte_page(pte) pfn_to_page(pte_pfn(pte))
@@@ -325,6 -318,16 +325,16 @@@ static inline pmd_t pmd_mksoft_dirty(pm
        return pmd_set_flags(pmd, _PAGE_SOFT_DIRTY);
  }
  
+ static inline pte_t pte_clear_soft_dirty(pte_t pte)
+ {
+       return pte_clear_flags(pte, _PAGE_SOFT_DIRTY);
+ }
+ static inline pmd_t pmd_clear_soft_dirty(pmd_t pmd)
+ {
+       return pmd_clear_flags(pmd, _PAGE_SOFT_DIRTY);
+ }
  #endif /* CONFIG_HAVE_ARCH_SOFT_DIRTY */
  
  /*
@@@ -386,9 -389,7 +396,9 @@@ static inline pgprot_t pgprot_modify(pg
        return __pgprot(preservebits | addbits);
  }
  
 -#define pte_pgprot(x) __pgprot(pte_flags(x) & PTE_FLAGS_MASK)
 +#define pte_pgprot(x) __pgprot(pte_flags(x))
 +#define pmd_pgprot(x) __pgprot(pmd_flags(x))
 +#define pud_pgprot(x) __pgprot(pud_flags(x))
  
  #define canon_pgprot(p) __pgprot(massage_pgprot(p))
  
@@@ -511,15 -512,14 +521,15 @@@ static inline int pmd_none(pmd_t pmd
  
  static inline unsigned long pmd_page_vaddr(pmd_t pmd)
  {
 -      return (unsigned long)__va(pmd_val(pmd) & PTE_PFN_MASK);
 +      return (unsigned long)__va(pmd_val(pmd) & pmd_pfn_mask(pmd));
  }
  
  /*
   * Currently stuck as a macro due to indirect forward reference to
   * linux/mmzone.h's __section_mem_map_addr() definition:
   */
 -#define pmd_page(pmd) pfn_to_page((pmd_val(pmd) & PTE_PFN_MASK) >> PAGE_SHIFT)
 +#define pmd_page(pmd)         \
 +      pfn_to_page((pmd_val(pmd) & pmd_pfn_mask(pmd)) >> PAGE_SHIFT)
  
  /*
   * the pmd page can be thought of an array like this: pmd_t[PTRS_PER_PMD]
@@@ -580,15 -580,14 +590,15 @@@ static inline int pud_present(pud_t pud
  
  static inline unsigned long pud_page_vaddr(pud_t pud)
  {
 -      return (unsigned long)__va((unsigned long)pud_val(pud) & PTE_PFN_MASK);
 +      return (unsigned long)__va(pud_val(pud) & pud_pfn_mask(pud));
  }
  
  /*
   * Currently stuck as a macro due to indirect forward reference to
   * linux/mmzone.h's __section_mem_map_addr() definition:
   */
 -#define pud_page(pud)         pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
 +#define pud_page(pud)         \
 +      pfn_to_page((pud_val(pud) & pud_pfn_mask(pud)) >> PAGE_SHIFT)
  
  /* Find an entry in the second-level page table.. */
  static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
index 3eabbbbfd5780adf2e8c5fc76bf2632d7cbb2dc4,f167cdd80fd7d810feb58fb286700ecdba02b11b..14b0ff32fb9f16c6ce30e0e54c3f3b4885216699
@@@ -30,19 -30,9 +30,19 @@@ extern int ptep_set_access_flags(struc
  #endif
  
  #ifndef __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
 +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
  extern int pmdp_set_access_flags(struct vm_area_struct *vma,
                                 unsigned long address, pmd_t *pmdp,
                                 pmd_t entry, int dirty);
 +#else
 +static inline int pmdp_set_access_flags(struct vm_area_struct *vma,
 +                                      unsigned long address, pmd_t *pmdp,
 +                                      pmd_t entry, int dirty)
 +{
 +      BUILD_BUG();
 +      return 0;
 +}
 +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
  #endif
  
  #ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
@@@ -74,12 -64,12 +74,12 @@@ static inline int pmdp_test_and_clear_y
                set_pmd_at(vma->vm_mm, address, pmdp, pmd_mkold(pmd));
        return r;
  }
 -#else /* CONFIG_TRANSPARENT_HUGEPAGE */
 +#else
  static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
                                            unsigned long address,
                                            pmd_t *pmdp)
  {
 -      BUG();
 +      BUILD_BUG();
        return 0;
  }
  #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
@@@ -91,21 -81,8 +91,21 @@@ int ptep_clear_flush_young(struct vm_ar
  #endif
  
  #ifndef __HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH
 -int pmdp_clear_flush_young(struct vm_area_struct *vma,
 -                         unsigned long address, pmd_t *pmdp);
 +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 +extern int pmdp_clear_flush_young(struct vm_area_struct *vma,
 +                                unsigned long address, pmd_t *pmdp);
 +#else
 +/*
 + * Despite relevant to THP only, this API is called from generic rmap code
 + * under PageTransHuge(), hence needs a dummy implementation for !THP
 + */
 +static inline int pmdp_clear_flush_young(struct vm_area_struct *vma,
 +                                       unsigned long address, pmd_t *pmdp)
 +{
 +      BUILD_BUG();
 +      return 0;
 +}
 +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
  #endif
  
  #ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR
@@@ -198,11 -175,11 +198,11 @@@ static inline void pmdp_set_wrprotect(s
        pmd_t old_pmd = *pmdp;
        set_pmd_at(mm, address, pmdp, pmd_wrprotect(old_pmd));
  }
 -#else /* CONFIG_TRANSPARENT_HUGEPAGE */
 +#else
  static inline void pmdp_set_wrprotect(struct mm_struct *mm,
                                      unsigned long address, pmd_t *pmdp)
  {
 -      BUG();
 +      BUILD_BUG();
  }
  #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
  #endif
@@@ -271,7 -248,7 +271,7 @@@ static inline int pmd_same(pmd_t pmd_a
  #else /* CONFIG_TRANSPARENT_HUGEPAGE */
  static inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b)
  {
 -      BUG();
 +      BUILD_BUG();
        return 0;
  }
  #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
@@@ -505,6 -482,16 +505,16 @@@ static inline pmd_t pmd_mksoft_dirty(pm
        return pmd;
  }
  
+ static inline pte_t pte_clear_soft_dirty(pte_t pte)
+ {
+       return pte;
+ }
+ static inline pmd_t pmd_clear_soft_dirty(pmd_t pmd)
+ {
+       return pmd;
+ }
  static inline pte_t pte_swp_mksoft_dirty(pte_t pte)
  {
        return pte;
diff --combined include/linux/compiler.h
index fe817432190c1cfb4c3108bbdfaf71b22916b8f8,449cb674c7fa0046851a1de87624b169348d4c1c..52a459ff75f4c2b88a8083338a2d173ce502f279
@@@ -56,7 -56,7 +56,7 @@@ extern void __chk_io_ptr(const volatil
  #include <linux/compiler-gcc.h>
  #endif
  
- #ifdef CC_USING_HOTPATCH
+ #if defined(CC_USING_HOTPATCH) && !defined(__CHECKER__)
  #define notrace __attribute__((hotpatch(0,0)))
  #else
  #define notrace __attribute__((no_instrument_function))
@@@ -198,45 -198,19 +198,45 @@@ void ftrace_likely_update(struct ftrace
  
  #include <uapi/linux/types.h>
  
 -static __always_inline void __read_once_size(const volatile void *p, void *res, int size)
 +#define __READ_ONCE_SIZE                                              \
 +({                                                                    \
 +      switch (size) {                                                 \
 +      case 1: *(__u8 *)res = *(volatile __u8 *)p; break;              \
 +      case 2: *(__u16 *)res = *(volatile __u16 *)p; break;            \
 +      case 4: *(__u32 *)res = *(volatile __u32 *)p; break;            \
 +      case 8: *(__u64 *)res = *(volatile __u64 *)p; break;            \
 +      default:                                                        \
 +              barrier();                                              \
 +              __builtin_memcpy((void *)res, (const void *)p, size);   \
 +              barrier();                                              \
 +      }                                                               \
 +})
 +
 +static __always_inline
 +void __read_once_size(const volatile void *p, void *res, int size)
  {
 -      switch (size) {
 -      case 1: *(__u8 *)res = *(volatile __u8 *)p; break;
 -      case 2: *(__u16 *)res = *(volatile __u16 *)p; break;
 -      case 4: *(__u32 *)res = *(volatile __u32 *)p; break;
 -      case 8: *(__u64 *)res = *(volatile __u64 *)p; break;
 -      default:
 -              barrier();
 -              __builtin_memcpy((void *)res, (const void *)p, size);
 -              barrier();
 -      }
 +      __READ_ONCE_SIZE;
 +}
 +
 +#ifdef CONFIG_KASAN
 +/*
 + * This function is not 'inline' because __no_sanitize_address confilcts
 + * with inlining. Attempt to inline it may cause a build failure.
 + *    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368
 + * '__maybe_unused' allows us to avoid defined-but-not-used warnings.
 + */
 +static __no_sanitize_address __maybe_unused
 +void __read_once_size_nocheck(const volatile void *p, void *res, int size)
 +{
 +      __READ_ONCE_SIZE;
  }
 +#else
 +static __always_inline
 +void __read_once_size_nocheck(const volatile void *p, void *res, int size)
 +{
 +      __READ_ONCE_SIZE;
 +}
 +#endif
  
  static __always_inline void __write_once_size(volatile void *p, void *res, int size)
  {
   * required ordering.
   */
  
 -#define READ_ONCE(x) \
 -      ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
 +#define __READ_ONCE(x, check)                                         \
 +({                                                                    \
 +      union { typeof(x) __val; char __c[1]; } __u;                    \
 +      if (check)                                                      \
 +              __read_once_size(&(x), __u.__c, sizeof(x));             \
 +      else                                                            \
 +              __read_once_size_nocheck(&(x), __u.__c, sizeof(x));     \
 +      __u.__val;                                                      \
 +})
 +#define READ_ONCE(x) __READ_ONCE(x, 1)
 +
 +/*
 + * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need
 + * to hide memory access from KASAN.
 + */
 +#define READ_ONCE_NOCHECK(x) __READ_ONCE(x, 0)
  
  #define WRITE_ONCE(x, val) \
  ({                                                    \
        __u.__val;                                      \
  })
  
 -/**
 - * READ_ONCE_CTRL - Read a value heading a control dependency
 - * @x: The value to be read, heading the control dependency
 - *
 - * Control dependencies are tricky.  See Documentation/memory-barriers.txt
 - * for important information on how to use them.  Note that in many cases,
 - * use of smp_load_acquire() will be much simpler.  Control dependencies
 - * should be avoided except on the hottest of hotpaths.
 - */
 -#define READ_ONCE_CTRL(x) \
 -({ \
 -      typeof(x) __val = READ_ONCE(x); \
 -      smp_read_barrier_depends(); /* Enforce control dependency. */ \
 -      __val; \
 -})
 -
  #endif /* __KERNEL__ */
  
  #endif /* __ASSEMBLY__ */