From: Russell King <rmk+lkml@arm.linux.org.uk>
To: Jamie Lokier <jamie@shareable.org>
Cc: Ian Molton <spyro@f2s.com>,
linux-arm-kernel@lists.arm.linux.org.uk,
linux-kernel@vger.kernel.org
Subject: Re: A question about PROT_NONE on ARM and ARM26
Date: Fri, 2 Jul 2004 19:39:14 +0100 [thread overview]
Message-ID: <20040702193914.B24028@flint.arm.linux.org.uk> (raw)
In-Reply-To: <20040630233014.GC32560@mail.shareable.org>; from jamie@shareable.org on Thu, Jul 01, 2004 at 12:30:14AM +0100
On Thu, Jul 01, 2004 at 12:30:14AM +0100, Jamie Lokier wrote:
> > Ok, this could work, but there's one gotcha - TASK_SIZE-4 doesn't fit
> > in an 8-bit rotated constants, so we need 2 extra instructions:
> >
> > __get_user_4:
> > mov r1, #TASK_SIZE
> > sub r1, r1, #4
> > cmp r0, r1
> > 4: ldrlet r1, [r0]
> > movle r0, #0
> > movle pc, lr
> > ...
>
> One more possibility:
>
> cmp r0, #(TASK_SIZE - (1<<24))
>
> I.e. just compare against the largest constant that can be
> represented. For accesses to the last part of userspace, it's a
> penalty of 4 instructions -- but it might work out to be a net gain.
>
> Actually, since the shortest path is only three instructions in the
> fast case, not counting control flow, it might be good to inline those
> 3 in uaccess.h, and change the "bl" to a conditonal "blhi" there.
I've been wondering whether we need any of this checking for 32-bit
ARMs in any case. I wouldn't like to say definitely, but I've just
tried this:
__get_user_4:
4: ldrt r1, [r0]
mov r0, #0
mov pc, lr
and it appears to behave as we want. My only concern is Xscale with
some of their errata.
If this works out fine, then we could kill the differences between
__get_user and get_user, and __put_user and put_user on ARM. Before
doing that, however, I would want to evaluate the performance and
size difference between having this out of line and inline.
diff -up -x BitKeeper -x ChangeSet -x SCCS -x _xlk -x '*.orig' -x '*.rej' orig/arch/arm/lib/getuser.S linux/arch/arm/lib/getuser.S
--- orig/arch/arm/lib/getuser.S Tue Apr 13 19:40:00 2004
+++ linux/arch/arm/lib/getuser.S Fri Jul 2 14:26:32 2004
@@ -32,59 +32,34 @@
.global __get_user_1
__get_user_1:
- bic r1, sp, #0x1f00
- bic r1, r1, #0x00ff
- ldr r1, [r1, #TI_ADDR_LIMIT]
- sub r1, r1, #1
- cmp r0, r1
-1: ldrlsbt r1, [r0]
- movls r0, #0
- movls pc, lr
- b __get_user_bad
+1: ldrbt r1, [r0]
+ mov r0, #0
+ mov pc, lr
.global __get_user_2
__get_user_2:
- bic r2, sp, #0x1f00
- bic r2, r2, #0x00ff
- ldr r2, [r2, #TI_ADDR_LIMIT]
- sub r2, r2, #2
- cmp r0, r2
-2: ldrlsbt r1, [r0], #1
-3: ldrlsbt r2, [r0]
+2: ldrbt r1, [r0], #1
+3: ldrbt r2, [r0]
#ifndef __ARMEB__
- orrls r1, r1, r2, lsl #8
+ orr r1, r1, r2, lsl #8
#else
- orrls r1, r2, r1, lsl #8
+ orr r1, r2, r1, lsl #8
#endif
- movls r0, #0
- movls pc, lr
- b __get_user_bad
+ mov r0, #0
+ mov pc, lr
.global __get_user_4
__get_user_4:
- bic r1, sp, #0x1f00
- bic r1, r1, #0x00ff
- ldr r1, [r1, #TI_ADDR_LIMIT]
- sub r1, r1, #4
- cmp r0, r1
-4: ldrlst r1, [r0]
- movls r0, #0
- movls pc, lr
- b __get_user_bad
+4: ldrt r1, [r0]
+ mov r0, #0
+ mov pc, lr
.global __get_user_8
__get_user_8:
- bic r2, sp, #0x1f00
- bic r2, r2, #0x00ff
- ldr r2, [r2, #TI_ADDR_LIMIT]
- sub r2, r2, #8
- cmp r0, r2
-5: ldrlst r1, [r0], #4
-6: ldrlst r2, [r0]
- movls r0, #0
- movls pc, lr
-
- /* fall through */
+5: ldrt r1, [r0], #4
+6: ldrt r2, [r0]
+ mov r0, #0
+ mov pc, lr
__get_user_bad_8:
mov r2, #0
diff -up -x BitKeeper -x ChangeSet -x SCCS -x _xlk -x '*.orig' -x '*.rej' orig/arch/arm/lib/putuser.S linux/arch/arm/lib/putuser.S
--- orig/arch/arm/lib/putuser.S Tue Apr 13 19:40:00 2004
+++ linux/arch/arm/lib/putuser.S Fri Jul 2 14:27:14 2004
@@ -32,60 +32,35 @@
.global __put_user_1
__put_user_1:
- bic ip, sp, #0x1f00
- bic ip, ip, #0x00ff
- ldr ip, [ip, #TI_ADDR_LIMIT]
- sub ip, ip, #1
- cmp r0, ip
-1: strlsbt r1, [r0]
- movls r0, #0
- movls pc, lr
- b __put_user_bad
+1: strbt r1, [r0]
+ mov r0, #0
+ mov pc, lr
.global __put_user_2
__put_user_2:
- bic ip, sp, #0x1f00
- bic ip, ip, #0x00ff
- ldr ip, [ip, #TI_ADDR_LIMIT]
- sub ip, ip, #2
- cmp r0, ip
movls ip, r1, lsr #8
#ifndef __ARMEB__
-2: strlsbt r1, [r0], #1
-3: strlsbt ip, [r0]
+2: strbt r1, [r0], #1
+3: strbt ip, [r0]
#else
-2: strlsbt ip, [r0], #1
-3: strlsbt r1, [r0]
+2: strbt ip, [r0], #1
+3: strbt r1, [r0]
#endif
- movls r0, #0
- movls pc, lr
- b __put_user_bad
+ mov r0, #0
+ mov pc, lr
.global __put_user_4
__put_user_4:
- bic ip, sp, #0x1f00
- bic ip, ip, #0x00ff
- ldr ip, [ip, #TI_ADDR_LIMIT]
- sub ip, ip, #4
- cmp r0, ip
-4: strlst r1, [r0]
- movls r0, #0
- movls pc, lr
- b __put_user_bad
+4: strt r1, [r0]
+ mov r0, #0
+ mov pc, lr
.global __put_user_8
__put_user_8:
- bic ip, sp, #0x1f00
- bic ip, ip, #0x00ff
- ldr ip, [ip, #TI_ADDR_LIMIT]
- sub ip, ip, #8
- cmp r0, ip
-5: strlst r1, [r0], #4
-6: strlst r2, [r0]
- movls r0, #0
- movls pc, lr
-
- /* fall through */
+5: strt r1, [r0], #4
+6: strt r2, [r0]
+ mov r0, #0
+ mov pc, lr
__put_user_bad:
mov r0, #-EFAULT
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/
2.6 Serial core
next prev parent reply other threads:[~2004-07-02 18:39 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-30 2:44 A question about PROT_NONE on ARM and ARM26 Jamie Lokier
2004-06-30 3:38 ` William Lee Irwin III
2004-07-01 3:26 ` Testing PROT_NONE and other protections, and a surprise Jamie Lokier
2004-07-01 3:35 ` William Lee Irwin III
2004-07-01 4:01 ` Jamie Lokier
2004-07-01 3:44 ` Kyle Moffett
2004-07-01 4:11 ` Jamie Lokier
2004-07-01 4:59 ` Kyle Moffett
2004-07-01 12:39 ` Jamie Lokier
2004-07-01 14:43 ` [OT] " Kyle Moffett
2004-07-01 14:50 ` Jamie Lokier
2004-07-01 15:01 ` Kyle Moffett
2004-07-01 16:37 ` Matt Mackall
2004-07-01 17:26 ` Michael Driscoll
2004-07-02 7:37 ` Gabriel Paubert
2004-07-01 12:52 ` Russell King
2004-07-01 14:26 ` Richard Curnow
2004-06-30 8:16 ` A question about PROT_NONE on ARM and ARM26 Russell King
2004-06-30 14:59 ` Jamie Lokier
2004-06-30 15:22 ` Ian Molton
2004-06-30 18:26 ` Russell King
2004-06-30 19:14 ` Jamie Lokier
2004-06-30 19:23 ` Russell King
2004-06-30 20:15 ` Jamie Lokier
2004-06-30 22:59 ` Russell King
2004-06-30 23:30 ` Jamie Lokier
2004-06-30 23:48 ` Ian Molton
2004-07-01 1:59 ` Jamie Lokier
2004-07-01 1:05 ` Nicolas Pitre
2004-07-01 1:50 ` Jamie Lokier
2004-07-02 18:39 ` Russell King [this message]
2004-07-01 15:27 ` Scott Wood
2004-07-01 23:53 ` Jamie Lokier
2004-07-02 14:36 ` Scott Wood
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=20040702193914.B24028@flint.arm.linux.org.uk \
--to=rmk+lkml@arm.linux.org.uk \
--cc=jamie@shareable.org \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=spyro@f2s.com \
/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