Linux-csky Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH V2] riscv: Fixup compile error BUILD_BUG_ON failed
@ 2020-06-28 16:07 guoren
  2020-06-28 16:25 ` Masami Hiramatsu
  0 siblings, 1 reply; 4+ messages in thread
From: guoren @ 2020-06-28 16:07 UTC (permalink / raw)
  To: greentime.hu, mhiramat, guoren
  Cc: palmerdabbelt, linux-riscv, linux-kernel, paul.walmsley, anup,
	linux-csky, zong.li, Guo Ren

From: Guo Ren <guoren@linux.alibaba.com>

Unfortunately, the current code couldn't be compiled:

  CC      arch/riscv/kernel/patch.o
In file included from ./include/linux/kernel.h:11,
                 from ./include/linux/list.h:9,
                 from ./include/linux/preempt.h:11,
                 from ./include/linux/spinlock.h:51,
                 from arch/riscv/kernel/patch.c:6:
In function ‘fix_to_virt’,
    inlined from ‘patch_map’ at arch/riscv/kernel/patch.c:37:17:
./include/linux/compiler.h:392:38: error: call to ‘__compiletime_assert_205’ declared with attribute error: BUILD_BUG_ON failed: idx >= __end_of_fixed_addresses
  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
                                      ^
./include/linux/compiler.h:373:4: note: in definition of macro ‘__compiletime_assert’
    prefix ## suffix();    \
    ^~~~~~
./include/linux/compiler.h:392:2: note: in expansion of macro ‘_compiletime_assert’
  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
  ^~~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’
 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                     ^~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
  ^~~~~~~~~~~~~~~~
./include/asm-generic/fixmap.h:32:2: note: in expansion of macro ‘BUILD_BUG_ON’
  BUILD_BUG_ON(idx >= __end_of_fixed_addresses);
  ^~~~~~~~~~~~

Because fix_to_virt(, idx) needs a const value, not a dynamic variable of
reg-a0 or BUILD_BUG_ON failed with "idx >= __end_of_fixed_addresses".

Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Zong Li <zong.li@sifive.com>
---
Changelog V2:
 - Use __always_inline as same as fix_to_virt
 - Use const "const unsigned int" for 2th param

Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
---
 arch/riscv/kernel/patch.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c
index d4a64df..3179a4e 100644
--- a/arch/riscv/kernel/patch.c
+++ b/arch/riscv/kernel/patch.c
@@ -20,7 +20,12 @@ struct patch_insn {
 };
 
 #ifdef CONFIG_MMU
-static void *patch_map(void *addr, int fixmap)
+/*
+ * The fix_to_virt(, idx) needs a const value (not a dynamic variable of
+ * reg-a0) or BUILD_BUG_ON failed with "idx >= __end_of_fixed_addresses".
+ * So use '__always_inline' and 'const unsigned int fixmap' here.
+ */
+static __always_inline void *patch_map(void *addr, const unsigned int fixmap)
 {
 	uintptr_t uintaddr = (uintptr_t) addr;
 	struct page *page;
@@ -37,7 +42,6 @@ static void *patch_map(void *addr, int fixmap)
 	return (void *)set_fixmap_offset(fixmap, page_to_phys(page) +
 					 (uintaddr & ~PAGE_MASK));
 }
-NOKPROBE_SYMBOL(patch_map);
 
 static void patch_unmap(int fixmap)
 {
-- 
2.7.4


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

* Re: [PATCH V2] riscv: Fixup compile error BUILD_BUG_ON failed
  2020-06-28 16:07 [PATCH V2] riscv: Fixup compile error BUILD_BUG_ON failed guoren
@ 2020-06-28 16:25 ` Masami Hiramatsu
  2020-06-29 23:22   ` Palmer Dabbelt
  0 siblings, 1 reply; 4+ messages in thread
From: Masami Hiramatsu @ 2020-06-28 16:25 UTC (permalink / raw)
  To: guoren
  Cc: greentime.hu, palmerdabbelt, linux-riscv, linux-kernel,
	paul.walmsley, anup, linux-csky, zong.li, Guo Ren

On Sun, 28 Jun 2020 16:07:37 +0000
guoren@kernel.org wrote:

> From: Guo Ren <guoren@linux.alibaba.com>
> 
> Unfortunately, the current code couldn't be compiled:
> 
>   CC      arch/riscv/kernel/patch.o
> In file included from ./include/linux/kernel.h:11,
>                  from ./include/linux/list.h:9,
>                  from ./include/linux/preempt.h:11,
>                  from ./include/linux/spinlock.h:51,
>                  from arch/riscv/kernel/patch.c:6:
> In function ‘fix_to_virt’,
>     inlined from ‘patch_map’ at arch/riscv/kernel/patch.c:37:17:
> ./include/linux/compiler.h:392:38: error: call to ‘__compiletime_assert_205’ declared with attribute error: BUILD_BUG_ON failed: idx >= __end_of_fixed_addresses
>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>                                       ^
> ./include/linux/compiler.h:373:4: note: in definition of macro ‘__compiletime_assert’
>     prefix ## suffix();    \
>     ^~~~~~
> ./include/linux/compiler.h:392:2: note: in expansion of macro ‘_compiletime_assert’
>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>   ^~~~~~~~~~~~~~~~~~~
> ./include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’
>  #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>                                      ^~~~~~~~~~~~~~~~~~
> ./include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
>   BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
>   ^~~~~~~~~~~~~~~~
> ./include/asm-generic/fixmap.h:32:2: note: in expansion of macro ‘BUILD_BUG_ON’
>   BUILD_BUG_ON(idx >= __end_of_fixed_addresses);
>   ^~~~~~~~~~~~
> 
> Because fix_to_virt(, idx) needs a const value, not a dynamic variable of
> reg-a0 or BUILD_BUG_ON failed with "idx >= __end_of_fixed_addresses".

Looks good to me :)

Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>

Thanks!

> 
> Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Cc: Zong Li <zong.li@sifive.com>
> ---
> Changelog V2:
>  - Use __always_inline as same as fix_to_virt
>  - Use const "const unsigned int" for 2th param
> 
> Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
> ---
>  arch/riscv/kernel/patch.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c
> index d4a64df..3179a4e 100644
> --- a/arch/riscv/kernel/patch.c
> +++ b/arch/riscv/kernel/patch.c
> @@ -20,7 +20,12 @@ struct patch_insn {
>  };
>  
>  #ifdef CONFIG_MMU
> -static void *patch_map(void *addr, int fixmap)
> +/*
> + * The fix_to_virt(, idx) needs a const value (not a dynamic variable of
> + * reg-a0) or BUILD_BUG_ON failed with "idx >= __end_of_fixed_addresses".
> + * So use '__always_inline' and 'const unsigned int fixmap' here.
> + */
> +static __always_inline void *patch_map(void *addr, const unsigned int fixmap)
>  {
>  	uintptr_t uintaddr = (uintptr_t) addr;
>  	struct page *page;
> @@ -37,7 +42,6 @@ static void *patch_map(void *addr, int fixmap)
>  	return (void *)set_fixmap_offset(fixmap, page_to_phys(page) +
>  					 (uintaddr & ~PAGE_MASK));
>  }
> -NOKPROBE_SYMBOL(patch_map);
>  
>  static void patch_unmap(int fixmap)
>  {
> -- 
> 2.7.4
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

* Re: [PATCH V2] riscv: Fixup compile error BUILD_BUG_ON failed
  2020-06-28 16:25 ` Masami Hiramatsu
