Received: by 10.213.65.68 with SMTP id h4csp2151949imn; Sun, 8 Apr 2018 21:03:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx48J4fxFFQhN/DznNfv3T0SVvDVo1sm+BeBCh7L0QoQ37cs2qGbpOt05W7fVEZ+yznjCTyqm X-Received: by 2002:a17:902:86:: with SMTP id a6-v6mr37672270pla.298.1523246588496; Sun, 08 Apr 2018 21:03:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523246588; cv=none; d=google.com; s=arc-20160816; b=lu3P5v5RI5AQubk3YJd7/BTrp5LlHKNEIJSGocJAXyv7eD2YHyaSUDPLKA0fGj2a9P I+jFX7TDUNkQ9JZhbkGdNHQQvch6qAtPxahwYm00iF6YX+hZ7uQAb1Ss6OpneU71CyQy YvATvynZE+CULTFt68F++2vq91ndzSv9UYi1qDG5f6VryFM29PrCe50HlLCl9ncOQ3sm swoR4mgCl93TOMNQ5BypBeFd2UNpA/aKh6g12W5AYY0H5HWEhxckYdtAlsEXWeLqvMER tnxrmaFcLdPV27fUjefkOhOf76XNsN2+h540sd+dLKrpcq0TceIHzP/pkUsPNFFMhnLu xlXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=P0G6oqRo1oSuuu/nvsWs/2HjWciim2AsLrAryQrT/Es=; b=JzlIyvHqzVaMDFUNruwJLt1di93lv++s/0q6ypfG3oO8oMWNfS2p/mOt50RKq06haa FsTmgPk/5LQSiCTEDZTb2bE7vcsXNsd8Kz5lDEcApnlY2y1ENnAWay0ReZIDrgaP9GU9 /L0zkHdzumqFig1Y6FCuF5KgveAeZ8ThxTZeMSD7ppyuMEjthyyf149rHT9qoejxWwsK QI34YlEQ2dCfbwUbfC76UX98fMeO7pf8hxBIkYkb1slzJAnyDQillCSSAP7gF2qYK1xU ZWVVocKypTESxjycRWI6hI5+6BxsNuSZmL7TymfP73N2APVhAKo1Fwto1J1rs1bBRuVJ DDBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=nwKXz4Sm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4si12115323pfi.400.2018.04.08.21.02.31; Sun, 08 Apr 2018 21:03:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=nwKXz4Sm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753655AbeDIDy5 (ORCPT + 99 others); Sun, 8 Apr 2018 23:54:57 -0400 Received: from mail-by2nam01on0126.outbound.protection.outlook.com ([104.47.34.126]:59343 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753821AbeDIASw (ORCPT ); Sun, 8 Apr 2018 20:18:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=P0G6oqRo1oSuuu/nvsWs/2HjWciim2AsLrAryQrT/Es=; b=nwKXz4Smu0ugE3bguze6adN4vvNBZpw958yqIJULVAUlnS5FMCFhogDKNGMuGvK+2EVOuwmLiG907q94v2EtskRGfITZ1jTXioA/7Vpnpip3krHShKCDdADPj4qJU1dFrhBeFbuUUTOE/ZCkoAIDY4CufjusAzJjKFFhUqq0sUk= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1128.namprd21.prod.outlook.com (52.132.133.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:18:43 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:18:43 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Vitaly Kuznetsov , Thomas Gleixner , David Zhang , Stephen Hemminger , Haiyang Zhang , "Michael Kelley (EOSG)" , Andy Lutomirski , "devel@linuxdriverproject.org" , KY Srinivasan , Aditya Bhandari , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 090/189] x86/hyperv: Stop suppressing X86_FEATURE_PCID Thread-Topic: [PATCH AUTOSEL for 4.15 090/189] x86/hyperv: Stop suppressing X86_FEATURE_PCID Thread-Index: AQHTz5g15HDkqLJsS0OmaDtuGWKt9Q== Date: Mon, 9 Apr 2018 00:17:56 +0000 Message-ID: <20180409001637.162453-90-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1128;7:/GWfbmz4REF1KeL7djRiGjCercRyn+pfd+HHHsZB9sW8rggkEH8HVB8h6Tn4lAc7SjJT82RkeEg0oLsgSpebguj+Gq1Dj4AmCb6kzdVh9UI5pO45uuNtaQtTwv3OqknyweiZuFa8AcpwdpUFwxH6zXuF2yL0O54jbTver6ffJ32cfzPzLid0fRTjXhdN1NlCs4258LHIGI+wnb0c5ehLl1D8Qft1WU74uDo91uUNMJyOZIfBqXfFfWXUky8XJpHM;20:u6HwcYJ6tc/s1kXvXqg0YZKDvp3ra3gq9tKMcES5d5t/1q9gU0M/TcFvv9qV4AxB4eJVCB3uftJDh49TsSvfAXzP4zEpzyVho4DSu+uG/pCmVuXE4gEmHQdJg7bEf3ecwDJ9kWOLa60tKu0S5mZSmcLwEobDYmQywW3uIsJzl8w= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: fb2aef26-456a-4179-d43a-08d59daf740b x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1128; x-ms-traffictypediagnostic: DM5PR2101MB1128: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(42068640409301); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1128;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1128; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(396003)(376002)(366004)(39380400002)(199004)(189003)(66066001)(86362001)(3660700001)(3280700002)(2900100001)(25786009)(36756003)(6506007)(76176011)(2906002)(6486002)(86612001)(99286004)(102836004)(1076002)(7736002)(97736004)(2616005)(446003)(486006)(11346002)(476003)(26005)(305945005)(6666003)(6512007)(4326008)(6306002)(107886003)(15760500003)(478600001)(6436002)(5660300001)(10290500003)(5250100002)(22452003)(316002)(105586002)(186003)(8676002)(110136005)(966005)(54906003)(72206003)(53936002)(2501003)(68736007)(14454004)(6116002)(8936002)(3846002)(81156014)(10090500001)(106356001)(81166006)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1128;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 3O4MJlHyKIAR3SHpnPlza90TE7MiKs2f5QQ/Sj1hLX0U2NA3YuN2clRm+JCLcx3MAznBR6CWSAKsXvbXzuEvw7tUqpp9eoDhiSsjA4HbzxkSGfawTBFtVm0/eCTRr4at5/cWELejPIxX7Rwz52kpDEdfq64zMcjCktpQ1nKe2kRyLYq1CBVVm2rTf7QIg0Uwl12igx7Kj1phrGeHBId5jBzHsn/WfC0BxfS/robNzmCXyxDAd/2PRWomiDf49YZPhhV09UZglzYGCFWCU+e1jPzi0B9t5rZnJusesPPdCTF8vhiV1b+8ZPHh+0ChZui07nxSIZh9bu2zcAAREiUo/yHryAkeeum14IraOjEQcXwBS6L7kKlIAplTaNV31h0TtEJslRxMvYjazo2/iUlZfFN/6QD2nRZ0VnbOUeqW+yw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb2aef26-456a-4179-d43a-08d59daf740b X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:17:56.8665 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1128 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vitaly Kuznetsov [ Upstream commit 617ab45c9a8900e64a78b43696c02598b8cad68b ] 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 Signed-off-by: Thomas Gleixner Cc: David Zhang Cc: Stephen Hemminger Cc: Haiyang Zhang Cc: "Michael Kelley (EOSG)" Cc: Andy Lutomirski Cc: devel@linuxdriverproject.org Cc: "K. Y. Srinivasan" Cc: Aditya Bhandari Link: https://lkml.kernel.org/r/20180124103629.29980-1-vkuznets@redhat.com Signed-off-by: Sasha Levin --- arch/x86/hyperv/mmu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c index 9cc9e1c1e2db..56c9ebac946f 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 cpuma= sk *cpus, } =20 if (info->mm) { + /* + * AddressSpace argument must match the CR3 with PCID bits + * stripped out. + */ flush->address_space =3D virt_to_phys(info->mm->pgd); + flush->address_space &=3D CR3_ADDR_MASK; flush->flags =3D 0; } else { flush->address_space =3D 0; @@ -219,7 +224,12 @@ static void hyperv_flush_tlb_others_ex(const struct cp= umask *cpus, } =20 if (info->mm) { + /* + * AddressSpace argument must match the CR3 with PCID bits + * stripped out. + */ flush->address_space =3D virt_to_phys(info->mm->pgd); + flush->address_space &=3D CR3_ADDR_MASK; flush->flags =3D 0; } else { flush->address_space =3D 0; @@ -278,8 +288,6 @@ void hyperv_setup_mmu_ops(void) if (!(ms_hyperv.hints & HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED)) return; =20 - 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 =3D hyperv_flush_tlb_others; --=20 2.15.1