linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] arm: Add BTB invalidation on switch_mm for Cortex-A9, A12, A15 and A17
Date: Mon, 8 Jan 2018 14:46:09 +0000	[thread overview]
Message-ID: <f48d11af-32b7-1c20-abaa-1efdf24616d0@arm.com> (raw)
In-Reply-To: <432481b8-11f0-6ee2-8b5c-5ac20f5f27db@arm.com>

On 08/01/18 14:29, Andre Przywara wrote:
> Hi,
> 
> On 06/01/18 12:09, Marc Zyngier wrote:
>> In order to avoid aliasing attacks against the branch predictor,
>> some implementations require to invalidate the BTB when switching
>> from one user context to another.
>>
>> For this, we reuse the existing implementation for Cortex-A8, and
>> apply it to A9, A12, A15, and A17.
>>
>> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
>> ---
>>  arch/arm/mm/proc-v7-2level.S |  4 ++--
>>  arch/arm/mm/proc-v7-3level.S |  6 ++++++
>>  arch/arm/mm/proc-v7.S        | 32 ++++++++++++++++----------------
>>  3 files changed, 24 insertions(+), 18 deletions(-)
>>
>> diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
>> index c6141a5435c3..0422e58b74e8 100644
>> --- a/arch/arm/mm/proc-v7-2level.S
>> +++ b/arch/arm/mm/proc-v7-2level.S
>> @@ -41,7 +41,7 @@
>>   *	even on Cortex-A8 revisions not affected by 430973.
>>   *	If IBE is not set, the flush BTAC/BTB won't do anything.
>>   */
>> -ENTRY(cpu_ca8_switch_mm)
>> +ENTRY(cpu_v7_btbinv_switch_mm)
>>  #ifdef CONFIG_MMU
>>  	mov	r2, #0
>>  	mcr	p15, 0, r2, c7, c5, 6		@ flush BTAC/BTB
>> @@ -66,7 +66,7 @@ ENTRY(cpu_v7_switch_mm)
>>  #endif
>>  	bx	lr
>>  ENDPROC(cpu_v7_switch_mm)
>> -ENDPROC(cpu_ca8_switch_mm)
>> +ENDPROC(cpu_v7_btbinv_switch_mm)
>>  
>>  /*
>>   *	cpu_v7_set_pte_ext(ptep, pte)
>> diff --git a/arch/arm/mm/proc-v7-3level.S b/arch/arm/mm/proc-v7-3level.S
>> index 7d16bbc4102b..934272e1fa08 100644
>> --- a/arch/arm/mm/proc-v7-3level.S
>> +++ b/arch/arm/mm/proc-v7-3level.S
>> @@ -54,6 +54,11 @@
>>   * Set the translation table base pointer to be pgd_phys (physical address of
>>   * the new TTB).
>>   */
>> +ENTRY(cpu_v7_btbinv_switch_mm)
>> +#ifdef CONFIG_MMU
>> +	mov	r2, #0
>> +	mcr	p15, 0, r2, c7, c5, 6			@ flush BTAC/BTB
> 
> r2 is already used below: this is the second argument to the function.
> The first argument is a phys_addr_t, so it takes both r0 and r1 already.
> That's why we need to use r3 above.
> This fixes a crash on the Midway for me.

I suppose you have DRAM above 4GB. Lucky you! I'll fix that in v2.

Thanks for the heads up.

	M.
-- 
Jazz is not dead. It just smells funny...

  reply	other threads:[~2018-01-08 14:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-06 12:09 [PATCH 0/3] ARM branch predictor hardening Marc Zyngier
2018-01-06 12:09 ` [PATCH 1/3] arm: Add BTB invalidation on switch_mm for Cortex-A9, A12, A15 and A17 Marc Zyngier
2018-01-06 18:48   ` [PATCH 1/2] ARM: Add BTB invalidation on switch_mm for Brahma-B15 Florian Fainelli
2018-01-08 14:29   ` [PATCH 1/3] arm: Add BTB invalidation on switch_mm for Cortex-A9, A12, A15 and A17 Andre Przywara
2018-01-08 14:46     ` Marc Zyngier [this message]
2018-01-08 17:50       ` Robin Murphy
2018-01-06 12:09 ` [PATCH 2/3] arm: Invalidate BTB on fatal signal for Cortex A8, A9, " Marc Zyngier
2018-01-06 18:49   ` [PATCH 2/2] ARM: Invalidate BTB on fatal signal for Brahma-B15 Florian Fainelli
2018-01-06 12:09 ` [PATCH 3/3] arm: KVM: Invalidate BTB on guest exit Marc Zyngier
2018-01-06 13:27   ` Ard Biesheuvel
2018-01-06 13:39     ` Marc Zyngier
2018-01-06 13:35   ` Ard Biesheuvel
2018-01-06 13:55     ` Marc Zyngier
2018-01-06 18:50 ` [PATCH 0/3] ARM branch predictor hardening Florian Fainelli
2018-01-08 21:28   ` Marc Zyngier
2018-01-10 16:57     ` Russell King - ARM Linux
2018-01-08 16:54 ` Tony Lindgren
2018-01-08 17:02   ` Marc Zyngier
2018-01-08 17:24     ` Tony Lindgren
2018-01-08 17:30       ` Marc Zyngier

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=f48d11af-32b7-1c20-abaa-1efdf24616d0@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).