xen/arm: livepatch: Prevent CPUs to fetch stale instructions after livepatching
PATCH 1/1 xen/arm: livepatch: Prevent CPUs to fetch stale instructions after livepatching
During livepatch, a single CPU will take care of applying the patch and all the others will wait for the action to complete. They will then once execute arch_livepatch_post_action() to flush the pipeline.
Per B2.2.5 "Concurrent modification and execution of instructions" in DDI 0487E.a, flushing the instruction cache is not enough to ensure new instructions are seen. All the PEs should also do an isb() to synchronize the fetched instruction stream.
--- xen/arch/arm/livepatch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/arm/livepatch.c +2 -1
@@ -88,7 +88,8 @@ void arch_livepatch_revert(const struct livepatch_func *func)void arch_livepatch_post_action (void ) { -/* arch_livepatch_revive has nuked the instruction cache. */ +/* Discard any stale instructions that may have been fetched. */ +isb (); }void arch_livepatch_mask (void )
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 20 lines · Julien Grall
During livepatch, a single CPU will take care of applying the patch and all the others will wait for the action to complete. They will then once execute
arch_livepatch_post_action()to flush the pipeline.Per B2.2.5 "Concurrent modification and execution of instructions" in DDI 0487E.a, flushing the instruction cache is not enough to ensure new instructions are seen. All the PEs should also do an
isb()to synchronize the fetched instruction stream.Signed-off-by Julien Grall <[email protected]>--- xen/arch/arm/livepatch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)xen/arch/arm/livepatch.c +0
-0
xen/arch/arm/livepatch.c void arch_livepatch_revert(const struct livepatch_func *func) · line 95
Quoted 9 lines
xen/arch/arm/livepatch.c +2
-1@@ -88,7 +88,8 @@ void arch_livepatch_revert(const struct livepatch_func *func)void arch_livepatch_post_action (void ) { -/* arch_livepatch_revive has nuked the instruction cache. */ +/* Discard any stale instructions that may have been fetched. */ +isb (); }void arch_livepatch_mask (void )
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Julien,
Quoted 10 lines · Julien Grall
During livepatch, a single CPU will take care of applying the patch and all the others will wait for the action to complete. They will then once execute
arch_livepatch_post_action()to flush the pipeline.Per B2.2.5 "Concurrent modification and execution of instructions" in DDI 0487E.a, flushing the instruction cache is not enough to ensure new instructions are seen. All the PEs should also do an
isb()to synchronize the fetched instruction stream.Signed-off-by Julien Grall <[email protected]>
Quoted 18 lines
--- xen/arch/arm/livepatch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)xen/arch/arm/livepatch.c +2
-1@@ -88,7 +88,8 @@ void arch_livepatch_revert(const struct livepatch_func *func)void arch_livepatch_post_action (void ) { -/* arch_livepatch_revive has nuked the instruction cache. */ +/* Discard any stale instructions that may have been fetched. */ +isb (); }void arch_livepatch_mask (void )
Signature · 5 lines
Volodymyr Babchuk at EPAM _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel