public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 5/5 Move-some-x86-specific-part-from-kvm_init-to-kvm_arch
@ 2007-11-14  5:44 Zhang, Xiantao
       [not found] ` <42DFA526FC41B1429CE7279EF83C6BDC94FACC-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Zhang, Xiantao @ 2007-11-14  5:44 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	carsteno-tA70FqPdS9bQT0dZR+AlfA, Hollis Blanchard

From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Move-some-x86-specific-part-from-kvm_init-to-kvm_arch
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 6e1bf8c..5162d29 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -493,7 +493,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);
 
 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
 void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu);
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index ae7ee77..1594e48 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1470,7 +1470,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;
@@ -1482,7 +1482,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);
 
@@ -1491,22 +1493,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;
@@ -1570,7 +1556,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:
@@ -1588,7 +1574,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 2e0fded..4fe9f60 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -1611,11 +1611,36 @@ 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)
 {
 	++vcpu->stat.halt_exits;
-- 
1.5.1.2

-------------------------------------------------------------------------
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/

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] 5/5 Move-some-x86-specific-part-from-kvm_init-to-kvm_arch
       [not found] ` <42DFA526FC41B1429CE7279EF83C6BDC94FACC-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-11-14 12:02   ` Carsten Otte
       [not found]     ` <473AE3E9.9020709-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Carsten Otte @ 2007-11-14 12:02 UTC (permalink / raw)
  To: Zhang, Xiantao
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	carsteno-tA70FqPdS9bQT0dZR+AlfA, Hollis Blanchard, Avi Kivity

I think two other functionalities need to be moved to kvm_arch_init 
which are still in common: The call to kvm_mmu_set_nonpresent_ptes() 
and the creation of kvm_vcpu_cache. This can well be done after 
merging this patch. kvm_init looks very much cleaned up now, well done 
Xiantao :-).

Acked-by: Carsten Otte <cotte-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>

Zhang, Xiantao wrote:
> From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Move-some-x86-specific-part-from-kvm_init-to-kvm_arch
> 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 6e1bf8c..5162d29 100644
> --- a/drivers/kvm/kvm.h
> +++ b/drivers/kvm/kvm.h
> @@ -493,7 +493,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);
>  
>  int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
>  void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu);
> diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
> index ae7ee77..1594e48 100644
> --- a/drivers/kvm/kvm_main.c
> +++ b/drivers/kvm/kvm_main.c
> @@ -1470,7 +1470,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;
> @@ -1482,7 +1482,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);
>  
> @@ -1491,22 +1493,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;
> @@ -1570,7 +1556,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:
> @@ -1588,7 +1574,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 2e0fded..4fe9f60 100644
> --- a/drivers/kvm/x86.c
> +++ b/drivers/kvm/x86.c
> @@ -1611,11 +1611,36 @@ 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)
>  {
>  	++vcpu->stat.halt_exits;


-------------------------------------------------------------------------
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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] 5/5 Move-some-x86-specific-part-from-kvm_init-to-kvm_arch
       [not found]     ` <473AE3E9.9020709-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
@ 2007-11-14 12:23       ` Zhang, Xiantao
       [not found]         ` <42DFA526FC41B1429CE7279EF83C6BDC94FBF7-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Zhang, Xiantao @ 2007-11-14 12:23 UTC (permalink / raw)
  To: carsteno-tA70FqPdS9bQT0dZR+AlfA, Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Hollis Blanchard

Carsten Otte wrote:
> I think two other functionalities need to be moved to kvm_arch_init
> which are still in common: The call to kvm_mmu_set_nonpresent_ptes()
> and the creation of kvm_vcpu_cache. This can well be done after
> merging this patch. kvm_init looks very much cleaned up now, well done
> Xiantao :-).

Agree.  I am working on this now.  I think we should move all mmu code
to arch specific.  

Avi, 
What's your ideas ? I rememberd you said we should keep some mmu
interface in common, but seems current code is more x86-specific. Maybe
we should move them into arch first. If other archs need them, we can
move back and work out more generic interfaces.  At least, IA64 and S390
doesn't need them:-)

Xiantao

> 
> Acked-by: Carsten Otte <cotte-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
> 
> Zhang, Xiantao wrote:
>> From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>> Move-some-x86-specific-part-from-kvm_init-to-kvm_arch
>> 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
>> 

-------------------------------------------------------------------------
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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] 5/5 Move-some-x86-specific-part-from-kvm_init-to-kvm_arch
       [not found]         ` <42DFA526FC41B1429CE7279EF83C6BDC94FBF7-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-11-14 13:18           ` Carsten Otte
  2007-11-14 13:37           ` Avi Kivity
  1 sibling, 0 replies; 6+ messages in thread
From: Carsten Otte @ 2007-11-14 13:18 UTC (permalink / raw)
  To: Zhang, Xiantao
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	carsteno-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8, Hollis Blanchard,
	Avi Kivity

Zhang, Xiantao wrote:
> Agree.  I am working on this now.  I think we should move all mmu code
> to arch specific.  
Yea, I think ppc does'nt need it as well. Hollis?

-------------------------------------------------------------------------
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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] 5/5 Move-some-x86-specific-part-from-kvm_init-to-kvm_arch
       [not found]         ` <42DFA526FC41B1429CE7279EF83C6BDC94FBF7-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  2007-11-14 13:18           ` Carsten Otte
@ 2007-11-14 13:37           ` Avi Kivity
       [not found]             ` <473AFA30.3040703-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
  1 sibling, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2007-11-14 13:37 UTC (permalink / raw)
  To: Zhang, Xiantao
  Cc: carsteno-tA70FqPdS9bQT0dZR+AlfA,
	kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Hollis Blanchard

Zhang, Xiantao wrote:
> Carsten Otte wrote:
>   
>> I think two other functionalities need to be moved to kvm_arch_init
>> which are still in common: The call to kvm_mmu_set_nonpresent_ptes()
>> and the creation of kvm_vcpu_cache. This can well be done after
>> merging this patch. kvm_init looks very much cleaned up now, well done
>> Xiantao :-).
>>     
>
> Agree.  I am working on this now.  I think we should move all mmu code
> to arch specific.  
>
> Avi, 
> What's your ideas ? I rememberd you said we should keep some mmu
> interface in common, but seems current code is more x86-specific. Maybe
> we should move them into arch first. If other archs need them, we can
> move back and work out more generic interfaces.  At least, IA64 and S390
> doesn't need them:-)
>   

kvm_mmu_set_nonpresent_ptes() is very much arch specific.  It's okay by me to move things and move them back, so long that's the exception and not the rule.




-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] 5/5Move-some-x86-specific-part-from-kvm_init-to-kvm_arch
       [not found]             ` <473AFA30.3040703-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-11-14 15:22               ` Zhang, Xiantao
  0 siblings, 0 replies; 6+ messages in thread
From: Zhang, Xiantao @ 2007-11-14 15:22 UTC (permalink / raw)
  To: Avi Kivity
  Cc: carsteno-tA70FqPdS9bQT0dZR+AlfA,
	kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Hollis Blanchard

Avi Kivity wrote:
> Zhang, Xiantao wrote:
>> Carsten Otte wrote:
>> 
>>> I think two other functionalities need to be moved to kvm_arch_init
>>> which are still in common: The call to kvm_mmu_set_nonpresent_ptes()
>>> and the creation of kvm_vcpu_cache. This can well be done after
>>> merging this patch. kvm_init looks very much cleaned up now, well
>>> done Xiantao :-). 
>>> 
>> 
>> Agree.  I am working on this now.  I think we should move all mmu
>> code to arch specific. 
>> 
>> Avi,
>> What's your ideas ? I rememberd you said we should keep some mmu
>> interface in common, but seems current code is more x86-specific.
>> Maybe we should move them into arch first. If other archs need them,
>> we can move back and work out more generic interfaces.  At least,
>> IA64 and S390 doesn't need them:-) 
>> 
> 
> kvm_mmu_set_nonpresent_ptes() is very much arch specific.  It's okay
> by me to move things and move them back, so long that's the exception
> and not the rule.  

Yes, I know:-)
Xiantao

-------------------------------------------------------------------------
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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-11-14 15:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-14  5:44 [PATCH] 5/5 Move-some-x86-specific-part-from-kvm_init-to-kvm_arch Zhang, Xiantao
     [not found] ` <42DFA526FC41B1429CE7279EF83C6BDC94FACC-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-11-14 12:02   ` Carsten Otte
     [not found]     ` <473AE3E9.9020709-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-11-14 12:23       ` Zhang, Xiantao
     [not found]         ` <42DFA526FC41B1429CE7279EF83C6BDC94FBF7-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-11-14 13:18           ` Carsten Otte
2007-11-14 13:37           ` Avi Kivity
     [not found]             ` <473AFA30.3040703-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-14 15:22               ` [PATCH] 5/5Move-some-x86-specific-part-from-kvm_init-to-kvm_arch Zhang, Xiantao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox