All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v2 4/7] x86: NOP out most XPTI entry/exit code when it's not in use
Date: Thu, 1 Mar 2018 19:42:16 +0000	[thread overview]
Message-ID: <d58cffd4-5971-1982-ace3-cd3b30017659@citrix.com> (raw)
In-Reply-To: <5A7B33C202000078001A6228@prv-mh.provo.novell.com>

On 07/02/18 16:13, Jan Beulich wrote:
> --- a/xen/arch/x86/x86_64/compat/entry.S
> +++ b/xen/arch/x86/x86_64/compat/entry.S
> @@ -199,7 +199,7 @@ ENTRY(compat_post_handle_exception)
>  
>  /* See lstar_enter for entry register state. */
>  ENTRY(cstar_enter)
> -        /* sti could live here when we don't switch page tables below. */
> +        ALTERNATIVE nop, sti, X86_FEATURE_NO_XPTI
>          CR4_PV32_RESTORE
>          movq  8(%rsp),%rax /* Restore %rax. */
>          movq  $FLAT_KERNEL_SS,8(%rsp)
> @@ -214,6 +214,7 @@ ENTRY(cstar_enter)
>          /* WARNING! `ret`, `call *`, `jmp *` not safe before this point. */
>  
>          GET_STACK_END(bx)
> +.Lcstar_cr3_start:
>          mov   STACK_CPUINFO_FIELD(xen_cr3)(%rbx), %rcx
>          neg   %rcx
>          jz    .Lcstar_cr3_okay
> @@ -223,6 +224,8 @@ ENTRY(cstar_enter)
>          movq  $0, STACK_CPUINFO_FIELD(xen_cr3)(%rbx)
>  .Lcstar_cr3_okay:
>          sti
> +.Lcstar_cr3_end:
> +        ALTERNATIVE_NOP .Lcstar_cr3_start, .Lcstar_cr3_end, X86_FEATURE_NO_XPTI

This is much clearer with the nop infrastructure abstracted away.

However, I remain unconvinced that this dynamic handling of interrupt
re-enabling is worth the hoops you've jumped through to make it happen. 
It might be interesting to hear others thoughts on the matter.

In particular, we've got a race window depending on the order in which
the alternatives list is traversed where we might be unsafe.

On a tangent (which probably wont affect the result of this patch),
given your thoughts to allow guests to notice and extend their own
featureset, what about Xen?  If so, we're going to need something more
clever than simply nopping out the code.

~Andrew

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

  reply	other threads:[~2018-03-01 19:42 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-07 16:05 [PATCH v2 0/7] x86: Meltdown band-aid overhead reduction Jan Beulich
2018-02-07 16:12 ` [PATCH v2 1/7] x86: slightly reduce Meltdown band-aid overhead Jan Beulich
2018-02-07 19:35   ` Andrew Cooper
2018-02-08  9:20     ` Jan Beulich
2018-03-01 19:21       ` Andrew Cooper
2018-03-02 11:34         ` Jan Beulich
2018-03-02 11:38           ` Andrew Cooper
2018-02-07 16:12 ` [PATCH v2 2/7] x86: remove CR reads from exit-to-guest path Jan Beulich
2018-03-01 19:23   ` Andrew Cooper
2018-02-07 16:13 ` [PATCH v2 3/7] x86: introduce altinstruction_nop assembler macro Jan Beulich
2018-03-01 19:25   ` Andrew Cooper
2018-03-02  7:24     ` Jan Beulich
2018-02-07 16:13 ` [PATCH v2 4/7] x86: NOP out most XPTI entry/exit code when it's not in use Jan Beulich
2018-03-01 19:42   ` Andrew Cooper [this message]
2018-03-02  7:38     ` Jan Beulich
2018-02-07 16:14 ` [PATCH v2 5/7] x86: avoid double CR3 reload when switching to guest user mode Jan Beulich
2018-02-07 16:14 ` [PATCH v2 6/7] x86: disable XPTI when RDCL_NO Jan Beulich
2018-02-07 16:15 ` [PATCH v2 7/7] x86: log XPTI enabled status Jan Beulich
2018-02-13 18:39 ` [PATCH v2 0/7] x86: Meltdown band-aid overhead reduction Rich Persaud
2018-02-14  8:04   ` Jan Beulich
2018-02-28 11:52 ` Ping: " Jan Beulich
2018-02-28 12:00   ` Juergen Gross
2018-03-08 11:32 ` [PATCH v2 8/7] x86/XPTI: use %r12 to write zero into xen_cr3 Jan Beulich
2018-03-08 11:33 ` [PATCH v2 9/7] x86/XPTI: reduce .text.entry Jan Beulich

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=d58cffd4-5971-1982-ace3-cd3b30017659@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=xen-devel@lists.xenproject.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.