From: Sean Christopherson <seanjc@google.com>
To: Kai Huang <kai.huang@intel.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"vipinsh@google.com" <vipinsh@google.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 2/3] KVM: x86: Use kvzalloc() to allocate VM struct
Date: Thu, 22 May 2025 06:40:25 -0700 [thread overview]
Message-ID: <aC8pSfEBdHZW9Ze7@google.com> (raw)
In-Reply-To: <918715044bf0aa6fb51ce511667bf7bb4ccbabea.camel@intel.com>
On Wed, May 21, 2025, Kai Huang wrote:
> On Wed, 2025-05-21 at 10:12 -0700, Sean Christopherson wrote:
> > > e.g., if we export kvm_x86_ops, we could unwind them.
> >
> > Maaaybe. I mean, yes, we could fully unwind kvm_x86_ops, but doing so would make
> > the overall code far more brittle. E.g. simply updating kvm_x86_ops won't suffice,
> > as the static_calls also need to be patched, and we would have to be very careful
> > not to touch anything in kvm_x86_ops that might have been consumed between here
> > and the call to tdx_bringup().
>
> Right. Maybe exporting kvm_ops_update() is better.
A bit, but KVM would still need to be careful not to modify the parts of
vt_x86_ops that have already been consumed.
While I agree that leaving TDX breadcrumbs in kvm_x86_ops when TDX is disabled is
undesirable, the behavior is known, i.e. we know exactly what TDX state is being
left behind. And failure to load the TDX Module should be very, very rare for
any setup that is actually trying to enable TDX.
Whereas providing a way to modify kvm_x86_ops creates the possibility for "bad"
updates. KVM's initialization code is a lot like the kernel's boot code (and
probably most bootstrapping code): it's inherently fragile because avoiding
dependencies is practically impossible.
E.g. I ran into a relevant ordering problem[*] just a few days ago, where checking
for VMX capabilities during PMU initialization always failed because the VMCS
config hadn't yet been parsed. Those types of bugs are especially dangerous
because they're very easy to overlook when modifying existing code, e.g. the
only sign that anything is broken is an optional feature being missing.
[*] https://lore.kernel.org/all/aCU2YEpU0dOk7RTk@google.com
next prev parent reply other threads:[~2025-05-22 13:40 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-16 21:54 [PATCH v3 0/3] KVM: x86: Dynamically allocate hashed page list Sean Christopherson
2025-05-16 21:54 ` [PATCH v3 1/3] KVM: x86/mmu: Dynamically allocate shadow MMU's " Sean Christopherson
2025-05-16 21:54 ` [PATCH v3 2/3] KVM: x86: Use kvzalloc() to allocate VM struct Sean Christopherson
2025-05-17 12:35 ` Paolo Bonzini
2025-05-19 15:39 ` Sean Christopherson
2025-05-20 14:42 ` Paolo Bonzini
2025-05-20 22:49 ` Huang, Kai
2025-05-20 23:11 ` Sean Christopherson
2025-05-20 23:57 ` Huang, Kai
2025-05-21 17:12 ` Sean Christopherson
2025-05-21 22:43 ` Huang, Kai
2025-05-22 13:40 ` Sean Christopherson [this message]
2025-05-23 11:31 ` Huang, Kai
2025-05-20 16:15 ` Sean Christopherson
2025-05-16 21:54 ` [PATCH v3 3/3] KVM: x86/mmu: Defer allocation of shadow MMU's hashed page list Sean Christopherson
2025-05-17 12:43 ` Paolo Bonzini
2025-05-19 13:37 ` Sean Christopherson
2025-05-19 15:29 ` James Houghton
2025-05-19 15:51 ` Sean Christopherson
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=aC8pSfEBdHZW9Ze7@google.com \
--to=seanjc@google.com \
--cc=kai.huang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=vipinsh@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;
as well as URLs for NNTP newsgroup(s).