Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1990493imm; Sat, 13 Oct 2018 07:56:00 -0700 (PDT) X-Google-Smtp-Source: ACcGV63wLOV12InlLEpszhCd83YO+70L1dxXBdM6MY9lWMwXkt4ycMlzKAsU/FOy6b8xJWmiUmNu X-Received: by 2002:a63:8343:: with SMTP id h64-v6mr9049442pge.368.1539442560371; Sat, 13 Oct 2018 07:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539442560; cv=none; d=google.com; s=arc-20160816; b=syVlZ6pLib8w5IWgcut+K3xg23d6IIgJtDDtaAT9pK4deIAyZsUbOlzpyMVEES3BD+ esbXvBbsw8A+M90FXVewynrBTnf4IdFf1hz5wU+IjBZvPBG/9efTF+69PX8WvYfufSpb T8J2ScpivpdWHVPlmO50JwVBP/GvNOnJL67nxOvU0qIzTL5zEGaJZ2xzs7k96jLrSEjH JvqubG+AcSLx5W+nTIOWa867NtJIw3NG3buAykWoQm4VRRKKQHQ0QxdHXqkt6iSl79lG K24uIu1JgTVu2ejZcs4s79rp+IsJF5RRd/yGg0WmQxoWn3fT1mt2Sp6FrOszruI7NzXX r3XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:message-id:date :subject:cc:from:dkim-signature; bh=GCaq3R6VmH1wWlGObzsIcMHnr3COIkQBYeAae2u7kcQ=; b=ARf6zGsEQGmbisfdLTCxtgI1IDkl2zL1gpcavQQfSGpl96LURpbci5BzCcsCLviFER 8HSwVMp4gdnc8sLHAkoIJc95NPPd1Z+5rfGxXUT4UB2SJXPcOMJXTbaO/4iQtxu1IU2V IyQDk06hz7iA7EoCVITDkkHcdawjYOLt88Vg2/Q+bS5vWUq9QQVIBfRlUBr8oCpEEM45 bYN4dKeUDOMOEucUgSP3LIAKXmrb+8MadpYYErvk13MQBmr1sn26G6q2OxCdSaC1dtXD Hg7RZnTpJJUV/15FaNhTZj46uS6qHCpYX0ffERrvlLqQOkO72SQ5DLe6Ojqwc6wA1vPb jMXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZVICMHN0; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p17-v6si4590529pgh.515.2018.10.13.07.55.23; Sat, 13 Oct 2018 07:56:00 -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=fail header.i=@gmail.com header.s=20161025 header.b=ZVICMHN0; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726775AbeJMWcE (ORCPT + 99 others); Sat, 13 Oct 2018 18:32:04 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34548 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726714AbeJMWcE (ORCPT ); Sat, 13 Oct 2018 18:32:04 -0400 Received: by mail-pf1-f193.google.com with SMTP id f78-v6so1833439pfe.1; Sat, 13 Oct 2018 07:54:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GCaq3R6VmH1wWlGObzsIcMHnr3COIkQBYeAae2u7kcQ=; b=ZVICMHN0AFLfvRfTF9yl5eF1LtUJio6d6J3YKdxugmdHzEsj5NXvND7pZv/SidDdek 6My4+c84eQCZREXmERXD0Z2ujNZD/ldNJn5zEVz37wk9/OYXYVpkpLkWRnABYIWyAmcK GF3oatbiLja/B2Ge3yx9NqdUaA+1W+keyw3OOvxZQdmm2aUfq3sYKOwk9jVqTHCjDbgk Wu2MFL9RTrN06WtDIlRlDY8nRY339wsHGB9T0q606/Yg7WI6wxRXmG77b0oOXGVz8pzE fl3VV6iszqco6/a9twuZ2bk9dauQqmQkRQ+Pzgk77Aph5Hld8/GC2Ur3ANhrpNdgLvHZ gQ6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GCaq3R6VmH1wWlGObzsIcMHnr3COIkQBYeAae2u7kcQ=; b=knVVLuWEaeSPXvrW79R6p2bSi6ABHhmG4Qd1j+lJ7pjrF9+sJNX0fPJgnajIDqK6vT GcoAld0M+XfLqOt2EaUD4t6UmqAMbcooSIkDq/6ifexe8f7/mi40TpcjA2g2NnK5FpJY 7iLfaWn1r36KNKZmr7kd8ANGBhd8loQcMwuNu8pE1MjFLFi0C5st7EMEwdBKD2I9ihIC /xagdLk7QkKk1Bs+750iP6uDogUA+pk3yo+WOPUd5GbirGLfruFsRQ2ocj9aXnY5Prm6 YmKCTUyIiPVri1b7ink5Hr69+HP6+1ulL3Yoeahpp/cNFUPjcO9Ba+gk7zwhIm+r4/j6 APHw== X-Gm-Message-State: ABuFfoj53gtiIeAAfYZ5M5qVWeNJO0auMidOn8tDOdL1JmhChqjKS2a4 lbspNinzdWZKhdx0JcOnwpJF+f1QmWc= X-Received: by 2002:a65:4103:: with SMTP id w3-v6mr9732885pgp.284.1539442478487; Sat, 13 Oct 2018 07:54:38 -0700 (PDT) Received: from localhost.corp.microsoft.com ([2404:f801:9000:18:d9bf:62c6:740b:9fc4]) by smtp.googlemail.com with ESMTPSA id v81-v6sm8688724pfj.25.2018.10.13.07.54.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 13 Oct 2018 07:54:37 -0700 (PDT) From: lantianyu1986@gmail.com X-Google-Original-From: Tianyu.Lan@microsoft.com Cc: Lan Tianyu , christoffer.dall@arm.com, marc.zyngier@arm.com, linux@armlinux.org, catalin.marinas@arm.com, will.deacon@arm.com, jhogan@kernel.org, ralf@linux-mips.org, paul.burton@mips.com, paulus@ozlabs.org, benh@kernel.crashing.org, mpe@ellerman.id.au, kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, linux-mips@linux-mips.org, kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, devel@linuxdriverproject.org, kvm@vger.kernel.org, michael.h.kelley@microsoft.com, vkuznets@redhat.com Subject: [PATCH V4 2/15] KVM/MMU: Add tlb flush with range helper function Date: Sat, 13 Oct 2018 22:53:53 +0800 Message-Id: <20181013145406.4911-3-Tianyu.Lan@microsoft.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20181013145406.4911-1-Tianyu.Lan@microsoft.com> References: <20181013145406.4911-1-Tianyu.Lan@microsoft.com> 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 From: Lan Tianyu This patch is to add wrapper functions for tlb_remote_flush_with_range callback. Signed-off-by: Lan Tianyu --- Change sicne V3: Remove code of updating "tlbs_dirty" Change since V2: Fix comment in the kvm_flush_remote_tlbs_with_range() --- arch/x86/kvm/mmu.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index c73d9f650de7..ff656d85903a 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -264,6 +264,46 @@ 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); + +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 = -ENOTSUPP; + + if (range && kvm_x86_ops->tlb_remote_flush_with_range) + ret = kvm_x86_ops->tlb_remote_flush_with_range(kvm, range); + + 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 = 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 = start_gfn; + range.pages = pages; + range.flush_list = 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) != mmio_value); -- 2.14.4