From: Matt Chapman <matthewc@cse.unsw.edu.au>
To: linux-ia64@vger.kernel.org
Subject: Re: load-store emulation with SIGSEGV
Date: Fri, 17 Oct 2003 15:11:04 +0000 [thread overview]
Message-ID: <marc-linux-ia64-106640366417855@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-106634457403703@msgid-missing>
On Thu, Oct 16, 2003 at 11:51:16PM +0100, R. Lake wrote:
>
> A simple test to decode the instruction, locate and modify the operand
> register in the sigcontext or backing store, then increment sc_ip shows the
> expected behaviour.
Yep, I do similar things in a virtual machine that I wrote. Here are some
notes in case you've overlooked some of the finer details (and perhaps I've
overlooked some of the finer details as well :)).
Incrementing the IP:
sc->sc_ip += ((sc->sc_ip & 0xf) = 2) ? 0xe : 1;
Register 0:
Read returns 0, write faults. When reading don't rely on sc_gr[0] being 0.
Register 1-3,8-31:
Simply read/write sc_gr[n].
Upon read check NaT bit, upon write clear NaT bit through sc_nat.
Register 4-7:
Preserved registers - read/write live value at entry to signal handler
(really would need to unwind to do this completely safely, but just using
the live value should do). gcc rarely uses these registers so I just
assert here :)
Register 32-127:
If using sigaltstack, bsp = sc->sc_rbs_base + (sc->sc_loadrs >> 16),
else bsp = sc->sc_ar_bsp.
Read: ;;flushrs;; to write back
read address = ia64_rse_skip_regs(bsp, -(sc->sc_cfm & 0x7f) + (regno - 32));
Write: ;;mov ar.rsc=0;;flushrs;;loadrs;; to go lazy, write back, invalidate
write address as before
;;mov ar.rsc=3;; to allow eager loads again
Strictly should check/clear the NaT bits as well (more fun working out
the addresses), I haven't bothered to do this yet.
Also beware that old kernels (pre about 2.5.60?) report the wrong si_addr for
accesses to the NULL page (the instruction address instead of the fault address).
I'm not sure when this was fixed in the 2.4 tree.
Matt
next prev parent reply other threads:[~2003-10-17 15:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-16 22:49 load-store emulation with SIGSEGV R. Lake
2003-10-16 22:49 ` R. Lake
2003-10-16 22:49 ` R. Lake
2003-10-16 22:51 ` R. Lake
2003-10-16 22:51 ` R. Lake
2003-10-16 23:57 ` David Mosberger
2003-10-17 8:13 ` R. Lake
2003-10-17 15:11 ` Matt Chapman [this message]
2003-10-17 18:16 ` Jim Hull
2003-10-17 18:54 ` David Mosberger
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=marc-linux-ia64-106640366417855@msgid-missing \
--to=matthewc@cse.unsw.edu.au \
--cc=linux-ia64@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