From: Qing He <qing.he@intel.com>
To: Tim Deegan <Tim.Deegan@citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH 11/17] vmx: nest: L2 tsc
Date: Fri, 21 May 2010 00:07:18 +0800 [thread overview]
Message-ID: <20100520160718.GE21538@qhe2-db> (raw)
In-Reply-To: <20100520114716.GR4164@whitby.uk.xensource.com>
On Thu, 2010-05-20 at 19:47 +0800, Tim Deegan wrote:
> At 10:41 +0100 on 22 Apr (1271932883), Qing He wrote:
> > L2 TSC needs special handling, either rdtsc exiting is
> > turned on or off
>
> Looks OK to me, but I'm a bit behind on some of the recent changes to
> TSC handling.
I'm also behind TSC changes, I'll try to understand more about those
changes, maybe after version 2.
Thanks,
Qing
>
> Tim.
>
> > Signed-off-by: Qing He <qing.he@intel.com>
> >
> > ---
> > arch/x86/hvm/vmx/nest.c | 31 +++++++++++++++++++++++++++++++
> > arch/x86/hvm/vmx/vmx.c | 4 ++++
> > include/asm-x86/hvm/vmx/nest.h | 2 ++
> > 3 files changed, 37 insertions(+)
> >
> > diff -r 2f9ba6dbbe62 -r 2332586ff957 xen/arch/x86/hvm/vmx/nest.c
> > --- a/xen/arch/x86/hvm/vmx/nest.c Thu Apr 22 22:30:09 2010 +0800
> > +++ b/xen/arch/x86/hvm/vmx/nest.c Thu Apr 22 22:30:09 2010 +0800
> > @@ -533,6 +533,18 @@
> > * Nested VMX context switch
> > */
> >
> > +u64 vmx_nest_get_tsc_offset(struct vcpu *v)
> > +{
> > + u64 offset = 0;
> > + struct vmx_nest_struct *nest = &v->arch.hvm_vmx.nest;
> > +
> > + if ( __get_vvmcs(nest->vvmcs, CPU_BASED_VM_EXEC_CONTROL) &
> > + CPU_BASED_USE_TSC_OFFSETING )
> > + offset = __get_vvmcs(nest->vvmcs, TSC_OFFSET);
> > +
> > + return offset;
> > +}
> > +
> > static unsigned long vmcs_gstate_field[] = {
> > /* 16 BITS */
> > GUEST_ES_SELECTOR,
> > @@ -715,6 +727,8 @@
> > hvm_set_cr4(__get_vvmcs(nest->vvmcs, GUEST_CR4));
> > hvm_set_cr3(__get_vvmcs(nest->vvmcs, GUEST_CR3));
> >
> > + hvm_funcs.set_tsc_offset(v, v->arch.hvm_vcpu.cache_tsc_offset);
> > +
> > vvmcs_to_shadow(nest->vvmcs, VM_ENTRY_INTR_INFO);
> > vvmcs_to_shadow(nest->vvmcs, VM_ENTRY_EXCEPTION_ERROR_CODE);
> > vvmcs_to_shadow(nest->vvmcs, VM_ENTRY_INSTRUCTION_LEN);
> > @@ -837,6 +851,8 @@
> > hvm_set_cr4(__get_vvmcs(nest->vvmcs, HOST_CR4));
> > hvm_set_cr3(__get_vvmcs(nest->vvmcs, HOST_CR3));
> >
> > + hvm_funcs.set_tsc_offset(v, v->arch.hvm_vcpu.cache_tsc_offset);
> > +
> > __set_vvmcs(nest->vvmcs, VM_ENTRY_INTR_INFO, 0);
> > }
> >
> > @@ -1116,6 +1132,21 @@
> >
> > if ( control_bit_for_reason[i].bit & ctrl )
> > nest->vmexit_pending = 1;
> > + else if ( exit_reason == EXIT_REASON_RDTSC )
> > + {
> > + uint64_t tsc;
> > +
> > + /*
> > + * rdtsc can't be handled normally in the L0 handler
> > + * if L1 doesn't want it
> > + */
> > + tsc = hvm_get_guest_tsc(v);
> > + tsc += __get_vvmcs(nest->vvmcs, TSC_OFFSET);
> > + regs->eax = (uint32_t)tsc;
> > + regs->edx = (uint32_t)(tsc >> 32);
> > +
> > + bypass_l0 = 1;
> > + }
> >
> > break;
> > }
> > diff -r 2f9ba6dbbe62 -r 2332586ff957 xen/arch/x86/hvm/vmx/vmx.c
> > --- a/xen/arch/x86/hvm/vmx/vmx.c Thu Apr 22 22:30:09 2010 +0800
> > +++ b/xen/arch/x86/hvm/vmx/vmx.c Thu Apr 22 22:30:09 2010 +0800
> > @@ -974,6 +974,10 @@
> > static void vmx_set_tsc_offset(struct vcpu *v, u64 offset)
> > {
> > vmx_vmcs_enter(v);
> > +
> > + if ( v->arch.hvm_vcpu.in_nesting )
> > + offset += vmx_nest_get_tsc_offset(v);
> > +
> > __vmwrite(TSC_OFFSET, offset);
> > #if defined (__i386__)
> > __vmwrite(TSC_OFFSET_HIGH, offset >> 32);
> > diff -r 2f9ba6dbbe62 -r 2332586ff957 xen/include/asm-x86/hvm/vmx/nest.h
> > --- a/xen/include/asm-x86/hvm/vmx/nest.h Thu Apr 22 22:30:09 2010 +0800
> > +++ b/xen/include/asm-x86/hvm/vmx/nest.h Thu Apr 22 22:30:09 2010 +0800
> > @@ -69,6 +69,8 @@
> > unsigned long value);
> > void vmx_nest_update_exception_bitmap(struct vcpu *v, unsigned long value);
> >
> > +u64 vmx_nest_get_tsc_offset(struct vcpu *v);
> > +
> > void vmx_nest_idtv_handling(void);
> >
> > int vmx_nest_l2_vmexit_handler(struct cpu_user_regs *regs,
> >
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xensource.com
> > http://lists.xensource.com/xen-devel
>
> --
> Tim Deegan <Tim.Deegan@citrix.com>
> Principal Software Engineer, XenServer Engineering
> Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)
next prev parent reply other threads:[~2010-05-20 16:07 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-22 9:41 [PATCH 00/17][RFC] Nested virtualization for VMX Qing He
2010-04-22 9:41 ` [PATCH 01/17] vmx: nest: fix CR4.VME in update_guest_cr Qing He
2010-05-20 9:26 ` Tim Deegan
2010-05-20 9:36 ` Qing He
2010-04-22 9:41 ` [PATCH 02/17] vmx: nest: rename host_vmcs Qing He
2010-04-22 9:41 ` [PATCH 03/17] vmx: nest: wrapper for control update Qing He
2010-05-20 9:34 ` Tim Deegan
2010-05-20 9:46 ` Qing He
2010-05-20 12:57 ` Keir Fraser
2010-04-22 9:41 ` [PATCH 04/17] vmx: nest: domain and vcpu flags Qing He
2010-05-20 9:37 ` Tim Deegan
2010-05-20 9:51 ` Christoph Egger
2010-05-20 9:54 ` Qing He
2010-05-20 10:55 ` Tim Deegan
2010-05-20 12:53 ` Qing He
2010-05-20 14:06 ` Christoph Egger
2010-04-22 9:41 ` [PATCH 05/17] vmx: nest: nested control structure Qing He
2010-04-22 9:41 ` [PATCH 06/17] vmx: nest: virtual vmcs layout Qing He
2010-04-22 9:41 ` [PATCH 07/17] vmx: nest: handling VMX instruction exits Qing He
2010-05-20 10:53 ` Tim Deegan
2010-05-20 13:28 ` Qing He
2010-04-22 9:41 ` [PATCH 08/17] vmx: nest: L1 <-> L2 context switch Qing He
2010-05-20 11:11 ` Tim Deegan
2010-05-20 13:49 ` Qing He
2010-05-21 9:19 ` Tim Deegan
2010-05-21 10:31 ` Qing He
2010-05-25 15:27 ` Tim Deegan
2010-04-22 9:41 ` [PATCH 09/17] vmx: nest: interrupt Qing He
2010-05-20 11:21 ` Tim Deegan
2010-05-20 15:55 ` Qing He
2010-04-22 9:41 ` [PATCH 10/17] vmx: nest: VMExit handler in L2 Qing He
2010-05-20 11:44 ` Tim Deegan
2010-05-20 16:06 ` Qing He
2010-05-21 8:42 ` Tim Deegan
2010-05-21 10:35 ` Qing He
2010-05-25 15:34 ` Tim Deegan
2010-04-22 9:41 ` [PATCH 11/17] vmx: nest: L2 tsc Qing He
2010-05-20 11:47 ` Tim Deegan
2010-05-20 16:07 ` Qing He [this message]
2010-04-22 9:41 ` [PATCH 12/17] vmx: nest: CR0.TS and #NM Qing He
2010-04-22 9:41 ` [PATCH 13/17] vmx: nest: capability reporting MSRs Qing He
2010-05-20 11:52 ` Tim Deegan
2010-04-22 9:41 ` [PATCH 14/17] vmx: nest: enable virtual VMX Qing He
2010-04-22 9:41 ` [PATCH 15/17] vmx: nest: virtual ept for nested Qing He
2010-05-20 12:21 ` Tim Deegan
2010-05-21 10:24 ` Qing He
2010-05-25 16:02 ` Tim Deegan
2010-04-22 9:41 ` [PATCH 16/17] vmx: nest: hvmtrace " Qing He
2010-04-22 9:41 ` [PATCH 17/17] tools: nest: allow enabling nesting Qing He
2010-04-22 10:15 ` [PATCH 00/17][RFC] Nested virtualization for VMX Christoph Egger
2010-04-23 10:10 ` He, Qing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100520160718.GE21538@qhe2-db \
--to=qing.he@intel.com \
--cc=Tim.Deegan@citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).