* [parisc-linux] uaccess ya patch
@ 2002-11-26 10:05 jsoe0708
2002-11-26 16:29 ` [parisc-linux] " Randolph Chung
0 siblings, 1 reply; 7+ messages in thread
From: jsoe0708 @ 2002-11-26 10:05 UTC (permalink / raw)
To: Randolph Chung; +Cc: parisc-linux
[-- Attachment #1: Type: text/plain, Size: 4524 bytes --]
Hi Randolph,
Much more for info, here is another way I found to implement __put_?_asm64.
--- uaccess.h.orig 2002-11-26 10:11:56.000000000 +0100
+++ uaccess.h 2002-11-26 09:58:08.000000000 +0100
@@ -28,6 +28,11 @@
* that put_user is the same as __put_user, etc.
*/
+extern int __get_kernel_bad(void);
+extern int __get_user_bad(void);
+extern int __put_kernel_bad(void);
+extern int __put_user_bad(void);
+
#define access_ok(type,addr,size) (1)
#define verify_area(type,addr,size) (0)
@@ -35,8 +40,12 @@
#define get_user __get_user
#if BITS_PER_LONG == 32
-#define LDD_KERNEL(ptr) BUG()
-#define LDD_USER(ptr) BUG()
+#define LDD_KERNEL(ptr) __get_kernel_bad();
+#define LDD_USER(ptr) __get_user_bad();
+/*
+#define STD_KERNEL(x, ptr) __put_kernel_bad();
+#define STD_USER(x, ptr) __put_user_bad();
+*/
#define STD_KERNEL(x, ptr) __put_kernel_asm64(x,ptr)
#define STD_USER(x, ptr) __put_user_asm64(x,ptr)
#else
@@ -75,7 +84,7 @@
case 2: __get_kernel_asm("ldh",ptr); break; \
case 4: __get_kernel_asm("ldw",ptr); break; \
case 8: LDD_KERNEL(ptr); break; \
- default: BUG(); break; \
+ default: __get_kernel_bad(); break; \
} \
} \
else { \
@@ -84,7 +93,7 @@
case 2: __get_user_asm("ldh",ptr); break; \
case 4: __get_user_asm("ldw",ptr); break; \
case 8: LDD_USER(ptr); break; \
- default: BUG(); break; \
+ default: __get_user_bad(); break; \
} \
} \
\
@@ -144,7 +153,7 @@
case 2: __put_kernel_asm("sth",x,ptr); break; \
case 4: __put_kernel_asm("stw",x,ptr); break; \
case 8: STD_KERNEL(x,ptr); break; \
- default: BUG(); break; \
+ default: __put_kernel_bad(); break; \
} \
} \
else { \
@@ -153,7 +162,7 @@
case 2: __put_user_asm("sth",x,ptr); break; \
case 4: __put_user_asm("stw",x,ptr); break; \
case 8: STD_USER(x,ptr); break; \
- default: BUG(); break; \
+ default: __put_user_bad(); break; \
} \
} \
\
@@ -211,45 +220,36 @@
: "=r"(__pu_err) \
: "r"(ptr), "r"(x), "0"(__pu_err))
-static inline void __put_kernel_asm64(u64 x, void *ptr)
-{
- u32 hi = x>>32;
- u32 lo = x&0xffffffff;
- __asm__ __volatile__ (
- "\n1:\tstw %1,0(%0)\n"
- "\n2:\tstw %2,4(%0)\n"
- "3:\n"
- "\t.section __ex_table,\"a\"\n"
- "\t.word\t1b\n"
- "\t.word\t(3b-1b)+1\n"
- "\t.word\t2b\n"
- "\t.word\t(3b-2b)+1\n"
- "\t.previous"
- : : "r"(ptr), "r"(hi), "r"(lo));
-
-}
-
-static inline void __put_user_asm64(u64 x, void *ptr)
-{
- u32 hi = x>>32;
- u32 lo = x&0xffffffff;
- __asm__ __volatile__ (
- "\n1:\tstw %1,0(%%sr3,%0)\n"
- "\n2:\tstw %2,4(%%sr3,%0)\n"
- "3:\n"
- "\t.section __ex_table,\"a\"\n"
- "\t.word\t1b\n"
- "\t.word\t(3b-1b)+1\n"
- "\t.word\t2b\n"
- "\t.word\t(3b-2b)+1\n"
- "\t.previous"
- : : "r"(ptr), "r"(hi), "r"(lo));
+#define __put_kernel_asm64(x, ptr) \
+ __asm__ __volatile__ ( \
+ "\n1:\tstw\t%2,0(%1)\n" \
+ "2:\tstw\t%R2,4(%1)\n" \
+ "3:\n" \
+ "\t.section __ex_table,\"a\"\n" \
+ "\t.word\t1b\n" \
+ "\t.word\t(3b-1b)+1\n" \
+ "\t.word\t2b\n" \
+ "\t.word\t(3b-2b)+1\n" \
+ "\t.previous" \
+ : "=r"(__pu_err) \
+ : "r"(ptr), "r"(x), "0"(__pu_err))
-}
+#define __put_user_asm64(x, ptr) \
+ __asm__ __volatile__ ( \
+ "\n1:\tstw\t%2,0(%%sr3,%1)\n" \
+ "2:\tstw\t%R2,4(%%sr3,%1)\n" \
+ "3:\n" \
+ "\t.section __ex_table,\"a\"\n" \
+ "\t.word\t1b\n" \
+ "\t.word\t(3b-1b)+1\n" \
+ "\t.word\t2b\n" \
+ "\t.word\t(3b-2b)+1\n" \
+ "\t.previous" \
+ : "=r"(__pu_err) \
+ : "r"(ptr), "r"(x), "0"(__pu_err))
#endif
-
/*
* Complex access routines -- external declarations
*/
Cheers,
Joel
********************************************************************************
Controlez mieux votre consommation Internet...surfez Tiscali Complete...http://tiscali.complete.be
[-- Attachment #2: pa-uaccess_h.txt --]
[-- Type: text/plain, Size: 4232 bytes --]
--- uaccess.h.orig 2002-11-26 10:11:56.000000000 +0100
+++ uaccess.h 2002-11-26 09:58:08.000000000 +0100
@@ -28,6 +28,11 @@
* that put_user is the same as __put_user, etc.
*/
+extern int __get_kernel_bad(void);
+extern int __get_user_bad(void);
+extern int __put_kernel_bad(void);
+extern int __put_user_bad(void);
+
#define access_ok(type,addr,size) (1)
#define verify_area(type,addr,size) (0)
@@ -35,8 +40,12 @@
#define get_user __get_user
#if BITS_PER_LONG == 32
-#define LDD_KERNEL(ptr) BUG()
-#define LDD_USER(ptr) BUG()
+#define LDD_KERNEL(ptr) __get_kernel_bad();
+#define LDD_USER(ptr) __get_user_bad();
+/*
+#define STD_KERNEL(x, ptr) __put_kernel_bad();
+#define STD_USER(x, ptr) __put_user_bad();
+*/
#define STD_KERNEL(x, ptr) __put_kernel_asm64(x,ptr)
#define STD_USER(x, ptr) __put_user_asm64(x,ptr)
#else
@@ -75,7 +84,7 @@
case 2: __get_kernel_asm("ldh",ptr); break; \
case 4: __get_kernel_asm("ldw",ptr); break; \
case 8: LDD_KERNEL(ptr); break; \
- default: BUG(); break; \
+ default: __get_kernel_bad(); break; \
} \
} \
else { \
@@ -84,7 +93,7 @@
case 2: __get_user_asm("ldh",ptr); break; \
case 4: __get_user_asm("ldw",ptr); break; \
case 8: LDD_USER(ptr); break; \
- default: BUG(); break; \
+ default: __get_user_bad(); break; \
} \
} \
\
@@ -144,7 +153,7 @@
case 2: __put_kernel_asm("sth",x,ptr); break; \
case 4: __put_kernel_asm("stw",x,ptr); break; \
case 8: STD_KERNEL(x,ptr); break; \
- default: BUG(); break; \
+ default: __put_kernel_bad(); break; \
} \
} \
else { \
@@ -153,7 +162,7 @@
case 2: __put_user_asm("sth",x,ptr); break; \
case 4: __put_user_asm("stw",x,ptr); break; \
case 8: STD_USER(x,ptr); break; \
- default: BUG(); break; \
+ default: __put_user_bad(); break; \
} \
} \
\
@@ -211,45 +220,36 @@
: "=r"(__pu_err) \
: "r"(ptr), "r"(x), "0"(__pu_err))
-static inline void __put_kernel_asm64(u64 x, void *ptr)
-{
- u32 hi = x>>32;
- u32 lo = x&0xffffffff;
- __asm__ __volatile__ (
- "\n1:\tstw %1,0(%0)\n"
- "\n2:\tstw %2,4(%0)\n"
- "3:\n"
- "\t.section __ex_table,\"a\"\n"
- "\t.word\t1b\n"
- "\t.word\t(3b-1b)+1\n"
- "\t.word\t2b\n"
- "\t.word\t(3b-2b)+1\n"
- "\t.previous"
- : : "r"(ptr), "r"(hi), "r"(lo));
-
-}
-
-static inline void __put_user_asm64(u64 x, void *ptr)
-{
- u32 hi = x>>32;
- u32 lo = x&0xffffffff;
- __asm__ __volatile__ (
- "\n1:\tstw %1,0(%%sr3,%0)\n"
- "\n2:\tstw %2,4(%%sr3,%0)\n"
- "3:\n"
- "\t.section __ex_table,\"a\"\n"
- "\t.word\t1b\n"
- "\t.word\t(3b-1b)+1\n"
- "\t.word\t2b\n"
- "\t.word\t(3b-2b)+1\n"
- "\t.previous"
- : : "r"(ptr), "r"(hi), "r"(lo));
+#define __put_kernel_asm64(x, ptr) \
+ __asm__ __volatile__ ( \
+ "\n1:\tstw\t%2,0(%1)\n" \
+ "2:\tstw\t%R2,4(%1)\n" \
+ "3:\n" \
+ "\t.section __ex_table,\"a\"\n" \
+ "\t.word\t1b\n" \
+ "\t.word\t(3b-1b)+1\n" \
+ "\t.word\t2b\n" \
+ "\t.word\t(3b-2b)+1\n" \
+ "\t.previous" \
+ : "=r"(__pu_err) \
+ : "r"(ptr), "r"(x), "0"(__pu_err))
-}
+#define __put_user_asm64(x, ptr) \
+ __asm__ __volatile__ ( \
+ "\n1:\tstw\t%2,0(%%sr3,%1)\n" \
+ "2:\tstw\t%R2,4(%%sr3,%1)\n" \
+ "3:\n" \
+ "\t.section __ex_table,\"a\"\n" \
+ "\t.word\t1b\n" \
+ "\t.word\t(3b-1b)+1\n" \
+ "\t.word\t2b\n" \
+ "\t.word\t(3b-2b)+1\n" \
+ "\t.previous" \
+ : "=r"(__pu_err) \
+ : "r"(ptr), "r"(x), "0"(__pu_err))
#endif
-
/*
* Complex access routines -- external declarations
*/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [parisc-linux] Re: uaccess ya patch
2002-11-26 10:05 [parisc-linux] uaccess ya patch jsoe0708
@ 2002-11-26 16:29 ` Randolph Chung
2002-11-26 17:02 ` jsoe0708
0 siblings, 1 reply; 7+ messages in thread
From: Randolph Chung @ 2002-11-26 16:29 UTC (permalink / raw)
To: jsoe0708; +Cc: parisc-linux
> Much more for info, here is another way I found to implement __put_?_asm64.
Joel, the __*_bad stuff is fine, but why do you want to rewrite the
asm64 functions as macros? you are also not doing it correctly:
> +#define __put_user_asm64(x, ptr) \
> + __asm__ __volatile__ ( \
> + "\n1:\tstw\t%2,0(%%sr3,%1)\n" \
> + "2:\tstw\t%R2,4(%%sr3,%1)\n" \
^^^ this will cause very bad things to happen.
randolph
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [parisc-linux] Re: uaccess ya patch
2002-11-26 16:29 ` [parisc-linux] " Randolph Chung
@ 2002-11-26 17:02 ` jsoe0708
2002-11-26 17:22 ` Randolph Chung
0 siblings, 1 reply; 7+ messages in thread
From: jsoe0708 @ 2002-11-26 17:02 UTC (permalink / raw)
To: Randolph Chung; +Cc: parisc-linux
>> Much more for info, here is another way I found to implement __put_?_asm64.
>
>Joel, the __*_bad stuff is fine, but why do you want to rewrite the
>asm64 functions as macros? you are also not doing it correctly:
>
>> +#define __put_user_asm64(x, ptr) \
>> + __asm__ __volatile__ ( \
>> + "\n1:\tstw\t%2,0(%%sr3,%1)\n" \
>> + "2:\tstw\t%R2,4(%%sr3,%1)\n" \
> ^^^ this will cause very bad things to happen.
It was much more to mentionned that in asm extension of gcc for hppa it exists
also a way to address the second word (what I tried to find for a long) of
a long long via the 'R' prefix as here in '%R2' [is it what you want to say
'will cause bad things'?]
(the macro was just beacuse the original __put_?_asm() was macro :) )
Well it has not more interest and for me you can forget it.
Thanks for your attention,
Joel
********************************************************************************
Controlez mieux votre consommation Internet...surfez Tiscali Complete...http://tiscali.complete.be
^ permalink raw reply [flat|nested] 7+ messages in thread
* [parisc-linux] Re: uaccess ya patch
2002-11-26 17:02 ` jsoe0708
@ 2002-11-26 17:22 ` Randolph Chung
2002-11-26 17:31 ` John David Anglin
0 siblings, 1 reply; 7+ messages in thread
From: Randolph Chung @ 2002-11-26 17:22 UTC (permalink / raw)
To: jsoe0708; +Cc: parisc-linux
> It was much more to mentionned that in asm extension of gcc for hppa it exists
> also a way to address the second word (what I tried to find for a long) of
> a long long via the 'R' prefix as here in '%R2' [is it what you want to say
> 'will cause bad things'?]
maybe you are thinking of floating point registers? %r2 is general
register number 2, i.e. the return pointer. it is not what you want to
store into memory.
> (the macro was just beacuse the original __put_?_asm() was macro :) )
well, it was an inline function for a reason -- to avoid nasty casts.
the macro as you've defined it will probably cause a lot of warnings.
randolph
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [parisc-linux] Re: uaccess ya patch
2002-11-26 17:22 ` Randolph Chung
@ 2002-11-26 17:31 ` John David Anglin
2002-11-26 18:44 ` Randolph Chung
0 siblings, 1 reply; 7+ messages in thread
From: John David Anglin @ 2002-11-26 17:31 UTC (permalink / raw)
To: tausq; +Cc: jsoe0708, parisc-linux
> > It was much more to mentionned that in asm extension of gcc for hppa it exists
> > also a way to address the second word (what I tried to find for a long) of
> > a long long via the 'R' prefix as here in '%R2' [is it what you want to say
> > 'will cause bad things'?]
>
> maybe you are thinking of floating point registers? %r2 is general
> register number 2, i.e. the return pointer. it is not what you want to
> store into memory.
The 'R' operand code selects the second half of a register pair. So
'%R2' refers to the second half of operand 2 in the asm. Look at
print_operand in pa.c to see the available codes for asms.
Dave
--
J. David Anglin dave.anglin@nrc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [parisc-linux] Re: uaccess ya patch
2002-11-26 17:31 ` John David Anglin
@ 2002-11-26 18:44 ` Randolph Chung
2002-11-26 18:56 ` John David Anglin
0 siblings, 1 reply; 7+ messages in thread
From: Randolph Chung @ 2002-11-26 18:44 UTC (permalink / raw)
To: John David Anglin; +Cc: jsoe0708, parisc-linux
> > maybe you are thinking of floating point registers? %r2 is general
> > register number 2, i.e. the return pointer. it is not what you want to
> > store into memory.
>
> The 'R' operand code selects the second half of a register pair. So
> '%R2' refers to the second half of operand 2 in the asm. Look at
> print_operand in pa.c to see the available codes for asms.
oh, i see, somehow i thought %R2 == %r2...
i guess if a 64-bit number is always passed in a way that we can access
the first half as %1 and the second half as %1R then we can do away with
the masking....
randolph
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [parisc-linux] Re: uaccess ya patch
2002-11-26 18:44 ` Randolph Chung
@ 2002-11-26 18:56 ` John David Anglin
0 siblings, 0 replies; 7+ messages in thread
From: John David Anglin @ 2002-11-26 18:56 UTC (permalink / raw)
To: randolph; +Cc: jsoe0708, parisc-linux
> i guess if a 64-bit number is always passed in a way that we can access
> the first half as %1 and the second half as %1R then we can do away with
> the masking....
That should be %R1. The form %1R is what you might use to select the
right half of a floating point register. In this, the R is just a
regular character. When the R follows the % character, it is an
operand modifier.
GCC always uses consecutive registers for objects larger than a word,
at least in the initial rtl generation. It is possible to split large
modes after reload for better register utilization but we don't
currently do it on the PA.
I have been working in the last few days on improving support for
non-consecutive groups of registers. At the moment, they are just
used for function arguments and return values. The hppa64 port
currently returns incorrectly justified small structures and we need
some enhancement to the current register group support to fix this..
Dave
--
J. David Anglin dave.anglin@nrc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-11-26 18:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-26 10:05 [parisc-linux] uaccess ya patch jsoe0708
2002-11-26 16:29 ` [parisc-linux] " Randolph Chung
2002-11-26 17:02 ` jsoe0708
2002-11-26 17:22 ` Randolph Chung
2002-11-26 17:31 ` John David Anglin
2002-11-26 18:44 ` Randolph Chung
2002-11-26 18:56 ` John David Anglin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox