简体   繁体   English

在 x86 (32bit) Linux 上启动 x86_64 代码,在 x86_64 CPU 上运行

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

?Is it possible to start an x86_64 code on i686 Linux (x86, 32-bit)? ?是否可以在 i686 Linux(x86,32 位)上启动 x86_64 代码? My CPU is modern Core 2 and it can run x86_64 64-bit code itself, but the OS is 32bit.我的 CPU 是现代 Core 2,它本身可以运行 x86_64 64 位代码,但操作系统是 32 位的。

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.我想测量,与 32 位模式相比,我的程序在 64 位模式下的速度有多快。 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.我可以使用 qemu 启动 64 位代码,但它不是本机执行,并且 qemu 中的速度与实际 cpu 速度无关。

You won't be able to run x86_64 programs on a 32bit kernel without some form of emulation.如果没有某种形式的仿真,您将无法在 32 位 kernel 上运行 x86_64 程序。 (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).为了能够在 x86_64 上运行 64 位代码,您必须进入“长模式”,这需要设置适当的页表(除其他外)。 A 32bit kernel won't have done any 64bit page tables or mappings. 32 位 kernel 不会完成任何 64 位页表或映射。 So userspace code can't enter 64bit mode.所以用户空间代码不能进入64位模式。 It might be possible with some kernel help, but a 32bit kernel is simply not prepared for that kind of thing.一些 kernel 帮助可能是可能的,但是 32 位 kernel 根本没有为这种事情做好准备。

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).而且由于您可以使用 64 位 kernel 很好地运行 32 位代码,因此现在没有真正的理由不使用 64 位 kernel,特别是如果您有一些可以从 64 位模式中受益的代码(尤其是更多寄存器)。

Why don't you just boot from a 64bit live-cd?为什么不直接从 64 位 live-cd 启动? Or install a 64bit distribution on a separate disk or partition?或者在单独的磁盘或分区上安装 64 位发行版?

Use vmware;使用vmware; it will work just fine running a 64-bit VM on a 32-bit host OS provided the CPU supports it.如果 CPU 支持,它可以在 32 位主机操作系统上运行 64 位 VM 正常工作。

There is a cycle-accurate simulator for x86/x86_64. x86/x86_64 有一个周期精确的模拟器。 By default it will emulate AMD's K8默认情况下,它将模拟 AMD 的 K8

PTLsim is a state of the art cycle accurate microprocessor simulator and virtual machine for the x86 and x86-64 instruction sets. PTLsim 是 state 的艺术周期精确微处理器模拟器和虚拟机,适用于 x86 和 x86-64 指令集。 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. PTLsim 模拟一个完整的无序处理器内核,具有广泛的 memory 和带重放的分支推测、具有各种问题队列设计的高度可配置的集群微架构、完整的缓存层次结构和 memory 子系统和支持硬件。

Unfortunately it can't run an x86_64 code on 32-bit x86 (cite from FAQ)不幸的是,它无法在 32 位 x86 上运行 x86_64 代码(引用自常见问题解答)

Of course, the 32-bit version of PTLsim will lack x86-64 support当然,32位版本的PTLsim会缺少x86-64支持

But the speed should correlate with real run and a lot of information is available.但是速度应该与实际运行相关,并且有很多信息可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM