From: "Jan Beulich" Subject: [PATCH v6][XSA-97] x86/paging: make log-dirty operations preemptible Date: Thu, 02 Oct 2014 16:15:29 +0100 Message-ID: <542D8831020000780003C115@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part7C490801.1__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XZi6Q-00039B-JI for xen-devel@lists.xenproject.org; Thu, 02 Oct 2014 15:15:34 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Andrew Cooper , Keir Fraser , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part7C490801.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Both the freeing and the inspection of the bitmap get done in (nested) loops which - besides having a rather high iteration count in general, albeit that would be covered by XSA-77 - have the number of non-trivial iterations they need to perform (indirectly) controllable by both the guest they are for and any domain controlling the guest (including the one running qemu for it). Note that the tying of the continuations to the invoking domain (which previously [wrongly] used the invoking vCPU instead) implies that the tools requesting such operations have to make sure they don't issue multiple similar operations in parallel. Note further that this breaks supervisor-mode kernel assumptions in hypercall_create_continuation() (where regs->eip gets rewound to the current hypercall stub beginning), but otoh hypercall_cancel_continuation() doesn't work in that mode either. Perhaps time to rip out all the remains of that feature? This is part of CVE-2014-5146 / XSA-97. Signed-off-by: Jan Beulich Reviewed-by: Tim Deegan --- v6: Move stats (dirty_count and fault_count) zeroing to the final success exit path (also fixing pre-existing issues with them getting cleaned but an error getting detected/reported later). v5: Also wire up helper hypercall in HVM/PVH hypercall tables (pointed out by Tim). v4: Fold in Andrew's paging_mode_log_dirty() guarding adjustments to paging_log_dirty_disable() and its caller. Convert tying continuations to domain (was vCPU). Introduce a separate internal hypercall (__HYPERCALL_arch_1) to deal with the continuation (both suggested by Tim and Andrew). As a result hap_domctl() and shadow_domctl() now don't propagate -ERESTART into paging_domctl() anymore, as that would imply setting d->arch.paging.preempt fields without holding the paging lock. Sadly this results in mixed methods used for continuations here. v3: Convert if(!resuming) to ASSERT() in paging_log_dirty_op(). v2: Re-order L4 loop continuation/termination handling in paging_free_log_dirty_bitmap(). Add an ASSERT() in a special case exit path of paging_log_dirty_op(). --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1941,7 +1941,9 @@ int domain_relinquish_resources(struct d pci_release_devices(d); =20 /* Tear down paging-assistance stuff. */ - paging_teardown(d); + ret =3D paging_teardown(d); + if ( ret ) + return ret; =20 /* Drop the in-use references to page-table bases. */ for_each_vcpu ( d, v ) --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -61,9 +61,11 @@ long arch_do_domctl( =20 case XEN_DOMCTL_shadow_op: { - ret =3D paging_domctl(d, - &domctl->u.shadow_op, - guest_handle_cast(u_domctl, void)); + ret =3D paging_domctl(d, &domctl->u.shadow_op, + guest_handle_cast(u_domctl, void), 0); + if ( ret =3D=3D -ERESTART ) + return hypercall_create_continuation(__HYPERVISOR_arch_1, + "h", u_domctl); copyback =3D 1; } break; --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4770,7 +4770,8 @@ static hvm_hypercall_t *const hvm_hyperc HYPERCALL(hvm_op), HYPERCALL(sysctl), HYPERCALL(domctl), - HYPERCALL(tmem_op) + HYPERCALL(tmem_op), + [ __HYPERVISOR_arch_1 ] =3D (hvm_hypercall_t *)paging_domctl_continuat= ion }; =20 #define COMPAT_CALL(x) \ @@ -4790,7 +4791,8 @@ static hvm_hypercall_t *const hvm_hyperc HYPERCALL(hvm_op), HYPERCALL(sysctl), HYPERCALL(domctl), - HYPERCALL(tmem_op) + HYPERCALL(tmem_op), + [ __HYPERVISOR_arch_1 ] =3D (hvm_hypercall_t *)paging_domctl_continuat= ion }; =20 /* PVH 32bitfixme. */ @@ -4808,7 +4810,8 @@ static hvm_hypercall_t *const pvh_hyperc [ __HYPERVISOR_physdev_op ] =3D (hvm_hypercall_t *)hvm_physdev_op= , HYPERCALL(hvm_op), HYPERCALL(sysctl), - HYPERCALL(domctl) + HYPERCALL(domctl), + [ __HYPERVISOR_arch_1 ] =3D (hvm_hypercall_t *)paging_domctl_continuat= ion }; =20 int hvm_do_hypercall(struct cpu_user_regs *regs) --- a/xen/arch/x86/mm/paging.c +++ b/xen/arch/x86/mm/paging.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -116,26 +117,46 @@ static void paging_free_log_dirty_page(s d->arch.paging.free_page(d, mfn_to_page(mfn)); } =20 -void paging_free_log_dirty_bitmap(struct domain *d) +static int paging_free_log_dirty_bitmap(struct domain *d, int rc) { mfn_t *l4, *l3, *l2; int i4, i3, i2; =20 + paging_lock(d); + if ( !mfn_valid(d->arch.paging.log_dirty.top) ) - return; + { + paging_unlock(d); + return 0; + } =20 - paging_lock(d); + if ( !d->arch.paging.preempt.dom ) + { + memset(&d->arch.paging.preempt.log_dirty, 0, + sizeof(d->arch.paging.preempt.log_dirty)); + ASSERT(rc <=3D 0); + d->arch.paging.preempt.log_dirty.done =3D -rc; + } + else if ( d->arch.paging.preempt.dom !=3D current->domain || + d->arch.paging.preempt.op !=3D XEN_DOMCTL_SHADOW_OP_OFF ) + { + paging_unlock(d); + return -EBUSY; + } =20 l4 =3D map_domain_page(mfn_x(d->arch.paging.log_dirty.top)); + i4 =3D d->arch.paging.preempt.log_dirty.i4; + i3 =3D d->arch.paging.preempt.log_dirty.i3; + rc =3D 0; =20 - for ( i4 =3D 0; i4 < LOGDIRTY_NODE_ENTRIES; i4++ ) + for ( ; i4 < LOGDIRTY_NODE_ENTRIES; i4++, i3 =3D 0 ) { if ( !mfn_valid(l4[i4]) ) continue; =20 l3 =3D map_domain_page(mfn_x(l4[i4])); =20 - for ( i3 =3D 0; i3 < LOGDIRTY_NODE_ENTRIES; i3++ ) + for ( ; i3 < LOGDIRTY_NODE_ENTRIES; i3++ ) { if ( !mfn_valid(l3[i3]) ) continue; @@ -148,20 +169,54 @@ void paging_free_log_dirty_bitmap(struct =20 unmap_domain_page(l2); paging_free_log_dirty_page(d, l3[i3]); + l3[i3] =3D _mfn(INVALID_MFN); + + if ( i3 < LOGDIRTY_NODE_ENTRIES - 1 && hypercall_preempt_check= () ) + { + d->arch.paging.preempt.log_dirty.i3 =3D i3 + 1; + d->arch.paging.preempt.log_dirty.i4 =3D i4; + rc =3D -ERESTART; + break; + } } =20 unmap_domain_page(l3); + if ( rc ) + break; paging_free_log_dirty_page(d, l4[i4]); + l4[i4] =3D _mfn(INVALID_MFN); + + if ( i4 < LOGDIRTY_NODE_ENTRIES - 1 && hypercall_preempt_check() = ) + { + d->arch.paging.preempt.log_dirty.i3 =3D 0; + d->arch.paging.preempt.log_dirty.i4 =3D i4 + 1; + rc =3D -ERESTART; + break; + } } =20 unmap_domain_page(l4); - paging_free_log_dirty_page(d, d->arch.paging.log_dirty.top); - d->arch.paging.log_dirty.top =3D _mfn(INVALID_MFN); =20 - ASSERT(d->arch.paging.log_dirty.allocs =3D=3D 0); - d->arch.paging.log_dirty.failed_allocs =3D 0; + if ( !rc ) + { + paging_free_log_dirty_page(d, d->arch.paging.log_dirty.top); + d->arch.paging.log_dirty.top =3D _mfn(INVALID_MFN); + + ASSERT(d->arch.paging.log_dirty.allocs =3D=3D 0); + d->arch.paging.log_dirty.failed_allocs =3D 0; + + rc =3D -d->arch.paging.preempt.log_dirty.done; + d->arch.paging.preempt.dom =3D NULL; + } + else + { + d->arch.paging.preempt.dom =3D current->domain; + d->arch.paging.preempt.op =3D XEN_DOMCTL_SHADOW_OP_OFF; + } =20 paging_unlock(d); + + return rc; } =20 int paging_log_dirty_enable(struct domain *d, bool_t log_global) @@ -187,15 +242,25 @@ int paging_log_dirty_enable(struct domai return ret; } =20 -int paging_log_dirty_disable(struct domain *d) +static int paging_log_dirty_disable(struct domain *d, bool_t resuming) { - int ret; + int ret =3D 1; + + if ( !resuming ) + { + domain_pause(d); + /* Safe because the domain is paused. */ + if ( paging_mode_log_dirty(d) ) + { + ret =3D d->arch.paging.log_dirty.disable_log_dirty(d); + ASSERT(ret <=3D 0); + } + } + + ret =3D paging_free_log_dirty_bitmap(d, ret); + if ( ret =3D=3D -ERESTART ) + return ret; =20 - domain_pause(d); - /* Safe because the domain is paused. */ - ret =3D d->arch.paging.log_dirty.disable_log_dirty(d); - if ( !paging_mode_log_dirty(d) ) - paging_free_log_dirty_bitmap(d); domain_unpause(d); =20 return ret; @@ -335,7 +400,9 @@ int paging_mfn_is_dirty(struct domain *d =20 /* Read a domain's log-dirty bitmap and stats. If the operation is a = CLEAN, * clear the bitmap and stats as well. */ -int paging_log_dirty_op(struct domain *d, struct xen_domctl_shadow_op = *sc) +static int paging_log_dirty_op(struct domain *d, + struct xen_domctl_shadow_op *sc, + bool_t resuming) { int rv =3D 0, clean =3D 0, peek =3D 1; unsigned long pages =3D 0; @@ -343,9 +410,22 @@ int paging_log_dirty_op(struct domain *d unsigned long *l1 =3D NULL; int i4, i3, i2; =20 - domain_pause(d); + if ( !resuming ) + domain_pause(d); paging_lock(d); =20 + if ( !d->arch.paging.preempt.dom ) + memset(&d->arch.paging.preempt.log_dirty, 0, + sizeof(d->arch.paging.preempt.log_dirty)); + else if ( d->arch.paging.preempt.dom !=3D current->domain || + d->arch.paging.preempt.op !=3D sc->op ) + { + paging_unlock(d); + ASSERT(!resuming); + domain_unpause(d); + return -EBUSY; + } + clean =3D (sc->op =3D=3D XEN_DOMCTL_SHADOW_OP_CLEAN); =20 PAGING_DEBUG(LOGDIRTY, "log-dirty %s: dom %u faults=3D%u dirty=3D%u\n"= , @@ -357,12 +437,6 @@ int paging_log_dirty_op(struct domain *d sc->stats.fault_count =3D d->arch.paging.log_dirty.fault_count; sc->stats.dirty_count =3D d->arch.paging.log_dirty.dirty_count; =20 - if ( clean ) - { - d->arch.paging.log_dirty.fault_count =3D 0; - d->arch.paging.log_dirty.dirty_count =3D 0; - } - if ( guest_handle_is_null(sc->dirty_bitmap) ) /* caller may have wanted just to clean the state or access = stats. */ peek =3D 0; @@ -374,17 +448,15 @@ int paging_log_dirty_op(struct domain *d goto out; } =20 - pages =3D 0; l4 =3D paging_map_log_dirty_bitmap(d); + i4 =3D d->arch.paging.preempt.log_dirty.i4; + i3 =3D d->arch.paging.preempt.log_dirty.i3; + pages =3D d->arch.paging.preempt.log_dirty.done; =20 - for ( i4 =3D 0; - (pages < sc->pages) && (i4 < LOGDIRTY_NODE_ENTRIES); - i4++ ) + for ( ; (pages < sc->pages) && (i4 < LOGDIRTY_NODE_ENTRIES); i4++, i3 = =3D 0 ) { l3 =3D (l4 && mfn_valid(l4[i4])) ? map_domain_page(mfn_x(l4[i4])) = : NULL; - for ( i3 =3D 0; - (pages < sc->pages) && (i3 < LOGDIRTY_NODE_ENTRIES); - i3++ ) + for ( ; (pages < sc->pages) && (i3 < LOGDIRTY_NODE_ENTRIES); i3++ = ) { l2 =3D ((l3 && mfn_valid(l3[i3])) ? map_domain_page(mfn_x(l3[i3])) : NULL); @@ -419,18 +491,58 @@ int paging_log_dirty_op(struct domain *d } if ( l2 ) unmap_domain_page(l2); + + if ( i3 < LOGDIRTY_NODE_ENTRIES - 1 && hypercall_preempt_check= () ) + { + d->arch.paging.preempt.log_dirty.i4 =3D i4; + d->arch.paging.preempt.log_dirty.i3 =3D i3 + 1; + rv =3D -ERESTART; + break; + } } if ( l3 ) unmap_domain_page(l3); + + if ( !rv && i4 < LOGDIRTY_NODE_ENTRIES - 1 && + hypercall_preempt_check() ) + { + d->arch.paging.preempt.log_dirty.i4 =3D i4 + 1; + d->arch.paging.preempt.log_dirty.i3 =3D 0; + rv =3D -ERESTART; + } + if ( rv ) + break; } if ( l4 ) unmap_domain_page(l4); =20 - if ( pages < sc->pages ) - sc->pages =3D pages; + if ( !rv ) + { + d->arch.paging.preempt.dom =3D NULL; + if ( clean ) + { + d->arch.paging.log_dirty.fault_count =3D 0; + d->arch.paging.log_dirty.dirty_count =3D 0; + } + } + else + { + d->arch.paging.preempt.dom =3D current->domain; + d->arch.paging.preempt.op =3D sc->op; + d->arch.paging.preempt.log_dirty.done =3D pages; + } =20 paging_unlock(d); =20 + if ( rv ) + { + /* Never leave the domain paused on real errors. */ + ASSERT(rv =3D=3D -ERESTART); + return rv; + } + + if ( pages < sc->pages ) + sc->pages =3D pages; if ( clean ) { /* We need to further call clean_dirty_bitmap() functions of = specific @@ -441,6 +553,7 @@ int paging_log_dirty_op(struct domain *d return rv; =20 out: + d->arch.paging.preempt.dom =3D NULL; paging_unlock(d); domain_unpause(d); =20 @@ -504,12 +617,6 @@ void paging_log_dirty_init(struct domain d->arch.paging.log_dirty.clean_dirty_bitmap =3D clean_dirty_bitmap; } =20 -/* This function fress log dirty bitmap resources. */ -static void paging_log_dirty_teardown(struct domain*d) -{ - paging_free_log_dirty_bitmap(d); -} - /************************************************/ /* CODE FOR PAGING SUPPORT */ /************************************************/ @@ -551,7 +658,7 @@ void paging_vcpu_init(struct vcpu *v) =20 =20 int paging_domctl(struct domain *d, xen_domctl_shadow_op_t *sc, - XEN_GUEST_HANDLE_PARAM(void) u_domctl) + XEN_GUEST_HANDLE_PARAM(void) u_domctl, bool_t resuming) { int rc; =20 @@ -575,6 +682,20 @@ int paging_domctl(struct domain *d, xen_ return -EINVAL; } =20 + if ( resuming + ? (d->arch.paging.preempt.dom !=3D current->domain || + d->arch.paging.preempt.op !=3D sc->op) + : (d->arch.paging.preempt.dom && + sc->op !=3D XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION) ) + { + printk(XENLOG_G_DEBUG + "%pv: Paging op %#x on Dom%u with unfinished prior op %#x = by Dom%u\n", + current, sc->op, d->domain_id, d->arch.paging.preempt.op, + d->arch.paging.preempt.dom + ? d->arch.paging.preempt.dom->domain_id : DOMID_INVALID); + return -EBUSY; + } + rc =3D xsm_shadow_control(XSM_HOOK, d, sc->op); if ( rc ) return rc; @@ -597,14 +718,13 @@ int paging_domctl(struct domain *d, xen_ return paging_log_dirty_enable(d, 1); =20 case XEN_DOMCTL_SHADOW_OP_OFF: - if ( paging_mode_log_dirty(d) ) - if ( (rc =3D paging_log_dirty_disable(d)) !=3D 0 ) - return rc; + if ( (rc =3D paging_log_dirty_disable(d, resuming)) !=3D 0 ) + return rc; break; =20 case XEN_DOMCTL_SHADOW_OP_CLEAN: case XEN_DOMCTL_SHADOW_OP_PEEK: - return paging_log_dirty_op(d, sc); + return paging_log_dirty_op(d, sc, resuming); } =20 /* Here, dispatch domctl to the appropriate paging code */ @@ -614,19 +734,67 @@ int paging_domctl(struct domain *d, xen_ return shadow_domctl(d, sc, u_domctl); } =20 +long paging_domctl_continuation(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) = u_domctl) +{ + struct xen_domctl op; + struct domain *d; + int ret; + + if ( copy_from_guest(&op, u_domctl, 1) ) + return -EFAULT; + + if ( op.interface_version !=3D XEN_DOMCTL_INTERFACE_VERSION || + op.cmd !=3D XEN_DOMCTL_shadow_op ) + return -EBADRQC; + + d =3D rcu_lock_domain_by_id(op.domain); + if ( d =3D=3D NULL ) + return -ESRCH; + + ret =3D xsm_domctl(XSM_OTHER, d, op.cmd); + if ( !ret ) + { + if ( domctl_lock_acquire() ) + { + ret =3D paging_domctl(d, &op.u.shadow_op, + guest_handle_cast(u_domctl, void), 1); + + domctl_lock_release(); + } + else + ret =3D -ERESTART; + } + + rcu_unlock_domain(d); + + if ( ret =3D=3D -ERESTART ) + ret =3D hypercall_create_continuation(__HYPERVISOR_arch_1, + "h", u_domctl); + else if ( __copy_field_to_guest(u_domctl, &op, u.shadow_op) ) + ret =3D -EFAULT; + + return ret; +} + /* Call when destroying a domain */ -void paging_teardown(struct domain *d) +int paging_teardown(struct domain *d) { + int rc; + if ( hap_enabled(d) ) hap_teardown(d); else shadow_teardown(d); =20 /* clean up log dirty resources. */ - paging_log_dirty_teardown(d); + rc =3D paging_free_log_dirty_bitmap(d, 0); + if ( rc =3D=3D -ERESTART ) + return rc; =20 /* Move populate-on-demand cache back to domain_list for destruction = */ p2m_pod_empty_cache(d); + + return rc; } =20 /* Call once all of the references to the domain have gone away */ --- a/xen/arch/x86/x86_64/compat/entry.S +++ b/xen/arch/x86/x86_64/compat/entry.S @@ -421,6 +421,7 @@ ENTRY(compat_hypercall_table) .quad compat_ni_hypercall .endr .quad do_mca /* 48 */ + .quad paging_domctl_continuation .rept NR_hypercalls-((.-compat_hypercall_table)/8) .quad compat_ni_hypercall .endr @@ -469,6 +470,7 @@ ENTRY(compat_hypercall_args_table) .byte 0 /* compat_ni_hypercall */ .endr .byte 1 /* do_mca */ + .byte 1 /* paging_domctl_continuation */ .rept NR_hypercalls-(.-compat_hypercall_args_table) .byte 0 /* compat_ni_hypercall */ .endr --- a/xen/arch/x86/x86_64/entry.S +++ b/xen/arch/x86/x86_64/entry.S @@ -776,6 +776,7 @@ ENTRY(hypercall_table) .quad do_ni_hypercall .endr .quad do_mca /* 48 */ + .quad paging_domctl_continuation .rept NR_hypercalls-((.-hypercall_table)/8) .quad do_ni_hypercall .endr @@ -824,6 +825,7 @@ ENTRY(hypercall_args_table) .byte 0 /* do_ni_hypercall */ .endr .byte 1 /* do_mca */ /* 48 */ + .byte 1 /* paging_domctl_continuation */ .rept NR_hypercalls-(.-hypercall_args_table) .byte 0 /* do_ni_hypercall */ .endr --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -619,7 +619,6 @@ int domain_kill(struct domain *d) { if ( rc =3D=3D -ERESTART ) rc =3D -EAGAIN; - BUG_ON(rc !=3D -EAGAIN); break; } if ( sched_move_domain(d, cpupool0) ) --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -187,6 +187,20 @@ struct paging_domain { struct hap_domain hap; /* log dirty support */ struct log_dirty_domain log_dirty; + + /* preemption handling */ + struct { + const struct domain *dom; + unsigned int op; + union { + struct { + unsigned long done:PADDR_BITS - PAGE_SHIFT; + unsigned long i4:PAGETABLE_ORDER; + unsigned long i3:PAGETABLE_ORDER; + } log_dirty; + }; + } preempt; + /* alloc/free pages from the pool for paging-assistance structures * (used by p2m and log-dirty code for their tries) */ struct page_info * (*alloc_page)(struct domain *d); --- a/xen/include/asm-x86/paging.h +++ b/xen/include/asm-x86/paging.h @@ -132,9 +132,6 @@ struct paging_mode { /*************************************************************************= **** * Log dirty code */ =20 -/* free log dirty bitmap resource */ -void paging_free_log_dirty_bitmap(struct domain *d); - /* get the dirty bitmap for a specific range of pfns */ void paging_log_dirty_range(struct domain *d, unsigned long begin_pfn, @@ -144,9 +141,6 @@ void paging_log_dirty_range(struct domai /* enable log dirty */ int paging_log_dirty_enable(struct domain *d, bool_t log_global); =20 -/* disable log dirty */ -int paging_log_dirty_disable(struct domain *d); - /* log dirty initialization */ void paging_log_dirty_init(struct domain *d, int (*enable_log_dirty)(struct domain *d, @@ -203,10 +197,13 @@ int paging_domain_init(struct domain *d, * and disable ephemeral shadow modes (test mode and log-dirty mode) and * manipulate the log-dirty bitmap. */ int paging_domctl(struct domain *d, xen_domctl_shadow_op_t *sc, - XEN_GUEST_HANDLE_PARAM(void) u_domctl); + XEN_GUEST_HANDLE_PARAM(void) u_domctl, bool_t resuming);= + +/* Helper hypercall for dealing with continuations. */ +long paging_domctl_continuation(XEN_GUEST_HANDLE_PARAM(xen_domctl_t)); =20 /* Call when destroying a domain */ -void paging_teardown(struct domain *d); +int paging_teardown(struct domain *d); =20 /* Call once all of the references to the domain have gone away */ void paging_final_teardown(struct domain *d); --=__Part7C490801.1__= Content-Type: text/plain; name="xsa97-HAP.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xsa97-HAP.patch" x86/paging: make log-dirty operations preemptible=0A=0ABoth the freeing = and the inspection of the bitmap get done in (nested)=0Aloops which - = besides having a rather high iteration count in general,=0Aalbeit that = would be covered by XSA-77 - have the number of non-trivial=0Aiterations = they need to perform (indirectly) controllable by both the=0Aguest they = are for and any domain controlling the guest (including the=0Aone running = qemu for it).=0A=0ANote that the tying of the continuations to the = invoking domain (which=0Apreviously [wrongly] used the invoking vCPU = instead) implies that the=0Atools requesting such operations have to make = sure they don't issue=0Amultiple similar operations in parallel.=0A=0ANote = further that this breaks supervisor-mode kernel assumptions in=0Ahypercall_= create_continuation() (where regs->eip gets rewound to the=0Acurrent = hypercall stub beginning), but otoh=0Ahypercall_cancel_continuation() = doesn't work in that mode either.=0APerhaps time to rip out all the = remains of that feature?=0A=0AThis is part of CVE-2014-5146 / XSA-97.=0A=0A= Signed-off-by: Jan Beulich =0AReviewed-by: Tim Deegan = =0A---=0Av6: Move stats (dirty_count and fault_count) zeroing = to the final=0A success exit path (also fixing pre-existing issues with = them=0A getting cleaned but an error getting detected/reported = later).=0Av5: Also wire up helper hypercall in HVM/PVH hypercall tables = (pointed=0A out by Tim).=0Av4: Fold in Andrew's paging_mode_log_dirty() = guarding adjustments to=0A paging_log_dirty_disable() and its caller. = Convert tying=0A continuations to domain (was vCPU). Introduce a = separate internal=0A hypercall (__HYPERCALL_arch_1) to deal with the = continuation (both=0A suggested by Tim and Andrew). As a result = hap_domctl() and=0A shadow_domctl() now don't propagate -ERESTART into = paging_domctl()=0A anymore, as that would imply setting d->arch.paging.p= reempt fields=0A without holding the paging lock. Sadly this results in = mixed=0A methods used for continuations here.=0Av3: Convert if(!resuming= ) to ASSERT() in paging_log_dirty_op().=0Av2: Re-order L4 loop continuation= /termination handling in=0A paging_free_log_dirty_bitmap(). Add an = ASSERT() in a special case=0A exit path of paging_log_dirty_op().=0A=0A-= -- a/xen/arch/x86/domain.c=0A+++ b/xen/arch/x86/domain.c=0A@@ -1941,7 = +1941,9 @@ int domain_relinquish_resources(struct d=0A pci_release_= devices(d);=0A =0A /* Tear down paging-assistance stuff. */=0A- = paging_teardown(d);=0A+ ret =3D paging_teardown(d);=0A+ = if ( ret )=0A+ return ret;=0A =0A /* Drop the in-use = references to page-table bases. */=0A for_each_vcpu ( d, v )=0A--- = a/xen/arch/x86/domctl.c=0A+++ b/xen/arch/x86/domctl.c=0A@@ -61,9 +61,11 @@ = long arch_do_domctl(=0A =0A case XEN_DOMCTL_shadow_op:=0A {=0A- = ret =3D paging_domctl(d,=0A- &domctl->u.shad= ow_op,=0A- guest_handle_cast(u_domctl, = void));=0A+ ret =3D paging_domctl(d, &domctl->u.shadow_op,=0A+ = guest_handle_cast(u_domctl, void), 0);=0A+ if = ( ret =3D=3D -ERESTART )=0A+ return hypercall_create_continuatio= n(__HYPERVISOR_arch_1,=0A+ = "h", u_domctl);=0A copyback =3D 1;=0A }=0A break;=0A--- = a/xen/arch/x86/hvm/hvm.c=0A+++ b/xen/arch/x86/hvm/hvm.c=0A@@ -4770,7 = +4770,8 @@ static hvm_hypercall_t *const hvm_hyperc=0A HYPERCALL(hvm_op= ),=0A HYPERCALL(sysctl),=0A HYPERCALL(domctl),=0A- HYPERCALL(tme= m_op)=0A+ HYPERCALL(tmem_op),=0A+ [ __HYPERVISOR_arch_1 ] =3D = (hvm_hypercall_t *)paging_domctl_continuation=0A };=0A =0A #define = COMPAT_CALL(x) \=0A@@ -4790,7 = +4791,8 @@ static hvm_hypercall_t *const hvm_hyperc=0A HYPERCALL(hvm_op= ),=0A HYPERCALL(sysctl),=0A HYPERCALL(domctl),=0A- HYPERCALL(tme= m_op)=0A+ HYPERCALL(tmem_op),=0A+ [ __HYPERVISOR_arch_1 ] =3D = (hvm_hypercall_t *)paging_domctl_continuation=0A };=0A =0A /* PVH = 32bitfixme. */=0A@@ -4808,7 +4810,8 @@ static hvm_hypercall_t *const = pvh_hyperc=0A [ __HYPERVISOR_physdev_op ] =3D (hvm_hypercall_t = *)hvm_physdev_op,=0A HYPERCALL(hvm_op),=0A HYPERCALL(sysctl),=0A- = HYPERCALL(domctl)=0A+ HYPERCALL(domctl),=0A+ [ __HYPERVISOR_arch_1 = ] =3D (hvm_hypercall_t *)paging_domctl_continuation=0A };=0A =0A int = hvm_do_hypercall(struct cpu_user_regs *regs)=0A--- a/xen/arch/x86/mm/paging= .c=0A+++ b/xen/arch/x86/mm/paging.c=0A@@ -26,6 +26,7 @@=0A #include = =0A #include =0A #include =0A+#include = =0A #include =0A #include =0A= #include =0A@@ -116,26 +117,46 @@ static void paging_free_log_d= irty_page(s=0A d->arch.paging.free_page(d, mfn_to_page(mfn));=0A }=0A = =0A-void paging_free_log_dirty_bitmap(struct domain *d)=0A+static int = paging_free_log_dirty_bitmap(struct domain *d, int rc)=0A {=0A mfn_t = *l4, *l3, *l2;=0A int i4, i3, i2;=0A =0A+ paging_lock(d);=0A+=0A = if ( !mfn_valid(d->arch.paging.log_dirty.top) )=0A- return;=0A+ = {=0A+ paging_unlock(d);=0A+ return 0;=0A+ }=0A =0A- = paging_lock(d);=0A+ if ( !d->arch.paging.preempt.dom )=0A+ {=0A+ = memset(&d->arch.paging.preempt.log_dirty, 0,=0A+ = sizeof(d->arch.paging.preempt.log_dirty));=0A+ ASSERT(rc <=3D = 0);=0A+ d->arch.paging.preempt.log_dirty.done =3D -rc;=0A+ }=0A+ = else if ( d->arch.paging.preempt.dom !=3D current->domain ||=0A+ = d->arch.paging.preempt.op !=3D XEN_DOMCTL_SHADOW_OP_OFF )=0A+ = {=0A+ paging_unlock(d);=0A+ return -EBUSY;=0A+ }=0A =0A = l4 =3D map_domain_page(mfn_x(d->arch.paging.log_dirty.top));=0A+ i4 = =3D d->arch.paging.preempt.log_dirty.i4;=0A+ i3 =3D d->arch.paging.preem= pt.log_dirty.i3;=0A+ rc =3D 0;=0A =0A- for ( i4 =3D 0; i4 < = LOGDIRTY_NODE_ENTRIES; i4++ )=0A+ for ( ; i4 < LOGDIRTY_NODE_ENTRIES; = i4++, i3 =3D 0 )=0A {=0A if ( !mfn_valid(l4[i4]) )=0A = continue;=0A =0A l3 =3D map_domain_page(mfn_x(l4[i4]));=0A =0A- = for ( i3 =3D 0; i3 < LOGDIRTY_NODE_ENTRIES; i3++ )=0A+ for ( = ; i3 < LOGDIRTY_NODE_ENTRIES; i3++ )=0A {=0A if ( = !mfn_valid(l3[i3]) )=0A continue;=0A@@ -148,20 +169,54 @@ = void paging_free_log_dirty_bitmap(struct=0A =0A unmap_domain_pa= ge(l2);=0A paging_free_log_dirty_page(d, l3[i3]);=0A+ = l3[i3] =3D _mfn(INVALID_MFN);=0A+=0A+ if ( i3 < LOGDIRTY_NODE_= ENTRIES - 1 && hypercall_preempt_check() )=0A+ {=0A+ = d->arch.paging.preempt.log_dirty.i3 =3D i3 + 1;=0A+ = d->arch.paging.preempt.log_dirty.i4 =3D i4;=0A+ rc =3D = -ERESTART;=0A+ break;=0A+ }=0A }=0A =0A = unmap_domain_page(l3);=0A+ if ( rc )=0A+ = break;=0A paging_free_log_dirty_page(d, l4[i4]);=0A+ l4[i4] = =3D _mfn(INVALID_MFN);=0A+=0A+ if ( i4 < LOGDIRTY_NODE_ENTRIES - 1 = && hypercall_preempt_check() )=0A+ {=0A+ d->arch.paging.p= reempt.log_dirty.i3 =3D 0;=0A+ d->arch.paging.preempt.log_dirty.= i4 =3D i4 + 1;=0A+ rc =3D -ERESTART;=0A+ break;=0A+ = }=0A }=0A =0A unmap_domain_page(l4);=0A- paging_free_log_d= irty_page(d, d->arch.paging.log_dirty.top);=0A- d->arch.paging.log_dirty= .top =3D _mfn(INVALID_MFN);=0A =0A- ASSERT(d->arch.paging.log_dirty.allo= cs =3D=3D 0);=0A- d->arch.paging.log_dirty.failed_allocs =3D 0;=0A+ = if ( !rc )=0A+ {=0A+ paging_free_log_dirty_page(d, d->arch.paging= .log_dirty.top);=0A+ d->arch.paging.log_dirty.top =3D _mfn(INVALID_M= FN);=0A+=0A+ ASSERT(d->arch.paging.log_dirty.allocs =3D=3D 0);=0A+ = d->arch.paging.log_dirty.failed_allocs =3D 0;=0A+=0A+ rc =3D = -d->arch.paging.preempt.log_dirty.done;=0A+ d->arch.paging.preempt.d= om =3D NULL;=0A+ }=0A+ else=0A+ {=0A+ d->arch.paging.preemp= t.dom =3D current->domain;=0A+ d->arch.paging.preempt.op =3D = XEN_DOMCTL_SHADOW_OP_OFF;=0A+ }=0A =0A paging_unlock(d);=0A+=0A+ = return rc;=0A }=0A =0A int paging_log_dirty_enable(struct domain *d, = bool_t log_global)=0A@@ -187,15 +242,25 @@ int paging_log_dirty_enable(stru= ct domai=0A return ret;=0A }=0A =0A-int paging_log_dirty_disable(struct= domain *d)=0A+static int paging_log_dirty_disable(struct domain *d, = bool_t resuming)=0A {=0A- int ret;=0A+ int ret =3D 1;=0A+=0A+ if = ( !resuming )=0A+ {=0A+ domain_pause(d);=0A+ /* Safe = because the domain is paused. */=0A+ if ( paging_mode_log_dirty(d) = )=0A+ {=0A+ ret =3D d->arch.paging.log_dirty.disable_log_= dirty(d);=0A+ ASSERT(ret <=3D 0);=0A+ }=0A+ }=0A+=0A+ = ret =3D paging_free_log_dirty_bitmap(d, ret);=0A+ if ( ret =3D=3D = -ERESTART )=0A+ return ret;=0A =0A- domain_pause(d);=0A- /* = Safe because the domain is paused. */=0A- ret =3D d->arch.paging.log_dir= ty.disable_log_dirty(d);=0A- if ( !paging_mode_log_dirty(d) )=0A- = paging_free_log_dirty_bitmap(d);=0A domain_unpause(d);=0A =0A = return ret;=0A@@ -335,7 +400,9 @@ int paging_mfn_is_dirty(struct domain = *d=0A =0A /* Read a domain's log-dirty bitmap and stats. If the operation = is a CLEAN,=0A * clear the bitmap and stats as well. */=0A-int paging_log_= dirty_op(struct domain *d, struct xen_domctl_shadow_op *sc)=0A+static int = paging_log_dirty_op(struct domain *d,=0A+ = struct xen_domctl_shadow_op *sc,=0A+ bool_t = resuming)=0A {=0A int rv =3D 0, clean =3D 0, peek =3D 1;=0A = unsigned long pages =3D 0;=0A@@ -343,9 +410,22 @@ int paging_log_dirty_op(s= truct domain *d=0A unsigned long *l1 =3D NULL;=0A int i4, i3, = i2;=0A =0A- domain_pause(d);=0A+ if ( !resuming )=0A+ = domain_pause(d);=0A paging_lock(d);=0A =0A+ if ( !d->arch.paging.pre= empt.dom )=0A+ memset(&d->arch.paging.preempt.log_dirty, 0,=0A+ = sizeof(d->arch.paging.preempt.log_dirty));=0A+ else if ( = d->arch.paging.preempt.dom !=3D current->domain ||=0A+ = d->arch.paging.preempt.op !=3D sc->op )=0A+ {=0A+ paging_unlock(d= );=0A+ ASSERT(!resuming);=0A+ domain_unpause(d);=0A+ = return -EBUSY;=0A+ }=0A+=0A clean =3D (sc->op =3D=3D XEN_DOMCTL_SHAD= OW_OP_CLEAN);=0A =0A PAGING_DEBUG(LOGDIRTY, "log-dirty %s: dom %u = faults=3D%u dirty=3D%u\n",=0A@@ -357,12 +437,6 @@ int paging_log_dirty_op(s= truct domain *d=0A sc->stats.fault_count =3D d->arch.paging.log_dirty.f= ault_count;=0A sc->stats.dirty_count =3D d->arch.paging.log_dirty.dirty= _count;=0A =0A- if ( clean )=0A- {=0A- d->arch.paging.log_dirt= y.fault_count =3D 0;=0A- d->arch.paging.log_dirty.dirty_count =3D = 0;=0A- }=0A-=0A if ( guest_handle_is_null(sc->dirty_bitmap) )=0A = /* caller may have wanted just to clean the state or access stats. = */=0A peek =3D 0;=0A@@ -374,17 +448,15 @@ int paging_log_dirty_op(s= truct domain *d=0A goto out;=0A }=0A =0A- pages =3D 0;=0A = l4 =3D paging_map_log_dirty_bitmap(d);=0A+ i4 =3D d->arch.paging.preem= pt.log_dirty.i4;=0A+ i3 =3D d->arch.paging.preempt.log_dirty.i3;=0A+ = pages =3D d->arch.paging.preempt.log_dirty.done;=0A =0A- for ( i4 =3D = 0;=0A- (pages < sc->pages) && (i4 < LOGDIRTY_NODE_ENTRIES);=0A- = i4++ )=0A+ for ( ; (pages < sc->pages) && (i4 < LOGDIRTY_NODE_ENT= RIES); i4++, i3 =3D 0 )=0A {=0A l3 =3D (l4 && mfn_valid(l4[i4])= ) ? map_domain_page(mfn_x(l4[i4])) : NULL;=0A- for ( i3 =3D 0;=0A- = (pages < sc->pages) && (i3 < LOGDIRTY_NODE_ENTRIES);=0A- = i3++ )=0A+ for ( ; (pages < sc->pages) && (i3 < LOGDIRTY_NODE= _ENTRIES); i3++ )=0A {=0A l2 =3D ((l3 && mfn_valid(l3[i= 3])) ?=0A map_domain_page(mfn_x(l3[i3])) : NULL);=0A@@ = -419,18 +491,58 @@ int paging_log_dirty_op(struct domain *d=0A = }=0A if ( l2 )=0A unmap_domain_page(l2);=0A+=0A= + if ( i3 < LOGDIRTY_NODE_ENTRIES - 1 && hypercall_preempt_check= () )=0A+ {=0A+ d->arch.paging.preempt.log_dirty.i= 4 =3D i4;=0A+ d->arch.paging.preempt.log_dirty.i3 =3D i3 + = 1;=0A+ rv =3D -ERESTART;=0A+ break;=0A+ = }=0A }=0A if ( l3 )=0A unmap_domain_page(= l3);=0A+=0A+ if ( !rv && i4 < LOGDIRTY_NODE_ENTRIES - 1 &&=0A+ = hypercall_preempt_check() )=0A+ {=0A+ d->arch.pagi= ng.preempt.log_dirty.i4 =3D i4 + 1;=0A+ d->arch.paging.preempt.l= og_dirty.i3 =3D 0;=0A+ rv =3D -ERESTART;=0A+ }=0A+ = if ( rv )=0A+ break;=0A }=0A if ( l4 )=0A = unmap_domain_page(l4);=0A =0A- if ( pages < sc->pages )=0A- = sc->pages =3D pages;=0A+ if ( !rv )=0A+ {=0A+ d->arch.paging.p= reempt.dom =3D NULL;=0A+ if ( clean )=0A+ {=0A+ = d->arch.paging.log_dirty.fault_count =3D 0;=0A+ d->arch.paging.l= og_dirty.dirty_count =3D 0;=0A+ }=0A+ }=0A+ else=0A+ {=0A+ = d->arch.paging.preempt.dom =3D current->domain;=0A+ = d->arch.paging.preempt.op =3D sc->op;=0A+ d->arch.paging.preempt.log= _dirty.done =3D pages;=0A+ }=0A =0A paging_unlock(d);=0A =0A+ if = ( rv )=0A+ {=0A+ /* Never leave the domain paused on real = errors. */=0A+ ASSERT(rv =3D=3D -ERESTART);=0A+ return = rv;=0A+ }=0A+=0A+ if ( pages < sc->pages )=0A+ sc->pages =3D = pages;=0A if ( clean )=0A {=0A /* We need to further call = clean_dirty_bitmap() functions of specific=0A@@ -441,6 +553,7 @@ int = paging_log_dirty_op(struct domain *d=0A return rv;=0A =0A out:=0A+ = d->arch.paging.preempt.dom =3D NULL;=0A paging_unlock(d);=0A = domain_unpause(d);=0A =0A@@ -504,12 +617,6 @@ void paging_log_dirty_init(st= ruct domain=0A d->arch.paging.log_dirty.clean_dirty_bitmap =3D = clean_dirty_bitmap;=0A }=0A =0A-/* This function fress log dirty bitmap = resources. */=0A-static void paging_log_dirty_teardown(struct domain*d)=0A-= {=0A- paging_free_log_dirty_bitmap(d);=0A-}=0A-=0A /********************= ****************************/=0A /* CODE FOR PAGING SUPPORT = */=0A /************************************************/=0A@@ -551,7 = +658,7 @@ void paging_vcpu_init(struct vcpu *v)=0A =0A =0A int paging_domct= l(struct domain *d, xen_domctl_shadow_op_t *sc,=0A- = XEN_GUEST_HANDLE_PARAM(void) u_domctl)=0A+ XEN_GUEST_HANDL= E_PARAM(void) u_domctl, bool_t resuming)=0A {=0A int rc;=0A =0A@@ = -575,6 +682,20 @@ int paging_domctl(struct domain *d, xen_=0A = return -EINVAL;=0A }=0A =0A+ if ( resuming=0A+ ? (d->arch.pa= ging.preempt.dom !=3D current->domain ||=0A+ d->arch.paging.pree= mpt.op !=3D sc->op)=0A+ : (d->arch.paging.preempt.dom &&=0A+ = sc->op !=3D XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION) )=0A+ {=0A+ = printk(XENLOG_G_DEBUG=0A+ "%pv: Paging op %#x on Dom%u with = unfinished prior op %#x by Dom%u\n",=0A+ current, sc->op, = d->domain_id, d->arch.paging.preempt.op,=0A+ d->arch.paging.p= reempt.dom=0A+ ? d->arch.paging.preempt.dom->domain_id : = DOMID_INVALID);=0A+ return -EBUSY;=0A+ }=0A+=0A rc =3D = xsm_shadow_control(XSM_HOOK, d, sc->op);=0A if ( rc )=0A = return rc;=0A@@ -597,14 +718,13 @@ int paging_domctl(struct domain *d, = xen_=0A return paging_log_dirty_enable(d, 1);=0A =0A case = XEN_DOMCTL_SHADOW_OP_OFF:=0A- if ( paging_mode_log_dirty(d) )=0A- = if ( (rc =3D paging_log_dirty_disable(d)) !=3D 0 )=0A- = return rc;=0A+ if ( (rc =3D paging_log_dirty_disable(d, = resuming)) !=3D 0 )=0A+ return rc;=0A break;=0A =0A = case XEN_DOMCTL_SHADOW_OP_CLEAN:=0A case XEN_DOMCTL_SHADOW_OP_PEEK:=0A-= return paging_log_dirty_op(d, sc);=0A+ return paging_log_dir= ty_op(d, sc, resuming);=0A }=0A =0A /* Here, dispatch domctl to = the appropriate paging code */=0A@@ -614,19 +734,67 @@ int paging_domctl(st= ruct domain *d, xen_=0A return shadow_domctl(d, sc, u_domctl);=0A = }=0A =0A+long paging_domctl_continuation(XEN_GUEST_HANDLE_PARAM(xen_domctl_= t) u_domctl)=0A+{=0A+ struct xen_domctl op;=0A+ struct domain = *d;=0A+ int ret;=0A+=0A+ if ( copy_from_guest(&op, u_domctl, 1) = )=0A+ return -EFAULT;=0A+=0A+ if ( op.interface_version !=3D = XEN_DOMCTL_INTERFACE_VERSION ||=0A+ op.cmd !=3D XEN_DOMCTL_shadow_o= p )=0A+ return -EBADRQC;=0A+=0A+ d =3D rcu_lock_domain_by_id(op.d= omain);=0A+ if ( d =3D=3D NULL )=0A+ return -ESRCH;=0A+=0A+ = ret =3D xsm_domctl(XSM_OTHER, d, op.cmd);=0A+ if ( !ret )=0A+ {=0A+ = if ( domctl_lock_acquire() )=0A+ {=0A+ ret =3D = paging_domctl(d, &op.u.shadow_op,=0A+ = guest_handle_cast(u_domctl, void), 1);=0A+=0A+ domctl_lock_relea= se();=0A+ }=0A+ else=0A+ ret =3D -ERESTART;=0A+ = }=0A+=0A+ rcu_unlock_domain(d);=0A+=0A+ if ( ret =3D=3D -ERESTART = )=0A+ ret =3D hypercall_create_continuation(__HYPERVISOR_arch_1,=0A+= "h", u_domctl);=0A+ else if = ( __copy_field_to_guest(u_domctl, &op, u.shadow_op) )=0A+ ret =3D = -EFAULT;=0A+=0A+ return ret;=0A+}=0A+=0A /* Call when destroying a = domain */=0A-void paging_teardown(struct domain *d)=0A+int paging_teardown(= struct domain *d)=0A {=0A+ int rc;=0A+=0A if ( hap_enabled(d) )=0A = hap_teardown(d);=0A else=0A shadow_teardown(d);=0A =0A = /* clean up log dirty resources. */=0A- paging_log_dirty_teardown(d);= =0A+ rc =3D paging_free_log_dirty_bitmap(d, 0);=0A+ if ( rc =3D=3D = -ERESTART )=0A+ return rc;=0A =0A /* Move populate-on-demand = cache back to domain_list for destruction */=0A p2m_pod_empty_cache(d);= =0A+=0A+ return rc;=0A }=0A =0A /* Call once all of the references to = the domain have gone away */=0A--- a/xen/arch/x86/x86_64/compat/entry.S=0A+= ++ b/xen/arch/x86/x86_64/compat/entry.S=0A@@ -421,6 +421,7 @@ ENTRY(compat_= hypercall_table)=0A .quad compat_ni_hypercall=0A .endr=0A = .quad do_mca /* 48 */=0A+ .quad paging_dom= ctl_continuation=0A .rept NR_hypercalls-((.-compat_hypercall_table)= /8)=0A .quad compat_ni_hypercall=0A .endr=0A@@ -469,6 = +470,7 @@ ENTRY(compat_hypercall_args_table)=0A .byte 0 /* = compat_ni_hypercall */=0A .endr=0A .byte 1 /* do_mca = */=0A+ .byte 1 /* paging_domctl_continuation = */=0A .rept NR_hypercalls-(.-compat_hypercall_args_table)=0A = .byte 0 /* compat_ni_hypercall */=0A .endr=0A--- a/xen/arch/= x86/x86_64/entry.S=0A+++ b/xen/arch/x86/x86_64/entry.S=0A@@ -776,6 +776,7 = @@ ENTRY(hypercall_table)=0A .quad do_ni_hypercall=0A = .endr=0A .quad do_mca /* 48 */=0A+ .quad = paging_domctl_continuation=0A .rept NR_hypercalls-((.-hypercall_tab= le)/8)=0A .quad do_ni_hypercall=0A .endr=0A@@ -824,6 = +825,7 @@ ENTRY(hypercall_args_table)=0A .byte 0 /* do_ni_hypercall= */=0A .endr=0A .byte 1 /* do_mca */ = /* 48 */=0A+ .byte 1 /* paging_domctl_continuation */=0A = .rept NR_hypercalls-(.-hypercall_args_table)=0A .byte 0 /* = do_ni_hypercall */=0A .endr=0A--- a/xen/common/domain.c=0A+++ = b/xen/common/domain.c=0A@@ -619,7 +619,6 @@ int domain_kill(struct domain = *d)=0A {=0A if ( rc =3D=3D -ERESTART )=0A = rc =3D -EAGAIN;=0A- BUG_ON(rc !=3D -EAGAIN);=0A = break;=0A }=0A if ( sched_move_domain(d, cpupool0) )=0A--- = a/xen/include/asm-x86/domain.h=0A+++ b/xen/include/asm-x86/domain.h=0A@@ = -187,6 +187,20 @@ struct paging_domain {=0A struct hap_domain = hap;=0A /* log dirty support */=0A struct log_dirty_domain = log_dirty;=0A+=0A+ /* preemption handling */=0A+ struct {=0A+ = const struct domain *dom;=0A+ unsigned int op;=0A+ union = {=0A+ struct {=0A+ unsigned long done:PADDR_BITS = - PAGE_SHIFT;=0A+ unsigned long i4:PAGETABLE_ORDER;=0A+ = unsigned long i3:PAGETABLE_ORDER;=0A+ } log_dirty;=0A= + };=0A+ } preempt;=0A+=0A /* alloc/free pages from the pool = for paging-assistance structures=0A * (used by p2m and log-dirty code = for their tries) */=0A struct page_info * (*alloc_page)(struct domain = *d);=0A--- a/xen/include/asm-x86/paging.h=0A+++ b/xen/include/asm-x86/pagin= g.h=0A@@ -132,9 +132,6 @@ struct paging_mode {=0A /************************= *****************************************************=0A * Log dirty code = */=0A =0A-/* free log dirty bitmap resource */=0A-void paging_free_log_dirt= y_bitmap(struct domain *d);=0A-=0A /* get the dirty bitmap for a specific = range of pfns */=0A void paging_log_dirty_range(struct domain *d,=0A = unsigned long begin_pfn,=0A@@ -144,9 +141,6 @@ void = paging_log_dirty_range(struct domai=0A /* enable log dirty */=0A int = paging_log_dirty_enable(struct domain *d, bool_t log_global);=0A =0A-/* = disable log dirty */=0A-int paging_log_dirty_disable(struct domain = *d);=0A-=0A /* log dirty initialization */=0A void paging_log_dirty_init(st= ruct domain *d,=0A int (*enable_log_dirty)(stru= ct domain *d,=0A@@ -203,10 +197,13 @@ int paging_domain_init(struct domain = *d,=0A * and disable ephemeral shadow modes (test mode and log-dirty = mode) and=0A * manipulate the log-dirty bitmap. */=0A int paging_domctl(st= ruct domain *d, xen_domctl_shadow_op_t *sc,=0A- XEN_GUEST_= HANDLE_PARAM(void) u_domctl);=0A+ XEN_GUEST_HANDLE_PARAM(v= oid) u_domctl, bool_t resuming);=0A+=0A+/* Helper hypercall for dealing = with continuations. */=0A+long paging_domctl_continuation(XEN_GUEST_HANDLE_= PARAM(xen_domctl_t));=0A =0A /* Call when destroying a domain */=0A-void = paging_teardown(struct domain *d);=0A+int paging_teardown(struct domain = *d);=0A =0A /* Call once all of the references to the domain have gone = away */=0A void paging_final_teardown(struct domain *d);=0A --=__Part7C490801.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part7C490801.1__=--