All of lore.kernel.org
 help / color / mirror / Atom feed
* arch/arm/kernel/patch.c:94:11: error: implicit declaration of function '__opcode_to_mem_thumb32'
@ 2021-02-20 19:08 ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-02-20 19:08 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: kbuild-all, linux-kernel, Ingo Molnar

[-- Attachment #1: Type: text/plain, Size: 5932 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   f40ddce88593482919761f74910f42f4b84c004b
commit: 5a735583b764750726621b0396d03e4782911b77 arm/ftrace: Use __patch_text()
date:   1 year, 3 months ago
config: arm-randconfig-r014-20210220 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5a735583b764750726621b0396d03e4782911b77
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 5a735583b764750726621b0396d03e4782911b77
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   arch/arm/kernel/patch.c: In function '__patch_text_real':
>> arch/arm/kernel/patch.c:94:11: error: implicit declaration of function '__opcode_to_mem_thumb32' [-Werror=implicit-function-declaration]
      94 |    insn = __opcode_to_mem_thumb32(insn);
         |           ^~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/__opcode_to_mem_thumb32 +94 arch/arm/kernel/patch.c

ab0615e2d6fb07 Rabin Vincent 2014-04-24   55  
ab0615e2d6fb07 Rabin Vincent 2014-04-24   56  void __kprobes __patch_text_real(void *addr, unsigned int insn, bool remap)
b21d55e98ac2bb Rabin Vincent 2012-02-18   57  {
b21d55e98ac2bb Rabin Vincent 2012-02-18   58  	bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   59  	unsigned int uintaddr = (uintptr_t) addr;
ab0615e2d6fb07 Rabin Vincent 2014-04-24   60  	bool twopage = false;
ab0615e2d6fb07 Rabin Vincent 2014-04-24   61  	unsigned long flags;
ab0615e2d6fb07 Rabin Vincent 2014-04-24   62  	void *waddr = addr;
b21d55e98ac2bb Rabin Vincent 2012-02-18   63  	int size;
b21d55e98ac2bb Rabin Vincent 2012-02-18   64  
ab0615e2d6fb07 Rabin Vincent 2014-04-24   65  	if (remap)
ab0615e2d6fb07 Rabin Vincent 2014-04-24   66  		waddr = patch_map(addr, FIX_TEXT_POKE0, &flags);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   67  	else
ab0615e2d6fb07 Rabin Vincent 2014-04-24   68  		__acquire(&patch_lock);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   69  
b21d55e98ac2bb Rabin Vincent 2012-02-18   70  	if (thumb2 && __opcode_is_thumb16(insn)) {
ab0615e2d6fb07 Rabin Vincent 2014-04-24   71  		*(u16 *)waddr = __opcode_to_mem_thumb16(insn);
b21d55e98ac2bb Rabin Vincent 2012-02-18   72  		size = sizeof(u16);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   73  	} else if (thumb2 && (uintaddr & 2)) {
b21d55e98ac2bb Rabin Vincent 2012-02-18   74  		u16 first = __opcode_thumb32_first(insn);
b21d55e98ac2bb Rabin Vincent 2012-02-18   75  		u16 second = __opcode_thumb32_second(insn);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   76  		u16 *addrh0 = waddr;
ab0615e2d6fb07 Rabin Vincent 2014-04-24   77  		u16 *addrh1 = waddr + 2;
ab0615e2d6fb07 Rabin Vincent 2014-04-24   78  
ab0615e2d6fb07 Rabin Vincent 2014-04-24   79  		twopage = (uintaddr & ~PAGE_MASK) == PAGE_SIZE - 2;
ab0615e2d6fb07 Rabin Vincent 2014-04-24   80  		if (twopage && remap)
ab0615e2d6fb07 Rabin Vincent 2014-04-24   81  			addrh1 = patch_map(addr + 2, FIX_TEXT_POKE1, NULL);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   82  
ab0615e2d6fb07 Rabin Vincent 2014-04-24   83  		*addrh0 = __opcode_to_mem_thumb16(first);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   84  		*addrh1 = __opcode_to_mem_thumb16(second);
b21d55e98ac2bb Rabin Vincent 2012-02-18   85  
ab0615e2d6fb07 Rabin Vincent 2014-04-24   86  		if (twopage && addrh1 != addr + 2) {
ab0615e2d6fb07 Rabin Vincent 2014-04-24   87  			flush_kernel_vmap_range(addrh1, 2);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   88  			patch_unmap(FIX_TEXT_POKE1, NULL);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   89  		}
b21d55e98ac2bb Rabin Vincent 2012-02-18   90  
b21d55e98ac2bb Rabin Vincent 2012-02-18   91  		size = sizeof(u32);
b21d55e98ac2bb Rabin Vincent 2012-02-18   92  	} else {
b21d55e98ac2bb Rabin Vincent 2012-02-18   93  		if (thumb2)
b21d55e98ac2bb Rabin Vincent 2012-02-18  @94  			insn = __opcode_to_mem_thumb32(insn);
b21d55e98ac2bb Rabin Vincent 2012-02-18   95  		else
b21d55e98ac2bb Rabin Vincent 2012-02-18   96  			insn = __opcode_to_mem_arm(insn);
b21d55e98ac2bb Rabin Vincent 2012-02-18   97  
ab0615e2d6fb07 Rabin Vincent 2014-04-24   98  		*(u32 *)waddr = insn;
b21d55e98ac2bb Rabin Vincent 2012-02-18   99  		size = sizeof(u32);
b21d55e98ac2bb Rabin Vincent 2012-02-18  100  	}
b21d55e98ac2bb Rabin Vincent 2012-02-18  101  
ab0615e2d6fb07 Rabin Vincent 2014-04-24  102  	if (waddr != addr) {
ab0615e2d6fb07 Rabin Vincent 2014-04-24  103  		flush_kernel_vmap_range(waddr, twopage ? size / 2 : size);
ab0615e2d6fb07 Rabin Vincent 2014-04-24  104  		patch_unmap(FIX_TEXT_POKE0, &flags);
ab0615e2d6fb07 Rabin Vincent 2014-04-24  105  	} else
ab0615e2d6fb07 Rabin Vincent 2014-04-24  106  		__release(&patch_lock);
ab0615e2d6fb07 Rabin Vincent 2014-04-24  107  
b21d55e98ac2bb Rabin Vincent 2012-02-18  108  	flush_icache_range((uintptr_t)(addr),
b21d55e98ac2bb Rabin Vincent 2012-02-18  109  			   (uintptr_t)(addr) + size);
b21d55e98ac2bb Rabin Vincent 2012-02-18  110  }
b21d55e98ac2bb Rabin Vincent 2012-02-18  111  

:::::: The code at line 94 was first introduced by commit
:::::: b21d55e98ac2bbcbbeec9a8cb091f717fd95b072 ARM: 7332/1: extract out code patch function from kprobes

:::::: TO: Rabin Vincent <rabin@rab.in>
:::::: CC: Russell King <rmk+kernel@arm.linux.org.uk>

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 36699 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* arch/arm/kernel/patch.c:94:11: error: implicit declaration of function '__opcode_to_mem_thumb32'
@ 2021-02-20 19:08 ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-02-20 19:08 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 6031 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   f40ddce88593482919761f74910f42f4b84c004b
commit: 5a735583b764750726621b0396d03e4782911b77 arm/ftrace: Use __patch_text()
date:   1 year, 3 months ago
config: arm-randconfig-r014-20210220 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5a735583b764750726621b0396d03e4782911b77
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 5a735583b764750726621b0396d03e4782911b77
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   arch/arm/kernel/patch.c: In function '__patch_text_real':
>> arch/arm/kernel/patch.c:94:11: error: implicit declaration of function '__opcode_to_mem_thumb32' [-Werror=implicit-function-declaration]
      94 |    insn = __opcode_to_mem_thumb32(insn);
         |           ^~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/__opcode_to_mem_thumb32 +94 arch/arm/kernel/patch.c

ab0615e2d6fb07 Rabin Vincent 2014-04-24   55  
ab0615e2d6fb07 Rabin Vincent 2014-04-24   56  void __kprobes __patch_text_real(void *addr, unsigned int insn, bool remap)
b21d55e98ac2bb Rabin Vincent 2012-02-18   57  {
b21d55e98ac2bb Rabin Vincent 2012-02-18   58  	bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   59  	unsigned int uintaddr = (uintptr_t) addr;
ab0615e2d6fb07 Rabin Vincent 2014-04-24   60  	bool twopage = false;
ab0615e2d6fb07 Rabin Vincent 2014-04-24   61  	unsigned long flags;
ab0615e2d6fb07 Rabin Vincent 2014-04-24   62  	void *waddr = addr;
b21d55e98ac2bb Rabin Vincent 2012-02-18   63  	int size;
b21d55e98ac2bb Rabin Vincent 2012-02-18   64  
ab0615e2d6fb07 Rabin Vincent 2014-04-24   65  	if (remap)
ab0615e2d6fb07 Rabin Vincent 2014-04-24   66  		waddr = patch_map(addr, FIX_TEXT_POKE0, &flags);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   67  	else
ab0615e2d6fb07 Rabin Vincent 2014-04-24   68  		__acquire(&patch_lock);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   69  
b21d55e98ac2bb Rabin Vincent 2012-02-18   70  	if (thumb2 && __opcode_is_thumb16(insn)) {
ab0615e2d6fb07 Rabin Vincent 2014-04-24   71  		*(u16 *)waddr = __opcode_to_mem_thumb16(insn);
b21d55e98ac2bb Rabin Vincent 2012-02-18   72  		size = sizeof(u16);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   73  	} else if (thumb2 && (uintaddr & 2)) {
b21d55e98ac2bb Rabin Vincent 2012-02-18   74  		u16 first = __opcode_thumb32_first(insn);
b21d55e98ac2bb Rabin Vincent 2012-02-18   75  		u16 second = __opcode_thumb32_second(insn);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   76  		u16 *addrh0 = waddr;
ab0615e2d6fb07 Rabin Vincent 2014-04-24   77  		u16 *addrh1 = waddr + 2;
ab0615e2d6fb07 Rabin Vincent 2014-04-24   78  
ab0615e2d6fb07 Rabin Vincent 2014-04-24   79  		twopage = (uintaddr & ~PAGE_MASK) == PAGE_SIZE - 2;
ab0615e2d6fb07 Rabin Vincent 2014-04-24   80  		if (twopage && remap)
ab0615e2d6fb07 Rabin Vincent 2014-04-24   81  			addrh1 = patch_map(addr + 2, FIX_TEXT_POKE1, NULL);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   82  
ab0615e2d6fb07 Rabin Vincent 2014-04-24   83  		*addrh0 = __opcode_to_mem_thumb16(first);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   84  		*addrh1 = __opcode_to_mem_thumb16(second);
b21d55e98ac2bb Rabin Vincent 2012-02-18   85  
ab0615e2d6fb07 Rabin Vincent 2014-04-24   86  		if (twopage && addrh1 != addr + 2) {
ab0615e2d6fb07 Rabin Vincent 2014-04-24   87  			flush_kernel_vmap_range(addrh1, 2);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   88  			patch_unmap(FIX_TEXT_POKE1, NULL);
ab0615e2d6fb07 Rabin Vincent 2014-04-24   89  		}
b21d55e98ac2bb Rabin Vincent 2012-02-18   90  
b21d55e98ac2bb Rabin Vincent 2012-02-18   91  		size = sizeof(u32);
b21d55e98ac2bb Rabin Vincent 2012-02-18   92  	} else {
b21d55e98ac2bb Rabin Vincent 2012-02-18   93  		if (thumb2)
b21d55e98ac2bb Rabin Vincent 2012-02-18  @94  			insn = __opcode_to_mem_thumb32(insn);
b21d55e98ac2bb Rabin Vincent 2012-02-18   95  		else
b21d55e98ac2bb Rabin Vincent 2012-02-18   96  			insn = __opcode_to_mem_arm(insn);
b21d55e98ac2bb Rabin Vincent 2012-02-18   97  
ab0615e2d6fb07 Rabin Vincent 2014-04-24   98  		*(u32 *)waddr = insn;
b21d55e98ac2bb Rabin Vincent 2012-02-18   99  		size = sizeof(u32);
b21d55e98ac2bb Rabin Vincent 2012-02-18  100  	}
b21d55e98ac2bb Rabin Vincent 2012-02-18  101  
ab0615e2d6fb07 Rabin Vincent 2014-04-24  102  	if (waddr != addr) {
ab0615e2d6fb07 Rabin Vincent 2014-04-24  103  		flush_kernel_vmap_range(waddr, twopage ? size / 2 : size);
ab0615e2d6fb07 Rabin Vincent 2014-04-24  104  		patch_unmap(FIX_TEXT_POKE0, &flags);
ab0615e2d6fb07 Rabin Vincent 2014-04-24  105  	} else
ab0615e2d6fb07 Rabin Vincent 2014-04-24  106  		__release(&patch_lock);
ab0615e2d6fb07 Rabin Vincent 2014-04-24  107  
b21d55e98ac2bb Rabin Vincent 2012-02-18  108  	flush_icache_range((uintptr_t)(addr),
b21d55e98ac2bb Rabin Vincent 2012-02-18  109  			   (uintptr_t)(addr) + size);
b21d55e98ac2bb Rabin Vincent 2012-02-18  110  }
b21d55e98ac2bb Rabin Vincent 2012-02-18  111  

:::::: The code at line 94 was first introduced by commit
:::::: b21d55e98ac2bbcbbeec9a8cb091f717fd95b072 ARM: 7332/1: extract out code patch function from kprobes

:::::: TO: Rabin Vincent <rabin@rab.in>
:::::: CC: Russell King <rmk+kernel@arm.linux.org.uk>

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 36699 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: arch/arm/kernel/patch.c:94:11: error: implicit declaration of function '__opcode_to_mem_thumb32'
  2021-02-20 19:08 ` kernel test robot
@ 2021-02-22  3:25   ` Randy Dunlap
  -1 siblings, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2021-02-22  3:25 UTC (permalink / raw)
  To: kernel test robot, Peter Zijlstra, Russell King
  Cc: kbuild-all, linux-kernel, Ingo Molnar

On 2/20/21 11:08 AM, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   f40ddce88593482919761f74910f42f4b84c004b
> commit: 5a735583b764750726621b0396d03e4782911b77 arm/ftrace: Use __patch_text()
> date:   1 year, 3 months ago
> config: arm-randconfig-r014-20210220 (attached as .config)
> compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5a735583b764750726621b0396d03e4782911b77
>         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>         git fetch --no-tags linus master
>         git checkout 5a735583b764750726621b0396d03e4782911b77
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
>    arch/arm/kernel/patch.c: In function '__patch_text_real':
>>> arch/arm/kernel/patch.c:94:11: error: implicit declaration of function '__opcode_to_mem_thumb32' [-Werror=implicit-function-declaration]
>       94 |    insn = __opcode_to_mem_thumb32(insn);
>          |           ^~~~~~~~~~~~~~~~~~~~~~~
>    cc1: some warnings being treated as errors
> 
> 
> vim +/__opcode_to_mem_thumb32 +94 arch/arm/kernel/patch.c
> 
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   55  
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   56  void __kprobes __patch_text_real(void *addr, unsigned int insn, bool remap)
> b21d55e98ac2bb Rabin Vincent 2012-02-18   57  {
> b21d55e98ac2bb Rabin Vincent 2012-02-18   58  	bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   59  	unsigned int uintaddr = (uintptr_t) addr;
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   60  	bool twopage = false;
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   61  	unsigned long flags;
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   62  	void *waddr = addr;
> b21d55e98ac2bb Rabin Vincent 2012-02-18   63  	int size;
> b21d55e98ac2bb Rabin Vincent 2012-02-18   64  
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   65  	if (remap)
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   66  		waddr = patch_map(addr, FIX_TEXT_POKE0, &flags);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   67  	else
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   68  		__acquire(&patch_lock);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   69  
> b21d55e98ac2bb Rabin Vincent 2012-02-18   70  	if (thumb2 && __opcode_is_thumb16(insn)) {
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   71  		*(u16 *)waddr = __opcode_to_mem_thumb16(insn);
> b21d55e98ac2bb Rabin Vincent 2012-02-18   72  		size = sizeof(u16);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   73  	} else if (thumb2 && (uintaddr & 2)) {
> b21d55e98ac2bb Rabin Vincent 2012-02-18   74  		u16 first = __opcode_thumb32_first(insn);
> b21d55e98ac2bb Rabin Vincent 2012-02-18   75  		u16 second = __opcode_thumb32_second(insn);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   76  		u16 *addrh0 = waddr;
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   77  		u16 *addrh1 = waddr + 2;
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   78  
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   79  		twopage = (uintaddr & ~PAGE_MASK) == PAGE_SIZE - 2;
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   80  		if (twopage && remap)
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   81  			addrh1 = patch_map(addr + 2, FIX_TEXT_POKE1, NULL);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   82  
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   83  		*addrh0 = __opcode_to_mem_thumb16(first);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   84  		*addrh1 = __opcode_to_mem_thumb16(second);
> b21d55e98ac2bb Rabin Vincent 2012-02-18   85  
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   86  		if (twopage && addrh1 != addr + 2) {
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   87  			flush_kernel_vmap_range(addrh1, 2);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   88  			patch_unmap(FIX_TEXT_POKE1, NULL);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   89  		}
> b21d55e98ac2bb Rabin Vincent 2012-02-18   90  
> b21d55e98ac2bb Rabin Vincent 2012-02-18   91  		size = sizeof(u32);
> b21d55e98ac2bb Rabin Vincent 2012-02-18   92  	} else {
> b21d55e98ac2bb Rabin Vincent 2012-02-18   93  		if (thumb2)
> b21d55e98ac2bb Rabin Vincent 2012-02-18  @94  			insn = __opcode_to_mem_thumb32(insn);
> b21d55e98ac2bb Rabin Vincent 2012-02-18   95  		else
> b21d55e98ac2bb Rabin Vincent 2012-02-18   96  			insn = __opcode_to_mem_arm(insn);
> b21d55e98ac2bb Rabin Vincent 2012-02-18   97  
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   98  		*(u32 *)waddr = insn;
> b21d55e98ac2bb Rabin Vincent 2012-02-18   99  		size = sizeof(u32);
> b21d55e98ac2bb Rabin Vincent 2012-02-18  100  	}
> b21d55e98ac2bb Rabin Vincent 2012-02-18  101  
> ab0615e2d6fb07 Rabin Vincent 2014-04-24  102  	if (waddr != addr) {
> ab0615e2d6fb07 Rabin Vincent 2014-04-24  103  		flush_kernel_vmap_range(waddr, twopage ? size / 2 : size);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24  104  		patch_unmap(FIX_TEXT_POKE0, &flags);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24  105  	} else
> ab0615e2d6fb07 Rabin Vincent 2014-04-24  106  		__release(&patch_lock);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24  107  
> b21d55e98ac2bb Rabin Vincent 2012-02-18  108  	flush_icache_range((uintptr_t)(addr),
> b21d55e98ac2bb Rabin Vincent 2012-02-18  109  			   (uintptr_t)(addr) + size);
> b21d55e98ac2bb Rabin Vincent 2012-02-18  110  }
> b21d55e98ac2bb Rabin Vincent 2012-02-18  111  
> 
> :::::: The code at line 94 was first introduced by commit
> :::::: b21d55e98ac2bbcbbeec9a8cb091f717fd95b072 ARM: 7332/1: extract out code patch function from kprobes
> 
> :::::: TO: Rabin Vincent <rabin@rab.in>
> :::::: CC: Russell King <rmk+kernel@arm.linux.org.uk>


This comes down to:

CONFIG_ARM_THUMB=y
CONFIG_CPU_BIG_ENDIAN=y
CONFIG_CPU_ENDIAN_BE32=y

and <asm/opcodes.h>, where arch/arm/asm/opcodes.h says:

/*
 * On BE32 systems, using 32-bit accesses to store Thumb instructions will not
 * work in all cases, due to alignment constraints.  For now, a correct
 * version is not provided for BE32.
 */

Should we try to find a way to prevent this combination from happening?


-- 
~Randy


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: arch/arm/kernel/patch.c:94:11: error: implicit declaration of function '__opcode_to_mem_thumb32'
@ 2021-02-22  3:25   ` Randy Dunlap
  0 siblings, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2021-02-22  3:25 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 6594 bytes --]

On 2/20/21 11:08 AM, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   f40ddce88593482919761f74910f42f4b84c004b
> commit: 5a735583b764750726621b0396d03e4782911b77 arm/ftrace: Use __patch_text()
> date:   1 year, 3 months ago
> config: arm-randconfig-r014-20210220 (attached as .config)
> compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5a735583b764750726621b0396d03e4782911b77
>         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>         git fetch --no-tags linus master
>         git checkout 5a735583b764750726621b0396d03e4782911b77
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
>    arch/arm/kernel/patch.c: In function '__patch_text_real':
>>> arch/arm/kernel/patch.c:94:11: error: implicit declaration of function '__opcode_to_mem_thumb32' [-Werror=implicit-function-declaration]
>       94 |    insn = __opcode_to_mem_thumb32(insn);
>          |           ^~~~~~~~~~~~~~~~~~~~~~~
>    cc1: some warnings being treated as errors
> 
> 
> vim +/__opcode_to_mem_thumb32 +94 arch/arm/kernel/patch.c
> 
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   55  
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   56  void __kprobes __patch_text_real(void *addr, unsigned int insn, bool remap)
> b21d55e98ac2bb Rabin Vincent 2012-02-18   57  {
> b21d55e98ac2bb Rabin Vincent 2012-02-18   58  	bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   59  	unsigned int uintaddr = (uintptr_t) addr;
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   60  	bool twopage = false;
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   61  	unsigned long flags;
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   62  	void *waddr = addr;
> b21d55e98ac2bb Rabin Vincent 2012-02-18   63  	int size;
> b21d55e98ac2bb Rabin Vincent 2012-02-18   64  
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   65  	if (remap)
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   66  		waddr = patch_map(addr, FIX_TEXT_POKE0, &flags);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   67  	else
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   68  		__acquire(&patch_lock);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   69  
> b21d55e98ac2bb Rabin Vincent 2012-02-18   70  	if (thumb2 && __opcode_is_thumb16(insn)) {
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   71  		*(u16 *)waddr = __opcode_to_mem_thumb16(insn);
> b21d55e98ac2bb Rabin Vincent 2012-02-18   72  		size = sizeof(u16);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   73  	} else if (thumb2 && (uintaddr & 2)) {
> b21d55e98ac2bb Rabin Vincent 2012-02-18   74  		u16 first = __opcode_thumb32_first(insn);
> b21d55e98ac2bb Rabin Vincent 2012-02-18   75  		u16 second = __opcode_thumb32_second(insn);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   76  		u16 *addrh0 = waddr;
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   77  		u16 *addrh1 = waddr + 2;
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   78  
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   79  		twopage = (uintaddr & ~PAGE_MASK) == PAGE_SIZE - 2;
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   80  		if (twopage && remap)
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   81  			addrh1 = patch_map(addr + 2, FIX_TEXT_POKE1, NULL);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   82  
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   83  		*addrh0 = __opcode_to_mem_thumb16(first);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   84  		*addrh1 = __opcode_to_mem_thumb16(second);
> b21d55e98ac2bb Rabin Vincent 2012-02-18   85  
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   86  		if (twopage && addrh1 != addr + 2) {
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   87  			flush_kernel_vmap_range(addrh1, 2);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   88  			patch_unmap(FIX_TEXT_POKE1, NULL);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   89  		}
> b21d55e98ac2bb Rabin Vincent 2012-02-18   90  
> b21d55e98ac2bb Rabin Vincent 2012-02-18   91  		size = sizeof(u32);
> b21d55e98ac2bb Rabin Vincent 2012-02-18   92  	} else {
> b21d55e98ac2bb Rabin Vincent 2012-02-18   93  		if (thumb2)
> b21d55e98ac2bb Rabin Vincent 2012-02-18  @94  			insn = __opcode_to_mem_thumb32(insn);
> b21d55e98ac2bb Rabin Vincent 2012-02-18   95  		else
> b21d55e98ac2bb Rabin Vincent 2012-02-18   96  			insn = __opcode_to_mem_arm(insn);
> b21d55e98ac2bb Rabin Vincent 2012-02-18   97  
> ab0615e2d6fb07 Rabin Vincent 2014-04-24   98  		*(u32 *)waddr = insn;
> b21d55e98ac2bb Rabin Vincent 2012-02-18   99  		size = sizeof(u32);
> b21d55e98ac2bb Rabin Vincent 2012-02-18  100  	}
> b21d55e98ac2bb Rabin Vincent 2012-02-18  101  
> ab0615e2d6fb07 Rabin Vincent 2014-04-24  102  	if (waddr != addr) {
> ab0615e2d6fb07 Rabin Vincent 2014-04-24  103  		flush_kernel_vmap_range(waddr, twopage ? size / 2 : size);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24  104  		patch_unmap(FIX_TEXT_POKE0, &flags);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24  105  	} else
> ab0615e2d6fb07 Rabin Vincent 2014-04-24  106  		__release(&patch_lock);
> ab0615e2d6fb07 Rabin Vincent 2014-04-24  107  
> b21d55e98ac2bb Rabin Vincent 2012-02-18  108  	flush_icache_range((uintptr_t)(addr),
> b21d55e98ac2bb Rabin Vincent 2012-02-18  109  			   (uintptr_t)(addr) + size);
> b21d55e98ac2bb Rabin Vincent 2012-02-18  110  }
> b21d55e98ac2bb Rabin Vincent 2012-02-18  111  
> 
> :::::: The code at line 94 was first introduced by commit
> :::::: b21d55e98ac2bbcbbeec9a8cb091f717fd95b072 ARM: 7332/1: extract out code patch function from kprobes
> 
> :::::: TO: Rabin Vincent <rabin@rab.in>
> :::::: CC: Russell King <rmk+kernel@arm.linux.org.uk>


This comes down to:

CONFIG_ARM_THUMB=y
CONFIG_CPU_BIG_ENDIAN=y
CONFIG_CPU_ENDIAN_BE32=y

and <asm/opcodes.h>, where arch/arm/asm/opcodes.h says:

/*
 * On BE32 systems, using 32-bit accesses to store Thumb instructions will not
 * work in all cases, due to alignment constraints.  For now, a correct
 * version is not provided for BE32.
 */

Should we try to find a way to prevent this combination from happening?


-- 
~Randy

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-22  3:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-20 19:08 arch/arm/kernel/patch.c:94:11: error: implicit declaration of function '__opcode_to_mem_thumb32' kernel test robot
2021-02-20 19:08 ` kernel test robot
2021-02-22  3:25 ` Randy Dunlap
2021-02-22  3:25   ` Randy Dunlap

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.