From 4c38ff00c65e1829882ec29118e091403808b6d4 Mon Sep 17 00:00:00 2001 From: Peter Fang Date: Tue, 16 Apr 2019 18:35:47 -0700 Subject: [PATCH] dm: completely remove enable_bar()/disable_bar() functions Following up on d648df766c263512c93356a55ff97cb3e23fe3e4, surgically remove all the functions related to enable_bar()/disable_bar() that got introduced in 8787b65fdee622639925ad75fe920913e0e7f102. Tracked-On: #2902 Signed-off-by: Peter Fang Reviewed-by: Shuo A Liu --- devicemodel/core/inout.c | 44 ------------------- devicemodel/core/mem.c | 88 ++++--------------------------------- devicemodel/include/inout.h | 2 - devicemodel/include/mem.h | 5 +-- 4 files changed, 9 insertions(+), 130 deletions(-) diff --git a/devicemodel/core/inout.c b/devicemodel/core/inout.c index daa8add98..a16f3db5a 100644 --- a/devicemodel/core/inout.c +++ b/devicemodel/core/inout.c @@ -26,7 +26,6 @@ * $FreeBSD$ */ -#include #include #include #include @@ -45,7 +44,6 @@ static struct { int flags; inout_func_t handler; void *arg; - bool enabled; } inout_handlers[MAX_IOPORTS]; static int @@ -115,11 +113,6 @@ emulate_inout(struct vmctx *ctx, int *pvcpu, struct pio_request *pio_request) if (!(flags & IOPORT_F_OUT)) return -1; } - - if (inout_handlers[port].enabled == false) { - return -1; - } - retval = handler(ctx, *pvcpu, in, port, bytes, (uint32_t *)&(pio_request->value), arg); return retval; @@ -148,42 +141,6 @@ init_inout(void) } } -int -disable_inout(struct inout_port *iop) -{ - int i; - - if (!VERIFY_IOPORT(iop->port, iop->size)) { - printf("invalid input: port:0x%x, size:%d", - iop->port, iop->size); - return -1; - } - - for (i = iop->port; i < iop->port + iop->size; i++) { - inout_handlers[i].enabled = false; - } - - return 0; -} - -int -enable_inout(struct inout_port *iop) -{ - int i; - - if (!VERIFY_IOPORT(iop->port, iop->size)) { - printf("invalid input: port:0x%x, size:%d", - iop->port, iop->size); - return -1; - } - - for (i = iop->port; i < iop->port + iop->size; i++) { - inout_handlers[i].enabled = true; - } - - return 0; -} - int register_inout(struct inout_port *iop) { @@ -211,7 +168,6 @@ register_inout(struct inout_port *iop) inout_handlers[i].flags = iop->flags; inout_handlers[i].handler = iop->handler; inout_handlers[i].arg = iop->arg; - inout_handlers[i].enabled = true; } return 0; diff --git a/devicemodel/core/mem.c b/devicemodel/core/mem.c index 4994eb221..7a30f26bb 100644 --- a/devicemodel/core/mem.c +++ b/devicemodel/core/mem.c @@ -33,7 +33,6 @@ */ #include -#include #include #include #include @@ -51,7 +50,6 @@ struct mmio_rb_range { struct mem_range mr_param; uint64_t mr_base; uint64_t mr_end; - bool enabled; }; static RB_HEAD(mmio_rb_tree, mmio_rb_range) mmio_rb_root, mmio_rb_fallback; @@ -168,25 +166,18 @@ emulate_mem(struct vmctx *ctx, struct mmio_request *mmio_req) if (mmio_hint && paddr >= mmio_hint->mr_base && paddr <= mmio_hint->mr_end) entry = mmio_hint; - - if (entry == NULL) { - if (mmio_rb_lookup(&mmio_rb_root, paddr, &entry) == 0) - /* Update the per-VMU cache */ - mmio_hint = entry; - else if (mmio_rb_lookup(&mmio_rb_fallback, paddr, &entry)) { - pthread_rwlock_unlock(&mmio_rwlock); - return -ESRCH; - } + else if (mmio_rb_lookup(&mmio_rb_root, paddr, &entry) == 0) + /* Update the per-VM cache */ + mmio_hint = entry; + else if (mmio_rb_lookup(&mmio_rb_fallback, paddr, &entry)) { + pthread_rwlock_unlock(&mmio_rwlock); + return -ESRCH; } + pthread_rwlock_unlock(&mmio_rwlock); + assert(entry != NULL); - if (entry->enabled == false) { - pthread_rwlock_unlock(&mmio_rwlock); - return -1; - } - pthread_rwlock_unlock(&mmio_rwlock); - if (mmio_req->direction == REQUEST_READ) err = mem_read(ctx, 0, paddr, (uint64_t *)&mmio_req->value, size, &entry->mr_param); @@ -197,68 +188,6 @@ emulate_mem(struct vmctx *ctx, struct mmio_request *mmio_req) return err; } -int -disable_mem(struct mem_range *memp) -{ - uint64_t paddr = memp->base; - struct mmio_rb_range *entry = NULL; - - pthread_rwlock_rdlock(&mmio_rwlock); - /* - * First check the per-VM cache - */ - if (mmio_hint && paddr >= mmio_hint->mr_base && - paddr <= mmio_hint->mr_end) - entry = mmio_hint; - - if (entry == NULL) { - if (mmio_rb_lookup(&mmio_rb_root, paddr, &entry) == 0) - /* Update the per-VMU cache */ - mmio_hint = entry; - else if (mmio_rb_lookup(&mmio_rb_fallback, paddr, &entry)) { - pthread_rwlock_unlock(&mmio_rwlock); - return -ESRCH; - } - } - - assert(entry != NULL); - entry->enabled = false; - pthread_rwlock_unlock(&mmio_rwlock); - - return 0; -} - -int -enable_mem(struct mem_range *memp) -{ - uint64_t paddr = memp->base; - struct mmio_rb_range *entry = NULL; - - pthread_rwlock_rdlock(&mmio_rwlock); - /* - * First check the per-VM cache - */ - if (mmio_hint && paddr >= mmio_hint->mr_base && - paddr <= mmio_hint->mr_end) - entry = mmio_hint; - - if (entry == NULL) { - if (mmio_rb_lookup(&mmio_rb_root, paddr, &entry) == 0) - /* Update the per-VMU cache */ - mmio_hint = entry; - else if (mmio_rb_lookup(&mmio_rb_fallback, paddr, &entry)) { - pthread_rwlock_unlock(&mmio_rwlock); - return -ESRCH; - } - } - - assert(entry != NULL); - entry->enabled = true; - pthread_rwlock_unlock(&mmio_rwlock); - - return 0; -} - static int register_mem_int(struct mmio_rb_tree *rbt, struct mem_range *memp) { @@ -273,7 +202,6 @@ register_mem_int(struct mmio_rb_tree *rbt, struct mem_range *memp) mrp->mr_param = *memp; mrp->mr_base = memp->base; mrp->mr_end = memp->base + memp->size - 1; - mrp->enabled = true; pthread_rwlock_wrlock(&mmio_rwlock); if (mmio_rb_lookup(rbt, memp->base, &entry) != 0) err = mmio_rb_add(rbt, mrp); diff --git a/devicemodel/include/inout.h b/devicemodel/include/inout.h index 8d08fe294..9f9d5386c 100644 --- a/devicemodel/include/inout.h +++ b/devicemodel/include/inout.h @@ -74,7 +74,5 @@ void init_inout(void); int emulate_inout(struct vmctx *ctx, int *pvcpu, struct pio_request *req); int register_inout(struct inout_port *iop); int unregister_inout(struct inout_port *iop); -int enable_inout(struct inout_port *iop); -int disable_inout(struct inout_port *iop); #endif /* _INOUT_H_ */ diff --git a/devicemodel/include/mem.h b/devicemodel/include/mem.h index 3752d5597..f023d3836 100644 --- a/devicemodel/include/mem.h +++ b/devicemodel/include/mem.h @@ -42,16 +42,13 @@ struct mem_range { long arg2; uint64_t base; uint64_t size; - bool enabled; }; #define MEM_F_READ 0x1 #define MEM_F_WRITE 0x2 -#define MEM_F_RW 0x3 +#define MEM_F_RW (MEM_F_READ | MEM_F_WRITE) #define MEM_F_IMMUTABLE 0x4 /* mem_range cannot be unregistered */ int emulate_mem(struct vmctx *ctx, struct mmio_request *mmio_req); -int disable_mem(struct mem_range *memp); -int enable_mem(struct mem_range *memp); int register_mem(struct mem_range *memp); int register_mem_fallback(struct mem_range *memp); int unregister_mem(struct mem_range *memp);