From: Sean Christopherson <seanjc@google.com>
To: Naveen N Rao <naveen@kernel.org>
Cc: Jean-Christophe Guillain <jean-christophe@guillain.net>,
kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Nikunj A Dadhania <nikunj@amd.com>
Subject: Re: BUILD_BUG_ON failed for kvm_vmx struct size sanity check in vmx.c
Date: Wed, 2 Sep 2026 09:15:47 -0700 [thread overview]
Message-ID: <aphLs9F70ojtzh-3@google.com> (raw)
In-Reply-To: <apgj5l7DZGsScsNc@blrnaveerao1>
On Wed, Sep 02, 2026, Naveen N Rao wrote:
> On Mon, Aug 31, 2026 at 05:52:48PM -0700, Sean Christopherson wrote:
> > On Fri, Aug 28, 2026, Sean Christopherson wrote:
> > > On Thu, Aug 27, 2026, Jean-Christophe Guillain wrote:
> >
> > So, rather than trying to come up with a scheme that is performant without being
> > too complex, I'm planning on fixing this by simply holding kvm->lock for the entire
> > duration of vCPU creation, so that KVM doesn't need to do extra tracking and can
> > instead rely purely on the array of online vCPUs. Then we can revert 97d65b544f48
> > and do more cleanups on top.
>
> I was going to report the below lockdep splat I am seeing when trying to
> enable Secure TSC due to commit ba903f738249 ("KVM: SEV: Assert that
> kvm->lock is held when querying SEV+ support"). I believe this will also
> be addressed if we continue to hold kvm->lock during vCPU creation:
>
> WARNING: arch/x86/kvm/svm/sev.c:136 at sev_snp_guest+0xb2/0xc0 [kvm_amd], CPU#170: CPU 0/KVM/5532
> ...
> Call Trace:
> <TASK>
> snp_is_secure_tsc_enabled+0x1a/0x40 [kvm_amd]
> sev_vcpu_create+0x77/0xc0 [kvm_amd]
> svm_vcpu_create+0x5f/0x160 [kvm_amd]
> kvm_arch_vcpu_create+0x234/0x2f0 [kvm]
> kvm_vm_ioctl+0x232/0x1c10 [kvm]
> ? __lock_acquire+0x465/0x1b10
> ? lock_acquire+0xbf/0x2f0
> ? __fget_files+0x2b/0x190
> ? find_held_lock+0x2b/0x80
> __x64_sys_ioctl+0x97/0xe0
> do_syscall_64+0xf3/0x880
> ? exc_page_fault+0x128/0x270
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
Oh, right! I forget about the wrinkles with kvm->lock not being held during
vCPU creation. This is largely fudged around by the kvm_get_running_vcpu() check
since VMCB initialization is done with the vCPU loaded (i.e. "running").
prev parent reply other threads:[~2026-09-02 16:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 8:52 BUILD_BUG_ON failed for kvm_vmx struct size sanity check in vmx.c Jean-Christophe Guillain
2026-08-28 23:55 ` Sean Christopherson
2026-09-01 0:52 ` Sean Christopherson
2026-09-02 8:09 ` Paolo Bonzini
2026-09-02 13:43 ` Naveen N Rao
2026-09-02 16:15 ` Sean Christopherson [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=aphLs9F70ojtzh-3@google.com \
--to=seanjc@google.com \
--cc=jean-christophe@guillain.net \
--cc=kvm@vger.kernel.org \
--cc=naveen@kernel.org \
--cc=nikunj@amd.com \
--cc=pbonzini@redhat.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