Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2363834imm; Mon, 28 May 2018 06:47:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZplt4ta0H3JpvekAXe0bYRk2pfaiUUfJogbJ/pGeT6SLmMnjNQjl9NV/BtbnHpygc5aY9Jl X-Received: by 2002:a62:8dc9:: with SMTP id p70-v6mr13542102pfk.72.1527515222777; Mon, 28 May 2018 06:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527515222; cv=none; d=google.com; s=arc-20160816; b=AbRutWiewu/BOrXfQDHSCjfteOrrz+n8xuBQsSevC9qaHgkX7sFcZcJjVtt7bIdkQq rV5y1A+mzsujMuKeNeBD1ecBQJ9RlCYQQtoueqsKa1ex/Nh8RSy+n+A3lfAY+JnyS78v 8b1H5COtQLbZ56fckKwe3DN6wtd0do2aX60Hs8U4ocR8q8Asy6up1w3VOvWaj86CWcXk 7wnwFjuCkCzancXjuhHx1HVPPGV4V1P7hBHTDO0hrV5tdrMrbZ+ESwWN/jqhUP+HDhAP 8f7cawt2h0gaTXSzc+RVROhAbeyHDTfI/YYBltfdqfWyAWHaVF5VHMj6OIVU5bafFuCJ 2O/g== 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=un3J1210pY2KNOVQ+00LQgkC/b/5iOsTil21cdMxZC0=; b=z9NPluClkesth2tRNcGw4iIaPwZdBWFgK2gSG5LXvLpTt3V+xXMWc04OoLzEQpkzfL MOwSXDKqtoj204JkpmuB5MDjXIdhmbjj2Ak4NGGLX+BKFv2dhudFEUwHyDt3JOFn3Gan 8/oL0yW3H6bn/+4FiQnL3kZ9KKaU55LgLr5yvyCtStC1za7SbqzZYXVjcSDGGvoTCcCj ip+9DYJ1EduqvFulMUw5/swcq7PSsNeGsogS0I+c6/hlSBXpC/2O3pSpXTwVs8Sr8ooQ HCtXrgAgXz4+vLQRQ8dUIhtFLB43WJzmcYoMnOZl9LDGMYJ0ViaQntjHa9B1rcJlPpOp 0NvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D/QR1dS0; 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 h91-v6si29488575pld.132.2018.05.28.06.46.47; Mon, 28 May 2018 06:47:02 -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=D/QR1dS0; 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 S1165509AbeE1Np1 (ORCPT + 99 others); Mon, 28 May 2018 09:45:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:34294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937425AbeE1KnK (ORCPT ); Mon, 28 May 2018 06:43:10 -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 ABD1A20660; Mon, 28 May 2018 10:43:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527504190; bh=7ZXl4hnfASSdOnuFBWEyBPvdLl13CeP/40naZIo6zEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D/QR1dS0ZAsu2P7hXTd7GwNotDvhgZhLYyUFm0CI8obdRlXMPVb5XqEeVIYxQZf+D xYQ7yXptcI7nGu0J0448xMbpJhNEsTS3Gf9vdcnC0xpxk3N2ffOIS/nmqRAcWdJ3F6 LSJobcLQGJRkEHBDDJWER5tIC5mDwGA6HvRPZxSQ= 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.14 048/496] powerpc/powernv: Use the security flags in pnv_setup_rfi_flush() Date: Mon, 28 May 2018 11:57:13 +0200 Message-Id: <20180528100321.771238252@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@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.14-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 @@ -65,7 +65,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)) @@ -98,11 +98,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"); @@ -110,40 +109,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)