Re: kvm: provide synchronous registers in kvm_run

2012-01-12 Thread Alexander Graf

On 01/11/2012 11:20 AM, Christian Borntraeger wrote:

Avi, Marcelo,

here is the next version of the sync register patch series.


A small hint for patch sets:

$ git format-patch -n --cover-letter ...

generates a / patch mail template that contains some summary 
about your set, like which files you modified. It can be very helpful to 
at first glance see obviously wrong things :).



Alex

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: kvm: provide synchronous registers in kvm_run

2012-01-12 Thread Alexander Graf

On 01/11/2012 11:20 AM, Christian Borntraeger wrote:

Avi, Marcelo,

here is the next version of the sync register patch series.


Whole set is:

Acked-by: Alexander Graf ag...@suse.de

Very cool interface addition!


Alex

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


kvm: provide synchronous registers in kvm_run

2012-01-11 Thread Christian Borntraeger
Avi, Marcelo,

here is the next version of the sync register patch series.

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 1/3] kvm: provide synchronous registers in kvm_run

2012-01-09 Thread Alexander Graf

On 22.12.2011, at 12:56, Christian Borntraeger wrote:

 From: Christian Borntraeger borntrae...@de.ibm.com
 
 On some cpus the overhead for virtualization instructions is in the same
 range as a system call. Having to call multiple ioctls to get set registers
 will make userspace handled exits more expensive than necessary.
 Lets provide two sections in kvm_run to have a shared save area for
 guest registers.
 1. the first section is read-only, to handle registers that have side-effects
 2. the second section is read/write, e.g. for general purpose registers.
 
 
 Signed-off-by: Christian Borntraeger borntrae...@de.ibm.com
 ---
 Documentation/virtual/kvm/api.txt |   16 
 arch/ia64/include/asm/kvm.h   |7 +++
 arch/powerpc/include/asm/kvm.h|7 +++
 arch/s390/include/asm/kvm.h   |6 ++
 arch/x86/include/asm/kvm.h|7 +++
 include/linux/kvm.h   |   13 +
 6 files changed, 56 insertions(+)
 
 Index: b/Documentation/virtual/kvm/api.txt
 ===
 --- a/Documentation/virtual/kvm/api.txt
 +++ b/Documentation/virtual/kvm/api.txt
 @@ -1652,7 +1652,23 @@ developer registration required to acces
   /* Fix the size of the union. */
   char padding[256];
   };
 + /* Here are two fields that allow to access often used registers
 + * directly, to avoid the overhead of the ioctl system call */
 + union {
 + /* registers which can be only read */
 + struct sync_ro_regs sync_ro_regs;
 + char padding[1024];
 + };
 + union {
 + /* read/write guest registers */
 + struct sync_rw_regs sync_rw_regs;
 + char padding[1024];
 + };

Why have 2 different structs?

Unions shouldn't be anonymous. Please give the union a name :).


Alex

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] kvm: provide synchronous registers in kvm_run

2012-01-09 Thread Alexander Graf

