libintrovirt v0.57.4
IntroVirt introspection library
Loading...
Searching...
No Matches
introvirt::Vcpu Class Referenceabstract

A class representing a single virtual processor. More...

#include <Vcpu.hh>

Public Member Functions

virtual Registersregisters ()=0
 Get the processor's registers.
 
virtual const Registersregisters () const =0
 Get the processor's registers.
 
virtual bool long_mode () const =0
 Check if the processor is in long mode.
 
virtual bool long_compatibility_mode () const =0
 Check if the processor is currently in long compatibility mode.
 
virtual void pause ()=0
 Pause this vcpu.
 
virtual void resume ()=0
 Resume this vcpu.
 
virtual void intercept_system_calls (bool enabled)=0
 Toggle system call interception for this VCPU.
 
virtual bool intercept_system_calls () const =0
 Check if system call interception is enabled.
 
virtual void intercept_cr_writes (int cr, bool enabled)=0
 Toggle control register write interception.
 
virtual bool intercept_cr_writes (int cr) const =0
 Check if writes to the control register are being intercepted.
 
virtual void inject_exception (x86::Exception vector)=0
 Inject an exception for this vcpu.
 
virtual void inject_exception (x86::Exception vector, int64_t error_code)=0
 Inject an exception for this vcpu.
 
virtual void inject_exception (x86::Exception vector, int64_t error_code, uint64_t cr2)=0
 Inject an exception for this vcpu.
 
virtual void inject_syscall ()=0
 Inject a SYSCALL instruction into the VCPU.
 
virtual void inject_sysenter ()=0
 Inject a SYSCALL instruction into the VCPU.
 
virtual std::unique_ptr< Vcpuclone () const =0
 Create a clone of this VCPU.
 
virtual bool handling_event () const =0
 Check if the vcpu is currently being used by an active event.
 
virtual SystemCallFiltersystem_call_filter ()=0
 Get the system call filter for this vcpu.
 
virtual const SystemCallFiltersystem_call_filter () const =0
 Get the system call filter for this vcpu.
 
virtual uint32_t id () const =0
 Get the number of this Vcpu.
 
virtual Domaindomain ()=0
 Get the domain associated with this Vcpu.
 
virtual const Domaindomain () const =0
 Get the domain associated with this Vcpu.
 
virtual x86::Segment segment (x86::SegmentSelector selector) const =0
 Get a segement descriptor given the current selector.
 
virtual x86::SegmentDescriptorTable global_descriptor_table () const =0
 Gets the Global Descriptor Table (GDT) for this VCPU.
 
virtual x86::SegmentDescriptorTable local_descriptor_table () const =0
 Gets the active Local Descriptor Table (LDT) for this VCPU.
 
virtual std::unique_ptr< const x86::Idtinterrupt_descriptor_table () const =0
 Gets the Interrupt Descriptor Table (IDT) for this VCPU.
 
virtual const x86::Tsstask_state_segment () const =0
 Get the x86 Task State Segment (TSS)
 
virtual void os_data (void *data)=0
 Set OS-specific data for address translation.
 
virtual void * os_data () const =0
 Get OS-specific data for address translation.
 
virtual ~Vcpu ()=default
 Destroy the instance.
 

Detailed Description

A class representing a single virtual processor.

It is subclassed for specific hypervisors, such as the KvmVcpu and the XenVcpu.

Examples
ivcr3mon.cc, and ivmemwatch.cc.

Constructor & Destructor Documentation

◆ ~Vcpu()

virtual introvirt::Vcpu::~Vcpu ( )
virtualdefault

Destroy the instance.

Member Function Documentation

◆ clone()

virtual std::unique_ptr< Vcpu > introvirt::Vcpu::clone ( ) const
pure virtual

Create a clone of this VCPU.

A cloned VCPU will not be able to change guest state. It is mainly used when a copy is necessary for address translation.

Returns
A clone of this vcpu

◆ domain() [1/2]

virtual const Domain & introvirt::Vcpu::domain ( ) const
pure virtual

Get the domain associated with this Vcpu.

Returns
This Vcpu's domain

