All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Suleiman Souhlal <suleiman@google.com>,
	rkrcmar@redhat.com, tglx@linutronix.de
Cc: john.stultz@linaro.org, sboyd@kernel.org,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	ssouhlal@freebsd.org, tfiga@chromium.org, vkuznets@redhat.com
Subject: Re: [RFC v2 2/2] x86/kvmclock: Introduce kvm-hostclock clocksource.
Date: Thu, 10 Oct 2019 12:55:27 +0200	[thread overview]
Message-ID: <2e6e5b14-fa68-67bd-1436-293659c8d92c@redhat.com> (raw)
In-Reply-To: <20191010073055.183635-3-suleiman@google.com>

On 10/10/19 09:30, Suleiman Souhlal wrote:
> +kvm_hostclock_enable(struct clocksource *cs)
> +{
> +	pv_timekeeper_enabled = 1;
> +
> +	old_vclock_mode = kvm_clock.archdata.vclock_mode;
> +	kvm_clock.archdata.vclock_mode = VCLOCK_TSC;
> +	return 0;
> +}
> +
> +static void
> +kvm_hostclock_disable(struct clocksource *cs)
> +{
> +	pv_timekeeper_enabled = 0;
> +	kvm_clock.archdata.vclock_mode = old_vclock_mode;
> +}
> +

Why do you poke at kvm_clock?  Instead you should add

	.archdata               = { .vclock_mode = VCLOCK_TSC },

to the kvm_hostclock declaration.

Please also check that the invariant TSC CPUID bit
CPUID[0x80000007].EDX[8] is set before enabling this feature.

Paolo

> +	pvtk = &pv_timekeeper;
> +	do {
> +		gen = pvtk_read_begin(pvtk);
> +		if (!(pv_timekeeper.flags & PVCLOCK_TIMEKEEPER_ENABLED))
> +			return;
> +
> +		pvclock_copy_into_read_base(pvtk, &tk->tkr_mono,
> +		    &pvtk->tkr_mono);
> +		pvclock_copy_into_read_base(pvtk, &tk->tkr_raw, &pvtk->tkr_raw);
> +
> +		tk->xtime_sec = pvtk->xtime_sec;
> +		tk->ktime_sec = pvtk->ktime_sec;
> +		tk->wall_to_monotonic.tv_sec = pvtk->wall_to_monotonic_sec;
> +		tk->wall_to_monotonic.tv_nsec = pvtk->wall_to_monotonic_nsec;
> +		tk->offs_real = pvtk->offs_real;
> +		tk->offs_boot = pvtk->offs_boot;
> +		tk->offs_tai = pvtk->offs_tai;
> +		tk->raw_sec = pvtk->raw_sec;
> +	} while (pvtk_read_retry(pvtk, gen));
> +}
> +

Should you write an "enabled value" (basically the flags) into pvtk as well?

> 
> +kvm_hostclock_init(void)
> +{
> +	unsigned long pa;
> +
> +	pa = __pa(&pv_timekeeper);
> +	wrmsrl(MSR_KVM_TIMEKEEPER_EN, pa);


As Vitaly said, a new CPUID bit must be defined in
Documentation/virt/kvm/cpuid.txt, and used here.  Also please make bit 0
an enable bit.

  parent reply	other threads:[~2019-10-10 10:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-10  7:30 [RFC v2 0/2] kvm: Use host timekeeping in guest Suleiman Souhlal
2019-10-10  7:30 ` [RFC v2 1/2] kvm: Mechanism to copy host timekeeping parameters into guest Suleiman Souhlal
2019-10-10  8:31   ` Vitaly Kuznetsov
2019-10-10 10:50   ` Paolo Bonzini
2019-10-10  7:30 ` [RFC v2 2/2] x86/kvmclock: Introduce kvm-hostclock clocksource Suleiman Souhlal
2019-10-10  8:37   ` Vitaly Kuznetsov
2019-10-10 10:55   ` Paolo Bonzini [this message]
2019-10-15  8:39     ` Suleiman Souhlal
2019-10-15  8:59       ` Paolo Bonzini
2019-10-10 10:39 ` [RFC v2 0/2] kvm: Use host timekeeping in guest Roman Kagan
2019-10-11 18:50   ` Konrad Rzeszutek Wilk
2019-10-15  5:08   ` Suleiman Souhlal
2019-10-10 10:43 ` Paolo Bonzini

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=2e6e5b14-fa68-67bd-1436-293659c8d92c@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=john.stultz@linaro.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rkrcmar@redhat.com \
    --cc=sboyd@kernel.org \
    --cc=ssouhlal@freebsd.org \
    --cc=suleiman@google.com \
    --cc=tfiga@chromium.org \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.