From patchwork Fri Feb 7 22:35:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11371339 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 628311398 for ; Fri, 7 Feb 2020 22:35:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 406BA222D9 for ; Fri, 7 Feb 2020 22:35:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TqgeDWsV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727465AbgBGWfa (ORCPT ); Fri, 7 Feb 2020 17:35:30 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:20554 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727379AbgBGWfa (ORCPT ); Fri, 7 Feb 2020 17:35:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581114928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8BwOjosBD3aan9vZqA1/XtTiViONk3Y9UUF8NI7mgRo=; b=TqgeDWsVl6jBUndQDpLwvSh19aWpr8HKcV3F+Sn5DF/18m/fbM1e8u7PR/0Z9U5CwOlEzn AzQCxtFJTyYB7DTa3+UmYkhrtwlU4zn3QiTXnDxidZxhOcVhEMiXDCDYa7Mymzm2UHRCCT RVC4ary7WfhAqsUIX5OkvCICezOS8Wo= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-321-jJu1sl6qPiOuGnj6dnw_PA-1; Fri, 07 Feb 2020 17:35:25 -0500 X-MC-Unique: jJu1sl6qPiOuGnj6dnw_PA-1 Received: by mail-qv1-f70.google.com with SMTP id l1so485508qvu.13 for ; Fri, 07 Feb 2020 14:35:25 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=8BwOjosBD3aan9vZqA1/XtTiViONk3Y9UUF8NI7mgRo=; b=eCopripMFszuJcljTne+EoyIOjHfiYemh9T7mJ7Z4zTSdvtGtNeCe039K1sfJXiVSP o7Qn/L0m+wQWAChwdYpsaCwbGbr9JI4ji7YOWxa8dM0I3dWya3JwVCV6fkcI71gXP3yt F6d0TjHnlxvF4eK7WoY3iyaIfK244qwY/l/PGkOvszj4l51irG6fic+K4taqYvX967uD 0CXqarHWIbssEY0It4zIqaQKgcNv7FqkDAOpiMop29NDud7gns6pwC38Cvz66u+bnfde JpT6ugceC92FL48GkHsxy+FyGdD4LP52IWjShvDpJ2RDOrUauOPFDYZ6wK1FM8zreatt 6h8Q== X-Gm-Message-State: APjAAAXrCsY3ausQOqxnwfeKpZuTxS9kBYs1brSmTdGBlOBCtRie/Hsm hscfhqbOvkPXt8PSOFpHq+v/A4kmkCTPDwwhL8sKkGB1Co9m6irlokRbswTx6sfQ9o89iIhBPvg 9c/MOpEy3+412 X-Received: by 2002:aed:3e13:: with SMTP id l19mr560576qtf.103.1581114925266; Fri, 07 Feb 2020 14:35:25 -0800 (PST) X-Google-Smtp-Source: APXvYqyVTvI4slEe315nMe8hBROEAYdieeZun635Z6BLpraphf59wQM9cy4oqH/UIWzzvIngWXEG9g== X-Received: by 2002:aed:3e13:: with SMTP id l19mr560554qtf.103.1581114925041; Fri, 07 Feb 2020 14:35:25 -0800 (PST) Received: from xz-x1.redhat.com ([2607:9880:19c8:32::2]) by smtp.gmail.com with ESMTPSA id u12sm2178736qtj.84.2020.02.07.14.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2020 14:35:24 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson , Paolo Bonzini , linux-mips@vger.kernel.org, peterx@redhat.com, Vitaly Kuznetsov Subject: [PATCH RFC 1/4] KVM: Provide kvm_flush_remote_tlbs_common() Date: Fri, 7 Feb 2020 17:35:17 -0500 Message-Id: <20200207223520.735523-2-peterx@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200207223520.735523-1-peterx@redhat.com> References: <20200207223520.735523-1-peterx@redhat.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org It's exactly kvm_flush_remote_tlbs() now but a internal wrapper of the common code path. With this, an arch can then optionally select CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL=y and will be able to use the common flushing code. Signed-off-by: Peter Xu --- include/linux/kvm_host.h | 1 + virt/kvm/kvm_main.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 6d5331b0d937..915df64125f9 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -798,6 +798,7 @@ int kvm_vcpu_yield_to(struct kvm_vcpu *target); void kvm_vcpu_on_spin(struct kvm_vcpu *vcpu, bool usermode_vcpu_not_eligible); void kvm_flush_remote_tlbs(struct kvm *kvm); +void kvm_flush_remote_tlbs_common(struct kvm *kvm); void kvm_reload_remote_mmus(struct kvm *kvm); bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req, diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index eb3709d55139..9c7b39b7bb21 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -302,8 +302,7 @@ bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req) return called; } -#ifndef CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL -void kvm_flush_remote_tlbs(struct kvm *kvm) +void kvm_flush_remote_tlbs_common(struct kvm *kvm) { /* * Read tlbs_dirty before setting KVM_REQ_TLB_FLUSH in @@ -327,6 +326,13 @@ void kvm_flush_remote_tlbs(struct kvm *kvm) ++kvm->stat.remote_tlb_flush; cmpxchg(&kvm->tlbs_dirty, dirty_count, 0); } +EXPORT_SYMBOL_GPL(kvm_flush_remote_tlbs_common); + +#ifndef CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL +void kvm_flush_remote_tlbs(struct kvm *kvm) +{ + kvm_flush_remote_tlbs_common(kvm); +} EXPORT_SYMBOL_GPL(kvm_flush_remote_tlbs); #endif From patchwork Fri Feb 7 22:35:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11371353 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C868109A for ; Fri, 7 Feb 2020 22:35:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1FC0922B48 for ; Fri, 7 Feb 2020 22:35:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hCN2/rhT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727573AbgBGWft (ORCPT ); Fri, 7 Feb 2020 17:35:49 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:28661 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727130AbgBGWf3 (ORCPT ); Fri, 7 Feb 2020 17:35:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581114929; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rPutAweyqqYRiz9KxYGz1dd9ij66mBcCSHiTuUd/XC8=; b=hCN2/rhTQAy/erq3v/0Q0BfNKET6FSc3E7iK7EdPyoa0ZPgOzYmasi/qpi9ULNo74xBbbd f8AXDTMMrGq+xbf7CrnT/oIAfI4xOiwATA8Zki6wZBYIbt67RPqpfjw6OsczpZU1VvyP+k j4WJ9lQqsorGkIzVXDpY47bE54KVmEE= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-BeBfieCTMWu8BomtH3wK5w-1; Fri, 07 Feb 2020 17:35:27 -0500 X-MC-Unique: BeBfieCTMWu8BomtH3wK5w-1 Received: by mail-qk1-f199.google.com with SMTP id i11so477836qki.12 for ; Fri, 07 Feb 2020 14:35:27 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=rPutAweyqqYRiz9KxYGz1dd9ij66mBcCSHiTuUd/XC8=; b=ccXQ01QdKKDva2850sXVk8p6n9Nt80vKu9wf//UCQjfXJLEA4OE3f6HQvDRyc8Jt5x 03wBAgJT3A2wtje56BhlAgzDdya6oC5DMyjaHmSig7rA7EWJrJat43jG18HPRQAak8Mw Oo6CF2Lx1vFlQnHPv0q/3oEpzyTDZiEte57oOnDByVm2lcQ7BiXPVKqCSGK1R9tK/axr cvJ07zq722xk0I76trmW9BIif+P+e4gdZ4GEa99tiMu5fiRYTq3sSyuI8PN2tKgaLY21 ZcUjY/2FIKMsw8OZE/HDUYtRYQrxAwZmpiFxsaC6AbUpp0twVeNQnHrpkP10Xv/hKvit OG8A== X-Gm-Message-State: APjAAAV94AK50GifJWqJv9yp04Y1JDL26BNEdVSy+Zjbv+1mlx6B3Trt hiM0G9Tk828Y1AhEdHDDgrsq8PrwkPM/cKFsZ1r1y6W7ef/SHHEFkhAFNXhmrQeu9M2T/6bKmuy Shnv0u+0WvFok X-Received: by 2002:a05:620a:ce5:: with SMTP id c5mr1099005qkj.49.1581114927307; Fri, 07 Feb 2020 14:35:27 -0800 (PST) X-Google-Smtp-Source: APXvYqyYCXDDBavylfK3XSW4kgxYTTnNpTKM31yKtNKqnzCOiKnqklk6yL1y/qv/w5shFGwTrtkFLw== X-Received: by 2002:a05:620a:ce5:: with SMTP id c5mr1098986qkj.49.1581114927069; Fri, 07 Feb 2020 14:35:27 -0800 (PST) Received: from xz-x1.redhat.com ([2607:9880:19c8:32::2]) by smtp.gmail.com with ESMTPSA id u12sm2178736qtj.84.2020.02.07.14.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2020 14:35:26 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson , Paolo Bonzini , linux-mips@vger.kernel.org, peterx@redhat.com, Vitaly Kuznetsov Subject: [PATCH RFC 2/4] KVM: MIPS: Drop flush_shadow_memslot() callback Date: Fri, 7 Feb 2020 17:35:18 -0500 Message-Id: <20200207223520.735523-3-peterx@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200207223520.735523-1-peterx@redhat.com> References: <20200207223520.735523-1-peterx@redhat.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The MIPS flush_shadow_memslot() callback is always calling the flush_shadow_all() implementation no matter for trap-emul or VZ. Delete it and call flush_shadow_all() instead. This patch prepares for a further replacement of letting MIPS to use the common kvm_flush_remote_tlbs() call in all places. No functional change expected. Signed-off-by: Peter Xu --- arch/mips/include/asm/kvm_host.h | 7 ------- arch/mips/kvm/mips.c | 8 ++++---- arch/mips/kvm/trap_emul.c | 7 ------- arch/mips/kvm/vz.c | 7 ------- 4 files changed, 4 insertions(+), 25 deletions(-) diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h index 41204a49cf95..e95faffb23d8 100644 --- a/arch/mips/include/asm/kvm_host.h +++ b/arch/mips/include/asm/kvm_host.h @@ -786,13 +786,6 @@ struct kvm_mips_callbacks { void (*vcpu_uninit)(struct kvm_vcpu *vcpu); int (*vcpu_setup)(struct kvm_vcpu *vcpu); void (*flush_shadow_all)(struct kvm *kvm); - /* - * Must take care of flushing any cached GPA PTEs (e.g. guest entries in - * VZ root TLB, or T&E GVA page tables and corresponding root TLB - * mappings). - */ - void (*flush_shadow_memslot)(struct kvm *kvm, - const struct kvm_memory_slot *slot); gpa_t (*gva_to_gpa)(gva_t gva); void (*queue_timer_int)(struct kvm_vcpu *vcpu); void (*dequeue_timer_int)(struct kvm_vcpu *vcpu); diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c index 2606f3f02b54..1d5e7ffda746 100644 --- a/arch/mips/kvm/mips.c +++ b/arch/mips/kvm/mips.c @@ -216,7 +216,7 @@ void kvm_arch_flush_shadow_memslot(struct kvm *kvm, kvm_mips_flush_gpa_pt(kvm, slot->base_gfn, slot->base_gfn + slot->npages - 1); /* Let implementation do the rest */ - kvm_mips_callbacks->flush_shadow_memslot(kvm, slot); + kvm_mips_callbacks->flush_shadow_all(kvm); spin_unlock(&kvm->mmu_lock); } @@ -258,7 +258,7 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, new->base_gfn + new->npages - 1); /* Let implementation do the rest */ if (needs_flush) - kvm_mips_callbacks->flush_shadow_memslot(kvm, new); + kvm_mips_callbacks->flush_shadow_all(kvm); spin_unlock(&kvm->mmu_lock); } } @@ -1003,7 +1003,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log) memslot = id_to_memslot(slots, log->slot); /* Let implementation handle TLB/GVA invalidation */ - kvm_mips_callbacks->flush_shadow_memslot(kvm, memslot); + kvm_mips_callbacks->flush_shadow_all(kvm); } mutex_unlock(&kvm->slots_lock); @@ -1026,7 +1026,7 @@ int kvm_vm_ioctl_clear_dirty_log(struct kvm *kvm, struct kvm_clear_dirty_log *lo memslot = id_to_memslot(slots, log->slot); /* Let implementation handle TLB/GVA invalidation */ - kvm_mips_callbacks->flush_shadow_memslot(kvm, memslot); + kvm_mips_callbacks->flush_shadow_all(kvm); } mutex_unlock(&kvm->slots_lock); diff --git a/arch/mips/kvm/trap_emul.c b/arch/mips/kvm/trap_emul.c index 5a11e83dffe6..2ecb430ea0f1 100644 --- a/arch/mips/kvm/trap_emul.c +++ b/arch/mips/kvm/trap_emul.c @@ -703,12 +703,6 @@ static void kvm_trap_emul_flush_shadow_all(struct kvm *kvm) kvm_flush_remote_tlbs(kvm); } -static void kvm_trap_emul_flush_shadow_memslot(struct kvm *kvm, - const struct kvm_memory_slot *slot) -{ - kvm_trap_emul_flush_shadow_all(kvm); -} - static u64 kvm_trap_emul_get_one_regs[] = { KVM_REG_MIPS_CP0_INDEX, KVM_REG_MIPS_CP0_ENTRYLO0, @@ -1292,7 +1286,6 @@ static struct kvm_mips_callbacks kvm_trap_emul_callbacks = { .vcpu_uninit = kvm_trap_emul_vcpu_uninit, .vcpu_setup = kvm_trap_emul_vcpu_setup, .flush_shadow_all = kvm_trap_emul_flush_shadow_all, - .flush_shadow_memslot = kvm_trap_emul_flush_shadow_memslot, .gva_to_gpa = kvm_trap_emul_gva_to_gpa_cb, .queue_timer_int = kvm_mips_queue_timer_int_cb, .dequeue_timer_int = kvm_mips_dequeue_timer_int_cb, diff --git a/arch/mips/kvm/vz.c b/arch/mips/kvm/vz.c index dde20887a70d..814bd1564a79 100644 --- a/arch/mips/kvm/vz.c +++ b/arch/mips/kvm/vz.c @@ -3123,12 +3123,6 @@ static void kvm_vz_flush_shadow_all(struct kvm *kvm) } } -static void kvm_vz_flush_shadow_memslot(struct kvm *kvm, - const struct kvm_memory_slot *slot) -{ - kvm_vz_flush_shadow_all(kvm); -} - static void kvm_vz_vcpu_reenter(struct kvm_run *run, struct kvm_vcpu *vcpu) { int cpu = smp_processor_id(); @@ -3185,7 +3179,6 @@ static struct kvm_mips_callbacks kvm_vz_callbacks = { .vcpu_uninit = kvm_vz_vcpu_uninit, .vcpu_setup = kvm_vz_vcpu_setup, .flush_shadow_all = kvm_vz_flush_shadow_all, - .flush_shadow_memslot = kvm_vz_flush_shadow_memslot, .gva_to_gpa = kvm_vz_gva_to_gpa_cb, .queue_timer_int = kvm_vz_queue_timer_int_cb, .dequeue_timer_int = kvm_vz_dequeue_timer_int_cb, From patchwork Fri Feb 7 22:35:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11371347 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DE11109A for ; Fri, 7 Feb 2020 22:35:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2C477217BA for ; Fri, 7 Feb 2020 22:35:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="R/X00Ubi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727570AbgBGWfn (ORCPT ); Fri, 7 Feb 2020 17:35:43 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:25472 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727516AbgBGWfe (ORCPT ); Fri, 7 Feb 2020 17:35:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581114933; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nbFuDNqXWxYaO1U3b7e5Dk8u+2RlyLNa/H+l9wnHCjY=; b=R/X00UbileoB8GuKo2SREXoKf79DDDeY4R7sZlkdD3MM4Eyil4++omsw1rG5fR/GpR70SF 1RIwCp5okSpGSMNIHf5/Teu8OwuUR712EWkt5dZckF+iX2T2VxYYKIUC0d16R0npwA+cME pIYgAsR4hvmLAvoMUC1af+USxXGEnIU= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-430-0e-SH77sO8mHSYGcg_l6iw-1; Fri, 07 Feb 2020 17:35:31 -0500 X-MC-Unique: 0e-SH77sO8mHSYGcg_l6iw-1 Received: by mail-qk1-f200.google.com with SMTP id r145so485530qke.8 for ; Fri, 07 Feb 2020 14:35:31 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=nbFuDNqXWxYaO1U3b7e5Dk8u+2RlyLNa/H+l9wnHCjY=; b=uFprM3HJABDP51rUhu/TWC+7noer+W+fm6GReeFnsbkQQkKWjAN9bK4DWOOkqGYZmv fGooq/asLIpvXy2lRSpv/OV2tOg+JOGVDqWY+6GU8/bFopn3gG8C1Q9l0w9xju5riGH+ QFFjz6Nkk0WbYul+s3E3eKSLwLssn/wxoPacweix2MeU3zLT8DmyTr8YvoxSouVo8rud 5EQD0cJLCVe4ps6L3C/MCB/+LIdvdBj238dBzBH3vV0dB70mysnUk2G7ZmT2LkLDl2Tn fhi1rGLFzEF75M6Q4irUTFUpWMJ2v+7EwoZltm+l8ATs1PAY04WeOxBBasNQGbIYON8d h/Vg== X-Gm-Message-State: APjAAAXuk943rsFqsBhnGlIpXwXpINeDQIcJ1X+DF1VN6rdROm5YlFwC AzEQwkN6DcX1fhmuXJHQdQvgU0jvKC0H6n+oMUTG88FS6kwQPNDM2BkmtI5szOqnCWy9KROJIxf qFGuK2kqxso5n X-Received: by 2002:ac8:70d3:: with SMTP id g19mr564428qtp.209.1581114929009; Fri, 07 Feb 2020 14:35:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwOrsIOK2qFxwanpIc4DdFHwxuCz+v4A8f7plovFbmLVtbkNX/2LPWpBFah+G+L0x+fURCmIg== X-Received: by 2002:ac8:70d3:: with SMTP id g19mr564402qtp.209.1581114928759; Fri, 07 Feb 2020 14:35:28 -0800 (PST) Received: from xz-x1.redhat.com ([2607:9880:19c8:32::2]) by smtp.gmail.com with ESMTPSA id u12sm2178736qtj.84.2020.02.07.14.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2020 14:35:28 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson , Paolo Bonzini , linux-mips@vger.kernel.org, peterx@redhat.com, Vitaly Kuznetsov Subject: [PATCH RFC 3/4] KVM: MIPS: Replace all the kvm_flush_remote_tlbs() references Date: Fri, 7 Feb 2020 17:35:19 -0500 Message-Id: <20200207223520.735523-4-peterx@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200207223520.735523-1-peterx@redhat.com> References: <20200207223520.735523-1-peterx@redhat.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Replace kvm_flush_remote_tlbs() calls in MIPS code into kvm_flush_remote_tlbs_common(). This is to prepare that MIPS will define its own kvm_flush_remote_tlbs() soon. The only three references are all in the flush_shadow_all() hooks. One of them can be directly dropped because it's exactly the kvm_flush_remote_tlbs_common(). Since at it, refactors the other one a bit. No functional change expected. Signed-off-by: Peter Xu --- arch/mips/kvm/trap_emul.c | 8 +------- arch/mips/kvm/vz.c | 7 ++----- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/arch/mips/kvm/trap_emul.c b/arch/mips/kvm/trap_emul.c index 2ecb430ea0f1..ced481c963be 100644 --- a/arch/mips/kvm/trap_emul.c +++ b/arch/mips/kvm/trap_emul.c @@ -697,12 +697,6 @@ static int kvm_trap_emul_vcpu_setup(struct kvm_vcpu *vcpu) return 0; } -static void kvm_trap_emul_flush_shadow_all(struct kvm *kvm) -{ - /* Flush GVA page tables and invalidate GVA ASIDs on all VCPUs */ - kvm_flush_remote_tlbs(kvm); -} - static u64 kvm_trap_emul_get_one_regs[] = { KVM_REG_MIPS_CP0_INDEX, KVM_REG_MIPS_CP0_ENTRYLO0, @@ -1285,7 +1279,7 @@ static struct kvm_mips_callbacks kvm_trap_emul_callbacks = { .vcpu_init = kvm_trap_emul_vcpu_init, .vcpu_uninit = kvm_trap_emul_vcpu_uninit, .vcpu_setup = kvm_trap_emul_vcpu_setup, - .flush_shadow_all = kvm_trap_emul_flush_shadow_all, + .flush_shadow_all = kvm_flush_remote_tlbs_common, .gva_to_gpa = kvm_trap_emul_gva_to_gpa_cb, .queue_timer_int = kvm_mips_queue_timer_int_cb, .dequeue_timer_int = kvm_mips_dequeue_timer_int_cb, diff --git a/arch/mips/kvm/vz.c b/arch/mips/kvm/vz.c index 814bd1564a79..91fbf6710da4 100644 --- a/arch/mips/kvm/vz.c +++ b/arch/mips/kvm/vz.c @@ -3105,10 +3105,7 @@ static int kvm_vz_vcpu_setup(struct kvm_vcpu *vcpu) static void kvm_vz_flush_shadow_all(struct kvm *kvm) { - if (cpu_has_guestid) { - /* Flush GuestID for each VCPU individually */ - kvm_flush_remote_tlbs(kvm); - } else { + if (!cpu_has_guestid) { /* * For each CPU there is a single GPA ASID used by all VCPUs in * the VM, so it doesn't make sense for the VCPUs to handle @@ -3119,8 +3116,8 @@ static void kvm_vz_flush_shadow_all(struct kvm *kvm) * kick any running VCPUs so they check asid_flush_mask. */ cpumask_setall(&kvm->arch.asid_flush_mask); - kvm_flush_remote_tlbs(kvm); } + kvm_flush_remote_tlbs_common(kvm); } static void kvm_vz_vcpu_reenter(struct kvm_run *run, struct kvm_vcpu *vcpu) From patchwork Fri Feb 7 22:35:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11371345 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AAA0F1398 for ; Fri, 7 Feb 2020 22:35:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 89C3A217BA for ; Fri, 7 Feb 2020 22:35:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DUbrIfrd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727551AbgBGWfh (ORCPT ); Fri, 7 Feb 2020 17:35:37 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:55117 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727502AbgBGWfg (ORCPT ); Fri, 7 Feb 2020 17:35:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581114935; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9XsUS877THbbHLMWAH0vUYHxXn1kbs8c4Q1KcyCj1WI=; b=DUbrIfrdHh4WnKTrN6X6btATVTGFr3f64b8UT/FmxgP/2IksPPSNZgVT+j/7+44W+jkpVg v7WC5guarDeFs1QzvYKM5TKqhrogDwotl8ZbL/r7VhLKT6nILJqi7wTh+i2pMBrrJWn4TY aca5/c2tMTz+x/O0m4rzGZna7E1bFHM= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-422-xC59e3F1O7iO6i0TV-Yzew-1; Fri, 07 Feb 2020 17:35:31 -0500 X-MC-Unique: xC59e3F1O7iO6i0TV-Yzew-1 Received: by mail-qt1-f200.google.com with SMTP id l1so517031qtp.21 for ; Fri, 07 Feb 2020 14:35:31 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=9XsUS877THbbHLMWAH0vUYHxXn1kbs8c4Q1KcyCj1WI=; b=XAuzkOhD5NjDZ/D5CZITdrPBeGkevf+22Kp6Nu4XVqHNFH3Ms+9zXUBCikyADD4ovU ItSp/xpmuIsY1MM9b5X36ghtA/68Wb6X7h1wFpbG8cJRhdqrCpIZG36Cd5OJxhn8W+Gr 9dFMy6BV3Nlu9dlJ3Maf/uK3Ws97418huo2tRnCGgcOqcDArcx/wqTXrDjt+HncOZIOF vSHiOGlWSVjk09YKPF+T40lGao0tOuJ0PinFyCN6GWvG3M04QY3ToXQhMK2GpePmX9hz w5KoNzQNQdSwNfB4MeE0eAcUgYIZsynTwi59eq7ItoO1qgBwNzme7LB8HOihqxxBIptO D+SA== X-Gm-Message-State: APjAAAUhMUkNpqFqsrAbQpIv8vV5Radwy97SnjSPa4IfVCx30M6pZlZJ H4VITmiVSnqMmgfCLc5K3Sq2ZITkp/x4FqeUSx8fLpB/ogjeVaSbQWHuByzXZKkObBZDOVxGmqX hGGArqCwihPho X-Received: by 2002:ac8:7388:: with SMTP id t8mr598858qtp.244.1581114930698; Fri, 07 Feb 2020 14:35:30 -0800 (PST) X-Google-Smtp-Source: APXvYqwn5fwgG8yLSUv1nZMep7TxP6EHJN2W9klV6ZqRv2GguI28ys/WxlL4swGn7j7HsjM3rXcdpw== X-Received: by 2002:ac8:7388:: with SMTP id t8mr598847qtp.244.1581114930463; Fri, 07 Feb 2020 14:35:30 -0800 (PST) Received: from xz-x1.redhat.com ([2607:9880:19c8:32::2]) by smtp.gmail.com with ESMTPSA id u12sm2178736qtj.84.2020.02.07.14.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2020 14:35:29 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson , Paolo Bonzini , linux-mips@vger.kernel.org, peterx@redhat.com, Vitaly Kuznetsov Subject: [PATCH RFC 4/4] KVM: MIPS: Define arch-specific kvm_flush_remote_tlbs() Date: Fri, 7 Feb 2020 17:35:20 -0500 Message-Id: <20200207223520.735523-5-peterx@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200207223520.735523-1-peterx@redhat.com> References: <20200207223520.735523-1-peterx@redhat.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Select HAVE_KVM_ARCH_TLB_FLUSH_ALL for MIPS to define its own kvm_flush_remote_tlbs(). It's as simple as calling the flush_shadow_all(kvm) hook. Then replace all the flush_shadow_all() calls to use this KVM generic API to do TLB flush. Signed-off-by: Peter Xu --- arch/mips/kvm/Kconfig | 1 + arch/mips/kvm/mips.c | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/arch/mips/kvm/Kconfig b/arch/mips/kvm/Kconfig index eac25aef21e0..8a06f660d39e 100644 --- a/arch/mips/kvm/Kconfig +++ b/arch/mips/kvm/Kconfig @@ -26,6 +26,7 @@ config KVM select KVM_MMIO select MMU_NOTIFIER select SRCU + select HAVE_KVM_ARCH_TLB_FLUSH_ALL ---help--- Support for hosting Guest kernels. diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c index 1d5e7ffda746..518020b466bf 100644 --- a/arch/mips/kvm/mips.c +++ b/arch/mips/kvm/mips.c @@ -194,13 +194,16 @@ int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot, return 0; } +void kvm_flush_remote_tlbs(struct kvm *kvm) +{ + kvm_mips_callbacks->flush_shadow_all(kvm); +} + void kvm_arch_flush_shadow_all(struct kvm *kvm) { /* Flush whole GPA */ kvm_mips_flush_gpa_pt(kvm, 0, ~0); - - /* Let implementation do the rest */ - kvm_mips_callbacks->flush_shadow_all(kvm); + kvm_flush_remote_tlbs(kvm); } void kvm_arch_flush_shadow_memslot(struct kvm *kvm, @@ -215,8 +218,7 @@ void kvm_arch_flush_shadow_memslot(struct kvm *kvm, /* Flush slot from GPA */ kvm_mips_flush_gpa_pt(kvm, slot->base_gfn, slot->base_gfn + slot->npages - 1); - /* Let implementation do the rest */ - kvm_mips_callbacks->flush_shadow_all(kvm); + kvm_flush_remote_tlbs(kvm); spin_unlock(&kvm->mmu_lock); } @@ -258,7 +260,7 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, new->base_gfn + new->npages - 1); /* Let implementation do the rest */ if (needs_flush) - kvm_mips_callbacks->flush_shadow_all(kvm); + kvm_flush_remote_tlbs(kvm); spin_unlock(&kvm->mmu_lock); } } @@ -1001,9 +1003,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log) if (flush) { slots = kvm_memslots(kvm); memslot = id_to_memslot(slots, log->slot); - - /* Let implementation handle TLB/GVA invalidation */ - kvm_mips_callbacks->flush_shadow_all(kvm); + kvm_flush_remote_tlbs(kvm); } mutex_unlock(&kvm->slots_lock); @@ -1024,9 +1024,7 @@ int kvm_vm_ioctl_clear_dirty_log(struct kvm *kvm, struct kvm_clear_dirty_log *lo if (flush) { slots = kvm_memslots(kvm); memslot = id_to_memslot(slots, log->slot); - - /* Let implementation handle TLB/GVA invalidation */ - kvm_mips_callbacks->flush_shadow_all(kvm); + kvm_flush_remote_tlbs(kvm); } mutex_unlock(&kvm->slots_lock);