All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@amacapital.net>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Xen-devel List <xen-devel@lists.xen.org>,
	Juergen Gross <jgross@suse.com>, Borislav Petkov <bp@alien8.de>,
	Matthew Whitehead <tedheadster@gmail.com>,
	One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>,
	Henrique de Moraes Holschuh <hmh@hmh.eng.br>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Brian Gerst <brgerst@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	X86 ML <x86@kernel.org>, Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation
Date: Fri, 2 Dec 2016 11:34:26 -0800	[thread overview]
Message-ID: <CALCETrVoCnhpQcstvzq7jgeNo9h2k9GzJnh=3MOj1qth_0RPyA@mail.gmail.com> (raw)
In-Reply-To: <402ae08c-22d3-bec7-6649-26632c941a29@oracle.com>

On Dec 2, 2016 10:48 AM, "Boris Ostrovsky" <boris.ostrovsky@oracle.com> wrote:
>
> On 12/02/2016 06:44 AM, Andrew Cooper wrote:
> > On 02/12/16 00:35, Andy Lutomirski wrote:
> >> On Xen PV, CPUID is likely to trap, and Xen hypercalls aren't
> >> guaranteed to serialize.  (Even CPUID isn't *really* guaranteed to
> >> serialize on Xen PV, but, in practice, any trap it generates will
> >> serialize.)
> > Well, Xen will enabled CPUID Faulting wherever it can, which is
> > realistically all IvyBridge hardware and newer.
> >
> > All hypercalls are a privilege change to cpl0.  I'd hope this condition
> > is serialising, but I can't actually find any documentation proving or
> > disproving this.
> >
> >> On my laptop, CPUID(eax=1, ecx=0) is ~83ns and IRET-to-self is
> >> ~110ns.  But Xen PV will trap CPUID if possible, so IRET-to-self
> >> should end up being a nice speedup.
> >>
> >> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> >> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> > CC'ing xen-devel and the Xen maintainers in Linux.
> >
> > As this is the only email from this series in my inbox, I will say this
> > here, but it should really be against patch 6.
> >
> > A write to %cr2 is apparently (http://sandpile.org/x86/coherent.htm) not
> > serialising on the 486, but I don't have a manual to hand to check.
> >
> > ~Andrew
> >
> >> ---
> >>  arch/x86/xen/enlighten.c | 35 +++++++++++++++++++++++++++++++++++
> >>  1 file changed, 35 insertions(+)
> >>
> >> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> >> index bdd855685403..1f765b41eee7 100644
> >> --- a/arch/x86/xen/enlighten.c
> >> +++ b/arch/x86/xen/enlighten.c
> >> @@ -311,6 +311,39 @@ static __read_mostly unsigned int cpuid_leaf1_ecx_set_mask;
> >>  static __read_mostly unsigned int cpuid_leaf5_ecx_val;
> >>  static __read_mostly unsigned int cpuid_leaf5_edx_val;
> >>
> >> +static void xen_sync_core(void)
> >> +{
> >> +    register void *__sp asm(_ASM_SP);
> >> +
> >> +#ifdef CONFIG_X86_32
> >> +    asm volatile (
> >> +            "pushl %%ss\n\t"
> >> +            "pushl %%esp\n\t"
> >> +            "addl $4, (%%esp)\n\t"
> >> +            "pushfl\n\t"
> >> +            "pushl %%cs\n\t"
> >> +            "pushl $1f\n\t"
> >> +            "iret\n\t"
> >> +            "1:"
> >> +            : "+r" (__sp) : : "cc");
>
> This breaks 32-bit PV guests.
>
> Why are we pushing %ss? We are not changing privilege levels so why not
> just flags, cs and eip (which, incidentally, does work)?
>

Doh!  I carefully tested 64-bit on Xen and 32-bit in user mode.

  parent reply	other threads:[~2016-12-02 19:34 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-30 20:34 [PATCH 0/4] CPUID-less CPU fixes and improvements Andy Lutomirski
2016-11-30 20:34 ` [PATCH 1/4] x86/asm/32: Make sync_core() handle missing CPUID on all 32-bit kernels Andy Lutomirski
2016-11-30 20:34 ` [PATCH 2/4] Revert "x86/boot: Fail the boot if !M486 and CPUID is missing" Andy Lutomirski
2016-12-01  5:53   ` Peter Zijlstra
2016-12-01  9:02     ` Borislav Petkov
2016-12-01 10:07       ` Thomas Gleixner
2016-12-01 11:15         ` [PATCH] x86/CPU: Add X86_FEATURE_CPUID Borislav Petkov
2016-12-01 17:00           ` Andy Lutomirski
2016-12-02  0:33       ` [PATCH 2/4] Revert "x86/boot: Fail the boot if !M486 and CPUID is missing" Andy Lutomirski
2016-12-01 17:00     ` Andy Lutomirski
2016-11-30 20:34 ` [PATCH 3/4] x86/microcode/intel: Replace sync_core() with cpuid_eax(1) Andy Lutomirski
2016-12-01  9:11   ` Borislav Petkov
2016-11-30 20:34 ` [PATCH 4/4] x86/asm: Change sync_core() to use MOV to CR2 to serialize Andy Lutomirski
2016-12-01  9:22   ` Borislav Petkov
2016-12-01 17:08     ` Andy Lutomirski
2016-12-01 17:46       ` Andrew Cooper
2016-12-02  7:34     ` Ingo Molnar
2016-12-02  0:34 ` [PATCH v2 0/6] CPUID-less CPU/sync_core fixes and improvements Andy Lutomirski
2016-12-02  0:34   ` [PATCH v2 1/6] x86/asm/32: Make sync_core() handle missing CPUID on all 32-bit kernels Andy Lutomirski
2016-12-02  0:34   ` [PATCH v2 2/6] Revert "x86/boot: Fail the boot if !M486 and CPUID is missing" Andy Lutomirski
2016-12-02  0:34   ` [PATCH v2 3/6] x86/microcode/intel: Replace sync_core() with cpuid_eax(1) Andy Lutomirski
2016-12-02  0:35   ` [PATCH v2 4/6] x86/paravirt: Make sync_core() be a paravirt op Andy Lutomirski
2016-12-02  0:35   ` [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Andy Lutomirski
2016-12-02 11:44     ` Andrew Cooper
2016-12-02 11:44     ` Andrew Cooper
2016-12-02 17:07       ` Andy Lutomirski
2016-12-02 17:07       ` Andy Lutomirski
2016-12-02 17:16         ` Andrew Cooper
2016-12-02 17:16         ` Andrew Cooper
2016-12-02 17:23           ` Andy Lutomirski
2016-12-02 17:26             ` Andrew Cooper
2016-12-02 17:26             ` Andrew Cooper
2016-12-02 17:23           ` Andy Lutomirski
2016-12-02 18:50       ` Boris Ostrovsky
2016-12-02 18:50       ` Boris Ostrovsky
2016-12-02 19:34         ` Andy Lutomirski
2016-12-02 19:34         ` Andy Lutomirski [this message]
2016-12-02 20:09       ` Boris Ostrovsky
2016-12-02 20:09         ` Boris Ostrovsky
2016-12-02 17:32     ` Linus Torvalds
2016-12-02 17:38       ` Andy Lutomirski
2016-12-02 17:53         ` Linus Torvalds
2016-12-02 18:03         ` Borislav Petkov
2016-12-02 18:27           ` Linus Torvalds
2016-12-02 18:50             ` Borislav Petkov
2016-12-02 19:03               ` Linus Torvalds
2016-12-02 19:20                 ` Borislav Petkov
2016-12-02 19:24                   ` Linus Torvalds
2016-12-02 19:28                     ` Borislav Petkov
2016-12-03 15:02                       ` [PATCH] x86/alternatives: Do not use sync_core() to serialize I$ Borislav Petkov
2016-12-03 17:05                         ` Andy Lutomirski
2016-12-20  7:58                         ` [tip:x86/urgent] " tip-bot for Borislav Petkov
2016-12-20  9:35                         ` tip-bot for Borislav Petkov
2016-12-02 19:30                     ` [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Andy Lutomirski
2016-12-02 19:35                       ` Linus Torvalds
2016-12-02 20:41                         ` Andy Lutomirski
2016-12-02 21:10                           ` Linus Torvalds
2016-12-02 22:55                             ` Andy Lutomirski
2016-12-02 23:09                               ` Linus Torvalds
2016-12-02 19:23                 ` Andy Lutomirski
2016-12-02 19:30                   ` Borislav Petkov
2016-12-03 12:44         ` Borislav Petkov
2016-12-02  0:35   ` [PATCH v2 6/6] x86/asm: Change sync_core() to use MOV to CR2 to serialize Andy Lutomirski
2016-12-02  0:36 ` [PATCH 0/4] CPUID-less CPU fixes and improvements Andy Lutomirski
2016-12-02 10:17   ` Ingo Molnar

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='CALCETrVoCnhpQcstvzq7jgeNo9h2k9GzJnh=3MOj1qth_0RPyA@mail.gmail.com' \
    --to=luto@amacapital.net \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=hmh@hmh.eng.br \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tedheadster@gmail.com \
    --cc=x86@kernel.org \
    --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 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.