From: Michael Ellerman <mpe@ellerman.id.au>
To: linuxppc-dev@ozlabs.org
Subject: [RFC PATCH 8/10] powerpc/pseries: Use the security flags in pseries_setup_rfi_flush()
Date: Fri, 2 Mar 2018 22:58:44 +1100 [thread overview]
Message-ID: <20180302115846.12240-2-mpe@ellerman.id.au> (raw)
In-Reply-To: <20180302115846.12240-1-mpe@ellerman.id.au>
Now that we have the security flags we can simplify the code in
pseries_setup_rfi_flush() because the security flags have pessimistic
defaults.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/platforms/pseries/setup.c | 39 ++++++++++++++--------------------
1 file changed, 16 insertions(+), 23 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 8ae04b586abe..2af14af6c410 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -501,38 +501,31 @@ static void pseries_setup_rfi_flush(void)
bool enable;
long rc;
- /* Enable by default */
- enable = true;
-
rc = plpar_get_cpu_characteristics(&result);
- if (rc == H_SUCCESS) {
+ if (rc == H_SUCCESS)
init_cpu_char_feature_flags(&result);
- types = L1D_FLUSH_NONE;
-
- if (result.character & H_CPU_CHAR_L1D_FLUSH_TRIG2)
- types |= L1D_FLUSH_MTTRIG;
- if (result.character & H_CPU_CHAR_L1D_FLUSH_ORI30)
- types |= L1D_FLUSH_ORI;
-
- /* Use fallback if nothing set in hcall */
- if (types == L1D_FLUSH_NONE)
- types = L1D_FLUSH_FALLBACK;
-
- if ((!(result.behaviour & H_CPU_BEHAV_L1D_FLUSH_PR)) ||
- (!(result.behaviour & H_CPU_BEHAV_FAVOUR_SECURITY)))
- enable = false;
- } else {
- /* Default to fallback if case hcall is not available */
- types = L1D_FLUSH_FALLBACK;
- }
-
/*
* 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);
+ types = L1D_FLUSH_NONE;
+
+ if (security_ftr_enabled(SEC_FTR_L1D_FLUSH_TRIG2))
+ types |= L1D_FLUSH_MTTRIG;
+
+ if (security_ftr_enabled(SEC_FTR_L1D_FLUSH_ORI30))
+ types |= L1D_FLUSH_ORI;
+
+ /* Use fallback if nothing set in hcall */
+ if (types == L1D_FLUSH_NONE)
+ types = L1D_FLUSH_FALLBACK;
+
+ enable = security_ftr_enabled(SEC_FTR_FAVOUR_SECURITY) && \
+ security_ftr_enabled(SEC_FTR_L1D_FLUSH_PR);
+
setup_rfi_flush(types, enable);
}
--
2.14.1
next prev parent reply other threads:[~2018-03-02 11:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-28 14:53 [RFC PATCH 1/6] powerpc: Add security feature flags for Spectre/Meltdown Michael Ellerman
2018-02-28 14:53 ` [RFC PATCH 2/6] powerpc/pseries: Add new H_GET_CPU_CHARACTERISTICS flags Michael Ellerman
2018-02-28 14:53 ` [RFC PATCH 3/6] powerpc/pseries: Set or clear security feature flags Michael Ellerman
2018-02-28 14:53 ` [RFC PATCH 4/6] powerpc/powernv: " Michael Ellerman
2018-02-28 14:53 ` [RFC PATCH 5/6] powerpc/64s: Move cpu_show_meltdown() Michael Ellerman
2018-02-28 14:53 ` [RFC PATCH 6/6] powerpc/64s: Enhance the information in cpu_show_meltdown() Michael Ellerman
2018-02-28 15:04 ` [RFC PATCH 1/6] powerpc: Add security feature flags for Spectre/Meltdown Segher Boessenkool
2018-03-01 13:19 ` Michael Ellerman
2018-03-01 0:34 ` Daniel Axtens
2018-03-01 13:20 ` Michael Ellerman
2018-03-02 11:58 ` [RFC PATCH 7/10] powerpc/powernv: Use the security flags in pnv_setup_rfi_flush() Michael Ellerman
2018-03-02 11:58 ` Michael Ellerman [this message]
2018-03-02 11:58 ` [RFC PATCH 9/10] powerpc/64s: Wire up cpu_show_spectre_v1() Michael Ellerman
2018-03-02 11:58 ` [RFC PATCH 10/10] powerpc/64s: Wire up cpu_show_spectre_v2() Michael Ellerman
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=20180302115846.12240-2-mpe@ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=linuxppc-dev@ozlabs.org \
/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).