[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 02/16] xen/arm: make mmio handlers domain specific
From: Vijaya Kumar K <Vijaya.Kumar@xxxxxxxxxxxxxxxxxx> register mmio handlers at runtime and make mmio handlers domain specific and check handlers are removed. Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@xxxxxxxxxxxxxxxxxx> --- xen/arch/arm/domain.c | 3 +++ xen/arch/arm/io.c | 42 ++++++++++++++++++++++++++++++------------ xen/arch/arm/vgic.c | 16 +++++++--------- xen/arch/arm/vuart.c | 17 +++++++---------- xen/include/asm-arm/domain.h | 2 ++ xen/include/asm-arm/mmio.h | 13 ++++++++++--- 6 files changed, 59 insertions(+), 34 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index e6ddedf..0d52457 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -521,6 +521,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags) share_xen_page_with_guest( virt_to_page(d->shared_info), d, XENSHARE_writable); + if ( (rc = domain_io_init(d)) != 0 ) + goto fail; + if ( (rc = p2m_alloc_table(d)) != 0 ) goto fail; diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c index ada1918..1a0be89 100644 --- a/xen/arch/arm/io.c +++ b/xen/arch/arm/io.c @@ -18,29 +18,47 @@ #include <xen/config.h> #include <xen/lib.h> +#include <xen/spinlock.h> +#include <xen/sched.h> #include <asm/current.h> #include <asm/mmio.h> -static const struct mmio_handler *const mmio_handlers[] = -{ - &vgic_distr_mmio_handler, - &vuart_mmio_handler, -}; -#define MMIO_HANDLER_NR ARRAY_SIZE(mmio_handlers) - int handle_mmio(mmio_info_t *info) { struct vcpu *v = current; int i; + struct io_handler *mmio_handle = &v->domain->arch.io_handlers; - for ( i = 0; i < MMIO_HANDLER_NR; i++ ) - if ( mmio_handlers[i]->check_handler(v, info->gpa) ) + for ( i = 0; i < mmio_handle->num_entries; i++ ) + { + if ( (info->gpa >= mmio_handle->mmio_handlers[i]->addr) && + info->gpa < (mmio_handle->mmio_handlers[i]->addr + mmio_handle->mmio_handlers[i]->size) ) return info->dabt.write ? - mmio_handlers[i]->write_handler(v, info) : - mmio_handlers[i]->read_handler(v, info); - + mmio_handle->mmio_handlers[i]->write_handler(v, info) : + mmio_handle->mmio_handlers[i]->read_handler(v, info); + } return 0; } + +void register_mmio_handler(struct domain *d, struct mmio_handler * handle) +{ + struct io_handler *handler = &d->arch.io_handlers; + + BUG_ON(handler->num_entries >= MAX_IO_HANDLER); + + spin_lock(&handler->lock); + handler->mmio_handlers[handler->num_entries] = handle; + handler->num_entries++; + spin_unlock(&handler->lock); +} + +int domain_io_init(struct domain *d) +{ + spin_lock_init(&d->arch.io_handlers.lock); + d->arch.io_handlers.num_entries = 0; + return 0; +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index 9c404fe..d36058a 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -35,6 +35,8 @@ /* Number of ranks of interrupt registers for a domain */ #define DOMAIN_NR_RANKS(d) (((d)->arch.vgic.nr_lines+31)/32) +static struct mmio_handler vgic_distr_mmio_handler; + /* * Rank containing GICD_<FOO><n> for GICD_<FOO> with * <b>-bits-per-interrupt @@ -98,6 +100,10 @@ int domain_vgic_init(struct domain *d) } for (i=0; i<DOMAIN_NR_RANKS(d); i++) spin_lock_init(&d->arch.vgic.shared_irqs[i].lock); + + vgic_distr_mmio_handler.addr = d->arch.vgic.dbase; + vgic_distr_mmio_handler.size = PAGE_SIZE; + register_mmio_handler(d, &vgic_distr_mmio_handler); return 0; } @@ -657,15 +663,7 @@ write_ignore: return 1; } -static int vgic_distr_mmio_check(struct vcpu *v, paddr_t addr) -{ - struct domain *d = v->domain; - - return (addr >= (d->arch.vgic.dbase)) && (addr < (d->arch.vgic.dbase + PAGE_SIZE)); -} - -const struct mmio_handler vgic_distr_mmio_handler = { - .check_handler = vgic_distr_mmio_check, +static struct mmio_handler vgic_distr_mmio_handler = { .read_handler = vgic_distr_mmio_read, .write_handler = vgic_distr_mmio_write, }; diff --git a/xen/arch/arm/vuart.c b/xen/arch/arm/vuart.c index 895e5cd..f43f2e5 100644 --- a/xen/arch/arm/vuart.c +++ b/xen/arch/arm/vuart.c @@ -44,6 +44,8 @@ #define domain_has_vuart(d) ((d)->arch.vuart.info != NULL) +static struct mmio_handler vuart_mmio_handler; + int domain_vuart_init(struct domain *d) { ASSERT( !d->domain_id ); @@ -59,6 +61,10 @@ int domain_vuart_init(struct domain *d) if ( !d->arch.vuart.buf ) return -ENOMEM; + vuart_mmio_handler.addr = d->arch.vuart.info->base_addr; + vuart_mmio_handler.size = d->arch.vuart.info->size; + register_mmio_handler(d, &vuart_mmio_handler); + return 0; } @@ -92,14 +98,6 @@ static void vuart_print_char(struct vcpu *v, char c) spin_unlock(&uart->lock); } -static int vuart_mmio_check(struct vcpu *v, paddr_t addr) -{ - const struct vuart_info *info = v->domain->arch.vuart.info; - - return (domain_has_vuart(v->domain) && addr >= info->base_addr && - addr <= (info->base_addr + info->size)); -} - static int vuart_mmio_read(struct vcpu *v, mmio_info_t *info) { struct domain *d = v->domain; @@ -133,8 +131,7 @@ static int vuart_mmio_write(struct vcpu *v, mmio_info_t *info) return 1; } -const struct mmio_handler vuart_mmio_handler = { - .check_handler = vuart_mmio_check, +static struct mmio_handler vuart_mmio_handler = { .read_handler = vuart_mmio_read, .write_handler = vuart_mmio_write, }; diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 696f36c..999bbdd 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -7,6 +7,7 @@ #include <asm/page.h> #include <asm/p2m.h> #include <asm/vfp.h> +#include <asm/mmio.h> #include <public/hvm/params.h> #include <xen/serial.h> @@ -116,6 +117,7 @@ struct arch_domain struct hvm_domain hvm_domain; xen_pfn_t *grant_table_gpfn; + struct io_handler io_handlers; /* Continuable domain_relinquish_resources(). */ enum { RELMEM_not_started, diff --git a/xen/include/asm-arm/mmio.h b/xen/include/asm-arm/mmio.h index 44b28a6..2bb5f5e 100644 --- a/xen/include/asm-arm/mmio.h +++ b/xen/include/asm-arm/mmio.h @@ -35,15 +35,22 @@ typedef int (*mmio_write_t)(struct vcpu *v, mmio_info_t *info); typedef int (*mmio_check_t)(struct vcpu *v, paddr_t addr); struct mmio_handler { - mmio_check_t check_handler; + paddr_t addr; + unsigned long size; mmio_read_t read_handler; mmio_write_t write_handler; }; -extern const struct mmio_handler vgic_distr_mmio_handler; -extern const struct mmio_handler vuart_mmio_handler; +#define MAX_IO_HANDLER 16 +struct io_handler { + int num_entries; + spinlock_t lock; + struct mmio_handler *mmio_handlers[MAX_IO_HANDLER]; +}; extern int handle_mmio(mmio_info_t *info); +void register_mmio_handler(struct domain *d, struct mmio_handler * handle); +int domain_io_init(struct domain *d); #endif -- 1.7.9.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |