From nobody Sun Feb 8 16:50:00 2026 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (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 2BCC42417C2 for ; Thu, 15 Jan 2026 01:13:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768439628; cv=none; b=bhvZYB2N5647FqhEUbdmHSVcvyuroerE4OCdlfVMRbDgud0syOlh2WL6YiLx1mTvD+HeJBgnpehk3R+OyiY4lmFWWPkfrYkcPbpzeAfd6b6PVjMnfTpKXqOR0wjiJzWJP7SLBEVr2pFm0e8lp4a2uzHshYtU+GCplT6XC8OPrdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768439628; c=relaxed/simple; bh=SvnJl/Qx7YbdnzpkzADENdnbM03g9c0nYE5AAk8vbss=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XmJucy3HQrVJu+aEKA/PeJ/jmKOpGZ8jIsj1BHChGwfTyjZ5SBxLdvlBKGVZnK4gNMo6ncxiecDRWc4FsXymazHYfvJ870MFgXrEz0lqpbBsZgszIRVrPUWpJqZlNfjOtUAePt0f+4YFr4gtSQIUzIs5WmNbkJaV1vQfQIHl1ps= 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=he2lkuv2; arc=none smtp.client-ip=91.218.175.172 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="he2lkuv2" 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=1768439620; 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=uWBKYRKqLR3Sf/6YuZ+mDu1Cr+lCy9BRdjKjJqfC+Js=; b=he2lkuv2PI2iBHlLj/ETD6DAB4YhoksK0vSlKS793awCQDgpDSHdTFYFVDAKSQ2kRv8qxi 2V5M7SzE/Zm0E6b1GUdcDeOyPd3HlLadoLpBk8Sso926MfwrHYURgRK5CMkIxSlkT+WAWa 4mkQ+cmUCP3pSnq2L6zMmkTqrLKJH+8= From: Yosry Ahmed To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed , stable@vger.kernel.org Subject: [PATCH v4 08/26] KVM: nSVM: Call enter_guest_mode() before switching to VMCB02 Date: Thu, 15 Jan 2026 01:12:54 +0000 Message-ID: <20260115011312.3675857-9-yosry.ahmed@linux.dev> In-Reply-To: <20260115011312.3675857-1-yosry.ahmed@linux.dev> References: <20260115011312.3675857-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" In preparation for moving more changes that rely on is_guest_mode() before switching to VMCB02, move entering guest mode a bit earlier. Nothing between the new callsite(s) and the old ones rely on is_guest_mode(), so this should be safe. No functional change intended. Cc: stable@vger.kernel.org Signed-off-by: Yosry Ahmed --- arch/x86/kvm/svm/nested.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 8515ff81508a..536ca8e1d29f 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -745,9 +745,6 @@ static void nested_vmcb02_prepare_control(struct vcpu_s= vm *svm, =20 nested_svm_transition_tlb_flush(vcpu); =20 - /* Enter Guest-Mode */ - enter_guest_mode(vcpu); - /* * Filled at exit: exit_code, exit_code_hi, exit_info_1, exit_info_2, * exit_int_info, exit_int_info_err, next_rip, insn_len, insn_bytes. @@ -948,6 +945,8 @@ int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmc= b12_gpa, =20 WARN_ON(svm->vmcb =3D=3D svm->nested.vmcb02.ptr); =20 + enter_guest_mode(vcpu); + nested_svm_copy_common_state(svm->vmcb01.ptr, svm->nested.vmcb02.ptr); =20 svm_switch_vmcb(svm, &svm->nested.vmcb02); @@ -1901,6 +1900,7 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu, svm_copy_vmrun_state(&svm->vmcb01.ptr->save, save); nested_copy_vmcb_control_to_cache(svm, ctl); =20 + enter_guest_mode(vcpu); svm_switch_vmcb(svm, &svm->nested.vmcb02); nested_vmcb02_prepare_control(svm, svm->vmcb->save.rip, svm->vmcb->save.c= s.base); =20 --=20 2.52.0.457.g6b5491de43-goog