OSDev.org
https://forum.osdev.org/

Bochs & SYSENTER
https://forum.osdev.org/viewtopic.php?f=1&t=15001
Page 1 of 1

Author:  JamesM [ Fri Sep 21, 2007 3:15 am ]
Post subject:  Bochs & SYSENTER

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?

Author:  Solar [ Fri Sep 21, 2007 3:36 am ]
Post subject: 

From Bochs user guide, 3.4 Compiling Bochs, 3.4.2 Configure Options:

Quote:
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.

Author:  Combuster [ Fri Sep 21, 2007 3:42 am ]
Post subject: 

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.

Author:  JamesM [ Fri Sep 21, 2007 3:55 am ]
Post subject: 

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! :?

Author:  bluecode [ Fri Sep 21, 2007 6:15 am ]
Post subject: 

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.

Author:  Solar [ Fri Sep 21, 2007 6:48 am ]
Post subject: 

bluecode wrote:
I don't know of a bochs version 2.3.1


I do.

Author:  gaf [ Fri Sep 21, 2007 7:01 am ]
Post subject: 

Quote:
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

Author:  bluecode [ Fri Sep 21, 2007 8:02 am ]
Post subject: 

Solar wrote:
bluecode wrote:
I don't know of a bochs version 2.3.1

I do.

I must be blind. :D Sorry.

Author:  JamesM [ Fri Sep 21, 2007 8:14 am ]
Post subject: 

Quote:
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!

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/