Subject: xenpaging: allow only one xenpaging binary per guest Make sure only one xenpaging binary is active per domain. Print info when the host lacks the required features for xenpaging. (xen-unstable changeset: 22436:b153d3b71504) (xen-unstable changeset: 22511:fdf95845c2f8) Signed-off-by: Olaf Hering Already-Acked-by: Patrick Colp Already-Acked-by: Keir Fraser --- v2: use perror for default case tools/xenpaging/xenpaging.c | 12 +++++++++++- xen/arch/x86/mm/mem_event.c | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) Index: xen-4.0.2-testing/tools/xenpaging/xenpaging.c =================================================================== --- xen-4.0.2-testing.orig/tools/xenpaging/xenpaging.c +++ xen-4.0.2-testing/tools/xenpaging/xenpaging.c @@ -120,7 +120,17 @@ xenpaging_t *xenpaging_init(domid_t doma paging->mem_event.ring_page); if ( rc != 0 ) { - ERROR("Error initialising shared page"); + switch ( errno ) { + case EBUSY: + ERROR("xenpaging is (or was) active on this domain"); + break; + case ENODEV: + ERROR("EPT not supported for this guest"); + break; + default: + ERROR("Error initialising shared page: %s", strerror(errno)); + break; + } goto err; } Index: xen-4.0.2-testing/xen/arch/x86/mm/mem_event.c =================================================================== --- xen-4.0.2-testing.orig/xen/arch/x86/mm/mem_event.c +++ xen-4.0.2-testing/xen/arch/x86/mm/mem_event.c @@ -214,6 +214,13 @@ int mem_event_domctl(struct domain *d, x mfn_t ring_mfn; mfn_t shared_mfn; + /* Only one xenpaging at a time. If xenpaging crashed, + * the cache is in an undefined state and so is the guest + */ + rc = -EBUSY; + if ( d->mem_event.ring_page ) + break; + /* Currently only EPT is supported */ rc = -ENODEV; if ( !(is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled &&