public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Carsten Otte <cotte-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
To: "Zhang, Xiantao" <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	carsteno-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org,
	Hollis Blanchard
	<hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>,
	Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH] 5/5 Make kvm_init as arch-indepenent
Date: Thu, 08 Nov 2007 14:56:37 +0100	[thread overview]
Message-ID: <47331595.4090109@de.ibm.com> (raw)
In-Reply-To: <42DFA526FC41B1429CE7279EF83C6BDC905008-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>

Acked-by: Carsten Otte <cotte-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
Zhang, Xiantao wrote:
>>From 2d6ee07b96f1a91cef9327f241077af3698ed4dc Mon Sep 17 00:00:00 2001
> From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Date: Thu, 8 Nov 2007 13:37:38 +0800
> Subject: [PATCH] Make kvm_init as arch-indepenent, through defining a
> void
> pointer type variable. All archs will register their corresponding arch
> functions
> into kvm module. For example, x86 will use it to register vmx/svm's ops.
> Signed-off-by: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/kvm/kvm.h      |    5 +++--
>  drivers/kvm/kvm_main.c |   26 ++++++--------------------
>  drivers/kvm/x86.c      |   27 ++++++++++++++++++++++++++-
>  3 files changed, 35 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
> index 33b4629..9b6087f 100644
> --- a/drivers/kvm/kvm.h
> +++ b/drivers/kvm/kvm.h
> @@ -494,7 +494,7 @@ void vcpu_load(struct kvm_vcpu *vcpu);
>  void vcpu_put(struct kvm_vcpu *vcpu);
> 
> 
> -int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size,
> +int kvm_init(void *opaque, unsigned int vcpu_size,
>  		  struct module *module);
>  void kvm_exit(void);
> 
> @@ -647,7 +647,8 @@ int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu
> *vcpu,
>  				    struct kvm_debug_guest *dbg);
>  int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run
> *kvm_run);
> 
> -__init void kvm_arch_init(void);
> +int kvm_arch_init(void *opaque);
> +void kvm_arch_exit(void);
> 
> 
>  void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu);
> diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
> index 8f09170..70bc4d4 100644
> --- a/drivers/kvm/kvm_main.c
> +++ b/drivers/kvm/kvm_main.c
> @@ -1503,7 +1503,7 @@ static void kvm_sched_out(struct preempt_notifier
> *pn,
>  	kvm_arch_vcpu_put(vcpu);
>  }
> 
> -int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size,
> +int kvm_init(void *opaque, unsigned int vcpu_size,
>  		  struct module *module)
>  {
>  	int r;
> @@ -1515,7 +1515,9 @@ int kvm_init(struct kvm_x86_ops *ops, unsigned int
> vcpu_size,
> 
>  	kvm_init_debug();
> 
> -	kvm_arch_init();
> +	r = kvm_arch_init(opaque);
> +	if (r)
> +		goto out4;
> 
>  	bad_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
> 
> @@ -1524,22 +1526,6 @@ int kvm_init(struct kvm_x86_ops *ops, unsigned
> int vcpu_size,
>  		goto out;
>  	}
> 
> -	if (kvm_x86_ops) {
> -		printk(KERN_ERR "kvm: already loaded the other
> module\n");
> -		return -EEXIST;
> -	}
> -
> -	if (!ops->cpu_has_kvm_support()) {
> -		printk(KERN_ERR "kvm: no hardware support\n");
> -		return -EOPNOTSUPP;
> -	}
> -	if (ops->disabled_by_bios()) {
> -		printk(KERN_ERR "kvm: disabled by bios\n");
> -		return -EOPNOTSUPP;
> -	}
> -
> -	kvm_x86_ops = ops;
> -
>  	r = kvm_arch_hardware_setup();
>  	if (r < 0)
>  		goto out;
> @@ -1603,7 +1589,7 @@ out_free_1:
>  out_free_0:
>  	kvm_arch_hardware_unsetup();
>  out:
> -	kvm_x86_ops = NULL;
> +	kvm_arch_exit();
>  	kvm_exit_debug();
>  	kvm_mmu_module_exit();
>  out4:   
> @@ -1621,7 +1607,7 @@ void kvm_exit(void)
>  	unregister_cpu_notifier(&kvm_cpu_notifier);
>  	on_each_cpu(hardware_disable, NULL, 0, 1);
>  	kvm_arch_hardware_unsetup();
> -	kvm_x86_ops = NULL;
> +	kvm_arch_exit();
>  	kvm_exit_debug();
>  	__free_page(bad_page);
>  	kvm_mmu_module_exit();
> diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
> index 8aea240..22b3cc6 100644
> --- a/drivers/kvm/x86.c
> +++ b/drivers/kvm/x86.c
> @@ -1611,9 +1611,34 @@ int kvm_emulate_pio_string(struct kvm_vcpu *vcpu,
> struct kvm_run *run, int in,
>  }
>  EXPORT_SYMBOL_GPL(kvm_emulate_pio_string);
> 
> -__init void kvm_arch_init(void)
> +int kvm_arch_init(void *opaque)
>  {
> +	struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
> +
>  	kvm_init_msr_list();
> +
> +	if (kvm_x86_ops) {
> +		printk(KERN_ERR "kvm: already loaded the other
> module\n");
> +		return -EEXIST;
> +	}
> +
> +	if (!ops->cpu_has_kvm_support()) {
> +		printk(KERN_ERR "kvm: no hardware support\n");
> +		return -EOPNOTSUPP;
> +	}
> +	if (ops->disabled_by_bios()) {
> +		printk(KERN_ERR "kvm: disabled by bios\n");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	kvm_x86_ops = ops;
> +
> +	return 0;
> +}
> +
> +void kvm_arch_exit(void)
> +{
> +	kvm_x86_ops = NULL;
>  }
> 
>  int kvm_emulate_halt(struct kvm_vcpu *vcpu)


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

      parent reply	other threads:[~2007-11-08 13:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200711080708.lA878c1M016017@vti-build.sh.intel.com>
     [not found] ` <200711080708.lA878c1M016017-h0Jaa6VhywQUKqEDCML9rVDQ4js95KgL@public.gmane.org>
2007-11-08  7:21   ` [PATCH] 5/5 Make kvm_init as arch-indepenent Zhang, Xiantao
     [not found]     ` <42DFA526FC41B1429CE7279EF83C6BDC905008-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-11-08 13:56       ` Carsten Otte [this message]

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=47331595.4090109@de.ibm.com \
    --to=cotte-ta70fqpds9bqt0dzr+alfa@public.gmane.org \
    --cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
    --cc=carsteno-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
    --cc=carsteno-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org \
    --cc=hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /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