The commit is pushed to "branch-rh7-3.10.0-514.26.1.vz7.35.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.26.1.vz7.33.22
------>
commit ee3435b5d8019870016bb88fc21b7342b1632171
Author: Radim Krčmář <rkrc...@redhat.com>
Date:   Mon Aug 7 14:41:11 2017 +0400

    ms/KVM: x86: add asm_safe wrapper
    
    Move the existing exception handling for inline assembly into a macro
    and switch its return values to X86EMUL type.
    
    Signed-off-by: Radim Krčmář <rkrc...@redhat.com>
    Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
    
    https://jira.sw.ru/browse/PSBM-69206
    ms commit: aabba3c6abd50b05b1fc2c6ec44244aa6bcda576
    
    Signed-off-by: Evgeny Yakovlev <eyakov...@virtuozzo.com>
---
 arch/x86/kvm/emulate.c | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index e9be9e9..ee1835d 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -468,6 +468,26 @@ FOP_END;
 FOP_START(salc) "pushf; sbb %al, %al; popf \n\t" FOP_RET
 FOP_END;
 
+/*
+ * XXX: inoutclob user must know where the argument is being expanded.
+ *      Relying on CC_HAVE_ASM_GOTO would allow us to remove _fault.
+ */
+#define asm_safe(insn, inoutclob...) \
+({ \
+       int _fault = 0; \
+ \
+       asm volatile("1:" insn "\n" \
+                    "2:\n" \
+                    ".pushsection .fixup, \"ax\"\n" \
+                    "3: movl $1, %[_fault]\n" \
+                    "   jmp  2b\n" \
+                    ".popsection\n" \
+                    _ASM_EXTABLE(1b, 3b) \
+                    : [_fault] "+qm"(_fault) inoutclob ); \
+ \
+       _fault ? X86EMUL_UNHANDLEABLE : X86EMUL_CONTINUE; \
+})
+
 static int emulator_check_intercept(struct x86_emulate_ctxt *ctxt,
                                    enum x86_intercept intercept,
                                    enum x86_intercept_stage stage)
@@ -5135,21 +5155,13 @@ static bool string_insn_completed(struct 
x86_emulate_ctxt *ctxt)
 
 static int flush_pending_x87_faults(struct x86_emulate_ctxt *ctxt)
 {
-       bool fault = false;
+       int rc;
 
        ctxt->ops->get_fpu(ctxt);
-       asm volatile("1: fwait \n\t"
-                    "2: \n\t"
-                    ".pushsection .fixup,\"ax\" \n\t"
-                    "3: \n\t"
-                    "movb $1, %[fault] \n\t"
-                    "jmp 2b \n\t"
-                    ".popsection \n\t"
-                    _ASM_EXTABLE(1b, 3b)
-                    : [fault]"+qm"(fault));
+       rc = asm_safe("fwait");
        ctxt->ops->put_fpu(ctxt);
 
-       if (unlikely(fault))
+       if (unlikely(rc != X86EMUL_CONTINUE))
                return emulate_exception(ctxt, MF_VECTOR, 0, false);
 
        return X86EMUL_CONTINUE;
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to