From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
To: Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org
Cc: linux-kernel@vger.kernel.org, Dave Hansen <dave.hansen@intel.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: [PATCH 3/3] x86/asm: Add support for WBNOINVD instruction
Date: Fri, 19 Jan 2018 15:18:21 +0300 [thread overview]
Message-ID: <20180119121821.77018-4-kirill.shutemov@linux.intel.com> (raw)
In-Reply-To: <20180119121821.77018-1-kirill.shutemov@linux.intel.com>
This patch implements infrastructure to call WBNOINVD instruction.
The basic idea is to match what we have for WBINVD.
The instruction is defined as WBINVD with REP (0xf3) prefix. If the
machine doesn't support the instruction the prefix will be ignored and
we would fallback to WBINVD.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
arch/x86/include/asm/smp.h | 10 ++++++++++
arch/x86/include/asm/special_insns.h | 5 +++++
arch/x86/lib/cache-smp.c | 17 +++++++++++++++++
3 files changed, 32 insertions(+)
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 461f53d27708..cadaf5e0ea92 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -140,6 +140,8 @@ void native_play_dead(void);
void play_dead_common(void);
void wbinvd_on_cpu(int cpu);
int wbinvd_on_all_cpus(void);
+void wbnoinvd_on_cpu(int cpu);
+int wbnoinvd_on_all_cpus(void);
void native_send_call_func_ipi(const struct cpumask *mask);
void native_send_call_func_single_ipi(int cpu);
@@ -170,6 +172,14 @@ static inline int wbinvd_on_all_cpus(void)
wbinvd();
return 0;
}
+
+#define wbnoinvd_on_cpu(cpu) wbnoinvd()
+static inline int wbnoinvd_on_all_cpus(void)
+{
+ wbnoinvd();
+ return 0;
+}
+
#define smp_num_siblings 1
#endif /* CONFIG_SMP */
diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h
index 0d9c28a7833d..03d01446fff6 100644
--- a/arch/x86/include/asm/special_insns.h
+++ b/arch/x86/include/asm/special_insns.h
@@ -134,6 +134,11 @@ static inline void wbinvd(void)
asm volatile("wbinvd": : :"memory");
}
+static inline void wbnoinvd(void)
+{
+ asm volatile(".byte 0xf3; wbinvd": : :"memory");
+}
+
extern asmlinkage void native_load_gs_index(unsigned);
static inline unsigned long __read_cr4(void)
diff --git a/arch/x86/lib/cache-smp.c b/arch/x86/lib/cache-smp.c
index 1811fa4a1b1a..e881741d0367 100644
--- a/arch/x86/lib/cache-smp.c
+++ b/arch/x86/lib/cache-smp.c
@@ -18,3 +18,20 @@ int wbinvd_on_all_cpus(void)
return on_each_cpu(__wbinvd, NULL, 1);
}
EXPORT_SYMBOL(wbinvd_on_all_cpus);
+
+static void __wbnoinvd(void *dummy)
+{
+ wbnoinvd();
+}
+
+void wbnoinvd_on_cpu(int cpu)
+{
+ smp_call_function_single(cpu, __wbnoinvd, NULL, 1);
+}
+EXPORT_SYMBOL(wbnoinvd_on_cpu);
+
+int wbnoinvd_on_all_cpus(void)
+{
+ return on_each_cpu(__wbnoinvd, NULL, 1);
+}
+EXPORT_SYMBOL(wbnoinvd_on_all_cpus);
--
2.15.1
next prev parent reply other threads:[~2018-01-19 12:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-19 12:18 [PATCH 0/3] Drop pv_cpu_ops::wbinvd() and bring support of WBNOINVD Kirill A. Shutemov
2018-01-19 12:18 ` [PATCH 1/3] x86/paravirt: Drop pv_cpu_ops::wbinvd() Kirill A. Shutemov
2018-01-19 12:18 ` [PATCH 2/3] x86/cpufeatures: Add WBNOINVD cpufeature Kirill A. Shutemov
2018-03-15 9:17 ` Thomas Gleixner
2018-01-19 12:18 ` Kirill A. Shutemov [this message]
2018-03-15 9:21 ` [PATCH 3/3] x86/asm: Add support for WBNOINVD instruction Thomas Gleixner
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=20180119121821.77018-4-kirill.shutemov@linux.intel.com \
--to=kirill.shutemov@linux.intel.com \
--cc=dave.hansen@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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
all inboxes | Powered by JetHome®