All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Zihui Guo" <youzih27@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 3/3] KVM: nVMX: Check the event injected into the HLT state on nested VM-Enter
Date: Thu, 03 Dec 2026 05:55:39 +0000	[thread overview]
Message-ID: <sashiko-outbox-247213@kernel.org> (raw)
In-Reply-To: <20261203053449.25917-4-youzih27@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] KVM: nVMX: nested_check_guest_non_reg_state() rejects stale
  entry intr info
--

commit 452383a9c0e3395f4748f51dbdcfd8ecc5c17e73
Author: Zihui Guo <youzih27@gmail.com>

KVM: nVMX: Check the event injected into the HLT state on nested VM-Enter

This commit adds a consistency check in nested_check_guest_non_reg_state()
to reject disallowed VM-entry event injections when vmcs12's guest activity
state is HLT.

> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index 82618f74d4ad2..2712648915a90 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c

[ ... ]

> @@ -3292,6 +3310,11 @@ static int nested_check_guest_non_reg_state(struct vmcs12 *vmcs12)
>  	       VMX_AR_DPL(vmcs12->guest_ss_ar_bytes) != 0))
>  		return -EINVAL;
>  
> +	if (CC(vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT &&
> +	       (vmcs12->vm_entry_intr_info_field & INTR_INFO_VALID_MASK) &&
> +	       !nested_hlt_event_allowed(vmcs12->vm_entry_intr_info_field)))
> +		return -EINVAL;

[Severity: High]
Can this reject stale vmcs12->vm_entry_intr_info_field during
KVM_SET_NESTED_STATE when vcpu->arch.nested_run_pending is 0?

If L1 enters an active L2 with CPU_BASED_HLT_EXITING clear and injects an
event disallowed in HLT (such as #PF), vmcs12->vm_entry_intr_info_field
keeps INTR_INFO_VALID_MASK set until prepare_vmcs12() runs on an L2-to-L1
exit.

When L2 later executes HLT, L0 handles it in guest mode with
nested_run_pending cleared.  vmx_get_nested_state() ->
sync_vmcs02_to_vmcs12() then sets guest_activity_state to
GUEST_ACTIVITY_HLT without clearing the stale entry interruption info.

On restore, vmx_set_nested_state() clears nested_run_pending and calls
nested_vmx_check_restored_vmcs12() -> nested_vmx_check_guest_state() ->
nested_check_guest_non_reg_state(), failing live migration with -EINVAL
even though prepare_vmcs02_early() ignores vm_entry_intr_info_field then.

Gating this check on vcpu->arch.nested_run_pending, as
nested_vmx_check_guest_state() does for VM_ENTRY_LOAD_IA32_EFER, avoids
rejecting stale state while still enforcing the check on nested VM-Enter.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203053449.25917-1-youzih27@gmail.com?part=3

  reply	other threads:[~2026-12-03  5:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  5:34 [PATCH 0/3] KVM: nVMX: Add missing guest-state checks on nested VM-Enter Zihui Guo
2026-12-03  5:34 ` [PATCH 1/3] KVM: nVMX: Check that the guest's IA32_S_CET is canonical on VM-Enter Zihui Guo
2026-12-03  5:54   ` sashiko-bot
2026-12-03  5:34 ` [PATCH 2/3] KVM: nVMX: Reject nested VM-Enter to HLT with a non-zero SS.DPL Zihui Guo
2026-12-03  5:34 ` [PATCH 3/3] KVM: nVMX: Check the event injected into the HLT state on nested VM-Enter Zihui Guo
2026-12-03  5:55   ` sashiko-bot [this message]
2026-12-03  6:05     ` Zihui Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-247213@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=youzih27@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.