On 05.01.2012, at 10:54, Christian Borntraeger wrote:

 On some cpus the overhead for virtualization instructions is in the same
 range as a system call. Having to call multiple ioctls to get set registers
 will make certain userspace handled exits more expensive than necessary.
 Lets provide two sections in kvm_run to have a shared save area for
 guest registers.
 1. the first section is read-only, to handle registers that have side-effects
 2. the second section is read/write, e.g. for general purpose registers.
 We also provide two 64bit flags fields (architecture specific), that will
 specify which parts of these fields are valid. Each bit will define that
 a group of registers (like general purpose) or a single register is valid.
 In that way we can extend and shrink the interface. (The structure definition
 itself can only grow of course).
 
 Signed-off-by: Christian Borntraeger borntrae...@de.ibm.com
 ---
 Documentation/virtual/kvm/api.txt |   28 
 arch/ia64/include/asm/kvm.h   |7 +++
 arch/powerpc/include/asm/kvm.h|7 +++
 arch/s390/include/asm/kvm.h   |6 ++
 arch/x86/include/asm/kvm.h|7 +++
 include/linux/kvm.h   |   20 
 6 files changed, 75 insertions(+), 0 deletions(-)
 
 diff --git a/Documentation/virtual/kvm/api.txt 
 b/Documentation/virtual/kvm/api.txt
 index da1f8fd..a149e22 100644
 --- a/Documentation/virtual/kvm/api.txt
 +++ b/Documentation/virtual/kvm/api.txt
 @@ -1693,6 +1693,34 @@ developer registration required to access it).
   /* Fix the size of the union. */
   char padding[256];
   };
 +
 + /*
 +  * Here are two fields that allow to access often used registers
 + * directly, to avoid the overhead of the ioctl system call. Each
 + * register can be extended or reduced by having flag bits specifying
 + * if a group of registers is valid.
 + */
 + __u64 kvm_valid_sync_ro_regs;
 + __u64 kvm_valid_sync_rw_regs;
 + union {
 + /* registers which can be only read */
 + struct kvm_sync_ro_regs sync_ro;
 + char padding[1024];
 + };
 + union {
 + /* read/write guest registers */
 + struct kvm_sync_rw_regs sync_rw;
 + char padding[1024];
 + };

Ah, new patch set. Same comment here. Please give the union a name. Also, I 
still don't understand why we need 2 structs. All we need is a bitmap that says 
this field is dirty and then kernel space can decide to ignore it.


Alex

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] kvm: provide synchronous registers in kvm_run

2012-01-09 Thread Avi Kivity
On 01/09/2012 03:01 PM, Alexander Graf wrote:
 On 05.01.2012, at 10:54, Christian Borntraeger wrote:

  On some cpus the overhead for virtualization instructions is in the same
  range as a system call. Having to call multiple ioctls to get set registers
  will make certain userspace handled exits more expensive than necessary.
  Lets provide two sections in kvm_run to have a shared save area for
  guest registers.
  1. the first section is read-only, to handle registers that have 
  side-effects
  2. the second section is read/write, e.g. for general purpose registers.
  We also provide two 64bit flags fields (architecture specific), that will
  specify which parts of these fields are valid. Each bit will define that
  a group of registers (like general purpose) or a single register is valid.
  In that way we can extend and shrink the interface. (The structure 
  definition
  itself can only grow of course).
  
  Signed-off-by: Christian Borntraeger borntrae...@de.ibm.com
  ---
  Documentation/virtual/kvm/api.txt |   28 
  arch/ia64/include/asm/kvm.h   |7 +++
  arch/powerpc/include/asm/kvm.h|7 +++
  arch/s390/include/asm/kvm.h   |6 ++
  arch/x86/include/asm/kvm.h|7 +++
  include/linux/kvm.h   |   20 
  6 files changed, 75 insertions(+), 0 deletions(-)
  
  diff --git a/Documentation/virtual/kvm/api.txt 
  b/Documentation/virtual/kvm/api.txt
  index da1f8fd..a149e22 100644
  --- a/Documentation/virtual/kvm/api.txt
  +++ b/Documentation/virtual/kvm/api.txt
  @@ -1693,6 +1693,34 @@ developer registration required to access it).
  /* Fix the size of the union. */
  char padding[256];
  };
  +
  +   /*
  +* Here are two fields that allow to access often used registers
  + * directly, to avoid the overhead of the ioctl system call. Each
  + * register can be extended or reduced by having flag bits 
  specifying
  + * if a group of registers is valid.
  + */
  +   __u64 kvm_valid_sync_ro_regs;
  +   __u64 kvm_valid_sync_rw_regs;
  +   union {
  +   /* registers which can be only read */
  +   struct kvm_sync_ro_regs sync_ro;
  +   char padding[1024];
  +   };
  +   union {
  +   /* read/write guest registers */
  +   struct kvm_sync_rw_regs sync_rw;
  +   char padding[1024];
  +   };

 Ah, new patch set. Same comment here. Please give the union a name. Also, I 
 still don't understand why we need 2 structs. 

