Received: by 10.213.65.68 with SMTP id h4csp2122634imn; Sun, 8 Apr 2018 20:15:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx490ZsqZZ+GuCfsafP1VTRvrm51+D0NAXeA3KOJs+HTKILrfc/ZENzt54l+1pQ5Vi6N/XVmw X-Received: by 10.101.89.5 with SMTP id f5mr23763990pgu.428.1523243740234; Sun, 08 Apr 2018 20:15:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243740; cv=none; d=google.com; s=arc-20160816; b=eddZIvJBhEHbLATUAXYkWgD0CUglMbmRpm2ZeusF7M3tl99L2fJuXVIR3djHQO8LgK 3pEP/iommsGvphg5N5zEx5CPouvQHRFQ6zySRTXslnTe+p/EkSW4FchH0Qin1RLKzC1J MjOBks9Nkom4WRmoEL3xGXw6hRHEM/FiiBwuaAOy49Mh0q68Sz2nHbpMzu+k2JhpBzoC Zv86TRfzgOXVq3TcWyNxy/HhmMj3keGFxKgud5m4uF6CfleCuVcLeu9GWaiATSkl6XP4 dxIP/7IXTOaQdimLqRCXv6rnYTXG8GWu9XU0roSa0ONrJzfHHiTHlgfTTeNXbW9aaQ0F Llag== 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=iK5v/GKxMIXOJF2o3/r+16+AuT2nM75wVa9Co7aDHsoePjy2FEQaTcylEX4EU6aGCJ l5MpwOYLR3wDaKO3TwVt4KIuQOhcnEe225XyxM091GafwbU2nFFCu1YD7O9KwaGbx6rs TrHLrlJbgNz43HWstj9kvhRR5q2csnaSX62ucBjcN5a74WdU69KYdec7zq7tWlTuQR9/ RRFUnKtHuO7QBnnxkt358BdB2zvqe4ucoz+tEw3QbcO0u1u+aQJrulIHrBV9e6EwguKP kOxBvTMm9lGr+tCCFNjztDJ46+zISlCaXdtGPzu+WLiW9joqEBIx2NCtFuQCKEAtBtwy SI5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=ep3/yT9R; 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 d11-v6si14778052plr.406.2018.04.08.20.15.03; Sun, 08 Apr 2018 20:15:40 -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=ep3/yT9R; 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 S1755217AbeDIDM2 (ORCPT + 99 others); Sun, 8 Apr 2018 23:12:28 -0400 Received: from mail-by2nam03on0115.outbound.protection.outlook.com ([104.47.42.115]:29467 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754960AbeDIAXz (ORCPT ); Sun, 8 Apr 2018 20:23:55 -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=ep3/yT9RVpk8RNcNXYhTtYrC313+mp1c/sVuSJRNKmbDxv/hIEPFPLS647RBkvX2iodxwzVrHffIvS3KZOgGsD+fRR7GdXJrr9BmMTaZE12aQUB4dbrmO/NWBuSwpX8RCp1YCl0NyUqY04Hna2vJuLicd+vGkMkSBKkNnac15RQ= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1080.namprd21.prod.outlook.com (52.132.130.14) 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:23:50 +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:23:50 +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.14 075/161] x86/hyperv: Stop suppressing X86_FEATURE_PCID Thread-Topic: [PATCH AUTOSEL for 4.14 075/161] x86/hyperv: Stop suppressing X86_FEATURE_PCID Thread-Index: AQHTz5ibqoT8u80qk0qWNOukXmqRrA== Date: Mon, 9 Apr 2018 00:20:47 +0000 Message-ID: <20180409001936.162706-75-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-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;DM5PR2101MB1080;7:3F8NSH+iLQtZXzup2GdAXxzRhYArdtur0lE1+mPE6cWrfpe4TFEwHEFqBv46lCum4BfdDhe6Lr4uTo+e0GYjn5lu9yhAXsg18oNStAXiHlnUIwF/2egQbqQ9K3ig582PpKbuKh1XAe3UhJM/sNW/F76jIjNPYdYLSgnhyS2uTburfhmLnOoDXRAzClpeKOwYNOEtEXHOxyMz4or2m/r7kD2KO0JSYa+d25OZtWJgUoWClu9geVCt9mWBEWCUpgGh;20:SnoypWpq1SVsDKxVz55rQaa0A97CL8ZTKrT6DhPTAqkQN4+7A7TebTLnX9I9WnR1MEdPaJVz69tmIamO7OMBHVmUXCqETgQW5+Cy3gfLu+W3NvwBwJjdWr2T/fQg/LLN9tEbTUSYJVhvywXGYztYkWJ6PBgobP/rxiMPtc6WoVg= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: b9378145-ac5f-4cce-0d87-08d59db02b4b x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1080; x-ms-traffictypediagnostic: DM5PR2101MB1080: 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)(10201501046)(93006095)(93001095)(3002001)(3231221)(944501327)(52105095)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB1080;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1080; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(346002)(396003)(39380400002)(366004)(39860400002)(199004)(189003)(2501003)(5250100002)(15760500003)(8936002)(10090500001)(5660300001)(3660700001)(446003)(107886003)(14454004)(36756003)(6436002)(476003)(3280700002)(2616005)(11346002)(4326008)(6666003)(6306002)(53936002)(6512007)(22452003)(305945005)(10290500003)(316002)(102836004)(2906002)(6116002)(66066001)(6506007)(3846002)(7736002)(966005)(486006)(54906003)(110136005)(186003)(72206003)(26005)(1076002)(105586002)(2900100001)(6486002)(97736004)(478600001)(81156014)(81166006)(86612001)(8676002)(106356001)(99286004)(86362001)(76176011)(68736007)(25786009)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1080;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: 5JesscRjC8y/W6vLlW4yIhcadrXjdK4eRzC5Ec+BNAPpcb/r71tl4EGT6PZwN05T+TYaSSTON05SS5Ytgc1v3mF/sKaNiT70wpaQNuOVFCI+470A7ycFZtkKjSDa5eJKzgvWQToj44RH3M4u82hGsBt6XO329Q+YrnU+Ciycd+TPhiuZR5KQBWnwjZ2PerrE4kbvVd8Mw3E0iBGQyaqWHaV3yu1PAagQo0ZdnfIRslmu70s3z2JEfRN8UeQOFDs93Zm4bA23//8FhPuX8FeBxSn0XIYquxKcClt/aJEtrdgCp03r4Yq8OcBWTkCZShq5fbp1BQfftUDRYRTqkg1GxPCDEN9sUzl4WGgAc3432rg2fSztrCqKHUyCwLcVy5slhACmDA9Wn9PqMiOMiUqUUxnL5h117JllkGIz9PFHBd8= 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: b9378145-ac5f-4cce-0d87-08d59db02b4b X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:20:47.8472 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1080 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