xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Lan Tianyu <tianyu.lan@intel.com>,
	Sergey Dyasli <sergey.dyasli@citrix.com>,
	Kevin Tian <kevin.tian@intel.com>,
	StefanoStabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>, Juergen Gross <jgross@suse.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	TimDeegan <tim@xen.org>, Anshul Makkar <anshul.makkar@citrix.com>,
	IanJackson <ian.jackson@eu.citrix.com>,
	Xen-devel <xen-devel@lists.xen.org>,
	Euan Harris <euan.harris@citrix.com>,
	JoaoMartins <joao.m.martins@oracle.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	PaulC Lai <paul.c.lai@intel.com>
Subject: Re: DESIGN: CPUID part 3
Date: Mon, 12 Jun 2017 15:02:03 +0100	[thread overview]
Message-ID: <607f9093-05ca-c321-8702-cc3bd1795425@citrix.com> (raw)
In-Reply-To: <593EB668020000780016201D@prv-mh.provo.novell.com>

On 12/06/17 14:42, Jan Beulich wrote:
>>>> On 12.06.17 at 15:36, <andrew.cooper3@citrix.com> wrote:
>> On 12/06/17 14:29, Jan Beulich wrote:
>>>>>> On 12.06.17 at 15:07, <andrew.cooper3@citrix.com> wrote:
>>>> On 08/06/17 14:47, Jan Beulich wrote:
>>>>>>>> On 08.06.17 at 15:12, <andrew.cooper3@citrix.com> wrote:
>>>>>> The `disable_migrate` field shall be dropped.  The concept of migrateability
>>>>>> is not boolean; it is a large spectrum, all of which needs to be managed by
>>>>>> the toolstack.  The simple case is picking the common subset of features
>>>>>> between the source and destination.  This becomes more complicated e.g. if 
>> the
>>>>>> guest uses LBR/LER, at which point the toolstack needs to consider hardware
>>>>>> with the same LBR/LER format in addition to just the plain features.
>>>>> Not sure about this - by intercepting the MSR accesses to the involved
>>>>> MSRs, it would be possible to mimic the LBR/LER format expected by
>>>>> the guest even if different from that of the host.
>>>> LER yes, but how would you emulate LBR?
>>>>
>>>> You could set DBG_CTL.BTF/EFLAGS.TF and intercept #DB, but this would be
>>>> visible to the guest via pushf/popf.  It would also interfere with a
>>>> guest trying to single-step itself.
>>> I don't understand: LBR is an MSR just like LER, and hence the
>>> guest can't avoid using RDMSR to read its contents. If we
>>> intercept that read, we can give them whatever format is
>>> needed, without a need to intercept anything else. But maybe
>>> I'm not seeing what you're getting at.
>> To emulate it, we need to sample state at the point that the last
>> exception or branch happened.
>>
>> You can't reverse the current value in hardware at the point of the
>> guest reading the LBR MSR to the value it should have been under a
>> different format.
> Aren't we talking about correct (or at least unproblematic) top
> bits of the value only? In which case the actual address bits
> can be taken as is, and only the top bits need adjustment.

I'm completely confused.

My original statement was "if the guest uses LBR/LER, then migration
needs to be restricted to hardware with an identical LBR format".

You countered that, saying we could emulate LBR/LER as an alternative. 
The implication here is that we could alter the LBR format via
emulation, by cooking the value observed when the guest reads the LBR MSRs.

For the record, the formats are:

Software should query an architectural MSR IA32_PERF_CAPABILITIES[5:0]
about the format of the address that is stored in the LBR stack. Four
formats are defined by the following encoding:
* 000000B (32-bit record format) — Stores 32-bit offset in current CS of
respective source/destination,
* 000001B (64-bit LIP record format) — Stores 64-bit linear address of
respective source/destination,
* 000010B (64-bit EIP record format) — Stores 64-bit offset (effective
address) of respective source/destination.
* 000011B (64-bit EIP record format) and Flags — Stores 64-bit offset
(effective address) of respective source/destination. Misprediction info
is reported in the upper bit of 'FROM' registers in the LBR stack. See
LBR stack details below for flag support and definition.
* 000100B (64-bit EIP record format), Flags and TSX — Stores 64-bit
offset (effective address) of respective source/destination.
Misprediction and TSX info are reported in the upper bits of ‘FROM’
registers in the LBR stack.
* 000101B (64-bit EIP record format), Flags, TSX, LBR_INFO — Stores
64-bit offset (effective address) of respective source/destination.
Misprediction, TSX, and elapsed cycles since the last LBR update are
reported in the LBR_INFO MSR stack.
* 000110B (64-bit EIP record format), Flags, Cycles — Stores 64-bit
linear address (CS.Base + effective address) of respective
source/destination. Misprediction info is reported in the upper bits of
17-16 Vol. 3BDEBUG, BRANCH PROFILE, TSC, AND RESOURCE MONITORING
FEATURES 'FROM' registers in the LBR stack. Elapsed cycles since the
last LBR update are reported in the upper 16 bits of the 'TO' registers
in the LBR stack (see Section 17.6).

In general, I don't see any sensible way of being able to convert
between these formats at the point of an RDMSR.

~Andrew

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

  reply	other threads:[~2017-06-12 14:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-08 13:12 DESIGN: CPUID part 3 Andrew Cooper
2017-06-08 13:47 ` Jan Beulich
2017-06-12 13:07   ` Andrew Cooper
2017-06-12 13:29     ` Jan Beulich
2017-06-12 13:36       ` Andrew Cooper
2017-06-12 13:42         ` Jan Beulich
2017-06-12 14:02           ` Andrew Cooper [this message]
2017-06-12 14:18             ` Jan Beulich
2017-06-09 12:24 ` Anshul Makkar
2017-06-12 13:21   ` Andrew Cooper
2017-07-04 14:55 ` DESIGN v2: " Andrew Cooper
2017-07-05  9:46   ` Joao Martins
2017-07-05 10:32     ` Joao Martins
2017-07-05 11:16     ` Andrew Cooper
2017-07-05 13:22       ` Joao Martins
2017-07-31 19:49         ` Konrad Rzeszutek Wilk
2017-08-01 18:34           ` Andrew Cooper
2017-08-02 10:34             ` Joao Martins
2017-08-03  2:55               ` Dario Faggioli

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=607f9093-05ca-c321-8702-cc3bd1795425@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=anshul.makkar@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=euan.harris@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jgross@suse.com \
    --cc=joao.m.martins@oracle.com \
    --cc=kevin.tian@intel.com \
    --cc=paul.c.lai@intel.com \
    --cc=sergey.dyasli@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=tianyu.lan@intel.com \
    --cc=tim@xen.org \
    --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).