Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4708278imm; Mon, 17 Sep 2018 20:20:13 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbS7g2XiKTIrK0phVQNcs1tASgugTiiPXjvPOBHGyhXnzqfNkV6OuNL4WO8nNZv44XGoXPW X-Received: by 2002:a17:902:6b0b:: with SMTP id o11-v6mr27341305plk.214.1537240813027; Mon, 17 Sep 2018 20:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537240812; cv=none; d=google.com; s=arc-20160816; b=hiSPBuCeeTC/ZLn1t4uR2V05b7sFmUyNDOyaaf7Y1uL803yQJDl1YsLn1ZPJZwghv9 /3CxK22kOyyLmIcp9nh/TPzAjRUgJ11fI2IUQCusl/oJdCdlwA0Um6euTQwmwGqO9QNy a9lj+BXxSC/1kzMRupR8/ATj3kNLBFuhE/qImv70ARGz3vrC2Kcg0MVOPgaA1C1rFdyE 4KPxbk6mVa48pa7c+nxxwY2PBUuqf3fSQQmfOpYfiZUuDfV+eGA1JlVHmA5LcdbsVeIB cESmMlW6ezJeI81G0dnG0BE/fhfBwbDv70nXst9fp0dpUpem87m9eEnIsXN3H75QEP0e xvOw== 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:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:from:dkim-signature; bh=mrCCzTSKTjSLohhy1cGoqzeZNco8LG9h282SGyt/Orc=; b=VnidPBJ3J2386PPOetz64Sy7NherkbmUzxuBfODhD6vHcUu8X7qSW8mlCGyopSCYmC thzqTQGO5/K1SKzYZBjc1bP01jfaTcssKtCE7MZ2sdZKmEgT5YIIAMjdnyzqoCwljldE JiheEuhRw3WxJBSehUSP49Rr8ICWW5gjpJepFmv80gLVVi/Y7LztFIXVwuWmgWTPKBDS 1+bOHa4nCQih/jbs0d/JKdfpDM46PiIx4q7212xNWGZM5tP6c+9uG//9GjNfBYXvyeQj nQsEVB7HVwz3OrQlKt8T5E0t6cquUkB/oZ72x5RbOXv2WX/uIlxigegAjiycck8RpNsL NO6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=l6dRX2uj; 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 82-v6si16985485pfo.229.2018.09.17.20.19.57; Mon, 17 Sep 2018 20:20:12 -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=l6dRX2uj; 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 S1729128AbeIRIs6 (ORCPT + 99 others); Tue, 18 Sep 2018 04:48:58 -0400 Received: from mail-sg2apc01on0128.outbound.protection.outlook.com ([104.47.125.128]:36634 "EHLO APC01-SG2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726434AbeIRIs5 (ORCPT ); Tue, 18 Sep 2018 04:48:57 -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=mrCCzTSKTjSLohhy1cGoqzeZNco8LG9h282SGyt/Orc=; b=l6dRX2ujGUMWpanJrVwu1CAZEYUlcqSQndYFqStAGCtSVmoSS1ianDTYx8UgEzfcPxE5xH8kWe94OR4Z7v+V2ZEWY+F2qvSazOgaKY9aEMBzh0cvDNTYNslLtp6kllGEL7TH11tWPSOhs6v5GwPOzWTsSXtNL7FwvoJ9ox3OyZs= 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:23 +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:23 +0000 From: Tianyu Lan CC: Tianyu Lan , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" , "x86@kernel.org" , "pbonzini@redhat.com" , "rkrcmar@redhat.com" , "devel@linuxdriverproject.org" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "Michael Kelley (EOSG)" , vkuznets , Jork Loeser Subject: [PATCH V2 2/13] KVM/MMU: Add tlb flush with range helper function Thread-Topic: [PATCH V2 2/13] KVM/MMU: Add tlb flush with range helper function Thread-Index: AQHUTv5BJRJv8ZvwJUKcRzk5V3vi1w== Date: Tue, 18 Sep 2018 03:18:23 +0000 Message-ID: <20180918031754.113013-3-Tianyu.Lan@microsoft.com> References: <20180918031754.113013-1-Tianyu.Lan@microsoft.com> In-Reply-To: <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:yvFjr4xSbuXRqGOQqvDROn6b8kDRiArw2nXOW0yD2uQgipPai7PY8D4gAEW5HSxfqTYD7loGtOpwbqo+HohYkpUUaKQsbXrFYwU6/XSCtnWeEz0BXNTcdcMb4IUdCLRh/iZNJpQadBnJYfQwBtxtTEYolxg9oeIdQzGatEjk4lk2yHYMFDdQEfPhclWCGMwwKBLa72mie1C3w16R4RC7P0oQCHY5g6tsbpAgO4WPHPo6vMvIzWzIL5XsqG1hwqSV9MAFfU54ZBehw05OqXtJ2Y482Iga6pOpSK0gcBq0Gd5LfHKz77Y3VqHFaQW8iwYLilRW01gWnsFrwlauZglJf0kANTeokrV2mWcbQkYWKEKWddyErqWt8BcTzMP9ICfxQlIRHkno37sNOUXY6Az8PkINe5X3ak71O3zdzJhwm5aAiik3a+yRtDOJFk698T2In4/hUJrS12QIX3tn2JuvXQ==;5:BOGa7WiQykJyxCRY7G0Gwn8J3/HIf5I2oJN4+Io7Gq9lkGFJWxrPdgI2ryFYUwI3q6mY9Hb7dIO6orbAu6Eu61RyDDoXj/aglxRFcU/GMtg9gCzsuJ2XNxeywWYwkCGIC/9+qdPbFPqwltAWLZrFcCGpnWLGYfCmWL5HluyE2uc=;7:5WoCUOGfILRhmX9P4/+RrcLrkl9yfxcEWJw9V7DeoHqcx9M1REmnV8GqZT44nmfboUFyMBd0lCGwWkgTfg/07+UCxaaE0yddbCurKwTmJp8uYBYOHXwXHwmI1qDmwacK+zKQVfxYdmYAFSlI4Eosb7YM4gvPQ2dW/UUVpDkEhO9aRFdsXtuGMN4oDVJnu2PdFkIL+8kDBG6QaDQ4yLyBXiT7tjO8/CZ1pYI73Bj27Yk7H+Et0vjP169NwqoOBpGb x-ms-office365-filtering-correlation-id: 917c83ac-92ff-4366-d112-08d61d1564a7 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:(28532068793085)(89211679590171); 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)(76176011)(10290500003)(1076002)(105586002)(476003)(2616005)(11346002)(446003)(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: HQVb6NuszfuIzYJVC2mDYMZ7WpEVyiqnVN403OjqAhoPnHlpvPe8T2Yz21SO1TsiSXTO+ZDYusTeicMsFIHcaowi/nFHIICwp0CVV0863B496a1qhNoXmenO60/NOFi8p9TLxvm9AC4nt4H/roA1FKEG8aDrrpQ7JZJIcKX1bbjsi2s4vU2SFPPiQV/jdVSTkwNYLoCRVe5ZH85yd9GkR/+HGmZomrgZiK8cSlqmFiDjK1Z11trXkG/KkNeub031Oelm/0I7sYfHFI6M04cC52dv2ew3BmOgae+8pe73avogkksHuYcI3UsofUxxKkf1/LHHWGxTBBLdt7ikTPJcUPe8Y8z1Z/8CXlBeUiuA6Zc= 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: 917c83ac-92ff-4366-d112-08d61d1564a7 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2018 03:18:23.4918 (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 This patch is to add wrapper functions for tlb_remote_flush_with_range callback. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index c67f09086378..ac3b748f58f8 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -253,6 +253,54 @@ static void mmu_spte_set(u64 *sptep, u64 spte); static union kvm_mmu_page_role kvm_mmu_calc_root_page_role(struct kvm_vcpu *vcpu); =20 + +static inline bool kvm_available_flush_tlb_with_range(void) +{ + return kvm_x86_ops->tlb_remote_flush_with_range; +} + +static void kvm_flush_remote_tlbs_with_range(struct kvm *kvm, + struct kvm_tlb_range *range) +{ + int ret =3D -ENOTSUPP; + + if (range && kvm_x86_ops->tlb_remote_flush_with_range) { + /* + * Read tlbs_dirty before setting KVM_REQ_TLB_FLUSH in + * kvm_make_all_cpus_request. + */ + long dirty_count =3D smp_load_acquire(&kvm->tlbs_dirty); + + ret =3D kvm_x86_ops->tlb_remote_flush_with_range(kvm, range); + cmpxchg(&kvm->tlbs_dirty, dirty_count, 0); + } + + if (ret) + kvm_flush_remote_tlbs(kvm); +} + +static void kvm_flush_remote_tlbs_with_list(struct kvm *kvm, + struct list_head *flush_list) +{ + struct kvm_tlb_range range; + + range.flush_list =3D flush_list; + + kvm_flush_remote_tlbs_with_range(kvm, &range); +} + +static void kvm_flush_remote_tlbs_with_address(struct kvm *kvm, + u64 start_gfn, u64 pages) +{ + struct kvm_tlb_range range; + + range.start_gfn =3D start_gfn; + range.pages =3D pages; + range.flush_list =3D NULL; + + kvm_flush_remote_tlbs_with_range(kvm, &range); +} + void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask, u64 mmio_value) { BUG_ON((mmio_mask & mmio_value) !=3D mmio_value); --=20 2.14.4