File valgrind.xen-4.1-fix-XEN_DOMCTL_mem_event_op.patch of Package valgrind
From: Olaf Hering <olaf@aepfle.de>
Date: Wed, 26 Feb 2020 17:37:56 +0100
Subject: xen-4.1: fix XEN_DOMCTL_mem_event_op
In Xen 4.1 XEN_DOMCTL_mem_event_op had a different layout.
Fix the existing code to handle it correctly.
bz#390553
---
coregrind/m_syswrap/syswrap-xen.c | 7 +++++++
include/vki/vki-xen-domctl.h | 9 +++++++++
2 files changed, 16 insertions(+)
--- a/coregrind/m_syswrap/syswrap-xen.c
+++ b/coregrind/m_syswrap/syswrap-xen.c
@@ -1417,24 +1417,30 @@ PRE(domctl)
case VKI_XEN_DOMCTL_cacheflush:
PRE_XEN_DOMCTL_READ(cacheflush, start_pfn);
PRE_XEN_DOMCTL_READ(cacheflush, nr_pfns);
break;
case VKI_XEN_DOMCTL_set_access_required:
PRE_XEN_DOMCTL_READ(access_required, access_required);
break;
case VKI_XEN_DOMCTL_mem_event_op | VKI_XEN_DOMCTL_vm_event_op:
switch (domctl->interface_version) {
case 0x00000007:
+ __PRE_XEN_DOMCTL_READ(mem_event_op, mem_event_op_00000007, op);
+ __PRE_XEN_DOMCTL_READ(mem_event_op, mem_event_op_00000007, mode);
+ __PRE_XEN_DOMCTL_READ(mem_event_op, mem_event_op_00000007, shared_addr);
+ __PRE_XEN_DOMCTL_READ(mem_event_op, mem_event_op_00000007, ring_addr);
+ __PRE_XEN_DOMCTL_READ(mem_event_op, mem_event_op_00000007, gfn);
+ break;
case 0x00000008:
case 0x00000009:
case 0x0000000a:
case 0x0000000b:
case 0x0000000c:
case 0x0000000d:
case 0x0000000e:
case 0x0000000f:
case 0x00000010:
case 0x00000011:
__PRE_XEN_DOMCTL_READ(mem_event_op, vm_event_op_00000008, op);
__PRE_XEN_DOMCTL_READ(mem_event_op, vm_event_op_00000008, mode);
@@ -2447,24 +2453,25 @@ POST(domctl){
}
break;
case VKI_XEN_DOMCTL_get_vcpu_msrs:
if (domctl->u.vcpu_msrs.msrs.p)
POST_MEM_WRITE((Addr)domctl->u.vcpu_msrs.msrs.p,
sizeof(vki_xen_domctl_vcpu_msr_t) *
domctl->u.vcpu_msrs.msr_count);
break;
case VKI_XEN_DOMCTL_mem_event_op | VKI_XEN_DOMCTL_vm_event_op:
switch (domctl->interface_version) {
case 0x00000007:
+ break;
case 0x00000008:
case 0x00000009:
case 0x0000000a:
case 0x0000000b:
case 0x0000000c:
case 0x0000000d:
case 0x0000000e:
case 0x0000000f:
case 0x00000010:
case 0x00000011:
__POST_XEN_DOMCTL_WRITE(mem_event_op, vm_event_op_00000008, port);
break;
--- a/include/vki/vki-xen-domctl.h
+++ b/include/vki/vki-xen-domctl.h
@@ -497,24 +497,32 @@ struct vki_xen_domctl_assign_device_0000000b {
} u;
/* IN */
//#define XEN_DOMCTL_DEV_RDM_RELAXED 1
vki_uint32_t flag; /* flag of assigned device */
};
struct vki_xen_domctl_debug_op {
vki_uint32_t op; /* IN */
vki_uint32_t vcpu; /* IN */
};
typedef struct vki_xen_domctl_debug_op vki_xen_domctl_debug_op_t;
+struct vki_xen_domctl_mem_event_op_00000007 {
+ vki_uint32_t op; /* IN */
+ vki_uint32_t mode; /* IN */
+ __vki_aligned_u64 shared_addr; /* IN */
+ __vki_aligned_u64 ring_addr; /* IN */
+ __vki_aligned_u64 gfn; /* IN */
+};
+
struct vki_xen_domctl_vm_event_op_00000008 {
vki_uint32_t op; /* IN */
vki_uint32_t mode; /* IN */
vki_uint32_t port; /* OUT */
};
struct vki_xen_domctl_vm_event_op_00000012 {
vki_uint32_t op; /* IN */
vki_uint32_t mode; /* IN */
union {
struct {
@@ -700,24 +708,25 @@ struct vki_xen_domctl {
//struct vki_xen_domctl_get_device_group get_device_group;
struct vki_xen_domctl_assign_device_00000007 assign_device_00000007;
struct vki_xen_domctl_assign_device_0000000b assign_device_0000000b;
//struct vki_xen_domctl_bind_pt_irq bind_pt_irq;
//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_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;
+ struct vki_xen_domctl_mem_event_op_00000007 mem_event_op_00000007;
struct vki_xen_domctl_vm_event_op_00000008 vm_event_op_00000008;
struct vki_xen_domctl_vm_event_op_00000012 vm_event_op_00000012;
//struct vki_xen_domctl_mem_sharing_op mem_sharing_op;
#if defined(__i386__) || defined(__x86_64__)
struct vki_xen_domctl_cpuid cpuid;
struct vki_xen_domctl_vcpuextstate vcpuextstate;
struct vki_xen_domctl_vcpu_msrs vcpu_msrs;
#endif
struct vki_xen_domctl_set_access_required access_required;
//struct vki_xen_domctl_audit_p2m audit_p2m;
//struct vki_xen_domctl_set_virq_handler set_virq_handler;
struct vki_xen_domctl_set_max_evtchn set_max_evtchn;