@ 2020-06-29 23:22   ` Palmer Dabbelt
  2020-06-30  0:12     ` Guo Ren
  0 siblings, 1 reply; 4+ messages in thread
From: Palmer Dabbelt @ 2020-06-29 23:22 UTC (permalink / raw)
  To: mhiramat
  Cc: guoren, greentime.hu, linux-riscv, linux-kernel, Paul Walmsley,
	anup, linux-csky, zong.li, guoren

On Sun, 28 Jun 2020 09:25:24 PDT (-0700), mhiramat@kernel.org wrote:
> On Sun, 28 Jun 2020 16:07:37 +0000
> guoren@kernel.org wrote:
>
>> From: Guo Ren <guoren@linux.alibaba.com>
>>
>> Unfortunately, the current code couldn't be compiled:
>>
>>   CC      arch/riscv/kernel/patch.o
>> In file included from ./include/linux/kernel.h:11,
>>                  from ./include/linux/list.h:9,
>>                  from ./include/linux/preempt.h:11,
>>                  from ./include/linux/spinlock.h:51,
>>                  from arch/riscv/kernel/patch.c:6:
>> In function ‘fix_to_virt’,
>>     inlined from ‘patch_map’ at arch/riscv/kernel/patch.c:37:17:
>> ./include/linux/compiler.h:392:38: error: call to ‘__compiletime_assert_205’ declared with attribute error: BUILD_BUG_ON failed: idx >= __end_of_fixed_addresses
>>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>                                       ^
>> ./include/linux/compiler.h:373:4: note: in definition of macro ‘__compiletime_assert’
>>     prefix ## suffix();    \
>>     ^~~~~~
>> ./include/linux/compiler.h:392:2: note: in expansion of macro ‘_compiletime_assert’
>>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>   ^~~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’
>>  #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>>                                      ^~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
>>   BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
>>   ^~~~~~~~~~~~~~~~
>> ./include/asm-generic/fixmap.h:32:2: note: in expansion of macro ‘BUILD_BUG_ON’
>>   BUILD_BUG_ON(idx >= __end_of_fixed_addresses);
>>   ^~~~~~~~~~~~
>>
>> Because fix_to_virt(, idx) needs a const value, not a dynamic variable of
>> reg-a0 or BUILD_BUG_ON failed with "idx >= __end_of_fixed_addresses".
>
> Looks good to me :)
>
> Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>

Is there a configuration that runs into this bug?  It's not showing up for me,
and I generally try to add regressions to my test suite.

