forked from hooklift/xhyve
-
Notifications
You must be signed in to change notification settings - Fork 6
/
vmm_api.c
836 lines (683 loc) · 15.1 KB
/
vmm_api.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
/*-
* Copyright (c) 2015 xhyve developers
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <xhyve/support/misc.h>
#include <xhyve/support/specialreg.h>
#include <xhyve/vmm/vmm.h>
#include <xhyve/vmm/vmm_lapic.h>
#include <xhyve/vmm/vmm_instruction_emul.h>
#include <xhyve/vmm/vmm_callout.h>
#include <xhyve/vmm/vmm_stat.h>
#include <xhyve/vmm/vmm_api.h>
#include <xhyve/vmm/io/vatpic.h>
#include <xhyve/vmm/io/vhpet.h>
#include <xhyve/vmm/io/vioapic.h>
#include <xhyve/vmm/io/vrtc.h>
static struct vm *vm;
static int memflags;
static uint32_t lowmem_limit;
static enum vm_mmap_style mmap_style;
static size_t lowmem;
static void *lowmem_addr;
static size_t highmem;
static void *highmem_addr;
static void
vcpu_freeze(int vcpu, bool freeze)
{
enum vcpu_state state;
state = (freeze) ? VCPU_FROZEN : VCPU_IDLE;
if (vcpu_set_state(vm, vcpu, state, freeze)) {
xhyve_abort("vcpu_set_state failed\n");
}
}
static void
vcpu_freeze_all(bool freeze)
{
enum vcpu_state state;
int vcpu;
state = (freeze) ? VCPU_FROZEN : VCPU_IDLE;
for (vcpu = 0; vcpu < VM_MAXCPU; vcpu++) {
if (vcpu_set_state(vm, vcpu, state, freeze)) {
xhyve_abort("vcpu_set_state failed\n");
}
}
}
void xh_hv_pause(int pause) {
assert(vm != NULL);
vm_signal_pause(vm, (pause != 0));
}
int
xh_vm_create(void)
{
int error;
if (vm != NULL) {
return (EEXIST);
}
error = vmm_init();
if (error != 0) {
return (error);
}
memflags = 0;
lowmem_limit = (3ull << 30);
return (vm_create(&vm));
}
void
xh_vm_destroy(void)
{
assert(vm != NULL);
vm_destroy(vm);
if (vmm_cleanup() == 0) {
vm = NULL;
}
}
int
xh_vcpu_create(int vcpu)
{
assert(vm != NULL);
return (vcpu_create(vm, vcpu));
}
void
xh_vcpu_destroy(int vcpu)
{
assert(vm != NULL);
vcpu_destroy(vm, vcpu);
}
int
xh_vm_get_memory_seg(uint64_t gpa, size_t *ret_len)
{
int error;
struct vm_memory_segment seg;
error = vm_gpabase2memseg(vm, gpa, &seg);
if (error == 0) {
*ret_len = seg.len;
}
return (error);
}
static int
setup_memory_segment(uint64_t gpa, size_t len, void **addr)
{
void *object;
uint64_t offset;
int error;
vcpu_freeze_all(true);
error = vm_malloc(vm, gpa, len);
if (error == 0) {
error = vm_get_memobj(vm, gpa, len, &offset, &object);
if (error == 0) {
*addr = (void *) (((uintptr_t) object) + offset);
}
}
vcpu_freeze_all(false);
return (error);
}
int
xh_vm_setup_memory(size_t len, enum vm_mmap_style vms)
{
void **addr;
int error;
/* XXX VM_MMAP_SPARSE not implemented yet */
assert(vms == VM_MMAP_NONE || vms == VM_MMAP_ALL);
mmap_style = vms;
/*
* If 'len' cannot fit entirely in the 'lowmem' segment then
* create another 'highmem' segment above 4GB for the remainder.
*/
lowmem = (len > lowmem_limit) ? lowmem_limit : len;
highmem = (len > lowmem_limit) ? (len - lowmem) : 0;
if (lowmem > 0) {
addr = (vms == VM_MMAP_ALL) ? &lowmem_addr : NULL;
if ((error = setup_memory_segment(0, lowmem, addr))) {
return (error);
}
}
if (highmem > 0) {
addr = (vms == VM_MMAP_ALL) ? &highmem_addr : NULL;
if ((error = setup_memory_segment((4ull << 30), highmem, addr))) {
return (error);
}
}
return (0);
}
void *
xh_vm_map_gpa(uint64_t gpa, size_t len)
{
assert(mmap_style == VM_MMAP_ALL);
if ((gpa < lowmem) && ((gpa + len) <= lowmem)) {
return ((void *) (((uintptr_t) lowmem_addr) + gpa));
}
if (gpa >= (4ull << 30)) {
gpa -= (4ull << 30);
if ((gpa < highmem) && ((gpa + len) <= highmem)) {
return ((void *) (((uintptr_t) highmem_addr) + gpa));
}
}
return (NULL);
}
int
xh_vm_gla2gpa(int vcpu, struct vm_guest_paging *paging, uint64_t gla,
int prot, uint64_t *gpa, int *fault)
{
int error;
vcpu_freeze(vcpu, true);
error = vm_gla2gpa(vm, vcpu, paging, gla, prot, gpa, fault);
vcpu_freeze(vcpu, false);
return (error);
}
uint32_t
xh_vm_get_lowmem_limit(void)
{
return (lowmem_limit);
}
void
xh_vm_set_lowmem_limit(uint32_t limit)
{
lowmem_limit = limit;
}
void
xh_vm_set_memflags(int flags)
{
memflags = flags;
}
size_t
xh_vm_get_lowmem_size(void)
{
return (lowmem);
}
size_t
xh_vm_get_highmem_size(void)
{
return (highmem);
}
int
xh_vm_set_desc(int vcpu, int reg, uint64_t base, uint32_t limit,
uint32_t access)
{
struct seg_desc sd;
int error;
sd.base = base;
sd.limit = limit;
sd.access = access;
vcpu_freeze(vcpu, true);
error = vm_set_seg_desc(vm, vcpu, reg, &sd);
vcpu_freeze(vcpu, false);
return (error);
}
int
xh_vm_get_desc(int vcpu, int reg, uint64_t *base, uint32_t *limit,
uint32_t *access)
{
struct seg_desc sd;
int error;
vcpu_freeze(vcpu, true);
error = vm_get_seg_desc(vm, vcpu, reg, &sd);
if (error == 0) {
*base = sd.base;
*limit = sd.limit;
*access = sd.access;
}
vcpu_freeze(vcpu, false);
return (error);
}
int
xh_vm_get_seg_desc(int vcpu, int reg, struct seg_desc *seg_desc)
{
int error;
error = xh_vm_get_desc(vcpu, reg, &seg_desc->base, &seg_desc->limit,
&seg_desc->access);
return (error);
}
int
xh_vm_set_register(int vcpu, int reg, uint64_t val)
{
int error;
vcpu_freeze(vcpu, true);
error = vm_set_register(vm, vcpu, reg, val);
vcpu_freeze(vcpu, false);
return (error);
}
int
xh_vm_get_register(int vcpu, int reg, uint64_t *retval)
{
int error;
vcpu_freeze(vcpu, true);
error = vm_get_register(vm, vcpu, reg, retval);
vcpu_freeze(vcpu, false);
return (error);
}
int
xh_vm_run(int vcpu, struct vm_exit *ret_vmexit)
{
int error;
vcpu_freeze(vcpu, true);
error = vm_run(vm, vcpu, ret_vmexit);
vcpu_freeze(vcpu, false);
return (error);
}
int
xh_vm_suspend(enum vm_suspend_how how)
{
return (vm_suspend(vm, how));
}
int
xh_vm_reinit(void)
{
int error;
vcpu_freeze_all(true);
error = vm_reinit(vm);
vcpu_freeze_all(false);
return (error);
}
int
xh_vm_apicid2vcpu(int apicid)
{
return (apicid);
}
int
xh_vm_inject_exception(int vcpu, int vector, int errcode_valid,
uint32_t errcode, int restart_instruction)
{
int error;
vcpu_freeze(vcpu, true);
error = vm_inject_exception(vm, vcpu, vector, errcode_valid, errcode,
restart_instruction);
vcpu_freeze(vcpu, false);
return (error);
}
int
xh_vm_lapic_irq(int vcpu, int vector)
{
return (lapic_intr_edge(vm, vcpu, vector));
}
int
xh_vm_lapic_local_irq(int vcpu, int vector)
{
return (lapic_set_local_intr(vm, vcpu, vector));
}
int
xh_vm_lapic_msi(uint64_t addr, uint64_t msg)
{
return (lapic_intr_msi(vm, addr, msg));
}
int
xh_vm_ioapic_assert_irq(int irq)
{
return (vioapic_assert_irq(vm, irq));
}
int
xh_vm_ioapic_deassert_irq(int irq)
{
return (vioapic_deassert_irq(vm, irq));
}
int
xh_vm_ioapic_pulse_irq(int irq)
{
return (vioapic_pulse_irq(vm, irq));
}
int
xh_vm_ioapic_pincount(int *pincount)
{
*pincount = vioapic_pincount(vm);
return (0);
}
int
xh_vm_isa_assert_irq(int atpic_irq, int ioapic_irq)
{
int error;
error = vatpic_assert_irq(vm, atpic_irq);
if ((error == 0) && (ioapic_irq != -1)) {
error = vioapic_assert_irq(vm, ioapic_irq);
}
return (error);
}
int
xh_vm_isa_deassert_irq(int atpic_irq, int ioapic_irq)
{
int error;
error = vatpic_deassert_irq(vm, atpic_irq);
if ((error == 0) && (ioapic_irq != -1)) {
error = vioapic_deassert_irq(vm, ioapic_irq);
}
return (error);
}
int
xh_vm_isa_pulse_irq(int atpic_irq, int ioapic_irq)
{
int error;
error = vatpic_pulse_irq(vm, atpic_irq);
if ((error == 0) && (ioapic_irq != -1)) {
error = vioapic_pulse_irq(vm, ioapic_irq);
}
return (error);
}
int
xh_vm_isa_set_irq_trigger(int atpic_irq, enum vm_intr_trigger trigger)
{
return (vatpic_set_irq_trigger(vm, atpic_irq, trigger));
}
int
xh_vm_inject_nmi(int vcpu)
{
return (vm_inject_nmi(vm, vcpu));
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpadded"
static struct {
const char *name;
int type;
} capstrmap[] = {
{ "hlt_exit", VM_CAP_HALT_EXIT },
{ "mtrap_exit", VM_CAP_MTRAP_EXIT },
{ "pause_exit", VM_CAP_PAUSE_EXIT },
{ NULL, 0 }
};
#pragma clang diagnostic pop
int
xh_vm_capability_name2type(const char *capname)
{
int i;
for (i = 0; (capstrmap[i].name != NULL) && (capname != NULL); i++) {
if (strcmp(capstrmap[i].name, capname) == 0) {
return (capstrmap[i].type);
}
}
return (-1);
}
const char *
xh_vm_capability_type2name(int type)
{
int i;
for (i = 0; (capstrmap[i].name != NULL); i++) {
if (capstrmap[i].type == type) {
return (capstrmap[i].name);
}
}
return (NULL);
}
int
xh_vm_get_capability(int vcpu, enum vm_cap_type cap, int *retval)
{
int error;
vcpu_freeze(vcpu, true);
error = vm_get_capability(vm, vcpu, cap, retval);
vcpu_freeze(vcpu, false);
return (error);
}
int
xh_vm_set_capability(int vcpu, enum vm_cap_type cap, int val)
{
int error;
vcpu_freeze(vcpu, true);
error = vm_set_capability(vm, vcpu, cap, val);
vcpu_freeze(vcpu, false);
return (error);
}
int
xh_vm_get_intinfo(int vcpu, uint64_t *i1, uint64_t *i2)
{
int error;
vcpu_freeze(vcpu, true);
error = vm_get_intinfo(vm, vcpu, i1, i2);
vcpu_freeze(vcpu, false);
return (error);
}
int
xh_vm_set_intinfo(int vcpu, uint64_t exit_intinfo)
{
int error;
vcpu_freeze(vcpu, true);
error = vm_exit_intinfo(vm, vcpu, exit_intinfo);
vcpu_freeze(vcpu, false);
return (error);
}
uint64_t *
xh_vm_get_stats(int vcpu, struct timeval *ret_tv, int *ret_entries)
{
static uint64_t statbuf[64];
struct timeval tv;
int re;
int error;
getmicrotime(&tv);
error = vmm_stat_copy(vm, vcpu, &re, ((uint64_t *) &statbuf));
if (error == 0) {
if (ret_entries) {
*ret_entries = re;
}
if (ret_tv) {
*ret_tv = tv;
}
return (((uint64_t *) &statbuf));
} else {
return (NULL);
}
}
const char *
xh_vm_get_stat_desc(int index)
{
static char desc[128];
if (vmm_stat_desc_copy(index, ((char *) &desc), sizeof(desc)) == 0) {
return (desc);
} else {
return (NULL);
}
}
int
xh_vm_get_x2apic_state(int vcpu, enum x2apic_state *s)
{
return (vm_get_x2apic_state(vm, vcpu, s));
}
int
xh_vm_set_x2apic_state(int vcpu, enum x2apic_state s)
{
int error;
vcpu_freeze(vcpu, true);
error = vm_set_x2apic_state(vm, vcpu, s);
vcpu_freeze(vcpu, false);
return (error);
}
int
xh_vm_get_hpet_capabilities(uint32_t *capabilities)
{
return (vhpet_getcap(capabilities));
}
int
xh_vm_copy_setup(int vcpu, struct vm_guest_paging *pg, uint64_t gla, size_t len,
int prot, struct iovec *iov, int iovcnt, int *fault)
{
void *va;
uint64_t gpa;
size_t n, off;
int i, error;
for (i = 0; i < iovcnt; i++) {
iov[i].iov_base = 0;
iov[i].iov_len = 0;
}
while (len) {
assert(iovcnt > 0);
error = xh_vm_gla2gpa(vcpu, pg, gla, prot, &gpa, fault);
if ((error) || *fault) {
return (error);
}
off = gpa & XHYVE_PAGE_MASK;
n = min(len, XHYVE_PAGE_SIZE - off);
va = xh_vm_map_gpa(gpa, n);
if (va == NULL) {
return (EFAULT);
}
iov->iov_base = va;
iov->iov_len = n;
iov++;
iovcnt--;
gla += n;
len -= n;
}
return (0);
}
void
xh_vm_copyin(struct iovec *iov, void *dst, size_t len)
{
const char *src;
char *d;
size_t n;
d = dst;
while (len) {
assert(iov->iov_len);
n = min(len, iov->iov_len);
src = iov->iov_base;
bcopy(src, d, n);
iov++;
d += n;
len -= n;
}
}
void
xh_vm_copyout(const void *src, struct iovec *iov, size_t len)
{
const char *s;
char *dst;
size_t n;
s = src;
while (len) {
assert(iov->iov_len);
n = min(len, iov->iov_len);
dst = iov->iov_base;
bcopy(s, dst, n);
iov++;
s += n;
len -= n;
}
}
int
xh_vm_rtc_write(int offset, uint8_t value)
{
return (vrtc_nvram_write(vm, offset, value));
}
int
xh_vm_rtc_read(int offset, uint8_t *retval)
{
return (vrtc_nvram_read(vm, offset, retval));
}
int
xh_vm_rtc_settime(time_t secs)
{
return (vrtc_set_time(vm, secs));
}
int
xh_vm_rtc_gettime(time_t *secs)
{
*secs = vrtc_get_time(vm);
return (0);
}
int
xh_vcpu_reset(int vcpu)
{
int error;
#define SET_REG(r, v) (error = xh_vm_set_register(vcpu, (r), (v)))
#define SET_DESC(d, b, l, a) (error = xh_vm_set_desc(vcpu, (d), (b), (l), (a)))
if (SET_REG(VM_REG_GUEST_RFLAGS, 0x2) ||
SET_REG(VM_REG_GUEST_RIP, 0xfff0) ||
SET_REG(VM_REG_GUEST_CR0, CR0_NE) ||
SET_REG(VM_REG_GUEST_CR3, 0) ||
SET_REG(VM_REG_GUEST_CR4, 0) ||
SET_REG(VM_REG_GUEST_CS, 0xf000) ||
SET_REG(VM_REG_GUEST_SS, 0) ||
SET_REG(VM_REG_GUEST_DS, 0) ||
SET_REG(VM_REG_GUEST_ES, 0) ||
SET_REG(VM_REG_GUEST_FS, 0) ||
SET_REG(VM_REG_GUEST_GS, 0) ||
SET_REG(VM_REG_GUEST_RAX, 0) ||
SET_REG(VM_REG_GUEST_RBX, 0) ||
SET_REG(VM_REG_GUEST_RCX, 0) ||
SET_REG(VM_REG_GUEST_RDX, 0xf00) ||
SET_REG(VM_REG_GUEST_RSI, 0) ||
SET_REG(VM_REG_GUEST_RDI, 0) ||
SET_REG(VM_REG_GUEST_RBP, 0) ||
SET_REG(VM_REG_GUEST_RSP, 0) ||
SET_REG(VM_REG_GUEST_TR, 0) ||
SET_REG(VM_REG_GUEST_LDTR, 0) ||
SET_DESC(VM_REG_GUEST_CS, 0xffff0000, 0xffff, 0x0093) ||
SET_DESC(VM_REG_GUEST_SS, 0, 0xffff, 0x0093) ||
SET_DESC(VM_REG_GUEST_DS, 0, 0xffff, 0x0093) ||
SET_DESC(VM_REG_GUEST_ES, 0, 0xffff, 0x0093) ||
SET_DESC(VM_REG_GUEST_FS, 0, 0xffff, 0x0093) ||
SET_DESC(VM_REG_GUEST_GS, 0, 0xffff, 0x0093) ||
SET_DESC(VM_REG_GUEST_GDTR, 0, 0xffff, 0) ||
SET_DESC(VM_REG_GUEST_IDTR, 0, 0xffff, 0) ||
SET_DESC(VM_REG_GUEST_TR, 0, 0, 0x0000008b) ||
SET_DESC(VM_REG_GUEST_LDTR, 0, 0xffff, 0x00000082))
{
return (error);
}
return (0);
}
int
xh_vm_active_cpus(cpuset_t *cpus)
{
*cpus = vm_active_cpus(vm);
return (0);
}
int
xh_vm_suspended_cpus(cpuset_t *cpus)
{
*cpus = vm_suspended_cpus(vm);
return (0);
}
int
xh_vm_activate_cpu(int vcpu)
{
int error;
vcpu_freeze(vcpu, true);
error = vm_activate_cpu(vm, vcpu);
vcpu_freeze(vcpu, false);
return (error);
}
int
xh_vm_restart_instruction(int vcpu)
{
int error;
vcpu_freeze(vcpu, true);
error = vm_restart_instruction(vm, vcpu);
vcpu_freeze(vcpu, false);
return (error);
}
int
xh_vm_emulate_instruction(int vcpu, uint64_t gpa, struct vie *vie,
struct vm_guest_paging *paging, mem_region_read_t memread,
mem_region_write_t memwrite, void *memarg)
{
int error;
vcpu_freeze(vcpu, true);
error = vmm_emulate_instruction(vm, vcpu, gpa, vie, paging, memread,
memwrite, memarg);
vcpu_freeze(vcpu, false);
return (error);
}