diff mbox

[v2,1/3] stacktrace: move arch_within_stack_frames from thread_info.h

Message ID 1523253969-31699-2-git-send-email-kpark3469@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

kpark3469@gmail.com April 9, 2018, 6:06 a.m. UTC
From: Sahara <keun-o.park@darkmatter.ae>

Since the inlined arch_within_stack_frames function was placed within
asm/thread_info.h, using stacktrace functions to unwind stack was
restricted. Now in order to have this function use more abundant apis,
it is moved to architecture's stacktrace.c. And, it is changed from
inline to noinline function to clearly have three depth calls like:

do_usercopy_stack()
  copy_[to|from]_user() : inline
    check_copy_size() : inline
      __check_object_size()
        check_stack_object()
          arch_within_stack_frames()

With this change, the x86's implementation was slightly changed also.
And, linux/stacktrace.h includes asm/stacktrace.h from now on.

Signed-off-by: Sahara <keun-o.park@darkmatter.ae>
Reviewed-by: Kees Cook <keescook@chromium.org>
---
 arch/arm/kernel/stacktrace.c       |  1 -
 arch/arm64/kernel/stacktrace.c     |  1 -
 arch/mips/kernel/stacktrace.c      |  1 -
 arch/mips/oprofile/backtrace.c     |  1 -
 arch/sh/kernel/stacktrace.c        |  1 -
 arch/sparc/kernel/stacktrace.c     |  1 -
 arch/um/kernel/stacktrace.c        |  1 -
 arch/unicore32/kernel/process.c    |  1 -
 arch/unicore32/kernel/stacktrace.c |  2 --
 arch/x86/include/asm/thread_info.h | 51 +-------------------------------------
 arch/x86/kernel/Makefile           |  2 +-
 arch/x86/kernel/stacktrace.c       | 50 ++++++++++++++++++++++++++++++++++++-
 arch/xtensa/kernel/stacktrace.c    |  1 -
 include/linux/page_ext.h           |  1 -
 include/linux/stacktrace.h         | 25 +++++++++++++++++++
 include/linux/thread_info.h        | 21 ----------------
 kernel/sysctl.c                    |  1 -
 mm/usercopy.c                      |  2 +-
 18 files changed, 77 insertions(+), 87 deletions(-)

Comments

kernel test robot April 9, 2018, 7:26 a.m. UTC | #1
Hi Sahara,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.16 next-20180406]
[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/kpark3469-gmail-com/usercopy-reimplement-arch_within_stack_frames/20180409-144349
config: i386-randconfig-x071-201814 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

                    from include/linux/time.h:6,
                    from include/linux/ktime.h:24,
                    from include/linux/rcutiny.h:28,
                    from include/linux/rcupdate.h:211,
                    from include/linux/rculist.h:11,
                    from include/linux/pid.h:5,
                    from include/linux/sched.h:14,
                    from include/linux/uaccess.h:5,
                    from arch/x86/include/asm/stacktrace.h:10,
                    from include/linux/stacktrace.h:6,
                    from include/linux/lockdep.h:29,
                    from include/linux/spinlock_types.h:18,
                    from kernel/bounds.c:14:
   include/linux/spinlock.h:297:24: error: unknown type name 'raw_spinlock_t'
    static __always_inline raw_spinlock_t *spinlock_check(spinlock_t *lock)
                           ^~~~~~~~~~~~~~
   include/linux/spinlock.h:297:55: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline raw_spinlock_t *spinlock_check(spinlock_t *lock)
                                                          ^~~~~~~~~~
                                                          clock_t
   include/linux/spinlock.h:308:39: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline void spin_lock(spinlock_t *lock)
                                          ^~~~~~~~~~
                                          clock_t
   include/linux/spinlock.h:313:42: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline void spin_lock_bh(spinlock_t *lock)
                                             ^~~~~~~~~~
                                             clock_t
   include/linux/spinlock.h:318:41: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline int spin_trylock(spinlock_t *lock)
                                            ^~~~~~~~~~
                                            clock_t
   include/linux/spinlock.h:333:43: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline void spin_lock_irq(spinlock_t *lock)
                                              ^~~~~~~~~~
                                              clock_t
   include/linux/spinlock.h:348:41: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline void spin_unlock(spinlock_t *lock)
                                            ^~~~~~~~~~
                                            clock_t
   include/linux/spinlock.h:353:44: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline void spin_unlock_bh(spinlock_t *lock)
                                               ^~~~~~~~~~
                                               clock_t
   include/linux/spinlock.h:358:45: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline void spin_unlock_irq(spinlock_t *lock)
                                                ^~~~~~~~~~
                                                clock_t
   include/linux/spinlock.h:363:52: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags)
                                                       ^~~~~~~~~~
                                                       clock_t
   include/linux/spinlock.h:368:44: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline int spin_trylock_bh(spinlock_t *lock)
                                               ^~~~~~~~~~
                                               clock_t
   include/linux/spinlock.h:373:45: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline int spin_trylock_irq(spinlock_t *lock)
                                                ^~~~~~~~~~
                                                clock_t
   include/linux/spinlock.h:383:43: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline int spin_is_locked(spinlock_t *lock)
                                              ^~~~~~~~~~
                                              clock_t
   include/linux/spinlock.h:388:46: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline int spin_is_contended(spinlock_t *lock)
                                                 ^~~~~~~~~~
                                                 clock_t
   include/linux/spinlock.h:408:51: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock);
                                                      ^~~~~~~~~~
                                                      clock_t
   include/linux/spinlock.h:412:28: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    int alloc_bucket_spinlocks(spinlock_t **locks, unsigned int *lock_mask,
                               ^~~~~~~~~~
                               clock_t
   include/linux/spinlock.h:416:28: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    void free_bucket_spinlocks(spinlock_t *locks);
                               ^~~~~~~~~~
                               clock_t
   In file included from include/linux/time.h:6:0,
                    from include/linux/ktime.h:24,
                    from include/linux/rcutiny.h:28,
                    from include/linux/rcupdate.h:211,
                    from include/linux/rculist.h:11,
                    from include/linux/pid.h:5,
                    from include/linux/sched.h:14,
                    from include/linux/uaccess.h:5,
                    from arch/x86/include/asm/stacktrace.h:10,
                    from include/linux/stacktrace.h:6,
                    from include/linux/lockdep.h:29,
                    from include/linux/spinlock_types.h:18,
                    from kernel/bounds.c:14:
   include/linux/seqlock.h:51:21: error: field 'dep_map' has incomplete type
     struct lockdep_map dep_map;
                        ^~~~~~~
   include/linux/seqlock.h:56:15: warning: 'struct lock_class_key' declared inside parameter list will not be visible outside of this definition or declaration
           struct lock_class_key *key)
                  ^~~~~~~~~~~~~~
   include/linux/seqlock.h: In function '__seqcount_init':
