From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 ACD5775801; Mon, 4 May 2026 14:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777903467; cv=none; b=t4lQNeI7dwfRftKziLDEtd6mPLg+T0BBpmNq0mRY7sRQLPK4d6uY+9ZU2P8xoicTdoyk78fKuUXEiBPebeHBAIuq+8Lsani4Y1FJHw7vVOMnUcEAwmpylDP0HWVFFMFNvOC9m6vyNdr3xHp37v0v+z0LpapeGDimeN5X0+KNfWU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777903467; c=relaxed/simple; bh=rogAXt1bTs/8bPlCsp2jzk+EvHFV2QStPwdUsRXGPgI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GpbhYBFj2pj40MtiNEUWnWv2E5J7BoKBeL9j+Psr4lLBJUEs/yAlpjaALNTzj9sc6QE/cMH95IbPAc82TOlxLWnMtqR8Qz1uiJsFGhdwAVkmVod11a7I4jjsZrhaFas+fwCSptReHWgw19mlbf1hbEeuF/ibCuXLVVZqeKcQmfU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NMbuLRP1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="NMbuLRP1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42DDDC2BCB8; Mon, 4 May 2026 14:04:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777903467; bh=rogAXt1bTs/8bPlCsp2jzk+EvHFV2QStPwdUsRXGPgI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NMbuLRP17FK6lJR1Tmb24OlzU5k5ImU2rZmFPG0LDWFyjVvwuy/eHNrc2brlfe048 E8jGAFoeXyXk1phW0Cvsw+4BTITKJToK34zAQOXVzrzpV1/CkqXL0lTtiheUz/Na8x Nx9/oW0BqgvCYXGnE/ejVPSw33UadTXxIHmnmLG4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yosry Ahmed , Sean Christopherson Subject: [PATCH 7.0 212/307] KVM: nSVM: Avoid clearing VMCB_LBR in vmcb12 Date: Mon, 4 May 2026 15:51:37 +0200 Message-ID: <20260504135150.845970857@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504135142.814938198@linuxfoundation.org> References: <20260504135142.814938198@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yosry Ahmed commit b53ab5167a81537777ac780bbd93d32613aa3bda upstream. svm_copy_lbrs() always marks VMCB_LBR dirty in the destination VMCB. However, nested_svm_vmexit() uses it to copy LBRs to vmcb12, and clearing clean bits in vmcb12 is not architecturally defined. Move vmcb_mark_dirty() to callers and drop it for vmcb12. This also facilitates incoming refactoring that does not pass the entire VMCB to svm_copy_lbrs(). Fixes: d20c796ca370 ("KVM: x86: nSVM: implement nested LBR virtualization") Cc: stable@vger.kernel.org Signed-off-by: Yosry Ahmed Link: https://patch.msgid.link/20260303003421.2185681-2-yosry@kernel.org Signed-off-by: Sean Christopherson Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm/nested.c | 7 +++++-- arch/x86/kvm/svm/svm.c | 2 -- 2 files changed, 5 insertions(+), 4 deletions(-) --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -726,6 +726,7 @@ static void nested_vmcb02_prepare_save(s } else { svm_copy_lbrs(vmcb02, vmcb01); } + vmcb_mark_dirty(vmcb02, VMCB_LBR); svm_update_lbrv(&svm->vcpu); } @@ -1242,10 +1243,12 @@ int nested_svm_vmexit(struct vcpu_svm *s kvm_make_request(KVM_REQ_EVENT, &svm->vcpu); if (unlikely(guest_cpu_cap_has(vcpu, X86_FEATURE_LBRV) && - (svm->nested.ctl.virt_ext & LBR_CTL_ENABLE_MASK))) + (svm->nested.ctl.virt_ext & LBR_CTL_ENABLE_MASK))) { svm_copy_lbrs(vmcb12, vmcb02); - else + } else { svm_copy_lbrs(vmcb01, vmcb02); + vmcb_mark_dirty(vmcb01, VMCB_LBR); + } svm_update_lbrv(vcpu); --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -848,8 +848,6 @@ void svm_copy_lbrs(struct vmcb *to_vmcb, to_vmcb->save.br_to = from_vmcb->save.br_to; to_vmcb->save.last_excp_from = from_vmcb->save.last_excp_from; to_vmcb->save.last_excp_to = from_vmcb->save.last_excp_to; - - vmcb_mark_dirty(to_vmcb, VMCB_LBR); } static void __svm_enable_lbrv(struct kvm_vcpu *vcpu)