Skip to contentSkip to conversation

uaccess ya patch

parisc-linux [email protected] 4 participants 7 messages Nov 26, 2002

lore
Share & tools
lore
#0 lore raw

Hi Randolph,

Much more for info, here is another way I found to implement __put_?_asm64.

uaccess.h renamed from uaccess.h.orig +41 -41
@@ -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

uaccess.h renamed from uaccess.h.orig +41 -41

128 lines not on this page · raw message

#1 lore raw
Quoted 1 line

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:

uaccess.h line 240

Quoted 4 lines
uaccess.h renamed from uaccess.h.orig +4 -0
+#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

Signature · 3 lines
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
#2 lore raw
Quoted 10 lines
Quoted 1 line

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:

uaccess.h line 240

Quoted 4 lines
uaccess.h renamed from uaccess.h.orig +4 -0
+#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

#3 lore raw
Quoted 4 lines

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.

Quoted 1 line

(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

#4 lore raw
Quoted 8 lines
Quoted 4 lines

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

Signature · 2 lines
J. David Anglin                                  [email protected]
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)
#5 lore raw
Quoted 7 lines
Quoted 3 lines

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

Signature · 3 lines
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
#6 lore raw
Quoted 3 lines

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

Signature · 2 lines
J. David Anglin                                  [email protected]
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)