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 8A8582745E; Fri, 21 Nov 2025 13:31:09 +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=1763731869; cv=none; b=h7tufv3ZcorvLTDqJzm0GYe31dAdvuwtE4c6nOBdhcGST83C7we7RlN9+qjNE6HNI2y0nVL/BKiZs1ShtCdtBUuFWFOuMwdTsCgW36a2VFEYqld0oNe4coRX3ljvDGlL43ji6R7nQ0jlZZ9l55xtKP/Cp7brNWlh60/8eZYOm28= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763731869; c=relaxed/simple; bh=26p0WgcmrHDeufg6/AM3pNe8iKdMrU6bSZ2Xwxoi7hY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gXsjdKOa8FY53to6icioQPLgpeuNbjNJIaqU8efkiXQlb2OU2ySL2KqBombFZgKuMI5jjsK/0lsHoJ5FOGNvvvrlz/FzHC57feqI1DhyTUKmsV15/Uw/OGLZtLOXE3A2LG55h7SlDzqwo9pCHeWueHT3TVhBUf9ArL/GKAPbGQo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=a7T+4Hf+; 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="a7T+4Hf+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12535C4CEF1; Fri, 21 Nov 2025 13:31:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1763731869; bh=26p0WgcmrHDeufg6/AM3pNe8iKdMrU6bSZ2Xwxoi7hY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a7T+4Hf+1wKgB+i5ynlNKytUln6yMIPfi+dGUUhV3yLNJ5S/ygqo5jVeincI3Uk4f ZeG7jdS3jZK9VKCwbrOlMQHU66W1IvplqaUKebLP0cHuFByYE06mImcGEs6VV1MMZV psg/dAnC63nLH3aYwfZM0eNqASsVsKIuzrWm5+OQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Matteo Rizzo , evn@google.com, Jim Mattson , Yosry Ahmed , Paolo Bonzini Subject: [PATCH 6.12 109/185] KVM: SVM: Mark VMCB_LBR dirty when MSR_IA32_DEBUGCTLMSR is updated Date: Fri, 21 Nov 2025 14:12:16 +0100 Message-ID: <20251121130147.807480816@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251121130143.857798067@linuxfoundation.org> References: <20251121130143.857798067@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yosry Ahmed commit dc55b3c3f61246e483e50c85d8d5366f9567e188 upstream. The APM lists the DbgCtlMsr field as being tracked by the VMCB_LBR clean bit. Always clear the bit when MSR_IA32_DEBUGCTLMSR is updated. The history is complicated, it was correctly cleared for L1 before commit 1d5a1b5860ed ("KVM: x86: nSVM: correctly virtualize LBR msrs when L2 is running"). At that point svm_set_msr() started to rely on svm_update_lbrv() to clear the bit, but when nested virtualization is enabled the latter does not always clear it even if MSR_IA32_DEBUGCTLMSR changed. Go back to clearing it directly in svm_set_msr(). Fixes: 1d5a1b5860ed ("KVM: x86: nSVM: correctly virtualize LBR msrs when L2 is running") Reported-by: Matteo Rizzo Reported-by: evn@google.com Co-developed-by: Jim Mattson Signed-off-by: Jim Mattson Signed-off-by: Yosry Ahmed Link: https://patch.msgid.link/20251108004524.1600006-2-yosry.ahmed@linux.dev Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm/svm.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3257,7 +3257,11 @@ static int svm_set_msr(struct kvm_vcpu * if (data & DEBUGCTL_RESERVED_BITS) return 1; + if (svm_get_lbr_vmcb(svm)->save.dbgctl == data) + break; + svm_get_lbr_vmcb(svm)->save.dbgctl = data; + vmcb_mark_dirty(svm->vmcb, VMCB_LBR); svm_update_lbrv(vcpu); break; case MSR_VM_HSAVE_PA: