All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tossati <mtosatti@redhat.com>
Cc: Carsten Otte <cotte@de.ibm.com>, Alexander Graf <agraf@suse.de>,
	Jens Freimann <jfrei@linux.vnet.ibm.com>,
	Cornelia Huck <cornelia.huck@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	KVM <kvm@vger.kernel.org>,
	Christian Borntraeger <borntraeger@de.ibm.com>
Subject: [patch 1/3] kvm: provide synchronous registers in kvm_run
Date: Thu, 22 Dec 2011 12:56:47 +0100	[thread overview]
Message-ID: <20111222120054.145183940@de.ibm.com> (raw)
In-Reply-To: 20111222115646.248800653@de.ibm.com

[-- Attachment #1: kvm_run_sync_regs.patch --]
[-- Type: text/plain, Size: 4397 bytes --]

From: Christian Borntraeger <borntraeger@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 <borntraeger@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_GPR		0x0000
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
 


  reply	other threads:[~2011-12-22 12:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-22 11:56 [patch 0/3] RFC: provide synchronous registers in kvm_run Christian Borntraeger
2011-12-22 11:56 ` Christian Borntraeger [this message]
2011-12-22 12:28   ` [patch 1/3] kvm: " Avi Kivity
2012-01-09 12:59   ` Alexander Graf
2011-12-22 11:56 ` [patch 2/3] kvm-s390: provide the prefix register via kvm_run Christian Borntraeger
2011-12-22 11:56 ` [patch 3/3] kvm-s390: provide general purpose registers " Christian Borntraeger
2011-12-22 12:34   ` Avi Kivity
2011-12-22 12:39     ` Christian Borntraeger
2011-12-22 12:46       ` Avi Kivity
2011-12-22 12:41   ` Heiko Carstens
2011-12-22 12:47     ` Avi Kivity
2011-12-22 12:35 ` [patch 0/3] RFC: provide synchronous registers in kvm_run Avi Kivity
2011-12-22 12:49   ` Christian Borntraeger
2011-12-22 12:54     ` Avi Kivity
2011-12-22 13:17       ` Christian Borntraeger
2011-12-22 13:25         ` Avi Kivity
     [not found] ` <1325605858-30492-1-git-send-email-borntraeger@de.ibm.com>
     [not found]   ` <1325605858-30492-4-git-send-email-borntraeger@de.ibm.com>
2012-01-04  8:16     ` [PATCH 3/3] kvm-s390: provide standard guest registers via kvm_run Heiko Carstens
2012-01-04  8:30       ` Christian Borntraeger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111222120054.145183940@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=agraf@suse.de \
    --cc=avi@redhat.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=cotte@de.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=jfrei@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=schwidefsky@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.