From mboxrd@z Thu Jan 1 00:00:00 1970 From: Laurent Vivier Subject: [PATCH] Split segments reload in vmx_load_host_state() Date: Thu, 23 Aug 2007 14:47:17 +0200 Message-ID: <46CD81D5.90707@bull.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------010703030906070902000002" Cc: kvm-devel To: Avi Kivity Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org This is a multi-part message in MIME format. --------------010703030906070902000002 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1 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 --------------010703030906070902000002 Content-Transfer-Encoding: 7bit Content-Type: text/plain; name="vmx_load_host_state-split" Content-Disposition: inline; filename="vmx_load_host_state-split" 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)) --------------010703030906070902000002 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- 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/ --------------010703030906070902000002 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kvm-devel mailing list kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/kvm-devel --------------010703030906070902000002--