libintrovirt v0.57.4
IntroVirt introspection library
Loading...
Searching...
No Matches
Vcpu.hh
Go to the documentation of this file.
1/*
2 * Copyright 2021 Assured Information Security, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
20
21#include <introvirt/core/fwd.hh>
22
23#include <cstdint>
24
25namespace introvirt {
26
33class Vcpu {
34 public:
40 virtual Registers& registers() = 0;
41
45 virtual const Registers& registers() const = 0;
46
53 virtual bool long_mode() const = 0;
54
63 virtual bool long_compatibility_mode() const = 0;
64
76 virtual void pause() = 0;
77
89 virtual void resume() = 0;
90
107 virtual void intercept_system_calls(bool enabled) = 0;
108
115 virtual bool intercept_system_calls() const = 0;
116
125 virtual void intercept_cr_writes(int cr, bool enabled) = 0;
126
134 virtual bool intercept_cr_writes(int cr) const = 0;
135
142 virtual void inject_exception(x86::Exception vector) = 0;
143
148 virtual void inject_exception(x86::Exception vector, int64_t error_code) = 0;
149
154 virtual void inject_exception(x86::Exception vector, int64_t error_code, uint64_t cr2) = 0;
155
161 virtual void inject_syscall() = 0;
162
168 virtual void inject_sysenter() = 0;
169
178 virtual std::unique_ptr<Vcpu> clone() const = 0;
179
186 virtual bool handling_event() const = 0;
187
201
205 virtual const SystemCallFilter& system_call_filter() const = 0;
206
212 virtual uint32_t id() const = 0;
213
219 virtual Domain& domain() = 0;
220
224 virtual const Domain& domain() const = 0;
225
234 virtual x86::Segment segment(x86::SegmentSelector selector) const = 0;
235
242
249
255 virtual std::unique_ptr<const x86::Idt> interrupt_descriptor_table() const = 0;
256
261 virtual const x86::Tss& task_state_segment() const = 0;
262
268 virtual void os_data(void* data) = 0;
269
275 virtual void* os_data() const = 0;
276
280 virtual ~Vcpu() = default;
281};
282
283} // namespace introvirt
A class representing a single Domain.
Definition Domain.hh:44
Base class for system call filtering.
Definition SystemCallFilter.hh:35
A class representing a single virtual processor.
Definition Vcpu.hh:33
virtual std::unique_ptr< Vcpu > clone() const =0
Create a clone of this VCPU.
virtual void inject_exception(x86::Exception vector)=0
Inject an exception for this vcpu.
virtual Registers & registers()=0
Get the processor's registers.
virtual const Registers & registers() const =0
Get the processor's registers.
virtual void intercept_cr_writes(int cr, bool enabled)=0
Toggle control register write interception.
virtual void inject_exception(x86::Exception vector, int64_t error_code)=0
Inject an exception for this vcpu.
virtual void intercept_system_calls(bool enabled)=0
Toggle system call interception for this VCPU.
virtual Domain & domain()=0
Get the domain associated with this Vcpu.
virtual bool handling_event() const =0
Check if the vcpu is currently being used by an active event.
virtual void inject_sysenter()=0
Inject a SYSCALL instruction into the VCPU.
virtual SystemCallFilter & system_call_filter()=0
Get the system call filter for this vcpu.
virtual void inject_syscall()=0
Inject a SYSCALL instruction into the VCPU.
virtual const SystemCallFilter & system_call_filter() const =0
Get the system call filter for this vcpu.
virtual bool long_mode() const =0
Check if the processor is in long mode.
virtual ~Vcpu()=default
Destroy the instance.
virtual std::unique_ptr< const x86::Idt > interrupt_descriptor_table() const =0
Gets the Interrupt Descriptor Table (IDT) for this VCPU.
virtual x86::SegmentDescriptorTable global_descriptor_table() const =0
Gets the Global Descriptor Table (GDT) for this VCPU.
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 bool intercept_system_calls() const =0
Check if system call interception is enabled.
virtual const Domain & domain() const =0
Get the domain associated with this Vcpu.
virtual x86::SegmentDescriptorTable local_descriptor_table() const =0
Gets the active Local Descriptor Table (LDT) for this VCPU.
virtual void resume()=0
Resume this vcpu.
virtual x86::Segment segment(x86::SegmentSelector selector) const =0
Get a segement descriptor given the current selector.
virtual bool intercept_cr_writes(int cr) const =0
Check if writes to the control register are being intercepted.
virtual const x86::Tss & task_state_segment() const =0
Get the x86 Task State Segment (TSS)
virtual void inject_exception(x86::Exception vector, int64_t error_code, uint64_t cr2)=0
Inject an exception for this vcpu.
virtual void pause()=0
Pause this vcpu.
virtual uint32_t id() const =0
Get the number of this Vcpu.
virtual bool long_compatibility_mode() const =0
Check if the processor is currently in long compatibility mode.
A class for holding x86 register state.
Definition Registers.hh:33
Class to parse a segment descriptor table.
Definition SegmentDescriptorTable.hh:34
Definition Segment.hh:26
Class to represent an x86 segment register.
Definition Segment.hh:66
x86 Task State Segment
Definition Tss.hh:28
Exception
x86 exception codes
Definition Exception.hh:27
Core IntroVirt classes.
Definition Cr0.hh:20