All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
	Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 7/8] x86/spec-ctrl: Issue VERW during IST exit to Xen
Date: Fri, 15 Sep 2023 09:15:47 +0200	[thread overview]
Message-ID: <7b4c0bfd-3eb2-3d0a-859a-b94b12397876@suse.com> (raw)
In-Reply-To: <22864483-9cb8-7220-f82e-883fd2ef617a@citrix.com>

On 14.09.2023 21:49, Andrew Cooper wrote:
> On 14/09/2023 11:01 am, Jan Beulich wrote:
>> On 13.09.2023 22:27, Andrew Cooper wrote:
>>> There is a corner case where e.g. an NMI hitting an exit-to-guest path after
>>> SPEC_CTRL_EXIT_TO_* would have run the entire NMI handler *after* the VERW
>>> flush to scrub potentially sensitive data from uarch buffers.
>>>
>>> In order to compensate, issue VERW when exiting to Xen from an IST entry.
>>>
>>> SPEC_CTRL_EXIT_TO_XEN already has two reads of spec_ctrl_flags off the stack,
>>> and we're about to add a third.  Load the field into %ebx, and list the
>>> register as clobbered.
>>>
>>> %r12 has been arranged to be the ist_exit signal, so add this as an input
>>> dependency and use it to identify when to issue a VERW.
>>>
>>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>> While looking technically okay, I still have a couple of remarks:
>>
>>> --- a/xen/arch/x86/include/asm/spec_ctrl_asm.h
>>> +++ b/xen/arch/x86/include/asm/spec_ctrl_asm.h
>>> @@ -344,10 +344,12 @@ UNLIKELY_DISPATCH_LABEL(\@_serialise):
>>>   */
>>>  .macro SPEC_CTRL_EXIT_TO_XEN
>>>  /*
>>> - * Requires %r14=stack_end
>>> - * Clobbers %rax, %rcx, %rdx
>>> + * Requires %r12=ist_exit, %r14=stack_end
>>> + * Clobbers %rax, %rbx, %rcx, %rdx
>> While I'd generally be a little concerned of the growing dependency and
>> clobber lists, there being a single use site makes this pretty okay. The
>> macro invocation being immediately followed by RESTORE_ALL effectively
>> means we can clobber almost everything here.
>>
>> As to register usage and my comment on patch 5: There's no real need
>> to switch %rbx to %r14 there if I'm not mistaken
> 
> As said, it's about consistency of the helpers.

While I'm not entirely happy with this, ...

>>> @@ -367,8 +369,16 @@ UNLIKELY_DISPATCH_LABEL(\@_serialise):
>>>  
>>>  .L\@_skip_sc_msr:
>>>  
>>> -    /* TODO VERW */
>>> +    test %r12, %r12
>>> +    jz .L\@_skip_ist_exit
>>> +
>>> +    /* Logically DO_SPEC_CTRL_COND_VERW but without the %rsp=cpuinfo dependency */
>>> +    testb $SCF_verw, %bl
>>> +    jz .L\@_verw_skip
>>> +    verw STACK_CPUINFO_FIELD(verw_sel)(%r14)
>>> +.L\@_verw_skip:
>> Nit: .L\@_skip_verw would be more consistent with the other label names.
> 
> So it would.  I'll tweak.

... then
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan


  reply	other threads:[~2023-09-15  7:16 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-13 20:27 [PATCH 0/8] x86/spec-ctrl: AMD DIV fix, and VERW prerequisite bugfixes Andrew Cooper
2023-09-13 20:27 ` [PATCH 1/8] x86/spec-ctrl: Fix confusion between SPEC_CTRL_EXIT_TO_XEN{,_IST} Andrew Cooper
2023-09-14  6:56   ` Jan Beulich
2023-09-14  9:54     ` Andrew Cooper
2023-09-13 20:27 ` [PATCH 2/8] x86/spec-ctrl: Fold DO_SPEC_CTRL_EXIT_TO_XEN into it's single user Andrew Cooper
2023-09-14  6:59   ` Jan Beulich
2023-09-13 20:27 ` [PATCH 3/8] x86/spec-ctrl: Turn the remaining SPEC_CTRL_{ENTRY,EXIT}_* into asm macros Andrew Cooper
2023-09-14  7:20   ` Jan Beulich
2023-09-13 20:27 ` [PATCH 4/8] x86/spec-ctrl: Extend all SPEC_CTRL_{ENTER,EXIT}_* comments Andrew Cooper
2023-09-14  7:58   ` Jan Beulich
2023-09-14 19:23     ` Andrew Cooper
2023-09-15  7:07       ` Jan Beulich
2023-09-15  9:27         ` Andrew Cooper
2023-09-13 20:27 ` [PATCH 5/8] x86/entry: Adjust restore_all_xen to hold stack_end in %r14 Andrew Cooper
2023-09-14  8:51   ` Jan Beulich
2023-09-14 19:28     ` Andrew Cooper
2023-09-13 20:27 ` [PATCH 6/8] x86/entry: Track the IST-ness of an entry for the exit paths Andrew Cooper
2023-09-14  9:32   ` Jan Beulich
2023-09-14 19:44     ` Andrew Cooper
2023-09-15  7:13       ` Jan Beulich
2023-09-15  9:30         ` Andrew Cooper
2023-09-13 20:27 ` [PATCH 7/8] x86/spec-ctrl: Issue VERW during IST exit to Xen Andrew Cooper
2023-09-14 10:01   ` Jan Beulich
2023-09-14 19:49     ` Andrew Cooper
2023-09-15  7:15       ` Jan Beulich [this message]
2023-09-13 20:27 ` [PATCH 8/8] x86/spec-ctrl: Mitigate the Zen1 DIV leakge Andrew Cooper
2023-09-13 20:43   ` Andrew Cooper
2023-09-13 21:12   ` Marek Marczykowski-Górecki
2023-09-14 10:52   ` Jan Beulich
2023-09-14 20:01     ` Andrew Cooper
2023-09-14 13:12   ` Jason Andryuk
2023-09-14 20:05     ` Andrew Cooper

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=7b4c0bfd-3eb2-3d0a-859a-b94b12397876@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --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.