From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Bernd Edlinger <bernd.edlinger@hotmail.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Arnd Bergmann <arnd@arndb.de>,
Russell King <linux@armlinux.org.uk>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"yadi.hu@windriver.com" <yadi.hu@windriver.com>
Subject: Re: [RFC PATCH] ARM: enable irq in translation/section permission fault handlers
Date: Wed, 20 Feb 2019 11:50:35 +0100 [thread overview]
Message-ID: <20190220105034.7fv7u7lel4siu6zr@linutronix.de> (raw)
In-Reply-To: <VI1PR0702MB3840A772914621B2F026B349E4600@VI1PR0702MB3840.eurprd07.prod.outlook.com>
On 2019-02-15 21:57:56 [+0000], Bernd Edlinger wrote:
> > diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
> > index 58f69fa07df95..da82967865836 100644
> > --- a/arch/arm/mm/fault.c
> > +++ b/arch/arm/mm/fault.c
> > @@ -161,8 +161,6 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
> > unsigned int fsr, unsigned int sig, int code,
> > struct pt_regs *regs)
> > {
> > - if (addr > TASK_SIZE)
> > - harden_branch_predictor();
> >
> > #ifdef CONFIG_DEBUG_USER
> > if (((user_debug & UDBG_SEGV) && (sig == SIGSEGV)) ||
> > @@ -191,6 +189,11 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
> > struct task_struct *tsk = current;
> > struct mm_struct *mm = tsk->active_mm;
> >
> > + if (addr > TASK_SIZE && user_mode(regs))
> > + harden_branch_predictor();
>
> This is somehow inconsisten with do_translation_fault, where
> we have this:
>
> if (addr < TASK_SIZE)
> return do_page_fault(addr, fsr, regs);
yes but harden_branch_predictor() is only invoked for addr > TASK_SIZE.
What do I miss?
> > +
> > + if (interrupts_enabled(regs))
> > + local_irq_enable();
> > /*
> > * If we are in kernel mode at this point, we
> > * have no context to handle this fault with.
> >
>
> I have seen three different failure modes, pleas see the first 3 calls stacks
> here: https://marc.info/?l=linux-rt-users&m=155016888714927&w=2
yes, but this is only with the one patch in RT. So you should not see
this without the RT patch.
> I am concerned about this fist issue, because it removes the branch
> predictor hardening after the do_page_fault has executed:
>
> do_DataAbort->do_page_fault(addr>TASK_SIZE)->__do_user_fault
>
> This is reachable because do_page_fault is not only called from
> do_translation_fault but also from here: arch/arm/mm/fsr-2level.c
> and here: arch/arm/mm/fsr-3level.c
> those are callable with addr > TASK_SIZE
okay. So 0xbffffff0 without LPAE would be left out. I wasn't ware of
that. And this indeed it hits the warning.
> And the following code path does enable the hard irqs before do_bad_area:
> do_DataAbort->do_sect_fault->do_bad_area->__do_user_fault
>
> So this function, would need to be rewritten:
>
> do_sect_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
> {
> if (interrupts_enabled(regs))
> local_irq_enable();
>
> do_bad_area(addr, fsr, regs);
> return 0;
> }
We would need to move the branch predictor piece before enabling
interrupts.
>
> Thanks
> Bernd.
Sebastian
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-02-20 10:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-15 20:05 [RFC PATCH] ARM: enable irq in translation/section permission fault handlers Sebastian Andrzej Siewior
2019-02-15 21:57 ` Bernd Edlinger
2019-02-20 10:50 ` Sebastian Andrzej Siewior [this message]
2019-02-16 11:33 ` Russell King - ARM Linux admin
2019-02-20 11:00 ` Sebastian Andrzej Siewior
2019-02-21 8:06 ` Bernd Edlinger
2019-02-21 9:31 ` Bernd Edlinger
2019-02-21 9:57 ` Sebastian Andrzej Siewior
2019-02-21 14:03 ` Bernd Edlinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190220105034.7fv7u7lel4siu6zr@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=arnd@arndb.de \
--cc=bernd.edlinger@hotmail.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=tglx@linutronix.de \
--cc=yadi.hu@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).