[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC PATCH V2 6/8] xen: introduce xen_event_channel_register_3level
Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- drivers/xen/events.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/drivers/xen/events.c b/drivers/xen/events.c index 5b45441..cbb10ed 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c @@ -2178,6 +2178,77 @@ static struct evtchn_ops evtchn_ops_l3 __read_mostly = { .debug_interrupt = debug_interrupt_l3, }; +static int xen_event_channel_register_3level(void) +{ + evtchn_register_nlevel_t reg; + evtchn_register_3level_t l3; + int i, nr_pages, cpu; + unsigned long *_evtchn_pending = NULL; + unsigned long *_evtchn_mask = NULL; + unsigned long *l2sel_mfns = NULL; + unsigned long *l2sel_offsets = NULL; + int rc; + + /* 1 page for 32 bit and 8 pages for 64 bit */ + nr_pages = (sizeof(unsigned long) == 4 ? 1 : 8); + + rc = -ENOMEM; +#define __ALLOC_ARRAY(_ptr, _nr) \ + do { \ + (_ptr) = kzalloc(sizeof(unsigned long) * (_nr), \ + GFP_KERNEL); \ + if (!(_ptr)) \ + goto out; \ + } while (0) + + __ALLOC_ARRAY(_evtchn_pending, nr_pages); + __ALLOC_ARRAY(_evtchn_mask, nr_pages); + __ALLOC_ARRAY(l2sel_mfns, nr_cpu_ids); + __ALLOC_ARRAY(l2sel_offsets, nr_cpu_ids); +#undef __ALLOC_ARRAY + + memset(®, 0, sizeof(reg)); + memset(&l3, 0, sizeof(l3)); + + for (i = 0; i < nr_pages; i++) { + unsigned long offset = PAGE_SIZE * i; + _evtchn_pending[i] = + arbitrary_virt_to_mfn( + (void *)((unsigned long)evtchn_pending+offset)); + _evtchn_mask[i] = + arbitrary_virt_to_mfn( + (void *)((unsigned long)evtchn_mask+offset)); + } + + for_each_possible_cpu(cpu) { + l2sel_mfns[cpu] = + arbitrary_virt_to_mfn(&per_cpu(evtchn_sel_l2, cpu)); + l2sel_offsets[cpu] = + offset_in_page(&per_cpu(evtchn_sel_l2, cpu)); + } + + l3.nr_pages = nr_pages; + l3.evtchn_pending = _evtchn_pending; + l3.evtchn_mask = _evtchn_mask; + + l3.nr_vcpus = nr_cpu_ids; + l3.l2sel_mfns = l2sel_mfns; + l3.l2sel_offsets = l2sel_offsets; + + reg.level = 3; + reg.u.l3 = &l3; + + rc = HYPERVISOR_event_channel_op(EVTCHNOP_register_nlevel, ®); + +out: + kfree(_evtchn_pending); + kfree(_evtchn_mask); + kfree(l2sel_mfns); + kfree(l2sel_offsets); + + return rc; +} + void __init xen_init_IRQ(void) { int i, rc; -- 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 |