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 8299C3DF018; Mon, 4 May 2026 14:24:11 +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=1777904651; cv=none; b=BDDcaRiU7ChikSq/d4L9uLFFUfg53HyFQnSpZFrzPkaHyHFi7q0ftIzzvjBtFQeuyGkaYyb8tPIKn/e6uhgKjVrpUYjO5yPgjrNkLFH+cuFEaHkzJ9+vDRQYvEjLEtJV1Apq/1GyB8Hs5rf0Z45GKcY9m4FKwn0Qgpz6MxqP2jg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777904651; c=relaxed/simple; bh=CDD6dufcVVjEU+yY9B4RvZjxmFO3S08vJfcDDp9IsQ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ePQJ66Ahp8rlio4c8H3oEDT5zmAxUT43dbX8AXrq49tEg/MM8i1thMFnVfR4hi51kO2V7dCwnlM/ADHD/cJdLkcPbMwiOnz5gMQQBgpyAsoaKKuu3gUDO2J/43w2n/J50MB3lBQDQDTEhu48Zrbql8xgpMZn1Gjqx5QPh2QGL/w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2KE2GDcV; 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="2KE2GDcV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19919C2BCF5; Mon, 4 May 2026 14:24:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777904651; bh=CDD6dufcVVjEU+yY9B4RvZjxmFO3S08vJfcDDp9IsQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2KE2GDcVrwcsXev3WKmY4BrJLs9mWS6luNKYfzXr8XbPR5B19aoUkbMUxef0KotaT pZDOV6Nemvw0xE5jLpJnq9dMTVHmuM4sWTYZKtwkMLtL0di9Vp7G5OcfiEcz66AhZh Mx7lhyXLyxxX7QfdNTyKqqKck2Is5lFtaHc+kEbc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yosry Ahmed , Sean Christopherson Subject: [PATCH 6.12 121/215] KVM: nSVM: Sync interrupt shadow to cached vmcb12 after VMRUN of L2 Date: Mon, 4 May 2026 15:52:20 +0200 Message-ID: <20260504135134.573280492@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504135130.169210693@linuxfoundation.org> References: <20260504135130.169210693@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 03bee264f8ebfd39e0254c98e112d033a7aa9055 upstream. After VMRUN in guest mode, nested_sync_control_from_vmcb02() syncs fields written by the CPU from vmcb02 to the cached vmcb12. This is because the cached vmcb12 is used as the authoritative copy of some of the controls, and is the payload when saving/restoring nested state. int_state is also written by the CPU, specifically bit 0 (i.e. SVM_INTERRUPT_SHADOW_MASK) for nested VMs, but it is not sync'd to cached vmcb12. This does not cause a problem if KVM_SET_NESTED_STATE preceeds KVM_SET_VCPU_EVENTS in the restore path, as an interrupt shadow would be correctly restored to vmcb02 (KVM_SET_VCPU_EVENTS overwrites what KVM_SET_NESTED_STATE restored in int_state). However, if KVM_SET_VCPU_EVENTS preceeds KVM_SET_NESTED_STATE, an interrupt shadow would be restored into vmcb01 instead of vmcb02. This would mostly be benign for L1 (delays an interrupt), but not for L2. For L2, the vCPU could hang (e.g. if a wakeup interrupt is delivered before a HLT that should have been in an interrupt shadow). Sync int_state to the cached vmcb12 in nested_sync_control_from_vmcb02() to avoid this problem. With that, KVM_SET_NESTED_STATE restores the correct interrupt shadow state, and if KVM_SET_VCPU_EVENTS follows it would overwrite it with the same value. 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/20260225005950.3739782-3-yosry@kernel.org Signed-off-by: Sean Christopherson Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm/nested.c | 1 + 1 file changed, 1 insertion(+) --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -420,6 +420,7 @@ void nested_sync_control_from_vmcb02(str u32 mask; svm->nested.ctl.event_inj = svm->vmcb->control.event_inj; svm->nested.ctl.event_inj_err = svm->vmcb->control.event_inj_err; + svm->nested.ctl.int_state = svm->vmcb->control.int_state; /* Only a few fields of int_ctl are written by the processor. */ mask = V_IRQ_MASK | V_TPR_MASK;