[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-04651dd978a8749e59065df14b970a127f219ac2@git.kernel.org>
Date: Wed, 24 Jan 2018 04:48:58 -0800
From: tip-bot for Vitaly Kuznetsov <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: dazhan@...rosoft.com, haiyangz@...rosoft.com, kys@...rosoft.com,
hpa@...or.com, linux-kernel@...r.kernel.org, luto@...nel.org,
vkuznets@...hat.com, mingo@...nel.org, sthemmin@...rosoft.com,
tglx@...utronix.de, adityabh@...rosoft.com,
Michael.H.Kelley@...rosoft.com
Subject: [tip:x86/hyperv] x86/hyperv: Stop suppressing X86_FEATURE_PCID
Commit-ID: 04651dd978a8749e59065df14b970a127f219ac2
Gitweb: https://git.kernel.org/tip/04651dd978a8749e59065df14b970a127f219ac2
Author: Vitaly Kuznetsov <vkuznets@...hat.com>
AuthorDate: Wed, 24 Jan 2018 11:36:29 +0100
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitDate: Wed, 24 Jan 2018 13:44:57 +0100
x86/hyperv: Stop suppressing X86_FEATURE_PCID
When hypercall-based TLB flush was enabled for Hyper-V guests PCID feature
was deliberately suppressed as a precaution: back then PCID was never
exposed to Hyper-V guests and it wasn't clear what will happen if some day
it becomes available. The day came and PCID/INVPCID features are already
exposed on certain Hyper-V hosts.
>From TLFS (as of 5.0b) it is unclear how TLB flush hypercalls combine with
PCID. In particular the usage of PCID is per-cpu based: the same mm gets
different CR3 values on different CPUs. If the hypercall does exact
matching this will fail. However, this is not the case. David Zhang
explains:
"In practice, the AddressSpace argument is ignored on any VM that supports
PCIDs.
Architecturally, the AddressSpace argument must match the CR3 with PCID
bits stripped out (i.e., the low 12 bits of AddressSpace should be 0 in
long mode). The flush hypercalls flush all PCIDs for the specified
AddressSpace."
With this, PCID can be enabled.
Signed-off-by: Vitaly Kuznetsov <vkuznets@...hat.com>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Cc: David Zhang <dazhan@...rosoft.com>
Cc: Stephen Hemminger <sthemmin@...rosoft.com>
Cc: Haiyang Zhang <haiyangz@...rosoft.com>
Cc: "Michael Kelley (EOSG)" <Michael.H.Kelley@...rosoft.com>
Cc: Andy Lutomirski <luto@...nel.org>
Cc: devel@...uxdriverproject.org
Cc: "K. Y. Srinivasan" <kys@...rosoft.com>
Cc: Aditya Bhandari <adityabh@...rosoft.com>
Link: https://lkml.kernel.org/r/20180124103629.29980-1-vkuznets@redhat.com
---
arch/x86/hyperv/mmu.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
index 9cc9e1c..694abf1 100644
--- a/arch/x86/hyperv/mmu.c
+++ b/arch/x86/hyperv/mmu.c
@@ -111,7 +111,7 @@ static void hyperv_flush_tlb_others(const struct cpumask *cpus,
int cpu, vcpu, gva_n, max_gvas;
struct hv_flush_pcpu **flush_pcpu;
struct hv_flush_pcpu *flush;
- u64 status = U64_MAX;
+ u64 base, status = U64_MAX;
unsigned long flags;
trace_hyperv_mmu_flush_tlb_others(cpus, info);
@@ -137,7 +137,12 @@ static void hyperv_flush_tlb_others(const struct cpumask *cpus,
}
if (info->mm) {
+ /*
+ * AddressSpace argument must match the CR3 with PCID bits
+ * stripped out.
+ */
flush->address_space = virt_to_phys(info->mm->pgd);
+ flush->address_space &= CR3_ADDR_MASK;
flush->flags = 0;
} else {
flush->address_space = 0;
@@ -219,7 +224,12 @@ static void hyperv_flush_tlb_others_ex(const struct cpumask *cpus,
}
if (info->mm) {
+ /*
+ * AddressSpace argument must match the CR3 with PCID bits
+ * stripped out.
+ */
flush->address_space = virt_to_phys(info->mm->pgd);
+ flush->address_space &= CR3_ADDR_MASK;
flush->flags = 0;
} else {
flush->address_space = 0;
@@ -278,8 +288,6 @@ void hyperv_setup_mmu_ops(void)
if (!(ms_hyperv.hints & HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED))
return;
- setup_clear_cpu_cap(X86_FEATURE_PCID);
-
if (!(ms_hyperv.hints & HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED)) {
pr_info("Using hypercall for remote TLB flush\n");
pv_mmu_ops.flush_tlb_others = hyperv_flush_tlb_others;
Powered by blists - more mailing lists