Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1924504imm; Thu, 24 May 2018 03:01:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpeG6tdJra1Q2eXbY/PKju5x9O4Bh0VTD9/BnwFrXL3OLinLmRusynoz0SJYkQgrE82wrGj X-Received: by 2002:a17:902:ba87:: with SMTP id k7-v6mr6681189pls.193.1527156118769; Thu, 24 May 2018 03:01:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527156118; cv=none; d=google.com; s=arc-20160816; b=fu35cpkTbnsAmAqO0K3ZxcpOwyn4hx+MowURql5K983BKry2MOUuQq8laoCJFub8Zw D3cpvN+tm0A/D3SH6w7V8IL8Bp0MCdflvOtg0B7knVMoX812qPXnon3eKncfVb24Va4d aeS/YCmBaN5akFeCKQnv9SjbYOp9pT+KXIyZo9jf4LDx82SaFB727/KlvDcOQimJuG4Z MdMTfe21oJWAbuTbu58qV5mVPwc5DRVu8J2txsJZuMAU48IZDy6MCklg3Y5cbIFH/jsJ yHBogFLmLyIO7jeqwlrgFodxuRNQZHNgmZ/iB7QFDOwq/7a25Ebj2WfLSiVH4G2NLJ0J sIlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Ilkctlkw3EuLS9edG72OzQHlnuhuRIaeD+T9qOdGHFM=; b=ZZ7wxitjvhZQKxM6Diy3r9QJh9PvdY0zDnU5tQnHMrI5EbnqRSUsLDl779QVldRmFO n+a/FUiSqedbNWxez+P1RGfeUGBfnOLWBS37b+dI7VBjItMB0ohZUPiV8upQdbqyvPG6 HBX5HSfSVviljpskL644aBXJ2LSQe3P9CUZRUXWv2r2HGPyz/9evxYUtdtVtOn8evxZA fUHzMRUL3g7BeKQDndaBsn0xtjWc/RKaYZFJs+XFtRbegk4MTig5qAHrbkVsxIMyTnjv QU9OF4O6YBhQcyUVyBJ2pXlBa9979jcVofGRqkCEgjCQzoOxSRErapBgLbk24i45RtM4 0Hgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gC9x7x59; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a81-v6si21378693pfg.200.2018.05.24.03.01.43; Thu, 24 May 2018 03:01:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gC9x7x59; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030839AbeEXKA6 (ORCPT + 99 others); Thu, 24 May 2018 06:00:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:43410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968476AbeEXKAm (ORCPT ); Thu, 24 May 2018 06:00:42 -0400 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 E7D0320870; Thu, 24 May 2018 10:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156041; bh=QfOaW3/qKX7442A9nT/qO3Su5OUcM7+tU82eFwfefU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gC9x7x59BBtvUEm96bFD2scrR5q9xn2/pN4Cr42txHnsSzevdrk4L3BbLy0+WzawJ 5wxOTK+2scooSrxAwqMzHQEHDeEmJrmFE3T307i6P9lmMMOabU/KLCjTNabXnifvMR Yho1eCJCIHjOLApDGN4dXJUY9X7taGYbZVCNjwxc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, greg@kroah.com Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Ellerman Subject: [PATCH 4.16 042/161] powerpc/powernv: Use the security flags in pnv_setup_rfi_flush() Date: Thu, 24 May 2018 11:37:47 +0200 Message-Id: <20180524093023.407204916@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Ellerman commit 37c0bdd00d3ae83369ab60a6712c28e11e6458d5 upstream. Now that we have the security flags we can significantly simplify the code in pnv_setup_rfi_flush(), because we can use the flags instead of checking device tree properties and because the security flags have pessimistic defaults. Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/platforms/powernv/setup.c | 41 ++++++++------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) --- a/arch/powerpc/platforms/powernv/setup.c +++ b/arch/powerpc/platforms/powernv/setup.c @@ -66,7 +66,7 @@ static void init_fw_feat_flags(struct de if (fw_feature_is("enabled", "fw-bcctrl-serialized", np)) security_ftr_set(SEC_FTR_BCCTRL_SERIALISED); - if (fw_feature_is("enabled", "inst-spec-barrier-ori31,31,0", np)) + if (fw_feature_is("enabled", "inst-l1d-flush-ori30,30,0", np)) security_ftr_set(SEC_FTR_L1D_FLUSH_ORI30); if (fw_feature_is("enabled", "inst-l1d-flush-trig2", np)) @@ -99,11 +99,10 @@ static void pnv_setup_rfi_flush(void) { struct device_node *np, *fw_features; enum l1d_flush_type type; - int enable; + bool enable; /* Default to fallback in case fw-features are not available */ type = L1D_FLUSH_FALLBACK; - enable = 1; np = of_find_node_by_name(NULL, "ibm,opal"); fw_features = of_get_child_by_name(np, "fw-features"); @@ -111,40 +110,20 @@ static void pnv_setup_rfi_flush(void) if (fw_features) { init_fw_feat_flags(fw_features); + of_node_put(fw_features); - np = of_get_child_by_name(fw_features, "inst-l1d-flush-trig2"); - if (np && of_property_read_bool(np, "enabled")) + if (security_ftr_enabled(SEC_FTR_L1D_FLUSH_TRIG2)) type = L1D_FLUSH_MTTRIG; - of_node_put(np); - - np = of_get_child_by_name(fw_features, "inst-l1d-flush-ori30,30,0"); - if (np && of_property_read_bool(np, "enabled")) + if (security_ftr_enabled(SEC_FTR_L1D_FLUSH_ORI30)) type = L1D_FLUSH_ORI; - - of_node_put(np); - - /* Enable unless firmware says NOT to */ - enable = 2; - np = of_get_child_by_name(fw_features, "needs-l1d-flush-msr-hv-1-to-0"); - if (np && of_property_read_bool(np, "disabled")) - enable--; - - of_node_put(np); - - np = of_get_child_by_name(fw_features, "needs-l1d-flush-msr-pr-0-to-1"); - if (np && of_property_read_bool(np, "disabled")) - enable--; - - np = of_get_child_by_name(fw_features, "speculation-policy-favor-security"); - if (np && of_property_read_bool(np, "disabled")) - enable = 0; - - of_node_put(np); - of_node_put(fw_features); } - setup_rfi_flush(type, enable > 0); + enable = security_ftr_enabled(SEC_FTR_FAVOUR_SECURITY) && \ + (security_ftr_enabled(SEC_FTR_L1D_FLUSH_PR) || \ + security_ftr_enabled(SEC_FTR_L1D_FLUSH_HV)); + + setup_rfi_flush(type, enable); } static void __init pnv_setup_arch(void)