Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1535085

Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation

Path csiph.com!news.mixmin.net!feeds.phibee-telecom.net!news.panservice.it!bofh.it!news.nic.it!robomod
From Andy Lutomirski <luto@amacapital.net>
Newsgroups linux.kernel
Subject Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation
Date Fri, 02 Dec 2016 18:10:02 +0100
Message-ID <sJZvs-6Fu-19@gated-at.bofh.it> (permalink)
References <sJK3o-4BW-19@gated-at.bofh.it> <sJK3n-4BW-9@gated-at.bofh.it> <sJUvM-3hJ-31@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=YvI1Js02EzHpK1gN+NjajqRGsGe7Pn1oohujlz+KvU8=; b=pyGDzjUdx+GfcvATnQZLxvHPNeg/3R2zApSUAbZNBP32iFKJDraxajB5kSPVBIX6bd zMeAEC82n3WwfxJmCLzujrdc4Iz9T4AV6C0sg0+qkVzsIQQnnxHacgzbrPA1FXHMU3TG TnCtnbywdhAS+Fmyl033LRoBni92e5tQ/pOvMGluHIo7sXnxUHZet2Ym/bYSLP14AT+W g+ilhYlWCTxDTqvVrkLH1n9EMR5Fk1CSoELNZoAeJrsZ4WpCjZwPl7PkXRQvBojjAQuM PMvergEZfmG8dkWJog4WQtzBStypbUVQ/x/cBBb4/Bu8E2zEOi3C/jaj5l9kmBMLYgkr WTlA==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=YvI1Js02EzHpK1gN+NjajqRGsGe7Pn1oohujlz+KvU8=; b=CJMMARgkfn9ZJ+dmXryghsv5rD9BBpYAd5+8vEsf2rpJZSEQAVGLN8pVxVHj+y3w8y u8Y/jgSoDtzOgXQa5yQFXjAfoMMOeEGOp2mzx9+7K4x9UjwZuK0PYrwsWPx4ntt/P2q+ SfcS9rZQsWfzU0rz1AE/2XIStvIKBuGfmN8+euaTYkmPkE/GcqfKpHxjfFi0+qo+NDEc yqaKIyRONs5dzPW9gVJp+ZCIl86eoqQTnEU2qEPr2Ui65HXiwT59t/zmnBh0dlLpKDHe 74qinxui+Q0LzvV0CdSUPU/pE7NfuZlh5do/i8+jeyY9gC9n9RsCgq3MZjR0wksa90L4 8XCg==
X-Gm-Message-State AKaTC03YYMbGzY6UsdOFTheKh3NuJpFY+xDM71SS482oZkCR1/ZXE3Nex+C5NY+zjs9NXTmdln3l6+FR15Cc0UJf
X-Received by 10.159.50.138 with SMTP id l10mr28446298uab.166.1480698453075; Fri, 02 Dec 2016 09:07:33 -0800 (PST)
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 50
Organization linux.* mail to news gateway
X-Original-Cc Boris Ostrovsky <boris.ostrovsky@oracle.com>, 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>, 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>
X-Original-Date Fri, 2 Dec 2016 09:07:12 -0800
X-Original-Message-ID <CALCETrV38BPzsOrhydgUqsQdQy9x2id2myQy+S3V3xUH9zJUdQ@mail.gmail.com>
X-Original-References <cover.1480638597.git.luto@kernel.org> <0a21157c2233ba7d0781bbf07866b3f2d7e7c25d.1480638597.git.luto@kernel.org> <a9c41f3a-f649-712e-21bb-a849b0a4de13@citrix.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1535085

Show key headers only | View raw


On Dec 2, 2016 3:44 AM, "Andrew Cooper" <andrew.cooper3@citrix.com> 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.

I don't know for sure.  IRET is serializing, and if Xen returns using
IRET, we're fine.

>
> >
> > 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.

I'll quote the (modern) SDM.  For self-modifying code "The use of one
of these options is not required for programs intended to run on the
Pentium or Intel486 processors,
but are recommended to ensure compatibility with the P6 and more
recent processor families.".  For cross-modifying code "The use of
this option is not required for programs intended to run on the
Intel486 processor, but is recommended
to ensure compatibility with the Pentium 4, Intel Xeon, P6 family, and
Pentium processors."  So I'm not sure there's a problem.

I can add an unconditional jump just to make sure.  It costs basically
nothing on modern CPUs.  (Also, CPUID also isn't serializing on 486
according to the table.)

