diff mbox

[v2,for-4.7,2/5] x86/hvm: Raise #SS faults for %ss-based segmentation violations

Message ID 1462818472-14225-3-git-send-email-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Cooper May 9, 2016, 6:27 p.m. UTC
Raising #GP under such circumstances is architecturally wrong.  (Refer
to the Intel or AMD manuals describing the conditions under which the

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
---
CC: Paul Durrant <paul.durrant@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>

v2:
 * Clarified the commit message.
---
 xen/arch/x86/hvm/emulate.c      | 3 ++-
 xen/arch/x86/mm/shadow/common.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

Comments

Jan Beulich May 10, 2016, 7:39 a.m. UTC | #1
>>> On 09.05.16 at 20:27, <andrew.cooper3@citrix.com> wrote:
> Raising #GP under such circumstances is architecturally wrong.  (Refer
> to the Intel or AMD manuals describing the conditions under which the

This sentence is pretty clearly unfinished.

Jan
Andrew Cooper May 10, 2016, 7:40 a.m. UTC | #2
On 10/05/2016 08:39, Jan Beulich wrote:
>>>> On 09.05.16 at 20:27, <andrew.cooper3@citrix.com> wrote:
>> Raising #GP under such circumstances is architecturally wrong.  (Refer
>> to the Intel or AMD manuals describing the conditions under which the
> This sentence is pretty clearly unfinished.

So it is.  It started #SS and Git helpfully stripped the comment out of
the final committed message.  I will fix it up.

~Andrew
diff mbox

Patch

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index be1e7c2..ee5cf1f 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -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;
diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c
index 559d4a4..226e32d 100644
--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -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;
     }