Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4707261imm; Mon, 17 Sep 2018 20:18:41 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYM8wnnpZtnM/kFYtkk2hSgQBIdK6n754mfRx+1K4QlG928ZC+6CLEIVAW2IIXMoUDP7aev X-Received: by 2002:a63:b914:: with SMTP id z20-v6mr25910496pge.396.1537240721274; Mon, 17 Sep 2018 20:18:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537240721; cv=none; d=google.com; s=arc-20160816; b=Zj1hAglFRhOaXcmCSMwsnnXKcn3o06KnVTfpQO5DXNtF0SKlUgttHSFK6pQ7CZXg3K F6O3f9Zz2/CEerYU7g976ZTcqRLwmrG54lxaI/7vm98CTPjkXQ1MwRtQjrSaCe21/Cyg wnZcKj31tKvEZSBI1OkOcXulfnFij9NGAcraRij601ZLNERl6/HPij6e+7SnZLyd+WgN mvif+LuebjOZ/G2o6nHkqN2DsVklg8R6AGQ1pj4aAWfrwa1vkx0lxab/MXibWFSuGHYC ytmCRJdh1gN9Ga2+ZKzs2230Gen8uWbWG3YTSMBSNHMCqtkGdxExbDVBKTmVWq3QbkUx WgPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:message-id:date:thread-index:thread-topic:subject :cc:from:dkim-signature; bh=GLWQL7WjO3FSjwU44Cp94pkhTXua11O1fLUdrAwfza8=; b=snBI/5d00MBvoEVlLRVJRG+teYD7OkKEXR9pGpSoA7EKDgn9KGlvrFIWv5M3GU5cyF R3P9dMVt/udEQFgnSaz97HT7yLE0zvrQXj5gLkexAg0Bdut92v+YDWqlZpdJgD8U40Jr haMG7WI8baiFnDVnXuVSpcKpkekK3a3rCm7nDzLTrn8KZKuuyzP4fxK/oBBYYXqdPbUT YsSuGRlmEdVWEb8VDGtsI+LgfDQKSajJac76HioAStZ3hl+H8+A2WDnDtWhe6iOo+tvA nIiHevUt9WRwftwo153TU7kuLeKvrcRLvZlvDC8MWpCpN8oNIgQfbfIbEvzgo0uwKgKa MJDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=GBYlVcnQ; 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 j1-v6si16485844pfh.63.2018.09.17.20.18.25; Mon, 17 Sep 2018 20:18:41 -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=GBYlVcnQ; 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 S1728877AbeIRIss (ORCPT + 99 others); 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