From: Peter Zijlstra <peterz@infradead.org>
To: Kyle Huey <me@kylehuey.com>
Cc: Keno Fischer <keno@juliacomputing.com>,
Andy Lutomirski <luto@amacapital.net>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Andi Kleen <andi@firstfloor.org>, Kyle Huey <khuey@kylehuey.com>,
Robert O'Callahan <robert@ocallahan.org>
Subject: Re: [RFC PATCH v2] x86/arch_prctl: Add ARCH_SET_XCR0 to set XCR0 per-thread
Date: Tue, 7 Apr 2020 14:33:48 +0200 [thread overview]
Message-ID: <20200407123348.GV20730@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <CAP045AohDoxZ+tvm+hBWWXgXz6N-z0+UWj--_o1AiVRubWYm6A@mail.gmail.com>
On Mon, Apr 06, 2020 at 09:53:40PM -0700, Kyle Huey wrote:
> On Mon, Apr 6, 2020 at 9:45 PM Keno Fischer <keno@juliacomputing.com> wrote:
> >
> > On Mon, Apr 6, 2020 at 11:58 PM Andy Lutomirski <luto@amacapital.net> wrote:
> > >
> > >
> > > > On Apr 6, 2020, at 6:13 PM, Keno Fischer <keno@juliacomputing.com> wrote:
> > > >
> > > > This is a follow-up to my from two-years ago [1].
> > >
> > > Your changelog is missing an explanation of why this is useful. Why would a user program want to change XCR0?
> >
> > Ah, sorry - I wasn't sure what the convention was around repeating the
> > applicable parts from the v1 changelog in this email.
> > Here's the description from the v1 patch:
> >
> > > The rr (http://rr-project.org/) debugger provides user space
> > > record-and-replay functionality by carefully controlling the process
> > > environment in order to ensure completely deterministic execution
> > > of recorded traces. The recently added ARCH_SET_CPUID arch_prctl
> > > allows rr to move traces across (Intel) machines, by allowing cpuid
> > > invocations to be reliably recorded and replayed. This works very
> > > well, with one catch: It is currently not possible to replay a
> > > recording from a machine supporting a smaller set of XCR0 state
> > > components on one supporting a larger set. This is because the
> > > value of XCR0 is observable in userspace (either by explicit
> > > xgetbv or by looking at the result of xsave) and since glibc
> > > does observe this value, replay divergence is almost immediate.
> > > I also suspect that people interested in process (or container)
> > > live-migration may eventually care about this if a migration happens
> > > in between a userspace xsave and a corresponding xrstor.
> > >
> > > We encounter this problem quite frequently since most of our users
> > > are using pre-Skylake systems (and thus don't support the AVX512
> > > state components), while we recently upgraded our main development
> > > machines to Skylake.
> >
> > Basically, for rr to work, we need to tightly control any user-visible
> > CPU behavior,
> > either by putting in the CPU in the right state or by trapping and emulating
> > (as we do for rdtsc, cpuid, etc). XCR0 controls a bunch of
> > user-visible CPU behavior,
> > namely:
> > 1) The size of the xsave region if xsave is passed an all-ones mask
> > (which is fairly common)
> > 2) The return value of xgetbv
>
> It's mentioned elsewhere, but I want to emphasize that the return
> value of xgetbv is the big one because the dynamic linker uses this.
> rr trace portability is essentially limited to machines with identical
> xcr0 values because of it.
I'm thinking just exposing that value is doable in a much less
objectionable fashion, no?
next prev parent reply other threads:[~2020-04-07 12:34 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-07 1:12 [RFC PATCH v2] x86/arch_prctl: Add ARCH_SET_XCR0 to set XCR0 per-thread Keno Fischer
2020-04-07 3:57 ` Andy Lutomirski
2020-04-07 4:44 ` Keno Fischer
2020-04-07 4:53 ` Kyle Huey
2020-04-07 12:33 ` Peter Zijlstra [this message]
2020-04-07 13:52 ` Keno Fischer
2020-04-07 12:21 ` Peter Zijlstra
2020-04-07 14:06 ` Dave Hansen
2020-04-07 14:16 ` Andy Lutomirski
2020-04-07 18:30 ` Keno Fischer
2020-04-14 23:20 ` Andy Lutomirski
2020-04-15 0:09 ` Keno Fischer
2020-04-16 1:07 ` Andy Lutomirski
2020-04-16 1:14 ` Keno Fischer
2020-04-16 1:16 ` Keno Fischer
2020-04-16 1:22 ` Andy Lutomirski
2020-04-07 16:29 ` Kyle Huey
2020-04-07 13:14 ` Dave Hansen
[not found] ` <CABV8kRw1TQsqs+z43bSfZ5isctuFGMB4g_ztDYihiiXHcy4nVA@mail.gmail.com>
2020-04-07 16:27 ` Dave Hansen
2020-04-07 17:55 ` Keno Fischer
2020-04-07 20:21 ` Dave Hansen
2020-04-07 21:42 ` Andy Lutomirski
2020-04-07 22:15 ` Keno Fischer
2020-04-14 19:55 ` Keno Fischer
2020-04-07 14:20 ` Andi Kleen
2020-04-07 18:06 ` Keno Fischer
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=20200407123348.GV20730@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=andi@firstfloor.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=keno@juliacomputing.com \
--cc=khuey@kylehuey.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=me@kylehuey.com \
--cc=mingo@redhat.com \
--cc=robert@ocallahan.org \
--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.