--Andy

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] CPUID-less CPU fixes and improvements Andy Lutomirski <luto@kernel.org> - 2016-11-30 21:40 +0100
  [PATCH 4/4] x86/asm: Change sync_core() to use MOV to CR2 to serialize Andy Lutomirski <luto@kernel.org> - 2016-11-30 21:40 +0100
    Re: [PATCH 4/4] x86/asm: Change sync_core() to use MOV to CR2 to  serialize Borislav Petkov <bp@alien8.de> - 2016-12-01 10:30 +0100
      Re: [PATCH 4/4] x86/asm: Change sync_core() to use MOV to CR2 to serialize Andy Lutomirski <luto@amacapital.net> - 2016-12-01 18:10 +0100
        Re: [PATCH 4/4] x86/asm: Change sync_core() to use MOV to CR2 to  serialize Andrew Cooper <andrew.cooper3@citrix.com> - 2016-12-01 18:50 +0100
      Re: [PATCH 4/4] x86/asm: Change sync_core() to use MOV to CR2 to  serialize Ingo Molnar <mingo@kernel.org> - 2016-12-02 08:40 +0100
  [PATCH 3/4] x86/microcode/intel: Replace sync_core() with cpuid_eax(1) Andy Lutomirski <luto@kernel.org> - 2016-11-30 21:40 +0100
    Re: [PATCH 3/4] x86/microcode/intel: Replace sync_core() with  cpuid_eax(1) Borislav Petkov <bp@alien8.de> - 2016-12-01 10:20 +0100
  [PATCH v2 6/6] x86/asm: Change sync_core() to use MOV to CR2 to serialize Andy Lutomirski <luto@kernel.org> - 2016-12-02 01:40 +0100
  [PATCH v2 4/6] x86/paravirt: Make sync_core() be a paravirt op Andy Lutomirski <luto@kernel.org> - 2016-12-02 01:40 +0100
  [PATCH v2 3/6] x86/microcode/intel: Replace sync_core() with cpuid_eax(1) Andy Lutomirski <luto@kernel.org> - 2016-12-02 01:40 +0100
  [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Andy Lutomirski <luto@kernel.org> - 2016-12-02 01:40 +0100
    Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core()  implementation Andrew Cooper <andrew.cooper3@citrix.com> - 2016-12-02 12:50 +0100
      Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Andy Lutomirski <luto@amacapital.net> - 2016-12-02 18:10 +0100
        Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core()  implementation Andrew Cooper <andrew.cooper3@citrix.com> - 2016-12-02 18:20 +0100
          Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core()  implementation Andrew Cooper <andrew.cooper3@citrix.com> - 2016-12-02 18:30 +0100
          Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Andy Lutomirski <luto@amacapital.net> - 2016-12-02 18:30 +0100
      Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core()  implementation Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2016-12-02 19:50 +0100
        Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Andy Lutomirski <luto@amacapital.net> - 2016-12-02 20:40 +0100
      Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core()  implementation Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2016-12-02 21:10 +0100
    Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-02 18:40 +0100
      Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Andy Lutomirski <luto@kernel.org> - 2016-12-02 18:40 +0100
        Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core()  implementation Borislav Petkov <bp@kernel.org> - 2016-12-02 19:20 +0100
          Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-02 19:30 +0100
            Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core()  implementation Borislav Petkov <bp@kernel.org> - 2016-12-02 20:00 +0100
              Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-02 20:10 +0100
                Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-02 20:30 +0100
                Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core()  implementation Borislav Petkov <bp@alien8.de> - 2016-12-02 20:30 +0100
                [PATCH] x86/alternatives: Do not use sync_core() to serialize I$ Borislav Petkov <bp@alien8.de> - 2016-12-03 16:10 +0100
                Re: [PATCH] x86/alternatives: Do not use sync_core() to serialize I$ Andy Lutomirski <luto@amacapital.net> - 2016-12-03 18:20 +0100
                Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-02 20:40 +0100
                Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Andy Lutomirski <luto@amacapital.net> - 2016-12-02 21:50 +0100
                Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-02 22:20 +0100
                Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Andy Lutomirski <luto@amacapital.net> - 2016-12-03 00:00 +0100
                Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-03 00:20 +0100
                Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Andy Lutomirski <luto@amacapital.net> - 2016-12-02 20:40 +0100
                Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Andy Lutomirski <luto@amacapital.net> - 2016-12-02 20:30 +0100
                Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core()  implementation Borislav Petkov <bp@alien8.de> - 2016-12-02 20:40 +0100
                Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core()  implementation Borislav Petkov <bp@alien8.de> - 2016-12-02 20:30 +0100
        Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core() implementation Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-02 19:20 +0100
        Re: [PATCH v2 5/6] x86/xen: Add a Xen-specific sync_core()  implementation Borislav Petkov <bp@alien8.de> - 2016-12-03 13:50 +0100
  [PATCH v2 2/6] Revert "x86/boot: Fail the boot if !M486 and CPUID is missing" Andy Lutomirski <luto@kernel.org> - 2016-12-02 01:40 +0100
  Re: [PATCH 0/4] CPUID-less CPU fixes and improvements Andy Lutomirski <luto@amacapital.net> - 2016-12-02 01:40 +0100
    Re: [PATCH 0/4] CPUID-less CPU fixes and improvements Ingo Molnar <mingo@kernel.org> - 2016-12-02 11:20 +0100
  [PATCH v2 0/6] CPUID-less CPU/sync_core fixes and improvements Andy Lutomirski <luto@kernel.org> - 2016-12-02 01:40 +0100
  [PATCH v2 1/6] x86/asm/32: Make sync_core() handle missing CPUID on all 32-bit kernels Andy Lutomirski <luto@kernel.org> - 2016-12-02 01:40 +0100

csiph-web