[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC 4/4] xen: arch-specific hooks for domain_soft_reset()
x86-specific hook cleans up the pirq-emuirq mappings and replaces the shared_info frame with an empty page to support subsequent XENMAPSPACE_shared_info call. ARM-specific hook is a noop for now. Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> --- xen/arch/arm/domain.c | 5 ++++ xen/arch/x86/domain.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ xen/common/domain.c | 2 ++ xen/include/xen/domain.h | 2 ++ 4 files changed, 82 insertions(+) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 24b8938..c112afa 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -653,6 +653,11 @@ void arch_domain_unpause(struct domain *d) { } +int arch_domain_soft_reset(struct domain *d) +{ + return 0; +} + static int is_guest_pv32_psr(uint32_t psr) { switch (psr & PSR_MODE_MASK) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 1f1550e..2d23c17 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -679,6 +679,79 @@ void arch_domain_unpause(struct domain *d) viridian_time_ref_count_thaw(d); } +int arch_domain_soft_reset(struct domain *d) +{ + struct page_info *page = virt_to_page(d->shared_info), *new_page; + int ret = 0; + struct domain *owner; + unsigned long mfn, mfn_new, gfn; + p2m_type_t __p2mt; + + if ( is_hvm_domain(d) ) + { + int i; + + spin_lock(&d->event_lock); + for ( i = 1; i < d->nr_pirqs ; i ++ ) + if ( domain_pirq_to_emuirq(d, i) != IRQ_UNBOUND ) + { + ret = unmap_domain_pirq_emuirq(d, i); + if (ret) + break; + } + spin_unlock(&d->event_lock); + } + + if ( ret || !d->shared_info || !page ) + return ret; + + /* + * shared_info page needs to be replaced with a new page, otherwise we + * will get a hole if the domain does XENMAPSPACE_shared_info + */ + + owner = page_get_owner_and_reference(page); + if ( owner != d ) + { + put_page(page); + return 0; + } + + mfn = page_to_mfn(page); + if ( !mfn_valid(mfn) ) + { + printk(XENLOG_G_ERR "Dom%d's shared_info page points to invalid MFN\n", + d->domain_id); + ret = -EINVAL; + goto fail_put_page; + } + + gfn = mfn_to_gmfn(d, mfn); + get_gfn_query(d, gfn, &__p2mt); + + new_page = alloc_domheap_page(d, 0); + if ( !new_page ) + { + printk(XENLOG_G_ERR "Failed to alloc a page to replace" + " Dom%d's shared_info frame %lx\n", d->domain_id, gfn); + ret = -ENOMEM; + goto fail_put_gfn; + } + mfn_new = page_to_mfn(new_page); + guest_physmap_remove_page(d, gfn, mfn, 0); + + ret = guest_physmap_add_page(d, gfn, mfn_new, 0); + if ( ret ) + printk(XENLOG_G_ERR "Failed to add a page to replace" + " Dom%d's shared_info frame %lx\n", d->domain_id, gfn); + fail_put_gfn: + put_gfn(d, gfn); + fail_put_page: + put_page(page); + + return ret; +} + unsigned long pv_guest_cr4_fixup(const struct vcpu *v, unsigned long guest_cr4) { unsigned long hv_cr4_mask, hv_cr4 = real_cr4_to_pv_guest_cr4(read_cr4()); diff --git a/xen/common/domain.c b/xen/common/domain.c index 44e532b..0ab1a71 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1467,6 +1467,8 @@ int domain_soft_reset(struct domain *d) for_each_vcpu ( d, v ) unmap_vcpu_info(v); + ret = arch_domain_soft_reset(d); + vcpu_unpause: for_each_vcpu ( d, v ) if ( v != current ) diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 57f8ddd..311bead 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -65,6 +65,8 @@ void arch_domain_shutdown(struct domain *d); void arch_domain_pause(struct domain *d); void arch_domain_unpause(struct domain *d); +int arch_domain_soft_reset(struct domain *d); + int arch_set_info_guest(struct vcpu *, vcpu_guest_context_u); void arch_get_info_guest(struct vcpu *, vcpu_guest_context_u); -- 1.9.3 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |