public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Wei Wang <wei.w.wang@intel.com>
Cc: pbonzini@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v2 4/5] KVM: x86: Remove KVM_X86_OP_OPTIONAL
Date: Fri, 19 Apr 2024 06:41:46 -0700	[thread overview]
Message-ID: <ZiJ0mjZxlRsLwl3E@google.com> (raw)
In-Reply-To: <20240419112952.15598-5-wei.w.wang@intel.com>

On Fri, Apr 19, 2024, Wei Wang wrote:
> KVM_X86_OP and KVM_X86_OP_OPTIONAL were utilized to define and execute
> static_call_update() calls on mandatory and optional hooks, respectively.
> Mandatory hooks were invoked via static_call() and necessitated definition
> due to the presumption that an undefined hook (i.e., NULL) would cause
> static_call() to fail. This assumption no longer holds true as
> static_call() has been updated to treat a "NULL" hook as a NOP on x86.
> Consequently, the so-called mandatory hooks are no longer required to be
> defined, rendering them non-mandatory. 

This is wrong.  They absolutely are mandatory.  The fact that static_call() doesn't
blow up doesn't make them optional.  If a vendor neglects to implement a mandatory
hook, KVM *will* break, just not immediately on the static_call().

The static_call() behavior is actually unfortunate, as KVM at least would prefer
that it does explode on a NULL point.  I.e. better to crash the kernel (hopefully
before getting to production) then to have a lurking bug just waiting to cause
problems.

> This eliminates the need to differentiate between mandatory and optional
> hooks, allowing a single KVM_X86_OP to suffice.
> 
> So KVM_X86_OP_OPTIONAL and the WARN_ON() associated with KVM_X86_OP are
> removed to simplify usage, 

Just in case it isn't clear, I am very strongly opposed to removing KVM_X86_OP_OPTIONAL()
and the WARN_ON() protection to ensure mandatory ops are implemented.

  reply	other threads:[~2024-04-19 13:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19 11:29 [PATCH v2 0/5] KVM/x86: Enhancements to static calls Wei Wang
2024-04-19 11:29 ` [PATCH v2 1/5] KVM: x86: Replace static_call_cond() with static_call() Wei Wang
2024-04-19 11:29 ` [PATCH v2 2/5] KVM: x86: Introduce KVM_X86_CALL() to simplify static calls of kvm_x86_ops Wei Wang
2024-04-22 10:34   ` Paolo Bonzini
2024-04-22 16:43     ` Sean Christopherson
2024-04-19 11:29 ` [PATCH v2 3/5] KVM: x86/pmu: Add KVM_PMU_CALL() to simplify static calls of kvm_pmu_ops Wei Wang
2024-04-19 11:29 ` [RFC PATCH v2 4/5] KVM: x86: Remove KVM_X86_OP_OPTIONAL Wei Wang
2024-04-19 13:41   ` Sean Christopherson [this message]
2024-04-19 15:12     ` Wang, Wei W
2024-04-19 15:58       ` Sean Christopherson
2024-04-20  3:01         ` Wang, Wei W
2024-04-19 11:29 ` [RFC PATCH v2 5/5] KVM: x86/pmu: Remove KVM_X86_PMU_OP_OPTIONAL Wei Wang

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=ZiJ0mjZxlRsLwl3E@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=wei.w.wang@intel.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