linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
	Will Deacon <will.deacon@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andy Lutomirski <luto@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Christoffer Dall <christoffer.dall@arm.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	Dominik Brodowski <linux@dominikbrodowski.net>,
	Julien Grall <julien.grall@arm.com>
Subject: Re: [PATCH v2 08/17] arm64: ssbd: Restore mitigation status on CPU resume
Date: Tue, 29 May 2018 14:35:13 +0100	[thread overview]
Message-ID: <20180529133510.xopxpmxf7ypjeksc@lakrids.cambridge.arm.com> (raw)
In-Reply-To: <20180529121121.24927-9-marc.zyngier@arm.com>

On Tue, May 29, 2018 at 01:11:12PM +0100, Marc Zyngier wrote:
> On a system where firmware can dynamically change the state of the
> mitigation, the CPU will always come up with the mitigation enabled,
> including when coming back from suspend.
> 
> If the user has requested "no mitigation" via a command line option,
> let's enforce it by calling into the firmware again to disable it.
> 
> Similarily, for a resume from hibernate, the mitigation could have
> been disabled by the boot kernel. Let's ensure that it is set
> back on in that case.
> 
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>

With teh fixup in swsusp_arch_suspend(), this looks good to me. FWIW:

Reviewed-by: Mark Rutland <mark.rutland@arm.com>

Mark.

