Difference between trap trap (TF) and monitor trap flag?

Debugging functions, such as GDB, by setting the TF flag of the eflags flag, which throws an exception after each execution of the command by the processor, allowing tools such as gdb to control debugging. When we start the Ex virtual machine in the case of kvm in order to do the same, you need to set a flag called MONITOR TRAP FLAG (pg 15 of the current Intel 3c software manual), which will cause the virtual macine to be EXIT ( VMEXIT) after each instruction to debug a hypervisor.

The hypervisor can set almost any bit / register of the virtual machine (guest). Why do we need a separate flag in VMCS (Macine virtual management structure) when such a flag is already present in the architecture (EFLAG)?

I read somewhere, the reason is that the guest can redefine the intent of VMM (hypervisor) by one step if EFLAGS were used.

A: What is the point of emulating equipment if you do not have control?

B: I encountered a problem when I need to install BTF (Trap Flag) (PG 689 vOLUME 3a INTEL sotfware manual). In a normal scenario, this calls DEBUG EXCEPTION for each branch instruction, but since I want this in a virtual machine, I cannot determine which bit to set in VMCS. There seems to be no direct way to do this, as in the case of a single step. Can someone tell me if there is a way to do the same using other means?

thank

+5
source share
1 answer

No, the Monitor Monitor trace flag is missing.

Perhaps Intel can do one, but it does not.

More details

Let first go through and define the terms:

[Note that all this applies only to Intel x86]

Trap Flag (TF)

, #DBG ( 0x1). 8 RFLAGS.

(BTF)

TL;DR: BTF TF .

Intel SDM 2016 :

BTF ( 1) IA32_DEBUGCTL MSR TF EFLAGS, , . [1] , . " " . BTF, . BTF, .

[1] CALL, IRET JMP, ( BTF ). , T ( ) TSS . 7.2.1, " (TSS)".

(MTF)

MTF VMCS, Monitor Trap Flag VMEXIT .

, , , , , MTF VMEXIT. , REP MOV (, ) SMI (, ). . " " SDM (25.5.2 2016 ).

VMCS ( Macine ), (EFLAG)?

. , GDB, VMEXIT, . , , (, , , ).

MTF, TF ​​ VMEXIT , VMCS. , , , , ( , RFLAGS). MTF , .

... - , ?

Branch Monitor. - , RIP ( VMCS), VMEXITS. , .

BTF , . BTF, BTF, . MTF VMCS, BTF MTF VMEXIT. , .

, VMEXIT , BTF , (IA32_DEBUGCTL ). MSR LOAD/STORE, .

+3

All Articles