-
Notifications
You must be signed in to change notification settings - Fork 882
Generate #UD exception for unsupported instructions which cause vm-exits #247
Conversation
In what scenario do this happen? |
When some application calls GETSEC, INVD, VMCALL, VMCLEAR, VMLAUNCH, VMPTRLD, VMPTRST, VMREAD, VMRESUME, VMWRITE, VMXOFF, VMXON or XSETBV instruction. |
Yes technically it's absolutely correct, SDM is the bible. What I'm concern is a "real" test case. |
I started a Windows 7 guest, then manually ran an application which calls some of these instructions and observed the application crash on #ud exception (before this patch the result was VM crash). The tests should do the same - wait till OS loads, then simply call these instructions. Since they result in an #ud exception, there is no need to worry about they arguments correctness. For example a test only runs a vmcall instruction and checks that it received #ud exception and the virtual machine is still working and didn't crash. I have code snippets of the tests for Visual Studio and Windows. |
Interesting. Sounds like you are testing some nested virtualization stuff. We tested Windows 7 before but it's not covered in regular full test. You have tested you patch and it resolves the issue you met right? Seems VMX_EXIT_VMREAD&VMX_EXIT_VMWRITE shouldn't be there. |
[VMX_EXIT_VMLAUNCH] = exit_unsupported_instruction, | ||
[VMX_EXIT_VMPTRLD] = exit_unsupported_instruction, | ||
[VMX_EXIT_VMPTRST] = exit_unsupported_instruction, | ||
[VMX_EXIT_VMREAD] = exit_unsupported_instruction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why VMREAD/WMWRITE registered to unconditional exit handler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cpuid handling in hax tells the guest that it does not support VT. So execution of any instruction in this subset should generate an #UD. Intel SDM says that exits of these instructions are conditionally, the conditions in hax lead to exits. I tested these instructions and they exited.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it makes the code more clear by adding comments after each of these vmx_exit_* item, like already did in the enum, tells that some are due to unconditional exit while other are conditional according to the SDM 3C 25.1.2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments.
…its, instead of terminating the guest. Signed-off-by: Alexey Romko <nevilad@yahoo.com>
fa7f038
to
fdcdf05
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Generate #UD exception for unsupported instructions which cause vm-exits, instead of terminating the guest.