Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5461643rwp; Mon, 17 Jul 2023 04:46:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlEwvrM5VdyjrvxXPh3gTlh+Zc3FH2OfOgQM22qkLzAK2tm/C5hFN0UkbzcSTRqtURLJ3kpE X-Received: by 2002:a17:906:535b:b0:993:fba5:cdf3 with SMTP id j27-20020a170906535b00b00993fba5cdf3mr12040469ejo.6.1689594370852; Mon, 17 Jul 2023 04:46:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689594370; cv=none; d=google.com; s=arc-20160816; b=TMeJuWITqpDc7v0Pa3o4KH/jyvrisQsFjjmcQPpVdK8dWlIYkYYgpEZUrfi75CwopP uQpJsDzQCr9iwzLOS56DXu2oJx48t2fSuXuO8OkjK4ndtHula3Sbju4JdPKf1S3hyh+l yKOhvxWKa774P/8a83QgagMA6JrGhWR6vg0eLJ34vPQYSDVYL9wbhZFuR8OjC5mmlf/U Hn0uMUCYNtWzLAhBpHOe9beYr6gFKGHe7+7kxqJN2gklosiQtCxY38S0Qswqqw/2B5kk MRRKsd8tEouO4y788dQJPtmmVMXai9aRoE4vrGhuMEHZjaWBLa+wfXflilM5C0WmLHoS tG8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=cifHTSGxLePrnNdALZCim8wNk8dyI3fwSptrejN9W0Y=; fh=Ue6fXJvFK/JYLKuYsREudUgD/yVhJz4AeUe7s+l1ZO0=; b=mC0CSkKC0awEepwtsyYmeYq9OP4WPQBZ94w/rljWqUSfFESmSbHIMBvLg6FSsT8uLv wsmDVk2shnrRMtRn1/HhuaiVgmHl21ItDGZH7odobgUFDUaTLn/pc5TiMzrRud2TS74D ViBj85S3cqhLZQZrrwiEamUysK6+o8Tj/EzVOjX2+e2cuwcKnUMovqWFxenk1dnHKNF8 NpkXLvWQWGJZHis85e0FFme3OteWhwaQgugajxr49FRA24KjcVWqmsNYTYCsNCdDtdrV ZtuyN5k/p7fCTqOX7TSzJRxLWXvszCJcYoxNmu/HOrkPSP/nlSSpWC3Rz9RpPLRZ6z8z TVPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KEJBoF8d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h14-20020a1709063c0e00b009929566f00asi15888611ejg.467.2023.07.17.04.45.46; Mon, 17 Jul 2023 04:46:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KEJBoF8d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229818AbjGQL2j (ORCPT + 99 others); Mon, 17 Jul 2023 07:28:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbjGQL2i (ORCPT ); Mon, 17 Jul 2023 07:28:38 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 452B5E4F for ; Mon, 17 Jul 2023 04:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689593275; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cifHTSGxLePrnNdALZCim8wNk8dyI3fwSptrejN9W0Y=; b=KEJBoF8dV38WX7IDPbRK8G3/Tv2+hj45U0SqB1ZgPLvXDzpgS//wSSk9USpIhw6lGjovLI fEL+CYRmjN7NM4oY/BsBAaznRKY/p2VMonDAiX2KpYyFQuMGSCldcTh5t1vt2VRfdR+9M9 At5jsi63nkBkh8bgtpliIwA/CtTljlo= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-170-CdVmGCEVMtyxyofWklb4QQ-1; Mon, 17 Jul 2023 07:27:54 -0400 X-MC-Unique: CdVmGCEVMtyxyofWklb4QQ-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-767a1ad2175so108480385a.0 for ; Mon, 17 Jul 2023 04:27:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689593273; x=1690198073; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cifHTSGxLePrnNdALZCim8wNk8dyI3fwSptrejN9W0Y=; b=kuAi+uSZi2kK1mJxpWcvRqLfrUkNWIXzAHxOxdJzdYPTRNdwIsiCMtqsLWjdK3d6fu kgewIWtdpbCOetbDzfMzzXR+Mz2KT06FQ6R29F4zKsw5y9EzeupBjRFO+aFa7MxFQ2sv SuFYWc2IxcqanTtPnkpwCpSwWH9Suj4/uY92HVnAzbRsZws7ISRsgGVEmDnjE76AKJoJ yI8D5F48diCbxYQ3DuNmSid0q5SXkazp7el2okHspRukxcRbzpxPRKdWURhu9QD9rGUc 6HWZs3JxZEMR7Zrvqhc/20rxlBVDKCb3nfoWasIZbIbV8qKEyxDVTVhekzDyXQVbIwsI VgmQ== X-Gm-Message-State: ABy/qLZmoR0o459ls40R+USQc1EyzUDjGK74k7+Ik57pEGadso5+KaAw B2WQHFYSMWxWoxmkM+texxE25fDyXvAlJPZpoiBOsoC+Ol4LcpP2C0yhpyXSm6Jtp2O7C+HFSto 28aVLcXAdsbgLWOr56Hif0IUV X-Received: by 2002:a05:620a:454a:b0:763:c764:577c with SMTP id u10-20020a05620a454a00b00763c764577cmr16480751qkp.5.1689593273642; Mon, 17 Jul 2023 04:27:53 -0700 (PDT) X-Received: by 2002:a05:620a:454a:b0:763:c764:577c with SMTP id u10-20020a05620a454a00b00763c764577cmr16480723qkp.5.1689593273369; Mon, 17 Jul 2023 04:27:53 -0700 (PDT) Received: from [10.66.61.39] ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id z1-20020a05620a100100b0075b2af4a076sm6028544qkj.16.2023.07.17.04.27.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Jul 2023 04:27:53 -0700 (PDT) Message-ID: <0e5dd611-b047-5565-cf09-ad8844386b81@redhat.com> Date: Mon, 17 Jul 2023 19:27:29 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v6 02/11] KVM: arm64: Use kvm_arch_flush_remote_tlbs() Content-Language: en-US To: Raghavendra Rao Ananta , Oliver Upton , Marc Zyngier , James Morse , Suzuki K Poulose Cc: Paolo Bonzini , Sean Christopherson , Huacai Chen , Zenghui Yu , Anup Patel , Atish Patra , Jing Zhang , Colton Lewis , David Matlack , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Zenghui Yu , Gavin Shan References: <20230715005405.3689586-1-rananta@google.com> <20230715005405.3689586-3-rananta@google.com> From: Shaoqin Huang In-Reply-To: <20230715005405.3689586-3-rananta@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/15/23 08:53, Raghavendra Rao Ananta wrote: > From: David Matlack > > Use kvm_arch_flush_remote_tlbs() instead of > CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL. The two mechanisms solve the same > problem, allowing architecture-specific code to provide a non-IPI > implementation of remote TLB flushing. > > Dropping CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL allows KVM to standardize > all architectures on kvm_arch_flush_remote_tlbs() instead of maintaining > two mechanisms. > > Opt to standardize on kvm_arch_flush_remote_tlbs() since it avoids > duplicating the generic TLB stats across architectures that implement > their own remote TLB flush. > > This adds an extra function call to the ARM64 kvm_flush_remote_tlbs() > path, but that is a small cost in comparison to flushing remote TLBs. > > In addition, instead of just incrementing remote_tlb_flush_requests > stat, the generic interface would also increment the > remote_tlb_flush stat. > > Signed-off-by: David Matlack > Signed-off-by: Raghavendra Rao Ananta > Reviewed-by: Zenghui Yu > Acked-by: Oliver Upton > Reviewed-by: Gavin Shan Reviewed-by: Shaoqin Huang > --- > arch/arm64/include/asm/kvm_host.h | 3 +++ > arch/arm64/kvm/Kconfig | 1 - > arch/arm64/kvm/mmu.c | 6 +++--- > virt/kvm/Kconfig | 3 --- > virt/kvm/kvm_main.c | 2 -- > 5 files changed, 6 insertions(+), 9 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 8b6096753740..7281222f24ef 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -1111,6 +1111,9 @@ int __init kvm_set_ipa_limit(void); > #define __KVM_HAVE_ARCH_VM_ALLOC > struct kvm *kvm_arch_alloc_vm(void); > > +#define __KVM_HAVE_ARCH_FLUSH_REMOTE_TLBS > +int kvm_arch_flush_remote_tlbs(struct kvm *kvm); > + > static inline bool kvm_vm_is_protected(struct kvm *kvm) > { > return false; > diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig > index f531da6b362e..6b730fcfee37 100644 > --- a/arch/arm64/kvm/Kconfig > +++ b/arch/arm64/kvm/Kconfig > @@ -25,7 +25,6 @@ menuconfig KVM > select MMU_NOTIFIER > select PREEMPT_NOTIFIERS > select HAVE_KVM_CPU_RELAX_INTERCEPT > - select HAVE_KVM_ARCH_TLB_FLUSH_ALL > select KVM_MMIO > select KVM_GENERIC_DIRTYLOG_READ_PROTECT > select KVM_XFER_TO_GUEST_WORK > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index 6db9ef288ec3..0ac721fa27f1 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -161,15 +161,15 @@ static bool memslot_is_logging(struct kvm_memory_slot *memslot) > } > > /** > - * kvm_flush_remote_tlbs() - flush all VM TLB entries for v7/8 > + * kvm_arch_flush_remote_tlbs() - flush all VM TLB entries for v7/8 > * @kvm: pointer to kvm structure. > * > * Interface to HYP function to flush all VM TLB entries > */ > -void kvm_flush_remote_tlbs(struct kvm *kvm) > +int kvm_arch_flush_remote_tlbs(struct kvm *kvm) > { > - ++kvm->stat.generic.remote_tlb_flush_requests; > kvm_call_hyp(__kvm_tlb_flush_vmid, &kvm->arch.mmu); > + return 0; > } > > static bool kvm_is_device_pfn(unsigned long pfn) > diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig > index b74916de5183..484d0873061c 100644 > --- a/virt/kvm/Kconfig > +++ b/virt/kvm/Kconfig > @@ -62,9 +62,6 @@ config HAVE_KVM_CPU_RELAX_INTERCEPT > config KVM_VFIO > bool > > -config HAVE_KVM_ARCH_TLB_FLUSH_ALL > - bool > - > config HAVE_KVM_INVALID_WAKEUPS > bool > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 70e5479797ac..d6b050786155 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -345,7 +345,6 @@ bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req) > } > EXPORT_SYMBOL_GPL(kvm_make_all_cpus_request); > > -#ifndef CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL > void kvm_flush_remote_tlbs(struct kvm *kvm) > { > ++kvm->stat.generic.remote_tlb_flush_requests; > @@ -366,7 +365,6 @@ void kvm_flush_remote_tlbs(struct kvm *kvm) > ++kvm->stat.generic.remote_tlb_flush; > } > EXPORT_SYMBOL_GPL(kvm_flush_remote_tlbs); > -#endif > > static void kvm_flush_shadow_all(struct kvm *kvm) > { -- Shaoqin