Deleted Added
full compact
bhyverun.c (266125) bhyverun.c (266573)
1/*-
2 * Copyright (c) 2011 NetApp, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2011 NetApp, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/usr.sbin/bhyve/bhyverun.c 266125 2014-05-15 14:16:55Z jhb $
26 * $FreeBSD: head/usr.sbin/bhyve/bhyverun.c 266573 2014-05-23 05:15:17Z neel $
27 */
28
29#include <sys/cdefs.h>
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/usr.sbin/bhyve/bhyverun.c 266125 2014-05-15 14:16:55Z jhb $");
30__FBSDID("$FreeBSD: head/usr.sbin/bhyve/bhyverun.c 266573 2014-05-23 05:15:17Z neel $");
31
32#include <sys/types.h>
33#include <sys/mman.h>
34#include <sys/time.h>
35
36#include <machine/atomic.h>
37#include <machine/segments.h>
38

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

283#endif
284 return (VMEXIT_CONTINUE);
285}
286
287static int
288vmexit_inout(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
289{
290 int error;
31
32#include <sys/types.h>
33#include <sys/mman.h>
34#include <sys/time.h>
35
36#include <machine/atomic.h>
37#include <machine/segments.h>
38

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

283#endif
284 return (VMEXIT_CONTINUE);
285}
286
287static int
288vmexit_inout(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
289{
290 int error;
291 int bytes, port, in, out;
292 uint32_t eax;
291 int bytes, port, in, out, string;
293 int vcpu;
294
295 vcpu = *pvcpu;
296
297 port = vme->u.inout.port;
298 bytes = vme->u.inout.bytes;
292 int vcpu;
293
294 vcpu = *pvcpu;
295
296 port = vme->u.inout.port;
297 bytes = vme->u.inout.bytes;
299 eax = vme->u.inout.eax;
298 string = vme->u.inout.string;
300 in = vme->u.inout.in;
301 out = !in;
302
299 in = vme->u.inout.in;
300 out = !in;
301
303 /* We don't deal with these */
304 if (vme->u.inout.string || vme->u.inout.rep)
305 return (VMEXIT_ABORT);
306
307 /* Extra-special case of host notifications */
302 /* Extra-special case of host notifications */
308 if (out && port == GUEST_NIO_PORT)
309 return (vmexit_handle_notify(ctx, vme, pvcpu, eax));
303 if (out && port == GUEST_NIO_PORT) {
304 error = vmexit_handle_notify(ctx, vme, pvcpu, vme->u.inout.eax);
305 return (error);
306 }
310
307
311 error = emulate_inout(ctx, vcpu, in, port, bytes, &eax, strictio);
312 if (error == INOUT_OK && in)
313 error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RAX, eax);
308 error = emulate_inout(ctx, vcpu, vme, strictio);
309 if (error == INOUT_OK && in && !string) {
310 error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RAX,
311 vme->u.inout.eax);
312 }
314
315 switch (error) {
316 case INOUT_OK:
317 return (VMEXIT_CONTINUE);
313
314 switch (error) {
315 case INOUT_OK:
316 return (VMEXIT_CONTINUE);
317 case INOUT_RESTART:
318 return (VMEXIT_RESTART);
318 case INOUT_RESET:
319 stats.io_reset++;
320 return (VMEXIT_RESET);
321 case INOUT_POWEROFF:
322 stats.io_poweroff++;
323 return (VMEXIT_POWEROFF);
324 default:
325 fprintf(stderr, "Unhandled %s%c 0x%04x\n",

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

509 fprintf(stderr, "vmexit_suspend: invalid reason %d\n", how);
510 exit(100);
511 }
512 return (0); /* NOTREACHED */
513}
514
515static vmexit_handler_t handler[VM_EXITCODE_MAX] = {
516 [VM_EXITCODE_INOUT] = vmexit_inout,
319 case INOUT_RESET:
320 stats.io_reset++;
321 return (VMEXIT_RESET);
322 case INOUT_POWEROFF:
323 stats.io_poweroff++;
324 return (VMEXIT_POWEROFF);
325 default:
326 fprintf(stderr, "Unhandled %s%c 0x%04x\n",

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

510 fprintf(stderr, "vmexit_suspend: invalid reason %d\n", how);
511 exit(100);
512 }
513 return (0); /* NOTREACHED */
514}
515
516static vmexit_handler_t handler[VM_EXITCODE_MAX] = {
517 [VM_EXITCODE_INOUT] = vmexit_inout,
518 [VM_EXITCODE_INOUT_STR] = vmexit_inout,
517 [VM_EXITCODE_VMX] = vmexit_vmx,
518 [VM_EXITCODE_BOGUS] = vmexit_bogus,
519 [VM_EXITCODE_RDMSR] = vmexit_rdmsr,
520 [VM_EXITCODE_WRMSR] = vmexit_wrmsr,
521 [VM_EXITCODE_MTRAP] = vmexit_mtrap,
522 [VM_EXITCODE_INST_EMUL] = vmexit_inst_emul,
523 [VM_EXITCODE_SPINUP_AP] = vmexit_spinup_ap,
524 [VM_EXITCODE_SUSPENDED] = vmexit_suspend

--- 304 unchanged lines hidden ---
519 [VM_EXITCODE_VMX] = vmexit_vmx,
520 [VM_EXITCODE_BOGUS] = vmexit_bogus,
521 [VM_EXITCODE_RDMSR] = vmexit_rdmsr,
522 [VM_EXITCODE_WRMSR] = vmexit_wrmsr,
523 [VM_EXITCODE_MTRAP] = vmexit_mtrap,
524 [VM_EXITCODE_INST_EMUL] = vmexit_inst_emul,
525 [VM_EXITCODE_SPINUP_AP] = vmexit_spinup_ap,
526 [VM_EXITCODE_SUSPENDED] = vmexit_suspend

--- 304 unchanged lines hidden ---