◆ domain() [2/2]

virtual Domain & introvirt::Vcpu::domain ( )
pure virtual

Get the domain associated with this Vcpu.

Returns
This Vcpu's domain

◆ global_descriptor_table()

virtual x86::SegmentDescriptorTable introvirt::Vcpu::global_descriptor_table ( ) const
pure virtual

Gets the Global Descriptor Table (GDT) for this VCPU.

Returns
The GDT for this VCPU

◆ handling_event()

virtual bool introvirt::Vcpu::handling_event ( ) const
pure virtual

Check if the vcpu is currently being used by an active event.

Returns
true if the vcpu is currently being used to handle an event
false if the vcpu is not in an active event

◆ id()

virtual uint32_t introvirt::Vcpu::id ( ) const
pure virtual

Get the number of this Vcpu.

Returns
uint32_t
Examples
ivcr3mon.cc, and ivmemwatch.cc.

◆ inject_exception() [1/3]

virtual void introvirt::Vcpu::inject_exception ( x86::Exception  vector)
pure virtual

Inject an exception for this vcpu.

Parameters
vectorThe exception type to inject
Exceptions
CommandFailedExceptionIf the hypervisor reports an error

◆ inject_exception() [2/3]

virtual void introvirt::Vcpu::inject_exception ( x86::Exception  vector,
int64_t  error_code 
)
pure virtual

Inject an exception for this vcpu.

Parameters
vectorThe exception type to inject
Exceptions
CommandFailedExceptionIf the hypervisor reports an error
Parameters
error_codeThe error code to deliver

◆ inject_exception() [3/3]

virtual void introvirt::Vcpu::inject_exception ( x86::Exception  vector,
int64_t  error_code,
uint64_t  cr2 
)
pure virtual

Inject an exception for this vcpu.

Parameters
vectorThe exception type to inject
Exceptions
CommandFailedExceptionIf the hypervisor reports an error
Parameters
error_codeThe error code to deliver
cr2The cr2 value to set (only for x86::Exception::PAGE_FAULT)

◆ inject_syscall()

virtual void introvirt::Vcpu::inject_syscall ( )
pure virtual

Inject a SYSCALL instruction into the VCPU.

You probably don't want to call this yourself.

◆ inject_sysenter()

virtual void introvirt::Vcpu::inject_sysenter ( )
pure virtual

Inject a SYSCALL instruction into the VCPU.

You probably don't want to call this yourself.

◆ intercept_cr_writes() [1/2]

virtual bool introvirt::Vcpu::intercept_cr_writes ( int  cr) const
pure virtual

Check if writes to the control register are being intercepted.

Parameters
crThe control register to check
Returns
true if writes to the control register are being intercepted
false if writes to the control register are not being intercepted

◆ intercept_cr_writes() [2/2]

virtual void introvirt::Vcpu::intercept_cr_writes ( int  cr,
bool  enabled 
)
pure virtual

Toggle control register write interception.

Parameters
crThe control register to toggle interception for
enabledIf set to true, writes to the given control register will be intercepted
Exceptions
NotImplementedExceptionif writes to the given CR cannot be intercepted
CommandFailedExceptionIf the hypervisor reports an error

◆ intercept_system_calls() [1/2]

virtual bool introvirt::Vcpu::intercept_system_calls ( ) const
pure virtual

Check if system call interception is enabled.

Returns
true if system call interception is enabled
false if system call interception is disabled

◆ intercept_system_calls() [2/2]

virtual void introvirt::Vcpu::intercept_system_calls ( bool  enabled)
pure virtual

Toggle system call interception for this VCPU.

Enables events of type EVENT_FAST_SYSCALL and EVENT_FAST_SYSCALL_RET.

When system call interception is enabled, SYSCALL/SYSENTER instructions are intercepted by the hypervisor. If the call number matches our SystemCallFilter (or the filter is disabled), a EVENT_FAST_SYSCALL event will be delivered.

While enabled, the hypervisor also intercept all SYSRET/SYSEXIT instructions.

Parameters
enabledIf set to true, system calls and returns that match our filters will be intercepted.
Exceptions
NotImplementedExceptionif system call hooking is not supported
CommandFailedExceptionIf the hypervisor reports an error

◆ interrupt_descriptor_table()

virtual std::unique_ptr< const x86::Idt > introvirt::Vcpu::interrupt_descriptor_table ( ) const
pure virtual

Gets the Interrupt Descriptor Table (IDT) for this VCPU.

Returns
The Idt for this VCPU

◆ local_descriptor_table()

virtual x86::SegmentDescriptorTable introvirt::Vcpu::local_descriptor_table ( ) const
pure virtual

Gets the active Local Descriptor Table (LDT) for this VCPU.

Returns
The active LDT for this VCPU

◆ long_compatibility_mode()

virtual bool introvirt::Vcpu::long_compatibility_mode ( ) const
pure virtual

Check if the processor is currently in long compatibility mode.

This occurs when the processor is in 64-bit mode, but in a 32-bit code segment.

Returns
true if in compatibility mode
false if not in compatibility mode

◆ long_mode()

virtual bool introvirt::Vcpu::long_mode ( ) const
pure virtual

Check if the processor is in long mode.

Returns
true if the processor is in long mode
false if the processor is not in long mode

◆ os_data() [1/2]

virtual void * introvirt::Vcpu::os_data ( ) const
pure virtual

Get OS-specific data for address translation.

Returns
OS-specific data

◆ os_data() [2/2]

virtual void introvirt::Vcpu::os_data ( void *  data)
pure virtual

Set OS-specific data for address translation.

Parameters
dataThe OS-specific data to set

◆ pause()

virtual void introvirt::Vcpu::pause ( )
pure virtual

Pause this vcpu.

This is implemented by tracking pause count. Every pause() increments the value, and resume() decrements.

The vcpu is paused when the count goes from 0 to 1. The vcpu is unpaused when the count reaches 0.

Exceptions
CommandFailedExceptionIf the hypervisor reports an error

◆ registers() [1/2]

virtual const Registers & introvirt::Vcpu::registers ( ) const
pure virtual

Get the processor's registers.

Returns
The registers for this Vcpu

◆ registers() [2/2]

virtual Registers & introvirt::Vcpu::registers ( )
pure virtual

Get the processor's registers.

Returns
The registers for this Vcpu
Examples
ivcallmon.cc, ivcr3mon.cc, and ivmemwatch.cc.

◆ resume()

virtual void introvirt::Vcpu::resume ( )
pure virtual

Resume this vcpu.

This is implemented by tracking pause count. Every pause() increments the value, and resume() decrements.

The vcpu is paused when the count goes from 0 to 1. The vcpu is unpaused when the count reaches 0.

Exceptions
CommandFailedExceptionIf the hypervisor reports an error

◆ segment()

virtual x86::Segment introvirt::Vcpu::segment ( x86::SegmentSelector  selector) const
pure virtual

Get a segement descriptor given the current selector.

Check the GDT or LDT for the correct segment descriptor

Parameters
selector
Returns
x86::Segment

◆ system_call_filter() [1/2]

virtual const SystemCallFilter & introvirt::Vcpu::system_call_filter ( ) const
pure virtual

Get the system call filter for this vcpu.

This is the vcpu-level system call filter.

If enabled, it will be checked first for a system call match. If a match occurs, the event is delivered.

If no match occurs, the domain-level filter will be checked if it is enabled.

Returns
The vcpu system call filter

◆ system_call_filter() [2/2]

virtual SystemCallFilter & introvirt::Vcpu::system_call_filter ( )
pure virtual

Get the system call filter for this vcpu.

This is the vcpu-level system call filter.

If enabled, it will be checked first for a system call match. If a match occurs, the event is delivered.

If no match occurs, the domain-level filter will be checked if it is enabled.

Returns
The vcpu system call filter

◆ task_state_segment()

virtual const x86::Tss & introvirt::Vcpu::task_state_segment ( ) const
pure virtual

Get the x86 Task State Segment (TSS)

Returns
The x86 task state segment

The documentation for this class was generated from the following file: