Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1526003imm; Wed, 26 Sep 2018 20:50:04 -0700 (PDT) X-Google-Smtp-Source: ACcGV62cWXdKoW8FOzkvmZVaIrPfuYDnLvJeUGf0JLF82T/aGVcj1W4Y3iwTtmLTAhFInULLLuTi X-Received: by 2002:a62:aa17:: with SMTP id e23-v6mr9090250pff.211.1538020204360; Wed, 26 Sep 2018 20:50:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538020204; cv=none; d=google.com; s=arc-20160816; b=EcvXNI8Ft28PvnX7wfX874PjM73LZnoWWSe5cC9oDGH9oMfai3UiedfuSgtxOMcy07 kGPUZVbU7MJjdocBEHtxRpwTF2hQwion1ORAgXv7s5P02dRavJSrlecNuz1bZpbrcGfe LP1LwpNGNkF6xZUnZHtk3ub1kWVkziZYr5GB1tbWQ3h1HAERhSXg8ygclb9QptcEAA6/ U0zGW3yMqy70qdO4o+dqUXlj+5s4KKUFu4lpMU9r1by10P+cuhBUJiMe9gG7W0HmGqvZ +ZNxVLLhil5dvUVK3vSW+rouF1IMYexwJQJXKyfFnf4FhaUz+WtnOjEp2JGbOeDQDeAg oTdQ== 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=iPTMoAeSOP1EBLl+y6ogI5JOOb4P0GRgqcwMj6tWfeo=; b=EQxFz5/DroFBSRlKw0iLp6wYld7DN400TOJ/WbiRry2zbunEZgjRp1WgI/zA+yz7Bz T5tHhQCkNlhuqxyqFOYJ0/tocL8kd402veOejEPWSV3E3WTEWC9QtDevIkaPNxejDokw 7wkv+bN1TuKGM0a/WSOwKlMLr0fR2Zt+sj1KaEgu8WXytuxJ8ToPj6D/1T/28KZgHGbo K6QI2W1vqwf+8mWBhl/cjOAyMlBKVgmmbcmfcmdXYS6t1vLf0Q9NRRoSUJ1n5TAUQcWY 6VnCC0S3HlXBt6p0bfsj/b1lBVej1XiRnrS4afqz6LJrW24PxbtBc0CjLKngLf5/otNH hbYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=IZ25KbOD; 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 24-v6si890996pft.235.2018.09.26.20.49.49; Wed, 26 Sep 2018 20:50:04 -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=IZ25KbOD; 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 S1727105AbeI0KFh (ORCPT + 99 others); Thu, 27 Sep 2018 06:05:37 -0400 Received: from mail-hk2apc01on0118.outbound.protection.outlook.com ([104.47.124.118]:22900 "EHLO APC01-HK2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726557AbeI0KFg (ORCPT ); Thu, 27 Sep 2018 06:05:36 -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=iPTMoAeSOP1EBLl+y6ogI5JOOb4P0GRgqcwMj6tWfeo=; b=IZ25KbOD/0k0WYdlydWCpTHa0lOYNzcSbRo+Io8ftCu/iV3gN7t548ZfgEfn8nYut2Oi/7/2CBHOikO86hMZ5r2F+3pDzgh5+O0HXPYU9SmCGX9uR2pTvfkWnrFLn+Y336zgc8Z9u8su/tttfDmXm3iVwjICsnP1nD2PxH9YGhE= Received: from HK0P153MB0129.APCP153.PROD.OUTLOOK.COM (52.133.156.18) by HK0P153MB0130.APCP153.PROD.OUTLOOK.COM (52.133.156.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.2; Thu, 27 Sep 2018 03:48:45 +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.1207.011; Thu, 27 Sep 2018 03:48:45 +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 V3 00/13] x86/KVM/Hyper-v: Add HV ept tlb range flush hypercall support in KVM Thread-Topic: [PATCH V3 00/13] x86/KVM/Hyper-v: Add HV ept tlb range flush hypercall support in KVM Thread-Index: AQHUVhT9Jvd8b1MsZ0uZSqXkUgrt4w== Date: Thu, 27 Sep 2018 03:48:44 +0000 Message-ID: <20180927034829.2230-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;HK0P153MB0130;6:5Iw3OujogA8xHSpsyhnO+9aGffMbvDOo/DLQKUMYYRT0qRPJvrVrpNe5AZPREJZWUoNRhswaCbs7PzxnOdZU2VHm7yV+ud7nKRFt9qbd5XC6yTKzcAkFSrdVBfsSds738JK9+jYK2VGM0Ca8lQy0teVkgoh52RQ8seLU8njVtUpPaOGmMgj2AZcLEBazpOe3HCwrVeVrOyEdUSpbgbqe8Avl9IecpZAF1HD8KyoY9l2awKc0yc3IiTQEGn+NTU/bcxi0v5wFxFS2lf/U1QBqzeMag7cWc4gzlbZ7ayrh4vWm/BchF1PNST/cIbKODdwQc15BdTJShIreu9RsgZJug15uLpn9U+if/II4oTDD32lWu6Vu/Tf9qZbruAP9DarTdIDh9/2N+wsx3Z7lPt7cgvFuRYsX67RXIn+LaIG+/vX3G8GUKu4KtuukNBHFeAFD8CtjufftWXEAqIWS3qNZeQ==;5:aRaP+6nReNvYLxQhERT0GkqlsX6bmNLcwl/DSfRJGuSvvQ/qlHUIOA2cfoVVh2aTXKDT2fEDUafTEj/nEoGn8W9Pcz5RScq/18UwRnIADm1WuNOuk3gWAQmWuMjrtfaO5R0g7bxqgmDo2YMFbU28cerXy/Js1AUM0eVux+UjFOQ=;7:qVPaz2UDa6BsTF+dK+zwLHNUbmdo8ANSEi0yVSlw/ZdFWfD15AsnVWWW2zbn8qdfrNq/LQyvzPHCyoSqJ7Iwn3uGcrdvF7QtwuNKPIujPdjtLjwxjHwkwqCl6SL33xutuTKGCJ+Y0uLBy0Au5yig84C78uWVyZ6i9yp1u1HpOsKRFQCMwg8OO21Ys6VJguGCaFd9LxligNdjCg0qaJQwIKEDUwrhQjDGGZ5F4+1RgUfR/y9jnWiV2x5gTzv4gnI5 x-ms-office365-filtering-correlation-id: 30d03087-e301-4b4b-3ec4-08d6242c1fce x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(2017052603328)(7193020);SRVR:HK0P153MB0130; x-ms-traffictypediagnostic: HK0P153MB0130: 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)(5005006)(8121501046)(3231355)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051);SRVR:HK0P153MB0130;BCL:0;PCL:0;RULEID:;SRVR:HK0P153MB0130; x-forefront-prvs: 0808323E97 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(136003)(366004)(396003)(39860400002)(376002)(346002)(199004)(189003)(102836004)(478600001)(6506007)(26005)(72206003)(10290500003)(8936002)(36756003)(54906003)(53936002)(22452003)(6486002)(8676002)(5660300001)(5250100002)(14454004)(107886003)(14444005)(6512007)(7736002)(34290500001)(1671002)(6436002)(256004)(86612001)(305945005)(86362001)(59246006)(97736004)(6116002)(66066001)(486006)(68736007)(2906002)(7416002)(99286004)(106356001)(3846002)(105586002)(4326008)(2616005)(1076002)(71200400001)(109986005)(81166006)(81156014)(71190400001)(476003)(25786009)(2900100001)(10090500001)(316002);DIR:OUT;SFP:1102;SCL:1;SRVR:HK0P153MB0130;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: qflaCYWEuCC1tLHfP/KQbWvsIseuilGA79BcmJRjbEJ9CtIpXXnfKyeBhEiLzulLP6riK3tA2zIVukb9eWB7Cic9AZdQiCBbkXHth+7T6xhwEAP09qv0Yjv+tfOkKRWVnTIxJoqxfkKn/JzNdBB/8h8j6N7hGSaLHt8IYloi4kqcrQzuNZjUVkT19EFWJJW8erfgG19/ZvrF0zhzC1qtendURhTDChbjRaBZc+aD2DHS41703NXYttVuWTA3BxnKUns2x4KTXtPokH+TILbv8sNG44lL4QYnJDsREA7ouYH0HQOyWbiAqoz1qXwZCqZwWCYlD0D3IGn6LQXgGrAAQyQMlfVnLHSOuJacmT//XAs= 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: 30d03087-e301-4b4b-3ec4-08d6242c1fce X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Sep 2018 03:48:44.6592 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK0P153MB0130 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 v2: 1) Fix comment in the kvm_flush_remote_tlbs_with_range() 2) Move HV_MAX_FLUSH_PAGES and HV_MAX_FLUSH_REP_COUNT to hyperv-tlfs.h. 3) Calculate HV_MAX_FLUSH_REP_COUNT in the macro definition 4) Use HV_MAX_FLUSH_REP_COUNT to define length of gpa_list in struct hv_guest_mapping_flush_list. 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 | 85 +++++++++++++++++++++ arch/x86/include/asm/hyperv-tlfs.h | 32 ++++++++ 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 | 10 ++- arch/x86/kvm/vmx.c | 65 +++++++++++++--- 8 files changed, 345 insertions(+), 30 deletions(-) --=20 2.14.4