Page 1 of 1

Bochs & SYSENTER

Posted: Fri Sep 21, 2007 3:15 am
by JamesM
Hi guys,

I'm currently trying to compile/run my kernel in bochs here at work. The problem is I'm getting an invalid opcode exception when bochs encounters the instruction 'sysenter' (which, obviously, does not happen at home)

I'm using v2.3 here, the 32-bit version (I've noticed on my home one it comes up as "Bochs: x86-64 emulator" whereas here it's missing the 64.

The systenter instruction was introduced in the PentiumII (?) IIRC so I wonder why it's not implemented in this version of bochs?

Does anyone have any ideas? Do I have to update my bochs install?

EDIT: trying to get the specific version number: bochs doesn't have a --version or -v argument - anyone know how to query it?

Posted: Fri Sep 21, 2007 3:36 am
by Solar
From Bochs user guide, 3.4 Compiling Bochs, 3.4.2 Configure Options:

Option: --enable-cpu-level={3,4,5,6}
Default: 5
Comments: Select which CPU level to emulate. Choices are 3,4,5,6 which mean to target 386, 486, Pentium, or Pentium Pro emulation. Pentium Pro support is quite incomplete, so level 5 is the best choice for now.


Ergo, by default Bochs emulates a Pentium.

Posted: Fri Sep 21, 2007 3:42 am
by Combuster
I'd be tempted to say that you should check CPUID before using special processor instructions :roll:

Bochs' version is displayed whenever you start it. It will not, however, show you the ./configure options which are just as interesting to know.

Anyway, if you require sysenter, you'll have to compile bochs manually. Open cygwin, download the sources, then type ./configure --help which will tell you everything.

Posted: Fri Sep 21, 2007 3:55 am
by JamesM
Cheers guys. Looks like '6' for me. I had actually compiled it from source anyway combuster.

And when you start bochs, it will show you only the first two major version numbers (e.g. mine shows '2.3', not '2.3.1')

Combuster: the advantage to checking CPUID for sysenter would be to print a lovely helpful "this kernel will not run, fool" message, as all my syscalls except fork/exec are implemented using sysenter/sysexit! :?

Posted: Fri Sep 21, 2007 6:15 am
by bluecode
JamesM wrote:And when you start bochs, it will show you only the first two major version numbers (e.g. mine shows '2.3', not '2.3.1')

I don't know of a bochs version 2.3.1
And for me bochs shows 2.3.5 correctly.

Posted: Fri Sep 21, 2007 6:48 am
by Solar
bluecode wrote:I don't know of a bochs version 2.3.1


I do.

Posted: Fri Sep 21, 2007 7:01 am
by gaf
Cheers guys. Looks like '6' for me. I had actually compiled it from source anyway combuster


Support for sysenter/sysexit isn't linked to any cpu-level, but rather has to be additionally enabled at compile time. Try running ./configure --enable-sep and have a look at the bochs (user) documentation for more details.

cheers,
gaf

Posted: Fri Sep 21, 2007 8:02 am
by bluecode
Solar wrote:
bluecode wrote:I don't know of a bochs version 2.3.1

I do.

I must be blind. :D Sorry.

Posted: Fri Sep 21, 2007 8:14 am
by JamesM
Support for sysenter/sysexit isn't linked to any cpu-level, but rather has to be additionally enabled at compile time. Try running ./configure --enable-sep and have a look at the bochs (user) documentation for more details.


Well I compiled it with machine-level=6 and it works. So I'm a happy chappy.

Partially, anyway. I'm having real difficulty compiling my code on this different computer. I've now installed a custom g++/gcc and binutils, and STILL linker errors that don't plague me at home are appearing. Currently they seem to be related to duplicate symbol names between object files and a shared library. On my system if it finds a duplicate symbol in a shared library it just quietly ignores it.

I never realised just how much difference there was between gcc/ld versions and just how easily they can break!