>> include/linux/seqlock.h:61:2: error: implicit declaration of function 'lockdep_init_map' [-Werror=implicit-function-declaration]
     lockdep_init_map(&s->dep_map, name, key, 0);
     ^~~~~~~~~~~~~~~~
   include/linux/seqlock.h: In function 'seqcount_lockdep_reader_access':
   include/linux/seqlock.h:81:2: error: implicit declaration of function 'seqcount_acquire_read' [-Werror=implicit-function-declaration]
     seqcount_acquire_read(&l->dep_map, 0, 0, _RET_IP_);
     ^~~~~~~~~~~~~~~~~~~~~
   include/linux/seqlock.h:82:2: error: implicit declaration of function 'seqcount_release'; did you mean 'xchg_release'? [-Werror=implicit-function-declaration]
     seqcount_release(&l->dep_map, 1, _RET_IP_);
     ^~~~~~~~~~~~~~~~
     xchg_release
   include/linux/seqlock.h: In function 'write_seqcount_begin_nested':
   include/linux/seqlock.h:377:2: error: implicit declaration of function 'seqcount_acquire'; did you mean 'seqcount_init'? [-Werror=implicit-function-declaration]
     seqcount_acquire(&s->dep_map, subclass, 0, _RET_IP_);
     ^~~~~~~~~~~~~~~~
     seqcount_init
   include/linux/seqlock.h: At top level:
   include/linux/seqlock.h:406:2: error: unknown type name 'spinlock_t'
     spinlock_t lock;
     ^~~~~~~~~~
   include/linux/seqlock.h: In function 'write_seqlock':
   include/linux/seqlock.h:448:2: error: implicit declaration of function 'spin_lock'; did you mean 'write_lock'? [-Werror=implicit-function-declaration]
     spin_lock(&sl->lock);
     ^~~~~~~~~
     write_lock
   include/linux/seqlock.h: In function 'write_sequnlock':
   include/linux/seqlock.h:455:2: error: implicit declaration of function 'spin_unlock'; did you mean 'raw_spin_unlock'? [-Werror=implicit-function-declaration]
     spin_unlock(&sl->lock);
     ^~~~~~~~~~~
     raw_spin_unlock
   include/linux/seqlock.h: In function 'write_seqlock_bh':
   include/linux/seqlock.h:460:2: error: implicit declaration of function 'spin_lock_bh'; did you mean 'raw_spin_lock_bh'? [-Werror=implicit-function-declaration]
     spin_lock_bh(&sl->lock);
     ^~~~~~~~~~~~
     raw_spin_lock_bh
   include/linux/seqlock.h: In function 'write_sequnlock_bh':
   include/linux/seqlock.h:467:2: error: implicit declaration of function 'spin_unlock_bh'; did you mean 'write_unlock_bh'? [-Werror=implicit-function-declaration]
     spin_unlock_bh(&sl->lock);
     ^~~~~~~~~~~~~~
     write_unlock_bh
   include/linux/seqlock.h: In function 'write_seqlock_irq':
   include/linux/seqlock.h:472:2: error: implicit declaration of function 'spin_lock_irq'; did you mean 'spin_lock_init'? [-Werror=implicit-function-declaration]
     spin_lock_irq(&sl->lock);
     ^~~~~~~~~~~~~
     spin_lock_init
   include/linux/seqlock.h: In function 'write_sequnlock_irq':
   include/linux/seqlock.h:479:2: error: implicit declaration of function 'spin_unlock_irq'; did you mean 'read_unlock_irq'? [-Werror=implicit-function-declaration]
     spin_unlock_irq(&sl->lock);
     ^~~~~~~~~~~~~~~
     read_unlock_irq
   In file included from include/linux/seqlock.h:36:0,
                    from include/linux/time.h:6,
                    from include/linux/ktime.h:24,
                    from include/linux/rcutiny.h:28,
                    from include/linux/rcupdate.h:211,
                    from include/linux/rculist.h:11,
                    from include/linux/pid.h:5,
                    from include/linux/sched.h:14,
                    from include/linux/uaccess.h:5,
                    from arch/x86/include/asm/stacktrace.h:10,
                    from include/linux/stacktrace.h:6,
                    from include/linux/lockdep.h:29,
                    from include/linux/spinlock_types.h:18,
                    from kernel/bounds.c:14:
   include/linux/seqlock.h: In function '__write_seqlock_irqsave':
   include/linux/spinlock.h:222:11: error: implicit declaration of function '_raw_spin_lock_irqsave'; did you mean 'raw_spin_lock_irqsave'? [-Werror=implicit-function-declaration]
      flags = _raw_spin_lock_irqsave(lock); \
              ^
   include/linux/spinlock.h:340:2: note: in expansion of macro 'raw_spin_lock_irqsave'
     raw_spin_lock_irqsave(spinlock_check(lock), flags); \
     ^~~~~~~~~~~~~~~~~~~~~
   include/linux/seqlock.h:486:2: note: in expansion of macro 'spin_lock_irqsave'
     spin_lock_irqsave(&sl->lock, flags);
     ^~~~~~~~~~~~~~~~~
   include/linux/spinlock.h:340:24: error: implicit declaration of function 'spinlock_check'; did you mean 'cpumask_check'? [-Werror=implicit-function-declaration]
     raw_spin_lock_irqsave(spinlock_check(lock), flags); \
                           ^
   include/linux/spinlock.h:222:34: note: in definition of macro 'raw_spin_lock_irqsave'
      flags = _raw_spin_lock_irqsave(lock); \
                                     ^~~~
   include/linux/seqlock.h:486:2: note: in expansion of macro 'spin_lock_irqsave'
     spin_lock_irqsave(&sl->lock, flags);
     ^~~~~~~~~~~~~~~~~
   In file included from include/linux/time.h:6:0,
                    from include/linux/ktime.h:24,
                    from include/linux/rcutiny.h:28,
                    from include/linux/rcupdate.h:211,
                    from include/linux/rculist.h:11,
                    from include/linux/pid.h:5,
                    from include/linux/sched.h:14,
                    from include/linux/uaccess.h:5,
                    from arch/x86/include/asm/stacktrace.h:10,
                    from include/linux/stacktrace.h:6,
                    from include/linux/lockdep.h:29,
                    from include/linux/spinlock_types.h:18,
                    from kernel/bounds.c:14:
   include/linux/seqlock.h: In function 'write_sequnlock_irqrestore':
   include/linux/seqlock.h:498:2: error: implicit declaration of function 'spin_unlock_irqrestore'; did you mean 'write_unlock_irqrestore'? [-Werror=implicit-function-declaration]
     spin_unlock_irqrestore(&sl->lock, flags);
     ^~~~~~~~~~~~~~~~~~~~~~
     write_unlock_irqrestore

