aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/kvm')
-rw-r--r--drivers/kvm/kvm_main.c63
-rw-r--r--drivers/kvm/mmu.c2
-rw-r--r--drivers/kvm/svm.c8
-rw-r--r--drivers/kvm/vmx.c2
4 files changed, 38 insertions, 37 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index b10972ed0c9f..099f0afd394d 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -62,7 +62,7 @@ static struct kvm_stats_debugfs_item {
62 { "halt_exits", &kvm_stat.halt_exits }, 62 { "halt_exits", &kvm_stat.halt_exits },
63 { "request_irq", &kvm_stat.request_irq_exits }, 63 { "request_irq", &kvm_stat.request_irq_exits },
64 { "irq_exits", &kvm_stat.irq_exits }, 64 { "irq_exits", &kvm_stat.irq_exits },
65 { 0, 0 } 65 { NULL, NULL }
66}; 66};
67 67
68static struct dentry *debugfs_dir; 68static struct dentry *debugfs_dir;
@@ -205,7 +205,7 @@ static struct kvm_vcpu *vcpu_load(struct kvm *kvm, int vcpu_slot)
205 mutex_lock(&vcpu->mutex); 205 mutex_lock(&vcpu->mutex);
206 if (unlikely(!vcpu->vmcs)) { 206 if (unlikely(!vcpu->vmcs)) {
207 mutex_unlock(&vcpu->mutex); 207 mutex_unlock(&vcpu->mutex);
208 return 0; 208 return NULL;
209 } 209 }
210 return kvm_arch_ops->vcpu_load(vcpu); 210 return kvm_arch_ops->vcpu_load(vcpu);
211} 211}
@@ -257,9 +257,9 @@ static void kvm_free_physmem_slot(struct kvm_memory_slot *free,
257 if (!dont || free->dirty_bitmap != dont->dirty_bitmap) 257 if (!dont || free->dirty_bitmap != dont->dirty_bitmap)
258 vfree(free->dirty_bitmap); 258 vfree(free->dirty_bitmap);
259 259
260 free->phys_mem = 0; 260 free->phys_mem = NULL;
261 free->npages = 0; 261 free->npages = 0;
262 free->dirty_bitmap = 0; 262 free->dirty_bitmap = NULL;
263} 263}
264 264
265static void kvm_free_physmem(struct kvm *kvm) 265static void kvm_free_physmem(struct kvm *kvm)
@@ -267,7 +267,7 @@ static void kvm_free_physmem(struct kvm *kvm)
267 int i; 267 int i;
268 268
269 for (i = 0; i < kvm->nmemslots; ++i) 269 for (i = 0; i < kvm->nmemslots; ++i)
270 kvm_free_physmem_slot(&kvm->memslots[i], 0); 270 kvm_free_physmem_slot(&kvm->memslots[i], NULL);
271} 271}
272 272
273static void kvm_free_vcpu(struct kvm_vcpu *vcpu) 273static void kvm_free_vcpu(struct kvm_vcpu *vcpu)
@@ -640,11 +640,11 @@ raced:
640 640
641 /* Deallocate if slot is being removed */ 641 /* Deallocate if slot is being removed */
642 if (!npages) 642 if (!npages)
643 new.phys_mem = 0; 643 new.phys_mem = NULL;
644 644
645 /* Free page dirty bitmap if unneeded */ 645 /* Free page dirty bitmap if unneeded */
646 if (!(new.flags & KVM_MEM_LOG_DIRTY_PAGES)) 646 if (!(new.flags & KVM_MEM_LOG_DIRTY_PAGES))
647 new.dirty_bitmap = 0; 647 new.dirty_bitmap = NULL;
648 648
649 r = -ENOMEM; 649 r = -ENOMEM;
650 650
@@ -799,14 +799,14 @@ struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn)
799 && gfn < memslot->base_gfn + memslot->npages) 799 && gfn < memslot->base_gfn + memslot->npages)
800 return memslot; 800 return memslot;
801 } 801 }
802 return 0; 802 return NULL;
803} 803}
804EXPORT_SYMBOL_GPL(gfn_to_memslot); 804EXPORT_SYMBOL_GPL(gfn_to_memslot);
805 805
806void mark_page_dirty(struct kvm *kvm, gfn_t gfn) 806void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
807{ 807{
808 int i; 808 int i;
809 struct kvm_memory_slot *memslot = 0; 809 struct kvm_memory_slot *memslot = NULL;
810 unsigned long rel_gfn; 810 unsigned long rel_gfn;
811 811
812 for (i = 0; i < kvm->nmemslots; ++i) { 812 for (i = 0; i < kvm->nmemslots; ++i) {
@@ -1778,6 +1778,7 @@ static long kvm_dev_ioctl(struct file *filp,
1778 unsigned int ioctl, unsigned long arg) 1778 unsigned int ioctl, unsigned long arg)
1779{ 1779{
1780 struct kvm *kvm = filp->private_data; 1780 struct kvm *kvm = filp->private_data;
1781 void __user *argp = (void __user *)arg;
1781 int r = -EINVAL; 1782 int r = -EINVAL;
1782 1783
1783 switch (ioctl) { 1784 switch (ioctl) {
@@ -1794,12 +1795,12 @@ static long kvm_dev_ioctl(struct file *filp,
1794 struct kvm_run kvm_run; 1795 struct kvm_run kvm_run;
1795 1796
1796 r = -EFAULT; 1797 r = -EFAULT;
1797 if (copy_from_user(&kvm_run, (void *)arg, sizeof kvm_run)) 1798 if (copy_from_user(&kvm_run, argp, sizeof kvm_run))
1798 goto out; 1799 goto out;
1799 r = kvm_dev_ioctl_run(kvm, &kvm_run); 1800 r = kvm_dev_ioctl_run(kvm, &kvm_run);
1800 if (r < 0 && r != -EINTR) 1801 if (r < 0 && r != -EINTR)
1801 goto out; 1802 goto out;
1802 if (copy_to_user((void *)arg, &kvm_run, sizeof kvm_run)) { 1803 if (copy_to_user(argp, &kvm_run, sizeof kvm_run)) {
1803 r = -EFAULT; 1804 r = -EFAULT;
1804 goto out; 1805 goto out;
1805 } 1806 }
@@ -1809,13 +1810,13 @@ static long kvm_dev_ioctl(struct file *filp,
1809 struct kvm_regs kvm_regs; 1810 struct kvm_regs kvm_regs;
1810 1811
1811 r = -EFAULT; 1812 r = -EFAULT;
1812 if (copy_from_user(&kvm_regs, (void *)arg, sizeof kvm_regs)) 1813 if (copy_from_user(&kvm_regs, argp, sizeof kvm_regs))
1813 goto out; 1814 goto out;
1814 r = kvm_dev_ioctl_get_regs(kvm, &kvm_regs); 1815 r = kvm_dev_ioctl_get_regs(kvm, &kvm_regs);
1815 if (r) 1816 if (r)
1816 goto out; 1817 goto out;
1817 r = -EFAULT; 1818 r = -EFAULT;
1818 if (copy_to_user((void *)arg, &kvm_regs, sizeof kvm_regs)) 1819 if (copy_to_user(argp, &kvm_regs, sizeof kvm_regs))
1819 goto out; 1820 goto out;
1820 r = 0; 1821 r = 0;
1821 break; 1822 break;
@@ -1824,7 +1825,7 @@ static long kvm_dev_ioctl(struct file *filp,
1824 struct kvm_regs kvm_regs; 1825 struct kvm_regs kvm_regs;
1825 1826
1826 r = -EFAULT; 1827 r = -EFAULT;
1827 if (copy_from_user(&kvm_regs, (void *)arg, sizeof kvm_regs)) 1828 if (copy_from_user(&kvm_regs, argp, sizeof kvm_regs))
1828 goto out; 1829 goto out;
1829 r = kvm_dev_ioctl_set_regs(kvm, &kvm_regs); 1830 r = kvm_dev_ioctl_set_regs(kvm, &kvm_regs);
1830 if (r) 1831 if (r)
@@ -1836,13 +1837,13 @@ static long kvm_dev_ioctl(struct file *filp,
1836 struct kvm_sregs kvm_sregs; 1837 struct kvm_sregs kvm_sregs;
1837 1838
1838 r = -EFAULT; 1839 r = -EFAULT;
1839 if (copy_from_user(&kvm_sregs, (void *)arg, sizeof kvm_sregs)) 1840 if (copy_from_user(&kvm_sregs, argp, sizeof kvm_sregs))
1840 goto out; 1841 goto out;
1841 r = kvm_dev_ioctl_get_sregs(kvm, &kvm_sregs); 1842 r = kvm_dev_ioctl_get_sregs(kvm, &kvm_sregs);
1842 if (r) 1843 if (r)
1843 goto out; 1844 goto out;
1844 r = -EFAULT; 1845 r = -EFAULT;
1845 if (copy_to_user((void *)arg, &kvm_sregs, sizeof kvm_sregs)) 1846 if (copy_to_user(argp, &kvm_sregs, sizeof kvm_sregs))
1846 goto out; 1847 goto out;
1847 r = 0; 1848 r = 0;
1848 break; 1849 break;
@@ -1851,7 +1852,7 @@ static long kvm_dev_ioctl(struct file *filp,
1851 struct kvm_sregs kvm_sregs; 1852 struct kvm_sregs kvm_sregs;
1852 1853
1853 r = -EFAULT; 1854 r = -EFAULT;
1854 if (copy_from_user(&kvm_sregs, (void *)arg, sizeof kvm_sregs)) 1855 if (copy_from_user(&kvm_sregs, argp, sizeof kvm_sregs))
1855 goto out; 1856 goto out;
1856 r = kvm_dev_ioctl_set_sregs(kvm, &kvm_sregs); 1857 r = kvm_dev_ioctl_set_sregs(kvm, &kvm_sregs);
1857 if (r) 1858 if (r)
@@ -1863,13 +1864,13 @@ static long kvm_dev_ioctl(struct file *filp,
1863 struct kvm_translation tr; 1864 struct kvm_translation tr;
1864 1865
1865 r = -EFAULT; 1866 r = -EFAULT;
1866 if (copy_from_user(&tr, (void *)arg, sizeof tr)) 1867 if (copy_from_user(&tr, argp, sizeof tr))
1867 goto out; 1868 goto out;
1868 r = kvm_dev_ioctl_translate(kvm, &tr); 1869 r = kvm_dev_ioctl_translate(kvm, &tr);
1869 if (r) 1870 if (r)
1870 goto out; 1871 goto out;
1871 r = -EFAULT; 1872 r = -EFAULT;
1872 if (copy_to_user((void *)arg, &tr, sizeof tr)) 1873 if (copy_to_user(argp, &tr, sizeof tr))
1873 goto out; 1874 goto out;
1874 r = 0; 1875 r = 0;
1875 break; 1876 break;
@@ -1878,7 +1879,7 @@ static long kvm_dev_ioctl(struct file *filp,
1878 struct kvm_interrupt irq; 1879 struct kvm_interrupt irq;
1879 1880
1880 r = -EFAULT; 1881 r = -EFAULT;
1881 if (copy_from_user(&irq, (void *)arg, sizeof irq)) 1882 if (copy_from_user(&irq, argp, sizeof irq))
1882 goto out; 1883 goto out;
1883 r = kvm_dev_ioctl_interrupt(kvm, &irq); 1884 r = kvm_dev_ioctl_interrupt(kvm, &irq);
1884 if (r) 1885 if (r)
@@ -1890,7 +1891,7 @@ static long kvm_dev_ioctl(struct file *filp,
1890 struct kvm_debug_guest dbg; 1891 struct kvm_debug_guest dbg;
1891 1892
1892 r = -EFAULT; 1893 r = -EFAULT;
1893 if (copy_from_user(&dbg, (void *)arg, sizeof dbg)) 1894 if (copy_from_user(&dbg, argp, sizeof dbg))
1894 goto out; 1895 goto out;
1895 r = kvm_dev_ioctl_debug_guest(kvm, &dbg); 1896 r = kvm_dev_ioctl_debug_guest(kvm, &dbg);
1896 if (r) 1897 if (r)
@@ -1902,7 +1903,7 @@ static long kvm_dev_ioctl(struct file *filp,
1902 struct kvm_memory_region kvm_mem; 1903 struct kvm_memory_region kvm_mem;
1903 1904
1904 r = -EFAULT; 1905 r = -EFAULT;
1905 if (copy_from_user(&kvm_mem, (void *)arg, sizeof kvm_mem)) 1906 if (copy_from_user(&kvm_mem, argp, sizeof kvm_mem))
1906 goto out; 1907 goto out;
1907 r = kvm_dev_ioctl_set_memory_region(kvm, &kvm_mem); 1908 r = kvm_dev_ioctl_set_memory_region(kvm, &kvm_mem);
1908 if (r) 1909 if (r)
@@ -1913,7 +1914,7 @@ static long kvm_dev_ioctl(struct file *filp,
1913 struct kvm_dirty_log log; 1914 struct kvm_dirty_log log;
1914 1915
1915 r = -EFAULT; 1916 r = -EFAULT;
1916 if (copy_from_user(&log, (void *)arg, sizeof log)) 1917 if (copy_from_user(&log, argp, sizeof log))
1917 goto out; 1918 goto out;
1918 r = kvm_dev_ioctl_get_dirty_log(kvm, &log); 1919 r = kvm_dev_ioctl_get_dirty_log(kvm, &log);
1919 if (r) 1920 if (r)
@@ -1921,13 +1922,13 @@ static long kvm_dev_ioctl(struct file *filp,
1921 break; 1922 break;
1922 } 1923 }
1923 case KVM_GET_MSRS: 1924 case KVM_GET_MSRS:
1924 r = msr_io(kvm, (void __user *)arg, get_msr, 1); 1925 r = msr_io(kvm, argp, get_msr, 1);
1925 break; 1926 break;
1926 case KVM_SET_MSRS: 1927 case KVM_SET_MSRS:
1927 r = msr_io(kvm, (void __user *)arg, do_set_msr, 0); 1928 r = msr_io(kvm, argp, do_set_msr, 0);
1928 break; 1929 break;
1929 case KVM_GET_MSR_INDEX_LIST: { 1930 case KVM_GET_MSR_INDEX_LIST: {
1930 struct kvm_msr_list __user *user_msr_list = (void __user *)arg; 1931 struct kvm_msr_list __user *user_msr_list = argp;
1931 struct kvm_msr_list msr_list; 1932 struct kvm_msr_list msr_list;
1932 unsigned n; 1933 unsigned n;
1933 1934
@@ -2014,7 +2015,7 @@ static int kvm_reboot(struct notifier_block *notifier, unsigned long val,
2014 * in vmx root mode. 2015 * in vmx root mode.
2015 */ 2016 */
2016 printk(KERN_INFO "kvm: exiting hardware virtualization\n"); 2017 printk(KERN_INFO "kvm: exiting hardware virtualization\n");
2017 on_each_cpu(kvm_arch_ops->hardware_disable, 0, 0, 1); 2018 on_each_cpu(kvm_arch_ops->hardware_disable, NULL, 0, 1);
2018 } 2019 }
2019 return NOTIFY_OK; 2020 return NOTIFY_OK;
2020} 2021}
@@ -2028,7 +2029,7 @@ static __init void kvm_init_debug(void)
2028{ 2029{
2029 struct kvm_stats_debugfs_item *p; 2030 struct kvm_stats_debugfs_item *p;
2030 2031
2031 debugfs_dir = debugfs_create_dir("kvm", 0); 2032 debugfs_dir = debugfs_create_dir("kvm", NULL);
2032 for (p = debugfs_entries; p->name; ++p) 2033 for (p = debugfs_entries; p->name; ++p)
2033 p->dentry = debugfs_create_u32(p->name, 0444, debugfs_dir, 2034 p->dentry = debugfs_create_u32(p->name, 0444, debugfs_dir,
2034 p->data); 2035 p->data);
@@ -2069,7 +2070,7 @@ int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module)
2069 if (r < 0) 2070 if (r < 0)
2070 return r; 2071 return r;
2071 2072
2072 on_each_cpu(kvm_arch_ops->hardware_enable, 0, 0, 1); 2073 on_each_cpu(kvm_arch_ops->hardware_enable, NULL, 0, 1);
2073 register_reboot_notifier(&kvm_reboot_notifier); 2074 register_reboot_notifier(&kvm_reboot_notifier);
2074 2075
2075 kvm_chardev_ops.owner = module; 2076 kvm_chardev_ops.owner = module;
@@ -2084,7 +2085,7 @@ int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module)
2084 2085
2085out_free: 2086out_free:
2086 unregister_reboot_notifier(&kvm_reboot_notifier); 2087 unregister_reboot_notifier(&kvm_reboot_notifier);
2087 on_each_cpu(kvm_arch_ops->hardware_disable, 0, 0, 1); 2088 on_each_cpu(kvm_arch_ops->hardware_disable, NULL, 0, 1);
2088 kvm_arch_ops->hardware_unsetup(); 2089 kvm_arch_ops->hardware_unsetup();
2089 return r; 2090 return r;
2090} 2091}
@@ -2094,7 +2095,7 @@ void kvm_exit_arch(void)
2094 misc_deregister(&kvm_dev); 2095 misc_deregister(&kvm_dev);
2095 2096
2096 unregister_reboot_notifier(&kvm_reboot_notifier); 2097 unregister_reboot_notifier(&kvm_reboot_notifier);
2097 on_each_cpu(kvm_arch_ops->hardware_disable, 0, 0, 1); 2098 on_each_cpu(kvm_arch_ops->hardware_disable, NULL, 0, 1);
2098 kvm_arch_ops->hardware_unsetup(); 2099 kvm_arch_ops->hardware_unsetup();
2099 kvm_arch_ops = NULL; 2100 kvm_arch_ops = NULL;
2100} 2101}
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c
index 22c426cd8cb2..be793770f31b 100644
--- a/drivers/kvm/mmu.c
+++ b/drivers/kvm/mmu.c
@@ -333,7 +333,7 @@ static void rmap_desc_remove_entry(struct kvm_vcpu *vcpu,
333 for (j = RMAP_EXT - 1; !desc->shadow_ptes[j] && j > i; --j) 333 for (j = RMAP_EXT - 1; !desc->shadow_ptes[j] && j > i; --j)
334 ; 334 ;
335 desc->shadow_ptes[i] = desc->shadow_ptes[j]; 335 desc->shadow_ptes[i] = desc->shadow_ptes[j];
336 desc->shadow_ptes[j] = 0; 336 desc->shadow_ptes[j] = NULL;
337 if (j != 0) 337 if (j != 0)
338 return; 338 return;
339 if (!prev_desc && !desc->more) 339 if (!prev_desc && !desc->more)
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index c79df79307ed..85f61dd1e936 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -274,7 +274,7 @@ static void svm_hardware_disable(void *garbage)
274 wrmsrl(MSR_VM_HSAVE_PA, 0); 274 wrmsrl(MSR_VM_HSAVE_PA, 0);
275 rdmsrl(MSR_EFER, efer); 275 rdmsrl(MSR_EFER, efer);
276 wrmsrl(MSR_EFER, efer & ~MSR_EFER_SVME_MASK); 276 wrmsrl(MSR_EFER, efer & ~MSR_EFER_SVME_MASK);
277 per_cpu(svm_data, raw_smp_processor_id()) = 0; 277 per_cpu(svm_data, raw_smp_processor_id()) = NULL;
278 __free_page(svm_data->save_area); 278 __free_page(svm_data->save_area);
279 kfree(svm_data); 279 kfree(svm_data);
280 } 280 }
@@ -642,7 +642,7 @@ static struct vmcb_seg *svm_seg(struct kvm_vcpu *vcpu, int seg)
642 case VCPU_SREG_LDTR: return &save->ldtr; 642 case VCPU_SREG_LDTR: return &save->ldtr;
643 } 643 }
644 BUG(); 644 BUG();
645 return 0; 645 return NULL;
646} 646}
647 647
648static u64 svm_get_segment_base(struct kvm_vcpu *vcpu, int seg) 648static u64 svm_get_segment_base(struct kvm_vcpu *vcpu, int seg)
@@ -934,7 +934,7 @@ static int io_get_override(struct kvm_vcpu *vcpu,
934 return 0; 934 return 0;
935 935
936 *addr_override = 0; 936 *addr_override = 0;
937 *seg = 0; 937 *seg = NULL;
938 for (i = 0; i < ins_length; i++) 938 for (i = 0; i < ins_length; i++)
939 switch (inst[i]) { 939 switch (inst[i]) {
940 case 0xf0: 940 case 0xf0:
@@ -1087,7 +1087,7 @@ static int cpuid_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1087 1087
1088static int emulate_on_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 1088static int emulate_on_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1089{ 1089{
1090 if (emulate_instruction(vcpu, 0, 0, 0) != EMULATE_DONE) 1090 if (emulate_instruction(vcpu, NULL, 0, 0) != EMULATE_DONE)
1091 printk(KERN_ERR "%s: failed\n", __FUNCTION__); 1091 printk(KERN_ERR "%s: failed\n", __FUNCTION__);
1092 return 1; 1092 return 1;
1093} 1093}
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 54c35c0b3181..27e05a77e21a 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -98,7 +98,7 @@ static struct vmx_msr_entry *find_msr_entry(struct kvm_vcpu *vcpu, u32 msr)
98 for (i = 0; i < vcpu->nmsrs; ++i) 98 for (i = 0; i < vcpu->nmsrs; ++i)
99 if (vcpu->guest_msrs[i].index == msr) 99 if (vcpu->guest_msrs[i].index == msr)
100 return &vcpu->guest_msrs[i]; 100 return &vcpu->guest_msrs[i];
101 return 0; 101 return NULL;
102} 102}
103 103
104static void vmcs_clear(struct vmcs *vmcs) 104static void vmcs_clear(struct vmcs *vmcs)