vmcs_intel_x64.h
Go to the documentation of this file.
1 //
2 // Bareflank Hypervisor
3 //
4 // Copyright (C) 2015 Assured Information Security, Inc.
5 // Author: Rian Quinn <quinnr@ainfosec.com>
6 // Author: Brendan Kerrigan <kerriganb@ainfosec.com>
7 // Author: Connor Davis <davisc@ainfosec.com>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 
23 #ifndef VMCS_INTEL_X64_H
24 #define VMCS_INTEL_X64_H
25 
29 
30 class vcpu_intel_x64;
31 
58 {
59 public:
60 
67 
73  virtual ~vmcs_intel_x64() = default;
74 
86  virtual void launch(gsl::not_null<vmcs_intel_x64_state *> host_state,
87  gsl::not_null<vmcs_intel_x64_state *> guest_state);
88 
109  virtual void resume();
110 
128  virtual void promote();
129 
146  virtual void load();
147 
159  virtual void clear();
160 
161 protected:
162 
163  virtual void write_fields(gsl::not_null<vmcs_intel_x64_state *> host_state,
164  gsl::not_null<vmcs_intel_x64_state *> guest_state);
165 
166  void create_vmcs_region();
168 
171 
172  void write_16bit_control_state(gsl::not_null<vmcs_intel_x64_state *> state);
173  void write_64bit_control_state(gsl::not_null<vmcs_intel_x64_state *> state);
174  void write_32bit_control_state(gsl::not_null<vmcs_intel_x64_state *> state);
175  void write_natural_control_state(gsl::not_null<vmcs_intel_x64_state *> state);
176 
177  void write_16bit_guest_state(gsl::not_null<vmcs_intel_x64_state *> state);
178  void write_64bit_guest_state(gsl::not_null<vmcs_intel_x64_state *> state);
179  void write_32bit_guest_state(gsl::not_null<vmcs_intel_x64_state *> state);
180  void write_natural_guest_state(gsl::not_null<vmcs_intel_x64_state *> state);
181 
182  void write_16bit_host_state(gsl::not_null<vmcs_intel_x64_state *> state);
183  void write_64bit_host_state(gsl::not_null<vmcs_intel_x64_state *> state);
184  void write_32bit_host_state(gsl::not_null<vmcs_intel_x64_state *> state);
185  void write_natural_host_state(gsl::not_null<vmcs_intel_x64_state *> state);
186 
190  void vm_exit_controls();
191  void vm_entry_controls();
192 
193 protected:
194 
196  std::unique_ptr<uint32_t[]> m_vmcs_region;
197 
199  std::unique_ptr<char[]> m_exit_handler_stack;
200 
201 private:
202 
203  friend class vcpu_ut;
204  friend class vmcs_ut;
205  friend class vcpu_intel_x64;
208 
209  virtual void set_state_save(gsl::not_null<state_save_intel_x64 *> state_save)
210  { m_state_save = state_save; }
211 };
212 
213 #endif
virtual void launch(gsl::not_null< vmcs_intel_x64_state *> host_state, gsl::not_null< vmcs_intel_x64_state *> guest_state)
void release_vmcs_region() noexcept
std::unique_ptr< uint32_t[]> m_vmcs_region
void write_32bit_control_state(gsl::not_null< vmcs_intel_x64_state *> state)
void write_natural_guest_state(gsl::not_null< vmcs_intel_x64_state *> state)
void create_exit_handler_stack()
void release_exit_handler_stack() noexcept
void write_64bit_control_state(gsl::not_null< vmcs_intel_x64_state *> state)
void write_64bit_host_state(gsl::not_null< vmcs_intel_x64_state *> state)
Definition: test.h:27
virtual void promote()
virtual void resume()
void uint64_t uint64_t uint64_t *rdx noexcept
void secondary_processor_based_vm_execution_controls()
void write_64bit_guest_state(gsl::not_null< vmcs_intel_x64_state *> state)
void pin_based_vm_execution_controls()
std::unique_ptr< char[]> m_exit_handler_stack
state_save_intel_x64 * m_state_save
void primary_processor_based_vm_execution_controls()
virtual ~vmcs_intel_x64()=default
virtual void load()
Definition: test.h:96
virtual void clear()
void write_16bit_control_state(gsl::not_null< vmcs_intel_x64_state *> state)
virtual void write_fields(gsl::not_null< vmcs_intel_x64_state *> host_state, gsl::not_null< vmcs_intel_x64_state *> guest_state)
void write_32bit_host_state(gsl::not_null< vmcs_intel_x64_state *> state)
void write_16bit_guest_state(gsl::not_null< vmcs_intel_x64_state *> state)
uintptr_t m_vmcs_region_phys
void write_natural_host_state(gsl::not_null< vmcs_intel_x64_state *> state)
void write_16bit_host_state(gsl::not_null< vmcs_intel_x64_state *> state)
void write_natural_control_state(gsl::not_null< vmcs_intel_x64_state *> state)
void write_32bit_guest_state(gsl::not_null< vmcs_intel_x64_state *> state)