x86/hvm: Raise #SS faults for %ss-based segmentation violations
authorAndrew Cooper <andrew.cooper3@citrix.com>
Sat, 7 May 2016 12:41:05 +0000 (13:41 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 10 May 2016 17:08:50 +0000 (18:08 +0100)
Raising #GP under such circumstances is architecturally wrong.

Refer to the Intel or AMD manuals describing faults, and the conditions
under which #SS is raised.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
xen/arch/x86/hvm/emulate.c
xen/arch/x86/mm/shadow/common.c

index be1e7c296845cef8eb792d54fb3a1644e6359109..ee5cf1f867218242cc09da44830a1ff4fa256c63 100644 (file)
@@ -566,7 +566,8 @@ static int hvmemul_virtual_to_linear(
 
     /* This is a singleton operation: fail it with an exception. */
     hvmemul_ctxt->exn_pending = 1;
-    hvmemul_ctxt->trap.vector = TRAP_gp_fault;
+    hvmemul_ctxt->trap.vector =
+        (seg == x86_seg_ss) ? TRAP_stack_error : TRAP_gp_fault;
     hvmemul_ctxt->trap.type = X86_EVENTTYPE_HW_EXCEPTION;
     hvmemul_ctxt->trap.error_code = 0;
     hvmemul_ctxt->trap.insn_len = 0;
index 559d4a4f9cdc24a25d77ac94cc8a794c1ca48fb7..226e32d46e616d2454406bf6c102d09591e64a2f 100644 (file)
@@ -148,7 +148,8 @@ static int hvm_translate_linear_addr(
 
     if ( !okay )
     {
-        hvm_inject_hw_exception(TRAP_gp_fault, 0);
+        hvm_inject_hw_exception(
+            (seg == x86_seg_ss) ? TRAP_stack_error : TRAP_gp_fault, 0);
         return X86EMUL_EXCEPTION;
     }