Run x86_64 code on x86 (32 bit) Linux running on x86_64 processor

? Can I run x86_64 code on i686 Linux (x86, 32-bit)? My processor is a modern Core 2, and it can run x86_64 64-bit code, but 32bit OS.

The initial code is purely mathematical, and it practically does not need to interact with the OS.

I want to measure how fast my program will be in 64-bit mode compared to 32-bit mode. The program is to solve a huge combinatorial problem and execute a full size of tens of hours.

I can run 64-bit code with qemu, but this will not be my own execution, and the speed in qemu will not be related to the actual processor speed.

+1
source share
3 answers

You cannot run x86_64 programs on a 32-bit kernel without any emulation. (Another way works fine, albeit without emulation.)

To be able to run 64-bit code on x86_64, you need to enter "long mode", for which you need to configure the appropriate page tables (among other things). The 32-bit kernel will not make any 64-bit tables or mappings. Thus, user space code cannot enter 64 bit mode. Perhaps with some help the kernel, but the 32-bit kernel is simply not ready for such things.

And since you can run 32-bit code just fine with a 64-bit kernel, there is currently no real reason not to use a 64-bit kernel, especially if you have code that can benefit from 64-bit mode (in particular , more registers).

Why don't you just boot from the 64-bit live-cd? Or install a 64-bit distribution on a separate disk or partition?

+3
source

Use vmware; it will work just fine, running on a 64-bit virtual machine on a 32-bit host OS, if the processor supports it.

+1
source

There is an exact simulator for x86 / x86_64. By default, it will emulate AMD K8

PTLsim is a state-of-the-art precision microprocessor simulator and virtual machine for x86 and x86-64 instruction sets. PTLsim simulates a complete processor core with extensive memory and industry specs with playback, a highly configurable cluster microarchitecture with various error queue designs, a complete cache hierarchy and memory subsystem, and hardware support.

Unfortunately, it cannot run x86_64 code on a x86 32-bit version (see frequently asked questions)

Of course, 32-bit version of PTLsim will not support x86-64

But speed should correlate with real mileage and a lot of information is available.

0
source

Source: https://habr.com/ru/post/895499/


All Articles