From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-1457137-1516790214-2-203158625532045591 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no ("Email failed DMARC policy for domain") X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.25, RCVD_IN_DNSWL_MED -2.3, SPF_PASS -0.001, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='140.211.166.136', Host='smtp3.osuosl.org', Country='US', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='us-ascii' X-IgnoreVacation: yes ("Email failed DMARC policy for domain") X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: driverdev-devel-bounces@linuxdriverproject.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1516790213; b=W9twOVK4pWXKZZd+vQMsmCZ4TOs3au0m0gjZ7xlwMx4DNH5 9/4BEEBFOPzCW5YfYylafV3VhvjLQlfFdi6/tlor4zLHc38X1z3aegQdSTm04Y4l 6VAWqx4eXUzcPyPgGJjEzLfXWUdj/3UXw2UsLRh/DyYacOAtrvlqsQmzW3/iY6l/ e95rmV/sYZkqHbTdkJ4tSyReeg4NoritIP4Hi7WVF2YaZ6fZhI+ZC4wOpu5j+RSX IqXMcTX/cZPckQbpTSLhPNae3MPaZbrd5UqZU85PxAdobxfCgtV6i1ykYMSKnuBg zveGeDfDNiL7QQSol1xlX8KZp41int+MAAZSvgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=from:to:subject:date:message-id:list-id :list-unsubscribe:list-archive:list-post:list-help :list-subscribe:cc:mime-version:content-type :content-transfer-encoding:sender; s=arctest; t=1516790213; bh=j MnPOiSyEXLOr1vITPYazlSPv4JWd8gEkOUzfbtJUUY=; b=J+cnTGiWsLRmDVceR xvHWakXZRKBAk9hMWSJUHbf1CMS5rC0uFPFRJ1+egyNV1ZsljpEpaWPMHnNrWwzJ OHztzIt7Ukj/8oIYBv3eKW1d02TPQycPFuHGHoz6klRBCczG5UK5s34kkhwRbhUu XC4BHsV5lBAwx+GXzeuwFjbCGqeKDKurhcedKdT5ir0zVgWxZrnhRTFEjnTZK3Qv Z3Qp2NNPDScoMved967auLggccxTVl8Nq3cFpmy+SLEZ8Xg6Q3YVaF9ZXbA0lxcs oIrXebhFK70nS4rY/sA6gk7XYyeeCECaqfJNFSq30QEn+LxCjb0llVi8dntrskng 7VQSg== ARC-Authentication-Results: i=1; mx3.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=fail (p=none,has-list-id=yes,d=none) header.from=redhat.com; iprev=pass policy.iprev=140.211.166.136 (smtp3.osuosl.org); spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org smtp.helo=silver.osuosl.org; x-aligned-from=fail; x-ptr=fail x-ptr-helo=silver.osuosl.org x-ptr-lookup=smtp3.osuosl.org; x-return-mx=pass smtp.domain=linuxdriverproject.org smtp.result=pass smtp_is_org_domain=yes header.domain=redhat.com header.result=pass header_is_org_domain=yes; x-tls=pass version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128 Authentication-Results: mx3.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=fail (p=none,has-list-id=yes,d=none) header.from=redhat.com; iprev=pass policy.iprev=140.211.166.136 (smtp3.osuosl.org); spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org smtp.helo=silver.osuosl.org; x-aligned-from=fail; x-ptr=fail x-ptr-helo=silver.osuosl.org x-ptr-lookup=smtp3.osuosl.org; x-return-mx=pass smtp.domain=linuxdriverproject.org smtp.result=pass smtp_is_org_domain=yes header.domain=redhat.com header.result=pass header_is_org_domain=yes; x-tls=pass version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128 X-Remote-Delivered-To: driverdev-devel@osuosl.org From: Vitaly Kuznetsov To: x86@kernel.org Subject: [PATCH] x86/hyper-v: stop suppressing X86_FEATURE_PCID Date: Wed, 24 Jan 2018 11:36:29 +0100 Message-Id: <20180124103629.29980-1-vkuznets@redhat.com> X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.24 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Zhang , Stephen Hemminger , Haiyang Zhang , linux-kernel@vger.kernel.org, "Michael Kelley \(EOSG\)" , Ingo Molnar , Andy Lutomirski , "H. Peter Anvin" , devel@linuxdriverproject.org, Thomas Gleixner , Aditya Bhandari MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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. I was asked if we can stop suppressing PCID. From TLFS (as of 5.0b) is is unclear how TLB flush hypercalls combine with PCID. In particular, I was worried about our usage of PCID where it is per-cpu based: the same mm gets different CR3 values on different CPUs and if hypercall does exact matching we're screwed. However, this is not the case. David Zhang writes: "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 --- arch/x86/hyperv/mmu.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c index 9cc9e1c1e2db..993a5dff1e40 100644 --- a/arch/x86/hyperv/mmu.c +++ b/arch/x86/hyperv/mmu.c @@ -137,7 +137,12 @@ static void hyperv_flush_tlb_others(const struct cpumask *cpus, } if (info->mm) { - flush->address_space = virt_to_phys(info->mm->pgd); + /* + * AddressSpace argument must match the CR3 with PCID bits + * stripped out. + */ + flush->address_space = + virt_to_phys(info->mm->pgd) & 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) { - flush->address_space = virt_to_phys(info->mm->pgd); + /* + * AddressSpace argument must match the CR3 with PCID bits + * stripped out. + */ + flush->address_space = + virt_to_phys(info->mm->pgd) & 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; -- 2.14.3 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel