public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Split segments reload in vmx_load_host_state()
@ 2007-08-23 12:47 Laurent Vivier
       [not found] ` <46CD81D5.90707-6ktuUTfB/bM@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Laurent Vivier @ 2007-08-23 12:47 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm-devel

[-- Attachment #1: Type: text/plain, Size: 339 bytes --]

It is from the TODO and I hope no one is already working on this.

'vmx_load_host_state() bundles fs, gs, ldt, and tss reloading into one in the
hope that it is infrequent. With smp guests, fs reloading is frequent and the
separate reloads should be unbundled.'

Signed-off-by: Laurent Vivier <Laurent.Vivier-6ktuUTfB/bM@public.gmane.org>

[-- Attachment #2: vmx_load_host_state-split --]
[-- Type: text/plain, Size: 2189 bytes --]

Index: kvm/drivers/kvm/vmx.c
===================================================================
--- kvm.orig/drivers/kvm/vmx.c	2007-08-23 11:26:34.000000000 +0200
+++ kvm/drivers/kvm/vmx.c	2007-08-23 13:45:10.000000000 +0200
@@ -54,7 +54,8 @@ struct vcpu_vmx {
 	struct {
 		int           loaded;
 		u16           fs_sel, gs_sel, ldt_sel;
-		int           fs_gs_ldt_reload_needed;
+		int           gs_ldt_reload_needed;
+		int           fs_reload_needed;
 	}host_state;
 
 };
@@ -353,20 +354,20 @@ static void vmx_save_host_state(struct v
 	 * allow segment selectors with cpl > 0 or ti == 1.
 	 */
 	vmx->host_state.ldt_sel = read_ldt();
-	vmx->host_state.fs_gs_ldt_reload_needed = vmx->host_state.ldt_sel;
+	vmx->host_state.gs_ldt_reload_needed = vmx->host_state.ldt_sel;
 	vmx->host_state.fs_sel = read_fs();
 	if (!(vmx->host_state.fs_sel & 7))
 		vmcs_write16(HOST_FS_SELECTOR, vmx->host_state.fs_sel);
 	else {
 		vmcs_write16(HOST_FS_SELECTOR, 0);
-		vmx->host_state.fs_gs_ldt_reload_needed = 1;
+		vmx->host_state.fs_reload_needed = 1;
 	}
 	vmx->host_state.gs_sel = read_gs();
 	if (!(vmx->host_state.gs_sel & 7))
 		vmcs_write16(HOST_GS_SELECTOR, vmx->host_state.gs_sel);
 	else {
 		vmcs_write16(HOST_GS_SELECTOR, 0);
-		vmx->host_state.fs_gs_ldt_reload_needed = 1;
+		vmx->host_state.gs_ldt_reload_needed = 1;
 	}
 
 #ifdef CONFIG_X86_64
@@ -396,9 +397,10 @@ static void vmx_load_host_state(struct v
 		return;
 
 	vmx->host_state.loaded = 0;
-	if (vmx->host_state.fs_gs_ldt_reload_needed) {
-		load_ldt(vmx->host_state.ldt_sel);
+	if (vmx->host_state.fs_reload_needed)
 		load_fs(vmx->host_state.fs_sel);
+	if (vmx->host_state.gs_ldt_reload_needed) {
+		load_ldt(vmx->host_state.ldt_sel);
 		/*
 		 * If we have to reload gs, we must take care to
 		 * preserve our gs base.
@@ -409,9 +411,9 @@ static void vmx_load_host_state(struct v
 		wrmsrl(MSR_GS_BASE, vmcs_readl(HOST_GS_BASE));
 #endif
 		local_irq_restore(flags);
-
-		reload_tss();
 	}
+	if (vmx->host_state.gs_ldt_reload_needed || vmx->host_state.fs_reload_needed)
+		reload_tss();
 	save_msrs(vmx->guest_msrs, vmx->save_nmsrs);
 	load_msrs(vmx->host_msrs, vmx->save_nmsrs);
 	if (msr_efer_need_save_restore(vmx))

[-- Attachment #3: Type: text/plain, Size: 315 bytes --]

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

[-- Attachment #4: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

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

* Re: [PATCH] Split segments reload in vmx_load_host_state()
       [not found] ` <46CD81D5.90707-6ktuUTfB/bM@public.gmane.org>
@ 2007-08-23 12:52   ` Avi Kivity
       [not found]     ` <46CD8316.2040208-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2007-08-23 12:52 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: kvm-devel

Laurent Vivier wrote:
> It is from the TODO and I hope no one is already working on this.
>
> 'vmx_load_host_state() bundles fs, gs, ldt, and tss reloading into one in the
> hope that it is infrequent. With smp guests, fs reloading is frequent and the
> separate reloads should be unbundled.'
>
>   

>  
>  };
> @@ -353,20 +354,20 @@ static void vmx_save_host_state(struct v
>  	 * allow segment selectors with cpl > 0 or ti == 1.
>  	 */
>  	vmx->host_state.ldt_sel = read_ldt();
> -	vmx->host_state.fs_gs_ldt_reload_needed = vmx->host_state.ldt_sel;
> +	vmx->host_state.gs_ldt_reload_needed = vmx->host_state.ldt_sel;
>   

Missing initialization for fs_reload_needed here.

-- 
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] Split segments reload in vmx_load_host_state()
       [not found]     ` <46CD8316.2040208-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-08-23 13:02       ` Laurent Vivier
       [not found]         ` <46CD8562.5000402-6ktuUTfB/bM@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Laurent Vivier @ 2007-08-23 13:02 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm-devel


[-- Attachment #1.1: Type: text/plain, Size: 956 bytes --]

Avi Kivity wrote:
> Laurent Vivier wrote:
>> It is from the TODO and I hope no one is already working on this.
>>
>> 'vmx_load_host_state() bundles fs, gs, ldt, and tss reloading into one in the
>> hope that it is infrequent. With smp guests, fs reloading is frequent and the
>> separate reloads should be unbundled.'
>>
>>   
> 
>>  
>>  };
>> @@ -353,20 +354,20 @@ static void vmx_save_host_state(struct v
>>  	 * allow segment selectors with cpl > 0 or ti == 1.
>>  	 */
>>  	vmx->host_state.ldt_sel = read_ldt();
>> -	vmx->host_state.fs_gs_ldt_reload_needed = vmx->host_state.ldt_sel;
>> +	vmx->host_state.gs_ldt_reload_needed = vmx->host_state.ldt_sel;
>>   
> 
> Missing initialization for fs_reload_needed here.
> 

It is initialized on fs_sel, should it be initialized on ldt_sel too ?

Laurent
-- 
------------- Laurent.Vivier-6ktuUTfB/bM@public.gmane.org  --------------
          "Software is hard" - Donald Knuth


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 315 bytes --]

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

[-- Attachment #3: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

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

* Re: [PATCH] Split segments reload in vmx_load_host_state()
       [not found]         ` <46CD8562.5000402-6ktuUTfB/bM@public.gmane.org>
@ 2007-08-23 13:14           ` Avi Kivity
       [not found]             ` <46CD881B.6040202-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2007-08-23 13:14 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: kvm-devel

