All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Daney <david.daney@cavium.com>
To: Joe Buehler <aspam@cox.net>
Cc: linux-mips@linux-mips.org
Subject: Re: using mprotect to write to .text
Date: Tue, 11 Oct 2011 09:36:49 -0700	[thread overview]
Message-ID: <4E9470A1.8020309@cavium.com> (raw)
In-Reply-To: <loom.20111010T215444-70@post.gmane.org>

On 10/10/2011 01:02 PM, Joe Buehler wrote:
> I intend to use mprotect in a running binary to allow it to modify its .text
> section.  The detailed behavior of mprotect for a multithreaded program on SMP
> hardware is not documented as far as I can tell.

It is well documented.  What is not well defined is what happens if you 
modify the code and then try to execute it.

>
> Can I depend on the LINUX mprotect call to take care of icache flushing,
> handling of hazards, etc.?

No, it does nothing of the sort.  You need cacheflush() for that.

>  I am using Octeon CN5650 on 2.6.21.7 and 2.6.27.7 if
> it matters.

It doesn't really matter.

What you need is something like:

#include <sys/cachectl.h>
.
.
.


cacheflush(location, size, ICACHE);
.
.
.

David Daney

  reply	other threads:[~2011-10-11 16:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-10 20:02 using mprotect to write to .text Joe Buehler
2011-10-11 16:36 ` David Daney [this message]
2011-10-11 17:31   ` Joe Buehler
2011-10-11 18:06     ` David Daney
2011-10-11 18:35       ` Joe Buehler
2011-10-11 18:43         ` David Daney
2011-10-11 23:17           ` Ralf Baechle

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=4E9470A1.8020309@cavium.com \
    --to=david.daney@cavium.com \
    --cc=aspam@cox.net \
    --cc=linux-mips@linux-mips.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 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.