From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F28C3ECE561 for ; Tue, 18 Sep 2018 03:18:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 89AAD21471 for ; Tue, 18 Sep 2018 03:18:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=microsoft.com header.i=@microsoft.com header.b="GBYlVcnQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89AAD21471 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=microsoft.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728922AbeIRIss (ORCPT ); Tue, 18 Sep 2018 04:48:48 -0400 Received: from mail-sg2apc01on0120.outbound.protection.outlook.com ([104.47.125.120]:24704 "EHLO APC01-SG2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726434AbeIRIsr (ORCPT ); Tue, 18 Sep 2018 04:48:47 -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:X-MS-Exchange-SenderADCheck; bh=GLWQL7WjO3FSjwU44Cp94pkhTXua11O1fLUdrAwfza8=; b=GBYlVcnQ3nY+GhiiX8xKuetmVFo3Y5iLdjyntoNnZjMSF6/GXe1lN0SUs9Ew2TZ/TqaDIAxBFprL+rN89WUoS+A7/3dqJdNPjpEHqXwfk+w7TxfHHJsqZ2Mx9WJK19QwjeVjHOj3aLn8gl3tSpnAd30jqs28Xg43ibhQ+mx55qc= Received: from HK0P153MB0129.APCP153.PROD.OUTLOOK.COM (52.133.156.18) by HK0P153MB0180.APCP153.PROD.OUTLOOK.COM (52.133.212.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.5; Tue, 18 Sep 2018 03:18:11 +0000 Received: from HK0P153MB0129.APCP153.PROD.OUTLOOK.COM ([fe80::8584:ad93:130a:6267]) by HK0P153MB0129.APCP153.PROD.OUTLOOK.COM ([fe80::8584:ad93:130a:6267%3]) with mapi id 15.20.1185.006; Tue, 18 Sep 2018 03:18:11 +0000 From: Tianyu Lan CC: Tianyu Lan , "devel@linuxdriverproject.org" , Haiyang Zhang , "hpa@zytor.com" , "kvm@vger.kernel.org" , KY Srinivasan , "linux-kernel@vger.kernel.org" , "mingo@redhat.com" , "pbonzini@redhat.com" , "rkrcmar@redhat.com" , Stephen Hemminger , "tglx@linutronix.de" , "x86@kernel.org" , "Michael Kelley (EOSG)" , vkuznets , Jork Loeser Subject: [PATCH V2 00/13] x86/KVM/Hyper-v: Add HV ept tlb range flush hypercall support in KVM Thread-Topic: [PATCH V2 00/13] x86/KVM/Hyper-v: Add HV ept tlb range flush hypercall support in KVM Thread-Index: AQHUTv46fKVracJe1E+mxPERcd/veg== Date: Tue, 18 Sep 2018 03:18:10 +0000 Message-ID: <20180918031754.113013-1-Tianyu.Lan@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Tianyu.Lan@microsoft.com; x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;HK0P153MB0180;6:oCul3o9cZS6slrg9G6BvKYO/G+5t3KjP8MVrTHZf9oQyyeWFNdHX+icCitszsjBqNvx8e9ZBJwKSjg4A1hJLe4RAhbNTYULGLGgsLulau2XGMOEvdjWFTcq+CKovPjKEct0ChW4Mpq6trmL8piqCH18zGt0pGnvSQpagDNWNP/YGgHD2IqnwZljhjMwYYCnNOI78Tg1djZYTutF8c9+fXp8FDI/muSbcDyKg5/DsQONSVE2xMCfMOtc3uHBf/yXZbY+3228MOFMZLHM31HjYsRDQHlN0BSCtPkxVLYZQ7As1OamAzAsqX7wv0PDQld50AeubsU2/fdipgcZ010J2jFT8v9JLkfkNY56UGSi1FwlvVmE212tqS6qvWGcAlSgxiRQAF7UCtUt9KbhqBBbVle/DVxqFf+mHPdavIwjDlCnW0TonloqM+hlJ5Ord+t6iUkqdlikhtTRJ7AVOMQwebQ==;5:taKpdMDNErgheWZXVuuYFrow3ioak9YyK51jlp7/+zT/b0oVLrAmWO47Np9xVfI6XxsQpuE8XJEFSUuGDFUVdtblXRPu+DZ+RD3JL7ZLPHSKtFBugSHhXRDBxkz5csWGZ1O2IeFtUAQVEulz3/NlOmZyAUBZkDfuTAgdmhv2Vgo=;7:Z33DxdFZEQPKYAnpdvnHGY89RWfbVXpjCa7VK0R2AlWM13+BsLvyQG9aSdzHCyeNL6qt9vHaKwRDMZmqY1M7ml9QwWXUM/sEb2bmv2XZndXgrppIJskEDG1IGMW5htOFkImxtOy2/ZufVUSyS7nM9aV13jZwomW6KbKrV0jTxp4o6B13k0hntAsgoA1bNYo6EHqa8w5OXcpe773aMAv7pdPSyKw6WCLuakqRdv0cRfnOG5dH9ABPeqMpgjeBEi5X x-ms-office365-filtering-correlation-id: 40d4dbd3-2e2d-4234-cce3-08d61d155d0a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(5600074)(711020)(4618075)(2017052603328)(7193020);SRVR:HK0P153MB0180; x-ms-traffictypediagnostic: HK0P153MB0180: x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(788757137089); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699050);SRVR:HK0P153MB0180;BCL:0;PCL:0;RULEID:;SRVR:HK0P153MB0180; x-forefront-prvs: 0799B1B2D7 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(376002)(396003)(39860400002)(346002)(136003)(199004)(189003)(26005)(102836004)(2906002)(7736002)(6506007)(22452003)(59246006)(54906003)(316002)(14454004)(86362001)(86612001)(36756003)(6436002)(10090500001)(6486002)(6512007)(305945005)(7416002)(53936002)(2900100001)(5250100002)(14444005)(256004)(97736004)(72206003)(478600001)(106356001)(8676002)(81156014)(81166006)(5660300001)(8936002)(6116002)(3846002)(99286004)(10290500003)(1076002)(105586002)(476003)(2616005)(66066001)(486006)(107886003)(25786009)(109986005)(68736007)(1671002)(4326008);DIR:OUT;SFP:1102;SCL:1;SRVR:HK0P153MB0180;H:HK0P153MB0129.APCP153.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: Yy9XMR27HuW6WU8FomfGdXXZxc11dEWMKDsulvrx/BDWHuYhabdAgxpWhQmUDrIqTAJQiczRvPbIrDTRndueSj1cwJpojKyek2uJc1cYEieuBO2RHQl4VAbh+Wq/FbU2oE4NB5repQqG/IJsl2BCYHUJnXXvDpcA53MxI2Tb2k+9Tx6bOgedsgB46FrIPCjleTV7uGIP5ytgT/OGYko2rkxKvBydR9vnko3P1bKgMVJeoSqmVuerrjo78+ozTI4ciSP5OFbGndhnMIYULRNRZCiIsqpOnHBi2lV/246QCfDBphCNC2UtYIoAX1myXE8xMfZm7kjNeqaWQBYZ6yCTxKNpaTEuv7kmejr2/djcPz4= 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: 40d4dbd3-2e2d-4234-cce3-08d61d155d0a X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2018 03:18:10.6987 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK0P153MB0180 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For nested memory virtualization, Hyper-v doesn't set write-protect L1 hypervisor EPT page directory and page table node to track changes=20 while it relies on guest to tell it changes via HvFlushGuestAddressLlist hypercall. HvFlushGuestAddressLlist hypercall provides a way to flush EPT page table with ranges which are specified by L1 hypervisor. If L1 hypervisor uses INVEPT or HvFlushGuestAddressSpace hypercall to flush EPT tlb, Hyper-V will invalidate associated EPT shadow page table and sync L1's EPT table when next EPT page fault is triggered. HvFlushGuestAddressLlist hypercall helps to avoid such redundant EPT page fault and synchronization of shadow page table. Change since v1: 1) Convert "end_gfn" of struct kvm_tlb_range to "pages" in order to avoid confusion as to whether "end_gfn" is inclusive or exlusi= ve. 2) Add hyperv tlb range struct and replace kvm tlb range struct with new struct in order to avoid using kvm struct in the hyperv code directly. Lan Tianyu (13): KVM: Add tlb_remote_flush_with_range callback in kvm_x86_ops KVM/MMU: Add tlb flush with range helper function KVM: Replace old tlb flush function with new one to flush a specified range. KVM/MMU: Flush tlb directly in the kvm_handle_hva_range() KVM/MMU: Flush tlb directly in the kvm_zap_gfn_range() KVM/MMU: Flush tlb directly in kvm_mmu_zap_collapsible_spte() KVM: Add flush_link and parent_pte in the struct kvm_mmu_page KVM: Add spte's point in the struct kvm_mmu_page KVM/MMU: Replace tlb flush function with range list flush function x86/hyper-v: Add HvFlushGuestAddressList hypercall support x86/Hyper-v: Add trace in the hyperv_nested_flush_guest_mapping_range() KVM/VMX: Change hv flush logic when ept tables are mismatched. KVM/VMX: Add hv tlb range flush support arch/x86/hyperv/nested.c | 104 ++++++++++++++++++++++++++ arch/x86/include/asm/hyperv-tlfs.h | 17 +++++ arch/x86/include/asm/kvm_host.h | 10 +++ arch/x86/include/asm/mshyperv.h | 16 ++++ arch/x86/include/asm/trace/hyperv.h | 14 ++++ arch/x86/kvm/mmu.c | 143 +++++++++++++++++++++++++++++++-= ---- arch/x86/kvm/paging_tmpl.h | 16 +++- arch/x86/kvm/vmx.c | 65 +++++++++++++--- 8 files changed, 354 insertions(+), 31 deletions(-) --=20 2.14.4