Skip to contentSkip to conversation

xen: Add GS base to HVM VCPU context

PATCH Superseded Aravindh Puthiyaparambil 3 participants 7 messages Apr 21, 2012 – Apr 23, 2012

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: Add GS base to HVM VCPU context

Add GS base to the HVM VCPU context returned by xc_vcpu_getcontext()

xen/arch/x86/domctl.c +6 -0
diff -r e62ab14d44af -r babbb3e0f4d3 xen/arch/x86/domctl.c
@@ -1592,6 +1592,12 @@ void arch_get_info_guest(struct vcpu *v,
         c.nat->user_regs.fs = sreg.sel;
         hvm_get_segment_register(v, x86_seg_gs, &sreg);
         c.nat->user_regs.gs = sreg.sel;
+#ifdef __x86_64__
+        if ( ring_0(&c.nat->user_regs) )
+            c.nat->gs_base_kernel = sreg.base;
+        else
+            c.nat->gs_base_user = sreg.base;
+#endif
     }
     else
     {
#1 lore raw
Quoted 9 lines
Quoted 1 line
Quoted 1 line · Aravindh Puthiyaparambil

Add GS base to the HVM VCPU context returned by xc_vcpu_getcontext()

diff -r e62ab14d44af -r babbb3e0f4d3 xen/arch/x86/domctl.c

xen/arch/x86/domctl.c void arch_get_info_guest(struct vcpu *v, · line 1600

Quoted 9 lines
xen/arch/x86/domctl.c +6 -0
@@ -1592,6 +1592,12 @@ void arch_get_info_guest(struct vcpu *v,
         c.nat->user_regs.fs = sreg.sel;
         hvm_get_segment_register(v, x86_seg_gs, &sreg);
         c.nat->user_regs.gs = sreg.sel;
+#ifdef __x86_64__
+        if ( ring_0(&c.nat->user_regs) )
+            c.nat->gs_base_kernel = sreg.base;
+        else
+            c.nat->gs_base_user = sreg.base;
+#endif

If you do anything like this, do it completely please (i.e. fill all three base address fields instead of just one).

Jan

Quoted 8 lines
xen/arch/x86/domctl.c +0 -0
     }
     else
     {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
Quoted 2 lines · Jan Beulich
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On 21.04.12 at 02:58, Aravindh Puthiyaparambil <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines

Add GS base to the HVM VCPU context returned by xc_vcpu_getcontext()

Quoted 17 lines

xen/arch/x86/domctl.c Fri Apr 20 17:55:49 2012 -0700 void arch_get_info_guest(struct vcpu *v, · line 1600

Quoted 13 lines

diff -r e62ab14d44af -r babbb3e0f4d3 xen/arch/x86/domctl.c

xen/arch/x86/domctl.c Fri Apr 20 17:55:49 2012 -0700 renamed from xen/arch/x86/domctl.c Fri Apr 20 11:36:02 2012 -0700 +6 -0
@@ -1592,6 +1592,12 @@ void arch_get_info_guest(struct vcpu *v,
         c.nat->user_regs.fs = sreg.sel;
         hvm_get_segment_register(v, x86_seg_gs, &sreg);
         c.nat->user_regs.gs = sreg.sel;
+#ifdef __x86_64__
+        if ( ring_0(&c.nat->user_regs) )
+            c.nat->gs_base_kernel = sreg.base;
+        else
+            c.nat->gs_base_user = sreg.base;
+#endif

If you do anything like this, do it completely please (i.e. fill all three base address fields instead of just one).

Sure. I was not sure if it was ok to add fields to the vcpu context structure which is why I didn't do it across the board. I will do so and resubmit.

Aravindh

Quoted 13 lines

Jan

Quoted 8 lines
xen/arch/x86/domctl.c Fri Apr 20 17:55:49 2012 -0700 renamed from xen/arch/x86/domctl.c Fri Apr 20 11:36:02 2012 -0700 +0 -0
     }
     else
     {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 27 lines
Quoted 1 line
Quoted 1 line · Aravindh Puthiyaparambil
Quoted 2 lines · Jan Beulich
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On 21.04.12 at 02:58, Aravindh Puthiyaparambil <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines

Add GS base to the HVM VCPU context returned by xc_vcpu_getcontext()

Quoted 17 lines

xen/arch/x86/domctl.c Fri Apr 20 17:55:49 2012 -0700 void arch_get_info_guest(struct vcpu *v, · line 1600

Quoted 13 lines

diff -r e62ab14d44af -r babbb3e0f4d3 xen/arch/x86/domctl.c

xen/arch/x86/domctl.c Fri Apr 20 17:55:49 2012 -0700 renamed from xen/arch/x86/domctl.c Fri Apr 20 11:36:02 2012 -0700 +6 -0
@@ -1592,6 +1592,12 @@ void arch_get_info_guest(struct vcpu *v,
         c.nat->user_regs.fs = sreg.sel;
         hvm_get_segment_register(v, x86_seg_gs, &sreg);
         c.nat->user_regs.gs = sreg.sel;
+#ifdef __x86_64__
+        if ( ring_0(&c.nat->user_regs) )
+            c.nat->gs_base_kernel = sreg.base;
+        else
+            c.nat->gs_base_user = sreg.base;
+#endif

If you do anything like this, do it completely please (i.e. fill all three base address fields instead of just one).

Quoted 3 lines

Sure. I was not sure if it was ok to add fields to the vcpu context structure which is why I didn't do it across the board. I will do so and resubmit.

I don't see what fields you would need to add.

Jan

#4 lore raw
Quoted 27 lines · Jan Beulich
Quoted 27 lines
Quoted 1 line
Quoted 1 line · Aravindh Puthiyaparambil
Quoted 2 lines · Jan Beulich
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On 21.04.12 at 02:58, Aravindh Puthiyaparambil <[email protected]>

Quoted 21 lines · wrote:
Quoted 8 lines

Add GS base to the HVM VCPU context returned by xc_vcpu_getcontext()

diff -r e62ab14d44af -r babbb3e0f4d3 xen/arch/x86/domctl.c

xen/arch/x86/domctl.c   Fri Apr 20 17:55:49 2012 -0700 void arch_get_info_guest(struct vcpu *v, · line 1600

Quoted 9 lines
xen/arch/x86/domctl.c   Fri Apr 20 17:55:49 2012 -0700 renamed from xen/arch/x86/domctl.c   Fri Apr 20 11:36:02 2012 -0700 +6 -0
@@ -1592,6 +1592,12 @@ void arch_get_info_guest(struct vcpu *v,
          c.nat->user_regs.fs = sreg.sel;
          hvm_get_segment_register(v, x86_seg_gs, &sreg);
          c.nat->user_regs.gs = sreg.sel;
+#ifdef __x86_64__
+        if ( ring_0(&c.nat->user_regs) )
+            c.nat->gs_base_kernel = sreg.base;
+        else
+            c.nat->gs_base_user = sreg.base;
+#endif

If you do anything like this, do it completely please (i.e. fill all three base address fields instead of just one).

Quoted 5 lines
Quoted 3 lines

Sure. I was not sure if it was ok to add fields to the vcpu context structure which is why I didn't do it across the board. I will do so and resubmit.

I don't see what fields you would need to add.

Don't I need to add ss_base, cs_base, es_base, ds_base to vcpu_guest_context? I am assuming both 32-bit and 64-bit cases.

Aravindh

#5 lore raw
Quoted 11 lines · Aravindh Puthiyaparambil
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

xen/arch/x86/domctl.c void arch_get_info_guest(struct vcpu *v, · line 1600

Quoted 6 lines
xen/arch/x86/domctl.c +6 -0
+#ifdef __x86_64__
+        if ( ring_0(&c.nat->user_regs) )
+            c.nat->gs_base_kernel = sreg.base;
+        else
+            c.nat->gs_base_user = sreg.base;
+#endif

If you do anything like this, do it completely please (i.e. fill all three base address fields instead of just one).

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Sure. I was not sure if it was ok to add fields to the vcpu context structure which is why I didn't do it across the board. I will do so and resubmit.

I don't see what fields you would need to add.

Don't I need to add ss_base, cs_base, es_base, ds_base to vcpu_guest_context? I am assuming both 32-bit and 64-bit cases.

Only the existing (x86_64-only) fs_base, gs_base_kernel, gs_base_user fields need be filled in. All other base addresses are zero in 64-bit mode, and in 32-bit mode the base addresses are obtained from the GDT/LDT when the segment register is loaded, and so do not need to be stored in the vcpu_context.

-- Keir

Quoted 6 lines

Aravindh

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw
Quoted 20 lines · Keir Fraser
Quoted 17 lines · Aravindh Puthiyaparambil
Quoted 16 lines
Quoted 11 lines
Quoted 10 lines

xen/arch/x86/domctl.c void arch_get_info_guest(struct vcpu *v, · line 1600

Quoted 6 lines
xen/arch/x86/domctl.c +6 -0
+#ifdef __x86_64__
+        if ( ring_0(&c.nat->user_regs) )
+            c.nat->gs_base_kernel = sreg.base;
+        else
+            c.nat->gs_base_user = sreg.base;
+#endif

If you do anything like this, do it completely please (i.e. fill all three base address fields instead of just one).

Quoted 3 lines

Sure. I was not sure if it was ok to add fields to the vcpu context structure which is why I didn't do it across the board. I will do so and resubmit.

I don't see what fields you would need to add.

Quoted 8 lines
Quoted 2 lines

Don't I need to add ss_base, cs_base, es_base, ds_base to vcpu_guest_context? I am assuming both 32-bit and 64-bit cases.

Only the existing (x86_64-only) fs_base, gs_base_kernel, gs_base_user fields need be filled in. All other base addresses are zero in 64-bit mode, and in 32-bit mode the base addresses are obtained from the GDT/LDT when the segment register is loaded, and so do not need to be stored in the vcpu_context.

Understood. I will resubmit with fs_based filled in.

Aravindh

Quoted 10 lines

 -- Keir

Quoted 6 lines

Aravindh

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel