[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC PATCH V5 11/15] evtchn: use pointers to reference evtchn_pending/mask
This allows better code sharing between 2/3-level event channel ABIs. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- xen/arch/arm/domain.c | 1 + xen/arch/x86/domain.c | 1 + xen/common/event_channel.c | 6 ++++++ xen/common/evtchn_bitmap_abi.c | 14 +++++++------- xen/include/xen/event.h | 3 +++ xen/include/xen/sched.h | 2 ++ 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index bca3d89..f6a5560 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -471,6 +471,7 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags) d->arch.vmpidr = boot_cpu_data.mpidr.bits; clear_page(d->shared_info); + evtchn_set_default_bitmap(d); share_xen_page_with_guest( virt_to_page(d->shared_info), d, XENSHARE_writable); diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 8d30d08..d7912b3 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -547,6 +547,7 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags) goto fail; clear_page(d->shared_info); + evtchn_set_default_bitmap(d); share_xen_page_with_guest( virt_to_page(d->shared_info), d, XENSHARE_writable); diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 4d02fc7..152b77a 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -1177,6 +1177,12 @@ void evtchn_set_abi(struct domain *d, uint64_t abi) } } +void evtchn_set_default_bitmap(struct domain *d) +{ + d->evtchn_pending = (xen_ulong_t *)shared_info(d, evtchn_pending); + d->evtchn_mask = (xen_ulong_t *)shared_info(d, evtchn_mask); +} + int evtchn_init(struct domain *d) { spin_lock_init(&d->event_lock); diff --git a/xen/common/evtchn_bitmap_abi.c b/xen/common/evtchn_bitmap_abi.c index 0d747bc..180a4bc 100644 --- a/xen/common/evtchn_bitmap_abi.c +++ b/xen/common/evtchn_bitmap_abi.c @@ -24,12 +24,12 @@ int evtchn_bitmap_is_pending(struct domain *d, int port) { - return test_bit(port, &shared_info(d, evtchn_pending)); + return test_bit(port, d->evtchn_pending); } int evtchn_bitmap_is_masked(struct domain *d, int port) { - return test_bit(port, &shared_info(d, evtchn_mask)); + return test_bit(port, d->evtchn_mask); } void evtchn_bitmap_set_pending(struct vcpu *v, int port) @@ -44,10 +44,10 @@ void evtchn_bitmap_set_pending(struct vcpu *v, int port) * others may require explicit memory barriers. */ - if ( test_and_set_bit(port, &shared_info(d, evtchn_pending)) ) + if ( test_and_set_bit(port, d->evtchn_pending) ) return; - if ( !test_bit (port, &shared_info(d, evtchn_mask)) && + if ( !test_bit (port, d->evtchn_mask) && !test_and_set_bit(port / BITS_PER_EVTCHN_WORD(d), &vcpu_info(v, evtchn_pending_sel)) ) { @@ -75,7 +75,7 @@ void evtchn_bitmap_set_pending(struct vcpu *v, int port) void evtchn_bitmap_clear_pending(struct domain *d, int port) { - clear_bit(port, &shared_info(d, evtchn_pending)); + clear_bit(port, d->evtchn_pending); } int evtchn_bitmap_unmask(unsigned int port) @@ -94,8 +94,8 @@ int evtchn_bitmap_unmask(unsigned int port) * These operations must happen in strict order. Based on * include/xen/event.h:evtchn_set_pending(). */ - if ( test_and_clear_bit(port, &shared_info(d, evtchn_mask)) && - test_bit (port, &shared_info(d, evtchn_pending)) && + if ( test_and_clear_bit(port, d->evtchn_mask) && + test_bit (port, d->evtchn_pending) && !test_and_set_bit (port / BITS_PER_EVTCHN_WORD(d), &vcpu_info(v, evtchn_pending_sel)) ) { diff --git a/xen/include/xen/event.h b/xen/include/xen/event.h index 9531029..2387461 100644 --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -135,6 +135,9 @@ void notify_via_xen_event_channel(struct domain *ld, int lport); mb(); /* set blocked status /then/ caller does his work */ \ } while ( 0 ) +/* This is called after domain's shared info page is setup */ +void evtchn_set_default_bitmap(struct domain *d); + /* 2-level ABI routines */ int evtchn_bitmap_is_pending(struct domain *d, int port); int evtchn_bitmap_is_masked(struct domain *d, int port); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 6bf96bd..71eebb6 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -270,6 +270,8 @@ struct domain struct evtchn **evtchn[NR_EVTCHN_GROUPS]; const struct evtchn_port_ops *evtchn_ops; spinlock_t event_lock; + xen_ulong_t *evtchn_pending; + xen_ulong_t *evtchn_mask; unsigned int max_evtchns; unsigned int evtchn_extended; -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |