Page 1 of 2

MSR support in Bochs

Posted: Mon Sep 03, 2007 9:06 am
by neon
Hey everyone,

Im currently setting up the MSRs to work with SYSENTER using Bochs. For some reason, I cannot seem to access the IA32_SYSENTER_CS MSR though..

Code: Select all

%define IA32_SYSENTER_CS 0x174

mov	ecx, IA32_SYSENTER_CS
wrmsr
Bochs gives me the error:
>>PANIC<< WRMSR: Unknown register 0x174
According to the intel docs, that is the correct MSR... wtf?

I was expecting Bochs to support this... Does anyone know what could be the problem?

*Hopes its not Bochs, Hopes its not Bochs*

Thanks :D

Posted: Mon Sep 03, 2007 10:08 am
by JamesM
It's not bochs, it's your code.
my code:

Code: Select all

[GLOBAL writeMsr]
writeMsr:
  mov edx, [esp+8]
  mov eax, [esp+12]
  mov ecx, [esp+4]
  wrmsr
  ret

Code: Select all

void DescriptorTables::initSyscalls()
{
  writeMsr(0x174, 0, 0x8);
  writeMsr(0x175, 0, (Address)processManager.getProcess()->getKernelStack());
  writeMsr(0x176, 0, (Address)fastSyscallHandler);
}
JamesM

Posted: Mon Sep 03, 2007 10:18 am
by neon
Im probably blind here, but I dont see any difference... :oops:

Your code does the same as mine, except it passes the parameters on the stack. The end result is still setting CS=0x174, and executing wrmsr--which is what my code does.

Posted: Mon Sep 03, 2007 10:52 am
by bluecode
Perhaps you did not configure bochs for sysenter/sysexit. There is a configure switch called
--enable-sep SYSENTER/SYSEXIT support

Posted: Mon Sep 03, 2007 11:03 am
by neon
I have Bochs 2.0.2; and it does not like that switch (Error:)
00000000000p[ ] >>PANIC<< config.txt: directive '--enable-sepSYSENTER/SYSEXITsupport' not understood
Bochs concatenated the string as shown here. (I directly copied/pasted the option you posted)

Although it does give me another place to look, though ;)

Posted: Mon Sep 03, 2007 11:36 am
by jnc100
Read again: its an option to ./configure, when you build bochs, rather than an option you pass on the command line.

Regards,
John.

Posted: Mon Sep 03, 2007 12:03 pm
by neon
I see... Thanks :D

Posted: Mon Sep 03, 2007 1:24 pm
by bluecode
The name of the option is "--enable-sep" the rest was just the explanation ./configure --help showed. Besides that 2.0.2 is a little bit out-of-date, don't you think so?

Posted: Mon Sep 03, 2007 6:48 pm
by neon
bluecode wrote:The name of the option is "--enable-sep" the rest was just the explanation ./configure --help showed. Besides that 2.0.2 is a little bit out-of-date, don't you think so?
I never actually compiled Bochs before--its a pain as I am having trouble finding a compatible toolset. Ugh. Oh well. MSVC++ 2005 fails to compile, Cygwin make failes to work :/ Then again, Im a little tired right now :)

(Im just recieving 8 compile errors from MSVC++2005). I can fix them, but then recieve an odd error from MSVC++2005--Ill display it here when I get the chance (and do a little more research on it)

Thanks for letting me know. I will attempt to get it to build through cygwin (I never personally liked cygwin--Im not sure why...)

Posted: Mon Sep 03, 2007 7:32 pm
by neon
Never mind--everything seems to be going good so far :wink: (Besides the millions of warnings MSVC++ spits out, and that I had to change a small manifest setting...ugh)

...And, this is Bochs 2.3, not the earlier version :D

Thanks! :D

Posted: Mon Sep 03, 2007 8:24 pm
by neon
Ugh.

At first I was having problems with the debug build (It halted while executing the BIOS), but after trying release build, everything seems to be working--Including setting the MSR.

...Guess it was Bochs after all.

Thanks for the help! :D

Posted: Tue Sep 04, 2007 12:38 pm
by Combuster
Over here, the bochs sources work out of the box on cygwin. Are you sure you have all the packages needed for compiling programs (autotools, make, gcc+binutils, flex, bison), and in the setup the configuration set to unix line endings and binary format?

Posted: Tue Sep 04, 2007 3:45 pm
by JamesM
I just installed the debian binary and it worked fine...

Code: Select all

sudo apt-get install bochs bochs-x11

Posted: Tue Sep 04, 2007 3:48 pm
by Combuster
JamesM wrote:the debian binary
Would someone with visual studio and cygwin be interested in a linux binary? :wink:

Posted: Tue Sep 04, 2007 3:52 pm
by pcmattman
I built Bochs under Cygwin with no problems at all. The only bumps in the process were the configuration options, which are not very well described in the manual.
Would someone with visual studio and cygwin be interested in a linux binary?
I would, if it's a program I've been working on that I want to port to Linux and don't have a spare distro lying around :lol: .