vim +/lockdep_init_map +61 include/linux/seqlock.h

^1da177e Linus Torvalds 2005-04-16  41  
^1da177e Linus Torvalds 2005-04-16  42  /*
^1da177e Linus Torvalds 2005-04-16  43   * Version using sequence counter only.
^1da177e Linus Torvalds 2005-04-16  44   * This can be used when code has its own mutex protecting the
^1da177e Linus Torvalds 2005-04-16  45   * updating starting before the write_seqcountbeqin() and ending
^1da177e Linus Torvalds 2005-04-16  46   * after the write_seqcount_end().
^1da177e Linus Torvalds 2005-04-16  47   */
^1da177e Linus Torvalds 2005-04-16  48  typedef struct seqcount {
^1da177e Linus Torvalds 2005-04-16  49  	unsigned sequence;
1ca7d67c John Stultz    2013-10-07  50  #ifdef CONFIG_DEBUG_LOCK_ALLOC
1ca7d67c John Stultz    2013-10-07 @51  	struct lockdep_map dep_map;
1ca7d67c John Stultz    2013-10-07  52  #endif
^1da177e Linus Torvalds 2005-04-16  53  } seqcount_t;
^1da177e Linus Torvalds 2005-04-16  54  
1ca7d67c John Stultz    2013-10-07  55  static inline void __seqcount_init(seqcount_t *s, const char *name,
1ca7d67c John Stultz    2013-10-07  56  					  struct lock_class_key *key)
1ca7d67c John Stultz    2013-10-07  57  {
1ca7d67c John Stultz    2013-10-07  58  	/*
1ca7d67c John Stultz    2013-10-07  59  	 * Make sure we are not reinitializing a held lock:
1ca7d67c John Stultz    2013-10-07  60  	 */
1ca7d67c John Stultz    2013-10-07 @61  	lockdep_init_map(&s->dep_map, name, key, 0);
1ca7d67c John Stultz    2013-10-07  62  	s->sequence = 0;
1ca7d67c John Stultz    2013-10-07  63  }
1ca7d67c John Stultz    2013-10-07  64  

:::::: The code at line 61 was first introduced by commit
:::::: 1ca7d67cf5d5a2aef26a8d9afd789006fa098347 seqcount: Add lockdep functionality to seqcount/seqlock structures

