qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/1] add Valgrind hint in kvm_get_one_reg()
@ 2022-04-05 13:04 Daniel Henrique Barboza
  2022-04-05 13:04 ` [RFC PATCH 1/1] kvm-all.c: hint Valgrind that kvm_get_one_reg() inits memory Daniel Henrique Barboza
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Henrique Barboza @ 2022-04-05 13:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel Henrique Barboza, david

Hi,

Valgrind is not happy with how we're using KVM functions that receives a
parameter via reference and write them. This results in a lot of
complaints about uninitialized values when using these functions
because, as default, Valgrind doesn't know that the variable is being
initialized in the function.

This is the overall pattern that Valgrind does not like:

---
uint64_t val;
(...)
kvm_get_one_reg(...., &val);

if (val) {...}
---

Valgrind complains that the 'if' clause is using an uninitialized
variable.

A quick fix is to init 'val' and be done with it. The drawback is that
every single caller of kvm_get_one_reg() must also be bothered with
initializing these variables to avoid the warnings.

David suggested in [1] that, instead, we should add a Valgrind hint in
the common KVM functions to fix this issue for everyone. This is what
this patch accomplishes. kvm_get_one_reg() has 20+ callers so I believe
this extra boilerplate is worth the benefits.

There are more common instances of KVM functions that Valgrind complains
about. If we're good with the approach taken here we can think about
adding this hint for more functions.


[1] https://lists.gnu.org/archive/html/qemu-devel/2022-03/msg07351.html

Daniel Henrique Barboza (1):
  kvm-all.c: hint Valgrind that kvm_get_one_reg() inits memory

 accel/kvm/kvm-all.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

-- 
2.35.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-04-06  9:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-05 13:04 [RFC PATCH 0/1] add Valgrind hint in kvm_get_one_reg() Daniel Henrique Barboza
2022-04-05 13:04 ` [RFC PATCH 1/1] kvm-all.c: hint Valgrind that kvm_get_one_reg() inits memory Daniel Henrique Barboza
2022-04-05 14:30   ` Peter Maydell
2022-04-05 19:18     ` Daniel Henrique Barboza
2022-04-06  1:49     ` David Gibson
2022-04-06  1:46   ` David Gibson

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).