All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V6] arm64: alternative:flush cache with unpatched code
@ 2018-06-06 23:29 Rohit Khanna
  2018-06-07 10:01 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: Rohit Khanna @ 2018-06-06 23:29 UTC (permalink / raw)
  To: linux-arm-kernel

In the current implementation,  __apply_alternatives patches
flush_icache_range and then executes it without invalidating the icache.
Thus, icache can contain some of the old instructions for
flush_icache_range. This can cause unpredictable behavior as during
execution we can get a mix of old and new instructions for
flush_icache_range.

This patch modifies __apply_alternatives so that it uses non hot-patched
__flush_icache_all after applying all the alternatives.

Signed-off-by: Rohit Khanna <rokhanna@nvidia.com>
---
 arch/arm64/kernel/alternative.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c
index 5c4bce4ac381..047139f570ac 100644
--- a/arch/arm64/kernel/alternative.c
+++ b/arch/arm64/kernel/alternative.c
@@ -154,10 +154,8 @@ static void __apply_alternatives(void *alt_region, bool use_linear_alias)
 			alt_cb  = ALT_REPL_PTR(alt);
 
 		alt_cb(alt, origptr, updptr, nr_inst);
-
-		flush_icache_range((uintptr_t)origptr,
-				   (uintptr_t)(origptr + nr_inst));
 	}
+	__flush_icache_all();
 }
 
 /*
-- 
2.1.4

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

* [PATCH V6] arm64: alternative:flush cache with unpatched code
  2018-06-06 23:29 [PATCH V6] arm64: alternative:flush cache with unpatched code Rohit Khanna
@ 2018-06-07 10:01 ` Will Deacon
  0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2018-06-07 10:01 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jun 06, 2018 at 04:29:03PM -0700, Rohit Khanna wrote:
> In the current implementation,  __apply_alternatives patches
> flush_icache_range and then executes it without invalidating the icache.
> Thus, icache can contain some of the old instructions for
> flush_icache_range. This can cause unpredictable behavior as during
> execution we can get a mix of old and new instructions for
> flush_icache_range.
> 
> This patch modifies __apply_alternatives so that it uses non hot-patched
> __flush_icache_all after applying all the alternatives.

Please can you try the diff I posted the other day? [1]

Will

--->8

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2018-June/582861.html

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

end of thread, other threads:[~2018-06-07 10:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-06 23:29 [PATCH V6] arm64: alternative:flush cache with unpatched code Rohit Khanna
2018-06-07 10:01 ` Will Deacon

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.