This repository has been archived by the owner on Jan 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 882
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
emulate: Abort decoding if opcode is unsupported
When decoding an instruction with an unsupported opcode (indicated by the INSN_NOTIMPL flag), em_decode_insn() does not fail, which can lead to a disaster in em_emulate_insn(), e.g. calling an invalid handler function (soft_handler == NULL) and causing a host kernel panic (#93). 1. As soon as the opcode is decoded, check if it is unsupported. If so, return a fatal error, raise a vCPU panic, and log the raw bytes of the instruction. 2. In em_emulate_insn(), make sure soft_handler is valid before calling it. 3. Before decoding a new instruction, reset the emulation context, so the old context is not accidentally referred to. 4. Add a unit test for the unsupported opcode case. This requires refactoring EmulatorTest::run() first. Signed-off-by: Yu Ning <[email protected]>
- Loading branch information
1 parent
a4b1abd
commit c5b959f
Showing
3 changed files
with
63 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters