From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-170.mta0.migadu.com (out-170.mta0.migadu.com [91.218.175.170]) (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 753192E11C5 for ; Thu, 20 Nov 2025 23:39:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763681999; cv=none; b=MkclcG4Zl0Nl/nyU14LDA8bTE7Di2RtbprmmUgs4ojPH4vWerdHy0lozFzsrsPUUgRQyxolS7zQceH0Q0BsmEAn/HuN3MqxPishMOB8LOi1YtF8vqUVElNAMxZpWvjOCsm45H9+Hn8uZ2UJCHUhO3QF9ePFG/z7QyXpJFxyhv/4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763681999; c=relaxed/simple; bh=HJ7/Ec1YAb+gxDf4HRX4G5ohTiCKFjHOMiGTreO9Goc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m+imZk9cafJb0kziuMZeHdOtQfoTwt1KY5XTaAdTE8p5rjZX0qV3UbDzi6V2Nn5RUch7/3oPQUk+JDOkjRTT7aOPLCLgdIsWQVM0NZDNxN9rr1pX8no24DQY0ehNeQ1ehKCrtHKTjJFtWAfV3Z1/x8FHUrNActDNp8cXvDyHoyI= 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=B3j/cJ7F; arc=none smtp.client-ip=91.218.175.170 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="B3j/cJ7F" 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=1763681995; 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=Hg7trAiU+tw1VoJlQQPfAPZBU/1D0vg0hX9/o+Tg4e0=; b=B3j/cJ7FlUfPdV8BvC5h/fLxJSKXjlF2D9TvVcwxSHK5CU5HX48P9kk7bB5r1j2b9MsxlZ pJ26HG0SUGQeJuwrr3htMApx8Er5UK7T8oSAflgZY5CUVVuG2rIYUeGBpwC7dDV5u9hzHT YfbfkrqLN25AuNJ5JIh0Va835gU1920= From: Yosry Ahmed To: stable@vger.kernel.org Cc: Yosry Ahmed , Matteo Rizzo , evn@google.com, Jim Mattson , Paolo Bonzini Subject: [PATCH 6.12.y 2/5] KVM: SVM: Mark VMCB_LBR dirty when MSR_IA32_DEBUGCTLMSR is updated Date: Thu, 20 Nov 2025 23:39:33 +0000 Message-ID: <20251120233936.2407119-3-yosry.ahmed@linux.dev> In-Reply-To: <20251120233936.2407119-1-yosry.ahmed@linux.dev> References: <2025112046-confider-smelting-6296@gregkh> <20251120233936.2407119-1-yosry.ahmed@linux.dev> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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 (cherry picked from commit dc55b3c3f61246e483e50c85d8d5366f9567e188) --- arch/x86/kvm/svm/svm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 6deccc1b1669..1e1210e5ef45 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3267,7 +3267,11 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr) 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: -- 2.52.0.rc2.455.g230fcf2819-goog