OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Apr 22, 2019 2:08 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: RDRAND eax crashes in Bochs
PostPosted: Thu Dec 13, 2018 3:19 pm 
Offline
Member
Member

Joined: Sun Oct 21, 2018 1:37 pm
Posts: 38
Hello,

does anyone know why RDRAND eax crashes in bochs in Protected Mode?

For what I have seen, it seems to be implemented (http://bochs.sourceforge.net/cgi-bin/lxr/source/cpu/rdrand.cc)

Checking some documentation I found this exceptions for Protected Mode (and others)

#UD If the LOCK prefix is used.
If the F2H or F3H prefix is used.
If CPUID.01H:ECX.RDRAND[bit 30] = 0.

I think the last one means that the CPU does not support RDRAND, but I cannot understand the meaning of the first two.

Any help will be very welcomed !!

Thanks in advance


Top
 Profile  
 
 Post subject: Re: RDRAND eax crashes in Bochs
PostPosted: Thu Dec 13, 2018 11:21 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 177
LOCK can't be used with RDRAND, and you'll get #UD if you try. Same with the REP prefixes (F2 and F3).


Top
 Profile  
 
 Post subject: Re: RDRAND eax crashes in Bochs
PostPosted: Fri Dec 14, 2018 1:37 am 
Offline
Member
Member

Joined: Sun Oct 21, 2018 1:37 pm
Posts: 38
nullplan wrote:
LOCK can't be used with RDRAND, and you'll get #UD if you try. Same with the REP prefixes (F2 and F3).


Hello nullplan, first of all thanks for your answer!

I am simply using:

RDRAND eax , and trying to compile it with NASM. In runtime, it is executed in 32bits, Protected Mode, but Bochs simply crashes.

Those exceptions is just documentation I found about the RDRAND instructions, trying to figure out why it crashes.

Thanks!


Top
 Profile  
 
 Post subject: Re: RDRAND eax crashes in Bochs
PostPosted: Fri Dec 14, 2018 1:52 am 
Offline
Member
Member

Joined: Wed Sep 19, 2012 3:43 am
Posts: 80
Location: The Netherlands
What does your bochs log say?


Top
 Profile  
 
 Post subject: Re: RDRAND eax crashes in Bochs
PostPosted: Fri Dec 14, 2018 4:48 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3355
Location: Chichester, UK
What is the version number of your Bochs?


Top
 Profile  
 
 Post subject: Re: RDRAND eax crashes in Bochs
PostPosted: Fri Dec 14, 2018 5:27 am 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 393
I suspect that your BOCHs hasn't been compiled with the support needed. You'll need to get the latest version 2.6.9 (or latest SVN snapshot) of the source code. You'll have to build it with at least these options: --enable-x86-64 --enable-cpu-level=6 --enable-avx. If using Linux with X-windows then configuring with this command should suffice:
Code:
./configure --enable-x86-64 --enable-cpu-level=6 --enable-avx --enable-smp --enable-all-optimizations --enable-pci --enable-debugger --enable-disasm --enable-debugger-gui --enable-logging --enable-fpu --enable-3dnow --enable-cdrom --enable-x86-debugger --enable-iodebug --disable-plugins --disable-docbook --with-x --with-x11 --with-term
make
sudo make install
Then you'll need to edit the CPU options and select at least a corei7_ivy_bridge_3770k that supports rdrand. You can tell what CPUs your BOCHs supports with: bochs -help cpu. If skylake/haswell/ivybridge aren't listed you will need to build a new version.When compiling your own, unless you override the prefix the installed bochs will be at /usr/local/bin/bochs


Top
 Profile  
 
 Post subject: Re: RDRAND eax crashes in Bochs
PostPosted: Fri Dec 14, 2018 6:27 am 
Offline
Member
Member

Joined: Fri Apr 04, 2008 6:43 am
Posts: 339
What does it mean - crashes ? Segfaults and dies ? Or emulated app closes with some error ?

Also - which version are you trying ?
RDRAND support (fake of course, Bochs just uses rand() function to produce RDRAND output) was introduced in Bochs 2.6.1 with bug in decoder.
The bug was fixed in 2.6.6 version.
You may also try latest SVN snapshot and see if the issue still there.

Stanislav


Top
 Profile  
 
 Post subject: Re: RDRAND eax crashes in Bochs
PostPosted: Fri Dec 14, 2018 1:29 pm 
Offline
Member
Member

Joined: Sun Oct 21, 2018 1:37 pm
Posts: 38
MichaelPetch wrote:
I suspect that your BOCHs hasn't been compiled with the support needed. You'll need to get the latest version 2.6.9 (or latest SVN snapshot) of the source code. You'll have to build it with at least these options: --enable-x86-64 --enable-cpu-level=6 --enable-avx. If using Linux with X-windows then configuring with this command should suffice:
Code:
./configure --enable-x86-64 --enable-cpu-level=6 --enable-avx --enable-smp --enable-all-optimizations --enable-pci --enable-debugger --enable-disasm --enable-debugger-gui --enable-logging --enable-fpu --enable-3dnow --enable-cdrom --enable-x86-debugger --enable-iodebug --disable-plugins --disable-docbook --with-x --with-x11 --with-term
make
sudo make install
Then you'll need to edit the CPU options and select at least a corei7_ivy_bridge_3770k that supports rdrand. You can tell what CPUs your BOCHs supports with: bochs -help cpu. If skylake/haswell/ivybridge aren't listed you will need to build a new version.When compiling your own, unless you override the prefix the installed bochs will be at /usr/local/bin/bochs


Hello Michael,

I think that is going to be the issue, because my current setup of Bochs does not support Ivy_bridge.

Supported CPU models:

bx_generic
pentium
pentium_mmx
amd_k6_2_chomper
p2_klamath
p3_katmai
p4_willamette
core_duo_t2400_yonah
atom_n270
p4_prescott_celeron_336
athlon64_clawhammer
athlon64_venice
turion64_tyler
phenom_8650_toliman
core2_penryn_t9600
corei5_lynnfield_750
corei5_arrandale_m520
corei7_sandy_bridge_2600k


I will compile with the latest one. thanks for your help!!


Top
 Profile  
 
 Post subject: Re: RDRAND eax crashes in Bochs
PostPosted: Fri Dec 14, 2018 1:31 pm 
Offline
Member
Member

Joined: Sun Oct 21, 2018 1:37 pm
Posts: 38
stlw wrote:
What does it mean - crashes ? Segfaults and dies ? Or emulated app closes with some error ?

Also - which version are you trying ?
RDRAND support (fake of course, Bochs just uses rand() function to produce RDRAND output) was introduced in Bochs 2.6.1 with bug in decoder.
The bug was fixed in 2.6.6 version.
You may also try latest SVN snapshot and see if the issue still there.

Stanislav


Sorry for the using the wrong semantics here. I used the term crash because I do not know how to denominate when Bochs stops executing your code and jumps to the BIOS code in FFFFF0.


Top
 Profile  
 
 Post subject: Re: RDRAND eax crashes in Bochs
PostPosted: Fri Dec 14, 2018 1:32 pm 
Offline
Member
Member

Joined: Sun Oct 21, 2018 1:37 pm
Posts: 38
iansjack wrote:
What is the version number of your Bochs?


2.6.9 but following the instructions written by Michael it seems that it needs to support Ivy Bridge, which I guess it should be one of the latest in the SVN. I will compile it later to test.

Thanks!


Top
 Profile  
 
 Post subject: Re: RDRAND eax crashes in Bochs
PostPosted: Tue Dec 18, 2018 1:36 pm 
Offline

Joined: Tue Dec 18, 2018 1:32 pm
Posts: 2
What does your bochs log say?

pornofilms
sexshop
webcams porno


Top
 Profile  
 
 Post subject: Re: RDRAND eax crashes in Bochs
PostPosted: Tue Dec 25, 2018 1:06 am 
Offline
Member
Member

Joined: Thu Feb 09, 2012 6:53 am
Posts: 39
Location: Czechoslovakia
mihe don't forget to execute the cpuid you mentioned prior the rdrand instruction to know whether it is supported (good practice for every newly introduced instruction)

_________________
hypervisor-based solutions developer (Intel, AMD)


Top
 Profile  
 
 Post subject: Re: RDRAND eax crashes in Bochs
PostPosted: Wed Dec 26, 2018 8:46 pm 
Offline
Member
Member

Joined: Wed Mar 09, 2011 3:55 am
Posts: 293
mihe wrote:

Sorry for the using the wrong semantics here. I used the term crash because I do not know how to denominate when Bochs stops executing your code and jumps to the BIOS code in FFFFF0.


"Crash" describes that well enough, but he asked what you meant because there's a need to know what exactly is crashing. If your OS code is crashing, causing the emulated computer to triple fault or otherwise reset, that likely indicates an problem with your code or an incompatibility between your code and your current bochs setup (as turned out to be the case). If the bochs process itself crashes when a specific instruction is executed, that indicates a bug in bochs.


Top
 Profile  
 
 Post subject: Re: RDRAND eax crashes in Bochs
PostPosted: Thu Dec 27, 2018 12:03 pm 
Offline
Member
Member

Joined: Sun Oct 21, 2018 1:37 pm
Posts: 38
linguofreak wrote:
mihe wrote:

Sorry for the using the wrong semantics here. I used the term crash because I do not know how to denominate when Bochs stops executing your code and jumps to the BIOS code in FFFFF0.


"Crash" describes that well enough, but he asked what you meant because there's a need to know what exactly is crashing. If your OS code is crashing, causing the emulated computer to triple fault or otherwise reset, that likely indicates an problem with your code or an incompatibility between your code and your current bochs setup (as turned out to be the case). If the bochs process itself crashes when a specific instruction is executed, that indicates a bug in bochs.


Thanks for the clarification. It was just a "crash" inside Bochs, not the Bochs process itself crashing.


Top
 Profile  
 
 Post subject: Re: RDRAND eax crashes in Bochs
PostPosted: Thu Dec 27, 2018 12:05 pm 
Offline
Member
Member

Joined: Sun Oct 21, 2018 1:37 pm
Posts: 38
feryno wrote:
mihe don't forget to execute the cpuid you mentioned prior the rdrand instruction to know whether it is supported (good practice for every newly introduced instruction)


Thanks for the tip!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: akasei, zity and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group