> Thanks!
>
>>
>> Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
>> Cc: Masami Hiramatsu <mhiramat@kernel.org>
>> Cc: Zong Li <zong.li@sifive.com>
>> ---
>> Changelog V2:
>>  - Use __always_inline as same as fix_to_virt
>>  - Use const "const unsigned int" for 2th param
>>
>> Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
>> ---
>>  arch/riscv/kernel/patch.c | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c
>> index d4a64df..3179a4e 100644
>> --- a/arch/riscv/kernel/patch.c
>> +++ b/arch/riscv/kernel/patch.c
>> @@ -20,7 +20,12 @@ struct patch_insn {
>>  };
>>
>>  #ifdef CONFIG_MMU
>> -static void *patch_map(void *addr, int fixmap)
>> +/*
>> + * The fix_to_virt(, idx) needs a const value (not a dynamic variable of
>> + * reg-a0) or BUILD_BUG_ON failed with "idx >= __end_of_fixed_addresses".
>> + * So use '__always_inline' and 'const unsigned int fixmap' here.
>> + */
>> +static __always_inline void *patch_map(void *addr, const unsigned int fixmap)
>>  {
>>  	uintptr_t uintaddr = (uintptr_t) addr;
>>  	struct page *page;
>> @@ -37,7 +42,6 @@ static void *patch_map(void *addr, int fixmap)
>>  	return (void *)set_fixmap_offset(fixmap, page_to_phys(page) +
>>  					 (uintaddr & ~PAGE_MASK));
>>  }
>> -NOKPROBE_SYMBOL(patch_map);
>>
>>  static void patch_unmap(int fixmap)
>>  {
>> --
>> 2.7.4
>>

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

* Re: [PATCH V2] riscv: Fixup compile error BUILD_BUG_ON failed
  2020-06-29 23:22   ` Palmer Dabbelt
@ 2020-06-30  0:12     ` Guo Ren
  0 siblings, 0 replies; 4+ messages in thread
From: Guo Ren @ 2020-06-30  0:12 UTC (permalink / raw)
  To: Palmer Dabbelt
  Cc: Masami Hiramatsu, Greentime Hu, linux-riscv,
	Linux Kernel Mailing List, Paul Walmsley, Anup Patel, linux-csky,
	Zong Li, Guo Ren

Hi Palmer,

On Tue, Jun 30, 2020 at 7:22 AM Palmer Dabbelt <palmerdabbelt@google.com> wrote:
>
> On Sun, 28 Jun 2020 09:25:24 PDT (-0700), mhiramat@kernel.org wrote:
> > On Sun, 28 Jun 2020 16:07:37 +0000
> > guoren@kernel.org wrote:
> >
> >> From: Guo Ren <guoren@linux.alibaba.com>
> >>
> >> Unfortunately, the current code couldn't be compiled:
> >>
> >>   CC      arch/riscv/kernel/patch.o
> >> In file included from ./include/linux/kernel.h:11,
> >>                  from ./include/linux/list.h:9,
> >>                  from ./include/linux/preempt.h:11,
> >>                  from ./include/linux/spinlock.h:51,
> >>                  from arch/riscv/kernel/patch.c:6:
> >> In function ‘fix_to_virt’,
> >>     inlined from ‘patch_map’ at arch/riscv/kernel/patch.c:37:17:
> >> ./include/linux/compiler.h:392:38: error: call to ‘__compiletime_assert_205’ declared with attribute error: BUILD_BUG_ON failed: idx >= __end_of_fixed_addresses
> >>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
> >>                                       ^
> >> ./include/linux/compiler.h:373:4: note: in definition of macro ‘__compiletime_assert’
> >>     prefix ## suffix();    \
> >>     ^~~~~~
> >> ./include/linux/compiler.h:392:2: note: in expansion of macro ‘_compiletime_assert’
> >>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
> >>   ^~~~~~~~~~~~~~~~~~~
> >> ./include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’
> >>  #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
> >>                                      ^~~~~~~~~~~~~~~~~~
> >> ./include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
> >>   BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
> >>   ^~~~~~~~~~~~~~~~
> >> ./include/asm-generic/fixmap.h:32:2: note: in expansion of macro ‘BUILD_BUG_ON’
> >>   BUILD_BUG_ON(idx >= __end_of_fixed_addresses);
> >>   ^~~~~~~~~~~~
> >>
> >> Because fix_to_virt(, idx) needs a const value, not a dynamic variable of
> >> reg-a0 or BUILD_BUG_ON failed with "idx >= __end_of_fixed_addresses".
> >
> > Looks good to me :)
> >
> > Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
>
> Is there a configuration that runs into this bug?  It's not showing up for me,
> and I generally try to add regressions to my test suite.
>
> > Thanks!

KPROBE, I'll send the patch soon.

-- 
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/

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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-28 16:07 [PATCH V2] riscv: Fixup compile error BUILD_BUG_ON failed guoren
2020-06-28 16:25 ` Masami Hiramatsu
2020-06-29 23:22   ` Palmer Dabbelt
2020-06-30  0:12     ` Guo Ren

Linux-csky Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-csky/0 linux-csky/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-csky linux-csky/ https://lore.kernel.org/linux-csky \
		linux-csky@vger.kernel.org
	public-inbox-index linux-csky

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-csky


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git