x86/spec_ctrl: Fix several bugs in SPEC_CTRL_ENTRY_FROM_INTR_IST
Quoted 70 lines · 2018年2月14日 19:10于 Andrew Cooper <[email protected]>写道:
DO_OVERWRITE_RSBclobbers %rax, meaning in practice that that thebti_ist_infofield gets zeroed. Older versions of this code had theDO_OVERWRITE_RSBregister selectable, so reintroduce this ability and use it to cause theINTR_ISTpath to use %rdx instead.The use of %dl for the %cs.rpl check means that when an IST interrupt hits Xen, we try to load 1 into the high 32 bits of
MSR_SPEC_CTRL, suffering a #GP fault instead.Also, drop an unused label which was a copy/paste mistake.
Reported-by Boris Ostrovsky <[email protected]>Reported-by Zhenzhong Duan <[email protected]>Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Zhenzhong Duan <[email protected]>
CC: Boris Ostrovsky <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
---xen/include/asm-x86/spec_ctrl_asm.h| 12 ++++++------1 file changed, 6 insertions(+), 6 deletions(-)xen/include/asm-x86/spec_ctrl_asm.h +2
-2@@ -79,10 +79,10 @@* - SPEC_CTRL_EXIT_TO_GUEST */ -.macro DO_OVERWRITE_RSB +.macro DO_OVERWRITE_RSB tmp=%rax/* * Requires nothing -* Clobbers %rax, %rcx +* Clobbers \tmp (%rax by default), %rcx * * Requires 256 bytes of stack space, but %rsp has no net change. Based on * Google's performance numbers, the loop is unrolled to 16 iterations and two @@ -97,7 +97,7 @@* optimised with mov-elimination in modern cores. */ mov $16, %ecx /* 16 iterations, two calls per loop */ - mov %rsp, %rax /* Store the current %rsp */ + mov %rsp, \tmp /* Store the current %rsp */
.L\@_fill_rsb_loop:
xen/include/asm-x86/spec_ctrl_asm.h +0
-0@@ -114,7 +114,7 @@sub $1, %ecx
jnz .L\@_fill_rsb_loop
- mov %rax, %rsp /* Restore old %rsp */ + mov \tmp, %rsp /* Restore old %rsp */ .endm.macro
DO_SPEC_CTRL_ENTRY_FROM_VMEXITibrs_val:reqxen/include/asm-x86/spec_ctrl_asm.h +0
-0@@ -274,7 +274,7 @@testb $BTI_IST_RSB, %al
jz .L\@_skip_rsb-
DO_OVERWRITE_RSB
+DO_OVERWRITE_RSBtmp=%rdx /* Clobbers %ecx/%rdx */.L\@_skip_rsb:
xen/include/asm-x86/spec_ctrl_asm.h +0
-0@@ -286,13 +286,13 @@
Quoted 2 lines
setz %dl
and %dl, STACK_CPUINFO_FIELD(use_shadow_spec_ctrl)(%r14)
Is it safe to remove the 'xor %edx, %edx' above? setz set whole byte 1 or 0.
---
thanks
zduan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 7 lines · zhenzhong.duan
Quoted 4 lines
(quoted diff) +0
-0@@ -286,13 +286,13 @@setz %dl
and %dl, STACK_CPUINFO_FIELD(use_shadow_spec_ctrl)(%r14)Is it safe to remove the 'xor %edx, %edx' above? setz set whole byte 1 or 0.
It is safe, but it is not a good idea.
Using setz is an 8bit operation, which will suffer a register merge stall in the pipeline as we know for certain at this point that the upper bits of %edx are nonzero at this point. (An encoding which allowed setz %eax would have been far more useful in 64bit code.)
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel