Re: [PATCH] Split segments reload in vmx_load_host_state()

Avi Kivity
2007-08-23T13:14:03Z

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