Skip to contentSkip to conversation

MIPS: Make UTS_MACHINE reflect big-endian/little-endian

RFC PATCH In review Huacai Chen 3 participants 4 messages Jul 11, 2018 – Jul 12, 2018 MIPS

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 MIPS: Make UTS_MACHINE reflect big-endian/little-endian

It seems like some application use "uname" command's output to do something different between big-endian and little-endian, so we make UTS_MACHINE reflect both 32bit/64bit and big-endian/little-endian.

---
 arch/mips/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/Makefile +2 -2
index e2122cc..a21c3a1 100644
@@ -38,11 +38,11 @@ endif
 
 ifdef CONFIG_32BIT
 tool-archpref		= $(32bit-tool-archpref)
-UTS_MACHINE		:= mips
+UTS_MACHINE		:= $(32bit-tool-archpref)
 endif
 ifdef CONFIG_64BIT
 tool-archpref		= $(64bit-tool-archpref)
-UTS_MACHINE		:= mips64
+UTS_MACHINE		:= $(64bit-tool-archpref)
 endif
 
 ifneq ($(SUBARCH),$(ARCH))
Signature · 1 line
2.7.0
#1 lore raw

Hi Huacai,

Quoted 3 lines · Huacai Chen

It seems like some application use "uname" command's output to do something different between big-endian and little-endian, so we make UTS_MACHINE reflect both 32bit/64bit and big-endian/little-endian.

Since UTS_MACHINE is exposed to userland (which is of course the point of your patch) I'm not comfortable changing it. If some piece of code checks whether uname -m gives "mips" then we'd break it by suddenly giving "mipsel". This is too risky.

Which applications are you talking about that look for endianness in uname output? Since Linux on MIPS doesn't expose endianness information in this way these applications will always have been broken on MIPS systems, and it would make more sense to fix the applications than to change the kernel & probably break others.

Thanks,
Paul

Quoted 16 lines
arch/mips/Makefile +2 -2
index e2122cc..a21c3a1 100644
@@ -38,11 +38,11 @@ endif
 
 ifdef CONFIG_32BIT
 tool-archpref		= $(32bit-tool-archpref)
-UTS_MACHINE		:= mips
+UTS_MACHINE		:= $(32bit-tool-archpref)
 endif
 ifdef CONFIG_64BIT
 tool-archpref		= $(64bit-tool-archpref)
-UTS_MACHINE		:= mips64
+UTS_MACHINE		:= $(64bit-tool-archpref)
 endif
#2 lore raw
Quoted 12 lines · Paul Burton

Hi Huacai,

Quoted 3 lines · Huacai Chen

It seems like some application use "uname" command's output to do something different between big-endian and little-endian, so we make UTS_MACHINE reflect both 32bit/64bit and big-endian/little-endian.

Since UTS_MACHINE is exposed to userland (which is of course the point of your patch) I'm not comfortable changing it. If some piece of code checks whether uname -m gives "mips" then we'd break it by suddenly giving "mipsel". This is too risky.

Quoted 5 lines

Which applications are you talking about that look for endianness in uname output? Since Linux on MIPS doesn't expose endianness information in this way these applications will always have been broken on MIPS systems, and it would make more sense to fix the applications than to change the kernel & probably break others.

Hi, we are making Fedora on MIPS, we found that yum use uname's output to adjust endianness compatibility. We haven't seen anything broken while we changing mips64 to mips64el, do you know something about "broken things with this changing". I also don't want to change UTS_MACHINE, but if it is harmless, I think we can just do it.

Quoted 20 lines

Thanks,
Paul

Quoted 16 lines
arch/mips/Makefile +2 -2
index e2122cc..a21c3a1 100644
@@ -38,11 +38,11 @@ endif
 
 ifdef CONFIG_32BIT
 tool-archpref                = $(32bit-tool-archpref)
-UTS_MACHINE          := mips
+UTS_MACHINE          := $(32bit-tool-archpref)
 endif
 ifdef CONFIG_64BIT
 tool-archpref                = $(64bit-tool-archpref)
-UTS_MACHINE          := mips64
+UTS_MACHINE          := $(64bit-tool-archpref)
 endif
#3 lore raw

Hi Huacai,

Quoted 15 lines · Huacai Chen
Quoted 9 lines
Quoted 3 lines

It seems like some application use "uname" command's output to do something different between big-endian and little-endian, so we make UTS_MACHINE reflect both 32bit/64bit and big-endian/little-endian.

Since UTS_MACHINE is exposed to userland (which is of course the point of your patch) I'm not comfortable changing it. If some piece of code checks whether uname -m gives "mips" then we'd break it by suddenly giving "mipsel". This is too risky.

Quoted 5 lines

Which applications are you talking about that look for endianness in uname output? Since Linux on MIPS doesn't expose endianness information in this way these applications will always have been broken on MIPS systems, and it would make more sense to fix the applications than to change the kernel & probably break others.

Quoted 5 lines

Hi, we are making Fedora on MIPS, we found that yum use uname's output to adjust endianness compatibility. We haven't seen anything broken while we changing mips64 to mips64el, do you know something about "broken things with this changing". I also don't want to change UTS_MACHINE, but if it is harmless, I think we can just do it.

A quick GitHub code search find a ton of things which check uname -m, some of which expect the exact string "mips":

    https://github.com/search?l=&p=1&q=uname+-m+mips&type=Code

UTS_MACHINE is not something to change.

Can you just have yum detect endianness some other way? Wikipedia tells me yum is written in python, and a quick Google tells me there's a sys.byteorder variable which would indicate endianness. Can you just use that?

Thanks,
Paul