MSR support in Bochs

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

MSR support in Bochs

Post 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
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post 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.
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Post by bluecode »

Perhaps you did not configure bochs for sysenter/sysexit. There is a configure switch called
--enable-sep SYSENTER/SYSEXIT support
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post 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 ;)
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Post 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.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post by neon »

I see... Thanks :D
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Post 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?
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post 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...)
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post 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
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post 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
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

I just installed the debian binary and it worked fine...

Code: Select all

sudo apt-get install bochs bochs-x11
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

JamesM wrote:the debian binary
Would someone with visual studio and cygwin be interested in a linux binary? :wink:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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: .
Post Reply