[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190923161352.GC18195@linux.intel.com>
Date: Mon, 23 Sep 2019 09:13:52 -0700
From: Sean Christopherson <sean.j.christopherson@...el.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: Andrea Arcangeli <aarcange@...hat.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
"Dr. David Alan Gilbert" <dgilbert@...hat.com>,
Marcelo Tosatti <mtosatti@...hat.com>,
Peter Xu <peterx@...hat.com>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 02/17] KVM: monolithic: x86: convert the kvm_x86_ops
methods to external functions
On Mon, Sep 23, 2019 at 12:19:30PM +0200, Paolo Bonzini wrote:
> On 20/09/19 23:24, Andrea Arcangeli wrote:
> > diff --git a/arch/x86/kvm/svm_ops.c b/arch/x86/kvm/svm_ops.c
> > new file mode 100644
> > index 000000000000..2aaabda92179
> > --- /dev/null
> > +++ b/arch/x86/kvm/svm_ops.c
> > @@ -0,0 +1,672 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * arch/x86/kvm/svm_ops.c
> > + *
> > + * Copyright 2019 Red Hat, Inc.
> > + */
> > +
> > +int kvm_x86_ops_cpu_has_kvm_support(void)
> > +{
> > + return has_svm();
> > +}
>
> Can you just rename all the functions in vmx/ and svm.c, instead of
> adding forwarders?
Yeah, having kvm_x86_ be analogous to kvm_arch_ seems like the obvious
approach. The necessary VMX and SVM renaming can be done in separate
preparatory patches, and the conversion from kvm_x86_ops to direct calls
would be fairly straightforward.
Alternatively, what if we use macros in the call sites, e.g. keep/require
vmx_ and svm_ prefixes for all functions, renaming VMX and SVM code as
needed? E.g.:
cpu_has_vmx_support -> vmx_supported_by_cpu
cpu_has_svm_support -> svm_supported_by_cpu
int vmx_disabled_by_bios(void)
int svm_disabled_by_bios(void)
#define X86_OP(name) kvm_x86_vendor##_##name
int kvm_arch_init(void *opaque)
{
if (X86_OP(supported_by_cpu())) {
printk(KERN_ERR "kvm: no hardware support\n");
r = -EOPNOTSUPP;
goto out;
}
if (X86_OP(disabled_by_bios())) {
printk(KERN_ERR "kvm: disabled by bios\n");
r = -EOPNOTSUPP;
goto out;
}
}
Pros:
- Smaller patches due to less renaming in VMX and SVM
- Calls to vendor code are very obvious
- Stack traces contain vmx vs. svm instead of kvm_x86
Cons:
- Macros
- Annoying development environment, e.g. editors tend to struggle with
macrofied funtion/variable names.
Powered by blists - more mailing lists