:::::: TO: John Stultz <john.stultz@linaro.org>
:::::: CC: Ingo Molnar <mingo@kernel.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot April 9, 2018, 8:58 a.m. UTC | #2
Hi Sahara,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.16 next-20180406]
[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/kpark3469-gmail-com/usercopy-reimplement-arch_within_stack_frames/20180409-144349
config: x86_64-randconfig-x013-201814 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

                    from include/linux/uaccess.h:5,
                    from arch/x86/include/asm/stacktrace.h:10,
                    from include/linux/stacktrace.h:6,
                    from include/linux/lockdep.h:29,
                    from include/linux/spinlock_types.h:18,
                    from kernel/bounds.c:14:
   include/linux/spinlock.h:297:24: error: unknown type name 'raw_spinlock_t'
    static __always_inline raw_spinlock_t *spinlock_check(spinlock_t *lock)
                           ^~~~~~~~~~~~~~
   include/linux/spinlock.h:297:55: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline raw_spinlock_t *spinlock_check(spinlock_t *lock)
                                                          ^~~~~~~~~~
                                                          clock_t
   include/linux/spinlock.h:308:39: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline void spin_lock(spinlock_t *lock)
                                          ^~~~~~~~~~
                                          clock_t
   include/linux/spinlock.h:313:42: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline void spin_lock_bh(spinlock_t *lock)
                                             ^~~~~~~~~~
                                             clock_t
   include/linux/spinlock.h:318:41: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline int spin_trylock(spinlock_t *lock)
                                            ^~~~~~~~~~
                                            clock_t
   include/linux/spinlock.h:333:43: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline void spin_lock_irq(spinlock_t *lock)
                                              ^~~~~~~~~~
                                              clock_t
   include/linux/spinlock.h:348:41: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline void spin_unlock(spinlock_t *lock)
                                            ^~~~~~~~~~
                                            clock_t
   include/linux/spinlock.h:353:44: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline void spin_unlock_bh(spinlock_t *lock)
                                               ^~~~~~~~~~
                                               clock_t
   include/linux/spinlock.h:358:45: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline void spin_unlock_irq(spinlock_t *lock)
                                                ^~~~~~~~~~
                                                clock_t
   include/linux/spinlock.h:363:52: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags)
                                                       ^~~~~~~~~~
                                                       clock_t
   include/linux/spinlock.h:368:44: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline int spin_trylock_bh(spinlock_t *lock)
                                               ^~~~~~~~~~
                                               clock_t
   include/linux/spinlock.h:373:45: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline int spin_trylock_irq(spinlock_t *lock)
                                                ^~~~~~~~~~
                                                clock_t
   include/linux/spinlock.h:383:43: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline int spin_is_locked(spinlock_t *lock)
                                              ^~~~~~~~~~
                                              clock_t
   include/linux/spinlock.h:388:46: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    static __always_inline int spin_is_contended(spinlock_t *lock)
                                                 ^~~~~~~~~~
                                                 clock_t
   include/linux/spinlock.h:408:51: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock);
                                                      ^~~~~~~~~~
                                                      clock_t
   include/linux/spinlock.h:412:28: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    int alloc_bucket_spinlocks(spinlock_t **locks, unsigned int *lock_mask,
                               ^~~~~~~~~~
                               clock_t
   include/linux/spinlock.h:416:28: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
    void free_bucket_spinlocks(spinlock_t *locks);
                               ^~~~~~~~~~
                               clock_t
   In file included from include/linux/time.h:6:0,
                    from include/linux/ktime.h:24,
                    from include/linux/rcutiny.h:28,
                    from include/linux/rcupdate.h:211,
                    from include/linux/rculist.h:11,
                    from include/linux/pid.h:5,
                    from include/linux/sched.h:14,
                    from include/linux/uaccess.h:5,
                    from arch/x86/include/asm/stacktrace.h:10,
                    from include/linux/stacktrace.h:6,
                    from include/linux/lockdep.h:29,
                    from include/linux/spinlock_types.h:18,
                    from kernel/bounds.c:14:
   include/linux/seqlock.h:51:21: error: field 'dep_map' has incomplete type
     struct lockdep_map dep_map;
                        ^~~~~~~
   include/linux/seqlock.h:56:15: warning: 'struct lock_class_key' declared inside parameter list will not be visible outside of this definition or declaration
           struct lock_class_key *key)
                  ^~~~~~~~~~~~~~
   include/linux/seqlock.h: In function '__seqcount_init':
   include/linux/seqlock.h:61:2: error: implicit declaration of function 'lockdep_init_map' [-Werror=implicit-function-declaration]
     lockdep_init_map(&s->dep_map, name, key, 0);
     ^~~~~~~~~~~~~~~~
   include/linux/seqlock.h: In function 'seqcount_lockdep_reader_access':
   include/linux/seqlock.h:81:2: error: implicit declaration of function 'seqcount_acquire_read' [-Werror=implicit-function-declaration]
     seqcount_acquire_read(&l->dep_map, 0, 0, _RET_IP_);
     ^~~~~~~~~~~~~~~~~~~~~
>> include/linux/seqlock.h:82:2: error: implicit declaration of function 'seqcount_release'; did you mean 'seqcount_init'? [-Werror=implicit-function-declaration]
     seqcount_release(&l->dep_map, 1, _RET_IP_);
     ^~~~~~~~~~~~~~~~
     seqcount_init
   include/linux/seqlock.h: In function 'write_seqcount_begin_nested':
   include/linux/seqlock.h:377:2: error: implicit declaration of function 'seqcount_acquire'; did you mean 'seqcount_init'? [-Werror=implicit-function-declaration]
     seqcount_acquire(&s->dep_map, subclass, 0, _RET_IP_);
     ^~~~~~~~~~~~~~~~
     seqcount_init
   include/linux/seqlock.h: At top level:
   include/linux/seqlock.h:406:2: error: unknown type name 'spinlock_t'
     spinlock_t lock;
     ^~~~~~~~~~
   include/linux/seqlock.h: In function 'write_seqlock':
   include/linux/seqlock.h:448:2: error: implicit declaration of function 'spin_lock'; did you mean 'write_lock'? [-Werror=implicit-function-declaration]
     spin_lock(&sl->lock);
     ^~~~~~~~~
     write_lock
   include/linux/seqlock.h: In function 'write_sequnlock':
   include/linux/seqlock.h:455:2: error: implicit declaration of function 'spin_unlock'; did you mean 'raw_spin_unlock'? [-Werror=implicit-function-declaration]
     spin_unlock(&sl->lock);
     ^~~~~~~~~~~
     raw_spin_unlock
   include/linux/seqlock.h: In function 'write_seqlock_bh':
   include/linux/seqlock.h:460:2: error: implicit declaration of function 'spin_lock_bh'; did you mean 'raw_spin_lock_bh'? [-Werror=implicit-function-declaration]
     spin_lock_bh(&sl->lock);
     ^~~~~~~~~~~~
     raw_spin_lock_bh
   include/linux/seqlock.h: In function 'write_sequnlock_bh':
   include/linux/seqlock.h:467:2: error: implicit declaration of function 'spin_unlock_bh'; did you mean 'write_unlock_bh'? [-Werror=implicit-function-declaration]
     spin_unlock_bh(&sl->lock);
     ^~~~~~~~~~~~~~
     write_unlock_bh
   include/linux/seqlock.h: In function 'write_seqlock_irq':
   include/linux/seqlock.h:472:2: error: implicit declaration of function 'spin_lock_irq'; did you mean 'spin_lock_init'? [-Werror=implicit-function-declaration]
     spin_lock_irq(&sl->lock);
     ^~~~~~~~~~~~~
     spin_lock_init
   include/linux/seqlock.h: In function 'write_sequnlock_irq':
   include/linux/seqlock.h:479:2: error: implicit declaration of function 'spin_unlock_irq'; did you mean 'read_unlock_irq'? [-Werror=implicit-function-declaration]
     spin_unlock_irq(&sl->lock);
     ^~~~~~~~~~~~~~~
     read_unlock_irq
   In file included from include/linux/seqlock.h:36:0,
                    from include/linux/time.h:6,
                    from include/linux/ktime.h:24,
                    from include/linux/rcutiny.h:28,
                    from include/linux/rcupdate.h:211,
                    from include/linux/rculist.h:11,
                    from include/linux/pid.h:5,
                    from include/linux/sched.h:14,
                    from include/linux/uaccess.h:5,
                    from arch/x86/include/asm/stacktrace.h:10,
                    from include/linux/stacktrace.h:6,
                    from include/linux/lockdep.h:29,
                    from include/linux/spinlock_types.h:18,
                    from kernel/bounds.c:14:
   include/linux/seqlock.h: In function '__write_seqlock_irqsave':
   include/linux/spinlock.h:222:11: error: implicit declaration of function '_raw_spin_lock_irqsave'; did you mean 'raw_spin_lock_irqsave'? [-Werror=implicit-function-declaration]
      flags = _raw_spin_lock_irqsave(lock); \
              ^
   include/linux/spinlock.h:340:2: note: in expansion of macro 'raw_spin_lock_irqsave'
     raw_spin_lock_irqsave(spinlock_check(lock), flags); \
     ^~~~~~~~~~~~~~~~~~~~~
   include/linux/seqlock.h:486:2: note: in expansion of macro 'spin_lock_irqsave'
     spin_lock_irqsave(&sl->lock, flags);
     ^~~~~~~~~~~~~~~~~
   include/linux/spinlock.h:340:24: error: implicit declaration of function 'spinlock_check'; did you mean 'cpumask_check'? [-Werror=implicit-function-declaration]
     raw_spin_lock_irqsave(spinlock_check(lock), flags); \
                           ^
   include/linux/spinlock.h:222:34: note: in definition of macro 'raw_spin_lock_irqsave'
      flags = _raw_spin_lock_irqsave(lock); \
                                     ^~~~
   include/linux/seqlock.h:486:2: note: in expansion of macro 'spin_lock_irqsave'
     spin_lock_irqsave(&sl->lock, flags);
     ^~~~~~~~~~~~~~~~~
   In file included from include/linux/time.h:6:0,
                    from include/linux/ktime.h:24,
                    from include/linux/rcutiny.h:28,
                    from include/linux/rcupdate.h:211,
                    from include/linux/rculist.h:11,
                    from include/linux/pid.h:5,
                    from include/linux/sched.h:14,
                    from include/linux/uaccess.h:5,
                    from arch/x86/include/asm/stacktrace.h:10,
                    from include/linux/stacktrace.h:6,
                    from include/linux/lockdep.h:29,
                    from include/linux/spinlock_types.h:18,
                    from kernel/bounds.c:14:
   include/linux/seqlock.h: In function 'write_sequnlock_irqrestore':
   include/linux/seqlock.h:498:2: error: implicit declaration of function 'spin_unlock_irqrestore'; did you mean 'raw_spin_unlock_irqrestore'? [-Werror=implicit-function-declaration]
     spin_unlock_irqrestore(&sl->lock, flags);
     ^~~~~~~~~~~~~~~~~~~~~~
     raw_spin_unlock_irqrestore
   In file included from include/linux/rculist.h:11:0,
                    from include/linux/pid.h:5,
                    from include/linux/sched.h:14,
                    from include/linux/uaccess.h:5,
                    from arch/x86/include/asm/stacktrace.h:10,
                    from include/linux/stacktrace.h:6,
                    from include/linux/lockdep.h:29,

