vm.hh (9651:f551c8ad12a5) vm.hh (9883:7e0dff1c165b)
1/*
2 * Copyright (c) 2012 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 26 unchanged lines hidden (view full) ---

35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 * Authors: Andreas Sandberg
38 */
39
40#ifndef __CPU_KVM_KVMVM_HH__
41#define __CPU_KVM_KVMVM_HH__
42
1/*
2 * Copyright (c) 2012 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 26 unchanged lines hidden (view full) ---

35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 * Authors: Andreas Sandberg
38 */
39
40#ifndef __CPU_KVM_KVMVM_HH__
41#define __CPU_KVM_KVMVM_HH__
42
43#include <vector>
44
43#include "base/addr_range.hh"
44#include "sim/sim_object.hh"
45
46// forward declarations
47struct KvmVMParams;
48class System;
49
50/**

--- 16 unchanged lines hidden (view full) ---

67 * specific to a VM or CPU. For example, it allows checking of the
68 * optional features and creation of VM containers.
69 */
70class Kvm
71{
72 friend class KvmVM;
73
74 public:
45#include "base/addr_range.hh"
46#include "sim/sim_object.hh"
47
48// forward declarations
49struct KvmVMParams;
50class System;
51
52/**

--- 16 unchanged lines hidden (view full) ---

69 * specific to a VM or CPU. For example, it allows checking of the
70 * optional features and creation of VM containers.
71 */
72class Kvm
73{
74 friend class KvmVM;
75
76 public:
77 typedef std::vector<struct kvm_cpuid_entry2> CPUIDVector;
78 typedef std::vector<uint32_t> MSRIndexVector;
79
75 virtual ~Kvm();
76
77 Kvm *create();
78
79 /** Get the version of the KVM API implemented by the kernel. */
80 int getAPIVersion() const { return apiVersion; }
81 /**
82 * Get the size of the MMAPed parameter area used to communicate

--- 29 unchanged lines hidden (view full) ---

112 bool capOneReg() const;
113
114 /**
115 * Support for creating an in-kernel IRQ chip model.
116 *
117 * @see KvmVM::createIRQChip()
118 */
119 bool capIRQChip() const;
80 virtual ~Kvm();
81
82 Kvm *create();
83
84 /** Get the version of the KVM API implemented by the kernel. */
85 int getAPIVersion() const { return apiVersion; }
86 /**
87 * Get the size of the MMAPed parameter area used to communicate

--- 29 unchanged lines hidden (view full) ---

117 bool capOneReg() const;
118
119 /**
120 * Support for creating an in-kernel IRQ chip model.
121 *
122 * @see KvmVM::createIRQChip()
123 */
124 bool capIRQChip() const;
125
126 /** Support for getting and setting the kvm_vcpu_events structure. */
127 bool capVCPUEvents() const;
128
129 /** Support for getting and setting the kvm_debugregs structure. */
130 bool capDebugRegs() const;
131
132 /** Support for getting and setting the x86 XCRs. */
133 bool capXCRs() const;
134
135 /** Support for getting and setting the kvm_xsave structure. */
136 bool capXSave() const;
120 /** @} */
121
122 /**
123 * Get the CPUID features supported by the hardware and Kvm.
124 *
125 * @note Requires capExtendedCPUID().
126 *
127 * @return False if the allocation is too small, true on success.
128 */
129 bool getSupportedCPUID(struct kvm_cpuid2 &cpuid) const;
130
137 /** @} */
138
139 /**
140 * Get the CPUID features supported by the hardware and Kvm.
141 *
142 * @note Requires capExtendedCPUID().
143 *
144 * @return False if the allocation is too small, true on success.
145 */
146 bool getSupportedCPUID(struct kvm_cpuid2 &cpuid) const;
147
148 /**
149 * Get the CPUID features supported by the hardware and Kvm.
150 *
151 * @note Requires capExtendedCPUID().
152 *
153 * @note This method uses an internal cache to minimize the number
154 * of calls into the kernel.
155 *
156 * @return Reference to cached MSR index list.
157 */
158 const CPUIDVector &getSupportedCPUID() const;
159
160 /**
161 * Get the MSRs supported by the hardware and Kvm.
162 *
163 * @return False if the allocation is too small, true on success.
164 */
165 bool getSupportedMSRs(struct kvm_msr_list &msrs) const;
166
167 /**
168 * Get the MSRs supported by the hardware and Kvm.
169 *
170 * @note This method uses an internal cache to minimize the number
171 * of calls into the kernel.
172 *
173 * @return Reference to cached MSR index list.
174 */
175 const MSRIndexVector &getSupportedMSRs() const;
176
131 protected:
132 /**
133 * Check for the presence of an extension to the KVM API.
134 *
135 * The return value depends on the extension, but is always zero
136 * if it is unsupported or positive otherwise. Some extensions use
137 * the return value provide additional data about the extension.
138 *

--- 42 unchanged lines hidden (view full) ---

181
182 /** KVM VM file descriptor */
183 int kvmFD;
184 /** KVM API version */
185 int apiVersion;
186 /** Size of the MMAPed vCPU parameter area. */
187 int vcpuMMapSize;
188
177 protected:
178 /**
179 * Check for the presence of an extension to the KVM API.
180 *
181 * The return value depends on the extension, but is always zero
182 * if it is unsupported or positive otherwise. Some extensions use
183 * the return value provide additional data about the extension.
184 *

--- 42 unchanged lines hidden (view full) ---

227
228 /** KVM VM file descriptor */
229 int kvmFD;
230 /** KVM API version */
231 int apiVersion;
232 /** Size of the MMAPed vCPU parameter area. */
233 int vcpuMMapSize;
234
235 /** Cached vector of supported CPUID entries. */
236 mutable CPUIDVector supportedCPUIDCache;
237
238 /** Cached vector of supported MSRs. */
239 mutable MSRIndexVector supportedMSRCache;
240
189 /** Singleton instance */
190 static Kvm *instance;
191};
192
193/**
194 * KVM VM container
195 *
196 * A KVM VM container normally contains all the CPUs in a shared

--- 194 unchanged lines hidden ---
241 /** Singleton instance */
242 static Kvm *instance;
243};
244
245/**
246 * KVM VM container
247 *
248 * A KVM VM container normally contains all the CPUs in a shared

--- 194 unchanged lines hidden ---