From nobody Mon Feb 9 04:40:30 2026 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 E1BE323BD1F for ; Sat, 8 Nov 2025 00:45:53 +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=1762562757; cv=none; b=qM9WQjIBXWAtPiXMmqUD99DupqW5lugx8DAHAEbD/qWs6S1GXOdXqL6sFXkeQtt2b+O+oJaNRlcf6ojrQ8uJEZOpiBA+udTBfYiIHfYCLA+ngxTpjHeSTHhaIeTRgkkJay9fORONbeUzYSUf6XUM1ADOcW6F/bntbMNhOl8qXmg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762562757; c=relaxed/simple; bh=x85JRd3eoh4Fmbm0hw42uUNA1ySyfDcR++08WBtPvAY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YBAc+xdW3QmhVjOR3RY+NR7l4I0lY+vuLlmLQWrrxowKrGkqN6nWhHwdHQSTUi96x0MLHNgHUHg5xdxxQT1kM1dmLV2QOvlHxB/dO75QRD16QDuCGPg4eCpcI9PXD9JNbfdGrOgSbRqHjd25kS4cc1PNi3WhIGrQNzRO1dsmf0A= 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=uMS1n4ZF; 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="uMS1n4ZF" 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=1762562751; 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=dqxsukY6YvoTOTLjaVVpP8tsHHl1y/4M81vp3qGNAj8=; b=uMS1n4ZFUiK46BRYuOJuLrtZiJU2mpDTu4SgcqddDGtQc2V31e7+h9DIQ0WDcvT0Bweihi ftPnMmy3y1Dz8w5KNmkhH3VqKPZabohnTCjKFppzy3L4qLTixb9P88szrfwvr5Xi5WcHes BqGCFbKe9Jd9/Bx6ub79Dq/o5oyCSAw= From: Yosry Ahmed To: Sean Christopherson Cc: Paolo Bonzini , Jim Mattson , Maxim Levitsky , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed , Matteo Rizzo , evn@google.com Subject: [PATCH 1/6] KVM: SVM: Mark VMCB_LBR dirty when MSR_IA32_DEBUGCTLMSR is updated Date: Sat, 8 Nov 2025 00:45:19 +0000 Message-ID: <20251108004524.1600006-2-yosry.ahmed@linux.dev> In-Reply-To: <20251108004524.1600006-1-yosry.ahmed@linux.dev> References: <20251108004524.1600006-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" Clear the VMCB_LBR clean bit when MSR_IA32_DEBUGCTLMSR is updated, as the only valid bit is DEBUGCTLMSR_LBR. The history is complicated, it was correctly cleared for L1 before commit 1d5a1b5860ed ("KVM: x86: nSVM: correctly virtualize LBR msrs when L2 is running"), then the latter relied on svm_update_lbrv() to clear it, but it only did so for L2. 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 --- 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 55bd7aa5cd743..d25c56b30b4e2 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3009,7 +3009,11 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct= msr_data *msr) if (data & DEBUGCTL_RESERVED_BITS) return 1; =20 + if (svm_get_lbr_vmcb(svm)->save.dbgctl =3D=3D data) + break; + svm_get_lbr_vmcb(svm)->save.dbgctl =3D data; + vmcb_mark_dirty(svm->vmcb, VMCB_LBR); svm_update_lbrv(vcpu); break; case MSR_VM_HSAVE_PA: --=20 2.51.2.1041.gc1ab5b90ca-goog