Re: [PATCH 3/3] KVM: For the symbols used locally only should bestatic type.
On 13/03/2015 21:37, Christian Borntraeger wrote: Am 13.03.2015 um 10:39 schrieb Xiubo Li: This patch fix the following sparse warnings: for file virt/kvm/kvm_main.c: warning: symbol 'halt_poll_ns' was not declared. Should it be static? Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index a109370..a23d2ba 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -66,7 +66,7 @@ MODULE_AUTHOR(Qumranet); MODULE_LICENSE(GPL); -unsigned int halt_poll_ns = 0; +static unsigned int halt_poll_ns; module_param(halt_poll_ns, uint, S_IRUGO | S_IWUSR); /* This change is already part of kvm/queue https://git.kernel.org/cgit/virt/kvm/kvm.git/commit/?h=queueid=0fa9778895635ab3824caf34fd573562dd2b999c Yes, right, before this patch, i had already synced the newest version, but didn't find this patch. I will abandon it. Thanks, BRs Xiubo -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3] KVM: X86: Avoid using plain integer as NULL pointer warning.
This patch fix the following sparse warning: for file arch/x86/kvm/x86.c: warning: Using plain integer as NULL pointer Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index bd7a70b..1e2e9b4 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5904,7 +5904,7 @@ static void kvm_pv_kick_cpu_op(struct kvm *kvm, unsigned long flags, int apicid) lapic_irq.dest_id = apicid; lapic_irq.delivery_mode = APIC_DM_REMRD; - kvm_irq_delivery_to_apic(kvm, 0, lapic_irq, NULL); + kvm_irq_delivery_to_apic(kvm, NULL, lapic_irq, NULL); } int kvm_emulate_hypercall(struct kvm_vcpu *vcpu) -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/3] KVM: Fix sparse warnings.
Using the command like: 'make C=1 ', the sparse tool will complain about warnings like: warning: symbol 'XXX' was not declared. Should it be static? warning: Using plain integer as NULL pointer ... And also, if the symbols will only used locally, shouldn't it be static? Xiubo Li (3): KVM: X86: Avoid using plain integer as NULL pointer warning. KVM: X86: For the symbols used locally only should be static type. KVM: For the symbols used locally only should be static type. arch/x86/kvm/pmu.c | 2 +- arch/x86/kvm/svm.c | 3 ++- arch/x86/kvm/x86.c | 13 - virt/kvm/kvm_main.c | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] KVM: For the symbols used locally only should be static type.
This patch fix the following sparse warnings: for file virt/kvm/kvm_main.c: warning: symbol 'halt_poll_ns' was not declared. Should it be static? Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index a109370..a23d2ba 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -66,7 +66,7 @@ MODULE_AUTHOR(Qumranet); MODULE_LICENSE(GPL); -unsigned int halt_poll_ns = 0; +static unsigned int halt_poll_ns; module_param(halt_poll_ns, uint, S_IRUGO | S_IWUSR); /* -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] KVM: X86: For the symbols used locally only should be static type.
This patch fix the following sparse warnings: for arch/x86/kvm/x86.c: warning: symbol 'emulator_read_write' was not declared. Should it be static? warning: symbol 'emulator_write_emulated' was not declared. Should it be static? warning: symbol 'emulator_get_dr' was not declared. Should it be static? warning: symbol 'emulator_set_dr' was not declared. Should it be static? for arch/x86/kvm/pmu.c: warning: symbol 'fixed_pmc_events' was not declared. Should it be static? Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- arch/x86/kvm/pmu.c | 2 +- arch/x86/kvm/svm.c | 3 ++- arch/x86/kvm/x86.c | 11 +++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c index 8e6b7d8..29fbf9d 100644 --- a/arch/x86/kvm/pmu.c +++ b/arch/x86/kvm/pmu.c @@ -38,7 +38,7 @@ static struct kvm_arch_event_perf_mapping { }; /* mapping between fixed pmc index and arch_events array */ -int fixed_pmc_events[] = {1, 0, 7}; +static int fixed_pmc_events[] = {1, 0, 7}; static bool pmc_is_gp(struct kvm_pmc *pmc) { diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index d319e0c..fa675d3 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -2902,7 +2902,8 @@ static int rdpmc_interception(struct vcpu_svm *svm) return 1; } -bool check_selective_cr0_intercepted(struct vcpu_svm *svm, unsigned long val) +static bool check_selective_cr0_intercepted(struct vcpu_svm *svm, + unsigned long val) { unsigned long cr0 = svm-vcpu.arch.cr0; bool ret = false; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 1e2e9b4..3af4651 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4476,7 +4476,8 @@ mmio: return X86EMUL_CONTINUE; } -int emulator_read_write(struct x86_emulate_ctxt *ctxt, unsigned long addr, +static int emulator_read_write(struct x86_emulate_ctxt *ctxt, + unsigned long addr, void *val, unsigned int bytes, struct x86_exception *exception, const struct read_write_emulator_ops *ops) @@ -4539,7 +4540,7 @@ static int emulator_read_emulated(struct x86_emulate_ctxt *ctxt, exception, read_emultor); } -int emulator_write_emulated(struct x86_emulate_ctxt *ctxt, +static int emulator_write_emulated(struct x86_emulate_ctxt *ctxt, unsigned long addr, const void *val, unsigned int bytes, @@ -4730,12 +4731,14 @@ static void emulator_wbinvd(struct x86_emulate_ctxt *ctxt) kvm_emulate_wbinvd(emul_to_vcpu(ctxt)); } -int emulator_get_dr(struct x86_emulate_ctxt *ctxt, int dr, unsigned long *dest) +static int emulator_get_dr(struct x86_emulate_ctxt *ctxt, int dr, + unsigned long *dest) { return kvm_get_dr(emul_to_vcpu(ctxt), dr, dest); } -int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr, unsigned long value) +static int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr, + unsigned long value) { return __kvm_set_dr(emul_to_vcpu(ctxt), dr, value); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv2 0/9] Fix possible warnings and errors for kvm_main.c
On 10/03/2015 07:07, Marcelo Tosatti wrote: On Fri, Feb 27, 2015 at 03:18:17PM +0800, Xiubo Li wrote: There are to much warning/error noise in kvm_main.c when gernerating and checking new patches. This patch series fix most of these warnings and errors to reduce possible noise. Change in v2: - Accept Thomas Huth's advice of using pr_info instead of printk to avoid exceeding the 80 columns limit. I applied v1 of the series by modifying the last patch. Thanks very much. BRs Xiubo Thanks. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCHv2 5/9] Fix WARNING:EXPORT_SYMBOL(x) should immediately.. in kvm_main.c
WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable +EXPORT_SYMBOL_GPL(gfn_to_page); This patch fixes these warnings to reduce noise when checking new patches in kvm_main.c. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index ba5355c..5761b3a 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1481,7 +1481,6 @@ struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn) return kvm_pfn_to_page(pfn); } - EXPORT_SYMBOL_GPL(gfn_to_page); void kvm_release_page_clean(struct page *page) -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCHv2 1/9] Fix WARNING: quoted string split across lines in kvm_main.c
WARNING: quoted string split across lines + printk(KERN_INFO kvm: enabling virtualization on +CPU%d failed\n, cpu); When fails to enable virtualization on CPUx for kvm, this log will be output in only one line, and it will be a little confusing for us to grep this log in kernel source code. In some case, the user maybe using on script to searching the error log in kernel source code, if so, won't it always fail? So this patch fix this issue. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index a109370..62c80fe 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2817,12 +2817,10 @@ static void hardware_enable_nolock(void *junk) cpumask_set_cpu(cpu, cpus_hardware_enabled); r = kvm_arch_hardware_enable(); - if (r) { cpumask_clear_cpu(cpu, cpus_hardware_enabled); atomic_inc(hardware_enable_failed); - printk(KERN_INFO kvm: enabling virtualization on -CPU%d failed\n, cpu); + pr_info(kvm: enabling virtualization on CPU%d failed\n, cpu); } } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCHv2 9/9] Fix WARNINGs about using printk drectly in kvm_main.c
WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ... + printk(KERN_INFO kvm: exiting hardware virtualization\n); WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then pr_err(... to printk(KERN_ERR ... + printk(KERN_ERR kvm: misc device register failed\n); Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 9e9a768..db931a5 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2900,13 +2900,11 @@ static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val, val = ~CPU_TASKS_FROZEN; switch (val) { case CPU_DYING: - printk(KERN_INFO kvm: disabling virtualization on CPU%d\n, - cpu); + pr_info(kvm: disabling virtualization on CPU%d\n, cpu); hardware_disable(); break; case CPU_STARTING: - printk(KERN_INFO kvm: enabling virtualization on CPU%d\n, - cpu); + pr_info(kvm: enabling virtualization on CPU%d\n, cpu); hardware_enable(); break; } @@ -2922,7 +2920,7 @@ static int kvm_reboot(struct notifier_block *notifier, unsigned long val, * * And Intel TXT required VMX off for all cpu when system shutdown. */ - printk(KERN_INFO kvm: exiting hardware virtualization\n); + pr_info(kvm: exiting hardware virtualization\n); kvm_rebooting = true; on_each_cpu(hardware_disable_nolock, NULL, 1); return NOTIFY_OK; @@ -3352,7 +3350,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, r = misc_register(kvm_dev); if (r) { - printk(KERN_ERR kvm: misc device register failed\n); + pr_err(kvm: misc device register failed\n); goto out_unreg; } @@ -3363,7 +3361,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, r = kvm_init_debug(); if (r) { - printk(KERN_ERR kvm: create debugfs files failed\n); + pr_err(kvm: create debugfs files failed\n); goto out_undebugfs; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCHv2 0/9] Fix possible warnings and errors for kvm_main.c
There are to much warning/error noise in kvm_main.c when gernerating and checking new patches. This patch series fix most of these warnings and errors to reduce possible noise. Change in v2: - Accept Thomas Huth's advice of using pr_info instead of printk to avoid exceeding the 80 columns limit. Xiubo Li (9): Fix WARNING: quoted string split across lines in kvm_main.c Fix WARNINGs for 'sizeof(X)' instead of 'sizeof X' in kvm_main.c Fix WARNING: labels should not be indented in kvm_main.c Fix ERROR:do not initialise statics to 0 or NULL in kvm_main.c Fix WARNING:EXPORT_SYMBOL(x) should immediately.. in kvm_main.c Fix WARNINGs:Missing blank line after declarationgs in kvm_main.c Fix WARNINGs:please, no space before tabs in kvm_main.c Fix ERROR WARNING for better alignment in kvm_main.c Fix WARNINGs about using printk drectly in kvm_main.c virt/kvm/kvm_main.c | 75 +++-- 1 file changed, 38 insertions(+), 37 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCHv2 8/9] Fix ERROR WARNING for better alignment in kvm_main.c
ERROR: code indent should use tabs where possible + const struct kvm_io_range *r2)$ WARNING: please, no spaces at the start of a line + const struct kvm_io_range *r2)$ This patch fixes this ERROR WARNING to reduce noise when checking new patches in kvm_main.c. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index fb8a556..9e9a768 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2946,7 +2946,7 @@ static void kvm_io_bus_destroy(struct kvm_io_bus *bus) } static inline int kvm_io_bus_cmp(const struct kvm_io_range *r1, - const struct kvm_io_range *r2) +const struct kvm_io_range *r2) { if (r1-addr r2-addr) return -1; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCHv2 4/9] Fix ERROR:do not initialise statics to 0 or NULL in kvm_main.c
ERROR: do not initialise statics to 0 or NULL +static int kvm_usage_count = 0; The kvm_usage_count will be placed to .bss segment when linking, so not need to set it to 0 here obviously. This patch fixes this ERROR to reduce noise when checking new patches in kvm_main.c. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index cb1c187..ba5355c 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -80,7 +80,7 @@ static DEFINE_RAW_SPINLOCK(kvm_count_lock); LIST_HEAD(vm_list); static cpumask_var_t cpus_hardware_enabled; -static int kvm_usage_count = 0; +static int kvm_usage_count; static atomic_t hardware_enable_failed; struct kmem_cache *kvm_vcpu_cache; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCHv2 7/9] Fix WARNINGs:please, no space before tabs in kvm_main.c
WARNING: please, no space before tabs + * ^I^Ikvm-lock -- kvm-slots_lock -- kvm-irq_lock$ WARNING: please, no space before tabs +^I^I * ^I- gfn_to_hva (kvm_read_guest, gfn_to_pfn)$ WARNING: please, no space before tabs +^I^I * ^I- kvm_is_visible_gfn (mmu_check_roots)$ This patch fixes these warnings to reduce noise when checking new patches in kvm_main.c. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index c6106f2..fb8a556 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -72,7 +72,7 @@ module_param(halt_poll_ns, uint, S_IRUGO | S_IWUSR); /* * Ordering of locks: * - * kvm-lock -- kvm-slots_lock -- kvm-irq_lock + * kvm-lock -- kvm-slots_lock -- kvm-irq_lock */ DEFINE_SPINLOCK(kvm_lock); @@ -888,8 +888,8 @@ int __kvm_set_memory_region(struct kvm *kvm, * or moved, memslot will be created. * * validation of sp-gfn happens in: -* - gfn_to_hva (kvm_read_guest, gfn_to_pfn) -* - kvm_is_visible_gfn (mmu_check_roots) +* - gfn_to_hva (kvm_read_guest, gfn_to_pfn) +* - kvm_is_visible_gfn (mmu_check_roots) */ kvm_arch_flush_shadow_memslot(kvm, slot); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCHv2 2/9] Fix WARNINGs for 'sizeof(X)' instead of 'sizeof X' in kvm_main.c
There are many WARNINGs like this: WARNING: sizeof tr should be sizeof(tr) + if (copy_from_user(tr, argp, sizeof tr)) In kvm_main.c many places are using 'sizeof(X)', and the other places are using 'sizeof X', while the kernel recommands to use 'sizeof(X)', so this patch will replace all 'sizeof X' to 'sizeof(X)' to make them consistent and at the same time to reduce the WARNINGs noise when we are checking new patches. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 40 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 62c80fe..847de52 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2205,7 +2205,7 @@ out_free1: if (r) goto out; r = -EFAULT; - if (copy_to_user(argp, mp_state, sizeof mp_state)) + if (copy_to_user(argp, mp_state, sizeof(mp_state))) goto out; r = 0; break; @@ -2214,7 +2214,7 @@ out_free1: struct kvm_mp_state mp_state; r = -EFAULT; - if (copy_from_user(mp_state, argp, sizeof mp_state)) + if (copy_from_user(mp_state, argp, sizeof(mp_state))) goto out; r = kvm_arch_vcpu_ioctl_set_mpstate(vcpu, mp_state); break; @@ -2223,13 +2223,13 @@ out_free1: struct kvm_translation tr; r = -EFAULT; - if (copy_from_user(tr, argp, sizeof tr)) + if (copy_from_user(tr, argp, sizeof(tr))) goto out; r = kvm_arch_vcpu_ioctl_translate(vcpu, tr); if (r) goto out; r = -EFAULT; - if (copy_to_user(argp, tr, sizeof tr)) + if (copy_to_user(argp, tr, sizeof(tr))) goto out; r = 0; break; @@ -2238,7 +2238,7 @@ out_free1: struct kvm_guest_debug dbg; r = -EFAULT; - if (copy_from_user(dbg, argp, sizeof dbg)) + if (copy_from_user(dbg, argp, sizeof(dbg))) goto out; r = kvm_arch_vcpu_ioctl_set_guest_debug(vcpu, dbg); break; @@ -2252,14 +2252,14 @@ out_free1: if (argp) { r = -EFAULT; if (copy_from_user(kvm_sigmask, argp, - sizeof kvm_sigmask)) + sizeof(kvm_sigmask))) goto out; r = -EINVAL; - if (kvm_sigmask.len != sizeof sigset) + if (kvm_sigmask.len != sizeof(sigset)) goto out; r = -EFAULT; if (copy_from_user(sigset, sigmask_arg-sigset, - sizeof sigset)) + sizeof(sigset))) goto out; p = sigset; } @@ -2321,14 +2321,14 @@ static long kvm_vcpu_compat_ioctl(struct file *filp, if (argp) { r = -EFAULT; if (copy_from_user(kvm_sigmask, argp, - sizeof kvm_sigmask)) + sizeof(kvm_sigmask))) goto out; r = -EINVAL; - if (kvm_sigmask.len != sizeof csigset) + if (kvm_sigmask.len != sizeof(csigset)) goto out; r = -EFAULT; if (copy_from_user(csigset, sigmask_arg-sigset, - sizeof csigset)) + sizeof(csigset))) goto out; sigset_from_compat(sigset, csigset); r = kvm_vcpu_ioctl_set_sigmask(vcpu, sigset); @@ -2524,7 +2524,7 @@ static long kvm_vm_ioctl(struct file *filp, r = -EFAULT; if (copy_from_user(kvm_userspace_mem, argp, - sizeof kvm_userspace_mem)) + sizeof(kvm_userspace_mem))) goto out; r = kvm_vm_ioctl_set_memory_region(kvm, kvm_userspace_mem); @@ -2534,7 +2534,7 @@ static long kvm_vm_ioctl(struct file *filp, struct kvm_dirty_log log; r = -EFAULT; - if (copy_from_user(log, argp, sizeof log)) + if (copy_from_user(log, argp, sizeof(log))) goto out; r
[PATCHv2 6/9] Fix WARNINGs:Missing blank line after declarationgs in kvm_main.c
There are many Warnings like this: WARNING: Missing a blank line after declarations + struct kvm_coalesced_mmio_zone zone; + r = -EFAULT; This patch fixes these warnings to reduce noise when checking new patches in kvm_main.c. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 5761b3a..c6106f2 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1516,6 +1516,7 @@ void kvm_set_pfn_dirty(pfn_t pfn) { if (!kvm_is_reserved_pfn(pfn)) { struct page *page = pfn_to_page(pfn); + if (!PageReserved(page)) SetPageDirty(page); } @@ -1799,6 +1800,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) start = cur = ktime_get(); if (halt_poll_ns) { ktime_t stop = ktime_add_ns(ktime_get(), halt_poll_ns); + do { /* * This sets KVM_REQ_UNHALT if an interrupt @@ -2134,6 +2136,7 @@ static long kvm_vcpu_ioctl(struct file *filp, /* The thread running this VCPU changed. */ struct pid *oldpid = vcpu-pid; struct pid *newpid = get_task_pid(current, PIDTYPE_PID); + rcu_assign_pointer(vcpu-pid, newpid); if (oldpid) synchronize_rcu(); @@ -2541,6 +2544,7 @@ static long kvm_vm_ioctl(struct file *filp, #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET case KVM_REGISTER_COALESCED_MMIO: { struct kvm_coalesced_mmio_zone zone; + r = -EFAULT; if (copy_from_user(zone, argp, sizeof(zone))) goto out; @@ -2549,6 +2553,7 @@ static long kvm_vm_ioctl(struct file *filp, } case KVM_UNREGISTER_COALESCED_MMIO: { struct kvm_coalesced_mmio_zone zone; + r = -EFAULT; if (copy_from_user(zone, argp, sizeof(zone))) goto out; @@ -3265,6 +3270,7 @@ struct kvm_vcpu *preempt_notifier_to_vcpu(struct preempt_notifier *pn) static void kvm_sched_in(struct preempt_notifier *pn, int cpu) { struct kvm_vcpu *vcpu = preempt_notifier_to_vcpu(pn); + if (vcpu-preempted) vcpu-preempted = false; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCHv2 3/9] Fix WARNING: labels should not be indented in kvm_main.c
WARNING: labels should not be indented + out_free_irq_routing: This patch fixes this WARNING to reduce noise when checking new patches in kvm_main.c. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 847de52..cb1c187 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2646,7 +2646,7 @@ static long kvm_vm_ioctl(struct file *filp, goto out_free_irq_routing; r = kvm_set_irq_routing(kvm, entries, routing.nr, routing.flags); - out_free_irq_routing: +out_free_irq_routing: vfree(entries); break; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/9] Fix WARNING: quoted string split across lines inkvm_main.c
On 26/02/2015 15:24, Thomas Huth wrote: On Thu, 26 Feb 2015 14:58:18 +0800 Xiubo Li lixi...@cmss.chinamobile.com wrote: WARNING: quoted string split across lines + printk(KERN_INFO kvm: enabling virtualization on +CPU%d failed\n, cpu); When fails to enable virtualization on CPUx for kvm, this log will be output in only one line, and it will be a little confusing for us to grep this log in kernel source code. In some case, the user maybe using on script to searching the error log in kernel source code, if so, won't it always fail? So this patch fix this issue. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index a109370..3f08716 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2817,12 +2817,11 @@ static void hardware_enable_nolock(void *junk) cpumask_set_cpu(cpu, cpus_hardware_enabled); r = kvm_arch_hardware_enable(); - if (r) { cpumask_clear_cpu(cpu, cpus_hardware_enabled); atomic_inc(hardware_enable_failed); - printk(KERN_INFO kvm: enabling virtualization on -CPU%d failed\n, cpu); + printk(KERN_INFO kvm: enabling virtualization on CPU%d failed\n, + cpu); You could use pr_info() here instead of printk(KERN_INFO, ...) to avoid exceeding the 80 columns limit. Thomas Yes, agree. I have fix this in another patch later, but i think i should fix it in this patch at the same time. Thanks very much, BRs Xiubo -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] KVM: fix possible coalesced_mmio_ring page leaks.
On 25/02/2015 00:44, Marcelo Tosatti wrote: On Thu, Feb 12, 2015 at 12:58:21PM +0800, Xiubo Li wrote: It forgets to free coalesced_mmio_ring page after the anon_inode_getfd fails. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 8579f18..85e8106 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2784,16 +2784,22 @@ static int kvm_dev_ioctl_create_vm(unsigned long type) return PTR_ERR(kvm); #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET r = kvm_coalesced_mmio_init(kvm); - if (r 0) { - kvm_put_kvm(kvm); - return r; - } + if (r 0) + goto out_put_kvm; #endif r = anon_inode_getfd(kvm-vm, kvm_vm_fops, kvm, O_RDWR | O_CLOEXEC); if (r 0) - kvm_put_kvm(kvm); + goto out_mmio_free; kvm_put_kvm - kvm_destroy_vm - kvm_coalesced_mmio_free. Yes, it is. As in my mind that who use it, it will be whose duty to release it. Thanks, BRs Xiubo -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/9] Fix WARNINGs for 'sizeof(X)' instead of 'sizeof X' in kvm_main.c
There are many WARNINGs like this: WARNING: sizeof tr should be sizeof(tr) + if (copy_from_user(tr, argp, sizeof tr)) In kvm_main.c many places are using 'sizeof(X)', and the other places are using 'sizeof X', while the kernel recommands to use 'sizeof(X)', so this patch will replace all 'sizeof X' to 'sizeof(X)' to make them consistent and at the same time to reduce the WARNINGs noise when we are checking new patches. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 40 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 3f08716..a934998 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2205,7 +2205,7 @@ out_free1: if (r) goto out; r = -EFAULT; - if (copy_to_user(argp, mp_state, sizeof mp_state)) + if (copy_to_user(argp, mp_state, sizeof(mp_state))) goto out; r = 0; break; @@ -2214,7 +2214,7 @@ out_free1: struct kvm_mp_state mp_state; r = -EFAULT; - if (copy_from_user(mp_state, argp, sizeof mp_state)) + if (copy_from_user(mp_state, argp, sizeof(mp_state))) goto out; r = kvm_arch_vcpu_ioctl_set_mpstate(vcpu, mp_state); break; @@ -2223,13 +2223,13 @@ out_free1: struct kvm_translation tr; r = -EFAULT; - if (copy_from_user(tr, argp, sizeof tr)) + if (copy_from_user(tr, argp, sizeof(tr))) goto out; r = kvm_arch_vcpu_ioctl_translate(vcpu, tr); if (r) goto out; r = -EFAULT; - if (copy_to_user(argp, tr, sizeof tr)) + if (copy_to_user(argp, tr, sizeof(tr))) goto out; r = 0; break; @@ -2238,7 +2238,7 @@ out_free1: struct kvm_guest_debug dbg; r = -EFAULT; - if (copy_from_user(dbg, argp, sizeof dbg)) + if (copy_from_user(dbg, argp, sizeof(dbg))) goto out; r = kvm_arch_vcpu_ioctl_set_guest_debug(vcpu, dbg); break; @@ -2252,14 +2252,14 @@ out_free1: if (argp) { r = -EFAULT; if (copy_from_user(kvm_sigmask, argp, - sizeof kvm_sigmask)) + sizeof(kvm_sigmask))) goto out; r = -EINVAL; - if (kvm_sigmask.len != sizeof sigset) + if (kvm_sigmask.len != sizeof(sigset)) goto out; r = -EFAULT; if (copy_from_user(sigset, sigmask_arg-sigset, - sizeof sigset)) + sizeof(sigset))) goto out; p = sigset; } @@ -2321,14 +2321,14 @@ static long kvm_vcpu_compat_ioctl(struct file *filp, if (argp) { r = -EFAULT; if (copy_from_user(kvm_sigmask, argp, - sizeof kvm_sigmask)) + sizeof(kvm_sigmask))) goto out; r = -EINVAL; - if (kvm_sigmask.len != sizeof csigset) + if (kvm_sigmask.len != sizeof(csigset)) goto out; r = -EFAULT; if (copy_from_user(csigset, sigmask_arg-sigset, - sizeof csigset)) + sizeof(csigset))) goto out; sigset_from_compat(sigset, csigset); r = kvm_vcpu_ioctl_set_sigmask(vcpu, sigset); @@ -2524,7 +2524,7 @@ static long kvm_vm_ioctl(struct file *filp, r = -EFAULT; if (copy_from_user(kvm_userspace_mem, argp, - sizeof kvm_userspace_mem)) + sizeof(kvm_userspace_mem))) goto out; r = kvm_vm_ioctl_set_memory_region(kvm, kvm_userspace_mem); @@ -2534,7 +2534,7 @@ static long kvm_vm_ioctl(struct file *filp, struct kvm_dirty_log log; r = -EFAULT; - if (copy_from_user(log, argp, sizeof log)) + if (copy_from_user(log, argp, sizeof(log))) goto out; r
[PATCH 6/9] Fix WARNINGs:Missing blank line after declarationgs in kvm_main.c
There are many Warnings like this: WARNING: Missing a blank line after declarations + struct kvm_coalesced_mmio_zone zone; + r = -EFAULT; This patch fixes these warnings to reduce noise when checking new patches in kvm_main.c. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 0b8092f..87ff84a 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1516,6 +1516,7 @@ void kvm_set_pfn_dirty(pfn_t pfn) { if (!kvm_is_reserved_pfn(pfn)) { struct page *page = pfn_to_page(pfn); + if (!PageReserved(page)) SetPageDirty(page); } @@ -1799,6 +1800,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) start = cur = ktime_get(); if (halt_poll_ns) { ktime_t stop = ktime_add_ns(ktime_get(), halt_poll_ns); + do { /* * This sets KVM_REQ_UNHALT if an interrupt @@ -2134,6 +2136,7 @@ static long kvm_vcpu_ioctl(struct file *filp, /* The thread running this VCPU changed. */ struct pid *oldpid = vcpu-pid; struct pid *newpid = get_task_pid(current, PIDTYPE_PID); + rcu_assign_pointer(vcpu-pid, newpid); if (oldpid) synchronize_rcu(); @@ -2541,6 +2544,7 @@ static long kvm_vm_ioctl(struct file *filp, #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET case KVM_REGISTER_COALESCED_MMIO: { struct kvm_coalesced_mmio_zone zone; + r = -EFAULT; if (copy_from_user(zone, argp, sizeof(zone))) goto out; @@ -2549,6 +2553,7 @@ static long kvm_vm_ioctl(struct file *filp, } case KVM_UNREGISTER_COALESCED_MMIO: { struct kvm_coalesced_mmio_zone zone; + r = -EFAULT; if (copy_from_user(zone, argp, sizeof(zone))) goto out; @@ -3266,6 +3271,7 @@ struct kvm_vcpu *preempt_notifier_to_vcpu(struct preempt_notifier *pn) static void kvm_sched_in(struct preempt_notifier *pn, int cpu) { struct kvm_vcpu *vcpu = preempt_notifier_to_vcpu(pn); + if (vcpu-preempted) vcpu-preempted = false; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 8/9] Fix ERROR WARNING for better alignment in kvm_main.c
ERROR: code indent should use tabs where possible + const struct kvm_io_range *r2)$ WARNING: please, no spaces at the start of a line + const struct kvm_io_range *r2)$ This patch fixes this ERROR WARNING to reduce noise when checking new patches in kvm_main.c. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 20a40b3..410fc86 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2947,7 +2947,7 @@ static void kvm_io_bus_destroy(struct kvm_io_bus *bus) } static inline int kvm_io_bus_cmp(const struct kvm_io_range *r1, - const struct kvm_io_range *r2) +const struct kvm_io_range *r2) { if (r1-addr r2-addr) return -1; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/9] Fix WARNING:EXPORT_SYMBOL(x) should immediately.. in kvm_main.c
WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable +EXPORT_SYMBOL_GPL(gfn_to_page); This patch fixes these warnings to reduce noise when checking new patches in kvm_main.c. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 23a1ac2..0b8092f 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1481,7 +1481,6 @@ struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn) return kvm_pfn_to_page(pfn); } - EXPORT_SYMBOL_GPL(gfn_to_page); void kvm_release_page_clean(struct page *page) -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/9] Fix ERROR:do not initialise statics to 0 or NULL in kvm_main.c
ERROR: do not initialise statics to 0 or NULL +static int kvm_usage_count = 0; The kvm_usage_count will be placed to .bss segment when linking, so not need to set it to 0 here obviously. This patch fixes this ERROR to reduce noise when checking new patches in kvm_main.c. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 6b4fb1e..23a1ac2 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -80,7 +80,7 @@ static DEFINE_RAW_SPINLOCK(kvm_count_lock); LIST_HEAD(vm_list); static cpumask_var_t cpus_hardware_enabled; -static int kvm_usage_count = 0; +static int kvm_usage_count; static atomic_t hardware_enable_failed; struct kmem_cache *kvm_vcpu_cache; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 9/9] Fix WARNINGs about using printk drectly in kvm_main.c
WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ... + printk(KERN_INFO kvm: exiting hardware virtualization\n); WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then pr_err(... to printk(KERN_ERR ... + printk(KERN_ERR kvm: misc device register failed\n); Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 410fc86..4be4c42 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2824,8 +2824,7 @@ static void hardware_enable_nolock(void *junk) if (r) { cpumask_clear_cpu(cpu, cpus_hardware_enabled); atomic_inc(hardware_enable_failed); - printk(KERN_INFO kvm: enabling virtualization on CPU%d failed\n, - cpu); + pr_info(kvm: enabling virtualization on CPU%d failed\n, cpu); } } @@ -2901,12 +2900,12 @@ static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val, val = ~CPU_TASKS_FROZEN; switch (val) { case CPU_DYING: - printk(KERN_INFO kvm: disabling virtualization on CPU%d\n, + pr_info(kvm: disabling virtualization on CPU%d\n, cpu); hardware_disable(); break; case CPU_STARTING: - printk(KERN_INFO kvm: enabling virtualization on CPU%d\n, + pr_info(kvm: enabling virtualization on CPU%d\n, cpu); hardware_enable(); break; @@ -2923,7 +2922,7 @@ static int kvm_reboot(struct notifier_block *notifier, unsigned long val, * * And Intel TXT required VMX off for all cpu when system shutdown. */ - printk(KERN_INFO kvm: exiting hardware virtualization\n); + pr_info(kvm: exiting hardware virtualization\n); kvm_rebooting = true; on_each_cpu(hardware_disable_nolock, NULL, 1); return NOTIFY_OK; @@ -3353,7 +3352,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, r = misc_register(kvm_dev); if (r) { - printk(KERN_ERR kvm: misc device register failed\n); + pr_err(kvm: misc device register failed\n); goto out_unreg; } @@ -3364,7 +3363,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, r = kvm_init_debug(); if (r) { - printk(KERN_ERR kvm: create debugfs files failed\n); + pr_err(kvm: create debugfs files failed\n); goto out_undebugfs; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/9] Fix WARNING: quoted string split across lines in kvm_main.c
WARNING: quoted string split across lines + printk(KERN_INFO kvm: enabling virtualization on +CPU%d failed\n, cpu); When fails to enable virtualization on CPUx for kvm, this log will be output in only one line, and it will be a little confusing for us to grep this log in kernel source code. In some case, the user maybe using on script to searching the error log in kernel source code, if so, won't it always fail? So this patch fix this issue. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index a109370..3f08716 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2817,12 +2817,11 @@ static void hardware_enable_nolock(void *junk) cpumask_set_cpu(cpu, cpus_hardware_enabled); r = kvm_arch_hardware_enable(); - if (r) { cpumask_clear_cpu(cpu, cpus_hardware_enabled); atomic_inc(hardware_enable_failed); - printk(KERN_INFO kvm: enabling virtualization on -CPU%d failed\n, cpu); + printk(KERN_INFO kvm: enabling virtualization on CPU%d failed\n, + cpu); } } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/9] Fix possible warnings and errors for kvm_main.c
There are to many warnings and errors noise in kvm_main.c when we are gernerating and checking new patches. This patch series fix these warnings and errors to reduce possible noise. Xiubo Li (9): Fix WARNING: quoted string split across lines in kvm_main.c Fix WARNINGs for 'sizeof(X)' instead of 'sizeof X' in kvm_main.c Fix WARNING: labels should not be indented in kvm_main.c Fix ERROR:do not initialise statics to 0 or NULL in kvm_main.c Fix WARNING:EXPORT_SYMBOL(x) should immediately.. in kvm_main.c Fix WARNINGs:Missing blank line after declarationgs in kvm_main.c Fix WARNINGs:please, no space before tabs in kvm_main.c Fix ERROR WARNING for better alignment in kvm_main.c Fix WARNINGs about using printk drectly in kvm_main.c virt/kvm/kvm_main.c | 73 - 1 file changed, 38 insertions(+), 35 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 7/9] Fix WARNINGs:please, no space before tabs in kvm_main.c
WARNING: please, no space before tabs + * ^I^Ikvm-lock -- kvm-slots_lock -- kvm-irq_lock$ WARNING: please, no space before tabs +^I^I * ^I- gfn_to_hva (kvm_read_guest, gfn_to_pfn)$ WARNING: please, no space before tabs +^I^I * ^I- kvm_is_visible_gfn (mmu_check_roots)$ This patch fixes these warnings to reduce noise when checking new patches in kvm_main.c. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 87ff84a..20a40b3 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -72,7 +72,7 @@ module_param(halt_poll_ns, uint, S_IRUGO | S_IWUSR); /* * Ordering of locks: * - * kvm-lock -- kvm-slots_lock -- kvm-irq_lock + * kvm-lock -- kvm-slots_lock -- kvm-irq_lock */ DEFINE_SPINLOCK(kvm_lock); @@ -888,8 +888,8 @@ int __kvm_set_memory_region(struct kvm *kvm, * or moved, memslot will be created. * * validation of sp-gfn happens in: -* - gfn_to_hva (kvm_read_guest, gfn_to_pfn) -* - kvm_is_visible_gfn (mmu_check_roots) +* - gfn_to_hva (kvm_read_guest, gfn_to_pfn) +* - kvm_is_visible_gfn (mmu_check_roots) */ kvm_arch_flush_shadow_memslot(kvm, slot); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/9] Fix WARNING: labels should not be indented in kvm_main.c
WARNING: labels should not be indented + out_free_irq_routing: This patch fixes this WARNING to reduce noise when checking new patches in kvm_main.c. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index a934998..6b4fb1e 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2646,7 +2646,7 @@ static long kvm_vm_ioctl(struct file *filp, goto out_free_irq_routing; r = kvm_set_irq_routing(kvm, entries, routing.nr, routing.flags); - out_free_irq_routing: +out_free_irq_routing: vfree(entries); break; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] KVM: fix possible coalesced_mmio_ring page leaks.
It forgets to free coalesced_mmio_ring page after the anon_inode_getfd fails. Signed-off-by: Xiubo Li lixi...@cmss.chinamobile.com --- virt/kvm/kvm_main.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 8579f18..85e8106 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2784,16 +2784,22 @@ static int kvm_dev_ioctl_create_vm(unsigned long type) return PTR_ERR(kvm); #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET r = kvm_coalesced_mmio_init(kvm); - if (r 0) { - kvm_put_kvm(kvm); - return r; - } + if (r 0) + goto out_put_kvm; #endif r = anon_inode_getfd(kvm-vm, kvm_vm_fops, kvm, O_RDWR | O_CLOEXEC); if (r 0) - kvm_put_kvm(kvm); + goto out_mmio_free; return r; + +out_mmio_free: +#ifdef KVM_COALESCED_MMIO_PAGE_OFFSET + kvm_coalesced_mmio_free(kvm); +#endif +out_put_kvm: + kvm_put_kvm(kvm); + return r; } static long kvm_dev_ioctl(struct file *filp, -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html