[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v5 1/6] x86: allow IRQ to be disabled for resource access
Add the ability to disable IRQ when operating on certain continuous resource entries. If one entry is marked as XEN_RESOURCE_ENTRY_FLAGS_DISABLE_IRQ, then the resource operation on both the entry and the following entry will be done with IRQ disabled. Signed-off-by: Chao Peng <chao.p.peng@xxxxxxxxxxxxxxx> --- tools/libxc/xc_psr.c | 4 ++-- xen/arch/x86/platform_hypercall.c | 22 +++++++++++++++++++++- xen/include/public/platform.h | 3 ++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c index 872e6dc..87db3a5 100644 --- a/tools/libxc/xc_psr.c +++ b/tools/libxc/xc_psr.c @@ -158,12 +158,12 @@ int xc_psr_cmt_get_data(xc_interface *xch, uint32_t rmid, entries[0].u.cmd = XEN_RESOURCE_OP_MSR_WRITE; entries[0].idx = MSR_IA32_CMT_EVTSEL; entries[0].val = (uint64_t)rmid << 32 | evtid; - entries[0].rsvd = 0; + entries[0].flags = 0; entries[1].u.cmd = XEN_RESOURCE_OP_MSR_READ; entries[1].idx = MSR_IA32_CMT_CTR; entries[1].val = 0; - entries[1].rsvd = 0; + entries[1].flags = 0; op.cpu = cpu; op.nr_entries = 2; diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hypercall.c index 32f39b2..df99bad 100644 --- a/xen/arch/x86/platform_hypercall.c +++ b/xen/arch/x86/platform_hypercall.c @@ -90,7 +90,9 @@ static void check_resource_access(struct xen_resource_access *ra) int ret = 0; xenpf_resource_entry_t *entry = ra->entries + i; - if ( entry->rsvd ) + /* DISABLE_IRQ flag should never be set for the last entry */ + if ( entry->flags & XEN_RESOURCE_ENTRY_FLAGS_DISABLE_IRQ && + i == ra->nr_entries - 1 ) { entry->u.ret = -EINVAL; break; @@ -124,11 +126,19 @@ static void resource_access(void *info) { struct xen_resource_access *ra = info; unsigned int i; + unsigned long irqflags = 0; + bool_t irq_disabled = 0; for ( i = 0; i < ra->nr_done; i++ ) { int ret; xenpf_resource_entry_t *entry = ra->entries + i; + if ( !irq_disabled && + entry->flags & XEN_RESOURCE_ENTRY_FLAGS_DISABLE_IRQ ) + { + irq_disabled = 1; + local_irq_save(irqflags); + } switch ( entry->u.cmd ) { @@ -143,6 +153,13 @@ static void resource_access(void *info) break; } + if ( irq_disabled && + !(entry->flags & XEN_RESOURCE_ENTRY_FLAGS_DISABLE_IRQ) ) + { + local_irq_restore(irqflags); + irq_disabled = 0; + } + if ( ret ) { entry->u.ret = ret; @@ -150,6 +167,9 @@ static void resource_access(void *info) } } + if ( irq_disabled ) + local_irq_restore(irqflags); + ra->nr_done = i; } diff --git a/xen/include/public/platform.h b/xen/include/public/platform.h index 5c57615..ef30ac2 100644 --- a/xen/include/public/platform.h +++ b/xen/include/public/platform.h @@ -545,7 +545,8 @@ struct xenpf_resource_entry { uint32_t cmd; /* IN: XEN_RESOURCE_OP_* */ int32_t ret; /* OUT: return value for failed entry */ } u; - uint32_t rsvd; /* IN: padding and must be zero */ +#define XEN_RESOURCE_ENTRY_FLAGS_DISABLE_IRQ 1 + uint32_t flags; /* IN: XEN_RESOURCE_ENTRY_FLAGS_* */ uint64_t idx; /* IN: resource address to access */ uint64_t val; /* IN/OUT: resource value to set/get */ }; -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |