xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/HVM: correct segment register loading during task switch
@ 2016-09-23 10:09 Jan Beulich
  2016-09-26 14:09 ` Andrew Cooper
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2016-09-23 10:09 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper

[-- Attachment #1: Type: text/plain, Size: 1098 bytes --]

Instead of #NP, #SS needs to be raised for a non-present %ss
descriptor.

Don't lose the low two selector bits on null selector loads.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
This basically mirrors
https://lists.xenproject.org/archives/html/xen-devel/2016-09/msg02198.html 
taking into account that there's no 64-bit mode case here.

--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -2723,6 +2723,7 @@ static int hvm_load_segment_selector(
         if ( (seg == x86_seg_cs) || (seg == x86_seg_ss) )
             goto fail;
         memset(&segr, 0, sizeof(segr));
+        segr.sel = sel;
         hvm_set_segment_register(v, seg, &segr);
         return 0;
     }
@@ -2749,7 +2750,8 @@ static int hvm_load_segment_selector(
         /* Segment present in memory? */
         if ( !(desc.b & _SEGMENT_P) )
         {
-            fault_type = TRAP_no_segment;
+            fault_type = (seg != x86_seg_ss) ? TRAP_no_segment
+                                             : TRAP_stack_error;
             goto unmap_and_fail;
         }
 




[-- Attachment #2: x86-HVM-task-switch-seg.patch --]
[-- Type: text/plain, Size: 1155 bytes --]

x86/HVM: correct segment register loading during task switch

Instead of #NP, #SS needs to be raised for a non-present %ss
descriptor.

Don't lose the low two selector bits on null selector loads.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
This basically mirrors
https://lists.xenproject.org/archives/html/xen-devel/2016-09/msg02198.html
taking into account that there's no 64-bit mode case here.

--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -2723,6 +2723,7 @@ static int hvm_load_segment_selector(
         if ( (seg == x86_seg_cs) || (seg == x86_seg_ss) )
             goto fail;
         memset(&segr, 0, sizeof(segr));
+        segr.sel = sel;
         hvm_set_segment_register(v, seg, &segr);
         return 0;
     }
@@ -2749,7 +2750,8 @@ static int hvm_load_segment_selector(
         /* Segment present in memory? */
         if ( !(desc.b & _SEGMENT_P) )
         {
-            fault_type = TRAP_no_segment;
+            fault_type = (seg != x86_seg_ss) ? TRAP_no_segment
+                                             : TRAP_stack_error;
             goto unmap_and_fail;
         }
 

[-- Attachment #3: Type: text/plain, Size: 127 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86/HVM: correct segment register loading during task switch
  2016-09-23 10:09 [PATCH] x86/HVM: correct segment register loading during task switch Jan Beulich
@ 2016-09-26 14:09 ` Andrew Cooper
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2016-09-26 14:09 UTC (permalink / raw)
  To: Jan Beulich, xen-devel

On 23/09/16 11:09, Jan Beulich wrote:
> Instead of #NP, #SS needs to be raised for a non-present %ss
> descriptor.
>
> Don't lose the low two selector bits on null selector loads.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-26 14:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-23 10:09 [PATCH] x86/HVM: correct segment register loading during task switch Jan Beulich
2016-09-26 14:09 ` Andrew Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).