From: Carsten Langgaard <carstenl@mips.com>
To: Kip Walker <kwalker@broadcom.com>
Cc: linux-mips@linux-mips.org
Subject: Re: unaligned exception handling
Date: Tue, 01 Oct 2002 09:38:34 +0200 [thread overview]
Message-ID: <3D9950FA.78C756EF@mips.com> (raw)
In-Reply-To: 3D987A87.8B855D01@broadcom.com
You are right there is a potential problem in the 64-bit kernel, when
emulating load/store instructions.
I have previously addressed this problem (and also send a patch).
The problem is the check_axs macro, that checks the access before
actually doing the emulation (any load/stores).
It's a simple copy from the 32-bit kernel, where you do a check for user
space by simple check the most significant bit.
That's fine in the 32-bit world, but it's not sufficient in the 64-bit
case.
Locally I have a check_axs that look like this:
/*
* User code may only access USEG;
* Kernel code may access the entire address space, except the area
between
* USEG (XUSEG) and KSEG0.
*/
#define check_axs(pc,a,s) \
if (((pc < KUSIZE) && (((a) | ((a)+(s))) >= KUSIZE)) || \
((((a) | ((a)+(s))) < K0BASE) && \
(((a) | ((a)+(s))) >= KUSIZE))) \
goto sigbus;
Hope that helps you.
/Carsten
Kip Walker wrote:
> After inspecting a strange case in the mips64 kernel with address
> errors, I'm starting to think there's a problem in the do_ade()
> implementation. I think the 32-bit kernel may have a similar problem,
> but I haven't really inspected it. The issue is where the kernel's
> emulation of an address error causes another address error (NOT a page
> fault).
>
> Basically, I don't see how the exception table stuff in
> emulate_load_store_insn is going to work. Consider this scenario:
>
> - user process does a 'sw' (for example) to an illegal address
> above xuseg but below xsseg
> - do_ade calls emulate_load_store_insn, which tries swl/swr
> - the swl again hits an illegal address, this time in the
> kernel's context
> - do_ade does NOT check the exception table for the swl
> - emulate_load_store_insn goes to the 'swl' part of the switch
> - die_if_kernel DOES __die before the SIGBUS is delivered.
>
> So I don't see how the ex_table stuff is useful at all. Shouldn't
> do_ade() do the exception table grovelling before calling
> emulate_load_store_insn?
>
> Kip
--
_ _ ____ ___ Carsten Langgaard Mailto:carstenl@mips.com
|\ /|||___)(___ MIPS Denmark Direct: +45 4486 5527
| \/ ||| ____) Lautrupvang 4B Switch: +45 4486 5555
TECHNOLOGIES 2750 Ballerup Fax...: +45 4486 5556
Denmark http://www.mips.com
prev parent reply other threads:[~2002-10-01 7:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-30 16:23 unaligned exception handling Kip Walker
2002-10-01 7:38 ` Carsten Langgaard [this message]
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=3D9950FA.78C756EF@mips.com \
--to=carstenl@mips.com \
--cc=kwalker@broadcom.com \
--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.