lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 7 Dec 2019 10:42:28 +0100
From:   Christophe Leroy <christophe.leroy@....fr>
To:     Segher Boessenkool <segher@...nel.crashing.org>
Cc:     Michael Ellerman <mpe@...erman.id.au>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Paul Mackerras <paulus@...ba.org>,
        linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH v4 2/2] powerpc/irq: inline call_do_irq() and
 call_do_softirq()



Le 06/12/2019 à 21:59, Segher Boessenkool a écrit :
> On Wed, Dec 04, 2019 at 05:32:54AM +0100, Christophe Leroy wrote:
>> Le 29/11/2019 à 19:46, Segher Boessenkool a écrit :
>>> The existing call_do_irq isn't C code.  It doesn't do anything with r2,
>>> as far as I can see; __do_irq just gets whatever the caller of call_do_irq
>>> has.
>>>
>>> So I guess all the callers of call_do_irq have the correct r2 value always
>>> already?  In that case everything Just Works.
>>
>> Indeed, there is only one caller for call_do_irq() which is do_IRQ().
>> And do_IRQ() is also calling __do_irq() directly (when the stack pointer
>> is already set to IRQ stack). do_IRQ() and __do_irq() are both in
>> arch/powerpc/kernel/irq.c
>>
>> As far as I can see when replacing the call to call_do_irq() by a call
>> to __do_irq(), the compiler doesn't do anything special with r2, and
>> doesn't add any nop after the bl either, whereas for all calls outside
>> irq.c, there is a nop added. So I guess that's ok ?
> 
> If the compiler can see the callee wants the same TOC as the caller has,
> it does not arrange to set (and restore) it, no.  If it sees it may be
> different, it does arrange for that (and the linker then will check if
> it actually needs to do anything, and do that if needed).
> 
> In this case, the compiler cannot know the callee wants the same TOC,
> which complicates thing a lot -- but it all works out.

Do we have a way to make sure which TOC the functions are using ? Is 
there several TOC at all in kernel code ?

> 
>> Now that call_do_irq() is inlined, we can even define __do_irq() as static.
>>
>> And that's the same for do_softirq_own_stack(), it is only called from
>> do_softirq() which is defined in the same file as __do_softirq()
>> (kernel/softirq.c)
> 
> I think things can still go wrong if any of this is inlined into a kernel
> module?  Is there anything that prevents this / can this not happen for
> some fundamental reason I don't see?

This can't happen can it ?
do_softirq_own_stack() is an outline function, defined in powerpc irq.c
Its only caller is do_softirq() which is an outline function defined in 
kernel/softirq.c

That prevents inlining, doesn't it ?


Anyway, until we clarify all this I'll limit my patch to PPC32 which is 
where the real benefit is I guess.

At the end, maybe the solution should be to switch to IRQ stack 
immediately in the exception entry as x86_64 do ?

And do_softirq_own_stack() could be entirely written in assembly like 
x86_64 as well ?

Christophe

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