* [PATCH] csky: fix csky_cmpxchg_fixup not working @ 2024-10-08 5:46 Yang Li 2024-10-16 2:10 ` kernel test robot 2024-10-16 9:56 ` [PATCH v2] " Yang Li 0 siblings, 2 replies; 7+ messages in thread From: Yang Li @ 2024-10-08 5:46 UTC (permalink / raw) To: guoren; +Cc: linux-csky, linux-kernel, Yang Li In the csky_cmpxchg_fixup function, using the global variable csky_cmpxchg_stw to determine the address where the exception occurred is incorrect. The global variable csky_cmpxchg_stw stores the opcode at the time of the exception, while &csky_cmpxchg_stw is the address where the exception occurred. Signed-off-by: Yang Li <yang.li85200@gmail.com> --- arch/csky/mm/fault.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c index a885518ce1dd..87ff26212261 100644 --- a/arch/csky/mm/fault.c +++ b/arch/csky/mm/fault.c @@ -45,8 +45,8 @@ static inline void csky_cmpxchg_fixup(struct pt_regs *regs) if (trap_no(regs) != VEC_TLBMODIFIED) return; - if (instruction_pointer(regs) == csky_cmpxchg_stw) - instruction_pointer_set(regs, csky_cmpxchg_ldw); + if (instruction_pointer(regs) == &csky_cmpxchg_stw) + instruction_pointer_set(regs, &csky_cmpxchg_ldw); return; } #endif -- 2.34.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] csky: fix csky_cmpxchg_fixup not working 2024-10-08 5:46 [PATCH] csky: fix csky_cmpxchg_fixup not working Yang Li @ 2024-10-16 2:10 ` kernel test robot 2024-10-16 9:56 ` [PATCH v2] " Yang Li 1 sibling, 0 replies; 7+ messages in thread From: kernel test robot @ 2024-10-16 2:10 UTC (permalink / raw) To: Yang Li, guoren; +Cc: oe-kbuild-all, linux-csky, linux-kernel, Yang Li Hi Yang, kernel test robot noticed the following build errors: [auto build test ERROR on linus/master] [also build test ERROR on v6.12-rc3 next-20241015] [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#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Yang-Li/csky-fix-csky_cmpxchg_fixup-not-working/20241008-134806 base: linus/master patch link: https://lore.kernel.org/r/20241008054615.43062-1-yang.li85200%40gmail.com patch subject: [PATCH] csky: fix csky_cmpxchg_fixup not working config: csky-allnoconfig (https://download.01.org/0day-ci/archive/20241016/202410160952.7oClZ4pG-lkp@intel.com/config) compiler: csky-linux-gcc (GCC) 14.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241016/202410160952.7oClZ4pG-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202410160952.7oClZ4pG-lkp@intel.com/ All error/warnings (new ones prefixed by >>): arch/csky/mm/fault.c: In function 'csky_cmpxchg_fixup': >> arch/csky/mm/fault.c:48:39: warning: comparison between pointer and integer 48 | if (instruction_pointer(regs) == &csky_cmpxchg_stw) | ^~ >> arch/csky/mm/fault.c:49:47: error: passing argument 2 of 'instruction_pointer_set' makes integer from pointer without a cast [-Wint-conversion] 49 | instruction_pointer_set(regs, &csky_cmpxchg_ldw); | ^~~~~~~~~~~~~~~~~ | | | long unsigned int * In file included from arch/csky/include/asm/processor.h:8, from arch/csky/include/asm/thread_info.h:10, from include/linux/thread_info.h:60, from include/asm-generic/current.h:6, from ./arch/csky/include/generated/asm/current.h:1, from include/linux/mutex.h:14, from include/linux/notifier.h:14, from include/linux/kprobes.h:21, from arch/csky/mm/fault.c:5: arch/csky/include/asm/ptrace.h:29:58: note: expected 'long unsigned int' but argument is of type 'long unsigned int *' 29 | unsigned long val) | ~~~~~~~~~~~~~~^~~ vim +/instruction_pointer_set +49 arch/csky/mm/fault.c 34 35 #ifdef CONFIG_CPU_HAS_LDSTEX 36 static inline void csky_cmpxchg_fixup(struct pt_regs *regs) 37 { 38 return; 39 } 40 #else 41 extern unsigned long csky_cmpxchg_ldw; 42 extern unsigned long csky_cmpxchg_stw; 43 static inline void csky_cmpxchg_fixup(struct pt_regs *regs) 44 { 45 if (trap_no(regs) != VEC_TLBMODIFIED) 46 return; 47 > 48 if (instruction_pointer(regs) == &csky_cmpxchg_stw) > 49 instruction_pointer_set(regs, &csky_cmpxchg_ldw); 50 return; 51 } 52 #endif 53 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] csky: fix csky_cmpxchg_fixup not working 2024-10-08 5:46 [PATCH] csky: fix csky_cmpxchg_fixup not working Yang Li 2024-10-16 2:10 ` kernel test robot @ 2024-10-16 9:56 ` Yang Li 2024-10-17 6:04 ` Guo Ren 1 sibling, 1 reply; 7+ messages in thread From: Yang Li @ 2024-10-16 9:56 UTC (permalink / raw) To: yang.li85200; +Cc: guoren, linux-csky, linux-kernel In the csky_cmpxchg_fixup function, it is incorrect to use the global variable csky_cmpxchg_stw to determine the address where the exception occurred.The global variable csky_cmpxchg_stw stores the opcode at the time of the exception, while &csky_cmpxchg_stw shows the address where the exception occurred. Signed-off-by: Yang Li <yang.li85200@gmail.com> --- V1 -> V2:Eliminate compilation warnings arch/csky/mm/fault.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c index a885518ce1dd..5226bc08c336 100644 --- a/arch/csky/mm/fault.c +++ b/arch/csky/mm/fault.c @@ -45,8 +45,8 @@ static inline void csky_cmpxchg_fixup(struct pt_regs *regs) if (trap_no(regs) != VEC_TLBMODIFIED) return; - if (instruction_pointer(regs) == csky_cmpxchg_stw) - instruction_pointer_set(regs, csky_cmpxchg_ldw); + if (instruction_pointer(regs) == (unsigned long)&csky_cmpxchg_stw) + instruction_pointer_set(regs, (unsigned long)&csky_cmpxchg_ldw); return; } #endif -- 2.34.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] csky: fix csky_cmpxchg_fixup not working 2024-10-16 9:56 ` [PATCH v2] " Yang Li @ 2024-10-17 6:04 ` Guo Ren [not found] ` <CA+N+=zu0=scmv9w7iZE2ZebxBVpvVb1eeoJ-qi=vhac-JhLthg@mail.gmail.com> 2024-10-21 7:51 ` yang li 0 siblings, 2 replies; 7+ messages in thread From: Guo Ren @ 2024-10-17 6:04 UTC (permalink / raw) To: Yang Li; +Cc: linux-csky, linux-kernel On Wed, Oct 16, 2024 at 5:56 PM Yang Li <yang.li85200@gmail.com> wrote: > > In the csky_cmpxchg_fixup function, it is incorrect to use the global > variable csky_cmpxchg_stw to determine the address where the exception > occurred.The global variable csky_cmpxchg_stw stores the opcode at the > time of the exception, while &csky_cmpxchg_stw shows the address where > the exception occurred. > > Signed-off-by: Yang Li <yang.li85200@gmail.com> > --- > V1 -> V2:Eliminate compilation warnings > > arch/csky/mm/fault.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c > index a885518ce1dd..5226bc08c336 100644 > --- a/arch/csky/mm/fault.c > +++ b/arch/csky/mm/fault.c > @@ -45,8 +45,8 @@ static inline void csky_cmpxchg_fixup(struct pt_regs *regs) > if (trap_no(regs) != VEC_TLBMODIFIED) > return; > > - if (instruction_pointer(regs) == csky_cmpxchg_stw) > - instruction_pointer_set(regs, csky_cmpxchg_ldw); > + if (instruction_pointer(regs) == (unsigned long)&csky_cmpxchg_stw) > + instruction_pointer_set(regs, (unsigned long)&csky_cmpxchg_ldw); csky_cmpxchg_ldw(stw) is a label symbol, not a variable. arch/csky/kernel/atomic.S: GLOBAL(csky_cmpxchg_ldw) GLOBAL(csky_cmpxchg_stw) Your modification does not affect the ASM output. (gdb) p main $1 = {void (void)} 0x5fa <main> (gdb) p &main $2 = (void (*)(void)) 0x5fa <main> > return; > } > #endif > -- > 2.34.1 > -- Best Regards Guo Ren ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <CA+N+=zu0=scmv9w7iZE2ZebxBVpvVb1eeoJ-qi=vhac-JhLthg@mail.gmail.com>]
* Re: [PATCH v2] csky: fix csky_cmpxchg_fixup not working [not found] ` <CA+N+=zu0=scmv9w7iZE2ZebxBVpvVb1eeoJ-qi=vhac-JhLthg@mail.gmail.com> @ 2024-10-18 8:46 ` yang li 0 siblings, 0 replies; 7+ messages in thread From: yang li @ 2024-10-18 8:46 UTC (permalink / raw) To: Guo Ren; +Cc: linux-csky, linux-kernel Hi Guo Ren: I used the readelf tool to view the address of csky_cmpxchg_ldw, and used printk("0x%x\n",csky_cmpxchg_ldw) and printk("0x%x\n",&csky_cmpxchg_ldw) to print it out in the code. The result is that printk("0x%x\n",&csky_cmpxchg_ldw) prints the correct result. include/linux/linkage.h #define GLOBAL(name) \ .globl name ASM_NL \ name: #endif arch/csky/kernel/atomic.S: GLOBAL(csky_cmpxchg_ldw) so .globl csky_cmpxchg_ldw --->globl symbol csky_cmpxchg_ldw: --->label symbol yang li <yang.li85200@gmail.com> 于2024年10月18日周五 16:33写道: > > Hi Guo Ren: > I used the readelf tool to view the address of csky_cmpxchg_ldw, > and used printk("0x%x\n",csky_cmpxchg_ldw) and > printk("0x%x\n",&csky_cmpxchg_ldw) to print it out in the code. > The result is that printk("0x%x\n",&csky_cmpxchg_ldw) prints the > correct result. > > include/linux/linkage.h > #define GLOBAL(name) \ > .globl name ASM_NL \ > name: > #endif > > arch/csky/kernel/atomic.S: > GLOBAL(csky_cmpxchg_ldw) > so > .globl csky_cmpxchg_ldw --->globl symbol > csky_cmpxchg_ldw: --->label symbol > > > > > Guo Ren <guoren@kernel.org> 于2024年10月17日周四 14:05写道: >> >> On Wed, Oct 16, 2024 at 5:56 PM Yang Li <yang.li85200@gmail.com> wrote: >> > >> > In the csky_cmpxchg_fixup function, it is incorrect to use the global >> > variable csky_cmpxchg_stw to determine the address where the exception >> > occurred.The global variable csky_cmpxchg_stw stores the opcode at the >> > time of the exception, while &csky_cmpxchg_stw shows the address where >> > the exception occurred. >> > >> > Signed-off-by: Yang Li <yang.li85200@gmail.com> >> > --- >> > V1 -> V2:Eliminate compilation warnings >> > >> > arch/csky/mm/fault.c | 4 ++-- >> > 1 file changed, 2 insertions(+), 2 deletions(-) >> > >> > diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c >> > index a885518ce1dd..5226bc08c336 100644 >> > --- a/arch/csky/mm/fault.c >> > +++ b/arch/csky/mm/fault.c >> > @@ -45,8 +45,8 @@ static inline void csky_cmpxchg_fixup(struct pt_regs *regs) >> > if (trap_no(regs) != VEC_TLBMODIFIED) >> > return; >> > >> > - if (instruction_pointer(regs) == csky_cmpxchg_stw) >> > - instruction_pointer_set(regs, csky_cmpxchg_ldw); >> > + if (instruction_pointer(regs) == (unsigned long)&csky_cmpxchg_stw) >> > + instruction_pointer_set(regs, (unsigned long)&csky_cmpxchg_ldw); >> csky_cmpxchg_ldw(stw) is a label symbol, not a variable. >> >> arch/csky/kernel/atomic.S: >> GLOBAL(csky_cmpxchg_ldw) >> GLOBAL(csky_cmpxchg_stw) >> >> Your modification does not affect the ASM output. >> >> (gdb) p main >> $1 = {void (void)} 0x5fa <main> >> (gdb) p &main >> $2 = (void (*)(void)) 0x5fa <main> >> >> > return; >> > } >> > #endif >> > -- >> > 2.34.1 >> > >> >> >> -- >> Best Regards >> Guo Ren ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] csky: fix csky_cmpxchg_fixup not working 2024-10-17 6:04 ` Guo Ren [not found] ` <CA+N+=zu0=scmv9w7iZE2ZebxBVpvVb1eeoJ-qi=vhac-JhLthg@mail.gmail.com> @ 2024-10-21 7:51 ` yang li 2024-10-28 2:54 ` Guo Ren 1 sibling, 1 reply; 7+ messages in thread From: yang li @ 2024-10-21 7:51 UTC (permalink / raw) To: Guo Ren; +Cc: linux-csky, linux-kernel Hi Guo Ren: In C language, your conclusion is correct, but in assembly language, global_symbol != &global_symbol I did the following experiment: liyang@liyang-virtual-machine:~/Desktop/test$ ls main.c test.s liyang@liyang-virtual-machine:~/Desktop/test$ cat test.s .globl test_symbol test_symbol: nop liyang@liyang-virtual-machine:~/Desktop/test$ cat main.c #include <stdio.h> extern unsigned long test_symbol; int main(void) { printf("test_symbol = 0x%lx\n",(unsigned long)test_symbol); printf("&test_symbol = 0x%lx\n",(unsigned long)&test_symbol); printf("main = 0x%lx\n",(unsigned long)main); printf("&main = 0x%lx\n",(unsigned long)&main); } liyang@liyang-virtual-machine:~/Desktop/test$ gcc main.c test.s --static -o test liyang@liyang-virtual-machine:~/Desktop/test$ ls main.c test test.s liyang@liyang-virtual-machine:~/Desktop/test$ readelf test -s | grep test_symbol 884: 000000000040170c 0 NOTYPE GLOBAL DEFAULT 7 test_symbol liyang@liyang-virtual-machine:~/Desktop/test$ readelf test -s | grep main -w 1605: 0000000000401685 135 FUNC GLOBAL DEFAULT 7 main liyang@liyang-virtual-machine:~/Desktop/test$ ./test test_symbol = 0x4b853001f0f90 &test_symbol = 0x40170c main = 0x401685 &main = 0x401685 The above test can lead to the conclusion that: Both c_symbol and &c_symbol represent the address of a symbol, but &ASM_symbol represents the address of a symbol while ASM_symbol represents the opcode stored at that address. On Thu, Oct 17, 2024 at 2:05 PM Guo Ren <guoren@kernel.org> wrote: > > On Wed, Oct 16, 2024 at 5:56 PM Yang Li <yang.li85200@gmail.com> wrote: > > > > In the csky_cmpxchg_fixup function, it is incorrect to use the global > > variable csky_cmpxchg_stw to determine the address where the exception > > occurred.The global variable csky_cmpxchg_stw stores the opcode at the > > time of the exception, while &csky_cmpxchg_stw shows the address where > > the exception occurred. > > > > Signed-off-by: Yang Li <yang.li85200@gmail.com> > > --- > > V1 -> V2:Eliminate compilation warnings > > > > arch/csky/mm/fault.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c > > index a885518ce1dd..5226bc08c336 100644 > > --- a/arch/csky/mm/fault.c > > +++ b/arch/csky/mm/fault.c > > @@ -45,8 +45,8 @@ static inline void csky_cmpxchg_fixup(struct pt_regs *regs) > > if (trap_no(regs) != VEC_TLBMODIFIED) > > return; > > > > - if (instruction_pointer(regs) == csky_cmpxchg_stw) > > - instruction_pointer_set(regs, csky_cmpxchg_ldw); > > + if (instruction_pointer(regs) == (unsigned long)&csky_cmpxchg_stw) > > + instruction_pointer_set(regs, (unsigned long)&csky_cmpxchg_ldw); > csky_cmpxchg_ldw(stw) is a label symbol, not a variable. > > arch/csky/kernel/atomic.S: > GLOBAL(csky_cmpxchg_ldw) > GLOBAL(csky_cmpxchg_stw) > > Your modification does not affect the ASM output. > > (gdb) p main > $1 = {void (void)} 0x5fa <main> > (gdb) p &main > $2 = (void (*)(void)) 0x5fa <main> > > > return; > > } > > #endif > > -- > > 2.34.1 > > > > > -- > Best Regards > Guo Ren ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] csky: fix csky_cmpxchg_fixup not working 2024-10-21 7:51 ` yang li @ 2024-10-28 2:54 ` Guo Ren 0 siblings, 0 replies; 7+ messages in thread From: Guo Ren @ 2024-10-28 2:54 UTC (permalink / raw) To: yang li; +Cc: linux-csky, linux-kernel Hi yang, On Mon, Oct 21, 2024 at 3:51 PM yang li <yang.li85200@gmail.com> wrote: > > Hi Guo Ren: > In C language, your conclusion is correct, but in assembly language, > global_symbol != &global_symbol > I did the following experiment: > > liyang@liyang-virtual-machine:~/Desktop/test$ ls > main.c test.s > liyang@liyang-virtual-machine:~/Desktop/test$ cat test.s > > .globl test_symbol > test_symbol: > nop > liyang@liyang-virtual-machine:~/Desktop/test$ cat main.c > #include <stdio.h> > > extern unsigned long test_symbol; > int main(void) > { > printf("test_symbol = 0x%lx\n",(unsigned long)test_symbol); > printf("&test_symbol = 0x%lx\n",(unsigned long)&test_symbol); > > printf("main = 0x%lx\n",(unsigned long)main); > printf("&main = 0x%lx\n",(unsigned long)&main); > } > liyang@liyang-virtual-machine:~/Desktop/test$ gcc main.c test.s --static -o test > liyang@liyang-virtual-machine:~/Desktop/test$ ls > main.c test test.s > liyang@liyang-virtual-machine:~/Desktop/test$ readelf test -s | grep test_symbol > 884: 000000000040170c 0 NOTYPE GLOBAL DEFAULT 7 test_symbol > liyang@liyang-virtual-machine:~/Desktop/test$ readelf test -s | grep main -w > 1605: 0000000000401685 135 FUNC GLOBAL DEFAULT 7 main > liyang@liyang-virtual-machine:~/Desktop/test$ ./test > test_symbol = 0x4b853001f0f90 > &test_symbol = 0x40170c > main = 0x401685 > &main = 0x401685 > > The above test can lead to the conclusion that: > Both c_symbol and &c_symbol represent the address of a symbol, but > &ASM_symbol represents the address of a symbol while ASM_symbol > represents the opcode stored at that address. > > On Thu, Oct 17, 2024 at 2:05 PM Guo Ren <guoren@kernel.org> wrote: > > > > On Wed, Oct 16, 2024 at 5:56 PM Yang Li <yang.li85200@gmail.com> wrote: > > > > > > In the csky_cmpxchg_fixup function, it is incorrect to use the global > > > variable csky_cmpxchg_stw to determine the address where the exception > > > occurred.The global variable csky_cmpxchg_stw stores the opcode at the > > > time of the exception, while &csky_cmpxchg_stw shows the address where > > > the exception occurred. > > > > > > Signed-off-by: Yang Li <yang.li85200@gmail.com> You convinced me. Applied to csky/linux-next, thanks! > > > --- > > > V1 -> V2:Eliminate compilation warnings > > > > > > arch/csky/mm/fault.c | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c > > > index a885518ce1dd..5226bc08c336 100644 > > > --- a/arch/csky/mm/fault.c > > > +++ b/arch/csky/mm/fault.c > > > @@ -45,8 +45,8 @@ static inline void csky_cmpxchg_fixup(struct pt_regs *regs) > > > if (trap_no(regs) != VEC_TLBMODIFIED) > > > return; > > > > > > - if (instruction_pointer(regs) == csky_cmpxchg_stw) > > > - instruction_pointer_set(regs, csky_cmpxchg_ldw); > > > + if (instruction_pointer(regs) == (unsigned long)&csky_cmpxchg_stw) > > > + instruction_pointer_set(regs, (unsigned long)&csky_cmpxchg_ldw); > > csky_cmpxchg_ldw(stw) is a label symbol, not a variable. > > > > arch/csky/kernel/atomic.S: > > GLOBAL(csky_cmpxchg_ldw) > > GLOBAL(csky_cmpxchg_stw) > > > > Your modification does not affect the ASM output. > > > > (gdb) p main > > $1 = {void (void)} 0x5fa <main> > > (gdb) p &main > > $2 = (void (*)(void)) 0x5fa <main> > > > > > return; > > > } > > > #endif > > > -- > > > 2.34.1 > > > > > > > > > -- > > Best Regards > > Guo Ren -- Best Regards Guo Ren ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-10-28 2:54 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08 5:46 [PATCH] csky: fix csky_cmpxchg_fixup not working Yang Li
2024-10-16 2:10 ` kernel test robot
2024-10-16 9:56 ` [PATCH v2] " Yang Li
2024-10-17 6:04 ` Guo Ren
[not found] ` <CA+N+=zu0=scmv9w7iZE2ZebxBVpvVb1eeoJ-qi=vhac-JhLthg@mail.gmail.com>
2024-10-18 8:46 ` yang li
2024-10-21 7:51 ` yang li
2024-10-28 2:54 ` Guo Ren
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox