[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 3/3] i386/kvm: initialize struct at full before
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [Qemu-devel] [PATCH 3/3] i386/kvm: initialize struct at full before ioctl call |
Date: |
Tue, 30 Jul 2019 18:44:56 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 |
On 7/30/19 6:01 PM, Andrey Shinkevich wrote:
> Not the whole structure is initialized before passing it to the KVM.
> Reduce the number of Valgrind reports.
>
> Signed-off-by: Andrey Shinkevich <address@hidden>
> ---
> target/i386/kvm.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/target/i386/kvm.c b/target/i386/kvm.c
> index dbbb137..ed57e31 100644
> --- a/target/i386/kvm.c
> +++ b/target/i386/kvm.c
> @@ -190,6 +190,7 @@ static int kvm_get_tsc(CPUState *cs)
> return 0;
> }
>
> + memset(&msr_data, 0, sizeof(msr_data));
I wonder the overhead of this one...
> msr_data.info.nmsrs = 1;
> msr_data.entries[0].index = MSR_IA32_TSC;
> env->tsc_valid = !runstate_is_running();
> @@ -1706,6 +1707,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
>
> if (has_xsave) {
> env->xsave_buf = qemu_memalign(4096, sizeof(struct kvm_xsave));
> + memset(env->xsave_buf, 0, sizeof(struct kvm_xsave));
OK
> }
>
> max_nested_state_len = kvm_max_nested_state_length();
> @@ -3477,6 +3479,7 @@ static int kvm_put_debugregs(X86CPU *cpu)
> return 0;
> }
>
> + memset(&dbgregs, 0, sizeof(dbgregs));
OK
> for (i = 0; i < 4; i++) {
> dbgregs.db[i] = env->dr[i];
> }
We could remove 'dbgregs.flags = 0;'
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Re: [Qemu-devel] [PATCH 3/3] i386/kvm: initialize struct at full before ioctl call, Peter Maydell, 2019/07/30
Re: [Qemu-devel] [PATCH 3/3] i386/kvm: initialize struct at full before ioctl call, Paolo Bonzini, 2019/07/30