vim +82 include/linux/seqlock.h

^1da177e Linus Torvalds 2005-04-16  54  
1ca7d67c John Stultz    2013-10-07  55  static inline void __seqcount_init(seqcount_t *s, const char *name,
1ca7d67c John Stultz    2013-10-07  56  					  struct lock_class_key *key)
1ca7d67c John Stultz    2013-10-07  57  {
1ca7d67c John Stultz    2013-10-07  58  	/*
1ca7d67c John Stultz    2013-10-07  59  	 * Make sure we are not reinitializing a held lock:
1ca7d67c John Stultz    2013-10-07  60  	 */
1ca7d67c John Stultz    2013-10-07 @61  	lockdep_init_map(&s->dep_map, name, key, 0);
1ca7d67c John Stultz    2013-10-07  62  	s->sequence = 0;
1ca7d67c John Stultz    2013-10-07  63  }
1ca7d67c John Stultz    2013-10-07  64  
1ca7d67c John Stultz    2013-10-07  65  #ifdef CONFIG_DEBUG_LOCK_ALLOC
1ca7d67c John Stultz    2013-10-07  66  # define SEQCOUNT_DEP_MAP_INIT(lockname) \
1ca7d67c John Stultz    2013-10-07  67  		.dep_map = { .name = #lockname } \
1ca7d67c John Stultz    2013-10-07  68  
1ca7d67c John Stultz    2013-10-07  69  # define seqcount_init(s)				\
1ca7d67c John Stultz    2013-10-07  70  	do {						\
1ca7d67c John Stultz    2013-10-07  71  		static struct lock_class_key __key;	\
1ca7d67c John Stultz    2013-10-07  72  		__seqcount_init((s), #s, &__key);	\
1ca7d67c John Stultz    2013-10-07  73  	} while (0)
1ca7d67c John Stultz    2013-10-07  74  
1ca7d67c John Stultz    2013-10-07  75  static inline void seqcount_lockdep_reader_access(const seqcount_t *s)
1ca7d67c John Stultz    2013-10-07  76  {
1ca7d67c John Stultz    2013-10-07  77  	seqcount_t *l = (seqcount_t *)s;
1ca7d67c John Stultz    2013-10-07  78  	unsigned long flags;
1ca7d67c John Stultz    2013-10-07  79  
1ca7d67c John Stultz    2013-10-07  80  	local_irq_save(flags);
1ca7d67c John Stultz    2013-10-07  81  	seqcount_acquire_read(&l->dep_map, 0, 0, _RET_IP_);
1ca7d67c John Stultz    2013-10-07 @82  	seqcount_release(&l->dep_map, 1, _RET_IP_);
1ca7d67c John Stultz    2013-10-07  83  	local_irq_restore(flags);
1ca7d67c John Stultz    2013-10-07  84  }
1ca7d67c John Stultz    2013-10-07  85  

:::::: The code at line 82 was first introduced by commit
:::::: 1ca7d67cf5d5a2aef26a8d9afd789006fa098347 seqcount: Add lockdep functionality to seqcount/seqlock structures

:::::: TO: John Stultz <john.stultz@linaro.org>
:::::: CC: Ingo Molnar <mingo@kernel.org>

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

Patch

diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
index a56e7c8..d7d629b 100644
--- a/arch/arm/kernel/stacktrace.c
+++ b/arch/arm/kernel/stacktrace.c
@@ -4,7 +4,6 @@ 
 #include <linux/stacktrace.h>
 
 #include <asm/sections.h>
-#include <asm/stacktrace.h>
 #include <asm/traps.h>
 
 #if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND)
diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
index d5718a0..33c4028 100644
--- a/arch/arm64/kernel/stacktrace.c
+++ b/arch/arm64/kernel/stacktrace.c
@@ -25,7 +25,6 @@ 
 
 #include <asm/irq.h>
 #include <asm/stack_pointer.h>
-#include <asm/stacktrace.h>
 
 /*
  * AArch64 PCS assigns the frame pointer to x29.
diff --git a/arch/mips/kernel/stacktrace.c b/arch/mips/kernel/stacktrace.c
index 7c7c902..0b44e10 100644
--- a/arch/mips/kernel/stacktrace.c
+++ b/arch/mips/kernel/stacktrace.c
@@ -8,7 +8,6 @@ 
 #include <linux/sched/task_stack.h>
 #include <linux/stacktrace.h>
 #include <linux/export.h>
-#include <asm/stacktrace.h>
 
 /*
  * Save stack-backtrace addresses into a stack_trace buffer:
diff --git a/arch/mips/oprofile/backtrace.c b/arch/mips/oprofile/backtrace.c
index 806fb79..845ff8c 100644
--- a/arch/mips/oprofile/backtrace.c
+++ b/arch/mips/oprofile/backtrace.c
@@ -4,7 +4,6 @@ 
 #include <linux/mm.h>
 #include <linux/uaccess.h>
 #include <asm/ptrace.h>
-#include <asm/stacktrace.h>
 #include <linux/stacktrace.h>
 #include <linux/kernel.h>
 #include <asm/sections.h>
diff --git a/arch/sh/kernel/stacktrace.c b/arch/sh/kernel/stacktrace.c
index 7a73d27..7a7ac4c 100644
--- a/arch/sh/kernel/stacktrace.c
+++ b/arch/sh/kernel/stacktrace.c
@@ -16,7 +16,6 @@ 
 #include <linux/module.h>
 #include <asm/unwinder.h>
 #include <asm/ptrace.h>
-#include <asm/stacktrace.h>
 
 static int save_stack_stack(void *data, char *name)
 {
diff --git a/arch/sparc/kernel/stacktrace.c b/arch/sparc/kernel/stacktrace.c
index be4c14c..42cdf86 100644
--- a/arch/sparc/kernel/stacktrace.c
+++ b/arch/sparc/kernel/stacktrace.c
@@ -5,7 +5,6 @@ 
 #include <linux/ftrace.h>
 #include <linux/export.h>
 #include <asm/ptrace.h>
-#include <asm/stacktrace.h>
 
 #include "kstack.h"
 
diff --git a/arch/um/kernel/stacktrace.c b/arch/um/kernel/stacktrace.c
index ebe7bcf..a0d556e 100644
--- a/arch/um/kernel/stacktrace.c
+++ b/arch/um/kernel/stacktrace.c
@@ -14,7 +14,6 @@ 
 #include <linux/stacktrace.h>
 #include <linux/module.h>
 #include <linux/uaccess.h>
-#include <asm/stacktrace.h>
 
 void dump_trace(struct task_struct *tsk,
 		const struct stacktrace_ops *ops,
diff --git a/arch/unicore32/kernel/process.c b/arch/unicore32/kernel/process.c
index 2bc10b8..ffca651 100644
--- a/arch/unicore32/kernel/process.c
+++ b/arch/unicore32/kernel/process.c
@@ -36,7 +36,6 @@ 
 
 #include <asm/cacheflush.h>
 #include <asm/processor.h>
-#include <asm/stacktrace.h>
 
 #include "setup.h"
 
diff --git a/arch/unicore32/kernel/stacktrace.c b/arch/unicore32/kernel/stacktrace.c
index 9976e76..f9cd2a4 100644
--- a/arch/unicore32/kernel/stacktrace.c
+++ b/arch/unicore32/kernel/stacktrace.c
@@ -14,8 +14,6 @@ 
 #include <linux/sched/debug.h>
 #include <linux/stacktrace.h>
 
-#include <asm/stacktrace.h>
-
 #if defined(CONFIG_FRAME_POINTER)
 /*
  * Unwind the current stack frame and store the new register values in the
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
index a5d9521..e25d70a 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -156,59 +156,10 @@  struct thread_info {
  *
  * preempt_count needs to be 1 initially, until the scheduler is functional.
  */
-#ifndef __ASSEMBLY__
-
-/*
- * Walks up the stack frames to make sure that the specified object is
- * entirely contained by a single stack frame.
- *
- * Returns:
- *	GOOD_FRAME	if within a frame
- *	BAD_STACK	if placed across a frame boundary (or outside stack)
- *	NOT_STACK	unable to determine (no frame pointers, etc)
- */
-static inline int arch_within_stack_frames(const void * const stack,
-					   const void * const stackend,
-					   const void *obj, unsigned long len)
-{
-#if defined(CONFIG_FRAME_POINTER)
-	const void *frame = NULL;
-	const void *oldframe;
-
-	oldframe = __builtin_frame_address(1);
-	if (oldframe)
-		frame = __builtin_frame_address(2);
-	/*
-	 * low ----------------------------------------------> high
-	 * [saved bp][saved ip][args][local vars][saved bp][saved ip]
-	 *                     ^----------------^
-	 *               allow copies only within here
-	 */
-	while (stack <= frame && frame < stackend) {
-		/*
-		 * If obj + len extends past the last frame, this
-		 * check won't pass and the next frame will be 0,
-		 * causing us to bail out and correctly report
-		 * the copy as invalid.
-		 */
-		if (obj + len <= frame)
-			return obj >= oldframe + 2 * sizeof(void *) ?
-				GOOD_FRAME : BAD_STACK;
-		oldframe = frame;
-		frame = *(const void * const *)frame;
-	}
-	return BAD_STACK;
-#else
-	return NOT_STACK;
-#endif
-}
-
-#else /* !__ASSEMBLY__ */
-
+#ifdef __ASSEMBLY__
 #ifdef CONFIG_X86_64
 # define cpu_current_top_of_stack (cpu_tss_rw + TSS_sp1)
 #endif
-
 #endif
 
 #ifdef CONFIG_COMPAT
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 02d6f5c..3b8afd5 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -70,7 +70,7 @@  obj-$(CONFIG_IA32_EMULATION)	+= tls.o
 obj-y				+= step.o
 obj-$(CONFIG_INTEL_TXT)		+= tboot.o
 obj-$(CONFIG_ISA_DMA_API)	+= i8237.o
-obj-$(CONFIG_STACKTRACE)	+= stacktrace.o
+obj-y				+= stacktrace.o
 obj-y				+= cpu/
 obj-y				+= acpi/
 obj-y				+= reboot.o
diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c
index 093f2ea..f433a33 100644
--- a/arch/x86/kernel/stacktrace.c
+++ b/arch/x86/kernel/stacktrace.c
@@ -9,9 +9,56 @@ 
 #include <linux/stacktrace.h>
 #include <linux/export.h>
 #include <linux/uaccess.h>
-#include <asm/stacktrace.h>
 #include <asm/unwind.h>
 
+
+/*
+ * Walks up the stack frames to make sure that the specified object is
+ * entirely contained by a single stack frame.
+ *
+ * Returns:
+ *	GOOD_FRAME	if within a frame
+ *	BAD_STACK	if placed across a frame boundary (or outside stack)
+ *	NOT_STACK	unable to determine (no frame pointers, etc)
+ */
+int arch_within_stack_frames(const void * const stack,
+			     const void * const stackend,
+			     const void *obj, unsigned long len)
+{
+#if defined(CONFIG_FRAME_POINTER)
+	const void *frame = NULL;
+	const void *oldframe;
+
+	oldframe = __builtin_frame_address(2);
+	if (oldframe)
+		frame = __builtin_frame_address(3);
+	/*
+	 * low ----------------------------------------------> high
+	 * [saved bp][saved ip][args][local vars][saved bp][saved ip]
+	 *                     ^----------------^
+	 *               allow copies only within here
+	 */
+	while (stack <= frame && frame < stackend) {
+		/*
+		 * If obj + len extends past the last frame, this
+		 * check won't pass and the next frame will be 0,
+		 * causing us to bail out and correctly report
+		 * the copy as invalid.
+		 */
+		if (obj + len <= frame)
+			return obj >= oldframe + 2 * sizeof(void *) ?
+				GOOD_FRAME : BAD_STACK;
+		oldframe = frame;
+		frame = *(const void * const *)frame;
+	}
+	return BAD_STACK;
+#else
+	return NOT_STACK;
+#endif
+}
+
+#ifdef CONFIG_STACKTRACE
+
 static int save_stack_address(struct stack_trace *trace, unsigned long addr,
 			      bool nosched)
 {
@@ -241,3 +288,4 @@  void save_stack_trace_user(struct stack_trace *trace)
 	if (trace->nr_entries < trace->max_entries)
 		trace->entries[trace->nr_entries++] = ULONG_MAX;
 }
+#endif /* CONFIG_STACKTRACE */
diff --git a/arch/xtensa/kernel/stacktrace.c b/arch/xtensa/kernel/stacktrace.c
index 0df4080..ab831d8 100644
--- a/arch/xtensa/kernel/stacktrace.c
+++ b/arch/xtensa/kernel/stacktrace.c
@@ -12,7 +12,6 @@ 
 #include <linux/sched.h>
 #include <linux/stacktrace.h>
 
-#include <asm/stacktrace.h>
 #include <asm/traps.h>
 #include <linux/uaccess.h>
 
diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h
index ca5461e..f3b7dd9 100644
--- a/include/linux/page_ext.h
+++ b/include/linux/page_ext.h
@@ -3,7 +3,6 @@ 
 #define __LINUX_PAGE_EXT_H
 
 #include <linux/types.h>
-#include <linux/stacktrace.h>
 #include <linux/stackdepot.h>
 
 struct pglist_data;
diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h
index ba29a06..4fd061e 100644
--- a/include/linux/stacktrace.h
+++ b/include/linux/stacktrace.h
@@ -3,10 +3,35 @@ 
 #define __LINUX_STACKTRACE_H
 
 #include <linux/types.h>
+#include <asm/stacktrace.h>
 
 struct task_struct;
 struct pt_regs;
 
+/*
+ * For per-arch arch_within_stack_frames() implementations, defined in
+ * kernel/stacktrace.c.
+ */
+enum {
+	BAD_STACK = -1,
+	NOT_STACK = 0,
+	GOOD_FRAME,
+	GOOD_STACK,
+};
+
+#ifdef CONFIG_HAVE_ARCH_WITHIN_STACK_FRAMES
+extern int arch_within_stack_frames(const void * const stack,
+				    const void * const stackend,
+				    const void *obj, unsigned long len);
+#else
+static inline int arch_within_stack_frames(const void * const stack,
+					   const void * const stackend,
+					   const void *obj, unsigned long len)
+{
+	return NOT_STACK;
+}
+#endif
+
 #ifdef CONFIG_STACKTRACE
 struct stack_trace {
 	unsigned int nr_entries, max_entries;
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index 34f053a..5403851 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -23,18 +23,6 @@ 
 #endif
 
 #include <linux/bitops.h>
-
-/*
- * For per-arch arch_within_stack_frames() implementations, defined in
- * asm/thread_info.h.
- */
-enum {
-	BAD_STACK = -1,
-	NOT_STACK = 0,
-	GOOD_FRAME,
-	GOOD_STACK,
-};
-
 #include <asm/thread_info.h>
 
 #ifdef __KERNEL__
@@ -92,15 +80,6 @@  static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
 
 #define tif_need_resched() test_thread_flag(TIF_NEED_RESCHED)
 
-#ifndef CONFIG_HAVE_ARCH_WITHIN_STACK_FRAMES
-static inline int arch_within_stack_frames(const void * const stack,
-					   const void * const stackend,
-					   const void *obj, unsigned long len)
-{
-	return 0;
-}
-#endif
-
 #ifdef CONFIG_HARDENED_USERCOPY
 extern void __check_object_size(const void *ptr, unsigned long n,
 					bool to_user);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index bdf7090..782c3e4 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -73,7 +73,6 @@ 
 
 #ifdef CONFIG_X86
 #include <asm/nmi.h>
-#include <asm/stacktrace.h>
 #include <asm/io.h>
 #endif
 #ifdef CONFIG_SPARC
diff --git a/mm/usercopy.c b/mm/usercopy.c
index e9e9325..6a74776 100644
--- a/mm/usercopy.c
+++ b/mm/usercopy.c
@@ -19,7 +19,7 @@ 
 #include <linux/sched.h>
 #include <linux/sched/task.h>
 #include <linux/sched/task_stack.h>
-#include <linux/thread_info.h>
+#include <linux/stacktrace.h>
 #include <asm/sections.h>
 
 /*