Skip to contentSkip to conversation

kernel.h: split out instruction pointer accessors

PATCH Superseded Andy Shevchenko 2 participants 3 messages Oct 27, 2021 Memory management

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kernel.h: split out instruction pointer accessors

From: Stephen Rothwell <[email protected]>

bottom_half.h needs _THIS_IP_ to be standalone, so split that and _RET_IP_ out from kernel.h into the new instruction_pointer.h. kernel.h directly needs them, so include it there and replace the include of kernel.h with this new file in bottom_half.h.

---
v2: sent as a formal patch, fixed a couple of typos

 include/linux/bottom_half.h         | 2 +-
 include/linux/instruction_pointer.h | 8 ++++++++
 include/linux/kernel.h              | 4 +---
 3 files changed, 10 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/instruction_pointer.h
include/linux/bottom_half.h +1 -1
index 11d107d88d03..fc53e0ad56d9 100644
@@ -2,7 +2,7 @@
 #ifndef _LINUX_BH_H
 #define _LINUX_BH_H
 
-#include <linux/kernel.h>
+#include <linux/instruction_pointer.h>
 #include <linux/preempt.h>
 
 #if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_TRACE_IRQFLAGS)
include/linux/instruction_pointer.h new file +8 -0
new file mode 100644
index 000000000000..19e979425bda
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_INSTRUCTION_POINTER_H
+#define _LINUX_INSTRUCTION_POINTER_H
+
+#define _RET_IP_		(unsigned long)__builtin_return_address(0)
+#define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here; })
+
+#enfif /* _LINUX_INSTRUCTION_POINTER_H */
include/linux/kernel.h +1 -3
index 24df51162e3e..968b4c4fe65b 100644
@@ -20,6 +20,7 @@
 #include <linux/printk.h>
 #include <linux/build_bug.h>
 #include <linux/static_call_types.h>
+#include <linux/instruction_pointer.h>
 #include <asm/byteorder.h>
 
 #include <uapi/linux/kernel.h>
@@ -53,9 +54,6 @@
 }					\
 )
 
-#define _RET_IP_		(unsigned long)__builtin_return_address(0)
-#define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here; })
-
 /**
  * upper_32_bits - return bits 32-63 of a number
  * @n: the number we're accessing
Signature · 1 line
2.33.0
#1 lore raw
Thank you for the patch! Yet something to improve:

Hi Andy,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20211026]
[cannot apply to linus/master v5.15-rc7 v5.15-rc6 v5.15-rc5 v5.15-rc7] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/kernel-h-split-out-instruction-pointer-accessors/20211027-235208
base:    2376e5fe91bcad74b997d2cc0535abff79ec73c5
config: i386-tinyconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/9fc7130c986cccb5765165dd9f7fc77a4935892c
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andy-Shevchenko/kernel-h-split-out-instruction-pointer-accessors/20211027-235208 git checkout 9fc7130c986cccb5765165dd9f7fc77a4935892c
# save the attached .config to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=i386 prepare

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from include/linux/kernel.h:23,

                    from include/linux/crypto.h:16,
                    from arch/x86/kernel/asm-offsets.c:9:
>> include/linux/instruction_pointer.h:8:2: error: invalid preprocessing directive #enfif; did you mean #endif?
       8 | #enfif /* _LINUX_INSTRUCTION_POINTER_H */
         |  ^~~~~
         |  endif
>> include/linux/instruction_pointer.h:2: error: unterminated #ifndef
       2 | #ifndef _LINUX_INSTRUCTION_POINTER_H
         | 
   In file included from include/linux/bottom_half.h:5,
                    from include/linux/spinlock.h:61,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:6,
                    from include/linux/slab.h:15,
                    from include/linux/crypto.h:20,
                    from arch/x86/kernel/asm-offsets.c:9:
>> include/linux/instruction_pointer.h:2: error: unterminated #ifndef

2 | #ifndef _LINUX_INSTRUCTION_POINTER_H
|
make[2]: *** [scripts/Makefile.build:122: arch/x86/kernel/asm-offsets.s] Error 1 make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1288: prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:226: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.

vim +8 include/linux/instruction_pointer.h

   > 2	#ifndef _LINUX_INSTRUCTION_POINTER_H
     3	#define _LINUX_INSTRUCTION_POINTER_H
     4	
     5	#define _RET_IP_		(unsigned long)__builtin_return_address(0)
     6	#define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here; })
     7	
   > 8	#enfif /* _LINUX_INSTRUCTION_POINTER_H */

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#2 lore raw
Quoted 23 lines · kernel test robot

Hi Andy,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20211026]
[cannot apply to linus/master v5.15-rc7 v5.15-rc6 v5.15-rc5 v5.15-rc7] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/kernel-h-split-out-instruction-pointer-accessors/20211027-235208
base:    2376e5fe91bcad74b997d2cc0535abff79ec73c5
config: i386-tinyconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/9fc7130c986cccb5765165dd9f7fc77a4935892c
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andy-Shevchenko/kernel-h-split-out-instruction-pointer-accessors/20211027-235208 git checkout 9fc7130c986cccb5765165dd9f7fc77a4935892c
# save the attached .config to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=i386 prepare

Quoted 2 lines

If you fix the issue, kindly add following tag as appropriate

Thanks!
Something went wrong when I fixed the typos...

Signature · 2 lines
With Best Regards,
Andy Shevchenko