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 DF0153B0ADB; Fri, 15 May 2026 16:00:33 +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=1778860833; cv=none; b=cgEellvXl3TQPEPn7xNPZFPAZEqea95dkc7RzBS9qUGNWQPytU5dLky9mZGH2lWLRqI5hfAMJ3ryu1e1jPJVGM3wrmMavb2VlqbqhJ87XODhvm4Ia7umdwiPp7ohv3cOed9OsKSXoAjZmSE/ZBDfcrtVwHHW6fvXzlBxSd7GB2I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778860833; c=relaxed/simple; bh=XJguncabssY45WQr0FkJseUoCzPw3UULhX1jkVjjoXs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EYNRk7cAiVTqcELRVYn2zMD6nPGuHNtGejzlS2cBelp9u01/6pwYwjrIVcfhReyiweqr7ON0zDmWEuarea4ssiZ1czIsYvLRRk0xzb1wtY47EjQ3BS0PPO4EjWgYvWyHjiteZ7UWG57+YgE+hHeEIGJQVWfCul1Wo8GWytM3O60= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vzYO7lZQ; 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="vzYO7lZQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32952C2BCB0; Fri, 15 May 2026 16:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778860833; bh=XJguncabssY45WQr0FkJseUoCzPw3UULhX1jkVjjoXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vzYO7lZQfBArEibr7qZfnZWRIjhqICrdEpOkChVkh1P2MMQwX9K8GVYpbtyExPaza b2v0AKDZap9czsA7uPo2oK8szaHtxLtjjbQeWh7EJar9twYIV7pYeXdFVyAd6SxG9N S0FqHqPeg144O47cDOCWLNLs/UTt0KwkdDUjuisw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yosry Ahmed , Sean Christopherson Subject: [PATCH 6.6 095/474] KVM: nSVM: Mark all of vmcb02 dirty when restoring nested state Date: Fri, 15 May 2026 17:43:24 +0200 Message-ID: <20260515154717.095472381@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260515154715.053014143@linuxfoundation.org> References: <20260515154715.053014143@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yosry Ahmed commit e63fb1379f4b9300a44739964e69549bebbcdca4 upstream. When restoring a vCPU in guest mode, any state restored before KVM_SET_NESTED_STATE (e.g. KVM_SET_SREGS) will mark the corresponding dirty bits in vmcb01, as it is the active VMCB before switching to vmcb02 in svm_set_nested_state(). Hence, mark all fields in vmcb02 dirty in svm_set_nested_state() to capture any previously restored fields. Fixes: cc440cdad5b7 ("KVM: nSVM: implement KVM_GET_NESTED_STATE and KVM_SET_NESTED_STATE") CC: stable@vger.kernel.org Signed-off-by: Yosry Ahmed Link: https://patch.msgid.link/20260210010806.3204289-1-yosry.ahmed@linux.dev Signed-off-by: Sean Christopherson Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm/nested.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -1753,6 +1753,12 @@ static int svm_set_nested_state(struct k nested_vmcb02_prepare_control(svm, svm->vmcb->save.rip, svm->vmcb->save.cs.base); /* + * Any previously restored state (e.g. KVM_SET_SREGS) would mark fields + * dirty in vmcb01 instead of vmcb02, so mark all of vmcb02 dirty here. + */ + vmcb_mark_all_dirty(svm->vmcb); + + /* * While the nested guest CR3 is already checked and set by * KVM_SET_SREGS, it was set when nested state was yet loaded, * thus MMU might not be initialized correctly.