All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] ARM: v7: get rid of boot time mini stack
@ 2021-02-08 22:49 Ard Biesheuvel
  2021-02-08 22:49 ` [PATCH 1/3] ARM: cache-v7: add missing ISB after cache level selection Ard Biesheuvel
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Ard Biesheuvel @ 2021-02-08 22:49 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Nicolas Pitre, Marc Zyngier, Linus Walleij, Russell King,
	kernel-team, Ard Biesheuvel

The v7 boot code uses a small chunk of BSS to preserve some register
contents across a call to v7_invalidate_l1 that occurs with the MMU and
caches disabled. Memory accesses in such cases are tricky on v7+, given
that the architecture permits some unintuitive behaviors (it is
implementation defined whether accesses done with the MMU and caches off
may hit in the caches, and on SoCs that incorporate off-core system
caches, this behavior appears to be different even between cache
levels). Also, cache invalidation is not safe under virtualization if
the intent is to retain stores issued directly to DRAM, given that the
hypervisor may upgrade invalidate operations to clean+invalidate,
resulting in DRAM contents to be overwritte by the dirty cachelines that
we were trying to evict in the first place.

So let's address this issue, by removing the need for this stack to
exist in the first place: v7_invalidate_l1 can be rewritten to use fewer
registers, which means fewer registers need to be preserved, and we have
enough spare registers available.

Patch #1 adds a missing ISB. This patch is included separately so it can
be backported if desired.

Patch #2 rewrites v7_invalidate_l1 so it only uses 5 registers (not
counting lr which it must preserve as well)

Patch #3 updates the callers to use spare registers instead of the mini
stack to stash the values that need to be preserved across the calls to
v7_invalidate_l1.

Cc: Marc Zyngier <maz@kernel.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Nicolas Pitre <nico@fluxnic.net>

Ard Biesheuvel (3):
  ARM: cache-v7: add missing ISB after cache level selection
  ARM: cache-v7: refactor v7_invalidate_l1 to avoid clobbering r5/r6
  ARM: cache-v7: get rid of mini-stack

 arch/arm/include/asm/memory.h | 15 -----
 arch/arm/mm/cache-v7.S        | 58 ++++++++++----------
 arch/arm/mm/proc-v7.S         | 40 ++++++--------
 3 files changed, 47 insertions(+), 66 deletions(-)

-- 
2.20.1


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-02-10 17:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08 22:49 [PATCH 0/3] ARM: v7: get rid of boot time mini stack Ard Biesheuvel
2021-02-08 22:49 ` [PATCH 1/3] ARM: cache-v7: add missing ISB after cache level selection Ard Biesheuvel
2021-02-08 22:49 ` [PATCH 2/3] ARM: cache-v7: refactor v7_invalidate_l1 to avoid clobbering r5/r6 Ard Biesheuvel
2021-02-08 22:49 ` [PATCH 3/3] ARM: cache-v7: get rid of mini-stack Ard Biesheuvel
2021-02-08 23:07   ` Nicolas Pitre
2021-02-09 22:37     ` Ard Biesheuvel
2021-02-08 23:11 ` [PATCH 0/3] ARM: v7: get rid of boot time mini stack Nicolas Pitre
2021-02-09 22:37   ` Ard Biesheuvel
2021-02-09 22:59     ` Nicolas Pitre
2021-02-09 23:02       ` Ard Biesheuvel
2021-02-09 23:22         ` Nicolas Pitre
2021-02-10 17:39           ` Ard Biesheuvel

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.