2022-05-21 11:15:28

by Naveen N. Rao

[permalink] [raw]
Subject: Re: linux-next: changed messages in qemu boot

Stephen Rothwell wrote:
> Hi all,
>
> Today's linux-next bboot of the powerpc pseries_le_defconfig build
> produced these different kernel messages (diff from yesterday's tree):
>
> - ftrace: allocating 33658 entries in 13 pages
> - ftrace: allocated 13 pages with 3 groups
> + ftrace-powerpc: Address of ftrace_regs_caller out of range of kernel_toc.

Thanks for the report. I think that is due to:
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/bb6626e884acffe87b58736291df57db3deaa9b9.1652074503.git.christophe.leroy@csgroup.eu/

The below diff fixes it for me:

diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
index 46c002a8388804..7418da705d43ac 100644
--- a/arch/powerpc/kernel/trace/ftrace.c
+++ b/arch/powerpc/kernel/trace/ftrace.c
@@ -746,7 +746,7 @@ int __init ftrace_dyn_arch_init(void)

reladdr = addr - kernel_toc_addr();

- if (reladdr >= SZ_2G || reladdr < -SZ_2G) {
+ if (reladdr >= SZ_2G || reladdr < -_UL(SZ_2G)) {
pr_err("Address of %ps out of range of kernel_toc.\n",
(void *)addr);
return -1;


- Naveen



2022-05-24 09:26:37

by Michael Ellerman

[permalink] [raw]
Subject: Re: linux-next: changed messages in qemu boot

"Naveen N. Rao" <[email protected]> writes:
> Stephen Rothwell wrote:
>> Hi all,
>>
>> Today's linux-next bboot of the powerpc pseries_le_defconfig build
>> produced these different kernel messages (diff from yesterday's tree):
>>
>> - ftrace: allocating 33658 entries in 13 pages
>> - ftrace: allocated 13 pages with 3 groups
>> + ftrace-powerpc: Address of ftrace_regs_caller out of range of kernel_toc.
>
> Thanks for the report. I think that is due to:
> https://patchwork.ozlabs.org/project/linuxppc-dev/patch/bb6626e884acffe87b58736291df57db3deaa9b9.1652074503.git.christophe.leroy@csgroup.eu/

Yep, I bisected it there.

I should really read my email before bisecting :)

> The below diff fixes it for me:
>
> diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
> index 46c002a8388804..7418da705d43ac 100644
> --- a/arch/powerpc/kernel/trace/ftrace.c
> +++ b/arch/powerpc/kernel/trace/ftrace.c
> @@ -746,7 +746,7 @@ int __init ftrace_dyn_arch_init(void)
>
> reladdr = addr - kernel_toc_addr();
>
> - if (reladdr >= SZ_2G || reladdr < -SZ_2G) {
> + if (reladdr >= SZ_2G || reladdr < -_UL(SZ_2G)) {
> pr_err("Address of %ps out of range of kernel_toc.\n",
> (void *)addr);
> return -1;

I did:

if (reladdr >= SZ_2G || reladdr < -(long)SZ_2G) {


Which more closely matches what the old code did, and I think is more
obvious? ie. we don't want to negate the unsigned value, we want a
signed value, and then the negative of that.

cheers

2022-05-24 10:31:33

by Naveen N. Rao

[permalink] [raw]
Subject: Re: linux-next: changed messages in qemu boot

Michael Ellerman wrote:
> "Naveen N. Rao" <[email protected]> writes:
>> Stephen Rothwell wrote:
>
>> The below diff fixes it for me:
>>
>> diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
>> index 46c002a8388804..7418da705d43ac 100644
>> --- a/arch/powerpc/kernel/trace/ftrace.c
>> +++ b/arch/powerpc/kernel/trace/ftrace.c
>> @@ -746,7 +746,7 @@ int __init ftrace_dyn_arch_init(void)
>>
>> reladdr = addr - kernel_toc_addr();
>>
>> - if (reladdr >= SZ_2G || reladdr < -SZ_2G) {
>> + if (reladdr >= SZ_2G || reladdr < -_UL(SZ_2G)) {
>> pr_err("Address of %ps out of range of kernel_toc.\n",
>> (void *)addr);
>> return -1;
>
> I did:
>
> if (reladdr >= SZ_2G || reladdr < -(long)SZ_2G) {

That was my first attempt.

> Which more closely matches what the old code did, and I think is more
> obvious? ie. we don't want to negate the unsigned value, we want a
> signed value, and then the negative of that.

When you put it like that... :D
In hindsight, I agree though -- _UL() isn't necessarily better.


Thanks,
Naveen