From: konrad.wilk@oracle.com
To: speck@linutronix.de
Subject: [MODERATED] [patch 4/8] [PATCH v1.3.1 4/7] Linux Patch 4
Date: Thu, 12 Apr 2018 22:26:53 -0400 [thread overview]
Message-ID: <20180413022657.402368163@localhost.localdomain> (raw)
x86/mdd/firmware calls: Save/Restore the MDD bit when using SPEC_CTRL
.. when we perform the IBRS calls for firmware calls we need
to take into account the MD bit as well. This is a bit complicated
in the assembler constructs as the value is no more a constant
but a variable.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
v3: s/md_v4/mdd/
v3.1: Add spec_ctrl_firmware to use only when going to SMI.
---
arch/x86/include/asm/nospec-branch.h | 12 ++++++++----
arch/x86/kernel/cpu/bugs.c | 3 +++
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
index 7c6ed8b1b19b..c3856b3f42eb 100644
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -226,6 +226,7 @@ enum md_mitigation {
extern enum md_mitigation md_mode;
extern u64 spec_ctrl_priv;
extern u64 spec_ctrl_unpriv;
+extern u64 spec_ctrl_firmware;
static inline bool mdd_at_boot(void)
{
@@ -263,12 +264,13 @@ static inline void vmexit_fill_RSB(void)
"movl $0, %%edx\n\t" \
"wrmsr", \
_feature) \
- : : [msr] "i" (_msr), [val] "i" (_val) \
+ : : [msr] "i" (_msr), [val] "m" (_val) \
: "eax", "ecx", "edx", "memory")
static inline void indirect_branch_prediction_barrier(void)
{
- alternative_msr_write(MSR_IA32_PRED_CMD, PRED_CMD_IBPB,
+ u64 val = PRED_CMD_IBPB;
+ alternative_msr_write(MSR_IA32_PRED_CMD, val,
X86_FEATURE_USE_IBPB);
}
@@ -281,13 +283,15 @@ static inline void indirect_branch_prediction_barrier(void)
#define firmware_restrict_branch_speculation_start() \
do { \
preempt_disable(); \
- alternative_msr_write(MSR_IA32_SPEC_CTRL, SPEC_CTRL_IBRS, \
+ alternative_msr_write(MSR_IA32_SPEC_CTRL, \
+ spec_ctrl_firmware, \
X86_FEATURE_USE_IBRS_FW); \
} while (0)
#define firmware_restrict_branch_speculation_end() \
do { \
- alternative_msr_write(MSR_IA32_SPEC_CTRL, 0, \
+ alternative_msr_write(MSR_IA32_SPEC_CTRL, \
+ spec_ctrl_unpriv, \
X86_FEATURE_USE_IBRS_FW); \
preempt_enable(); \
} while (0)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 73f76d0f5181..250baf24da56 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -329,6 +329,9 @@ EXPORT_SYMBOL_GPL(spec_ctrl_priv);
u64 spec_ctrl_unpriv;
EXPORT_SYMBOL_GPL(spec_ctrl_unpriv);
+/* When switching from higher to SMI privilege level. */
+u64 spec_ctrl_firmware = SPEC_CTRL_IBRS;
+
/* The kernel command line selection */
enum md_mitigation_cmd {
MD_CMD_NONE,
--
2.14.3
reply other threads:[~2018-04-18 14:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20180413022657.402368163@localhost.localdomain \
--to=konrad.wilk@oracle.com \
--cc=speck@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.