Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/2] arm64: entry: Move ct_user_exit before we can take another exception
Date: Fri, 2 Aug 2019 13:43:13 +0100	[thread overview]
Message-ID: <c1119d68-b7a2-e65d-64ca-be985ea6ab69@arm.com> (raw)
In-Reply-To: <20190801163919.jlpvy47pknqx75ze@willie-the-truck>

Hi Will,

On 01/08/2019 17:39, Will Deacon wrote:
> On Thu, Aug 01, 2019 at 04:41:50PM +0100, James Morse wrote:
>> When taking an exception from EL0 we unmask exceptions before calling
>> ct_user_exit. This means we could take an interrupt or be single-stepped
>> in the gap. The entry from EL1 code sees that we took an exception from
>> the kernel, whereas the context_tracking code believes we are still in
>> user-space.
>>
>> To keep these things consistent, move the ct_user_exit calls before
>> any unmask of exceptions.

>> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
>> index 28681034d599..88f4ab21cb66 100644
>> --- a/arch/arm64/kernel/entry.S
>> +++ b/arch/arm64/kernel/entry.S
>> @@ -792,8 +792,8 @@ el0_cp15:
>>  	/*
>>  	 * Trapped CP15 (MRC, MCR, MRRC, MCRR) instructions
>>  	 */
>> -	enable_daif
>>  	ct_user_exit
>> +	enable_daif
>>  	mov	x0, x25
>>  	mov	x1, sp
>>  	bl	do_cp15instr
>> @@ -805,8 +805,8 @@ el0_da:
>>  	 * Data abort handling
>>  	 */
>>  	mrs	x26, far_el1
>> -	enable_daif
>>  	ct_user_exit
>> +	enable_daif

> This strikes me as a bit dodgy, since we end up in context_tracking_exit(),
> which calls local_irq_{save,restore}() and I think our accounting is
> probably off at this point.

Huh, I'm sure I had all those options turned on...

~

local_irq_save() calls trace_hardirqs_off() unconditionally, whereas local_irq_restore()
uses the saved flags to decide interrupts aren't enabled by this restore call, so the
accounting ends up being correct. It calls trace_hardirqs_off() a second time.

The asserts check trace_hardirqs_off() is called with interrupts masked, which it is in
this case.


> I think we need to call via
> user_{enter,exit}_irqoff() instead to make this work.

Sure, that would be clearer.


Thanks,

James

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply	other threads:[~2019-08-02 12:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-01 15:41 [PATCH 0/2] arm64: entry: Move ct_user_exit calls earlier James Morse
2019-08-01 15:41 ` [PATCH 1/2] arm64: entry: Move ct_user_exit before any user of RCU James Morse
2019-08-01 15:41 ` [PATCH 2/2] arm64: entry: Move ct_user_exit before we can take another exception James Morse
2019-08-01 16:39   ` Will Deacon
2019-08-02 12:43     ` James Morse [this message]

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=c1119d68-b7a2-e65d-64ca-be985ea6ab69@arm.com \
    --to=james.morse@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mhiramat@kernel.org \
    --cc=will@kernel.org \
    /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