Aravindh Puthiyaparambil
2012-Apr-21 00:58 UTC
[PATCH] xen: Add GS base to HVM VCPU context
Add GS base to the HVM VCPU context returned by xc_vcpu_getcontext() Signed-off-by: Aravindh Puthiyaparambil <aravindh@virtuata.com> diff -r e62ab14d44af -r babbb3e0f4d3 xen/arch/x86/domctl.c --- a/xen/arch/x86/domctl.c Fri Apr 20 11:36:02 2012 -0700 +++ b/xen/arch/x86/domctl.c Fri Apr 20 17:55:49 2012 -0700 @@ -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 {
>>> On 21.04.12 at 02:58, Aravindh Puthiyaparambil <aravindh@virtuata.com> wrote: > Add GS base to the HVM VCPU context returned by xc_vcpu_getcontext() > > Signed-off-by: Aravindh Puthiyaparambil <aravindh@virtuata.com> > > diff -r e62ab14d44af -r babbb3e0f4d3 xen/arch/x86/domctl.c > --- a/xen/arch/x86/domctl.c Fri Apr 20 11:36:02 2012 -0700 > +++ b/xen/arch/x86/domctl.c Fri Apr 20 17:55:49 2012 -0700 > @@ -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; > +#endifIf you do anything like this, do it completely please (i.e. fill all three base address fields instead of just one). Jan> } > else > { > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel
Aravindh Puthiyaparambil
2012-Apr-23 07:47 UTC
Re: [PATCH] xen: Add GS base to HVM VCPU context
On Apr 23, 2012 12:41 AM, "Jan Beulich" <JBeulich@suse.com> wrote:> > >>> On 21.04.12 at 02:58, Aravindh Puthiyaparambil <aravindh@virtuata.com>wrote:> > Add GS base to the HVM VCPU context returned by xc_vcpu_getcontext() > > > > Signed-off-by: Aravindh Puthiyaparambil <aravindh@virtuata.com> > > > > diff -r e62ab14d44af -r babbb3e0f4d3 xen/arch/x86/domctl.c > > --- a/xen/arch/x86/domctl.c Fri Apr 20 11:36:02 2012 -0700 > > +++ b/xen/arch/x86/domctl.c Fri Apr 20 17:55:49 2012 -0700 > > @@ -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> Jan > > > } > > else > > { > > > > _______________________________________________ > > Xen-devel mailing list > > Xen-devel@lists.xen.org > > http://lists.xen.org/xen-devel > > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
>>> On 23.04.12 at 09:47, Aravindh Puthiyaparambil <aravindh@virtuata.com> wrote: > On Apr 23, 2012 12:41 AM, "Jan Beulich" <JBeulich@suse.com> wrote: >> >> >>> On 21.04.12 at 02:58, Aravindh Puthiyaparambil <aravindh@virtuata.com> > wrote: >> > Add GS base to the HVM VCPU context returned by xc_vcpu_getcontext() >> > >> > Signed-off-by: Aravindh Puthiyaparambil <aravindh@virtuata.com> >> > >> > diff -r e62ab14d44af -r babbb3e0f4d3 xen/arch/x86/domctl.c >> > --- a/xen/arch/x86/domctl.c Fri Apr 20 11:36:02 2012 -0700 >> > +++ b/xen/arch/x86/domctl.c Fri Apr 20 17:55:49 2012 -0700 >> > @@ -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.I don''t see what fields you would need to add. Jan
Aravindh Puthiyaparambil
2012-Apr-23 19:11 UTC
Re: [PATCH] xen: Add GS base to HVM VCPU context
On Mon, Apr 23, 2012 at 12:53 AM, Jan Beulich <JBeulich@suse.com> wrote:>>>> On 23.04.12 at 09:47, Aravindh Puthiyaparambil <aravindh@virtuata.com> wrote: >> On Apr 23, 2012 12:41 AM, "Jan Beulich" <JBeulich@suse.com> wrote: >>> >>> >>> On 21.04.12 at 02:58, Aravindh Puthiyaparambil <aravindh@virtuata.com> >> wrote: >>> > Add GS base to the HVM VCPU context returned by xc_vcpu_getcontext() >>> > >>> > Signed-off-by: Aravindh Puthiyaparambil <aravindh@virtuata.com> >>> > >>> > diff -r e62ab14d44af -r babbb3e0f4d3 xen/arch/x86/domctl.c >>> > --- a/xen/arch/x86/domctl.c Fri Apr 20 11:36:02 2012 -0700 >>> > +++ b/xen/arch/x86/domctl.c Fri Apr 20 17:55:49 2012 -0700 >>> > @@ -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. > > 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
On 23/04/2012 20:11, "Aravindh Puthiyaparambil" <aravindh@virtuata.com> wrote:>>>>> +#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. >> >> 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> Aravindh > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel
Aravindh Puthiyaparambil
2012-Apr-23 22:11 UTC
Re: [PATCH] xen: Add GS base to HVM VCPU context
On Mon, Apr 23, 2012 at 2:04 PM, Keir Fraser <keir.xen@gmail.com> wrote:> On 23/04/2012 20:11, "Aravindh Puthiyaparambil" <aravindh@virtuata.com> > wrote: > >>>>>> +#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. >>> >>> 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.Understood. I will resubmit with fs_based filled in. Aravindh> -- Keir > >> Aravindh >> >> _______________________________________________ >> Xen-devel mailing list >> Xen-devel@lists.xen.org >> http://lists.xen.org/xen-devel > >
Seemingly Similar Threads
- [PATCH RFC v2] pvh: clearly specify used parameters in vcpu_guest_context
- [PATCH] mem_event: fix regression affecting CR3, CR4 memory events
- [PATCH v3] Fix the mistake of exception execution
- [PATCH 0/4] x86: XSA-67 follow-up
- [PATCH] [resend] xen-access: Check return values and clean up on errors during init