Laurent Vivier wrote:
> Avi Kivity wrote:
>   
>> Laurent Vivier wrote:
>>     
>>> It is from the TODO and I hope no one is already working on this.
>>>
>>> 'vmx_load_host_state() bundles fs, gs, ldt, and tss reloading into one in the
>>> hope that it is infrequent. With smp guests, fs reloading is frequent and the
>>> separate reloads should be unbundled.'
>>>
>>>   
>>>       
>>>  
>>>  };
>>> @@ -353,20 +354,20 @@ static void vmx_save_host_state(struct v
>>>  	 * allow segment selectors with cpl > 0 or ti == 1.
>>>  	 */
>>>  	vmx->host_state.ldt_sel = read_ldt();
>>> -	vmx->host_state.fs_gs_ldt_reload_needed = vmx->host_state.ldt_sel;
>>> +	vmx->host_state.gs_ldt_reload_needed = vmx->host_state.ldt_sel;
>>>   
>>>       
>> Missing initialization for fs_reload_needed here.
>>
>>     
>
> It is initialized on fs_sel, should it be initialized on ldt_sel too ?
>
>   

It's only initialized to 1, but never cleared to zero.

The original code means: if ((ldt_sel != 0) || ((fs_sel  & 7) != 0) || 
((gs_sel & 7) != 0)) then a reload is needed.  In the new code, fs 
reload should depend only on ((fs_sel & 7) != 0) and ldt/gs reload 
should depend on ldt_sel and gs_sel only.

Regarding reload_tss(), it should probably be unconditional.

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

* [PATCH][RESEND] Split segments reload in vmx_load_host_state()
       [not found]             ` <46CD881B.6040202-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-08-23 14:33               ` Laurent Vivier
       [not found]                 ` <46CD9AA7.9010101-6ktuUTfB/bM@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Laurent Vivier @ 2007-08-23 14:33 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 291 bytes --]

From KVM/TODO:
vmx_load_host_state() bundles fs, gs, ldt, and tss reloading into
one in the hope that it is infrequent. With smp guests, fs reloading is
frequent and the separate reloads should be unbundled.

Signed-off-by: Laurent Vivier <Laurent.Vivier-6ktuUTfB/bM@public.gmane.org>

[-- Attachment #1.1.2: vmx_load_host_state-split --]
[-- Type: text/plain, Size: 2264 bytes --]

Index: kvm/drivers/kvm/vmx.c
===================================================================
--- kvm.orig/drivers/kvm/vmx.c	2007-08-23 14:41:48.000000000 +0200
+++ kvm/drivers/kvm/vmx.c	2007-08-23 16:20:23.000000000 +0200
@@ -54,7 +54,8 @@ struct vcpu_vmx {
 	struct {
 		int           loaded;
 		u16           fs_sel, gs_sel, ldt_sel;
-		int           fs_gs_ldt_reload_needed;
+		int           gs_ldt_reload_needed;
+		int           fs_reload_needed;
 	}host_state;
 
 };
@@ -353,20 +354,21 @@ static void vmx_save_host_state(struct v
 	 * allow segment selectors with cpl > 0 or ti == 1.
 	 */
 	vmx->host_state.ldt_sel = read_ldt();
-	vmx->host_state.fs_gs_ldt_reload_needed = vmx->host_state.ldt_sel;
+	vmx->host_state.gs_ldt_reload_needed = vmx->host_state.ldt_sel;
 	vmx->host_state.fs_sel = read_fs();
-	if (!(vmx->host_state.fs_sel & 7))
+	if (!(vmx->host_state.fs_sel & 7)) {
 		vmcs_write16(HOST_FS_SELECTOR, vmx->host_state.fs_sel);
-	else {
+		vmx->host_state.fs_reload_needed = 0;
+	} else {
 		vmcs_write16(HOST_FS_SELECTOR, 0);
-		vmx->host_state.fs_gs_ldt_reload_needed = 1;
+		vmx->host_state.fs_reload_needed = 1;
 	}
 	vmx->host_state.gs_sel = read_gs();
 	if (!(vmx->host_state.gs_sel & 7))
 		vmcs_write16(HOST_GS_SELECTOR, vmx->host_state.gs_sel);
 	else {
 		vmcs_write16(HOST_GS_SELECTOR, 0);
-		vmx->host_state.fs_gs_ldt_reload_needed = 1;
+		vmx->host_state.gs_ldt_reload_needed = 1;
 	}
 
 #ifdef CONFIG_X86_64
@@ -396,9 +398,10 @@ static void vmx_load_host_state(struct v
 		return;
 
 	vmx->host_state.loaded = 0;
-	if (vmx->host_state.fs_gs_ldt_reload_needed) {
-		load_ldt(vmx->host_state.ldt_sel);
+	if (vmx->host_state.fs_reload_needed)
 		load_fs(vmx->host_state.fs_sel);
+	if (vmx->host_state.gs_ldt_reload_needed) {
+		load_ldt(vmx->host_state.ldt_sel);
 		/*
 		 * If we have to reload gs, we must take care to
 		 * preserve our gs base.
@@ -409,9 +412,8 @@ static void vmx_load_host_state(struct v
 		wrmsrl(MSR_GS_BASE, vmcs_readl(HOST_GS_BASE));
 #endif
 		local_irq_restore(flags);
-
-		reload_tss();
 	}
+	reload_tss();
 	save_msrs(vmx->guest_msrs, vmx->save_nmsrs);
 	load_msrs(vmx->host_msrs, vmx->save_nmsrs);
 	if (msr_efer_need_save_restore(vmx))

[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 315 bytes --]

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

[-- Attachment #3: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

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

* Re: [PATCH][RESEND] Split segments reload in vmx_load_host_state()
       [not found]                 ` <46CD9AA7.9010101-6ktuUTfB/bM@public.gmane.org>
@ 2007-08-23 14:44                   ` Avi Kivity
  0 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2007-08-23 14:44 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: kvm-devel

Laurent Vivier wrote:
> From KVM/TODO:
> vmx_load_host_state() bundles fs, gs, ldt, and tss reloading into
> one in the hope that it is infrequent. With smp guests, fs reloading is
> frequent and the separate reloads should be unbundled.
>
>   

Applied, thanks.


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

end of thread, other threads:[~2007-08-23 14:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-23 12:47 [PATCH] Split segments reload in vmx_load_host_state() Laurent Vivier
     [not found] ` <46CD81D5.90707-6ktuUTfB/bM@public.gmane.org>
2007-08-23 12:52   ` Avi Kivity
     [not found]     ` <46CD8316.2040208-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-23 13:02       ` Laurent Vivier
     [not found]         ` <46CD8562.5000402-6ktuUTfB/bM@public.gmane.org>
2007-08-23 13:14           ` Avi Kivity
     [not found]             ` <46CD881B.6040202-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-23 14:33               ` [PATCH][RESEND] " Laurent Vivier
     [not found]                 ` <46CD9AA7.9010101-6ktuUTfB/bM@public.gmane.org>
2007-08-23 14:44                   ` Avi Kivity

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