Right.

 All we need is a bitmap that says this field is dirty and then kernel space 
 can decide to ignore it.

Makes sense.

-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] kvm: provide synchronous registers in kvm_run

2012-01-05 Thread Christian Borntraeger
On some cpus the overhead for virtualization instructions is in the same
range as a system call. Having to call multiple ioctls to get set registers
will make certain userspace handled exits more expensive than necessary.
Lets provide two sections in kvm_run to have a shared save area for
guest registers.
1. the first section is read-only, to handle registers that have side-effects
2. the second section is read/write, e.g. for general purpose registers.
We also provide two 64bit flags fields (architecture specific), that will
specify which parts of these fields are valid. Each bit will define that
a group of registers (like general purpose) or a single register is valid.
In that way we can extend and shrink the interface. (The structure definition
itself can only grow of course).

Signed-off-by: Christian Borntraeger borntrae...@de.ibm.com
---
 Documentation/virtual/kvm/api.txt |   28 
 arch/ia64/include/asm/kvm.h   |7 +++
 arch/powerpc/include/asm/kvm.h|7 +++
 arch/s390/include/asm/kvm.h   |6 ++
 arch/x86/include/asm/kvm.h|7 +++
 include/linux/kvm.h   |   20 
 6 files changed, 75 insertions(+), 0 deletions(-)

diff --git a/Documentation/virtual/kvm/api.txt 
b/Documentation/virtual/kvm/api.txt
index da1f8fd..a149e22 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -1693,6 +1693,34 @@ developer registration required to access it).
/* Fix the size of the union. */
char padding[256];
};
+
+   /*
+* Here are two fields that allow to access often used registers
+ * directly, to avoid the overhead of the ioctl system call. Each
+ * register can be extended or reduced by having flag bits specifying
+ * if a group of registers is valid.
+ */
+   __u64 kvm_valid_sync_ro_regs;
+   __u64 kvm_valid_sync_rw_regs;
+   union {
+   /* registers which can be only read */
+   struct kvm_sync_ro_regs sync_ro;
+   char padding[1024];
+   };
+   union {
+   /* read/write guest registers */
+   struct kvm_sync_rw_regs sync_rw;
+   char padding[1024];
+   };
+
+If KVM_CAP_SYNC_REGS is defined, these fields allow userspace to access
+certain guest registers without having to call SET/GET_*REGS. Thus we can
+avoid some system call overhead if userspace has to handle the exit.
+Userspace can query the validity of the structure by checking
+kvm_valid_sync_r[wo]_regs for specific bits. These bits are architecture
+specific and usually define the validity of a groups of registers. (e.g.
+one bit for general purpose registers)
+
 };
 
 6. Capabilities that can be enabled
diff --git a/arch/ia64/include/asm/kvm.h b/arch/ia64/include/asm/kvm.h
index bc90c75..bae1f1e 100644
--- a/arch/ia64/include/asm/kvm.h
+++ b/arch/ia64/include/asm/kvm.h
@@ -261,4 +261,11 @@ struct kvm_debug_exit_arch {
 struct kvm_guest_debug_arch {
 };
 
+/* definition of registers in kvm_run */
+struct kvm_sync_ro_regs {
+};
+
+struct kvm_sync_rw_regs {
+};
+
 #endif
diff --git a/arch/powerpc/include/asm/kvm.h b/arch/powerpc/include/asm/kvm.h
index f7727d9..14b766b 100644
--- a/arch/powerpc/include/asm/kvm.h
+++ b/arch/powerpc/include/asm/kvm.h
@@ -265,6 +265,13 @@ struct kvm_debug_exit_arch {
 struct kvm_guest_debug_arch {
 };
 
+/* definition of registers in kvm_run */
+struct kvm_sync_ro_regs {
+};
+
+struct kvm_sync_rw_regs {
+};
+
 #define KVM_REG_MASK   0x001f
 #define KVM_REG_EXT_MASK   0xffe0
 #define KVM_REG_GPR0x
diff --git a/arch/s390/include/asm/kvm.h b/arch/s390/include/asm/kvm.h
index 82b32a1..dda27a0 100644
--- a/arch/s390/include/asm/kvm.h
+++ b/arch/s390/include/asm/kvm.h
@@ -41,4 +41,10 @@ struct kvm_debug_exit_arch {
 struct kvm_guest_debug_arch {
 };
 
+/* definition of registers in kvm_run */
+struct kvm_sync_ro_regs {
+};
+
+struct kvm_sync_rw_regs {
+};
 #endif
diff --git a/arch/x86/include/asm/kvm.h b/arch/x86/include/asm/kvm.h
index 4d8dcbd..fb32847 100644
--- a/arch/x86/include/asm/kvm.h
+++ b/arch/x86/include/asm/kvm.h
@@ -321,4 +321,11 @@ struct kvm_xcrs {
__u64 padding[16];
 };
 
+/* definition of registers in kvm_run */
+struct kvm_sync_ro_regs {
+};
+
+struct kvm_sync_rw_regs {
+};
+
 #endif /* _ASM_X86_KVM_H */
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 68e67e5..9398672 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -273,6 +273,25 @@ struct kvm_run {
/* Fix the size of the union. */
char padding[256];
};
+
+   /*
+* Here are two fields that allow to access often used registers
+* directly, to avoid the overhead of the ioctl system call. Each
+* register can be extended or reduced by having flag bits specifying
+* if a group of registers is valid.
+*/
+   

[patch 1/3] kvm: provide synchronous registers in kvm_run

2011-12-22 Thread Christian Borntraeger
From: Christian Borntraeger borntrae...@de.ibm.com

On some cpus the overhead for virtualization instructions is in the same
range as a system call. Having to call multiple ioctls to get set registers
will make userspace handled exits more expensive than necessary.
Lets provide two sections in kvm_run to have a shared save area for
guest registers.
1. the first section is read-only, to handle registers that have side-effects
2. the second section is read/write, e.g. for general purpose registers.


Signed-off-by: Christian Borntraeger borntrae...@de.ibm.com
---
 Documentation/virtual/kvm/api.txt |   16 
 arch/ia64/include/asm/kvm.h   |7 +++
 arch/powerpc/include/asm/kvm.h|7 +++
 arch/s390/include/asm/kvm.h   |6 ++
 arch/x86/include/asm/kvm.h|7 +++
 include/linux/kvm.h   |   13 +
 6 files changed, 56 insertions(+)

Index: b/Documentation/virtual/kvm/api.txt
===
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -1652,7 +1652,23 @@ developer registration required to acces
/* Fix the size of the union. */
char padding[256];
};
+   /* Here are two fields that allow to access often used registers
+ * directly, to avoid the overhead of the ioctl system call */
+   union {
+   /* registers which can be only read */
+   struct sync_ro_regs sync_ro_regs;
+   char padding[1024];
+   };
+   union {
+   /* read/write guest registers */
+   struct sync_rw_regs sync_rw_regs;
+   char padding[1024];
+   };
 };
+These fields allow userspace to access certain guest registers without
+having to call SET/GET_*REGS. Thus we can avoid some system call
+overhead if userspace has to handle the exit. (only available if
+KVM_CAP_SYNC_REGS is set). The ioctls will still work.
 
 6. Capabilities that can be enabled
 
Index: b/arch/ia64/include/asm/kvm.h
===
--- a/arch/ia64/include/asm/kvm.h
+++ b/arch/ia64/include/asm/kvm.h
@@ -261,4 +261,11 @@ struct kvm_debug_exit_arch {
 struct kvm_guest_debug_arch {
 };
 
+/* definition of registers in kvm_run */
+struct sync_ro_regs {
+};
+
+struct sync_rw_regs {
+};
+
 #endif
Index: b/arch/powerpc/include/asm/kvm.h
===
--- a/arch/powerpc/include/asm/kvm.h
+++ b/arch/powerpc/include/asm/kvm.h
@@ -265,6 +265,13 @@ struct kvm_debug_exit_arch {
 struct kvm_guest_debug_arch {
 };
 
+/* definition of registers in kvm_run */
+struct sync_ro_regs {
+};
+
+struct sync_rw_regs {
+};
+
 #define KVM_REG_MASK   0x001f
 #define KVM_REG_EXT_MASK   0xffe0
 #define KVM_REG_GPR0x
Index: b/arch/s390/include/asm/kvm.h
===
--- a/arch/s390/include/asm/kvm.h
+++ b/arch/s390/include/asm/kvm.h
@@ -41,4 +41,10 @@ struct kvm_debug_exit_arch {
 struct kvm_guest_debug_arch {
 };
 
+/* definition of registers in kvm_run */
+struct sync_ro_regs {
+};
+
+struct sync_rw_regs {
+};
 #endif
Index: b/arch/x86/include/asm/kvm.h
===
--- a/arch/x86/include/asm/kvm.h
+++ b/arch/x86/include/asm/kvm.h
@@ -321,4 +321,11 @@ struct kvm_xcrs {
__u64 padding[16];
 };
 
+/* definition of registers in kvm_run */
+struct sync_ro_regs {
+};
+
+struct sync_rw_regs {
+};
+
 #endif /* _ASM_X86_KVM_H */
Index: b/include/linux/kvm.h
===
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -273,6 +273,18 @@ struct kvm_run {
/* Fix the size of the union. */
char padding[256];
};
+   /* Here are two fields that allow to access often used registers
+ * directly, to avoid the overhead of the ioctl system call */
+   union {
+   /* registers which can be only read */
+   struct sync_ro_regs sync_ro_regs;
+   char padding[1024];
+   };
+   union {
+   /* read/write guest registers */
+   struct sync_rw_regs sync_rw_regs;
+   char padding[1024];
+   };
 };
 
 /* for KVM_REGISTER_COALESCED_MMIO / KVM_UNREGISTER_COALESCED_MMIO */
@@ -557,6 +569,7 @@ struct kvm_ppc_pvinfo {
 #define KVM_CAP_MAX_VCPUS 66   /* returns max vcpus per vm */
 #define KVM_CAP_PPC_PAPR 68
 #define KVM_CAP_S390_GMAP 71
+#define KVM_CAP_SYNC_REGS 72
 
 #ifdef KVM_CAP_IRQ_ROUTING
 

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 1/3] kvm: provide synchronous registers in kvm_run

2011-12-22 Thread Avi Kivity
On 12/22/2011 01:56 PM, Christian Borntraeger wrote:
 From: Christian Borntraeger borntrae...@de.ibm.com

 On some cpus the overhead for virtualization instructions is in the same
 range as a system call. Having to call multiple ioctls to get set registers
 will make userspace handled exits more expensive than necessary.
 Lets provide two sections in kvm_run to have a shared save area for
 guest registers.
 1. the first section is read-only, to handle registers that have side-effects
 2. the second section is read/write, e.g. for general purpose registers.

An alternative is to have a single section, with a bitmask set by
userspace to indicate which registers have not been changed (a la svm's
CleanBits).  Is this worthwhile for s390?

   };
 + /* Here are two fields that allow to access often used registers
 + * directly, to avoid the overhead of the ioctl system call */
 + union {
 + /* registers which can be only read */
 + struct sync_ro_regs sync_ro_regs;

kvm_

 + char padding[1024];
 + };
 + union {
 + /* read/write guest registers */
 + struct sync_rw_regs sync_rw_regs;

kvm_

 + char padding[1024];
 + };
  };

blank line

 +These fields allow userspace to access certain guest registers without
 +having to call SET/GET_*REGS. Thus we can avoid some system call
 +overhead if userspace has to handle the exit. (only available if
 +KVM_CAP_SYNC_REGS is set). The ioctls will still work.
  



-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html