OSDev.org https://forum.osdev.org/ |
|
RDRAND eax crashes in Bochs https://forum.osdev.org/viewtopic.php?f=1&t=33374 |
Page 1 of 1 |
Author: | mihe [ Thu Dec 13, 2018 3:19 pm ] |
Post subject: | RDRAND eax crashes in Bochs |
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 |
Author: | nullplan [ Thu Dec 13, 2018 11:21 pm ] |
Post subject: | Re: RDRAND eax crashes in Bochs |
LOCK can't be used with RDRAND, and you'll get #UD if you try. Same with the REP prefixes (F2 and F3). |
Author: | mihe [ Fri Dec 14, 2018 1:37 am ] |
Post subject: | Re: RDRAND eax crashes in Bochs |
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! |
Author: | FusT [ Fri Dec 14, 2018 1:52 am ] |
Post subject: | Re: RDRAND eax crashes in Bochs |
What does your bochs log say? |
Author: | iansjack [ Fri Dec 14, 2018 4:48 am ] |
Post subject: | Re: RDRAND eax crashes in Bochs |
What is the version number of your Bochs? |
Author: | MichaelPetch [ Fri Dec 14, 2018 5:27 am ] |
Post subject: | Re: RDRAND eax crashes in Bochs |
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 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
make sudo make install |
Author: | stlw [ Fri Dec 14, 2018 6:27 am ] |
Post subject: | Re: RDRAND eax crashes in Bochs |
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 |
Author: | mihe [ Fri Dec 14, 2018 1:29 pm ] |
Post subject: | Re: RDRAND eax crashes in Bochs |
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 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/bochsmake sudo make install 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!! |
Author: | mihe [ Fri Dec 14, 2018 1:31 pm ] |
Post subject: | Re: RDRAND eax crashes in Bochs |
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. |
Author: | mihe [ Fri Dec 14, 2018 1:32 pm ] |
Post subject: | Re: RDRAND eax crashes in Bochs |
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! |
Author: | feryno [ Tue Dec 25, 2018 1:06 am ] |
Post subject: | Re: RDRAND eax crashes in Bochs |
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) |
Author: | linguofreak [ Wed Dec 26, 2018 8:46 pm ] |
Post subject: | Re: RDRAND eax crashes in Bochs |
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. |
Author: | mihe [ Thu Dec 27, 2018 12:03 pm ] |
Post subject: | Re: RDRAND eax crashes in Bochs |
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. |
Author: | mihe [ Thu Dec 27, 2018 12:05 pm ] |
Post subject: | Re: RDRAND eax crashes in Bochs |
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!! |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |