From: Sean Christopherson <seanjc@google.com>
To: David Woodhouse <dwmw@amazon.co.uk>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"hpa@zytor.com" <hpa@zytor.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"bp@alien8.de" <bp@alien8.de>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"paul@xen.org" <paul@xen.org>
Subject: Re: [RFC PATCH] KVM: x86: Generate guest PV wall clock info from a single TSC read
Date: Fri, 29 Sep 2023 15:25:30 +0000 [thread overview]
Message-ID: <ZRbqyCXSClhkLttk@google.com> (raw)
In-Reply-To: <2f1a1bf1b359ff6164b91a06a6f9ed03f2d6204d.camel@amazon.co.uk>
On Fri, Sep 29, 2023, Woodhouse, David wrote:
> Poking around at various places which calculate the time "now" in some
> clock domain... then maybe get preempted for a while... and then
> compare that with the time "now" in the same or another clock domain.
>
> This one with its "ktime_get_real_ns() - get_kvmclock_ns(kvm);" seemed
> like perfect low-hanging fruit to start with.
...
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 04b57a336b34..0ec989bb61a1 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -2317,14 +2317,9 @@ static void kvm_write_wall_clock(struct kvm *kvm, gpa_t wall_clock, int sec_hi_o
> if (kvm_write_guest(kvm, wall_clock, &version, sizeof(version)))
> return;
>
> - /*
> - * The guest calculates current wall clock time by adding
> - * system time (updated by kvm_guest_time_update below) to the
> - * wall clock specified here. We do the reverse here.
> - */
> - wall_nsec = ktime_get_real_ns() - get_kvmclock_ns(kvm);
> + wall_nsec = kvm_get_wall_clock_epoch(kvm);
Possibly silly question: why can't preemption simply be disabled for the duration
of the sensitive calculation?
next parent reply other threads:[~2023-09-29 15:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2f1a1bf1b359ff6164b91a06a6f9ed03f2d6204d.camel@amazon.co.uk>
2023-09-29 15:25 ` Sean Christopherson [this message]
2023-09-29 21:27 ` [RFC PATCH] KVM: x86: Generate guest PV wall clock info from a single TSC read David Woodhouse
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=ZRbqyCXSClhkLttk@google.com \
--to=seanjc@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=dwmw@amazon.co.uk \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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 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.