From nobody Fri Dec 19 12:28:39 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 E492B2EA480 for ; Tue, 4 Nov 2025 20:00:22 +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=1762286424; cv=none; b=l/+bvFyJbc7VMqXCfj5LE8ua7LRo68WyEMEc+ODclL6pOLnm1MH+OhRjlCgDV/Gvr1kX40z96U0j2Beh3XTO9v++LuzFtMge7y7U2Osp9/JWWyKlliNecp4CTS9qUdJ93f5+0GdO1wg4Jn4RCQIvfx0pBOqxcSypFwr5poYDce8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762286424; c=relaxed/simple; bh=F2d4zJWmJQn8eRgN2rp7OuKccAIw/xuB2G4WdPyfXgo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ucvub+0YVK6mxHnobtCgrYaM9lMw2VuWieXOC1qyaL4NnuqKzMJ2poIPMz0ieuJd1ULTW03ezITgBm5q8B9FGdHMULK1fo56MRlBrGEyR70J0oXF5pC45yd+H1uybpbVLuzQhSDQM6CasdSPVQAdvZzKUJLm+WrDKo+189WOZmY= 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=vMEpTT2g; 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="vMEpTT2g" 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=1762286421; 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=xsWbejesb8AWWtsjpUDkTupID+opAoj51F+TZvPbnTY=; b=vMEpTT2g6mT0u59REaoXaRoGvwDuMJ2nTfuJtZqBVNy63xkwGajHS2zcv/oQNCqupOgJxL gnZV15uxU6DgeZ72NC13XQ/QHxYIIti6iq0UxhwZRYqOIE6N7hZI61vj7upCLd3Gzy4ISG kTbfbyiXFZwv0RpQ7/ZuRYYqU4xEDQw= From: Yosry Ahmed To: Sean Christopherson Cc: Paolo Bonzini , Jim Mattson , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed Subject: [PATCH 09/11] KVM: nSVM: Simplify nested_svm_vmrun() Date: Tue, 4 Nov 2025 19:59:47 +0000 Message-ID: <20251104195949.3528411-10-yosry.ahmed@linux.dev> In-Reply-To: <20251104195949.3528411-1-yosry.ahmed@linux.dev> References: <20251104195949.3528411-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" Call nested_svm_merge_msrpm() from enter_svm_guest_mode() if called from the VMRUN path, instead of making the call in nested_svm_vmrun(). This simplifies the flow of nested_svm_vmrun() and removes all jumps to cleanup labels. Signed-off-by: Yosry Ahmed --- arch/x86/kvm/svm/nested.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 8d5165df52f57..3c0d8990ecd11 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -1009,6 +1009,9 @@ int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 v= mcb12_gpa, bool from_vmrun) =20 nested_svm_hv_update_vm_vp_ids(vcpu); =20 + if (from_vmrun && !nested_svm_merge_msrpm(vcpu)) + return -1; + return 0; } =20 @@ -1094,23 +1097,18 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu) =20 svm->nested.nested_run_pending =3D 1; =20 - if (enter_svm_guest_mode(vcpu, vmcb12_gpa, true)) - goto out_exit_err; - - if (nested_svm_merge_msrpm(vcpu)) - return ret; - -out_exit_err: - svm->nested.nested_run_pending =3D 0; - svm->nmi_l1_to_l2 =3D false; - svm->soft_int_injected =3D false; + if (enter_svm_guest_mode(vcpu, vmcb12_gpa, true)) { + svm->nested.nested_run_pending =3D 0; + svm->nmi_l1_to_l2 =3D false; + svm->soft_int_injected =3D false; =20 - svm->vmcb->control.exit_code =3D SVM_EXIT_ERR; - svm->vmcb->control.exit_code_hi =3D 0; - svm->vmcb->control.exit_info_1 =3D 0; - svm->vmcb->control.exit_info_2 =3D 0; + svm->vmcb->control.exit_code =3D SVM_EXIT_ERR; + svm->vmcb->control.exit_code_hi =3D 0; + svm->vmcb->control.exit_info_1 =3D 0; + svm->vmcb->control.exit_info_2 =3D 0; =20 - nested_svm_vmexit(svm); + nested_svm_vmexit(svm); + } return ret; } =20 --=20 2.51.2.1026.g39e6a42477-goog