Deleted Added
full compact
mem.c (266627) mem.c (269008)
1/*-
2 * Copyright (c) 2012 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) 2012 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/mem.c 266627 2014-05-24 20:26:57Z neel $
26 * $FreeBSD: head/usr.sbin/bhyve/mem.c 269008 2014-07-23 04:28:51Z neel $
27 */
28
29/*
30 * Memory ranges are represented with an RB tree. On insertion, the range
31 * is checked for overlaps. On lookup, the key has the same base and limit
32 * so it can be searched within the range.
33 */
34
35#include <sys/cdefs.h>
27 */
28
29/*
30 * Memory ranges are represented with an RB tree. On insertion, the range
31 * is checked for overlaps. On lookup, the key has the same base and limit
32 * so it can be searched within the range.
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/usr.sbin/bhyve/mem.c 266627 2014-05-24 20:26:57Z neel $");
36__FBSDID("$FreeBSD: head/usr.sbin/bhyve/mem.c 269008 2014-07-23 04:28:51Z neel $");
37
38#include <sys/types.h>
39#include <sys/tree.h>
40#include <sys/errno.h>
41#include <machine/vmm.h>
42#include <machine/vmm_instruction_emul.h>
43
44#include <stdio.h>

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

152 struct mem_range *mr = arg;
153
154 error = (*mr->handler)(ctx, vcpu, MEM_F_WRITE, gpa, size,
155 &wval, mr->arg1, mr->arg2);
156 return (error);
157}
158
159int
37
38#include <sys/types.h>
39#include <sys/tree.h>
40#include <sys/errno.h>
41#include <machine/vmm.h>
42#include <machine/vmm_instruction_emul.h>
43
44#include <stdio.h>

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

152 struct mem_range *mr = arg;
153
154 error = (*mr->handler)(ctx, vcpu, MEM_F_WRITE, gpa, size,
155 &wval, mr->arg1, mr->arg2);
156 return (error);
157}
158
159int
160emulate_mem(struct vmctx *ctx, int vcpu, uint64_t paddr, struct vie *vie)
160emulate_mem(struct vmctx *ctx, int vcpu, uint64_t paddr, struct vie *vie,
161 struct vm_guest_paging *paging)
162
161{
162 struct mmio_rb_range *entry;
163 int err;
164
165 pthread_rwlock_rdlock(&mmio_rwlock);
166 /*
167 * First check the per-vCPU cache
168 */

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

179 mmio_hint[vcpu] = entry;
180 } else if (mmio_rb_lookup(&mmio_rb_fallback, paddr, &entry)) {
181 pthread_rwlock_unlock(&mmio_rwlock);
182 return (ESRCH);
183 }
184 }
185
186 assert(entry != NULL);
163{
164 struct mmio_rb_range *entry;
165 int err;
166
167 pthread_rwlock_rdlock(&mmio_rwlock);
168 /*
169 * First check the per-vCPU cache
170 */

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

181 mmio_hint[vcpu] = entry;
182 } else if (mmio_rb_lookup(&mmio_rb_fallback, paddr, &entry)) {
183 pthread_rwlock_unlock(&mmio_rwlock);
184 return (ESRCH);
185 }
186 }
187
188 assert(entry != NULL);
187 err = vmm_emulate_instruction(ctx, vcpu, paddr, vie,
189 err = vmm_emulate_instruction(ctx, vcpu, paddr, vie, paging,
188 mem_read, mem_write, &entry->mr_param);
189 pthread_rwlock_unlock(&mmio_rwlock);
190 mem_read, mem_write, &entry->mr_param);
191 pthread_rwlock_unlock(&mmio_rwlock);
190
192
191 return (err);
192}
193
194static int
195register_mem_int(struct mmio_rb_tree *rbt, struct mem_range *memp)
196{
197 struct mmio_rb_range *entry, *mrp;
198 int err;

--- 72 unchanged lines hidden ---
193 return (err);
194}
195
196static int
197register_mem_int(struct mmio_rb_tree *rbt, struct mem_range *memp)
198{
199 struct mmio_rb_range *entry, *mrp;
200 int err;

--- 72 unchanged lines hidden ---