inout.c (277310) | inout.c (282558) |
---|---|
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/inout.c 277310 2015-01-18 03:08:30Z neel $ | 26 * $FreeBSD: head/usr.sbin/bhyve/inout.c 282558 2015-05-06 16:25:20Z neel $ |
27 */ 28 29#include <sys/cdefs.h> | 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/usr.sbin/bhyve/inout.c 277310 2015-01-18 03:08:30Z neel $"); | 30__FBSDID("$FreeBSD: head/usr.sbin/bhyve/inout.c 282558 2015-05-06 16:25:20Z neel $"); |
31 32#include <sys/param.h> 33#include <sys/linker_set.h> 34#include <sys/_iovec.h> 35#include <sys/mman.h> 36 37#include <x86/psl.h> 38#include <x86/segments.h> --- 63 unchanged lines hidden (view full) --- 102 103int 104emulate_inout(struct vmctx *ctx, int vcpu, struct vm_exit *vmexit, int strict) 105{ 106 int addrsize, bytes, flags, in, port, prot, rep; 107 uint32_t eax, val; 108 inout_func_t handler; 109 void *arg; | 31 32#include <sys/param.h> 33#include <sys/linker_set.h> 34#include <sys/_iovec.h> 35#include <sys/mman.h> 36 37#include <x86/psl.h> 38#include <x86/segments.h> --- 63 unchanged lines hidden (view full) --- 102 103int 104emulate_inout(struct vmctx *ctx, int vcpu, struct vm_exit *vmexit, int strict) 105{ 106 int addrsize, bytes, flags, in, port, prot, rep; 107 uint32_t eax, val; 108 inout_func_t handler; 109 void *arg; |
110 int error, retval; | 110 int error, fault, retval; |
111 enum vm_reg_name idxreg; 112 uint64_t gla, index, iterations, count; 113 struct vm_inout_str *vis; 114 struct iovec iov[2]; 115 116 bytes = vmexit->u.inout.bytes; 117 in = vmexit->u.inout.in; 118 port = vmexit->u.inout.port; --- 39 unchanged lines hidden (view full) --- 158 if (vie_calculate_gla(vis->paging.cpu_mode, 159 vis->seg_name, &vis->seg_desc, index, bytes, 160 addrsize, prot, &gla)) { 161 vm_inject_gp(ctx, vcpu); 162 break; 163 } 164 165 error = vm_copy_setup(ctx, vcpu, &vis->paging, gla, | 111 enum vm_reg_name idxreg; 112 uint64_t gla, index, iterations, count; 113 struct vm_inout_str *vis; 114 struct iovec iov[2]; 115 116 bytes = vmexit->u.inout.bytes; 117 in = vmexit->u.inout.in; 118 port = vmexit->u.inout.port; --- 39 unchanged lines hidden (view full) --- 158 if (vie_calculate_gla(vis->paging.cpu_mode, 159 vis->seg_name, &vis->seg_desc, index, bytes, 160 addrsize, prot, &gla)) { 161 vm_inject_gp(ctx, vcpu); 162 break; 163 } 164 165 error = vm_copy_setup(ctx, vcpu, &vis->paging, gla, |
166 bytes, prot, iov, nitems(iov)); 167 if (error == -1) { | 166 bytes, prot, iov, nitems(iov), &fault); 167 if (error) { |
168 retval = -1; /* Unrecoverable error */ 169 break; | 168 retval = -1; /* Unrecoverable error */ 169 break; |
170 } else if (error == 1) { | 170 } else if (fault) { |
171 retval = 0; /* Resume guest to handle fault */ 172 break; 173 } 174 175 if (vie_alignment_check(vis->paging.cpl, bytes, 176 vis->cr0, vis->rflags, gla)) { 177 vm_inject_ac(ctx, vcpu, 0); 178 break; --- 119 unchanged lines hidden --- | 171 retval = 0; /* Resume guest to handle fault */ 172 break; 173 } 174 175 if (vie_alignment_check(vis->paging.cpl, bytes, 176 vis->cr0, vis->rflags, gla)) { 177 vm_inject_ac(ctx, vcpu, 0); 178 break; --- 119 unchanged lines hidden --- |