linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/pseries: Fix to clear security feature flags
@ 2018-03-29 18:32 Mauricio Faria de Oliveira
  2018-03-31 14:04 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Mauricio Faria de Oliveira @ 2018-03-29 18:32 UTC (permalink / raw)
  To: mpe, linuxppc-dev

The H_CPU_BEHAV_* flags should be checked for in the 'behaviour' field
of 'struct h_cpu_char_result' -- 'character' is for H_CPU_CHAR_* flags.

Found it by playing around with QEMU's implementation of the hypercall:

Example: 
  H_CPU_CHAR=0xf000000000000000
  H_CPU_BEHAV=0x0000000000000000

  This clears H_CPU_BEHAV_FAVOUR_SECURITY and H_CPU_BEHAV_L1D_FLUSH_PR
  so pseries_setup_rfi_flush() disables 'rfi_flush'; and it also clears
  H_CPU_CHAR_L1D_THREAD_PRIV flag.  So there is no RFI flush mitigation
  at all for cpu_show_meltdown() to report; but currently it does:

  Original kernel:

    # cat /sys/devices/system/cpu/vulnerabilities/meltdown
    Mitigation: RFI Flush

  Patched kernel:

    # cat /sys/devices/system/cpu/vulnerabilities/meltdown
    Not affected

Example:
  H_CPU_CHAR=0x0000000000000000
  H_CPU_BEHAV=0xf000000000000000

  This sets H_CPU_BEHAV_BNDS_CHK_SPEC_BAR so cpu_show_spectre_v1() should
  report vulnerable; but currently it doesn't:

  Original kernel:

    # cat /sys/devices/system/cpu/vulnerabilities/spectre_v1
    Not affected

  Patched kernel:

    # cat /sys/devices/system/cpu/vulnerabilities/spectre_v1
    Vulnerable

Fixes: f636c14790ea ("powerpc/pseries: Set or clear security feature flags")
Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/pseries/setup.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 1f12235..b11564f 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -484,13 +484,13 @@ static void init_cpu_char_feature_flags(struct h_cpu_char_result *result)
 	 * The features below are enabled by default, so we instead look to see
 	 * if firmware has *disabled* them, and clear them if so.
 	 */
-	if (!(result->character & H_CPU_BEHAV_FAVOUR_SECURITY))
+	if (!(result->behaviour & H_CPU_BEHAV_FAVOUR_SECURITY))
 		security_ftr_clear(SEC_FTR_FAVOUR_SECURITY);
 
-	if (!(result->character & H_CPU_BEHAV_L1D_FLUSH_PR))
+	if (!(result->behaviour & H_CPU_BEHAV_L1D_FLUSH_PR))
 		security_ftr_clear(SEC_FTR_L1D_FLUSH_PR);
 
-	if (!(result->character & H_CPU_BEHAV_BNDS_CHK_SPEC_BAR))
+	if (!(result->behaviour & H_CPU_BEHAV_BNDS_CHK_SPEC_BAR))
 		security_ftr_clear(SEC_FTR_BNDS_CHK_SPEC_BAR);
 }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: powerpc/pseries: Fix to clear security feature flags
  2018-03-29 18:32 [PATCH] powerpc/pseries: Fix to clear security feature flags Mauricio Faria de Oliveira
@ 2018-03-31 14:04 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2018-03-31 14:04 UTC (permalink / raw)
  To: Mauricio Faria de Oliveira, linuxppc-dev

On Thu, 2018-03-29 at 18:32:11 UTC, Mauricio Faria de Oliveira wrote:
> The H_CPU_BEHAV_* flags should be checked for in the 'behaviour' field
> of 'struct h_cpu_char_result' -- 'character' is for H_CPU_CHAR_* flags.
> 
> Found it by playing around with QEMU's implementation of the hypercall:
> 
> Example: 
>   H_CPU_CHAR=0xf000000000000000
>   H_CPU_BEHAV=0x0000000000000000
> 
>   This clears H_CPU_BEHAV_FAVOUR_SECURITY and H_CPU_BEHAV_L1D_FLUSH_PR
>   so pseries_setup_rfi_flush() disables 'rfi_flush'; and it also clears
>   H_CPU_CHAR_L1D_THREAD_PRIV flag.  So there is no RFI flush mitigation
>   at all for cpu_show_meltdown() to report; but currently it does:
> 
>   Original kernel:
> 
>     # cat /sys/devices/system/cpu/vulnerabilities/meltdown
>     Mitigation: RFI Flush
> 
>   Patched kernel:
> 
>     # cat /sys/devices/system/cpu/vulnerabilities/meltdown
>     Not affected
> 
> Example:
>   H_CPU_CHAR=0x0000000000000000
>   H_CPU_BEHAV=0xf000000000000000
> 
>   This sets H_CPU_BEHAV_BNDS_CHK_SPEC_BAR so cpu_show_spectre_v1() should
>   report vulnerable; but currently it doesn't:
> 
>   Original kernel:
> 
>     # cat /sys/devices/system/cpu/vulnerabilities/spectre_v1
>     Not affected
> 
>   Patched kernel:
> 
>     # cat /sys/devices/system/cpu/vulnerabilities/spectre_v1
>     Vulnerable
> 
> Fixes: f636c14790ea ("powerpc/pseries: Set or clear security feature flags")
> Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/0f9bdfe3c77091e8704d2e510eb7c2

cheers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-31 14:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-29 18:32 [PATCH] powerpc/pseries: Fix to clear security feature flags Mauricio Faria de Oliveira
2018-03-31 14:04 ` Michael Ellerman

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