Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3873909ioo; Wed, 25 May 2022 09:48:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaZj51TcCp3+0+9BvlEfU3cSBbqUmw/Q7W8xOUeTjk36D0eWoo5ynSwQ8y1hbJe4TgIxBE X-Received: by 2002:a63:4c:0:b0:3fa:b4d8:26cf with SMTP id 73-20020a63004c000000b003fab4d826cfmr6660422pga.463.1653497316718; Wed, 25 May 2022 09:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653497316; cv=none; d=google.com; s=arc-20160816; b=tndWAK0aF0hgK6tp1+r6R0mxHWt5lwTciX6yuXNSyfwitenve2dLRH372F7x5vDZy9 pVP6I0qH2wk3FJqFYoPyRiHQ4EE1rkhZbWwjZ/iGmozAIVUy3mkWc9De3hM/PDvH3OeZ CpH3V6OieatTSwbGo5dk5YGJR3YSM10L0fvBwLZR011HTkh8ilrodgoExHb7ql/gwPm8 pSXfz1KOu2EXShlk2MUS0g3kuXkgRJuBLYpTOEXXlpFg2K4Ue01740bRfa5q5liXoFPe rWFgBqASSj4CbviAoV6DYlmZAi9YQ/B9BbF6eQpjW6KiT3K3VmBFZgmK9GUuiEgocsas hlpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=B2s/9SfYEmUCeB/Q2Gft8JfkhOG9QuJaBzKgdBSdiJo=; b=hCWJ4V74t8DbFXscJYNwutOU1NQBSx6dp4O6+YMmnR93dvb8iwmyQOyz37Ajooe3Rq 17G4Zpae5PMhheYl4Xzbh0OOrJTnsrtiHgl7FvlFSJ2ZMl0cK939CrR8puhpXl73+YE5 UcRMdBCTq+usNG4V8zrXj2WOcIqMWCyf43O8Ud6OzYig5/PFzwK4yLgz3Cg7NhzBd8xt u0nlfeoM9c3oY+fcXR19FUXDw0tDLKo+SiIeSmUMEJTpnH/rhqWtChLPAs4V4FsJR8km UXoU7wZUVUGrFHUUqxRHW/cU4nb6l7+v3sJ1JgGuyZMHqt0WbVvXeThcINCZJ5ceLBFO UpLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cyPGiPAG; 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 bm18-20020a656e92000000b003c6aa1dce61si21563016pgb.534.2022.05.25.09.48.10; Wed, 25 May 2022 09:48:36 -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=cyPGiPAG; 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 S234541AbiEYJCA (ORCPT + 99 others); Wed, 25 May 2022 05:02:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236816AbiEYJBr (ORCPT ); Wed, 25 May 2022 05:01:47 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 627A97037E for ; Wed, 25 May 2022 02:01:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653469305; 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=B2s/9SfYEmUCeB/Q2Gft8JfkhOG9QuJaBzKgdBSdiJo=; b=cyPGiPAGklRuVEtayVPbkQbUnaIIqa3QlvmOU5LMKCnhTavEyYbOpvA3ILM84oyB14xG70 Hgz0a/PiCqIzeQJUH9t6A3/C3QfOS7bqFkp2jzskfxuzCuTpguKFuzBAipbFKdALcKM1K+ yFSj3Xefnytc82QgpwbpUUpXXPGESGs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-487-7KriNd-POmCDUVXiSb8mng-1; Wed, 25 May 2022 05:01:41 -0400 X-MC-Unique: 7KriNd-POmCDUVXiSb8mng-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C2982101AA46; Wed, 25 May 2022 09:01:40 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.194.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AED640CF8EF; Wed, 25 May 2022 09:01:38 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Maxim Levitsky , Wanpeng Li , Jim Mattson , Michael Kelley , Siddharth Chandrasekaran , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 02/37] KVM: x86: hyper-v: Resurrect dedicated KVM_REQ_HV_TLB_FLUSH flag Date: Wed, 25 May 2022 11:00:58 +0200 Message-Id: <20220525090133.1264239-3-vkuznets@redhat.com> In-Reply-To: <20220525090133.1264239-1-vkuznets@redhat.com> References: <20220525090133.1264239-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, 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 In preparation to implementing fine-grained Hyper-V TLB flush and L2 TLB flush, resurrect dedicated KVM_REQ_HV_TLB_FLUSH request bit. As KVM_REQ_TLB_FLUSH_GUEST/KVM_REQ_TLB_FLUSH_GUEST/KVM_REQ_TLB_FLUSH_CURRENT are stronger operations, clear KVM_REQ_HV_TLB_FLUSH request in kvm_service_local_tlb_flush_requests() when any of these were also requested. No (real) functional change intended. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/hyperv.c | 4 ++-- arch/x86/kvm/x86.c | 10 ++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 151880cfab9e..92509ee6ae1b 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -105,6 +105,8 @@ KVM_ARCH_REQ_FLAGS(30, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP) #define KVM_REQ_MMU_FREE_OBSOLETE_ROOTS \ KVM_ARCH_REQ_FLAGS(31, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP) +#define KVM_REQ_HV_TLB_FLUSH \ + KVM_ARCH_REQ_FLAGS(32, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP) #define CR0_RESERVED_BITS \ (~(unsigned long)(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS \ diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 46f9dfb60469..b402ad059eb9 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -1876,11 +1876,11 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc) * analyze it here, flush TLB regardless of the specified address space. */ if (all_cpus) { - kvm_make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH_GUEST); + kvm_make_all_cpus_request(kvm, KVM_REQ_HV_TLB_FLUSH); } else { sparse_set_to_vcpu_mask(kvm, sparse_banks, valid_bank_mask, vcpu_mask); - kvm_make_vcpus_request_mask(kvm, KVM_REQ_TLB_FLUSH_GUEST, vcpu_mask); + kvm_make_vcpus_request_mask(kvm, KVM_REQ_HV_TLB_FLUSH, vcpu_mask); } ret_success: diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 891507b2eca5..f98503431f8d 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3363,11 +3363,17 @@ static inline void kvm_vcpu_flush_tlb_current(struct kvm_vcpu *vcpu) */ void kvm_service_local_tlb_flush_requests(struct kvm_vcpu *vcpu) { - if (kvm_check_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu)) + if (kvm_check_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu)) { kvm_vcpu_flush_tlb_current(vcpu); + kvm_clear_request(KVM_REQ_HV_TLB_FLUSH, vcpu); + } - if (kvm_check_request(KVM_REQ_TLB_FLUSH_GUEST, vcpu)) + if (kvm_check_request(KVM_REQ_TLB_FLUSH_GUEST, vcpu)) { + kvm_vcpu_flush_tlb_guest(vcpu); + kvm_clear_request(KVM_REQ_HV_TLB_FLUSH, vcpu); + } else if (kvm_check_request(KVM_REQ_HV_TLB_FLUSH, vcpu)) { kvm_vcpu_flush_tlb_guest(vcpu); + } } EXPORT_SYMBOL_GPL(kvm_service_local_tlb_flush_requests); -- 2.35.3