9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Alexander Viro <viro@math.psu.edu>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] drawterm and linux 2.4.4 SMP
Date: Fri, 20 Jul 2001 22:43:27 -0400	[thread overview]
Message-ID: <Pine.GSO.4.21.0107202209470.12660-100000@weyl.math.psu.edu> (raw)
In-Reply-To: <E15NlQw-0001p7-00@000pri026.bresnanlink.net>



On Sat, 21 Jul 2001 crdevilb@mtu.edu wrote:

> Was there some suggestion or patch anybody had to fix this, or am I
> going to be digging into the linux kernel to find yet another hack to
> solve this?

Check the archives.

BTW, there _is_ a dirty hack that will work on slightly modified 2.4 (x86).
So if you are into really kinky stuff - try to play with the following
idea: let sys_fork() and sys_clone() set cr2 to current->pid before returning
into (child's) userland. Ditto on the exit from do_page_fault(). Then you are
guaranteed that in userland cr2 will be always equal to value of getpid(2).

Mechanics behind this ugliness:
	a) cr2 is never directly assigned - neither by kernel nor by userland
	b) it is clobbered by pagefault exception (MMU sets it to address that
had caused fault)
	c) pagefault handler reads its value in the very beginning and doesn't
use cr2 after that.

IIRC, that had been proposed as a proof-of-concept implementation of
getpid() without syscalls. It should even be 'portable' to other systems
running on x86 - e.g. in case of Plan 9 you'd need to s/current/up/ and
s/do_page_fault/fault386/. ISTR author of that hack claiming that other
architectures usually allow something similar - rarely used registers
that are clobbered only in situations when we have access to task_struct
and know that thing had been clobbered.

IMO it's a dirty hack, but then so was the use of TSS...

/me grabs the popcorn and removes Boyd from killfile for a while...



  reply	other threads:[~2001-07-21  2:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-21  1:12 crdevilb
2001-07-21  2:43 ` Alexander Viro [this message]
2001-07-21  4:24 ` Ish Rattan
2001-07-21  4:28   ` Ish Rattan
2001-07-21  2:38 jmk
2001-07-21  4:59 ` William K. Josephson
2001-07-21  7:34 forsyth
2001-07-21  7:37 forsyth
2001-07-21  8:19 nigel
2001-07-21  9:34 forsyth
2001-07-22  1:03 Colin DeVilbiss
2001-07-23  2:01 David Gordon Hogan

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=Pine.GSO.4.21.0107202209470.12660-100000@weyl.math.psu.edu \
    --to=viro@math.psu.edu \
    --cc=9fans@cse.psu.edu \
    /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;
as well as URLs for NNTP newsgroup(s).