All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	"Cornelia Huck" <cohuck@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	David Hildenbrand <david@redhat.com>,
	Halil Pasic <pasic@linux.ibm.com>,
	qemu-s390x <qemu-s390x@nongnu.org>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH] s390x/kvm: help valgrind in several places
Date: Wed, 29 Apr 2020 09:21:12 +0200	[thread overview]
Message-ID: <beb31760-962a-c68c-a343-7aee0dca0530@de.ibm.com> (raw)
In-Reply-To: <2a9751b5-3b0b-2982-0756-3083cea22f31@redhat.com>



On 29.04.20 09:00, Philippe Mathieu-Daudé wrote:
> Hi Christian,
> 
> On 4/28/20 8:31 PM, Christian Borntraeger wrote:
>> We need some little help in the code to reduce the valgrind noise.
>> - some designated initializers for the cpu model features and subfunctions
> 
> ^ This could go as trivial patch while we discuss the rest.

I can certainly split.

> 
>> - mark memory as defined for sida memory reads
>>
>> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
>> ---
> 
> I couldn't apply this patch, then figured out it targets s390-next.
> 
>>   target/s390x/kvm.c | 15 +++++++++++++--
>>   1 file changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
>> index 69881a0da0..bcd0ee0d14 100644
>> --- a/target/s390x/kvm.c
>> +++ b/target/s390x/kvm.c
>> @@ -52,6 +52,10 @@
>>   #include "hw/s390x/s390-virtio-hcall.h"
>>   #include "hw/s390x/pv.h"
>>   +#ifdef CONFIG_VALGRIND_H
>> +#include <valgrind/memcheck.h>
>> +#endif
>> +
>>   #ifndef DEBUG_KVM
>>   #define DEBUG_KVM  0
>>   #endif
>> @@ -875,6 +879,13 @@ int kvm_s390_mem_op_pv(S390CPU *cpu, uint64_t offset, void *hostbuf,
>>           error_report("KVM_S390_MEM_OP failed: %s", strerror(-ret));
>>           abort();
>>       }
> 
> What about kvm_s390_mem_op()?

I have not triggered something in here, but you are right, there should be cases where we make conditions
depend of that content. Will change my testing and add something here as well. 
> 
>> +
>> +#ifdef CONFIG_VALGRIND_H
>> +    if (!is_write) {
>> +        VALGRIND_MAKE_MEM_DEFINED(hostbuf, len);
>> +    }
>> +#endif
> 
> I agree with this macro usage, but think it should be widely accessible by the whole codebase (and other targets).
> 
> "exec/memory.h" is for MemoryRegion and AddressSpace. Maybe "exec/ram_addr.h" is a better place for common helpers.
> 
> If Valgrind is only confused under KVM, the "sysemu/kvm.h" is the obvious place.

This macro IS available for the whole codebase if you include valgrind/memcheck.h.
We used it in the past (before 2.2) for kvm memory.
See commit 541be9274e8ef227fb1b50ce124fd2cc2dce81a5 (kvm/valgrind: don't mark memory as initialized).

The only thing that we could discuss is introducing a new global function like
valgrind_make_mem_defined that would hide the ifdefs.
Is there interest in such a thing?
It is likely that these corner cases (valgrind not able to see that this is defined) are more likely 
o happen with KVM.  But it would be useful for anything not only KVM.
 

> 
>> +
>>       return ret;
>>   }
>>   @@ -2165,7 +2176,7 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
>>     static int query_cpu_subfunc(S390FeatBitmap features)
>>   {
>> -    struct kvm_s390_vm_cpu_subfunc prop;
>> +    struct kvm_s390_vm_cpu_subfunc prop = {};
>>       struct kvm_device_attr attr = {
>>           .group = KVM_S390_VM_CPU_MODEL,
>>           .attr = KVM_S390_VM_CPU_MACHINE_SUBFUNC,
>> @@ -2292,7 +2303,7 @@ static int kvm_to_feat[][2] = {
>>     static int query_cpu_feat(S390FeatBitmap features)
>>   {
>> -    struct kvm_s390_vm_cpu_feat prop;
>> +    struct kvm_s390_vm_cpu_feat prop = {};
>>       struct kvm_device_attr attr = {
>>           .group = KVM_S390_VM_CPU_MODEL,
>>           .attr = KVM_S390_VM_CPU_MACHINE_FEAT,
>>
> 


  reply	other threads:[~2020-04-29  7:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28 18:31 [PATCH] s390x/kvm: help valgrind in several places Christian Borntraeger
2020-04-29  7:00 ` Philippe Mathieu-Daudé
2020-04-29  7:21   ` Christian Borntraeger [this message]
2020-04-29  7:32     ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=beb31760-962a-c68c-a343-7aee0dca0530@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.