> ---
>  arch/arm64/include/asm/cpufeature.h |  6 ++++++
>  arch/arm64/kernel/cpu_errata.c      |  2 +-
>  arch/arm64/kernel/hibernate.c       | 11 +++++++++++
>  arch/arm64/kernel/suspend.c         |  8 ++++++++
>  4 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
> index b0fc3224ce8a..55bc1f073bfb 100644
> --- a/arch/arm64/include/asm/cpufeature.h
> +++ b/arch/arm64/include/asm/cpufeature.h
> @@ -553,6 +553,12 @@ static inline int arm64_get_ssbd_state(void)
>  #endif
>  }
>  
> +#ifdef CONFIG_ARM64_SSBD
> +void arm64_set_ssbd_mitigation(bool state);
> +#else
> +static inline void arm64_set_ssbd_mitigation(bool state) {}
> +#endif
> +
>  #endif /* __ASSEMBLY__ */
>  
>  #endif
> diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
> index 2fef634e6953..2b9a31a6a16a 100644
> --- a/arch/arm64/kernel/cpu_errata.c
> +++ b/arch/arm64/kernel/cpu_errata.c
> @@ -303,7 +303,7 @@ void __init arm64_enable_wa2_handling(struct alt_instr *alt,
>  		*updptr = cpu_to_le32(aarch64_insn_gen_nop());
>  }
>  
> -static void arm64_set_ssbd_mitigation(bool state)
> +void arm64_set_ssbd_mitigation(bool state)
>  {
>  	switch (psci_ops.conduit) {
>  	case PSCI_CONDUIT_HVC:
> diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c
> index 1ec5f28c39fc..6b2686d54411 100644
> --- a/arch/arm64/kernel/hibernate.c
> +++ b/arch/arm64/kernel/hibernate.c
> @@ -313,6 +313,17 @@ int swsusp_arch_suspend(void)
>  
>  		sleep_cpu = -EINVAL;
>  		__cpu_suspend_exit();
> +
> +		/*
> +		 * Just in case the boot kernel did turn the SSBD
> +		 * mitigation off behind our back, let's set the state
> +		 * to what we expect it to be.
> +		 */
> +		switch (arm64_get_ssbd_state()) {
> +		case ARM64_SSBD_FORCE_ENABLE:
> +		case ARM64_SSBD_KERNEL:
> +			arm64_set_ssbd_mitigation(true);
> +		}
>  	}
>  
>  	local_daif_restore(flags);
> diff --git a/arch/arm64/kernel/suspend.c b/arch/arm64/kernel/suspend.c
> index a307b9e13392..70c283368b64 100644
> --- a/arch/arm64/kernel/suspend.c
> +++ b/arch/arm64/kernel/suspend.c
> @@ -62,6 +62,14 @@ void notrace __cpu_suspend_exit(void)
>  	 */
>  	if (hw_breakpoint_restore)
>  		hw_breakpoint_restore(cpu);
> +
> +	/*
> +	 * On resume, firmware implementing dynamic mitigation will
> +	 * have turned the mitigation on. If the user has forcefully
> +	 * disabled it, make sure their wishes are obeyed.
> +	 */
> +	if (arm64_get_ssbd_state() == ARM64_SSBD_FORCE_DISABLE)
> +		arm64_set_ssbd_mitigation(false);
>  }
>  
>  /*
> -- 
> 2.14.2
> 

  reply	other threads:[~2018-05-29 13:35 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-29 12:11 [PATCH v2 00/17] arm64 SSBD (aka Spectre-v4) mitigation Marc Zyngier
2018-05-29 12:11 ` [PATCH v2 01/17] arm/arm64: smccc: Add SMCCC-specific return codes Marc Zyngier
2018-05-29 12:11 ` [PATCH v2 02/17] arm64: Call ARCH_WORKAROUND_2 on transitions between EL0 and EL1 Marc Zyngier
2018-05-29 12:11 ` [PATCH v2 03/17] arm64: Add per-cpu infrastructure to call ARCH_WORKAROUND_2 Marc Zyngier
2018-05-29 12:11 ` [PATCH v2 04/17] arm64: Add ARCH_WORKAROUND_2 probing Marc Zyngier
2018-05-29 13:39   ` Suzuki K Poulose
2018-05-29 12:11 ` [PATCH v2 05/17] arm64: Add 'ssbd' command-line option Marc Zyngier
2018-06-09 12:53   ` Jon Masters
2018-06-09 13:19     ` Marc Zyngier
2018-05-29 12:11 ` [PATCH v2 06/17] arm64: ssbd: Add global mitigation state accessor Marc Zyngier
2018-05-29 12:11 ` [PATCH v2 07/17] arm64: ssbd: Skip apply_ssbd if not using dynamic mitigation Marc Zyngier
2018-06-09 13:03   ` Jon Masters
2018-06-09 13:21     ` Marc Zyngier
2018-05-29 12:11 ` [PATCH v2 08/17] arm64: ssbd: Restore mitigation status on CPU resume Marc Zyngier
2018-05-29 13:35   ` Mark Rutland [this message]
2018-05-29 12:11 ` [PATCH v2 09/17] arm64: ssbd: Introduce thread flag to control userspace mitigation Marc Zyngier
2018-05-29 12:11 ` [PATCH v2 10/17] arm64: ssbd: Add prctl interface for per-thread mitigation Marc Zyngier
2018-05-29 12:11 ` [PATCH v2 11/17] arm64: KVM: Add HYP per-cpu accessors Marc Zyngier
2018-05-29 12:11 ` [PATCH v2 12/17] arm64: KVM: Add ARCH_WORKAROUND_2 support for guests Marc Zyngier
2018-06-09 13:09   ` Jon Masters
2018-06-09 13:21     ` Marc Zyngier
2018-05-29 12:11 ` [PATCH v2 13/17] arm64: KVM: Handle guest's ARCH_WORKAROUND_2 requests Marc Zyngier
2018-05-29 12:11 ` [PATCH v2 14/17] arm64: KVM: Add ARCH_WORKAROUND_2 discovery through ARCH_FEATURES_FUNC_ID Marc Zyngier
2018-05-29 12:11 ` [PATCH v2 15/17] arm64: Add test_and_clear_flag and set_flag atomic assembler primitives Marc Zyngier
2018-05-29 12:11 ` [PATCH v2 16/17] arm64: ssbd: Enable delayed setting of TIF_SSBD Marc Zyngier
2018-05-29 12:11 ` [PATCH v2 17/17] arm64: ssbd: Implement arch_seccomp_spec_mitigate Marc Zyngier
2018-05-30 15:58 ` [PATCH v2 00/17] arm64 SSBD (aka Spectre-v4) mitigation Will Deacon
2018-05-31 16:41 ` Catalin Marinas
2018-05-31 16:55   ` Marc Zyngier
2018-06-09 13:16 ` Jon Masters

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=20180529133510.xopxpmxf7ypjeksc@lakrids.cambridge.arm.com \
    --to=mark.rutland@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=christoffer.dall@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=julien.grall@arm.com \
    --cc=keescook@chromium.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --cc=luto@kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=rdunlap@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).