Skip to content

Commit 41577ab

Browse files
Sean Christophersonbonzini
authored andcommitted
KVM: x86: Add comments to document various emulation types
Document the intended usage of each emulation type as each exists to handle an edge case of one kind or another and can be easily misinterpreted at first glance. Cc: Liran Alon <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 1957aa6 commit 41577ab

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,36 @@ extern u64 kvm_default_tsc_scaling_ratio;
13151315

13161316
extern u64 kvm_mce_cap_supported;
13171317

1318+
/*
1319+
* EMULTYPE_NO_DECODE - Set when re-emulating an instruction (after completing
1320+
* userspace I/O) to indicate that the emulation context
1321+
* should be resued as is, i.e. skip initialization of
1322+
* emulation context, instruction fetch and decode.
1323+
*
1324+
* EMULTYPE_TRAP_UD - Set when emulating an intercepted #UD from hardware.
1325+
* Indicates that only select instructions (tagged with
1326+
* EmulateOnUD) should be emulated (to minimize the emulator
1327+
* attack surface). See also EMULTYPE_TRAP_UD_FORCED.
1328+
*
1329+
* EMULTYPE_SKIP - Set when emulating solely to skip an instruction, i.e. to
1330+
* decode the instruction length. For use *only* by
1331+
* kvm_x86_ops->skip_emulated_instruction() implementations.
1332+
*
1333+
* EMULTYPE_ALLOW_RETRY - Set when the emulator should resume the guest to
1334+
* retry native execution under certain conditions.
1335+
*
1336+
* EMULTYPE_TRAP_UD_FORCED - Set when emulating an intercepted #UD that was
1337+
* triggered by KVM's magic "force emulation" prefix,
1338+
* which is opt in via module param (off by default).
1339+
* Bypasses EmulateOnUD restriction despite emulating
1340+
* due to an intercepted #UD (see EMULTYPE_TRAP_UD).
1341+
* Used to test the full emulator from userspace.
1342+
*
1343+
* EMULTYPE_VMWARE_GP - Set when emulating an intercepted #GP for VMware
1344+
* backdoor emulation, which is opt in via module param.
1345+
* VMware backoor emulation handles select instructions
1346+
* and reinjects the #GP for all other cases.
1347+
*/
13181348
#define EMULTYPE_NO_DECODE (1 << 0)
13191349
#define EMULTYPE_TRAP_UD (1 << 1)
13201350
#define EMULTYPE_SKIP (1 << 2)

0 commit comments

Comments
 (0)