This was a short term hack to get something linking quickly, but its usefulness has now passed. This series replaces everything in here with proper functions. In many cases these are still just stubs. It seems to me that at least some of this stuff consists of x86-isms which should instead be removed from the common code. This highlights two large missing pieces of functionality: wallclock time and cleaning up on domain destroy. Ian.
For now just initialise it as a single online node, which is what asm-arm/numa.h assumes anyway. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/dummy.S | 1 - xen/arch/arm/smpboot.c | 3 +++ xen/include/asm-arm/numa.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S index 022338a..4abb30a 100644 --- a/xen/arch/arm/dummy.S +++ b/xen/arch/arm/dummy.S @@ -7,7 +7,6 @@ x: .word 0xe7f000f0 /* Undefined instruction */ x: mov pc, lr /* SMP support */ -DUMMY(node_online_map); DUMMY(smp_send_state_dump); /* PIRQ support */ diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index 6555ac6..351b559 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -38,6 +38,9 @@ EXPORT_SYMBOL(cpu_online_map); cpumask_t cpu_possible_map; EXPORT_SYMBOL(cpu_possible_map); +/* Fake one node for now. See also include/asm-arm/numa.h */ +nodemask_t __read_mostly node_online_map = { { [0] = 1UL } }; + /* Xen stack for bringing up the first CPU. */ static unsigned char __initdata cpu0_boot_stack[STACK_SIZE] __attribute__((__aligned__(STACK_SIZE))); diff --git a/xen/include/asm-arm/numa.h b/xen/include/asm-arm/numa.h index 1b060e6..a1b1f58 100644 --- a/xen/include/asm-arm/numa.h +++ b/xen/include/asm-arm/numa.h @@ -1,7 +1,7 @@ #ifndef __ARCH_ARM_NUMA_H #define __ARCH_ARM_NUMA_H -/* Fake one node for now... */ +/* Fake one node for now. See also node_online_map. */ #define cpu_to_node(cpu) 0 #define node_to_cpumask(node) (cpu_online_map) -- 1.7.9.1
Ian Campbell
2012-Dec-04 11:56 UTC
[PATCH 02/15] xen: arm: make smp_send_state_dump a real function
It still doesn''t do anything useful, but at least it isn''t in dummy.S! Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/dummy.S | 3 --- xen/arch/arm/gic.c | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S index 4abb30a..bfd948a 100644 --- a/xen/arch/arm/dummy.S +++ b/xen/arch/arm/dummy.S @@ -6,9 +6,6 @@ x: .word 0xe7f000f0 /* Undefined instruction */ .globl x; \ x: mov pc, lr -/* SMP support */ -DUMMY(smp_send_state_dump); - /* PIRQ support */ DUMMY(alloc_pirq_struct); DUMMY(nr_irqs_gsi); diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 0c6fab9..416e8d8 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -330,6 +330,12 @@ void __init gic_init(void) spin_unlock(&gic.lock); } +void smp_send_state_dump(unsigned int cpu) +{ + printk("WARNING: unable to send state dump request to CPU%d\n", cpu); + /* XXX TODO -- send an SGI */ +} + /* Set up the per-CPU parts of the GIC for a secondary CPU */ void __cpuinit gic_init_secondary_cpu(void) { -- 1.7.9.1
Untested, but basically the inverse of arch_set_info_guest. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/domctl.c | 17 +++++++++++++++++ xen/arch/arm/dummy.S | 1 - 2 files changed, 17 insertions(+), 1 deletions(-) diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index cf16791..76f31ce 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -8,6 +8,7 @@ #include <xen/types.h> #include <xen/lib.h> #include <xen/errno.h> +#include <xen/sched.h> #include <public/domctl.h> long arch_do_domctl(struct xen_domctl *domctl, @@ -16,6 +17,22 @@ long arch_do_domctl(struct xen_domctl *domctl, return -ENOSYS; } +void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c) +{ + struct vcpu_guest_context *ctxt = c.nat; + struct cpu_user_regs *regs = &c.nat->user_regs; + + *regs = v->arch.cpu_info->guest_cpu_user_regs; + + ctxt->sctlr = v->arch.sctlr; + ctxt->ttbr0 = v->arch.ttbr0; + ctxt->ttbr1 = v->arch.ttbr1; + ctxt->ttbcr = v->arch.ttbcr; + + if ( !test_bit(_VPF_down, &v->pause_flags) ) + ctxt->flags |= VGCF_online; +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S index bfd948a..5ac6af9 100644 --- a/xen/arch/arm/dummy.S +++ b/xen/arch/arm/dummy.S @@ -14,7 +14,6 @@ DUMMY(pirq_guest_unbind); DUMMY(pirq_set_affinity); /* VCPU */ -DUMMY(arch_get_info_guest); DUMMY(arch_vcpu_reset); NOP(update_vcpu_system_time); -- 1.7.9.1
Untested. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/domain.c | 5 +++++ xen/arch/arm/dummy.S | 1 - 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index c5292c7..b7b2d5c 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -515,6 +515,11 @@ int arch_set_info_guest( return 0; } +void arch_vcpu_reset(struct vcpu *v) +{ + vcpu_end_shutdown_deferral(v); +} + void arch_dump_domain_info(struct domain *d) { } diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S index 5ac6af9..66eb314 100644 --- a/xen/arch/arm/dummy.S +++ b/xen/arch/arm/dummy.S @@ -14,7 +14,6 @@ DUMMY(pirq_guest_unbind); DUMMY(pirq_set_affinity); /* VCPU */ -DUMMY(arch_vcpu_reset); NOP(update_vcpu_system_time); /* Grant Tables */ -- 1.7.9.1
Ian Campbell
2012-Dec-04 11:56 UTC
[PATCH 05/15] xen: remove nr_irqs_gsi from generic code
The concept is X86 specific. AFAICT the generic concept here is the number of physical IRQs which the current hardware has, so call this nr_hw_irqs. Also using "defined NR_IRQS" as a standin for x86 might have made sense at one point but its just cleaner to push the necessary definitions into asm/irq.h. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Cc: Keir (Xen.org) <keir@xen.org> Cc: Jan Beulich <JBeulich@suse.com> Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov> --- xen/arch/arm/dummy.S | 1 - xen/common/domain.c | 4 ++-- xen/include/asm-arm/irq.h | 3 +++ xen/include/asm-x86/irq.h | 4 ++++ xen/include/xen/irq.h | 8 -------- xen/xsm/flask/hooks.c | 4 ++-- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S index 66eb314..5d9bcff 100644 --- a/xen/arch/arm/dummy.S +++ b/xen/arch/arm/dummy.S @@ -8,7 +8,6 @@ x: mov pc, lr /* PIRQ support */ DUMMY(alloc_pirq_struct); -DUMMY(nr_irqs_gsi); DUMMY(pirq_guest_bind); DUMMY(pirq_guest_unbind); DUMMY(pirq_set_affinity); diff --git a/xen/common/domain.c b/xen/common/domain.c index 12c8e24..d80461d 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -259,9 +259,9 @@ struct domain *domain_create( atomic_inc(&d->pause_count); if ( domid ) - d->nr_pirqs = nr_irqs_gsi + extra_domU_irqs; + d->nr_pirqs = nr_hw_irqs + extra_domU_irqs; else - d->nr_pirqs = nr_irqs_gsi + extra_dom0_irqs; + d->nr_pirqs = nr_hw_irqs + extra_dom0_irqs; if ( d->nr_pirqs > nr_irqs ) d->nr_pirqs = nr_irqs; diff --git a/xen/include/asm-arm/irq.h b/xen/include/asm-arm/irq.h index abde839..4facaf0 100644 --- a/xen/include/asm-arm/irq.h +++ b/xen/include/asm-arm/irq.h @@ -21,6 +21,9 @@ struct irq_cfg { #define NR_IRQS 1024 #define nr_irqs NR_IRQS +#define nr_irqs NR_IRQS +#define nr_hw_irqs NR_IRQS + struct irq_desc; struct irq_desc *__irq_to_desc(int irq); diff --git a/xen/include/asm-x86/irq.h b/xen/include/asm-x86/irq.h index 5eefb94..6ea5f53 100644 --- a/xen/include/asm-x86/irq.h +++ b/xen/include/asm-x86/irq.h @@ -11,6 +11,10 @@ #include <irq_vectors.h> #include <asm/percpu.h> +extern unsigned int nr_irqs_gsi; +extern unsigned int nr_irqs; +#define nr_hw_irqs nr_irqs_gsi + #define IO_APIC_IRQ(irq) (platform_legacy_irq(irq) ? \ (1 << (irq)) & io_apic_irqs : \ (irq) < nr_irqs_gsi) diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h index 5973cce..7386358 100644 --- a/xen/include/xen/irq.h +++ b/xen/include/xen/irq.h @@ -58,14 +58,6 @@ typedef const struct hw_interrupt_type hw_irq_controller; #include <asm/irq.h> -#ifdef NR_IRQS -# define nr_irqs NR_IRQS -# define nr_irqs_gsi NR_IRQS -#else -extern unsigned int nr_irqs_gsi; -extern unsigned int nr_irqs; -#endif - struct msi_desc; /* * This is the "IRQ descriptor", which contains various information diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index 0ca10d0..595c31e 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -72,7 +72,7 @@ static int get_irq_sid(int irq, u32 *sid, struct avc_audit_data *ad) struct irq_desc *desc = irq_to_desc(irq); if ( irq >= nr_irqs || irq < 0 ) return -EINVAL; - if ( irq < nr_irqs_gsi ) { + if ( irq < nr_hw_irqs ) { if (ad) { AVC_AUDIT_DATA_INIT(ad, IRQ); ad->irq = irq; @@ -699,7 +699,7 @@ static int flask_map_domain_pirq (struct domain *d, int irq, void *data) if ( rc ) return rc; - if ( irq >= nr_irqs_gsi && msi ) { + if ( irq >= nr_hw_irqs && msi ) { u32 machine_bdf = (msi->seg << 16) | (msi->bus << 8) | msi->devfn; AVC_AUDIT_DATA_INIT(&ad, DEV); ad.device = machine_bdf; -- 1.7.9.1
Ian Campbell
2012-Dec-04 11:56 UTC
[PATCH 06/15] xen: arm: stub out pirq related functions.
On ARM we use GIC functionality to inject virtualised real interrupts for h/w devices rather than evtchn-pirqs. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/dummy.S | 6 ------ xen/arch/arm/irq.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S index 5d9bcff..2110bf1 100644 --- a/xen/arch/arm/dummy.S +++ b/xen/arch/arm/dummy.S @@ -6,12 +6,6 @@ x: .word 0xe7f000f0 /* Undefined instruction */ .globl x; \ x: mov pc, lr -/* PIRQ support */ -DUMMY(alloc_pirq_struct); -DUMMY(pirq_guest_bind); -DUMMY(pirq_guest_unbind); -DUMMY(pirq_set_affinity); - /* VCPU */ NOP(update_vcpu_system_time); diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c index 72e83e6..a50281b 100644 --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -192,6 +192,35 @@ out_no_end: } /* + * pirq event channels. We don''t use these on ARM, instead we use the + * features of the GIC to inject virtualised normal interrupts. + */ +struct pirq *alloc_pirq_struct(struct domain *d) +{ + return NULL; +} + +/* + * These are all unreachable given an alloc_pirq_struct + * which returns NULL, all callers try to lookup struct pirq first + * which will fail. + */ +int pirq_guest_bind(struct vcpu *v, struct pirq *pirq, int will_share) +{ + BUG(); +} + +void pirq_guest_unbind(struct domain *d, struct pirq *pirq) +{ + BUG(); +} + +void pirq_set_affinity(struct domain *d, int pirq, const cpumask_t *mask) +{ + BUG(); +} + +/* * Local variables: * mode: C * c-set-style: "BSD" -- 1.7.9.1
We don''t currently have much concept of wallclock time on ARM (for either the hypervisor, dom0 or guests). For now just stub everything out. Specifically domain_set_time_offset, update_vcpu_system_time and wallclock_time. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/dummy.S | 5 ----- xen/arch/arm/time.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S index 2110bf1..87159da 100644 --- a/xen/arch/arm/dummy.S +++ b/xen/arch/arm/dummy.S @@ -6,9 +6,6 @@ x: .word 0xe7f000f0 /* Undefined instruction */ .globl x; \ x: mov pc, lr -/* VCPU */ -NOP(update_vcpu_system_time); - /* Grant Tables */ DUMMY(steal_page); @@ -18,8 +15,6 @@ DUMMY(page_is_ram_type); /* Other */ DUMMY(domain_get_maximum_gpfn); DUMMY(domain_relinquish_resources); -DUMMY(domain_set_time_offset); DUMMY(dom_cow); DUMMY(send_timer_event); DUMMY(share_xen_page_with_privileged_guests); -DUMMY(wallclock_time); diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c index b6d7015..ac606f7 100644 --- a/xen/arch/arm/time.c +++ b/xen/arch/arm/time.c @@ -25,6 +25,7 @@ #include <xen/mm.h> #include <xen/softirq.h> #include <xen/time.h> +#include <xen/sched.h> #include <asm/system.h> /* @@ -185,6 +186,23 @@ void udelay(unsigned long usecs) isb(); } +/* VCPU PV clock. */ +void update_vcpu_system_time(struct vcpu *v) +{ + /* XXX update shared_info->wc_* */ +} + +void domain_set_time_offset(struct domain *d, int32_t time_offset_seconds) +{ + d->time_offset_seconds = time_offset_seconds; + /* XXX update guest visible wallclock time */ +} + +struct tm wallclock_time(void) +{ + return (struct tm) { 0 }; +} + /* * Local variables: * mode: C -- 1.7.9.1
Callers handle the failure gracefully, can be called by GNTTABOP_transfer, XENMEM_exchange or tmem. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/dummy.S | 3 --- xen/arch/arm/mm.c | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S index 87159da..f5b0db7 100644 --- a/xen/arch/arm/dummy.S +++ b/xen/arch/arm/dummy.S @@ -6,9 +6,6 @@ x: .word 0xe7f000f0 /* Undefined instruction */ .globl x; \ x: mov pc, lr -/* Grant Tables */ -DUMMY(steal_page); - /* Page Offlining */ DUMMY(page_is_ram_type); diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 855f83d..687eb55 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -435,6 +435,12 @@ int donate_page(struct domain *d, struct page_info *page, unsigned int memflags) return -ENOSYS; } +int steal_page( + struct domain *d, struct page_info *page, unsigned int memflags) +{ + return -1; +} + void share_xen_page_with_guest(struct page_info *page, struct domain *d, int readonly) { -- 1.7.9.1
Callers are VT-d (so x86 specific) and various bits of page offlining support, which although it looks generic (and is in xen/common) does things like diving into page_info->count_info which is not generic. In any case on this is only reachable via XEN_SYSCTL_page_offline_op, which clearly shouldn''t be called on ARM just yet. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/dummy.S | 3 --- xen/arch/arm/mm.c | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S index f5b0db7..7e6f171 100644 --- a/xen/arch/arm/dummy.S +++ b/xen/arch/arm/dummy.S @@ -5,9 +5,6 @@ x: .word 0xe7f000f0 /* Undefined instruction */ #define NOP(x) \ .globl x; \ x: mov pc, lr - -/* Page Offlining */ -DUMMY(page_is_ram_type); /* Other */ DUMMY(domain_get_maximum_gpfn); diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 687eb55..329b1d4 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -441,6 +441,12 @@ int steal_page( return -1; } +int page_is_ram_type(unsigned long mfn, unsigned long mem_type) +{ + ASSERT(0); + return 0; +} + void share_xen_page_with_guest(struct page_info *page, struct domain *d, int readonly) { -- 1.7.9.1
Ian Campbell
2012-Dec-04 11:56 UTC
[PATCH 10/15] xen: arm: stub out domain_get_maximum_gpfn
It currently has no callers, so return ENOSYS until such a time as one arrives. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/dummy.S | 1 - xen/arch/arm/mm.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S index 7e6f171..fd667e5 100644 --- a/xen/arch/arm/dummy.S +++ b/xen/arch/arm/dummy.S @@ -7,7 +7,6 @@ x: .word 0xe7f000f0 /* Undefined instruction */ x: mov pc, lr /* Other */ -DUMMY(domain_get_maximum_gpfn); DUMMY(domain_relinquish_resources); DUMMY(dom_cow); DUMMY(send_timer_event); diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 329b1d4..718f32d 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -447,6 +447,11 @@ int page_is_ram_type(unsigned long mfn, unsigned long mem_type) return 0; } +unsigned long domain_get_maximum_gpfn(struct domain *d) +{ + return -ENOSYS; +} + void share_xen_page_with_guest(struct page_info *page, struct domain *d, int readonly) { -- 1.7.9.1
Ian Campbell
2012-Dec-04 11:56 UTC
[PATCH 11/15] xen: arm: stub domain_relinquish_resources.
Currently unimplemented. Domain teardown in general needs looking at. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/domain.c | 7 +++++++ xen/arch/arm/dummy.S | 1 - 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index b7b2d5c..7bbad45 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -520,6 +520,13 @@ void arch_vcpu_reset(struct vcpu *v) vcpu_end_shutdown_deferral(v); } +int domain_relinquish_resources(struct domain *d) +{ + /* XXX teardown pagetables, free pages etc */ + ASSERT(0); + return 0; +} + void arch_dump_domain_info(struct domain *d) { } diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S index fd667e5..7189648 100644 --- a/xen/arch/arm/dummy.S +++ b/xen/arch/arm/dummy.S @@ -7,7 +7,6 @@ x: .word 0xe7f000f0 /* Undefined instruction */ x: mov pc, lr /* Other */ -DUMMY(domain_relinquish_resources); DUMMY(dom_cow); DUMMY(send_timer_event); DUMMY(share_xen_page_with_privileged_guests); -- 1.7.9.1
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/dummy.S | 1 - xen/arch/arm/mm.c | 28 +++++++++++++++++++++++++++- xen/arch/arm/setup.c | 2 ++ xen/include/asm-arm/setup.h | 2 ++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S index 7189648..3fe4ba6 100644 --- a/xen/arch/arm/dummy.S +++ b/xen/arch/arm/dummy.S @@ -7,6 +7,5 @@ x: .word 0xe7f000f0 /* Undefined instruction */ x: mov pc, lr /* Other */ -DUMMY(dom_cow); DUMMY(send_timer_event); DUMMY(share_xen_page_with_privileged_guests); diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 718f32d..d9c1ff7 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -30,12 +30,13 @@ #include <xen/event.h> #include <xen/guest_access.h> #include <xen/domain_page.h> +#include <xen/err.h> #include <asm/page.h> #include <asm/current.h> #include <public/memory.h> #include <xen/sched.h> -struct domain *dom_xen, *dom_io; +struct domain *dom_xen, *dom_io, *dom_cow; /* Static start-of-day pagetables that we use before the allocators are up */ lpae_t xen_pgtable[LPAE_ENTRIES] __attribute__((__aligned__(4096))); @@ -206,6 +207,31 @@ void unmap_domain_page(const void *va) local_irq_restore(flags); } +void __init arch_init_memory(void) +{ + /* + * Initialise our DOMID_XEN domain. + * Any Xen-heap pages that we will allow to be mapped will have + * their domain field set to dom_xen. + */ + dom_xen = domain_create(DOMID_XEN, DOMCRF_dummy, 0); + BUG_ON(IS_ERR(dom_xen)); + + /* + * Initialise our DOMID_IO domain. + * This domain owns I/O pages that are within the range of the page_info + * array. Mappings occur at the priv of the caller. + */ + dom_io = domain_create(DOMID_IO, DOMCRF_dummy, 0); + BUG_ON(IS_ERR(dom_io)); + + /* + * Initialise our COW domain. + * This domain owns sharable pages. + */ + dom_cow = domain_create(DOMID_COW, DOMCRF_dummy, 0); + BUG_ON(IS_ERR(dom_cow)); +} /* Boot-time pagetable setup. * Changes here may need matching changes in head.S */ diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 2076724..61bf47c 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -265,6 +265,8 @@ void __init start_xen(unsigned long boot_phys_offset, rcu_init(); + arch_init_memory(); + local_irq_enable(); smp_prepare_cpus(cpus); diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h index 8769f66..5c84334 100644 --- a/xen/include/asm-arm/setup.h +++ b/xen/include/asm-arm/setup.h @@ -3,6 +3,8 @@ #include <public/version.h> +void arch_init_memory(void); + void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len, int attrindx); void arch_get_xen_caps(xen_capabilities_info_t *info); -- 1.7.9.1
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/dummy.S | 1 - xen/arch/arm/time.c | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S index 3fe4ba6..6d4b34f 100644 --- a/xen/arch/arm/dummy.S +++ b/xen/arch/arm/dummy.S @@ -7,5 +7,4 @@ x: .word 0xe7f000f0 /* Undefined instruction */ x: mov pc, lr /* Other */ -DUMMY(send_timer_event); DUMMY(share_xen_page_with_privileged_guests); diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c index ac606f7..0f9335e 100644 --- a/xen/arch/arm/time.c +++ b/xen/arch/arm/time.c @@ -26,6 +26,7 @@ #include <xen/softirq.h> #include <xen/time.h> #include <xen/sched.h> +#include <xen/event.h> #include <asm/system.h> /* @@ -186,6 +187,12 @@ void udelay(unsigned long usecs) isb(); } +/* VCPU PV timers. */ +void send_timer_event(struct vcpu *v) +{ + send_guest_vcpu_virq(v, VIRQ_TIMER); +} + /* VCPU PV clock. */ void update_vcpu_system_time(struct vcpu *v) { -- 1.7.9.1
Ian Campbell
2012-Dec-04 11:56 UTC
[PATCH 14/15] xen: arm: implement share_xen_page_with_privileged_guests
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/dummy.S | 3 --- xen/arch/arm/mm.c | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S index 6d4b34f..a48ec08 100644 --- a/xen/arch/arm/dummy.S +++ b/xen/arch/arm/dummy.S @@ -5,6 +5,3 @@ x: .word 0xe7f000f0 /* Undefined instruction */ #define NOP(x) \ .globl x; \ x: mov pc, lr - -/* Other */ -DUMMY(share_xen_page_with_privileged_guests); diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index d9c1ff7..d97b3ea 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -506,6 +506,12 @@ void share_xen_page_with_guest(struct page_info *page, spin_unlock(&d->page_alloc_lock); } +void share_xen_page_with_privileged_guests( + struct page_info *page, int readonly) +{ + share_xen_page_with_guest(page, dom_xen, readonly); +} + static int xenmem_add_to_physmap_one( struct domain *d, uint16_t space, -- 1.7.9.1
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/Makefile | 1 - xen/arch/arm/dummy.S | 7 ------- 2 files changed, 0 insertions(+), 8 deletions(-) delete mode 100644 xen/arch/arm/dummy.S diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index fd92b72..5867fff 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -1,6 +1,5 @@ subdir-y += lib -obj-y += dummy.o obj-y += early_printk.o obj-y += entry.o obj-y += domain.o diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S deleted file mode 100644 index a48ec08..0000000 --- a/xen/arch/arm/dummy.S +++ /dev/null @@ -1,7 +0,0 @@ -#define DUMMY(x) \ - .globl x; \ -x: .word 0xe7f000f0 /* Undefined instruction */ - -#define NOP(x) \ - .globl x; \ -x: mov pc, lr -- 1.7.9.1
Jan Beulich
2012-Dec-04 13:43 UTC
Re: [PATCH 05/15] xen: remove nr_irqs_gsi from generic code
>>> On 04.12.12 at 12:56, Ian Campbell <ian.campbell@citrix.com> wrote: > The concept is X86 specific. > > AFAICT the generic concept here is the number of physical IRQs which > the current hardware has, so call this nr_hw_irqs.Hmm, I don''t particularly like this name, as (at least to me) it gives the appearance to include MSI ones, which isn''t correct. How about nr_fixed_irqs or nr_static_irqs or some such? Jan> Also using "defined NR_IRQS" as a standin for x86 might have made > sense at one point but its just cleaner to push the necessary > definitions into asm/irq.h. > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com> > Cc: Keir (Xen.org) <keir@xen.org> > Cc: Jan Beulich <JBeulich@suse.com> > Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov> > --- > xen/arch/arm/dummy.S | 1 - > xen/common/domain.c | 4 ++-- > xen/include/asm-arm/irq.h | 3 +++ > xen/include/asm-x86/irq.h | 4 ++++ > xen/include/xen/irq.h | 8 -------- > xen/xsm/flask/hooks.c | 4 ++-- > 6 files changed, 11 insertions(+), 13 deletions(-) > > diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S > index 66eb314..5d9bcff 100644 > --- a/xen/arch/arm/dummy.S > +++ b/xen/arch/arm/dummy.S > @@ -8,7 +8,6 @@ x: mov pc, lr > > /* PIRQ support */ > DUMMY(alloc_pirq_struct); > -DUMMY(nr_irqs_gsi); > DUMMY(pirq_guest_bind); > DUMMY(pirq_guest_unbind); > DUMMY(pirq_set_affinity); > diff --git a/xen/common/domain.c b/xen/common/domain.c > index 12c8e24..d80461d 100644 > --- a/xen/common/domain.c > +++ b/xen/common/domain.c > @@ -259,9 +259,9 @@ struct domain *domain_create( > atomic_inc(&d->pause_count); > > if ( domid ) > - d->nr_pirqs = nr_irqs_gsi + extra_domU_irqs; > + d->nr_pirqs = nr_hw_irqs + extra_domU_irqs; > else > - d->nr_pirqs = nr_irqs_gsi + extra_dom0_irqs; > + d->nr_pirqs = nr_hw_irqs + extra_dom0_irqs; > if ( d->nr_pirqs > nr_irqs ) > d->nr_pirqs = nr_irqs; > > diff --git a/xen/include/asm-arm/irq.h b/xen/include/asm-arm/irq.h > index abde839..4facaf0 100644 > --- a/xen/include/asm-arm/irq.h > +++ b/xen/include/asm-arm/irq.h > @@ -21,6 +21,9 @@ struct irq_cfg { > #define NR_IRQS 1024 > #define nr_irqs NR_IRQS > > +#define nr_irqs NR_IRQS > +#define nr_hw_irqs NR_IRQS > + > struct irq_desc; > > struct irq_desc *__irq_to_desc(int irq); > diff --git a/xen/include/asm-x86/irq.h b/xen/include/asm-x86/irq.h > index 5eefb94..6ea5f53 100644 > --- a/xen/include/asm-x86/irq.h > +++ b/xen/include/asm-x86/irq.h > @@ -11,6 +11,10 @@ > #include <irq_vectors.h> > #include <asm/percpu.h> > > +extern unsigned int nr_irqs_gsi; > +extern unsigned int nr_irqs; > +#define nr_hw_irqs nr_irqs_gsi > + > #define IO_APIC_IRQ(irq) (platform_legacy_irq(irq) ? \ > (1 << (irq)) & io_apic_irqs : \ > (irq) < nr_irqs_gsi) > diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h > index 5973cce..7386358 100644 > --- a/xen/include/xen/irq.h > +++ b/xen/include/xen/irq.h > @@ -58,14 +58,6 @@ typedef const struct hw_interrupt_type hw_irq_controller; > > #include <asm/irq.h> > > -#ifdef NR_IRQS > -# define nr_irqs NR_IRQS > -# define nr_irqs_gsi NR_IRQS > -#else > -extern unsigned int nr_irqs_gsi; > -extern unsigned int nr_irqs; > -#endif > - > struct msi_desc; > /* > * This is the "IRQ descriptor", which contains various information > diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c > index 0ca10d0..595c31e 100644 > --- a/xen/xsm/flask/hooks.c > +++ b/xen/xsm/flask/hooks.c > @@ -72,7 +72,7 @@ static int get_irq_sid(int irq, u32 *sid, struct > avc_audit_data *ad) > struct irq_desc *desc = irq_to_desc(irq); > if ( irq >= nr_irqs || irq < 0 ) > return -EINVAL; > - if ( irq < nr_irqs_gsi ) { > + if ( irq < nr_hw_irqs ) { > if (ad) { > AVC_AUDIT_DATA_INIT(ad, IRQ); > ad->irq = irq; > @@ -699,7 +699,7 @@ static int flask_map_domain_pirq (struct domain *d, int > irq, void *data) > if ( rc ) > return rc; > > - if ( irq >= nr_irqs_gsi && msi ) { > + if ( irq >= nr_hw_irqs && msi ) { > u32 machine_bdf = (msi->seg << 16) | (msi->bus << 8) | msi->devfn; > AVC_AUDIT_DATA_INIT(&ad, DEV); > ad.device = machine_bdf; > -- > 1.7.9.1
Ian Campbell
2012-Dec-04 13:49 UTC
Re: [PATCH 05/15] xen: remove nr_irqs_gsi from generic code
On Tue, 2012-12-04 at 13:43 +0000, Jan Beulich wrote:> >>> On 04.12.12 at 12:56, Ian Campbell <ian.campbell@citrix.com> wrote: > > The concept is X86 specific. > > > > AFAICT the generic concept here is the number of physical IRQs which > > the current hardware has, so call this nr_hw_irqs. > > Hmm, I don''t particularly like this name, as (at least to me) it > gives the appearance to include MSI ones, which isn''t correct.Ah, I wondered about this then forgot to mention it.> How about nr_fixed_irqs or nr_static_irqs or some such?Static would be a nice counter to "dynamic" which is how I tend to think of MSIs.> > Jan > > > Also using "defined NR_IRQS" as a standin for x86 might have made > > sense at one point but its just cleaner to push the necessary > > definitions into asm/irq.h. > > > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com> > > Cc: Keir (Xen.org) <keir@xen.org> > > Cc: Jan Beulich <JBeulich@suse.com> > > Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov> > > --- > > xen/arch/arm/dummy.S | 1 - > > xen/common/domain.c | 4 ++-- > > xen/include/asm-arm/irq.h | 3 +++ > > xen/include/asm-x86/irq.h | 4 ++++ > > xen/include/xen/irq.h | 8 -------- > > xen/xsm/flask/hooks.c | 4 ++-- > > 6 files changed, 11 insertions(+), 13 deletions(-) > > > > diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S > > index 66eb314..5d9bcff 100644 > > --- a/xen/arch/arm/dummy.S > > +++ b/xen/arch/arm/dummy.S > > @@ -8,7 +8,6 @@ x: mov pc, lr > > > > /* PIRQ support */ > > DUMMY(alloc_pirq_struct); > > -DUMMY(nr_irqs_gsi); > > DUMMY(pirq_guest_bind); > > DUMMY(pirq_guest_unbind); > > DUMMY(pirq_set_affinity); > > diff --git a/xen/common/domain.c b/xen/common/domain.c > > index 12c8e24..d80461d 100644 > > --- a/xen/common/domain.c > > +++ b/xen/common/domain.c > > @@ -259,9 +259,9 @@ struct domain *domain_create( > > atomic_inc(&d->pause_count); > > > > if ( domid ) > > - d->nr_pirqs = nr_irqs_gsi + extra_domU_irqs; > > + d->nr_pirqs = nr_hw_irqs + extra_domU_irqs; > > else > > - d->nr_pirqs = nr_irqs_gsi + extra_dom0_irqs; > > + d->nr_pirqs = nr_hw_irqs + extra_dom0_irqs; > > if ( d->nr_pirqs > nr_irqs ) > > d->nr_pirqs = nr_irqs; > > > > diff --git a/xen/include/asm-arm/irq.h b/xen/include/asm-arm/irq.h > > index abde839..4facaf0 100644 > > --- a/xen/include/asm-arm/irq.h > > +++ b/xen/include/asm-arm/irq.h > > @@ -21,6 +21,9 @@ struct irq_cfg { > > #define NR_IRQS 1024 > > #define nr_irqs NR_IRQS > > > > +#define nr_irqs NR_IRQS > > +#define nr_hw_irqs NR_IRQS > > + > > struct irq_desc; > > > > struct irq_desc *__irq_to_desc(int irq); > > diff --git a/xen/include/asm-x86/irq.h b/xen/include/asm-x86/irq.h > > index 5eefb94..6ea5f53 100644 > > --- a/xen/include/asm-x86/irq.h > > +++ b/xen/include/asm-x86/irq.h > > @@ -11,6 +11,10 @@ > > #include <irq_vectors.h> > > #include <asm/percpu.h> > > > > +extern unsigned int nr_irqs_gsi; > > +extern unsigned int nr_irqs; > > +#define nr_hw_irqs nr_irqs_gsi > > + > > #define IO_APIC_IRQ(irq) (platform_legacy_irq(irq) ? \ > > (1 << (irq)) & io_apic_irqs : \ > > (irq) < nr_irqs_gsi) > > diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h > > index 5973cce..7386358 100644 > > --- a/xen/include/xen/irq.h > > +++ b/xen/include/xen/irq.h > > @@ -58,14 +58,6 @@ typedef const struct hw_interrupt_type hw_irq_controller; > > > > #include <asm/irq.h> > > > > -#ifdef NR_IRQS > > -# define nr_irqs NR_IRQS > > -# define nr_irqs_gsi NR_IRQS > > -#else > > -extern unsigned int nr_irqs_gsi; > > -extern unsigned int nr_irqs; > > -#endif > > - > > struct msi_desc; > > /* > > * This is the "IRQ descriptor", which contains various information > > diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c > > index 0ca10d0..595c31e 100644 > > --- a/xen/xsm/flask/hooks.c > > +++ b/xen/xsm/flask/hooks.c > > @@ -72,7 +72,7 @@ static int get_irq_sid(int irq, u32 *sid, struct > > avc_audit_data *ad) > > struct irq_desc *desc = irq_to_desc(irq); > > if ( irq >= nr_irqs || irq < 0 ) > > return -EINVAL; > > - if ( irq < nr_irqs_gsi ) { > > + if ( irq < nr_hw_irqs ) { > > if (ad) { > > AVC_AUDIT_DATA_INIT(ad, IRQ); > > ad->irq = irq; > > @@ -699,7 +699,7 @@ static int flask_map_domain_pirq (struct domain *d, int > > irq, void *data) > > if ( rc ) > > return rc; > > > > - if ( irq >= nr_irqs_gsi && msi ) { > > + if ( irq >= nr_hw_irqs && msi ) { > > u32 machine_bdf = (msi->seg << 16) | (msi->bus << 8) | msi->devfn; > > AVC_AUDIT_DATA_INIT(&ad, DEV); > > ad.device = machine_bdf; > > -- > > 1.7.9.1 > >
David Vrabel
2012-Dec-04 14:17 UTC
Re: [PATCH 12/15] xen: arm: initialise dom_{xen, io, cow}
On 04/12/12 11:56, Ian Campbell wrote:> +void __init arch_init_memory(void) > +{ > + /* > + * Initialise our DOMID_XEN domain. > + * Any Xen-heap pages that we will allow to be mapped will have > + * their domain field set to dom_xen. > + */ > + dom_xen = domain_create(DOMID_XEN, DOMCRF_dummy, 0); > + BUG_ON(IS_ERR(dom_xen)); > + > + /* > + * Initialise our DOMID_IO domain. > + * This domain owns I/O pages that are within the range of the page_info > + * array. Mappings occur at the priv of the caller. > + */ > + dom_io = domain_create(DOMID_IO, DOMCRF_dummy, 0); > + BUG_ON(IS_ERR(dom_io)); > + > + /* > + * Initialise our COW domain. > + * This domain owns sharable pages. > + */ > + dom_cow = domain_create(DOMID_COW, DOMCRF_dummy, 0); > + BUG_ON(IS_ERR(dom_cow)); > +}This looks like a cut and paste from the x86 code. Should it be refactored into a common function? David
Ian Campbell
2012-Dec-04 14:21 UTC
Re: [PATCH 12/15] xen: arm: initialise dom_{xen, io, cow}
On Tue, 2012-12-04 at 14:17 +0000, David Vrabel wrote:> On 04/12/12 11:56, Ian Campbell wrote: > > +void __init arch_init_memory(void) > > +{ > > + /* > > + * Initialise our DOMID_XEN domain. > > + * Any Xen-heap pages that we will allow to be mapped will have > > + * their domain field set to dom_xen. > > + */ > > + dom_xen = domain_create(DOMID_XEN, DOMCRF_dummy, 0); > > + BUG_ON(IS_ERR(dom_xen)); > > + > > + /* > > + * Initialise our DOMID_IO domain. > > + * This domain owns I/O pages that are within the range of the page_info > > + * array. Mappings occur at the priv of the caller. > > + */ > > + dom_io = domain_create(DOMID_IO, DOMCRF_dummy, 0); > > + BUG_ON(IS_ERR(dom_io)); > > + > > + /* > > + * Initialise our COW domain. > > + * This domain owns sharable pages. > > + */ > > + dom_cow = domain_create(DOMID_COW, DOMCRF_dummy, 0); > > + BUG_ON(IS_ERR(dom_cow)); > > +} > > This looks like a cut and paste from the x86 code. Should it be > refactored into a common function?Yes, I suppose it should. I guess this is the counterpoint to my observation that there is x86 stuff in generic code ;-) Ian.
At 11:56 +0000 on 04 Dec (1354622173), Ian Campbell wrote:> This was a short term hack to get something linking quickly, but its > usefulness has now passed. > > This series replaces everything in here with proper functions. In many > cases these are still just stubs.For the arch/arm parts, Acked-by: Tim Deegan <tim@xen.org>
Ping? Any comments on the ARM parts before I go through a rebase + refresh cycle? On Tue, 2012-12-04 at 11:56 +0000, Ian Campbell wrote:> This was a short term hack to get something linking quickly, but its > usefulness has now passed. > > This series replaces everything in here with proper functions. In many > cases these are still just stubs. > > It seems to me that at least some of this stuff consists of x86-isms > which should instead be removed from the common code. > > This highlights two large missing pieces of functionality: wallclock > time and cleaning up on domain destroy. > > Ian. > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel
I don''t have any comments, they all look pretty straightforward. On Tue, 18 Dec 2012, Ian Campbell wrote:> Ping? Any comments on the ARM parts before I go through a rebase + > refresh cycle? > > On Tue, 2012-12-04 at 11:56 +0000, Ian Campbell wrote: > > This was a short term hack to get something linking quickly, but its > > usefulness has now passed. > > > > This series replaces everything in here with proper functions. In many > > cases these are still just stubs. > > > > It seems to me that at least some of this stuff consists of x86-isms > > which should instead be removed from the common code. > > > > This highlights two large missing pieces of functionality: wallclock > > time and cleaning up on domain destroy. > > > > Ian. > > > > > > _______________________________________________ > > Xen-devel mailing list > > Xen-devel@lists.xen.org > > http://lists.xen.org/xen-devel > > >
On Tue, 2012-12-18 at 18:31 +0000, Stefano Stabellini wrote:> I don''t have any comments, they all look pretty straightforward.Is that an Acked-by: Stefano on all 15?
On Tue, 18 Dec 2012, Ian Campbell wrote:> On Tue, 2012-12-18 at 18:31 +0000, Stefano Stabellini wrote: > > I don''t have any comments, they all look pretty straightforward. > > Is that an Acked-by: Stefano on all 15? >Yes
On Thu, 2012-12-06 at 12:09 +0000, Tim Deegan wrote:> At 11:56 +0000 on 04 Dec (1354622173), Ian Campbell wrote: > > This was a short term hack to get something linking quickly, but its > > usefulness has now passed. > > > > This series replaces everything in here with proper functions. In many > > cases these are still just stubs. > > For the arch/arm parts, > > Acked-by: Tim Deegan <tim@xen.org>I somehow missed this in my ping yesterday, sorry! Ian.
On Tue, 2012-12-04 at 11:56 +0000, Ian Campbell wrote:> This was a short term hack to get something linking quickly, but its > usefulness has now passed. > > This series replaces everything in here with proper functions. In many > cases these are still just stubs. > > It seems to me that at least some of this stuff consists of x86-isms > which should instead be removed from the common code. > > This highlights two large missing pieces of functionality: wallclock > time and cleaning up on domain destroy.Applied 1..4,6..14 with Tim+Stefano''s acks. Thanks. 5 was the patch which touched x86 which I need to refresh after Jan''s comment. 15 is the final removal of dummy.S which needs 5.
The concept is X86 specific. AFAICT the generic concept here is the number of physical IRQs which the current hardware has, so call this nr_hw_irqs. Also using "defined NR_IRQS" as a standin for x86 might have made sense at one point but its just cleaner to push the necessary definitions into asm/irq.h. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Cc: Keir (Xen.org) <keir@xen.org> Cc: Jan Beulich <JBeulich@suse.com> Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov> -- v2: s/nr_hw_irqs/nr_static_irqs/g --- xen/arch/arm/dummy.S | 2 -- xen/common/domain.c | 4 ++-- xen/include/asm-arm/irq.h | 3 +++ xen/include/asm-x86/irq.h | 4 ++++ xen/include/xen/irq.h | 8 -------- xen/xsm/flask/hooks.c | 4 ++-- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S index 6416f94..a214fbf 100644 --- a/xen/arch/arm/dummy.S +++ b/xen/arch/arm/dummy.S @@ -6,5 +6,3 @@ x: .word 0xe7f000f0 /* Undefined instruction */ .globl x; \ x: mov pc, lr -/* PIRQ support */ -DUMMY(nr_irqs_gsi); diff --git a/xen/common/domain.c b/xen/common/domain.c index 12c8e24..2f8ef00 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -259,9 +259,9 @@ struct domain *domain_create( atomic_inc(&d->pause_count); if ( domid ) - d->nr_pirqs = nr_irqs_gsi + extra_domU_irqs; + d->nr_pirqs = nr_static_irqs + extra_domU_irqs; else - d->nr_pirqs = nr_irqs_gsi + extra_dom0_irqs; + d->nr_pirqs = nr_static_irqs + extra_dom0_irqs; if ( d->nr_pirqs > nr_irqs ) d->nr_pirqs = nr_irqs; diff --git a/xen/include/asm-arm/irq.h b/xen/include/asm-arm/irq.h index abde839..bd6b54a 100644 --- a/xen/include/asm-arm/irq.h +++ b/xen/include/asm-arm/irq.h @@ -21,6 +21,9 @@ struct irq_cfg { #define NR_IRQS 1024 #define nr_irqs NR_IRQS +#define nr_irqs NR_IRQS +#define nr_static_irqs NR_IRQS + struct irq_desc; struct irq_desc *__irq_to_desc(int irq); diff --git a/xen/include/asm-x86/irq.h b/xen/include/asm-x86/irq.h index 5eefb94..7f5da06 100644 --- a/xen/include/asm-x86/irq.h +++ b/xen/include/asm-x86/irq.h @@ -11,6 +11,10 @@ #include <irq_vectors.h> #include <asm/percpu.h> +extern unsigned int nr_irqs_gsi; +extern unsigned int nr_irqs; +#define nr_static_irqs nr_irqs_gsi + #define IO_APIC_IRQ(irq) (platform_legacy_irq(irq) ? \ (1 << (irq)) & io_apic_irqs : \ (irq) < nr_irqs_gsi) diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h index 5973cce..7386358 100644 --- a/xen/include/xen/irq.h +++ b/xen/include/xen/irq.h @@ -58,14 +58,6 @@ typedef const struct hw_interrupt_type hw_irq_controller; #include <asm/irq.h> -#ifdef NR_IRQS -# define nr_irqs NR_IRQS -# define nr_irqs_gsi NR_IRQS -#else -extern unsigned int nr_irqs_gsi; -extern unsigned int nr_irqs; -#endif - struct msi_desc; /* * This is the "IRQ descriptor", which contains various information diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index 0ca10d0..782e28c 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -72,7 +72,7 @@ static int get_irq_sid(int irq, u32 *sid, struct avc_audit_data *ad) struct irq_desc *desc = irq_to_desc(irq); if ( irq >= nr_irqs || irq < 0 ) return -EINVAL; - if ( irq < nr_irqs_gsi ) { + if ( irq < nr_static_irqs ) { if (ad) { AVC_AUDIT_DATA_INIT(ad, IRQ); ad->irq = irq; @@ -699,7 +699,7 @@ static int flask_map_domain_pirq (struct domain *d, int irq, void *data) if ( rc ) return rc; - if ( irq >= nr_irqs_gsi && msi ) { + if ( irq >= nr_static_irqs && msi ) { u32 machine_bdf = (msi->seg << 16) | (msi->bus << 8) | msi->devfn; AVC_AUDIT_DATA_INIT(&ad, DEV); ad.device = machine_bdf; -- 1.7.9.1
On 19/12/2012 14:43, "Ian Campbell" <ian.campbell@citrix.com> wrote:> The concept is X86 specific. > > AFAICT the generic concept here is the number of physical IRQs which > the current hardware has, so call this nr_hw_irqs. > > Also using "defined NR_IRQS" as a standin for x86 might have made > sense at one point but its just cleaner to push the necessary > definitions into asm/irq.h. > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com> > Cc: Keir (Xen.org) <keir@xen.org> > Cc: Jan Beulich <JBeulich@suse.com> > Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>Acked-by: Keir Fraser <keir@xen.org>> -- > v2: s/nr_hw_irqs/nr_static_irqs/g > --- > xen/arch/arm/dummy.S | 2 -- > xen/common/domain.c | 4 ++-- > xen/include/asm-arm/irq.h | 3 +++ > xen/include/asm-x86/irq.h | 4 ++++ > xen/include/xen/irq.h | 8 -------- > xen/xsm/flask/hooks.c | 4 ++-- > 6 files changed, 11 insertions(+), 14 deletions(-) > > diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S > index 6416f94..a214fbf 100644 > --- a/xen/arch/arm/dummy.S > +++ b/xen/arch/arm/dummy.S > @@ -6,5 +6,3 @@ x: .word 0xe7f000f0 /* Undefined instruction */ > .globl x; \ > x: mov pc, lr > > -/* PIRQ support */ > -DUMMY(nr_irqs_gsi); > diff --git a/xen/common/domain.c b/xen/common/domain.c > index 12c8e24..2f8ef00 100644 > --- a/xen/common/domain.c > +++ b/xen/common/domain.c > @@ -259,9 +259,9 @@ struct domain *domain_create( > atomic_inc(&d->pause_count); > > if ( domid ) > - d->nr_pirqs = nr_irqs_gsi + extra_domU_irqs; > + d->nr_pirqs = nr_static_irqs + extra_domU_irqs; > else > - d->nr_pirqs = nr_irqs_gsi + extra_dom0_irqs; > + d->nr_pirqs = nr_static_irqs + extra_dom0_irqs; > if ( d->nr_pirqs > nr_irqs ) > d->nr_pirqs = nr_irqs; > > diff --git a/xen/include/asm-arm/irq.h b/xen/include/asm-arm/irq.h > index abde839..bd6b54a 100644 > --- a/xen/include/asm-arm/irq.h > +++ b/xen/include/asm-arm/irq.h > @@ -21,6 +21,9 @@ struct irq_cfg { > #define NR_IRQS 1024 > #define nr_irqs NR_IRQS > > +#define nr_irqs NR_IRQS > +#define nr_static_irqs NR_IRQS > + > struct irq_desc; > > struct irq_desc *__irq_to_desc(int irq); > diff --git a/xen/include/asm-x86/irq.h b/xen/include/asm-x86/irq.h > index 5eefb94..7f5da06 100644 > --- a/xen/include/asm-x86/irq.h > +++ b/xen/include/asm-x86/irq.h > @@ -11,6 +11,10 @@ > #include <irq_vectors.h> > #include <asm/percpu.h> > > +extern unsigned int nr_irqs_gsi; > +extern unsigned int nr_irqs; > +#define nr_static_irqs nr_irqs_gsi > + > #define IO_APIC_IRQ(irq) (platform_legacy_irq(irq) ? \ > (1 << (irq)) & io_apic_irqs : \ > (irq) < nr_irqs_gsi) > diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h > index 5973cce..7386358 100644 > --- a/xen/include/xen/irq.h > +++ b/xen/include/xen/irq.h > @@ -58,14 +58,6 @@ typedef const struct hw_interrupt_type hw_irq_controller; > > #include <asm/irq.h> > > -#ifdef NR_IRQS > -# define nr_irqs NR_IRQS > -# define nr_irqs_gsi NR_IRQS > -#else > -extern unsigned int nr_irqs_gsi; > -extern unsigned int nr_irqs; > -#endif > - > struct msi_desc; > /* > * This is the "IRQ descriptor", which contains various information > diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c > index 0ca10d0..782e28c 100644 > --- a/xen/xsm/flask/hooks.c > +++ b/xen/xsm/flask/hooks.c > @@ -72,7 +72,7 @@ static int get_irq_sid(int irq, u32 *sid, struct > avc_audit_data *ad) > struct irq_desc *desc = irq_to_desc(irq); > if ( irq >= nr_irqs || irq < 0 ) > return -EINVAL; > - if ( irq < nr_irqs_gsi ) { > + if ( irq < nr_static_irqs ) { > if (ad) { > AVC_AUDIT_DATA_INIT(ad, IRQ); > ad->irq = irq; > @@ -699,7 +699,7 @@ static int flask_map_domain_pirq (struct domain *d, int > irq, void *data) > if ( rc ) > return rc; > > - if ( irq >= nr_irqs_gsi && msi ) { > + if ( irq >= nr_static_irqs && msi ) { > u32 machine_bdf = (msi->seg << 16) | (msi->bus << 8) | msi->devfn; > AVC_AUDIT_DATA_INIT(&ad, DEV); > ad.device = machine_bdf;
>>> On 19.12.12 at 15:43, Ian Campbell <ian.campbell@citrix.com> wrote: > The concept is X86 specific. > > AFAICT the generic concept here is the number of physical IRQs which > the current hardware has, so call this nr_hw_irqs. > > Also using "defined NR_IRQS" as a standin for x86 might have made > sense at one point but its just cleaner to push the necessary > definitions into asm/irq.h. > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com> > Cc: Keir (Xen.org) <keir@xen.org> > Cc: Jan Beulich <JBeulich@suse.com> > Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>Acked-by: Jan Beulich <jbeulich@suse.com>> -- > v2: s/nr_hw_irqs/nr_static_irqs/g > --- > xen/arch/arm/dummy.S | 2 -- > xen/common/domain.c | 4 ++-- > xen/include/asm-arm/irq.h | 3 +++ > xen/include/asm-x86/irq.h | 4 ++++ > xen/include/xen/irq.h | 8 -------- > xen/xsm/flask/hooks.c | 4 ++-- > 6 files changed, 11 insertions(+), 14 deletions(-) > > diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S > index 6416f94..a214fbf 100644 > --- a/xen/arch/arm/dummy.S > +++ b/xen/arch/arm/dummy.S > @@ -6,5 +6,3 @@ x: .word 0xe7f000f0 /* Undefined instruction */ > .globl x; \ > x: mov pc, lr > > -/* PIRQ support */ > -DUMMY(nr_irqs_gsi); > diff --git a/xen/common/domain.c b/xen/common/domain.c > index 12c8e24..2f8ef00 100644 > --- a/xen/common/domain.c > +++ b/xen/common/domain.c > @@ -259,9 +259,9 @@ struct domain *domain_create( > atomic_inc(&d->pause_count); > > if ( domid ) > - d->nr_pirqs = nr_irqs_gsi + extra_domU_irqs; > + d->nr_pirqs = nr_static_irqs + extra_domU_irqs; > else > - d->nr_pirqs = nr_irqs_gsi + extra_dom0_irqs; > + d->nr_pirqs = nr_static_irqs + extra_dom0_irqs; > if ( d->nr_pirqs > nr_irqs ) > d->nr_pirqs = nr_irqs; > > diff --git a/xen/include/asm-arm/irq.h b/xen/include/asm-arm/irq.h > index abde839..bd6b54a 100644 > --- a/xen/include/asm-arm/irq.h > +++ b/xen/include/asm-arm/irq.h > @@ -21,6 +21,9 @@ struct irq_cfg { > #define NR_IRQS 1024 > #define nr_irqs NR_IRQS > > +#define nr_irqs NR_IRQS > +#define nr_static_irqs NR_IRQS > + > struct irq_desc; > > struct irq_desc *__irq_to_desc(int irq); > diff --git a/xen/include/asm-x86/irq.h b/xen/include/asm-x86/irq.h > index 5eefb94..7f5da06 100644 > --- a/xen/include/asm-x86/irq.h > +++ b/xen/include/asm-x86/irq.h > @@ -11,6 +11,10 @@ > #include <irq_vectors.h> > #include <asm/percpu.h> > > +extern unsigned int nr_irqs_gsi; > +extern unsigned int nr_irqs; > +#define nr_static_irqs nr_irqs_gsi > + > #define IO_APIC_IRQ(irq) (platform_legacy_irq(irq) ? \ > (1 << (irq)) & io_apic_irqs : \ > (irq) < nr_irqs_gsi) > diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h > index 5973cce..7386358 100644 > --- a/xen/include/xen/irq.h > +++ b/xen/include/xen/irq.h > @@ -58,14 +58,6 @@ typedef const struct hw_interrupt_type hw_irq_controller; > > #include <asm/irq.h> > > -#ifdef NR_IRQS > -# define nr_irqs NR_IRQS > -# define nr_irqs_gsi NR_IRQS > -#else > -extern unsigned int nr_irqs_gsi; > -extern unsigned int nr_irqs; > -#endif > - > struct msi_desc; > /* > * This is the "IRQ descriptor", which contains various information > diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c > index 0ca10d0..782e28c 100644 > --- a/xen/xsm/flask/hooks.c > +++ b/xen/xsm/flask/hooks.c > @@ -72,7 +72,7 @@ static int get_irq_sid(int irq, u32 *sid, struct > avc_audit_data *ad) > struct irq_desc *desc = irq_to_desc(irq); > if ( irq >= nr_irqs || irq < 0 ) > return -EINVAL; > - if ( irq < nr_irqs_gsi ) { > + if ( irq < nr_static_irqs ) { > if (ad) { > AVC_AUDIT_DATA_INIT(ad, IRQ); > ad->irq = irq; > @@ -699,7 +699,7 @@ static int flask_map_domain_pirq (struct domain *d, int > irq, void *data) > if ( rc ) > return rc; > > - if ( irq >= nr_irqs_gsi && msi ) { > + if ( irq >= nr_static_irqs && msi ) { > u32 machine_bdf = (msi->seg << 16) | (msi->bus << 8) | msi->devfn; > AVC_AUDIT_DATA_INIT(&ad, DEV); > ad.device = machine_bdf; > -- > 1.7.9.1
On Wed, 2012-12-19 at 14:43 +0000, Ian Campbell wrote:> The concept is X86 specific. > > AFAICT the generic concept here is the number of physical IRQs which > the current hardware has, so call this nr_hw_irqs.I corrected this to: AFAICT the generic concept here is the number of static physical IRQs which the current hardware has, so call this nr_static_irqs.> Also using "defined NR_IRQS" as a standin for x86 might have made > sense at one point but its just cleaner to push the necessary > definitions into asm/irq.h. > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com> > Cc: Keir (Xen.org) <keir@xen.org> > Cc: Jan Beulich <JBeulich@suse.com>Applied with Keir + Jan''s ack.