From: Maxim Levitsky <mlevitsk@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <sean.j.christopherson@intel.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Jim Mattson <jmattson@google.com>,
Wanpeng Li <wanpengli@tencent.com>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Thomas Gleixner <tglx@linutronix.de>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>, Joerg Roedel <joro@8bytes.org>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH v2 1/1] KVM: x86: fix MSR_IA32_TSC read for nested migration
Date: Tue, 22 Sep 2020 17:50:36 +0300 [thread overview]
Message-ID: <7db1383cc9d40f76a02076c3b86cf832fd7463cc.camel@redhat.com> (raw)
In-Reply-To: <de9411ce-aa83-77c8-b2ae-a3873250a0b1@redhat.com>
On Tue, 2020-09-22 at 14:50 +0200, Paolo Bonzini wrote:
> On 21/09/20 18:23, Sean Christopherson wrote:
> > Avoid "should" in code comments and describe what the code is doing, not what
> > it should be doing. The only exception for this is when the code has a known
> > flaw/gap, e.g. "KVM should do X, but because of Y, KVM actually does Z".
> >
> > > + * return it's real L1 value so that its restore will be correct.
> > s/it's/its
> >
> > Perhaps add "unconditionally" somewhere, since arch.tsc_offset can also contain
> > the L1 value. E.g.
> >
> > * Unconditionally return L1's TSC offset on userspace reads
> > * so that userspace reads and writes always operate on L1's
> > * offset, e.g. to ensure deterministic behavior for migration.
> > */
> >
>
> Technically the host need not restore MSR_IA32_TSC at all. This follows
> the idea of the discussion with Oliver Upton about transmitting the
> state of the kvmclock heuristics to userspace, which include a (TSC,
> CLOCK_MONOTONIC) pair to transmit the offset to the destination. All
> that needs to be an L1 value is then the TSC value in that pair.
>
> I'm a bit torn over this patch. On one hand it's an easy solution, on
> the other hand it's... just wrong if KVM_GET_MSR is used for e.g.
> debugging the guest.
Could you explain why though? After my patch, the KVM_GET_MSR will consistently
read the L1 TSC, just like all other MSRs as I explained. I guess for debugging,
this should work?
The fact that TSC reads with the guest offset is a nice exception made for the guests,
that insist on reading this msr without inteception and not using rdtsc.
Best regards,
Maxim Levitsky
>
> I'll talk to Maxim and see if he can work on the kvmclock migration stuff.
>
> Paolo
>
next prev parent reply other threads:[~2020-09-22 14:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-21 10:38 [PATCH v2 0/1] KVM: correctly restore the TSC value on nested migration Maxim Levitsky
2020-09-21 10:38 ` [PATCH v2 1/1] KVM: x86: fix MSR_IA32_TSC read for " Maxim Levitsky
[not found] ` <20200921162326.GB23989@linux.intel.com>
2020-09-22 12:50 ` Paolo Bonzini
2020-09-22 14:50 ` Maxim Levitsky [this message]
2020-09-22 15:39 ` Maxim Levitsky
2020-09-22 16:39 ` Paolo Bonzini
2020-09-24 17:33 ` Paolo Bonzini
2020-09-30 14:37 ` Maxim Levitsky
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=7db1383cc9d40f76a02076c3b86cf832fd7463cc.camel@redhat.com \
--to=mlevitsk@redhat.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=sean.j.christopherson@intel.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox