From nobody Fri Dec 19 13:46:24 2025 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D7FA264FA2 for ; Wed, 26 Mar 2025 19:37:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743017836; cv=none; b=ua7Q6KWLPBRJP98OlB8Vay+FU+uzJFRndgrBh2emUkJEUumBy2Lf6LtB8jQergOh54Lm7qS4BJaX5DJ6sOATnCgKw0X/MbNzNv4L/mCXFn/6cizFMc5OnPUT9GEGrAUTSiduaMhp8825DMCEfIgW0f3MQTp6kvLiaeqfDxm3gK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743017836; c=relaxed/simple; bh=SNlGfOlmT0Nbk2eVp5pfC34DGqtLN2buTW2ZGWeYC90=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FdKtLJXLRvj4lfLkKpT249SkQC2RQ7RRjl+1cilyi/psf8mSLKdM2ods+wFLzJ44mHAn6/3mz3vvv2atR1CoVt7zMpz7y4rdkD6pguTGRdbPoouEXH+dhG+q6i535yrLdrsbX/Kti6wfXG1NwNHSEn3nDC9yLQsfrQNir8kipMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=plC0CXSP; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="plC0CXSP" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1743017833; 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=Q3ZtK3C7hcG8VBa+3J86AOH6HCNRDt3Nw0pXDBnhw+c=; b=plC0CXSPWL/z9yytx7ucGuf3qjy5bZxk+2QnQxH0J5E/wgWAsLPO1V+tvbI8VP75HgCado XDrI4U2Hbn5lr0DLOQPzI8wU/zBhACW3NuaVcJumoUjsb2juXCOe7QASeY72diQkRFqrX8 kmldVI1/NoqGwDcLsFNwUPssB68C5Q4= From: Yosry Ahmed To: Sean Christopherson Cc: Paolo Bonzini , Jim Mattson , Maxim Levitsky , Vitaly Kuznetsov , Rik van Riel , Tom Lendacky , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed Subject: [RFC PATCH 12/24] KVM: x86: hyper-v: Pass is_guest_mode to kvm_hv_vcpu_purge_flush_tlb() Date: Wed, 26 Mar 2025 19:36:07 +0000 Message-ID: <20250326193619.3714986-13-yosry.ahmed@linux.dev> In-Reply-To: <20250326193619.3714986-1-yosry.ahmed@linux.dev> References: <20250326193619.3714986-1-yosry.ahmed@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Instead of calling is_guest_mode() inside kvm_hv_vcpu_purge_flush_tlb() pass the value from the caller. Future changes will pass different values than is_guest_mode(vcpu). No functional change intended. Signed-off-by: Yosry Ahmed Reviewed-by: Maxim Levitsky --- arch/x86/kvm/hyperv.h | 8 +++++--- arch/x86/kvm/svm/svm.c | 2 +- arch/x86/kvm/x86.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/hyperv.h b/arch/x86/kvm/hyperv.h index 913bfc96959cb..be715deaeb003 100644 --- a/arch/x86/kvm/hyperv.h +++ b/arch/x86/kvm/hyperv.h @@ -203,14 +203,15 @@ static inline struct kvm_vcpu_hv_tlb_flush_fifo *kvm_= hv_get_tlb_flush_fifo(struc return &hv_vcpu->tlb_flush_fifo[i]; } =20 -static inline void kvm_hv_vcpu_purge_flush_tlb(struct kvm_vcpu *vcpu) +static inline void kvm_hv_vcpu_purge_flush_tlb(struct kvm_vcpu *vcpu, + bool is_guest_mode) { struct kvm_vcpu_hv_tlb_flush_fifo *tlb_flush_fifo; =20 if (!to_hv_vcpu(vcpu) || !kvm_check_request(KVM_REQ_HV_TLB_FLUSH, vcpu)) return; =20 - tlb_flush_fifo =3D kvm_hv_get_tlb_flush_fifo(vcpu, is_guest_mode(vcpu)); + tlb_flush_fifo =3D kvm_hv_get_tlb_flush_fifo(vcpu, is_guest_mode); =20 kfifo_reset_out(&tlb_flush_fifo->entries); } @@ -285,7 +286,8 @@ static inline int kvm_hv_hypercall(struct kvm_vcpu *vcp= u) { return HV_STATUS_ACCESS_DENIED; } -static inline void kvm_hv_vcpu_purge_flush_tlb(struct kvm_vcpu *vcpu) {} +static inline void kvm_hv_vcpu_purge_flush_tlb(struct kvm_vcpu *vcpu, + bool is_guest_mode) {} static inline bool kvm_hv_synic_has_vector(struct kvm_vcpu *vcpu, int vect= or) { return false; diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index e664d8428c792..865c5ce4fa473 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -4025,7 +4025,7 @@ static void svm_flush_tlb_asid(struct kvm_vcpu *vcpu) * A TLB flush for the current ASID flushes both "host" and "guest" TLB * entries, and thus is a superset of Hyper-V's fine grained flushing. */ - kvm_hv_vcpu_purge_flush_tlb(vcpu); + kvm_hv_vcpu_purge_flush_tlb(vcpu, is_guest_mode(vcpu)); =20 /* * Flush only the current ASID even if the TLB flush was invoked via diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 182f18ebc62f3..469a8e5526902 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3615,7 +3615,7 @@ static void kvm_vcpu_flush_tlb_guest(struct kvm_vcpu = *vcpu) * Flushing all "guest" TLB is always a superset of Hyper-V's fine * grained flushing. */ - kvm_hv_vcpu_purge_flush_tlb(vcpu); + kvm_hv_vcpu_purge_flush_tlb(vcpu, is_guest_mode(vcpu)); } =20 =20 --=20 2.49.0.395.g12beb8f557-goog