KVM: Miscellaneous stabilization fixes
cover KVM: Miscellaneous stabilization fixes
A trio of fixes for miscellaneous problems, that don't affect usage under normal .configs and usage. However they do need fixing.
Signature · 8 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
PATCH 1/3 KVM: Fix GFP_KERNEL alloc in atomic section bug
From: Ingo Molnar <[email protected]>
KVM does kmalloc() in an atomic section while having preemption disabled via vcpu_load(). Fix this by moving the ->*_msr setup from the vcpu_setup method to the vcpu_create method.
(This is also a small speedup for setting up a vcpu, which can in theory be more frequent than the vcpu_create method).
drivers/kvm/vmx.c +21 -11
@@ -1094,14 +1094,6 @@ static int vmx_vcpu_setup(struct kvm_vcprdmsrl (MSR_IA32_SYSENTER_EIP , a);vmcs_writel (HOST_IA32_SYSENTER_EIP , a);/* 22.2.3 */ - ret = -ENOMEM ; - vcpu->guest_msrs =kmalloc (PAGE_SIZE ,GFP_KERNEL ); -if (!vcpu->guest_msrs) - goto out; - vcpu->host_msrs =kmalloc (PAGE_SIZE ,GFP_KERNEL ); -if (!vcpu->host_msrs) - goto out_free_guest_msrs; -for (i =0 ; i <NR_VMX_MSR ; ++i) {u32 index = vmx_msr_index[i];u32 data_low, data_high;
@@ -1155,8 +1147,6 @@ static int vmx_vcpu_setup(struct kvm_vcpreturn 0 ; -out_free_guest_msrs: -kfree (vcpu->guest_msrs); out:return ret; }
@@ -1906,13 +1896,33 @@ static int vmx_create_vcpu(struct kvm_vc {struct vmcs *vmcs; + vcpu->guest_msrs =kmalloc (PAGE_SIZE ,GFP_KERNEL ); +if (!vcpu->guest_msrs) +return -ENOMEM ; + + vcpu->host_msrs =kmalloc (PAGE_SIZE ,GFP_KERNEL ); +if (!vcpu->host_msrs) + goto out_free_guest_msrs; + vmcs =alloc_vmcs ();if (!vmcs) -return -ENOMEM ; + goto out_free_msrs; +vmcs_clear (vmcs); vcpu->vmcs = vmcs; vcpu->launched =0 ; +return 0 ; + +out_free_msrs: +kfree (vcpu->host_msrs); + vcpu->host_msrs =NULL ; + +out_free_guest_msrs: +kfree (vcpu->guest_msrs); + vcpu->guest_msrs =NULL ; + +return -ENOMEM ; }static struct kvm_arch_ops vmx_arch_ops = {
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
PATCH 2/3 KVM: Use raw_smp_processor_id() instead of smp_processor_id() where applicable
In reply to Avi KivityFrom: Ingo Molnar <[email protected]>
drivers/kvm/vmx.c +2 -2
@@ -116,7 +116,7 @@ static void vmcs_clear(struct vmcs *vmcsstatic void __vcpu_clear (void *arg) {struct kvm_vcpu *vcpu = arg; -int cpu =smp_processor_id (); +int cpu =raw_smp_processor_id ();if (vcpu->cpu == cpu)vmcs_clear (vcpu->vmcs);
@@ -541,7 +541,7 @@ static struct vmcs *alloc_vmcs_cpu(int cstatic struct vmcs *alloc_vmcs (void ) { -return alloc_vmcs_cpu (smp_processor_id ()); +return alloc_vmcs_cpu (raw_smp_processor_id ()); }static void free_vmcs (struct vmcs *vmcs)
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
PATCH 3/3 KVM: Recover after an arch module load failure
In reply to Avi KivityFrom: Yoshimi Ichiyanagi <[email protected]>
If we load the wrong arch module, it leaves behind kvm_arch_ops set, which prevents loading of the correct arch module later.
Fix be not setting kvm_arch_ops until we're sure it's good.
drivers/kvm/kvm_main.c +4 -4
@@ -1944,17 +1944,17 @@ int kvm_init_arch(struct kvm_arch_ops *oreturn -EEXIST ; } - kvm_arch_ops = ops; - -if (!kvm_arch_ops->cpu_has_kvm_support ()) { +if (!ops->cpu_has_kvm_support ()) {printk (KERN_ERR "kvm: no hardware support\n" );return -EOPNOTSUPP ; } -if (kvm_arch_ops->disabled_by_bios ()) { +if (ops->disabled_by_bios ()) {printk (KERN_ERR "kvm: disabled by bios\n" );return -EOPNOTSUPP ; } + kvm_arch_ops = ops; + r = kvm_arch_ops->hardware_setup ();if (r <0 )return r;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV