From 7806d251be609a039b7e4ea0e2ebf1f415f8cc59 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 28 Jun 2015 16:36:30 +0000 Subject: [PATCH] xen: syswrap XEN_DOMCTL_[gs]et_ext_vcpustate The VKI_XEN_DOMCTL_[gs]et_ext_vcpucontext hypercalls have had interface changes, but are largly just extentions of the existing structure. Signed-off-by: Andrew Cooper git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15369 --- coregrind/m_syswrap/syswrap-xen.c | 139 ++++++++++++++++++++++++++++++++++++++ include/vki/vki-xen-domctl.h | 41 ++++++++++- 2 files changed, 179 insertions(+), 1 deletion(-) diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c index f51191d2b..317705570 100644 --- a/coregrind/m_syswrap/syswrap-xen.c +++ b/coregrind/m_syswrap/syswrap-xen.c @@ -790,6 +790,92 @@ PRE(domctl) __PRE_XEN_DOMCTL_READ(setvcpucontext, vcpucontext, ctxt.p); break; + case VKI_XEN_DOMCTL_get_ext_vcpucontext: + switch (domctl->interface_version) + { + case 0x00000007: + case 0x00000008: + __PRE_XEN_DOMCTL_READ(get_ext_vcpucontext, ext_vcpucontext_00000008, vcpu); + break; + + case 0x00000009: + __PRE_XEN_DOMCTL_READ(get_ext_vcpucontext, ext_vcpucontext_00000009, vcpu); + break; + + default: + VG_(dmsg)("WARNING: VKI_XEN_DOMCTL_get_ext_vcpucontext domctl version %#" + PRIx32" not implemented\n", domctl->interface_version); + SET_STATUS_Failure(VKI_EINVAL); + break; + } + break; + + case VKI_XEN_DOMCTL_set_ext_vcpucontext: + switch (domctl->interface_version) + { + case 0x00000007: + case 0x00000008: + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000008, vcpu); + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000008, size); +#if defined(__i386__) || defined(__x86_64__) + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000008, + syscall32_callback_eip); + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000008, + sysenter_callback_eip); + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000008, + syscall32_callback_cs); + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000008, + sysenter_callback_cs); + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000008, + syscall32_disables_events); + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000008, + sysenter_disables_events); + + if ( domctl->u.ext_vcpucontext_00000008.size >= + offsetof(struct vki_xen_domctl_ext_vcpucontext_00000008, mcg_cap) ) + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000008, + mcg_cap); +#endif + break; + + case 0x00000009: + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000009, vcpu); + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000009, size); +#if defined(__i386__) || defined(__x86_64__) + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000009, + syscall32_callback_eip); + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000009, + sysenter_callback_eip); + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000009, + syscall32_callback_cs); + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000009, + sysenter_callback_cs); + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000009, + syscall32_disables_events); + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000009, + sysenter_disables_events); + + if ( domctl->u.ext_vcpucontext_00000009.size >= + offsetof(struct vki_xen_domctl_ext_vcpucontext_00000009, caps) ) + { + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000009, + caps); + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000009, + mci_ctl2_bank0); + __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000009, + mci_ctl2_bank1); + } +#endif + break; + + default: + VG_(dmsg)("WARNING: VKI_XEN_DOMCTL_set_ext_vcpucontext domctl version %#" + PRIx32" not implemented\n", domctl->interface_version); + SET_STATUS_Failure(VKI_EINVAL); + break; + } + break; + case VKI_XEN_DOMCTL_set_cpuid: PRE_MEM_READ("XEN_DOMCTL_set_cpuid u.cpuid", (Addr)&domctl->u.cpuid, sizeof(domctl->u.cpuid)); @@ -1324,6 +1410,7 @@ POST(domctl){ case VKI_XEN_DOMCTL_ioport_permission: case VKI_XEN_DOMCTL_hypercall_init: case VKI_XEN_DOMCTL_setvcpucontext: + case VKI_XEN_DOMCTL_set_ext_vcpucontext: case VKI_XEN_DOMCTL_setnodeaffinity: case VKI_XEN_DOMCTL_set_cpuid: case VKI_XEN_DOMCTL_unpausedomain: @@ -1491,6 +1578,58 @@ POST(domctl){ domctl->u.getpageframeinfo3.num * sizeof(vki_xen_pfn_t)); break; + case VKI_XEN_DOMCTL_get_ext_vcpucontext: + switch (domctl->interface_version) + { + case 0x00000007: + case 0x00000008: + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000008, size); +#if defined(__i386__) || defined(__x86_64__) + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000008, + syscall32_callback_eip); + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000008, + sysenter_callback_eip); + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000008, + syscall32_callback_cs); + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000008, + sysenter_callback_cs); + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000008, + syscall32_disables_events); + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000008, + sysenter_disables_events); + + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000008, + mcg_cap); +#endif + break; + + case 0x00000009: + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000009, size); +#if defined(__i386__) || defined(__x86_64__) + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000009, + syscall32_callback_eip); + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000009, + sysenter_callback_eip); + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000009, + syscall32_callback_cs); + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000009, + sysenter_callback_cs); + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000009, + syscall32_disables_events); + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000009, + sysenter_disables_events); + + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000009, + caps); + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000009, + mci_ctl2_bank0); + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000009, + mci_ctl2_bank1); +#endif + break; + } + break; + case VKI_XEN_DOMCTL_getvcpuextstate: if (domctl->u.vcpuextstate.buffer.p) diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h index 5e9902b8f..3b8c28b9e 100644 --- a/include/vki/vki-xen-domctl.h +++ b/include/vki/vki-xen-domctl.h @@ -330,6 +330,44 @@ struct vki_xen_domctl_tsc_info { vki_xen_guest_tsc_info_t info; /* IN */ }; +struct vki_xen_domctl_ext_vcpucontext_00000008 { + vki_uint32_t vcpu; /* IN */ + + /* IN for XEN_DOMCTL_set_ext_vcpucontext + * OUT for XEN_DOMCTL_get_ext_vcpucontext */ + vki_uint32_t size; +#if defined(__i386__) || defined(__x86_64__) + vki_xen_uint64_aligned_t syscall32_callback_eip; + vki_xen_uint64_aligned_t sysenter_callback_eip; + vki_uint16_t syscall32_callback_cs; + vki_uint16_t sysenter_callback_cs; + vki_uint8_t syscall32_disables_events; + vki_uint8_t sysenter_disables_events; + vki_xen_uint64_aligned_t mcg_cap; +#endif +}; + +struct vki_xen_domctl_ext_vcpucontext_00000009 { + vki_uint32_t vcpu; /* IN */ + + /* IN for XEN_DOMCTL_set_ext_vcpucontext + * OUT for XEN_DOMCTL_get_ext_vcpucontext */ + vki_uint32_t size; +#if defined(__i386__) || defined(__x86_64__) + vki_xen_uint64_aligned_t syscall32_callback_eip; + vki_xen_uint64_aligned_t sysenter_callback_eip; + vki_uint16_t syscall32_callback_cs; + vki_uint16_t sysenter_callback_cs; + vki_uint8_t syscall32_disables_events; + vki_uint8_t sysenter_disables_events; + vki_uint64_t caps; + vki_uint64_t mci_ctl2_bank0; + vki_uint64_t mci_ctl2_bank1; +#endif +}; + +/* vki_xen_domctl_ext_vcpucontext_0000000a is the same as 00000009 */ + struct vki_xen_domctl_vcpuextstate { vki_uint32_t vcpu; vki_xen_uint64_aligned_t xfeature_mask; @@ -409,7 +447,8 @@ struct vki_xen_domctl { //struct vki_xen_domctl_memory_mapping memory_mapping; //struct vki_xen_domctl_ioport_mapping ioport_mapping; //struct vki_xen_domctl_pin_mem_cacheattr pin_mem_cacheattr; - //struct vki_xen_domctl_ext_vcpucontext ext_vcpucontext; + struct vki_xen_domctl_ext_vcpucontext_00000008 ext_vcpucontext_00000008; + struct vki_xen_domctl_ext_vcpucontext_00000009 ext_vcpucontext_00000009; //struct vki_xen_domctl_set_target set_target; //struct vki_xen_domctl_subscribe subscribe; struct vki_xen_domctl_debug_op debug_op; -- 2.11.4.GIT