Hook_PM_Fault

include vmm.inc

mov eax, Interrupt ; interrupt number for fault

mov esi, OFFSET32 FaultProc ; points to a fault handler

VMMcall Hook_PM_Fault

jc not_installed ; carry flag set if not installed

mov [Previous], esi ; points to previous fault handler (if any)


The Hook_PM_Fault service installs a fault handler procedure for protected mode. Virtual devices typically install fault handlers while processing the Sys_Critical_Init control message to handle faults, such as general protection faults, that the VMM fault handlers cannot handle. The VMM installs its fault handlers only after the Sys_Critical_Init control message. Virtual devices install fault handlers after Sys_Critical_Init to handle faults before the fault is passed to the VMM fault handlers.

Parameters

Interrupt

Specifies the number of the interrupt for which to install the fault handler. The interrupt number cannot be 02h, and must not be greater than 4Fh.

FaultProc

Points to the fault handler to install. For more information about the handler, see the following “Comments” section.

Return Value

If the carry flag is clear, the ESI register contains the address of the previous fault handler. The register contains zero if there was no previous handler.

If the carry flag is set, the specified fault number is not valid and the handler is not installed.

Comments

A virtual device can install a fault handler while processing the Sys_Critical_Init message or at a later time. When a fault occurs, fault handlers installed after the Sys_Critical_Init message receive control first, the VMM fault handlers receive control next, and fault handlers installed during the Sys_Critical_Init message receive control last.

The system disables interrupts, and calls the fault handler as follows:

mov ebx, VM ; current VM handle

mov ebp, OFFSET32 crs ; points to a Client_Reg_Struc

call [FaultProc]

The VM parameter is a handle identifying the current virtual machine, and the crs parameter points to a Client_Reg_Struc structure containing the register values for the current virtual machine.

If the fault does not process the fault, it should pass the fault to the previous fault handler (if any), making sure that all registers are preserved (not just the registers containing input parameters).

If the fault handler processes the fault or if there is no previous fault handler, the handler should return without chaining by executing a near ret instruction (not an iret instruction).

The fault handler can modify the EAX, EBX, ECX, EDX, ESI, and EDI registers.

Do not use this service to install a fault handler for the Non-Maskable Interrupt (NMI). Instead, a virtual device must use the Get_NMI_Handler_Addr and Set_NMI_Handler_Addr services.

Do not use this service to install handlers for hardware interrupts. Instead, a virtual device must use virtual PIC device services.

Uses

ESI, Flags

See Also

Hook_V86_Fault, Hook_VMM_Fault