Start x86_64 code on x86 (32bit) Linux, running on x86_64 CPU

前端 未结 3 1163
-上瘾入骨i
-上瘾入骨i 2021-01-15 20:52

?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

相关标签:
3条回答
  • 2021-01-15 21:04

    Use vmware; it will work just fine running a 64-bit VM on a 32-bit host OS provided the CPU supports it.

    0 讨论(0)
  • 2021-01-15 21:06

    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?

    0 讨论(0)
  • 2021-01-15 21:16

    There is a cycle-accurate simulator for x86/x86_64. By default it will emulate AMD's K8

    PTLsim is a state of the art cycle accurate microprocessor simulator and virtual machine for the x86 and x86-64 instruction sets. PTLsim models a full out of order processor core, featuring extensive memory and branch speculation with replay, a highly configurable clustered microarchitecture with various issue queue designs, a full cache hierarchy and memory subsystem and supporting hardware.

    Unfortunately it can't run an x86_64 code on 32-bit x86 (cite from FAQ)

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

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

    0 讨论(0)
提交回复
热议问题