mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Amirmohammad Eftekhar <amirmohammad.eftekhar@cispa.de>
To: <seanjc@google.com>, <pbonzini@redhat.com>
Cc: <kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<amirmohammad.eftekhar@cispa.de>
Subject: Re: [PATCH] KVM: nVMX: Restore L2's DEBUGCTL/BNDCFGS/CET from vmcs12 on RSM and nested state restore
Date: Fri, 23 Oct 2026 11:03:13 +0200	[thread overview]
Message-ID: <20261023090313.9524-1-amirmohammad.eftekhar@cispa.de> (raw)
In-Reply-To: <20261022223820.8279-1-amirmohammad.eftekhar@cispa.de>

The automated Sashiko review of this patch is right, please drop it.

I missed that the pre_vmenter_* snapshot is taken from the loaded VMCS on
purpose. The comment on struct nested_vmx says as much: on
KVM_SET_NESTED_STATE the snapshot ends up holding L2's value because
userspace restores the MSRs into vmcs01 before it restores nested state.
Reading from vmcs12 on that path discards those restored values, so the
patch breaks restore rather than helping it. My changelog had this
backwards.

The other points hold up too:

  - On RSM and on restore nested_run_pending is 0, so prepare_vmcs02()
    hands pre_vmenter_debugctl to vmx_guest_debugctl_write() unmasked.
    vmcs12->guest_ia32_debugctl is not validated when
    VM_ENTRY_LOAD_DEBUG_CONTROLS is clear, so with VMWRITE + SMI + RSM a
    guest can trip WARN_ON_ONCE(val & VMX_HOST_OWNED_DEBUGCTL_BITS) and
    get host-owned bits written into vmcs02.

  - vmcs12->guest_ia32_debugctl and guest_bndcfgs are not reliably L2's
    live values anyway. sync_vmcs02_to_vmcs12() deliberately does not
    save them, and vmx_set_msr() only updates them under the matching
    save/load controls, so sourcing them from vmcs12 can regress the
    plain inherit case.

The only gap I still see is narrower: on RSM into L2 with
VM_ENTRY_LOAD_CET_STATE clear, the CET snapshot comes from vmcs01 (L1's
state) while L2's pre-SMI CET was saved into vmcs12. That looks like the
SMI+RSM corruption the TODO near vmx_enter_smm() already flags, and if it
is worth fixing it needs a validated, RSM-only change, not this blanket
one.

Thanks,
Amirmohammad

      reply	other threads:[~2026-10-23  9:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 22:38 Amirmohammad Eftekhar
2026-10-23  9:03 ` Amirmohammad Eftekhar [this message]

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=20261023090313.9524-1-amirmohammad.eftekhar@cispa.de \
    --to=amirmohammad.eftekhar@cispa.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®