* [Qemu-devel] [PATCH] kvm: fill in padding to help valgrind
@ 2012-02-29 15:54 Michael S. Tsirkin
2012-03-07 10:31 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Michael S. Tsirkin @ 2012-02-29 15:54 UTC (permalink / raw)
Cc: Marcelo Tosatti, Avi Kivity, kvm, qemu-devel
valgrind warns about padding fields which are passed
to vcpu ioctls uninitialized.
This is not an error in practice because kvm ignored padding.
Since the ioctls in question are off data path and
the cost is zero anyway, initialize padding to 0
to suppress these errors.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
kvm-all.c | 2 ++
target-i386/kvm.c | 6 ++++++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/kvm-all.c b/kvm-all.c
index c58c77b..3bc0eb3 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -447,6 +447,7 @@ int kvm_coalesce_mmio_region(target_phys_addr_t start, ram_addr_t size)
zone.addr = start;
zone.size = size;
+ zone.pad = 0;
ret = kvm_vm_ioctl(s, KVM_REGISTER_COALESCED_MMIO, &zone);
}
@@ -464,6 +465,7 @@ int kvm_uncoalesce_mmio_region(target_phys_addr_t start, ram_addr_t size)
zone.addr = start;
zone.size = size;
+ zone.pad = 0;
ret = kvm_vm_ioctl(s, KVM_UNREGISTER_COALESCED_MMIO, &zone);
}
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 981192d..285cf55 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -555,6 +555,7 @@ int kvm_arch_init_vcpu(CPUState *env)
qemu_add_vm_change_state_handler(cpu_update_state, env);
+ cpuid_data.cpuid.padding = 0;
r = kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
if (r) {
return r;
@@ -740,6 +741,7 @@ static void set_seg(struct kvm_segment *lhs, const SegmentCache *rhs)
lhs->g = (flags & DESC_G_MASK) != 0;
lhs->avl = (flags & DESC_AVL_MASK) != 0;
lhs->unusable = 0;
+ lhs->padding = 0;
}
static void get_seg(SegmentCache *lhs, const struct kvm_segment *rhs)
@@ -919,8 +921,10 @@ static int kvm_put_sregs(CPUState *env)
sregs.idt.limit = env->idt.limit;
sregs.idt.base = env->idt.base;
+ memset(sregs.idt.padding, 0, sizeof sregs.idt.padding);
sregs.gdt.limit = env->gdt.limit;
sregs.gdt.base = env->gdt.base;
+ memset(sregs.gdt.padding, 0, sizeof sregs.gdt.padding);
sregs.cr0 = env->cr[0];
sregs.cr2 = env->cr[2];
@@ -1392,6 +1396,7 @@ static int kvm_put_vcpu_events(CPUState *env, int level)
events.exception.nr = env->exception_injected;
events.exception.has_error_code = env->has_error_code;
events.exception.error_code = env->error_code;
+ events.exception.pad = 0;
events.interrupt.injected = (env->interrupt_injected >= 0);
events.interrupt.nr = env->interrupt_injected;
@@ -1400,6 +1405,7 @@ static int kvm_put_vcpu_events(CPUState *env, int level)
events.nmi.injected = env->nmi_injected;
events.nmi.pending = env->nmi_pending;
events.nmi.masked = !!(env->hflags2 & HF2_NMI_MASK);
+ events.nmi.pad = 0;
events.sipi_vector = env->sipi_vector;
--
1.7.9.111.gf3fb0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] kvm: fill in padding to help valgrind
2012-02-29 15:54 [Qemu-devel] [PATCH] kvm: fill in padding to help valgrind Michael S. Tsirkin
@ 2012-03-07 10:31 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2012-03-07 10:31 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Marcelo Tosatti, qemu-devel, kvm
On 02/29/2012 05:54 PM, Michael S. Tsirkin wrote:
> valgrind warns about padding fields which are passed
> to vcpu ioctls uninitialized.
> This is not an error in practice because kvm ignored padding.
> Since the ioctls in question are off data path and
> the cost is zero anyway, initialize padding to 0
> to suppress these errors.
>
Applied to uq/master, thanks.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-07 10:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-29 15:54 [Qemu-devel] [PATCH] kvm: fill in padding to help valgrind Michael S. Tsirkin
2012-03-07 10:31 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).