Skip to contentSkip to conversation

linux kernel building for mips malta target board

DISCUSSION David Daney 4 participants 8 messages Nov 3, 2005 – Jan 18, 2006 1 message not in the archive MIPS

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 10 lines · [email protected] wrote:
Quoted 6 lines
Quoted 3 lines

I would like to build latest kernel (ie kernel 2.6.13) for mips malta
board. Can any one advise me the cross-compiler tools version to be used for building the linux kernel.

I use both gcc-3.3.1 and gcc-3.4.3 to build 2.6.x mips linux kernels. I think for the 2.6.13 kernel any of the latest released versions of 3.3.x, 3.4.x, or 4.0.x would work. Use the latest binutils (2.16.91 20050817 is what I am using).

Also, make sure to NOT use any of the 4.1 GCC stuff with Linux/MIPS kernels. I am still tracking down errors with it.

Is this the problem you are seeing?:
In file included from include/linux/nfs_fs.h:15,

                 from init/do_mounts.c:12:

include/linux/pagemap.h: In function ‘fault_in_pages_readable’:
include/linux/pagemap.h:236: error: read-only variable ‘__gu_val’ used as ‘asm’ output include/linux/pagemap.h:236: error: read-only variable ‘__gu_val’ used as ‘asm’ output include/linux/pagemap.h:236: error: read-only variable ‘__gu_val’ used as ‘asm’ output include/linux/pagemap.h:236: error: read-only variable ‘__gu_val’ used as ‘asm’ output

The compiler behavior has changed since 4.0.1, but I think the new behavior is correct. I am blaming the __get_user macro in include/asm-mips/uaccess.h. It should be possible to fix it there. The alternative is to hack up include/linux/pagemap.h.

David Daney

#2 lore raw
Quoted 10 lines · David Daney

Is this the problem you are seeing?:
In file included from include/linux/nfs_fs.h:15,

                from init/do_mounts.c:12:

include/linux/pagemap.h: In function fault_in_pages_readable:
include/linux/pagemap.h:236: error: read-only variable __gu_val used as asm output include/linux/pagemap.h:236: error: read-only variable __gu_val used as asm output include/linux/pagemap.h:236: error: read-only variable __gu_val used as asm output include/linux/pagemap.h:236: error: read-only variable __gu_val used as asm output

The compiler behavior has changed since 4.0.1, but I think the new behavior is correct. I am blaming the __get_user macro in include/asm-mips/uaccess.h. It should be possible to fix it there. The alternative is to hack up include/linux/pagemap.h.

__get_user() is unhappy, with tpyes that are "const". It uses __typeof()
to create a local variable that it wants to write to. I've intended to
have offer up a patch by now, but, too manyunexpected thing have happened in the firs thalf of this week.

Stuart

Stuart R. Anderson                               [email protected]
Network & Software Engineering                   http://www.netsweng.com/
1024D/37A79149:                                  0791 D3B8 9A4C 2CDC A31F
                                                  BD03 0A62 E534 37A7 9149
#3 lore raw
Quoted 11 lines · Stuart Anderson
Quoted 9 lines · David Daney

Is this the problem you are seeing?:
In file included from include/linux/nfs_fs.h:15,

                from init/do_mounts.c:12:

include/linux/pagemap.h: In function fault_in_pages_readable:
include/linux/pagemap.h:236: error: read-only variable __gu_val used as asm output include/linux/pagemap.h:236: error: read-only variable __gu_val used as asm output include/linux/pagemap.h:236: error: read-only variable __gu_val used as asm output include/linux/pagemap.h:236: error: read-only variable __gu_val used as asm output

Quoted 7 lines
Quoted 1 line

The compiler behavior has changed since 4.0.1, but I think the new behavior is correct. I am blaming the __get_user macro in include/asm-mips/uaccess.h. It should be possible to fix it there. The alternative is to hack up include/linux/pagemap.h.

__get_user() is unhappy, with tpyes that are "const". It uses __typeof()
to create a local variable that it wants to write to. I've intended to
have offer up a patch by now, but, too manyunexpected thing have happened in the firs thalf of this week.

That is my analysis as well. The typeof converts the const char * into a const char which is then unsuitable as the destination in an inline asm.

David Daney

#4 lore raw
Quoted 3 lines · David Daney
Quoted 3 lines

__get_user() is unhappy, with tpyes that are "const". It uses __typeof()
to create a local variable that it wants to write to. I've intended to
have offer up a patch by now, but, too many unexpected thing have happened in the firs thalf of this week.

I shamed myself into sitting down and doing this. 8-)

The attached patch seems to work, or at least doesn't seem to cause things to blow up. An o32 userspace on a 64-bit kernel comes up multi-user and can build a kernel, and run a quick subset of LTP.

There was a comment on IRC that there was a register allocation issue which lead to the current code. I'm not sure of the exact details, but I _think_ this change ends up being equivilent to the code it replaces.

Stuart

Stuart R. Anderson                               [email protected]
Network & Software Engineering                   http://www.netsweng.com/
1024D/37A79149:                                  0791 D3B8 9A4C 2CDC A31F
                                                 BD03 0A62 E534 37A7 9149
uaccess.h +24 -6
Index: uaccess.h
===================================================================
@@ -210,17 +210,35 @@
 
 #define __get_user_nocheck(x,ptr,size)					\
 ({									\
-	__typeof(*(ptr)) __gu_val =  (__typeof(*(ptr))) 0;		\
 	long __gu_err = 0;						\
 									\
 	switch (size) {							\
-	case 1: __get_user_asm("lb", ptr); break;			\
-	case 2: __get_user_asm("lh", ptr); break;			\
-	case 4: __get_user_asm("lw", ptr); break;			\
-	case 8: __GET_USER_DW(ptr); break;				\
+	case 1: {							\
+		s8 __gu_val =  (s8) 0;					\
+		__get_user_asm("lb", ptr); 				\
+		(x) = (__typeof__(*(ptr))) __gu_val;			\
+		break;							\
+		}							\
+	case 2:	{							\
+		s16 __gu_val =  (s16) 0;				\
+		__get_user_asm("lh", ptr);				\
+		(x) = (__typeof__(*(ptr))) __gu_val;			\
+		break;							\
+		}							\
+	case 4:	{							\
+		s32 __gu_val = (s32) 0;					\
+		__get_user_asm("lw", ptr);				\
+		(x) = (__typeof__(*(ptr))) __gu_val;			\
+		break;							\
+		}							\
+	case 8:	{							\
+		s64 __gu_val = (s64) 0;					\
+		__GET_USER_DW(ptr);					\
+		(x) = (__typeof__(*(ptr))) __gu_val;			\
+		break;							\
+		}							\
 	default: __get_user_unknown(); break;				\
 	}								\
-	(x) = (__typeof__(*(ptr))) __gu_val;				\
 	__gu_err;							\
 })
 
#5 lore raw
Quoted 9 lines

I shamed myself into sitting down and doing this. 8-)

The attached patch seems to work, or at least doesn't seem to cause things to blow up. An o32 userspace on a 64-bit kernel comes up multi-user and can build a kernel, and run a quick subset of LTP.

There was a comment on IRC that there was a register allocation issue which lead to the current code. I'm not sure of the exact details, but I _think_ this change ends up being equivilent to the code it replaces.

It's correct - but triggers plenty of extra warnings and you forgot about get_user() which has the same kind of issue. Also you don't have the guarantee that <linux/types.h> has been included, so in order to avoid a yet another header file dependency I changed s8, s16 etc. to char, short, int, long long. Working on it but as usual uaccess.h is quite a quiz.

Ralf

#6 lore raw
Quoted 9 lines · Ralf Baechle
Quoted 3 lines

There was a comment on IRC that there was a register allocation issue which lead to the current code. I'm not sure of the exact details, but I _think_ this change ends up being equivilent to the code it replaces.

It's correct - but triggers plenty of extra warnings and you forgot about get_user() which has the same kind of issue. Also you don't have the guarantee that <linux/types.h> has been included, so in order to avoid a yet another header file dependency I changed s8, s16 etc. to char, short, int, long long. Working on it but as usual uaccess.h is quite a quiz.

What's the status of this?

With current linux-mips git I still get the problem. As a reminder, the error is:

CC fs/compat_ioctl.o
fs/compat_ioctl.c: In function 'fd_ioctl_trans':
fs/compat_ioctl.c:1831: error: read-only variable '__gu_val' used as 'asm' output fs/compat_ioctl.c:1831: error: read-only variable '__gu_val' used as 'asm' output fs/compat_ioctl.c:1831: error: read-only variable '__gu_val' used as 'asm' output fs/compat_ioctl.c:1831: error: read-only variable '__gu_val' used as 'asm' output make[1]: *** [fs/compat_ioctl.o] Error 1

Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/
#7 lore raw
Quoted 16 lines · Martin Michlmayr
Quoted 9 lines · Ralf Baechle
Quoted 3 lines

There was a comment on IRC that there was a register allocation issue which lead to the current code. I'm not sure of the exact details, but I _think_ this change ends up being equivilent to the code it replaces.

It's correct - but triggers plenty of extra warnings and you forgot about get_user() which has the same kind of issue. Also you don't have the guarantee that <linux/types.h> has been included, so in order to avoid a yet another header file dependency I changed s8, s16 etc. to char, short, int, long long. Working on it but as usual uaccess.h is quite a quiz.

What's the status of this?

With current linux-mips git I still get the problem. As a reminder, the error is:

Quoted 7 lines

CC fs/compat_ioctl.o
fs/compat_ioctl.c: In function 'fd_ioctl_trans':
fs/compat_ioctl.c:1831: error: read-only variable '__gu_val' used as 'asm' output fs/compat_ioctl.c:1831: error: read-only variable '__gu_val' used as 'asm' output fs/compat_ioctl.c:1831: error: read-only variable '__gu_val' used as 'asm' output fs/compat_ioctl.c:1831: error: read-only variable '__gu_val' used as 'asm' output make[1]: *** [fs/compat_ioctl.o] Error 1

I have not been able to find some construct that keeps gcc happy and at the same time doesn't result in significantly worse code. That matters because get_user / put_user are used very often throughout the kernel.

Ralf

#8 lore raw
Quoted 9 lines · Ralf Baechle
Quoted 6 lines

With current linux-mips git I still get the problem. As a reminder, the error is:

CC fs/compat_ioctl.o
fs/compat_ioctl.c: In function 'fd_ioctl_trans':
fs/compat_ioctl.c:1831: error: read-only variable '__gu_val' used as 'asm' output

I have not been able to find some construct that keeps gcc happy and at the same time doesn't result in significantly worse code. That matters because get_user / put_user are used very often throughout the kernel.

Who could help with that? Maciej? David Daney?

(See the original discussion and the proposed patch at
http://www.spinics.net/lists/mips/msg20671.html)

Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/