All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: Julien Grall <julien.grall@arm.com>
Cc: xen-devel@lists.xenproject.org,
	Stefano Stabellini <sstabellini@kernel.org>,
	andre.przywara@arm.com
Subject: Re: [PATCH 05/13] xen/arm: Add command line option to control SSBD mitigation
Date: Wed, 30 May 2018 13:10:16 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.10.1805301228400.23991@sstabellini-ThinkPad-X260> (raw)
In-Reply-To: <dff77236-51d7-41bd-ad74-3b2ea6bcedcb@arm.com>

On Wed, 30 May 2018, Julien Grall wrote:
> On 05/29/2018 11:34 PM, Stefano Stabellini wrote:
> > On Tue, 29 May 2018, Julien Grall wrote:
> > > On 25/05/18 21:51, Stefano Stabellini wrote:
> > > > On Thu, 24 May 2018, Julien Grall wrote:
> > > > > On 23/05/18 23:34, Stefano Stabellini wrote:
> > > > > > On Tue, 22 May 2018, Julien Grall  >>>>
> > > > > > arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FID,
> > > > > > >                           ARM_SMCCC_ARCH_WORKAROUND_2_FID, &res);
> > > > > > > -    if ( (int)res.a0 != 0 )
> > > > > > > -        supported = false;
> > > > > > >     -    if ( supported )
> > > > > > > -        this_cpu(ssbd_callback_required) = 1;
> > > > > > > +    switch ( (int)res.a0 )
> > > > > > 
> > > > > > Please introduce this switch in the previous patch. But it makes
> > > > > > sense
> > > > > > to add the ssbd_state variable in this patch.
> > > > > 
> > > > > Well, that's not going to make the diff simpler here as the switch
> > > > > will be
> > > > > different. So I would keep the patch like that.
> > > > 
> > > > The split is a bit iffy to me, but if you don't want to change it, I can
> > > > live with it anyway.
> > > 
> > > I don't think the other way will help. But I will do it.
> > 
> > Thank you
> > 
> > 
> > > > > > 
> > > > > > > +    {
> > > > > > > +    case ARM_SMCCC_NOT_SUPPORTED:
> > > > > > > +        ssbd_state = ARM_SSBD_UNKNOWN;
> > > > > > > +        return false;
> > > > > > > +
> > > > > > > +    case ARM_SMCCC_NOT_REQUIRED:
> > > > > > > +        ssbd_state = ARM_SSBD_MITIGATED;
> > > > > > > +        return false;
> > > > > > > +
> > > > > > > +    case ARM_SMCCC_SUCCESS:
> > > > > > > +        required = true;
> > > > > > > +        break;
> > > > > > > +
> > > > > > > +    case 1: /* Mitigation not required on this CPU. */
> > > > > > > +        required = false;
> > > > > > > +        break;
> > > > > > 
> > > > > > This should "return false".
> > > > > 
> > > > > It is perfectly fine to continue as it is safe to execute
> > > > > ARCH_WORKAROUND_2 on
> > > > > that CPU.
> > > > 
> > > > This is the case where mitigation is not required but issuing the SMCCC
> > > > is safe. Instead of returning immediately, we go through the next
> > > > switch:
> > > > 
> > > > 1) if ARM_SSBD_FORCE_DISABLE, we make the SMCCC
> > > > 2) if ARM_SSBD_RUNTIME, we do nothing
> > > > 3) if ARM_SSBD_FORCE_ENABLE, we make the SMCCC
> > > > 
> > > > What is the desired outcome for this situation? Obviously, continuing
> > > > for
> > > > case 2) is pointless, we might as well return immediately. For 1) and 3)
> > > > is the intention that the SMCCC will actually have an effect even if the
> > > > mitigation is not required?
> > > 
> > > While the SMCCC call in 1) and 3) will do nothing for those CPUs, you will
> > > still print a warning message if the user choose to force enable/disable
> > > the
> > > mitigation.
> > 
> > Printing warnings could be a good idea. However, I think we should do
> > the same thing for "1" and for "ARM_SMCCC_NOT_REQUIRED", and maybe even
> > for "ARM_SMCCC_NOT_SUPPORTED": printing warnings for all or for none.
> > 
> > I also noticed that if the first SMCCC returns "1" and we continue, in case
> > ssbd_state == ARM_SSBD_FORCE_ENABLE, "required" gets changed to
> > "true".  Do we want to let the user force-enable the mitigation even
> > when it will do nothing? I am not really sure, probably not? In any case
> > I would prefer if we kept the same behavior across "1" and
> > "ARM_SMCCC_NOT_REQUIRED".
> 
> I don't think it is right ot expect the same behavior for "1"and
> "ARM_SMCCC_NOT_REQUIRED". There are majors difference between those 2 and
> ARM_SMCCC_NOT_SUPPORTED.
> 
> From the spec ARM DEN 0070A section 2.2.5:
> 	- If your firmware does not support the call, ARM_SMCCC_NOT_SUPPORTED
> will be returned for *all* CPUs. This will happen on current firmwares.
> 	- If your firmware has mitigation permanently disabled/enabled for
> *all* CPUs, ARM_SMCCC_NOT_REQUIRED will be returned.
> 	- If one of the CPUs in the platform require dynamic mitigation, the
> call will return 0 for them. The others CPUs will return 1.
> 
> Printing a warning for the first two will likely scare the user because it is
> going to be printed on most of the current platforms.
> 
> Printing a warning for the last one makes sense because you know that one of
> the CPU may be affected. That CPU may be bring up later on. So you offer a
> print in similar place in the logs whatever the platform is.

I should have read the spec more carefully, thanks for the pointer.
Sorry about that. Finally, these patches are starting to make sense :-)

All right. I can see why ssbd_state and ssbd_callback_required are
separate and their purpose. Aside from adding more info to the commit
message, I'll make a couple of different suggestions:

1) Let's check if ssbd_state == ARM_SSBD_UNKNOWN || ssbd_state ==
ARM_SSBD_MITIGATED at the beginning of has_ssbd_mitigation and return
early in that case. This will help clarify the intended behavior and
mitigate broken firmware returning ARM_SMCCC_NOT_SUPPORTED only on some
cpus. This is just optional, I am fine either way.

2) Can we turn ssbd_callback_required from a this_cpu variable to a
single cpu bitmask? It is not great to introduce a new per-cpu varible
for just one bit. It would save space and make it easier to access from
assembly as a bitmask as it would remove the need for the ldr_this_cpu
macro. If I am wrong and the bitmask makes things more complicated
rather than simpler, then keep the code as is and just mention it in the
next version of the patch.

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

  reply	other threads:[~2018-05-30 20:10 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-22 17:42 [PATCH 00/13] xen/arm: SSBD (aka Spectre-v4) mitigation (XSA-263) Julien Grall
2018-05-22 17:42 ` [PATCH 01/13] xen/arm: domain: Zeroed the vCPU stack Julien Grall
2018-05-25 20:52   ` Stefano Stabellini
2018-05-29 10:27     ` Julien Grall
2018-05-29 21:41       ` Stefano Stabellini
2018-05-22 17:42 ` [PATCH 02/13] xen/arm64: entry: Use named label in guest_sync Julien Grall
2018-05-23 21:27   ` Stefano Stabellini
2018-05-22 17:42 ` [PATCH 03/13] xen/arm: setup: Check errata for boot CPU later on Julien Grall
2018-05-23 21:34   ` Stefano Stabellini
2018-05-25 19:51     ` Julien Grall
2018-05-29 21:30       ` Stefano Stabellini
2018-05-30  9:17         ` Julien Grall
2018-05-22 17:42 ` [PATCH 04/13] xen/arm: Add ARCH_WORKAROUND_2 probing Julien Grall
2018-05-23 21:57   ` Stefano Stabellini
2018-05-23 22:31     ` Julien Grall
2018-05-25 20:51       ` Stefano Stabellini
2018-05-25 23:54         ` Andrew Cooper
2018-05-29 21:35           ` Stefano Stabellini
2018-05-30  9:35             ` Julien Grall
2018-05-22 17:42 ` [PATCH 05/13] xen/arm: Add command line option to control SSBD mitigation Julien Grall
2018-05-23 22:34   ` Stefano Stabellini
2018-05-24  0:48     ` Stefano Stabellini
2018-05-25 19:56       ` Julien Grall
2018-05-24  9:52     ` Julien Grall
2018-05-25 20:51       ` Stefano Stabellini
2018-05-29 11:31         ` Julien Grall
2018-05-29 22:34           ` Stefano Stabellini
2018-05-30 10:39             ` Julien Grall
2018-05-30 20:10               ` Stefano Stabellini [this message]
2018-05-31 10:34                 ` Julien Grall
2018-05-31 20:58                   ` Stefano Stabellini
2018-05-31 21:29                     ` Julien Grall
2018-05-23 23:23   ` Stefano Stabellini
2018-05-24  9:53     ` Julien Grall
2018-05-22 17:42 ` [PATCH 06/13] xen/arm: Add ARCH_WORKAROUND_2 support for guests Julien Grall
2018-05-23 23:24   ` Stefano Stabellini
2018-05-24  0:40     ` Stefano Stabellini
2018-05-24 10:00       ` Julien Grall
2018-05-25 20:51         ` Stefano Stabellini
2018-05-22 17:42 ` [PATCH 07/13] xen/arm: Simplify alternative patching Julien Grall
2018-05-25 20:52   ` Stefano Stabellini
2018-05-25 21:34     ` Julien Grall
2018-05-25 23:24       ` Stefano Stabellini
2018-05-29 11:34         ` Julien Grall
2018-05-22 17:42 ` [PATCH 08/13] xen/arm: alternatives: Add dynamic patching feature Julien Grall
2018-05-25 20:52   ` Stefano Stabellini
2018-05-22 17:42 ` [PATCH 09/13] xen/arm64: Add generic assembly macros Julien Grall
2018-05-23 23:37   ` Stefano Stabellini
2018-05-22 17:42 ` [PATCH 10/13] xen/arm64: Implement a fast path for handling SMCCC_ARCH_WORKAROUND_2 Julien Grall
2018-05-25 19:18   ` Stefano Stabellini
2018-05-29 12:16     ` Julien Grall
2018-05-29 21:39       ` Stefano Stabellini
2018-05-22 17:42 ` [PATCH 11/13] xen/arm: Kconfig: Move HARDEN_BRANCH_PREDICTOR under "Architecture features" Julien Grall
2018-05-23 23:45   ` Stefano Stabellini
2018-05-22 17:42 ` [PATCH 12/13] xen/arm: smccc: Fix indentation in ARM_SMCCC_ARCH_WORKAROUND_1_FID Julien Grall
2018-05-23 23:44   ` Stefano Stabellini
2018-05-22 17:42 ` [PATCH 13/13] xen/arm: Avoid to use current everywhere in enter_hypervisor_head Julien Grall
2018-05-23 23:47   ` Stefano Stabellini
2018-05-24 10:29     ` Julien Grall
2018-05-24 18:46       ` Stefano Stabellini
2018-05-22 17:46 ` [for-4.11] Re: [PATCH 00/13] xen/arm: SSBD (aka Spectre-v4) mitigation (XSA-263) Julien Grall
2018-05-23  4:07   ` Juergen Gross

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=alpine.DEB.2.10.1805301228400.23991@sstabellini-ThinkPad-X260 \
    --to=sstabellini@kernel.org \
    --cc=andre.przywara@arm.com \
    --cc=julien.grall@arm.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.