From nobody Sat Feb 7 18:15:43 2026 Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [91.218.175.174]) (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 0825842885A for ; Fri, 6 Feb 2026 19:09:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770404965; cv=none; b=TSKF33rSh+xNZalWb4vjZbPblUQzEeih5pxgK8jpEkl0hGY7cOmYnh+6BZMtxqgOHsehVYvArZU8yY0wbr4H7vhtfRG1x0aN3TpqyvwV5Hny5ANoAJgkpOUf+DyVLgKd25mcLrv4R82jYuwW4IL6vbrf0AlZ2H5ZKLrNkIcVaJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770404965; c=relaxed/simple; bh=aFbbE1mXIIfwFOvI+A1BZSivVcixs1P5aMa3QZelj1Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QFqhNBq1wG711/osSh5snTf6LNVM6ZUNqKxH0sABwwczVs8/ZQ4JgIcDwjvzpb7IqnmzB85pCHxk31K1EkoHoexbs1Lmc6eTbnRu4JxaXmWUJ6y6MdiI91m63w0WuafrGeoQsxURPFakz+laaNwtXVHnr+iOIcRovFc2dkdQOe8= 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=a4gul3kQ; arc=none smtp.client-ip=91.218.175.174 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="a4gul3kQ" 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=1770404963; 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=2eFD0yh8gByHsKvBqdBWwO0lKqyxFdc3ADbFbDOMW+c=; b=a4gul3kQEYygRMo6Z2mkbFDspLs3RN7nVa5IMWp7D/upcAodgiyc8wGyCAQNLzc4X5IFrW wlAijZpez8mo1FcPRVr2VhZTm08ICjLi1DNRUgLs5heabWWc9Ra7yKU0purgX8nTbScGVa jMPf3zKHFSXrkkw6bV7ZgOrNMUiZLHg= 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 v5 09/26] KVM: nSVM: Call enter_guest_mode() before switching to VMCB02 Date: Fri, 6 Feb 2026 19:08:34 +0000 Message-ID: <20260206190851.860662-10-yosry.ahmed@linux.dev> In-Reply-To: <20260206190851.860662-1-yosry.ahmed@linux.dev> References: <20260206190851.860662-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 29069fc5e8cb..607d99172e2b 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -741,9 +741,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_info_1, exit_info_2, exit_int_info, * exit_int_info_err, next_rip, insn_len, insn_bytes. @@ -944,6 +941,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); @@ -1890,6 +1889,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.53.0.rc2.204.g2597b5adb4-goog