From: Avi Kivity <avi@redhat.com>
To: "Liu, Jinsong" <jinsong.liu@intel.com>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [Qemu-devel] [PATCH] KVM: emulate lapic tsc deadline timer for hvm
Date: Tue, 06 Sep 2011 14:26:41 +0300 [thread overview]
Message-ID: <4E660371.2060201@redhat.com> (raw)
In-Reply-To: <BC00F5384FCFC9499AF06F92E8B78A9E24B86873B0@shsmsx502.ccr.corp.intel.com>
On 09/06/2011 02:18 PM, Liu, Jinsong wrote:
> >> struct x86_instruction_info *info,
> >> enum x86_intercept_stage stage);
> >> + u64 (*guest_to_host_tsc)(u64 guest_tsc);
> >> };
> >
> > Please put this near the other tsc functions. Add a comment
> > explaining what value is returned under nested virtualization.
>
> OK
>
> >
> > Please add the svm callback implementation.
> >
>
> It's un-necessary to add svm callback.
> AMD lapic timer has no tsc deadline mode, svm callback would be an unused dummy function.
It's a generic function, at the moment it's only used by tsc deadline
timer but it could be used tomorrow for something else.
> >> + u64 tsc_now, tsc_target, tsc_delta, nsec;
> >> +
> >> + if (!apic->lapic_timer.tscdeadline)
> >> + return;
> >> +
> >> + tsc_target = kvm_x86_ops->
> >> + guest_to_host_tsc(apic->lapic_timer.tscdeadline);
> >> + rdtscll(tsc_now); + tsc_delta = tsc_target - tsc_now;
> >
> > This only works if we have a constant tsc, that's not true for large
>
> Agree with Kevin, variable tsc exposes tricky issues to time virtualization in general.
> At some very old processors it maybe variable tsc, but all recent processors work on constant tsc regardless of Px and Cx.
> For lapic tsc deadline timer capacibility cpu, I think it works on constant tsc otherwise os has no way to expect next absolute timepoint.
Well, we need something better here. It's not just old cpus, it's also
large multi-board machines.
> >> +u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu) +{
> >> + struct kvm_lapic *apic = vcpu->arch.apic;
> >> +
> >> + if (apic_lvtt_oneshot(apic) || apic_lvtt_period(apic))
> >> + return 0;
> >
> > Why?
> >
>
> Intel SDM define such hardware behavior (10.5.4.1):
> 'In other timer modes (LVT bit 18 = 0), the IA32_TSC_DEADLINE MSR reads zero and writes are ignored.'
Ok.
>
> >
> >> /*
> >> * Empty call-back. Needs to be implemented when VMX enables the
> >> SET_TSC_KHZ
> >> * ioctl. In this case the call-back should update internal vmx
> >> state to make @@ -6270,6 +6278,16 @@ static void
> >> vmx_cpuid_update(struct kvm_vcpu *vcpu) } }
> >> }
> >> +
> >> + /*
> >> + * Emulate Intel lapic tsc deadline timer even if host not support
> >> it. + * Open CPUID.1.ECX[24] and use bit17/18 as timer mode mask.
> >> + */ + best = kvm_find_cpuid_entry(vcpu, 1, 0);
> >> + if (best) {
> >> + best->ecx |= bit(X86_FEATURE_TSC_DEADLINE_TIMER);
> >> + vcpu->arch.apic->lapic_timer.timer_mode_mask = (3<< 17); + }
> >> }
> >
> > Should be in common code; there is nothing vmx specific about it
> > (although it is Intel specific at present).
>
> AMD lapic timer has no tsc deadline mode and so cpuid.1.ecx[24], and its timer_mode_mask should be 1<< 17 (AMD APM 16.4.1.)
> It would be more safe to handle cpuid and lapic timer_mode_mask in arch code.
>
Again, vmx.c is NOT about Intel specific code. It is about vmx-specific
code - programming vmx via VMREAD and VMWRITE.
(not to mention that we don't really need host cpu support for this - we
can emulate tsc deadline mode without host cpu support at all, as this
patchset shows).
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2011-09-06 11:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-17 4:19 [Qemu-devel] [PATCH] KVM: emulate lapic tsc deadline timer for hvm Liu, Jinsong
2011-08-22 9:18 ` Avi Kivity
2011-08-23 10:47 ` Marcelo Tosatti
2011-08-29 6:47 ` Tian, Kevin
2011-09-06 11:21 ` Liu, Jinsong
2011-09-08 17:12 ` Liu, Jinsong
2011-09-09 12:56 ` Marcelo Tosatti
2011-09-09 18:11 ` Liu, Jinsong
2011-09-09 18:36 ` Marcelo Tosatti
2011-09-09 18:47 ` Liu, Jinsong
2011-09-09 18:21 ` Liu, Jinsong
2011-09-06 11:18 ` Liu, Jinsong
2011-09-06 11:26 ` Avi Kivity [this message]
2011-09-07 16:45 ` Liu, Jinsong
2011-09-07 17:06 ` Avi Kivity
2011-09-07 17:33 ` Liu, Jinsong
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=4E660371.2060201@redhat.com \
--to=avi@redhat.com \
--cc=jinsong.liu@intel.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).