?Is it possible to start an x86_64 code on i686 Linux (x86, 32-bit)? My CPU is modern Core 2 and it can run x86_64 64-bit code itself, but the OS is 32bit.
The code to start is pure mathematic, and it need almost no interaction with OS.
I want to measure, how fast will be my program in 64bit mode comparing with 32-bit mode. The program is to solve huge combinatoric problem and full size run is dozens of hours.
I can start 64bit code with qemu, but it will be not native execution and speed in qemu will be not related to real cpu speed.
You won’t be able to run x86_64 programs on a 32bit kernel without some form of emulation. (The other way around works just fine though, with no emulation.)
To be able to run 64bit code on x86_64, you have to enter “long mode” which requires the appropriate page tables to be set up (among other things). A 32bit kernel won’t have done any 64bit page tables or mappings. So userspace code can’t enter 64bit mode. It might be possible with some kernel help, but a 32bit kernel is simply not prepared for that kind of thing.
And since you can run 32bit code just fine with a 64bit kernel, there is no real reason not to use a 64bit kernel these days, especially if you have some code that could benefit from 64bit mode (more registers in particular).
Why don’t you just boot from a 64bit live-cd? Or install a 64bit distribution on a separate disk or partition?