From: Maxim Levitsky <mlevitsk@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Like Xu <like.xu.linux@gmail.com>
Subject: Re: [PATCH 01/22] KVM: x86: Drop unnecessary and confusing KVM_X86_OP_NULL macro
Date: Mon, 31 Jan 2022 17:19:52 +0200 [thread overview]
Message-ID: <864b41e42a88a92586b1c2361bebaf04446a98d5.camel@redhat.com> (raw)
In-Reply-To: <6979e482-1f07-4148-b9d7-d91cfa98c081@redhat.com>
On Mon, 2022-01-31 at 15:56 +0100, Paolo Bonzini wrote:
> On 1/28/22 16:42, Sean Christopherson wrote:
> > On Fri, Jan 28, 2022, Paolo Bonzini wrote:
> > > On 1/28/22 01:51, Sean Christopherson wrote:
> > > > Drop KVM_X86_OP_NULL, which is superfluous and confusing. The macro is
> > > > just a "pass-through" to KVM_X86_OP; it was added with the intent of
> > > > actually using it in the future, but that obviously never happened. The
> > > > name is confusing because its intended use was to provide a way for
> > > > vendor implementations to specify a NULL pointer, and even if it were
> > > > used, wouldn't necessarily be synonymous with declaring a kvm_x86_op as
> > > > DEFINE_STATIC_CALL_NULL.
> > > >
> > > > Lastly, actually using KVM_X86_OP_NULL as intended isn't a maintanable
> > > > approach, e.g. bleeds vendor details into common x86 code, and would
> > > > either be prone to bit rot or would require modifying common x86 code
> > > > when modifying a vendor implementation.
> > >
> > > I have some patches that redefine KVM_X86_OP_NULL as "must be used with
> > > static_call_cond". That's a more interesting definition, as it can be used
> > > to WARN if KVM_X86_OP is used with a NULL function pointer.
> >
> > I'm skeptical that will actually work well and be maintainble. E.g. sync_pir_to_ir()
> > must be explicitly check for NULL in apic_has_interrupt_for_ppr(), forcing that path
> > to do static_call_cond() will be odd. Ditto for ops that are wired up to ioctl()s,
> > e.g. the confidential VM stuff, and for ops that are guarded by other stuff, e.g. the
> > hypervisor timer.
> >
> > Actually, it won't just be odd, it will be impossible to disallow NULL a pointer
> > for KVM_X86_OP and require static_call_cond() for KVM_X86_OP_NULL. static_call_cond()
> > forces the return to "void", so any path that returns a value needs to be manually
> > guarded and can't use static_call_cond(), e.g.
>
> You're right and I should have looked up the series instead of going by
> memory. What I did was mostly WARNing on KVM_X86_OP that sets NULL, as
> non-NULL ops are the common case. I also added KVM_X86_OP_RET0 to
> remove some checks on kvm_x86_ops for ops that return a value.
>
> All in all I totally agree with patches 2-11 and will apply them (patch
> 2 to 5.17 even, as a prerequisite to fix the AVIC race). Several of
> patches 13-21 are also mostly useful as it clarifies the code, and the
> others I guess are okay in the context of a coherent series though
> probably they would have been rejected as one-offs. However, patches 12
> and 22 are unnecessary uses of the C preprocessor in my opinion.
>
I will send my patches very very soon - I'll rebase on top of this,
and review this patch series soon as well.
Best regards,
Maxim Levitsky
> Paolo
>
next prev parent reply other threads:[~2022-01-31 15:20 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-28 0:51 [PATCH 00/22] KVM: x86: Fill *_x86_ops via kvm-x86-ops.h Sean Christopherson
2022-01-28 0:51 ` [PATCH 01/22] KVM: x86: Drop unnecessary and confusing KVM_X86_OP_NULL macro Sean Christopherson
2022-01-28 10:11 ` Paolo Bonzini
2022-01-28 15:42 ` Sean Christopherson
2022-01-31 14:56 ` Paolo Bonzini
2022-01-31 15:19 ` Maxim Levitsky [this message]
2022-01-31 16:48 ` Sean Christopherson
2022-01-28 0:51 ` [PATCH 02/22] KVM: x86: Move delivery of non-APICv interrupt into vendor code Sean Christopherson
2022-01-28 0:51 ` [PATCH 03/22] KVM: x86: Drop export for .tlb_flush_current() static_call key Sean Christopherson
2022-01-28 0:51 ` [PATCH 04/22] KVM: x86: Rename kvm_x86_ops pointers to align w/ preferred vendor names Sean Christopherson
2022-01-28 0:51 ` [PATCH 05/22] KVM: x86: Use static_call() for .vcpu_deliver_sipi_vector() Sean Christopherson
2022-01-28 0:51 ` [PATCH 06/22] KVM: VMX: Call vmx_get_cpl() directly in handle_dr() Sean Christopherson
2022-01-28 0:51 ` [PATCH 07/22] KVM: xen: Use static_call() for invoking kvm_x86_ops hooks Sean Christopherson
2022-01-28 0:51 ` [PATCH 08/22] KVM: nVMX: Refactor PMU refresh to avoid referencing kvm_x86_ops.pmu_ops Sean Christopherson
2022-01-28 0:51 ` [PATCH 09/22] KVM: x86: Uninline and export hv_track_root_tdp() Sean Christopherson
2022-01-31 16:19 ` Vitaly Kuznetsov
2022-01-28 0:51 ` [PATCH 10/22] KVM: x86: Unexport kvm_x86_ops Sean Christopherson
2022-01-28 0:51 ` [PATCH 11/22] KVM: x86: Use static_call() for copy/move encryption context ioctls() Sean Christopherson
2022-01-28 0:51 ` [PATCH 12/22] KVM: x86: Allow different macros for APICv, CVM, and Hyper-V kvm_x86_ops Sean Christopherson
2022-01-28 0:51 ` [PATCH 13/22] KVM: VMX: Rename VMX functions to conform to kvm_x86_ops names Sean Christopherson
2022-01-28 0:52 ` [PATCH 14/22] KVM: VMX: Use kvm-x86-ops.h to fill vmx_x86_ops Sean Christopherson
2022-01-28 0:52 ` [PATCH 15/22] KVM: x86: Move get_cs_db_l_bits() helper to SVM Sean Christopherson
2022-01-28 0:52 ` [PATCH 16/22] KVM: SVM: Rename svm_flush_tlb() to svm_flush_tlb_current() Sean Christopherson
2022-01-28 0:52 ` [PATCH 17/22] KVM: SVM: Remove unused MAX_INST_SIZE #define Sean Christopherson
2022-01-28 0:52 ` [PATCH 18/22] KVM: SVM: Rename AVIC helpers to use "avic" prefix instead of "svm" Sean Christopherson
2022-01-28 0:52 ` [PATCH 19/22] KVM: x86: Use more verbose names for mem encrypt kvm_x86_ops hooks Sean Christopherson
2022-01-28 0:52 ` [PATCH 20/22] KVM: SVM: Rename SEV implemenations to conform to " Sean Christopherson
2022-01-28 0:52 ` [PATCH 21/22] KVM: SVM: Rename hook implementations to conform to kvm_x86_ops' names Sean Christopherson
2022-01-28 0:52 ` [PATCH 22/22] KVM: SVM: Use kvm-x86-ops.h to fill svm_x86_ops 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=864b41e42a88a92586b1c2361bebaf04446a98d5.camel@redhat.com \
--to=mlevitsk@redhat.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=like.xu.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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).