• Avi Kivity's avatar
    KVM: x86 emulator: add framework for instruction intercepts · c4f035c6
    Avi Kivity authored
    When running in guest mode, certain instructions can be intercepted by
    hardware.  This also holds for nested guests running on emulated
    virtualization hardware, in particular instructions emulated by kvm
    itself.
    
    This patch adds a framework for intercepting instructions.  If an
    instruction is marked for interception, and if we're running in guest
    mode, a callback is called to check whether an intercept is needed or
    not.  The callback is called at three points in time: immediately after
    beginning execution, after checking privilge exceptions, and after
    checking memory exception.  This suits the different interception points
    defined for different instructions and for the various virtualization
    instruction sets.
    
    In addition, a new X86EMUL_INTERCEPT is defined, which any callback or
    memory access may define, allowing the more complicated intercepts to be
    implemented in existing callbacks.
    Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
    Signed-off-by: default avatarJoerg Roedel <joerg.roedel@amd.com>
    Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
    c4f035c6
x86.c 159 KB