xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: "Kevin Tian" <kevin.tian@intel.com>,
	"Jun Nakajima" <jun.nakajima@intel.com>,
	Xen-devel <xen-devel@lists.xen.org>,
	"Jan Beulich" <JBeulich@suse.com>,
	"Suravee Suthikulpanit" <suravee.suthikulpanit@amd.com>,
	"Boris Ostrovsky" <boris.ostrovsky@oracle.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [PATCH 5/5] x86: Rework MSR_TSC_AUX handling from scratch.
Date: Tue, 20 Feb 2018 17:42:06 +0000	[thread overview]
Message-ID: <03ceb0f6-6a2e-7e4c-b3f0-d10ecf211ece@citrix.com> (raw)
In-Reply-To: <20180220170344.s5lyrsi5t6yotllv@citrix.com>

On 20/02/18 17:03, Wei Liu wrote:
> On Tue, Feb 20, 2018 at 11:58:43AM +0000, Andrew Cooper wrote:
>> There are many problems with MSR_TSC_AUX handling.
>>
>> To being with, the RDPID instruction reads MSR_TSC_AUX, but it is only the
>      ^
>      begin
>
>> RDTSCP feature which enumerates the MSR.  Therefore, RDPID functionally
>> depends on RDTSCP.
>>
>> For PV guests, we hide RDTSCP but advertise RDPID.  We also silently drop
>> writes to MSR_TSC_AUX, which is very antisocial.  Therefore, enable RDTSCP for
>> PV guests, which in turn allows RDPID to work.
>>
>> To support RDTSCP properly for PV guests, the MSR_TSC_AUX handling is moved
>> into the generic MSR policy infrastructure, and becomes common.  One
>> improvement is that we will now reject invalid values, rather than silently
>> truncating an accepting them.  This also causes the emulator to reject RDTSCP
>              ^
>              and
>
>> for guests without the features.
>>
>>  
> [...]
>> @@ -1284,7 +1285,18 @@ long arch_do_domctl(
>>                  for ( j = 0; j < ARRAY_SIZE(msrs_to_send); ++j )
>>                  {
>>                      uint64_t val;
>> -                    int rc = guest_rdmsr(v, msrs_to_send[j], &val);
>> +                    int rc;
>> +
>> +                    /*
>> +                     * Skip MSR_TSC_AUX if using TSC_MODE_PVRDTSCP.  In this
>> +                     * case, the MSR is read-only, and should be rejected if
>> +                     * seen on the restore side.
>> +                     */
>> +                    if ( msrs_to_send[j] == MSR_TSC_AUX &&
>> +                         d->arch.tsc_mode == TSC_MODE_PVRDTSCP )
>> +                        continue;
> Shouldn't we increment incarnation and send it over to the remote end?
> Or send the original value and let the remote increments it?

incarnation, and its increments, is handled in tsc_set_info(), which is
keyed off the TSC_INFO record in the migration stream.  That side of
things "already works" (FSVO "works").

The check here is to cause us to skip everything to do with migrating
MSR_TSC_AUX if we think the TSC code is responsible for the value.

> Frankly I'm not sure how guest is supposed to use that value, but
> letting the receiving end restart at 0, which can end up using the same
> incarnation as before seems conceptually wrong to me. The more so you
> mention a lot of migration's in your previous patches.

I don't understand what thought and planning lead to TSC_MODE_PVRDTSCP.

From an implementation side of things, it was also responsible for
introducing a binary incompatibility into the migration stream between
3.3 and 3.4 which caused sporadic loss of interrupts on migrate, and was
sufficiently complicated to track down that it only got fixed in 4.2 
(c/s 620ce29a2d45, but not that that change is an accurate reflection of
how much stress and effort went into tracking the issue down).

> This is not disagreeing with the point that IA32_TSC_AUX should be
> read-only for PV guest.

Any guest running with TSC_MODE_PVRDTSCP.  It supposedly works for HVM
guests as well.

> And +1 for the unification of HVM and PV code for handling this.

An observant person might notice that all MSR handing is starting to
become common, and this might be following suite from CPUID a few
release ago.  This totally isn't on purpose...

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-02-20 17:42 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20 11:58 [RFC PATCH 0/5] x86: Multiple fixes to MSR_TSC_AUX and RDTSCP handling for guests Andrew Cooper
2018-02-20 11:58 ` [PATCH 1/5] x86/hvm: Don't shadow the domain parameter in hvm_save_cpu_msrs() Andrew Cooper
2018-02-20 14:54   ` Roger Pau Monné
2018-02-20 15:12   ` Wei Liu
2018-02-23 13:53   ` Jan Beulich
2018-02-20 11:58 ` [PATCH 2/5] x86/pv: Avoid leaking other guests' MSR_TSC_AUX values into PV context Andrew Cooper
2018-02-20 15:22   ` Wei Liu
2018-02-20 15:26     ` Andrew Cooper
2018-02-20 15:32       ` Wei Liu
2018-02-20 15:49   ` Roger Pau Monné
2018-02-23 14:04   ` Jan Beulich
2018-02-23 14:22     ` Andrew Cooper
2018-02-23 15:09       ` Jan Beulich
2018-02-26 11:25   ` Jan Beulich
2018-02-26 19:11     ` [ping] " Andrew Cooper
2018-02-27  5:38       ` Tian, Kevin
2018-02-26 19:52   ` Boris Ostrovsky
2018-02-20 11:58 ` [PATCH 3/5] x86/time: Rework pv_soft_rdtsc() to aid further cleanup Andrew Cooper
2018-02-20 15:32   ` Wei Liu
2018-02-20 16:04   ` Roger Pau Monné
2018-02-20 16:07     ` Andrew Cooper
2018-02-23 14:38   ` Jan Beulich
2018-02-20 11:58 ` [PATCH 4/5] x86/pv: Remove deferred RDTSC{, P} handling in pv_emulate_privileged_op() Andrew Cooper
2018-02-20 16:08   ` Wei Liu
2018-02-20 16:28   ` Roger Pau Monné
2018-02-20 16:37     ` Andrew Cooper
2018-02-20 17:40       ` Roger Pau Monné
2018-02-23 14:40   ` Jan Beulich
2018-02-20 11:58 ` [PATCH 5/5] x86: Rework MSR_TSC_AUX handling from scratch Andrew Cooper
2018-02-20 17:03   ` Wei Liu
2018-02-20 17:42     ` Andrew Cooper [this message]
2018-02-21 11:08       ` Wei Liu
2018-02-20 17:35   ` Roger Pau Monné
2018-02-20 18:28     ` Andrew Cooper
2018-02-21 10:13       ` Roger Pau Monné
2018-02-21 11:36   ` [PATCH v2 " Andrew Cooper
2018-02-21 12:06     ` Wei Liu
2018-02-21 13:04     ` Roger Pau Monné
2018-02-23 15:05     ` Jan Beulich
2018-02-23 15:51       ` Andrew Cooper
2018-02-26 11:30         ` Jan Beulich
2018-02-26 19:12 ` [RFC PATCH 0/5] x86: Multiple fixes to MSR_TSC_AUX and RDTSCP handling for guests Andrew Cooper
2018-02-26 19:44   ` Boris Ostrovsky
2018-02-26 23:30     ` Andrew Cooper
2018-03-09 18:05       ` Boris Ostrovsky
2018-03-09 18:41         ` Andrew Cooper
2018-03-09 19:10           ` Boris Ostrovsky

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=03ceb0f6-6a2e-7e4c-b3f0-d10ecf211ece@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=roger.pau@citrix.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.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).