Bug 339424 - Full support of KVM ioctl
Summary: Full support of KVM ioctl
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Christian Borntraeger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-26 11:48 UTC by Christian Borntraeger
Modified: 2016-11-29 09:27 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Borntraeger 2014-09-26 11:48:37 UTC
valgrind supports many of the ioctls from kernel based virtual machine (KVM).
This bug will track all remaining things.

Already working are several KVm ioctls via the IORW macros, as well as

VKI_KVM_CREATE_IRQCHIP
VKI_KVM_S390_ENABLE_SIE
VKI_KVM_S390_INITIAL_RESET
VKI_KVM_GET_API_VERSION
VKI_KVM_CREATE_VM
VKI_KVM_GET_VCPU_MMAP_SIZE
VKI_KVM_CHECK_EXTENSION
VKI_KVM_CREATE_VCPU
VKI_KVM_RUN

via specific handlers in syswrap-linux.c

Reproducible: Always

Steps to Reproduce:
3.10:  shows
Warning: noted but unhandled ioctl 0xae47 with no size/direction hints.

There are probably others. Will add later
Comment 1 Christian Borntraeger 2014-09-26 12:26:01 UTC
ae47 (KVM_SET_TSS_ADDR) fixed with Commit 14568.
Comment 2 Christian Borntraeger 2014-09-26 13:22:14 UTC
next on list:
Warning: noted but unhandled ioctl 0xaead with no size/direction hints
Comment 3 Christian Borntraeger 2014-09-26 18:45:32 UTC
aead (KVM_KVMCLOCK_CTRL) fixed with Commit 14569
Comment 4 Julian Seward 2015-02-02 23:35:02 UTC
Christian, is this bug still alive, or can it be closed?
Comment 5 Christian Borntraeger 2015-02-03 08:48:20 UTC
Its alive and I will continue to work on that, as soon as other things have settled again. sorry
Comment 6 Christian Borntraeger 2015-06-11 11:43:17 UTC
the new s390 memop ioctl causes several false positives:
I plan to apply this patch soon:

Index: coregrind/m_syswrap/syswrap-linux.c
===================================================================
--- coregrind/m_syswrap/syswrap-linux.c	(Revision 15332)
+++ coregrind/m_syswrap/syswrap-linux.c	(Arbeitskopie)
@@ -7220,6 +7220,21 @@
    case VKI_KVM_RUN:
       break;
 
+   case VKI_KVM_S390_MEM_OP: {
+      struct vki_kvm_s390_mem_op *args =
+         (struct vki_kvm_s390_mem_op *)(ARG3);
+      PRE_MEM_READ("ioctl(KVM_S390_MEM_OP)", ARG3,
+                   sizeof(struct vki_kvm_s390_mem_op));
+      if (args->flags & VKI_KVM_S390_MEMOP_F_CHECK_ONLY)
+         break;
+      if (args->op == VKI_KVM_S390_MEMOP_LOGICAL_READ)
+         PRE_MEM_WRITE("ioctl(KVM_S390_MEM_OP).buf", (Addr)args->buf, args->size);
+      if (args->op == VKI_KVM_S390_MEMOP_LOGICAL_WRITE)
+         PRE_MEM_READ("ioctl(KVM_S390_MEM_OP).buf", (Addr)args->buf, args->size);
+      }
+      break;
+
+
 #ifdef ENABLE_XEN
    case VKI_XEN_IOCTL_PRIVCMD_HYPERCALL: {
       SyscallArgs harrghs;
@@ -9614,6 +9629,18 @@
    case VKI_KVM_KVMCLOCK_CTRL:
       break;
 
+   case VKI_KVM_S390_MEM_OP: {
+      struct vki_kvm_s390_mem_op *args =
+         (struct vki_kvm_s390_mem_op *)(ARG3);
+      PRE_MEM_READ("ioctl(KVM_S390_MEM_OP)", ARG3,
+                   sizeof(struct vki_kvm_s390_mem_op));
+      if (args->flags & VKI_KVM_S390_MEMOP_F_CHECK_ONLY)
+         break;
+      if (args->op == VKI_KVM_S390_MEMOP_LOGICAL_READ)
+         POST_MEM_WRITE((Addr)args->buf, args->size);
+      }
+      break;
+
 #ifdef ENABLE_XEN
    case VKI_XEN_IOCTL_PRIVCMD_HYPERCALL: {
        SyscallArgs harrghs;
Index: include/vki/vki-linux.h
===================================================================
--- include/vki/vki-linux.h	(Revision 15332)
+++ include/vki/vki-linux.h	(Arbeitskopie)
@@ -3167,6 +3167,24 @@
 #define VKI_KVM_NMI                   _VKI_IO(KVMIO,   0x9a)
 #define VKI_KVM_KVMCLOCK_CTRL         _VKI_IO(KVMIO,   0xad)
 
+struct vki_kvm_s390_mem_op {
+        /* in */
+        __vki_u64 gaddr;            /* the guest address */
+        __vki_u64 flags;            /* flags */
+        __vki_u32 size;             /* amount of bytes */
+        __vki_u32 op;               /* type of operation */
+        __vki_u64 buf;              /* buffer in userspace */
+        __vki_u8 ar;                /* the access register number */
+        __vki_u8 reserved[31];      /* should be set to 0 */
+};
+
+#define VKI_KVM_S390_MEMOP_LOGICAL_READ		0
+#define VKI_KVM_S390_MEMOP_LOGICAL_WRITE	1
+#define VKI_KVM_S390_MEMOP_F_CHECK_ONLY		(1ULL << 0)
+#define VKI_KVM_S390_MEMOP_F_INJECT_EXCEPTION	(1ULL << 1)
+
+#define VKI_KVM_S390_MEM_OP           _VKI_IOW(KVMIO,  0xb1, struct vki_kvm_s390_mem_op)
+
 //----------------------------------------------------------------------
 // From linux-2.6/include/linux/net_stamp.h
 //----------------------------------------------------------------------
Comment 7 Christian Borntraeger 2015-06-12 10:54:21 UTC
The 2nd + PRE_MEM_READ("ioctl(KVM_S390_MEM_OP)", ARG3, + sizeof(struct vki_kvm_s390_mem_op)); in the post handler is a leftover.
Fixed and committed as 15334
Comment 8 Julian Seward 2015-08-13 14:41:40 UTC
Christian, can this be closed now?
Comment 9 Christian Borntraeger 2015-08-14 19:43:07 UTC
Well it will be an endless task, but valgrind works reasonably well with qemu 2.3 and recent kernels. So lets close this and open new bugzilla (or just jfix) if we have new ioctls.