public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH v2 3/5] KVM: x86: warn on incorrectly NULL static calls
Date: Tue, 15 Feb 2022 17:10:41 +0000	[thread overview]
Message-ID: <YgvekYk2QEIzOc+T@google.com> (raw)
In-Reply-To: <20220214131614.3050333-4-pbonzini@redhat.com>

For the shortlog, it's not the "static call" that's incorrectly NULL, it's the
kvm_x86_ops.func that's wrong.  E.g. yank out static calls and KVM could still
keep the WARN.

On Mon, Feb 14, 2022, Paolo Bonzini wrote:
> Use the newly corrected KVM_X86_OP annotations to warn about possible
> NULL pointer dereferences as soon as the vendor module is loaded.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/x86/include/asm/kvm_host.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index e3f7d958c150..5dce6fbd9ab6 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -1546,9 +1546,10 @@ extern struct kvm_x86_ops kvm_x86_ops;
>  
>  static inline void kvm_ops_static_call_update(void)
>  {
> -#define KVM_X86_OP(func) \
> +#define KVM_X86_OP_OPTIONAL(func) \
>  	static_call_update(kvm_x86_##func, kvm_x86_ops.func);
> -#define KVM_X86_OP_OPTIONAL KVM_X86_OP
> +#define KVM_X86_OP(func) \
> +	WARN_ON(!kvm_x86_ops.func); KVM_X86_OP_OPTIONAL(func)

As before, I'd prefer that we not have a KVM_X86_OP => KVM_X86_OP_OPTIONAL
dependency and instead have a common __KVM_X86_OP for this one case.

>  #include <asm/kvm-x86-ops.h>
>  }
>  
> -- 
> 2.31.1
> 
> 

  reply	other threads:[~2022-02-15 17:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-14 13:16 [PATCH v2 0/5] kvm: x86: better handling of optional kvm_x86_ops Paolo Bonzini
2022-02-14 13:16 ` [PATCH v2 1/5] KVM: x86: use static_call_cond for optional callbacks Paolo Bonzini
2022-02-15 16:55   ` Sean Christopherson
2022-02-14 13:16 ` [PATCH v2 2/5] KVM: x86: remove KVM_X86_OP_NULL and mark optional kvm_x86_ops Paolo Bonzini
2022-02-15 17:08   ` Sean Christopherson
2022-02-15 17:09     ` Paolo Bonzini
2022-02-14 13:16 ` [PATCH v2 3/5] KVM: x86: warn on incorrectly NULL static calls Paolo Bonzini
2022-02-15 17:10   ` Sean Christopherson [this message]
2022-02-14 13:16 ` [PATCH v2 4/5] KVM: x86: make several APIC virtualization callbacks optional Paolo Bonzini
2022-02-15 17:12   ` Sean Christopherson
2022-02-14 13:16 ` [PATCH v2 5/5] KVM: x86: allow defining return-0 static calls Paolo Bonzini
2022-02-15 17:29   ` Sean Christopherson
2022-02-15 18:07     ` Paolo Bonzini

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=YgvekYk2QEIzOc+T@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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