* [PATCH] powerpc: Fix HMIs on big-endian with CONFIG_RELOCATABLE=y
@ 2018-10-08 4:08 Benjamin Herrenschmidt
2018-10-08 7:04 ` Nicholas Piggin
2018-12-23 13:28 ` Michael Ellerman
0 siblings, 2 replies; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2018-10-08 4:08 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, npiggin
HMIs will crash the kernel due to
BRANCH_LINK_TO_FAR(hmi_exception_realmode)
Calling into the OPD instead of the actual code.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
This hack fixes it for me, but it's not great. Nick, any better idea ?
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index ea04dfb..752709cc8 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1119,7 +1119,11 @@ TRAMP_REAL_BEGIN(hmi_exception_early)
EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN)
EXCEPTION_PROLOG_COMMON_3(0xe60)
addi r3,r1,STACK_FRAME_OVERHEAD
+#ifdef PPC64_ELF_ABI_v1
+ BRANCH_LINK_TO_FAR(.hmi_exception_realmode) /* Function call ABI */
+#else
BRANCH_LINK_TO_FAR(hmi_exception_realmode) /* Function call ABI */
+#endif
cmpdi cr0,r3,0
/* Windup the stack. */
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc: Fix HMIs on big-endian with CONFIG_RELOCATABLE=y
2018-10-08 4:08 [PATCH] powerpc: Fix HMIs on big-endian with CONFIG_RELOCATABLE=y Benjamin Herrenschmidt
@ 2018-10-08 7:04 ` Nicholas Piggin
2018-10-08 9:53 ` Benjamin Herrenschmidt
2018-12-23 13:28 ` Michael Ellerman
1 sibling, 1 reply; 6+ messages in thread
From: Nicholas Piggin @ 2018-10-08 7:04 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev
On Mon, 08 Oct 2018 15:08:31 +1100
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> HMIs will crash the kernel due to
>
> BRANCH_LINK_TO_FAR(hmi_exception_realmode)
>
> Calling into the OPD instead of the actual code.
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>
> This hack fixes it for me, but it's not great. Nick, any better idea ?
Is it a hack because the ifdef gunk, or because there's something
deeper wrong with using the .sym?
I guess all those handlers that load label address by hand could have
the bug silently creep in. Can we have them use the DOTSYM() macro?
Thanks,
Nick
>
> diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
> index ea04dfb..752709cc8 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -1119,7 +1119,11 @@ TRAMP_REAL_BEGIN(hmi_exception_early)
> EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN)
> EXCEPTION_PROLOG_COMMON_3(0xe60)
> addi r3,r1,STACK_FRAME_OVERHEAD
> +#ifdef PPC64_ELF_ABI_v1
> + BRANCH_LINK_TO_FAR(.hmi_exception_realmode) /* Function call ABI */
> +#else
> BRANCH_LINK_TO_FAR(hmi_exception_realmode) /* Function call ABI */
> +#endif
> cmpdi cr0,r3,0
>
> /* Windup the stack. */
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc: Fix HMIs on big-endian with CONFIG_RELOCATABLE=y
2018-10-08 7:04 ` Nicholas Piggin
@ 2018-10-08 9:53 ` Benjamin Herrenschmidt
2018-10-09 10:37 ` Michael Ellerman
0 siblings, 1 reply; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2018-10-08 9:53 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linuxppc-dev
On Mon, 2018-10-08 at 17:04 +1000, Nicholas Piggin wrote:
> On Mon, 08 Oct 2018 15:08:31 +1100
> Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
>
> > HMIs will crash the kernel due to
> >
> > BRANCH_LINK_TO_FAR(hmi_exception_realmode)
> >
> > Calling into the OPD instead of the actual code.
> >
> > Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > ---
> >
> > This hack fixes it for me, but it's not great. Nick, any better idea ?
>
> Is it a hack because the ifdef gunk, or because there's something
> deeper wrong with using the .sym?
I'd say ifdef gunk, also the KVM use doesn't need it bcs the kvm entry
isn't an OPD.
> I guess all those handlers that load label address by hand could have
> the bug silently creep in. Can we have them use the DOTSYM() macro?
The KVM one doesnt have a dotsym does it ?
Also should we load the TOC from the OPD ?
> Thanks,
> Nick
>
> >
> > diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
> > index ea04dfb..752709cc8 100644
> > --- a/arch/powerpc/kernel/exceptions-64s.S
> > +++ b/arch/powerpc/kernel/exceptions-64s.S
> > @@ -1119,7 +1119,11 @@ TRAMP_REAL_BEGIN(hmi_exception_early)
> > EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN)
> > EXCEPTION_PROLOG_COMMON_3(0xe60)
> > addi r3,r1,STACK_FRAME_OVERHEAD
> > +#ifdef PPC64_ELF_ABI_v1
> > + BRANCH_LINK_TO_FAR(.hmi_exception_realmode) /* Function call ABI */
> > +#else
> > BRANCH_LINK_TO_FAR(hmi_exception_realmode) /* Function call ABI */
> > +#endif
> > cmpdi cr0,r3,0
> >
> > /* Windup the stack. */
> >
> >
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc: Fix HMIs on big-endian with CONFIG_RELOCATABLE=y
2018-10-08 9:53 ` Benjamin Herrenschmidt
@ 2018-10-09 10:37 ` Michael Ellerman
2018-10-09 12:27 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2018-10-09 10:37 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Nicholas Piggin; +Cc: linuxppc-dev
Benjamin Herrenschmidt <benh@kernel.crashing.org> writes:
> On Mon, 2018-10-08 at 17:04 +1000, Nicholas Piggin wrote:
>> On Mon, 08 Oct 2018 15:08:31 +1100
>> Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
>>
>> > HMIs will crash the kernel due to
>> >
>> > BRANCH_LINK_TO_FAR(hmi_exception_realmode)
>> >
>> > Calling into the OPD instead of the actual code.
>> >
>> > Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> > ---
>> >
>> > This hack fixes it for me, but it's not great. Nick, any better idea ?
>>
>> Is it a hack because the ifdef gunk, or because there's something
>> deeper wrong with using the .sym?
>
> I'd say ifdef gunk, also the KVM use doesn't need it bcs the kvm entry
> isn't an OPD.
>
>> I guess all those handlers that load label address by hand could have
>> the bug silently creep in. Can we have them use the DOTSYM() macro?
>
> The KVM one doesnt have a dotsym does it ?
>
> Also should we load the TOC from the OPD ?
Technically yes. But I thought because we build with mcmodel=medium
we'll never actually get multiple TOCs in the kernel itself, so it
doesn't actually matter.
So this seems to work for now:
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 301a6a86a20f..e5566e248a02 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1149,7 +1149,7 @@ TRAMP_REAL_BEGIN(hmi_exception_early)
EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN)
EXCEPTION_PROLOG_COMMON_3(0xe60)
addi r3,r1,STACK_FRAME_OVERHEAD
- BRANCH_LINK_TO_FAR(hmi_exception_realmode) /* Function call ABI */
+ BRANCH_LINK_TO_FAR(DOTSYM(hmi_exception_realmode)) /* Function call ABI */
cmpdi cr0,r3,0
/* Windup the stack. */
cheers
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc: Fix HMIs on big-endian with CONFIG_RELOCATABLE=y
2018-10-09 10:37 ` Michael Ellerman
@ 2018-10-09 12:27 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2018-10-09 12:27 UTC (permalink / raw)
To: Michael Ellerman, Nicholas Piggin; +Cc: linuxppc-dev
On Tue, 2018-10-09 at 21:37 +1100, Michael Ellerman wrote:
> Technically yes. But I thought because we build with mcmodel=medium
> we'll never actually get multiple TOCs in the kernel itself, so it
> doesn't actually matter.
>
> So this seems to work for now:
Ok, fine. I forgot about DOTSYM. Will do for now.
Cheers,
Ben.
> diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
> index 301a6a86a20f..e5566e248a02 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -1149,7 +1149,7 @@ TRAMP_REAL_BEGIN(hmi_exception_early)
> EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN)
> EXCEPTION_PROLOG_COMMON_3(0xe60)
> addi r3,r1,STACK_FRAME_OVERHEAD
> - BRANCH_LINK_TO_FAR(hmi_exception_realmode) /* Function call ABI */
> + BRANCH_LINK_TO_FAR(DOTSYM(hmi_exception_realmode)) /* Function call ABI */
> cmpdi cr0,r3,0
>
> /* Windup the stack. */
>
>
> cheers
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: powerpc: Fix HMIs on big-endian with CONFIG_RELOCATABLE=y
2018-10-08 4:08 [PATCH] powerpc: Fix HMIs on big-endian with CONFIG_RELOCATABLE=y Benjamin Herrenschmidt
2018-10-08 7:04 ` Nicholas Piggin
@ 2018-12-23 13:28 ` Michael Ellerman
1 sibling, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2018-12-23 13:28 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, npiggin
On Mon, 2018-10-08 at 04:08:31 UTC, Benjamin Herrenschmidt wrote:
> HMIs will crash the kernel due to
>
> BRANCH_LINK_TO_FAR(hmi_exception_realmode)
>
> Calling into the OPD instead of the actual code.
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/505a314fb28ce122091691c51426fa
cheers
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-12-23 14:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-08 4:08 [PATCH] powerpc: Fix HMIs on big-endian with CONFIG_RELOCATABLE=y Benjamin Herrenschmidt
2018-10-08 7:04 ` Nicholas Piggin
2018-10-08 9:53 ` Benjamin Herrenschmidt
2018-10-09 10:37 ` Michael Ellerman
2018-10-09 12:27 ` Benjamin Herrenschmidt
2018-12-23 13:28 ` Michael Ellerman
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.