From patchwork Sat Jun 2 13:35:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 924509 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40yjsK4tqYz9s02 for ; Sun, 3 Jun 2018 00:15:33 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="hXupA8IB"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40yjsK3B1qzF1Cq for ; Sun, 3 Jun 2018 00:15:33 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="hXupA8IB"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40yj1F4PdPzF0tX for ; Sat, 2 Jun 2018 23:37:21 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="hXupA8IB"; dkim-atps=neutral Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) by bilbo.ozlabs.org (Postfix) with ESMTP id 40yj1F2v83z8tGk for ; Sat, 2 Jun 2018 23:37:21 +1000 (AEST) Received: by ozlabs.org (Postfix) id 40yj1F25w8z9s0x; Sat, 2 Jun 2018 23:37:21 +1000 (AEST) Delivered-To: linuxppc-dev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=kernel.org (client-ip=198.145.29.99; helo=mail.kernel.org; envelope-from=srs0=e1is=iu=linuxfoundation.org=gregkh@kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="hXupA8IB"; dkim-atps=neutral Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40yj1D54nFz9s08 for ; Sat, 2 Jun 2018 23:37:20 +1000 (AEST) Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C6F4D20876; Sat, 2 Jun 2018 13:37:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527946639; bh=SmmWdVhrynI3k0P6X2/VIQWf+BScAOGtVMcyuAaic58=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=hXupA8IB+HClVfpiGb0ocrDxFoUtcpIF//c/Zv8F3UkFOIA5qWey8ClE82tf9x1O/ dkC439pbC1Rvw4d6PGD8DMKWb219st5J51dCVUjt0aMJUisINLhWQ4QrqhLdhM0s+h NjL2JbIo+wFnqw7D3rTv6W2rUhZywaQRpCbaRuew= Subject: Patch "powerpc/pseries: Set or clear security feature flags" has been added to the 4.9-stable tree To: gregkh@linuxfoundation.org,linuxppc-dev@ozlabs.org,mpe@ellerman.id.au From: Date: Sat, 02 Jun 2018 15:35:41 +0200 In-Reply-To: <20180602110908.29773-12-mpe@ellerman.id.au> Message-ID: <152794654189239@kroah.com> MIME-Version: 1.0 X-stable: commit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stable-commits@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This is a note to let you know that I've just added the patch titled powerpc/pseries: Set or clear security feature flags to the 4.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: powerpc-pseries-set-or-clear-security-feature-flags.patch and it can be found in the queue-4.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. From foo@baz Sat Jun 2 15:29:05 CEST 2018 From: Michael Ellerman Date: Sat, 2 Jun 2018 21:08:56 +1000 Subject: powerpc/pseries: Set or clear security feature flags To: gregkh@linuxfoundation.org Cc: stable@vger.kernel.org, linuxppc-dev@ozlabs.org Message-ID: <20180602110908.29773-12-mpe@ellerman.id.au> From: Michael Ellerman commit f636c14790ead6cc22cf62279b1f8d7e11a67116 upstream. Now that we have feature flags for security related things, set or clear them based on what we receive from the hypercall. Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/platforms/pseries/setup.c | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) Patches currently in stable-queue which might be from mpe@ellerman.id.au are queue-4.9/powerpc-64s-clear-pcr-on-boot.patch queue-4.9/powerpc-rfi-flush-differentiate-enabled-and-patched-flush-types.patch queue-4.9/powerpc-64s-fix-section-mismatch-warnings-from-setup_rfi_flush.patch queue-4.9/powerpc-pseries-fix-clearing-of-security-feature-flags.patch queue-4.9/powerpc-powernv-set-or-clear-security-feature-flags.patch queue-4.9/powerpc-64s-move-cpu_show_meltdown.patch queue-4.9/powerpc-rfi-flush-call-setup_rfi_flush-after-lpm-migration.patch queue-4.9/powerpc-pseries-set-or-clear-security-feature-flags.patch queue-4.9/powerpc-rfi-flush-make-it-possible-to-call-setup_rfi_flush-again.patch queue-4.9/powerpc-move-default-security-feature-flags.patch queue-4.9/powerpc-powernv-use-the-security-flags-in-pnv_setup_rfi_flush.patch queue-4.9/powerpc-add-security-feature-flags-for-spectre-meltdown.patch queue-4.9/powerpc-pseries-use-the-security-flags-in-pseries_setup_rfi_flush.patch queue-4.9/powerpc-64s-enhance-the-information-in-cpu_show_meltdown.patch queue-4.9/powerpc-rfi-flush-move-out-of-hardlockup_detector-ifdef.patch queue-4.9/powerpc-rfi-flush-always-enable-fallback-flush-on-pseries.patch queue-4.9/powerpc-rfi-flush-move-the-logic-to-avoid-a-redo-into-the-debugfs-code.patch queue-4.9/powerpc-pseries-restore-default-security-feature-flags-on-setup.patch queue-4.9/powerpc-pseries-add-new-h_get_cpu_characteristics-flags.patch queue-4.9/powerpc-64s-add-support-for-a-store-forwarding-barrier-at-kernel-entry-exit.patch queue-4.9/powerpc-64s-wire-up-cpu_show_spectre_v1.patch queue-4.9/powerpc-powernv-support-firmware-disable-of-rfi-flush.patch queue-4.9/powerpc-pseries-support-firmware-disable-of-rfi-flush.patch queue-4.9/powerpc-64s-wire-up-cpu_show_spectre_v2.patch --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c @@ -66,6 +66,7 @@ #include #include #include +#include #include "pseries.h" @@ -450,6 +451,40 @@ static void __init find_and_init_phbs(vo of_pci_check_probe_only(); } +static void init_cpu_char_feature_flags(struct h_cpu_char_result *result) +{ + if (result->character & H_CPU_CHAR_SPEC_BAR_ORI31) + security_ftr_set(SEC_FTR_SPEC_BAR_ORI31); + + if (result->character & H_CPU_CHAR_BCCTRL_SERIALISED) + security_ftr_set(SEC_FTR_BCCTRL_SERIALISED); + + if (result->character & H_CPU_CHAR_L1D_FLUSH_ORI30) + security_ftr_set(SEC_FTR_L1D_FLUSH_ORI30); + + if (result->character & H_CPU_CHAR_L1D_FLUSH_TRIG2) + security_ftr_set(SEC_FTR_L1D_FLUSH_TRIG2); + + if (result->character & H_CPU_CHAR_L1D_THREAD_PRIV) + security_ftr_set(SEC_FTR_L1D_THREAD_PRIV); + + if (result->character & H_CPU_CHAR_COUNT_CACHE_DISABLED) + security_ftr_set(SEC_FTR_COUNT_CACHE_DISABLED); + + /* + * 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)) + security_ftr_clear(SEC_FTR_FAVOUR_SECURITY); + + if (!(result->character & H_CPU_BEHAV_L1D_FLUSH_PR)) + security_ftr_clear(SEC_FTR_L1D_FLUSH_PR); + + if (!(result->character & H_CPU_BEHAV_BNDS_CHK_SPEC_BAR)) + security_ftr_clear(SEC_FTR_BNDS_CHK_SPEC_BAR); +} + void pseries_setup_rfi_flush(void) { struct h_cpu_char_result result; @@ -463,6 +498,8 @@ void pseries_setup_rfi_flush(void) rc = plpar_get_cpu_characteristics(&result); if (rc == H_SUCCESS) { + init_cpu_char_feature_flags(&result); + if (result.character & H_CPU_CHAR_L1D_FLUSH_TRIG2) types |= L1D_FLUSH_MTTRIG; if (result.character & H_CPU_CHAR_L1D_FLUSH_ORI30) @@ -473,6 +510,12 @@ void pseries_setup_rfi_flush(void) enable = false; } + /* + * We're the guest so this doesn't apply to us, clear it to simplify + * handling of it elsewhere. + */ + security_ftr_clear(SEC_FTR_L1D_FLUSH_HV); + setup_rfi_flush(types, enable); }