[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen stable-4.16] x86/spec-ctrl: Simplify DO_COND_IBPB



commit 7efe5a0eee0e4f593c064b7f1b106acc74d8c7f9
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Fri Mar 22 14:33:17 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Tue Apr 9 17:10:28 2024 +0100

    x86/spec-ctrl: Simplify DO_COND_IBPB
    
    With the prior refactoring, SPEC_CTRL_ENTRY_{PV,INTR} both load SCF into 
%ebx,
    and handle the conditional safety including skipping if interrupting Xen.
    
    Therefore, we can drop the maybexen parameter and the conditional safety.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    (cherry picked from commit 2378d16a931de0e62c03669169989e9437306abe)
---
 xen/include/asm-x86/spec_ctrl_asm.h | 30 ++++++++----------------------
 1 file changed, 8 insertions(+), 22 deletions(-)

diff --git a/xen/include/asm-x86/spec_ctrl_asm.h 
b/xen/include/asm-x86/spec_ctrl_asm.h
index de6a6e4ff1..89edcf62fd 100644
--- a/xen/include/asm-x86/spec_ctrl_asm.h
+++ b/xen/include/asm-x86/spec_ctrl_asm.h
@@ -87,33 +87,21 @@
  *  - SPEC_CTRL_EXIT_TO_{SVM,VMX}
  */
 
-.macro DO_SPEC_CTRL_COND_IBPB maybexen:req
+.macro DO_COND_IBPB
 /*
- * Requires %rsp=regs (also cpuinfo if !maybexen)
- * Requires %r14=stack_end (if maybexen), %rdx=0
- * Clobbers %rax, %rcx, %rdx
+ * Requires %rbx=SCF, %rdx=0
+ * Clobbers %rax, %rcx
  *
- * Conditionally issue IBPB if SCF_entry_ibpb is active.  In the maybexen
- * case, we can safely look at UREGS_cs to skip taking the hit when
- * interrupting Xen.
+ * Conditionally issue IBPB if SCF_entry_ibpb is active.
  */
-    .if \maybexen
-        testb  $SCF_entry_ibpb, STACK_CPUINFO_FIELD(scf)(%r14)
-        jz     .L\@_skip
-        testb  $3, UREGS_cs(%rsp)
-    .else
-        testb  $SCF_entry_ibpb, CPUINFO_scf(%rsp)
-    .endif
+    testb  $SCF_entry_ibpb, %bl
     jz     .L\@_skip
 
     mov     $MSR_PRED_CMD, %ecx
     mov     $PRED_CMD_IBPB, %eax
     wrmsr
-    jmp     .L\@_done
 
 .L\@_skip:
-    lfence
-.L\@_done:
 .endm
 
 .macro DO_OVERWRITE_RSB tmp=rax xu
@@ -273,8 +261,7 @@
  */
     movzbl STACK_CPUINFO_FIELD(scf)(%r14), %ebx
 
-    ALTERNATIVE "", __stringify(DO_SPEC_CTRL_COND_IBPB maybexen=0),     \
-        X86_FEATURE_IBPB_ENTRY_PV
+    ALTERNATIVE "", DO_COND_IBPB, X86_FEATURE_IBPB_ENTRY_PV
 
     ALTERNATIVE "", DO_OVERWRITE_RSB, X86_FEATURE_SC_RSB_PV
 
@@ -303,8 +290,7 @@
     testb $3, UREGS_cs(%rsp)
     jz .L\@_skip
 
-    ALTERNATIVE "", __stringify(DO_SPEC_CTRL_COND_IBPB maybexen=1),     \
-        X86_FEATURE_IBPB_ENTRY_PV
+    ALTERNATIVE "", DO_COND_IBPB, X86_FEATURE_IBPB_ENTRY_PV
 
     ALTERNATIVE "", DO_OVERWRITE_RSB, X86_FEATURE_SC_RSB_PV
 
@@ -344,7 +330,7 @@
  * Clobbers %rax, %rbx, %rcx, %rdx
  *
  * This is logical merge of:
- *    DO_SPEC_CTRL_COND_IBPB maybexen=0
+ *    DO_COND_IBPB
  *    DO_OVERWRITE_RSB
  *    DO_SPEC_CTRL_ENTRY maybexen=1
  * but with conditionals rather than alternatives.
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.16



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.