public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Dike <jdike@karaya.com>
To: linux-kernel@vger.kernel.org
Cc: Jeremy Fitzhardinge <jeremy@goop.org>, Julian Seward <jseward@acm.org>
Subject: Valgrind meets UML
Date: Thu, 19 Dec 2002 21:41:43 -0500	[thread overview]
Message-ID: <200212200241.VAA04202@ccure.karaya.com> (raw)

After some hacking on valgrind (and help from Jeremy Fitzhardinge and Julian 
Seward), I got it to run the kernel, in the form of UML.  

I don't have a long list of bugs to report because I'm still trying to drive
the noise level down by teaching valgrind about how the kernel does business.

As a result, I have some questions that I'd appreciate advice on.

You teach it things by putting declarations in the code about what level of
access is permitted for a region of memory.  So, 

	VALGRIND_MAKE_WRITABLE(ptr, len);
	VALGRIND_MAKE_READABLE(ptr, len);

tells valgrind that the region [ ptr, ptr + len ) is open for business, and
	
	VALGRIND_MAKE_NOACCESS(ptr, len);

tells it that it's not.

First question - is sticking something (not necessarily the VALGRIND_* things)
in the code acceptable?  I personally don't see a problem with it, although
I would do something like BUFFER_RW(ptr, len), which would expand into the 
first pair of declarations if CONFIG_VALGRIND was enabled, and nothing if it's
not.

Which leads to the next question - where to put CONFIG_VALGRIND?  UML is the
only form of the kernel which valgrind will deal with any time soon, so it's
reasonable for it to be in the UML config only.  However, the memory access
declarations are going to be sprinkled around generic code, so that suggests
putting it in the generic config someplace, just conditional on UML (which 
suggests putting it back in the UML-only config :-).  

I think there would also need to be a CONFIG_VALGRIND_INCLUDE which points
to wherever the valgrind headers are installed.

I would also appreciate suggestions on what sort of memory access state table
to implement, and where best to put the declarations.  What I'm not clear
on is what sort of access a buffer should have when it's in the care of
the allocator (i.e. it's free).  If the allocator sticks information 
temporarily in the buffer, then that needs to be stated.

There are also some non-obvious places where this could be used.  
- VALGRIND_MAKE_READABLE could be used to enforce read-only data when an rwlock
is taken for reading
- it could also be used whenever there's an interface that hands out read-only
objects, and writing them is done under that interface.

So, it's not only the memory allocators that can make use of this.  We'll get
the best use of this if other subsystem maintainers figure out what rules
they have and whether valgrind can be used to enforce them.

				Jeff


             reply	other threads:[~2002-12-20  2:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-20  2:41 Jeff Dike [this message]
2002-12-20 15:26 ` Valgrind meets UML John Reiser
2002-12-20 22:58   ` Jeff Dike
2002-12-20 23:32     ` John Reiser
2002-12-21  2:49       ` Jeff Dike
2002-12-21  7:32         ` Jeremy Fitzhardinge
2002-12-21 16:05           ` Jeff Dike
2002-12-21 14:40 ` John Reiser
2002-12-21 16:07   ` Jeff Dike
2002-12-21 16:15     ` John Reiser
2002-12-21 18:57       ` Jeff Dike
2002-12-21 19:07   ` Jeremy Fitzhardinge

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=200212200241.VAA04202@ccure.karaya.com \
    --to=jdike@karaya.com \
    --cc=jeremy@goop.org \
    --cc=jseward@acm.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox