lkml.org 
[lkml]   [2019]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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.

\
 
 \ /
  Last update: 2019-09-23 18:15    [W:0.066 / U:0.720 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site