From: Anthony Liguori <[email protected]> This is necessary to trigger event channel upcalls but it is also useful to passthrough the full version information such that the guest believes it is running on the parent Xen.
Signed-off-by: Matt Wilson <[email protected]> Signed-off-by: Anthony Liguori <[email protected]> --- xen/common/kernel.c | 82 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 12 deletions(-) diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 8d137c5..b9885c8 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -15,6 +15,7 @@ #include <xsm/xsm.h> #include <asm/current.h> #include <public/version.h> +#include <asm/guest/vixen.h> #ifndef COMPAT @@ -311,14 +312,32 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) switch ( cmd ) { case XENVER_version: - return (xen_major_version() << 16) | xen_minor_version(); + if ( is_vixen() ) + return HYPERVISOR_xen_version(XENVER_version, NULL); + else + return (xen_major_version() << 16) | xen_minor_version(); case XENVER_extraversion: { xen_extraversion_t extraversion; + int rc; memset(extraversion, 0, sizeof(extraversion)); - safe_strcpy(extraversion, deny ? xen_deny() : xen_extra_version()); + if ( is_vixen() ) + { + if ( deny ) + safe_strcpy(extraversion, xen_deny()); + else + { + rc = HYPERVISOR_xen_version(XENVER_extraversion, &extraversion); + if ( rc ) + return rc; + } + } + else + { + safe_strcpy(extraversion, deny ? xen_deny() : xen_extra_version()); + } if ( copy_to_guest(arg, extraversion, ARRAY_SIZE(extraversion)) ) return -EFAULT; return 0; @@ -327,12 +346,22 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) case XENVER_compile_info: { xen_compile_info_t info; + int rc; memset(&info, 0, sizeof(info)); - safe_strcpy(info.compiler, deny ? xen_deny() : xen_compiler()); - safe_strcpy(info.compile_by, deny ? xen_deny() : xen_compile_by()); - safe_strcpy(info.compile_domain, deny ? xen_deny() : xen_compile_domain()); - safe_strcpy(info.compile_date, deny ? xen_deny() : xen_compile_date()); + if ( is_vixen() ) + { + rc = HYPERVISOR_xen_version(XENVER_compile_info, &info); + if ( rc ) + return rc; + } + else + { + safe_strcpy(info.compiler, deny ? xen_deny() : xen_compiler()); + safe_strcpy(info.compile_by, deny ? xen_deny() : xen_compile_by()); + safe_strcpy(info.compile_domain, deny ? xen_deny() : xen_compile_domain()); + safe_strcpy(info.compile_date, deny ? xen_deny() : xen_compile_date()); + } if ( copy_to_guest(arg, &info, 1) ) return -EFAULT; return 0; @@ -366,9 +395,24 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) case XENVER_changeset: { xen_changeset_info_t chgset; + int rc; memset(chgset, 0, sizeof(chgset)); - safe_strcpy(chgset, deny ? xen_deny() : xen_changeset()); + if ( is_vixen() ) + { + if ( deny ) + safe_strcpy(chgset, xen_deny()); + else + { + rc = HYPERVISOR_xen_version(XENVER_changeset, &chgset); + if ( rc ) + return rc; + } + } + else + { + safe_strcpy(chgset, deny ? xen_deny() : xen_changeset()); + } if ( copy_to_guest(arg, chgset, ARRAY_SIZE(chgset)) ) return -EFAULT; return 0; @@ -430,15 +474,29 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) case XENVER_guest_handle: { xen_domain_handle_t hdl; + int rc; - if ( deny ) - memset(&hdl, 0, ARRAY_SIZE(hdl)); + memset(&hdl, 0, ARRAY_SIZE(hdl)); BUILD_BUG_ON(ARRAY_SIZE(current->domain->handle) != ARRAY_SIZE(hdl)); - if ( copy_to_guest(arg, deny ? hdl : current->domain->handle, - ARRAY_SIZE(hdl) ) ) - return -EFAULT; + if ( is_vixen () ) + { + if ( !deny ) + { + rc = HYPERVISOR_xen_version(XENVER_guest_handle, &hdl); + if ( rc ) + return rc; + } + if ( copy_to_guest(arg, hdl, ARRAY_SIZE(hdl) ) ) + return -EFAULT; + } + else + { + if ( copy_to_guest(arg, deny ? hdl : current->domain->handle, + ARRAY_SIZE(hdl) ) ) + return -EFAULT; + } return 0; } -- 1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
