vmcs_intel_x64_64bit_host_state_fields.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_64BIT_HOST_STATE_FIELDS_H
24 #define VMCS_INTEL_X64_64BIT_HOST_STATE_FIELDS_H
25 
26 #include <vmcs/vmcs_intel_x64.h>
27 
34 
35 // *INDENT-OFF*
36 
37 namespace intel_x64
38 {
39 namespace vmcs
40 {
41 
42 namespace host_ia32_pat
43 {
44  constexpr const auto addr = 0x0000000000002C00UL;
45  constexpr const auto name = "host_ia32_pat";
46 
47  inline auto exists() noexcept
49 
50  inline auto get()
51  { return get_vmcs_field(addr, name, exists()); }
52 
53  inline auto get_if_exists(bool verbose = false) noexcept
54  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
55 
56  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
57  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
58 
59  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
60  void set_if_exists(T val, bool verbose = false) noexcept
61  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
62 
63  namespace pa0
64  {
65  constexpr const auto mask = 0x00000000000000FFUL;
66  constexpr const auto from = 0;
67  constexpr const auto name = "pa0";
68 
69  inline auto get()
70  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
71 
72  inline auto get_if_exists(bool verbose = false) noexcept
73  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
74 
75  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
76  void set(T val)
77  {
78  auto&& field = get_vmcs_field(addr, name, exists());
79  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
80  }
81 
82  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
83  void set_if_exists(T val, bool verbose = false) noexcept
84  {
85  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
86  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
87  }
88 
89  namespace memory_type
90  {
91  constexpr const auto mask = 0x0000000000000007UL;
92  constexpr const auto from = 0;
93  constexpr const auto name = "memory_type";
94 
95  inline auto get()
96  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
97 
98  inline auto get_if_exists(bool verbose = false) noexcept
99  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
100 
101  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
102  void set(T val)
103  {
104  auto&& field = get_vmcs_field(addr, name, exists());
105  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
106  }
107 
108  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
109  void set_if_exists(T val, bool verbose = false) noexcept
110  {
111  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
112  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
113  }
114  }
115 
116  namespace reserved
117  {
118  constexpr const auto mask = 0x00000000000000F8UL;
119  constexpr const auto from = 3;
120  constexpr const auto name = "reserved";
121 
122  inline auto get()
123  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
124 
125  inline auto get_if_exists(bool verbose = false) noexcept
126  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
127 
128  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
129  void set(T val)
130  {
131  auto&& field = get_vmcs_field(addr, name, exists());
132  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
133  }
134 
135  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
136  void set_if_exists(T val, bool verbose = false) noexcept
137  {
138  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
139  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
140  }
141  }
142  }
143 
144  namespace pa1
145  {
146  constexpr const auto mask = 0x000000000000FF00UL;
147  constexpr const auto from = 8;
148  constexpr const auto name = "pa1";
149 
150  inline auto get()
151  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
152 
153  inline auto get_if_exists(bool verbose = false) noexcept
154  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
155 
156  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
157  void set(T val)
158  {
159  auto&& field = get_vmcs_field(addr, name, exists());
160  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
161  }
162 
163  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
164  void set_if_exists(T val, bool verbose = false) noexcept
165  {
166  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
167  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
168  }
169 
170  namespace memory_type
171  {
172  constexpr const auto mask = 0x0000000000000700UL;
173  constexpr const auto from = 8;
174  constexpr const auto name = "memory_type";
175 
176  inline auto get()
177  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
178 
179  inline auto get_if_exists(bool verbose = false) noexcept
180  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
181 
182  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
183  void set(T val)
184  {
185  auto&& field = get_vmcs_field(addr, name, exists());
186  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
187  }
188 
189  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
190  void set_if_exists(T val, bool verbose = false) noexcept
191  {
192  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
193  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
194  }
195  }
196 
197  namespace reserved
198  {
199  constexpr const auto mask = 0x000000000000F800UL;
200  constexpr const auto from = 11;
201  constexpr const auto name = "reserved";
202 
203  inline auto get()
204  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
205 
206  inline auto get_if_exists(bool verbose = false) noexcept
207  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
208 
209  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
210  void set(T val)
211  {
212  auto&& field = get_vmcs_field(addr, name, exists());
213  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
214  }
215 
216  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
217  void set_if_exists(T val, bool verbose = false) noexcept
218  {
219  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
220  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
221  }
222  }
223  }
224 
225  namespace pa2
226  {
227  constexpr const auto mask = 0x0000000000FF0000UL;
228  constexpr const auto from = 16;
229  constexpr const auto name = "pa2";
230 
231  inline auto get()
232  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
233 
234  inline auto get_if_exists(bool verbose = false) noexcept
235  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
236 
237  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
238  void set(T val)
239  {
240  auto&& field = get_vmcs_field(addr, name, exists());
241  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
242  }
243 
244  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
245  void set_if_exists(T val, bool verbose = false) noexcept
246  {
247  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
248  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
249  }
250 
251  namespace memory_type
252  {
253  constexpr const auto mask = 0x0000000000070000UL;
254  constexpr const auto from = 16;
255  constexpr const auto name = "memory_type";
256 
257  inline auto get()
258  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
259 
260  inline auto get_if_exists(bool verbose = false) noexcept
261  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
262 
263  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
264  void set(T val)
265  {
266  auto&& field = get_vmcs_field(addr, name, exists());
267  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
268  }
269 
270  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
271  void set_if_exists(T val, bool verbose = false) noexcept
272  {
273  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
274  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
275  }
276  }
277 
278  namespace reserved
279  {
280  constexpr const auto mask = 0x0000000000F80000UL;
281  constexpr const auto from = 19;
282  constexpr const auto name = "reserved";
283 
284  inline auto get()
285  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
286 
287  inline auto get_if_exists(bool verbose = false) noexcept
288  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
289 
290  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
291  void set(T val)
292  {
293  auto&& field = get_vmcs_field(addr, name, exists());
294  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
295  }
296 
297  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
298  void set_if_exists(T val, bool verbose = false) noexcept
299  {
300  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
301  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
302  }
303  }
304  }
305 
306  namespace pa3
307  {
308  constexpr const auto mask = 0x00000000FF000000UL;
309  constexpr const auto from = 24;
310  constexpr const auto name = "pa3";
311 
312  inline auto get()
313  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
314 
315  inline auto get_if_exists(bool verbose = false) noexcept
316  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
317 
318  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
319  void set(T val)
320  {
321  auto&& field = get_vmcs_field(addr, name, exists());
322  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
323  }
324 
325  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
326  void set_if_exists(T val, bool verbose = false) noexcept
327  {
328  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
329  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
330  }
331 
332  namespace memory_type
333  {
334  constexpr const auto mask = 0x0000000007000000UL;
335  constexpr const auto from = 24;
336  constexpr const auto name = "memory_type";
337 
338  inline auto get()
339  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
340 
341  inline auto get_if_exists(bool verbose = false) noexcept
342  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
343 
344  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
345  void set(T val)
346  {
347  auto&& field = get_vmcs_field(addr, name, exists());
348  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
349  }
350 
351  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
352  void set_if_exists(T val, bool verbose = false) noexcept
353  {
354  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
355  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
356  }
357  }
358 
359  namespace reserved
360  {
361  constexpr const auto mask = 0x00000000F8000000UL;
362  constexpr const auto from = 27;
363  constexpr const auto name = "reserved";
364 
365  inline auto get()
366  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
367 
368  inline auto get_if_exists(bool verbose = false) noexcept
369  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
370 
371  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
372  void set(T val)
373  {
374  auto&& field = get_vmcs_field(addr, name, exists());
375  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
376  }
377 
378  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
379  void set_if_exists(T val, bool verbose = false) noexcept
380  {
381  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
382  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
383  }
384  }
385  }
386 
387  namespace pa4
388  {
389  constexpr const auto mask = 0x000000FF00000000UL;
390  constexpr const auto from = 32;
391  constexpr const auto name = "pa4";
392 
393  inline auto get()
394  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
395 
396  inline auto get_if_exists(bool verbose = false) noexcept
397  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
398 
399  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
400  void set(T val)
401  {
402  auto&& field = get_vmcs_field(addr, name, exists());
403  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
404  }
405 
406  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
407  void set_if_exists(T val, bool verbose = false) noexcept
408  {
409  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
410  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
411  }
412 
413  namespace memory_type
414  {
415  constexpr const auto mask = 0x0000000700000000UL;
416  constexpr const auto from = 32;
417  constexpr const auto name = "memory_type";
418 
419  inline auto get()
420  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
421 
422  inline auto get_if_exists(bool verbose = false) noexcept
423  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
424 
425  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
426  void set(T val)
427  {
428  auto&& field = get_vmcs_field(addr, name, exists());
429  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
430  }
431 
432  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
433  void set_if_exists(T val, bool verbose = false) noexcept
434  {
435  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
436  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
437  }
438  }
439 
440  namespace reserved
441  {
442  constexpr const auto mask = 0x000000F800000000UL;
443  constexpr const auto from = 35;
444  constexpr const auto name = "reserved";
445 
446  inline auto get()
447  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
448 
449  inline auto get_if_exists(bool verbose = false) noexcept
450  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
451 
452  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
453  void set(T val)
454  {
455  auto&& field = get_vmcs_field(addr, name, exists());
456  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
457  }
458 
459  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
460  void set_if_exists(T val, bool verbose = false) noexcept
461  {
462  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
463  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
464  }
465  }
466  }
467 
468  namespace pa5
469  {
470  constexpr const auto mask = 0x0000FF0000000000UL;
471  constexpr const auto from = 40;
472  constexpr const auto name = "pa5";
473 
474  inline auto get()
475  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
476 
477  inline auto get_if_exists(bool verbose = false) noexcept
478  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
479 
480  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
481  void set(T val)
482  {
483  auto&& field = get_vmcs_field(addr, name, exists());
484  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
485  }
486 
487  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
488  void set_if_exists(T val, bool verbose = false) noexcept
489  {
490  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
491  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
492  }
493 
494  namespace memory_type
495  {
496  constexpr const auto mask = 0x0000070000000000UL;
497  constexpr const auto from = 40;
498  constexpr const auto name = "memory_type";
499 
500  inline auto get()
501  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
502 
503  inline auto get_if_exists(bool verbose = false) noexcept
504  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
505 
506  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
507  void set(T val)
508  {
509  auto&& field = get_vmcs_field(addr, name, exists());
510  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
511  }
512 
513  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
514  void set_if_exists(T val, bool verbose = false) noexcept
515  {
516  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
517  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
518  }
519  }
520 
521  namespace reserved
522  {
523  constexpr const auto mask = 0x0000F80000000000UL;
524  constexpr const auto from = 43;
525  constexpr const auto name = "reserved";
526 
527  inline auto get()
528  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
529 
530  inline auto get_if_exists(bool verbose = false) noexcept
531  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
532 
533  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
534  void set(T val)
535  {
536  auto&& field = get_vmcs_field(addr, name, exists());
537  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
538  }
539 
540  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
541  void set_if_exists(T val, bool verbose = false) noexcept
542  {
543  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
544  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
545  }
546  }
547  }
548 
549  namespace pa6
550  {
551  constexpr const auto mask = 0x00FF000000000000UL;
552  constexpr const auto from = 48;
553  constexpr const auto name = "pa6";
554 
555  inline auto get()
556  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
557 
558  inline auto get_if_exists(bool verbose = false) noexcept
559  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
560 
561  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
562  void set(T val)
563  {
564  auto&& field = get_vmcs_field(addr, name, exists());
565  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
566  }
567 
568  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
569  void set_if_exists(T val, bool verbose = false) noexcept
570  {
571  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
572  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
573  }
574 
575  namespace memory_type
576  {
577  constexpr const auto mask = 0x0007000000000000UL;
578  constexpr const auto from = 48;
579  constexpr const auto name = "memory_type";
580 
581  inline auto get()
582  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
583 
584  inline auto get_if_exists(bool verbose = false) noexcept
585  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
586 
587  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
588  void set(T val)
589  {
590  auto&& field = get_vmcs_field(addr, name, exists());
591  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
592  }
593 
594  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
595  void set_if_exists(T val, bool verbose = false) noexcept
596  {
597  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
598  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
599  }
600  }
601 
602  namespace reserved
603  {
604  constexpr const auto mask = 0x00F8000000000000UL;
605  constexpr const auto from = 51;
606  constexpr const auto name = "reserved";
607 
608  inline auto get()
609  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
610 
611  inline auto get_if_exists(bool verbose = false) noexcept
612  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
613 
614  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
615  void set(T val)
616  {
617  auto&& field = get_vmcs_field(addr, name, exists());
618  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
619  }
620 
621  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
622  void set_if_exists(T val, bool verbose = false) noexcept
623  {
624  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
625  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
626  }
627  }
628  }
629 
630  namespace pa7
631  {
632  constexpr const auto mask = 0xFF00000000000000UL;
633  constexpr const auto from = 56;
634  constexpr const auto name = "pa7";
635 
636  inline auto get()
637  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
638 
639  inline auto get_if_exists(bool verbose = false) noexcept
640  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
641 
642  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
643  void set(T val)
644  {
645  auto&& field = get_vmcs_field(addr, name, exists());
646  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
647  }
648 
649  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
650  void set_if_exists(T val, bool verbose = false) noexcept
651  {
652  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
653  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
654  }
655 
656  namespace memory_type
657  {
658  constexpr const auto mask = 0x0700000000000000UL;
659  constexpr const auto from = 56;
660  constexpr const auto name = "memory_type";
661 
662  inline auto get()
663  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
664 
665  inline auto get_if_exists(bool verbose = false) noexcept
666  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
667 
668  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
669  void set(T val)
670  {
671  auto&& field = get_vmcs_field(addr, name, exists());
672  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
673  }
674 
675  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
676  void set_if_exists(T val, bool verbose = false) noexcept
677  {
678  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
679  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
680  }
681  }
682 
683  namespace reserved
684  {
685  constexpr const auto mask = 0xF800000000000000UL;
686  constexpr const auto from = 59;
687  constexpr const auto name = "reserved";
688 
689  inline auto get()
690  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
691 
692  inline auto get_if_exists(bool verbose = false) noexcept
693  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
694 
695  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
696  void set(T val)
697  {
698  auto&& field = get_vmcs_field(addr, name, exists());
699  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
700  }
701 
702  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
703  void set_if_exists(T val, bool verbose = false) noexcept
704  {
705  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
706  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
707  }
708  }
709  }
710 }
711 
712 namespace host_ia32_efer
713 {
714  constexpr const auto addr = 0x0000000000002C02UL;
715  constexpr const auto name = "host_ia32_efer";
716 
717  inline auto exists() noexcept
719 
720  inline auto get()
721  { return get_vmcs_field(addr, name, exists()); }
722 
723  inline auto get_if_exists(bool verbose = false) noexcept
724  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
725 
726  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
727  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
728 
729  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
730  void set_if_exists(T val, bool verbose = false) noexcept
731  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
732 
733  namespace sce
734  {
735  constexpr const auto mask = 0x0000000000000001UL;
736  constexpr const auto from = 0;
737  constexpr const auto name = "sce";
738 
739  inline auto is_enabled()
740  { return is_bit_set(get_vmcs_field(addr, name, exists()), from); }
741 
742  inline auto is_enabled_if_exists(bool verbose = false) noexcept
743  { return is_bit_set(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
744 
745  inline auto is_disabled()
746  { return is_bit_cleared(get_vmcs_field(addr, name, exists()), from); }
747 
748  inline auto is_disabled_if_exists(bool verbose = false) noexcept
749  { return is_bit_cleared(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
750 
751  inline void enable()
752  {
753  auto&& field = get_vmcs_field(addr, name, exists());
754  set_vmcs_field(set_bit(field, from), addr, name, exists());
755  }
756 
757  inline void enable_if_exists(bool verbose = false) noexcept
758  {
759  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
760  set_vmcs_field_if_exists(set_bit(field, from), addr, name, verbose, exists());
761  }
762 
763  inline void disable()
764  {
765  auto&& field = get_vmcs_field(addr, name, exists());
766  set_vmcs_field(clear_bit(field, from), addr, name, exists());
767  }
768 
769  inline void disable_if_exists(bool verbose = false) noexcept
770  {
771  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
772  set_vmcs_field_if_exists(clear_bit(field, from), addr, name, verbose, exists());
773  }
774  }
775 
776  namespace lme
777  {
778  constexpr const auto mask = 0x0000000000000100UL;
779  constexpr const auto from = 8;
780  constexpr const auto name = "lme";
781 
782  inline auto is_enabled()
783  { return is_bit_set(get_vmcs_field(addr, name, exists()), from); }
784 
785  inline auto is_enabled_if_exists(bool verbose = false) noexcept
786  { return is_bit_set(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
787 
788  inline auto is_disabled()
789  { return is_bit_cleared(get_vmcs_field(addr, name, exists()), from); }
790 
791  inline auto is_disabled_if_exists(bool verbose = false) noexcept
792  { return is_bit_cleared(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
793 
794  inline void enable()
795  {
796  auto&& field = get_vmcs_field(addr, name, exists());
797  set_vmcs_field(set_bit(field, from), addr, name, exists());
798  }
799 
800  inline void enable_if_exists(bool verbose = false) noexcept
801  {
802  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
803  set_vmcs_field_if_exists(set_bit(field, from), addr, name, verbose, exists());
804  }
805 
806  inline void disable()
807  {
808  auto&& field = get_vmcs_field(addr, name, exists());
809  set_vmcs_field(clear_bit(field, from), addr, name, exists());
810  }
811 
812  inline void disable_if_exists(bool verbose = false) noexcept
813  {
814  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
815  set_vmcs_field_if_exists(clear_bit(field, from), addr, name, verbose, exists());
816  }
817  }
818 
819  namespace lma
820  {
821  constexpr const auto mask = 0x0000000000000400UL;
822  constexpr const auto from = 10;
823  constexpr const auto name = "lma";
824 
825  inline auto is_enabled()
826  { return is_bit_set(get_vmcs_field(addr, name, exists()), from); }
827 
828  inline auto is_enabled_if_exists(bool verbose = false) noexcept
829  { return is_bit_set(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
830 
831  inline auto is_disabled()
832  { return is_bit_cleared(get_vmcs_field(addr, name, exists()), from); }
833 
834  inline auto is_disabled_if_exists(bool verbose = false) noexcept
835  { return is_bit_cleared(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
836 
837  inline void enable()
838  {
839  auto&& field = get_vmcs_field(addr, name, exists());
840  set_vmcs_field(set_bit(field, from), addr, name, exists());
841  }
842 
843  inline void enable_if_exists(bool verbose = false) noexcept
844  {
845  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
846  set_vmcs_field_if_exists(set_bit(field, from), addr, name, verbose, exists());
847  }
848 
849  inline void disable()
850  {
851  auto&& field = get_vmcs_field(addr, name, exists());
852  set_vmcs_field(clear_bit(field, from), addr, name, exists());
853  }
854 
855  inline void disable_if_exists(bool verbose = false) noexcept
856  {
857  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
858  set_vmcs_field_if_exists(clear_bit(field, from), addr, name, verbose, exists());
859  }
860  }
861 
862  namespace nxe
863  {
864  constexpr const auto mask = 0x0000000000000800UL;
865  constexpr const auto from = 11;
866  constexpr const auto name = "nxe";
867 
868  inline auto is_enabled()
869  { return is_bit_set(get_vmcs_field(addr, name, exists()), from); }
870 
871  inline auto is_enabled_if_exists(bool verbose = false) noexcept
872  { return is_bit_set(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
873 
874  inline auto is_disabled()
875  { return is_bit_cleared(get_vmcs_field(addr, name, exists()), from); }
876 
877  inline auto is_disabled_if_exists(bool verbose = false) noexcept
878  { return is_bit_cleared(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
879 
880  inline void enable()
881  {
882  auto&& field = get_vmcs_field(addr, name, exists());
883  set_vmcs_field(set_bit(field, from), addr, name, exists());
884  }
885 
886  inline void enable_if_exists(bool verbose = false) noexcept
887  {
888  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
889  set_vmcs_field_if_exists(set_bit(field, from), addr, name, verbose, exists());
890  }
891 
892  inline void disable()
893  {
894  auto&& field = get_vmcs_field(addr, name, exists());
895  set_vmcs_field(clear_bit(field, from), addr, name, exists());
896  }
897 
898  inline void disable_if_exists(bool verbose = false) noexcept
899  {
900  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
901  set_vmcs_field_if_exists(clear_bit(field, from), addr, name, verbose, exists());
902  }
903  }
904 
905  namespace reserved
906  {
907  constexpr const auto mask = 0xFFFFFFFFFFFFF2FEUL;
908  constexpr const auto from = 0;
909  constexpr const auto name = "reserved";
910 
911  inline auto get()
912  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
913 
914  inline auto get_if_exists(bool verbose = false) noexcept
915  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
916 
917  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
918  void set(T val)
919  {
920  auto&& field = get_vmcs_field(addr, name, exists());
921  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
922  }
923 
924  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
925  void set_if_exists(T val, bool verbose = false) noexcept
926  {
927  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
928  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
929  }
930  }
931 }
932 
933 namespace host_ia32_perf_global_ctrl
934 {
935  constexpr const auto addr = 0x0000000000002C04UL;
936  constexpr const auto name = "host_ia32_perf_global_ctrl";
937 
938  inline auto exists() noexcept
940 
941  inline auto get()
942  { return get_vmcs_field(addr, name, exists()); }
943 
944  inline auto get_if_exists(bool verbose = false) noexcept
945  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
946 
947  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
948  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
949 
950  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
951  void set_if_exists(T val, bool verbose = false) noexcept
952  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
953 
954  namespace reserved
955  {
956  constexpr const auto mask = 0xFFFFFFF8FFFFFFFCUL;
957  constexpr const auto from = 0;
958 
959  inline auto get()
960  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
961 
962  inline auto get_if_exists(bool verbose = false) noexcept
963  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
964 
965  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
966  void set(T val)
967  {
968  auto&& field = get_vmcs_field(addr, name, exists());
969  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
970  }
971 
972  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
973  void set_if_exists(T val, bool verbose = false) noexcept
974  {
975  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
976  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
977  }
978  }
979 }
980 
981 }
982 }
983 
984 // *INDENT-ON*
985 
986 #endif
auto get_vmcs_field_if_exists(T addr, const char *name, bool verbose, bool exists)
void set_if_exists(T val, bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
auto set_vmcs_field_if_exists(V val, A addr, const char *name, bool verbose, bool exists) noexcept
void uint64_t uint64_t uint64_t *rdx noexcept
auto is_bit_cleared(T t, B b) noexcept
Definition: bitmanip.h:54
auto get_if_exists(bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
auto clear_bit(T t, B b) noexcept
Definition: bitmanip.h:36
constexpr const auto reserved
Definition: vcpuid.h:33
auto set_vmcs_field(V val, A addr, const char *name, bool exists)
auto set_bit(T t, B b) noexcept
Definition: bitmanip.h:30
auto get_bits(T t, M m) noexcept
Definition: bitmanip.h:65
void set_if_exists(T val, bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
auto get_vmcs_field(T addr, const char *name, bool exists)
void set_if_exists(T val, bool verbose=false) noexcept
auto is_bit_set(T t, B b) noexcept
Definition: bitmanip.h:48
auto set_bits(T t, M m, V v) noexcept
Definition: bitmanip.h:72