From: Andi Kleen <andi@firstfloor.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>,
linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] Add a text_poke syscall
Date: Tue, 19 Nov 2013 20:10:34 +0100 [thread overview]
Message-ID: <20131119191034.GF29695@two.firstfloor.org> (raw)
In-Reply-To: <20131119064948.GA32025@gmail.com>
> Design: more fundamentally, you don't explain the design: why is this
> architecture specific and why is it a new syscall?
>
> In particular I'm somewhat sceptical about doing this as a separate
> syscall, because such Linux-only syscall specials tend to propagate to
> the right tools rather slowly - especially if it's an x86-only
> Linux-special syscall ...
Self modifying code is by definition x86 specific.
Very likely any other method to do this would be Linux specific
in some form or another, as there doesn't seem to be any
existing art.
>
> If we want to do this then it could be shaped as a straightforward
> ptrace() extension: ptrace already has the concept of self-tracing
> (PTRACE_TRACEME), so adding PTRACE_POKETEXT with pid==0 (or a special
> flag to denote 'careful text self-modification') would achieve that,
> and would make it instantly available to tooling, without fragile
> syscall wrappers.
Hmm, my impression was that ptrace would always stop, but yes
that TRACEME thing would be possible. Of course once you
do TRACMEME the debugger won't work anymore. But there's no
reason for text_poke to exclude debuggers. That would seem
like a major disadvantage to me.
My personal feeling is that ptrace is already very complicated,
hard to understand and best left alone. So I preferred to
do it in a clean separate system call.
But if people really think ptrace is somehow better it would
be a possibility.
Is the motivation here just to limit the number of syscalls,
or some other reason too?
> That would also allow other SMP architectures with speculative
> execution to implement such code modification helpers as well, by
> reusing the same new ptrace ABI.
They could always add text_poke too. But their requirements
may be different (for example they may or may not need the
handler) and any code using it would be necessarily
architecture specific anyways.
-Andi
--
ak@linux.intel.com -- Speaking for myself only.
next prev parent reply other threads:[~2013-11-19 19:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-19 0:27 [PATCH] Add a text_poke syscall Andi Kleen
2013-11-19 2:32 ` Andy Lutomirski
2013-11-19 20:16 ` Andi Kleen
2013-11-21 10:02 ` Jiri Kosina
2013-11-19 5:23 ` H. Peter Anvin
2013-11-19 18:49 ` Andi Kleen
2013-11-20 16:42 ` H. Peter Anvin
2013-11-20 17:25 ` Andi Kleen
2013-11-20 18:30 ` H. Peter Anvin
2013-11-20 21:00 ` H. Peter Anvin
2013-11-21 12:49 ` Steven Rostedt
2013-11-19 6:49 ` Ingo Molnar
2013-11-19 19:10 ` Andi Kleen [this message]
2013-11-21 13:07 ` Steven Rostedt
2013-11-22 3:26 ` Andi Kleen
2013-11-21 18:26 ` Oleg Nesterov
2013-11-22 3:29 ` Andi Kleen
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=20131119191034.GF29695@two.firstfloor.org \
--to=andi@firstfloor.org \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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.