Skip to contentSkip to conversation

running 64 bit user mode program on 32 bit host machine

Qemu-devel Yongbok Kim 2 participants 2 messages Apr 20, 2015

lore
Share & tools
lore
#0 lore raw

Hi All,

I have faced a problem to run a simple 64 bit Linux user mode application on 32 bit Linux host machines.
I did some investigation and found out that the TARGET_ELF_PAGESTART macro in the linux-user/elfload.c is causing the problem.
However I am not sure if this is the right solution as I am not familiar with the area.
Perhaps the macro should take care of target’s bits width rather than just use unsigned long.
Would you please confirm the change or suggest better solution?

Regards,
Yongbok

$  ../masterbin/mips64-linux-user/qemu-mips64 -cpu MIPS64R6-generic ./hello_linux.elf
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault (core dumped)
$ git diff
linux-user/elfload.c +1 -1
index 399c021..d99a43b 100644
@@ -1227,7 +1227,7 @@ struct exec
 
 /* Necessary parameters */
 #define TARGET_ELF_EXEC_PAGESIZE TARGET_PAGE_SIZE
-#define TARGET_ELF_PAGESTART(_v) ((_v) & ~(unsigned long)(TARGET_ELF_EXEC_PAGESIZE-1))
+#define TARGET_ELF_PAGESTART(_v) ((_v) & ~(abi_ulong)(TARGET_ELF_EXEC_PAGESIZE-1))
 #define TARGET_ELF_PAGEOFFSET(_v) ((_v) & (TARGET_ELF_EXEC_PAGESIZE-1))
 
 #define DLINFO_ITEMS 14

(END)

WITH the change:

$  ../masterbin/mips64-linux-user/qemu-mips64 -cpu MIPS64R6-generic ./hello_linux.elf
Hello World!
Reviewed-by
#1 lore raw
Quoted 31 lines · Yongbok Kim

Hi All,

I have faced a problem to run a simple 64 bit Linux user mode application on 32 bit Linux host machines.
I did some investigation and found out that the TARGET_ELF_PAGESTART macro in
the linux-user/elfload.c is causing the problem.
However I am not sure if this is the right solution as I am not familiar with
the area.
Perhaps the macro should take care of target’s bits width rather than just use
unsigned long.
Would you please confirm the change or suggest better solution?

Regards,
Yongbok

$  ../masterbin/mips64-linux-user/qemu-mips64 -cpu MIPS64R6-generic
./hello_linux.elf
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault (core dumped)
$ git diff
linux-user/elfload.c +0 -0
index 399c021..d99a43b 100644

linux-user/elfload.c struct exec · line 1233

Quoted 8 lines
linux-user/elfload.c +1 -1
@@ -1227,7 +1227,7 @@ struct exec
 
 /* Necessary parameters */
 #define TARGET_ELF_EXEC_PAGESIZE TARGET_PAGE_SIZE
-#define TARGET_ELF_PAGESTART(_v) ((_v) & ~(unsigned
 long)(TARGET_ELF_EXEC_PAGESIZE-1))
+#define TARGET_ELF_PAGESTART(_v) ((_v) &
 ~(abi_ulong)(TARGET_ELF_EXEC_PAGESIZE-1))
 #define TARGET_ELF_PAGEOFFSET(_v) ((_v) & (TARGET_ELF_EXEC_PAGESIZE-1))

I think this is a correct change. If you want to resubmit it as a properly formatted patch with your signed-off-by you can add my

thanks
-- PMM