/* * \brief CPU context of a virtual machine for x86 * \author Alexander Boettcher * \date 2018-10-09 */ /* * Copyright (C) 2018 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU Affero General Public License version 3. */ #ifndef _INCLUDE__SPEC__X86__CPU__VM_STATE_H_ #define _INCLUDE__SPEC__X86__CPU__VM_STATE_H_ #include namespace Genode { struct Vm_state; } struct Genode::Vm_state { template class Register { private: bool _valid; T _value { }; public: Register() : _valid(false) { } Register(T value) : _valid(true), _value(value) { } T value() const { return _value; } void value(T value) { _value = value; _valid = true; } bool valid() const { return _valid; } void invalid() { _valid = false; } Register &operator = (Register const &other) { _valid = other._valid; /* keep original _value if other._valid is not valid */ if (_valid) _value = other._value; return *this; } }; struct Range { addr_t base; uint32_t limit; }; struct Segment { uint16_t sel, ar; uint32_t limit; addr_t base; }; Register ax; Register cx; Register dx; Register bx; Register bp; Register si; Register di; Register sp; Register ip; Register ip_len; Register flags; Register es; Register ds; Register fs; Register gs; Register cs; Register ss; Register tr; Register ldtr; Register gdtr; Register idtr; Register cr0; Register cr2; Register cr3; Register cr4; Register dr7; Register sysenter_ip; Register sysenter_sp; Register sysenter_cs; Register qual_primary; Register qual_secondary; Register ctrl_primary; Register ctrl_secondary; Register inj_info; Register inj_error; Register intr_state; Register actv_state; Register tsc; Register tsc_offset; Register efer; Register pdpte_0; Register pdpte_1; Register pdpte_2; Register pdpte_3; Register r8; Register r9; Register r10; Register r11; Register r12; Register r13; Register r14; Register r15; Register star; Register lstar; Register fmask; Register kernel_gs_base; Register tpr; Register tpr_threshold; unsigned exit_reason; class Fpu { private : uint8_t _value[512] { }; bool _valid { false }; public: bool valid() const { return _valid; } void invalid() { _valid = false; } template void value(FUNC const &fn) { _valid = true; fn(_value, sizeof(_value)); }; Fpu &operator = (Fpu const &) { _valid = false; return *this; } } fpu __attribute__((aligned(16))); }; #endif /* _INCLUDE__SPEC__X86__CPU__VM_STATE_H_ */