在x86_64 CPU上运行的x86(32bit)Linux上启动x86_64代码 [英] Start x86_64 code on x86 (32bit) Linux, running on x86_64 CPU

查看:289
本文介绍了在x86_64 CPU上运行的x86(32bit)Linux上启动x86_64代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

?是否可以在i686 Linux(x86,32位)上启动x86_64代码?我的CPU是现代的Core 2,它本身可以运行x86_64 64位代码,但操作系统是32位.

?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.

开始的代码是纯数学的,几乎不需要与OS交互.

The code to start is pure mathematic, and it need almost no interaction with OS.

我想测量一下,与32位模式相比,我的程序在64位模式下运行有多快.该程序将解决巨大的组合问题,全尺寸运行需要数十个小时.

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.

我可以使用qemu启动64位代码,但是它不是本机执行,并且qemu中的速度与实际cpu速度无关.

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.

推荐答案

如果没有某种形式的仿真,您将无法在32位内核上运行x86_64程序. (但是,另一种方法可以很好地运行,无需仿真.)

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.)

要在x86_64上运行64位代码,必须输入长模式",这需要设置适当的页表(除其他外). 32位内核不会完成任何64位页表或映射.因此,用户空间代码无法进入64位模式.在某些内核帮助下可能是有可能的,但是根本没有为这种事情准备32位内核.

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.

并且由于您可以在64位内核上运行32位代码就很好了,因此,现在没有任何理由不使用64位内核,特别是如果您有一些可以从64位模式中受益的代码,则 (尤其是更多的寄存器).

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位live-cd引导?还是在单独的磁盘或分区上安装64位发行版?

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

这篇关于在x86_64 CPU上运行的x86(32bit)Linux上启动x86_64代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