x86/svm: Reduce vmentry latency
PATCH 1/1 x86/svm: Reduce vmentry latency
Writing to the stack pointer in the middle of a line of pop operations is specifically recommended against by the optimisation guide, and is a technique used by Speculative Load Hardening to combat SpectreRSB.
In practice, it causes all further stack-relative accesses to block until the write to the stack pointer retires, so the stack engine can get back in sync.
Pop into any dead register to discard %rax's value without clobbering the stack engine. Smaller compiled code, and runs faster.
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
In a small test where I wired ICEBP to tighly re-enter the guest, this dropped the guests perviced time for ICEBP (as close to one vmexit and entry as I could realistically manage) by 20 ticks. Sadly, that also seems to be the granuarlity of measurement. The modal measurement (accounting for 80% of samples) was 1200 ticks, and reduced to 1180 with just this change in place.
--- xen/arch/x86/hvm/svm/entry.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/svm/entry.S +1 -1
@@ -76,7 +76,7 @@ __UNLIKELY_END(nsvm_hap) pop %r10 pop %r9 pop %r8 - add $8,%rsp /* Skip %rax: restored by VMRUN. */ + pop %rcx /* Skip %rax: restored by VMRUN. */ pop %rcx pop %rdx pop %rsi
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 11 lines · Andrew Cooper
Writing to the stack pointer in the middle of a line of pop operations is specifically recommended against by the optimisation guide, and is a technique used by Speculative Load Hardening to combat SpectreRSB.
In practice, it causes all further stack-relative accesses to block until the write to the stack pointer retires, so the stack engine can get back in sync.
Pop into any dead register to discard %rax's value without clobbering the stack engine. Smaller compiled code, and runs faster.
Signed-off-by Andrew Cooper <[email protected]>
Thanks.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Jan Beulich
Acked-byQuoted 8 lines · Roger Pau Monné
Quoted 7 lines · Andrew Cooper
Writing to the stack pointer in the middle of a line of pop operations is specifically recommended against by the optimisation guide, and is a technique used by Speculative Load Hardening to combat SpectreRSB.
In practice, it causes all further stack-relative accesses to block until the write to the stack pointer retires, so the stack engine can get back in sync.
Quoted 6 lines
Quoted 4 lines
Pop into any dead register to discard %rax's value without clobbering the stack engine. Smaller compiled code, and runs faster.
Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Roger Pau Monné <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel