All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <levinsasha928@gmail.com>
To: kvm@vger.kernel.org
Cc: Sasha Levin <levinsasha928@gmail.com>,
	Avi Kivity <avi@redhat.com>, Ingo Molnar <mingo@elte.hu>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Pekka Enberg <penberg@kernel.org>
Subject: [PATCH 4/5] ioeventfd: Introduce KVM_IOEVENTFD_FLAG_NOWRITE
Date: Wed,  6 Jul 2011 07:37:57 +0300	[thread overview]
Message-ID: <1309927078-5983-4-git-send-email-levinsasha928@gmail.com> (raw)
In-Reply-To: <1309927078-5983-1-git-send-email-levinsasha928@gmail.com>

The new flag specifies whether writes to the address specified
in the ioeventfd shouldn't raise the event.

Cc: Avi Kivity <avi@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 Documentation/virtual/kvm/api.txt |    5 +++++
 include/linux/kvm.h               |    2 ++
 virt/kvm/eventfd.c                |    9 +++++++++
 3 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index 8179bc1..317d86a 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -1347,6 +1347,7 @@ The following flags are defined:
 #define KVM_IOEVENTFD_FLAG_PIO       (1 << kvm_ioeventfd_flag_nr_pio)
 #define KVM_IOEVENTFD_FLAG_DEASSIGN  (1 << kvm_ioeventfd_flag_nr_deassign)
 #define KVM_IOEVENTFD_FLAG_READ      (1 << kvm_ioeventfd_flag_nr_read)
+#define KVM_IOEVENTFD_FLAG_NOWRITE   (1 << kvm_ioeventfd_flag_nr_nowrite)
 
 If datamatch flag is set, the event will be signaled only if the written value
 to the registered address is equal to datamatch in struct kvm_ioeventfd.
@@ -1355,6 +1356,10 @@ If the read flag is set, the event will be signaled when the specified address
 is being read from. The value actually read by the guest will be the value
 passed in datamatch.
 
+If the nowrite flag is set, the event won't be signaled when the specified address
+is being written to.
+
+
 5. The kvm_run structure
 
 Application code obtains a pointer to the kvm_run structure by
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index ce4cc89..8a12711 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -388,6 +388,7 @@ enum {
 	kvm_ioeventfd_flag_nr_pio,
 	kvm_ioeventfd_flag_nr_deassign,
 	kvm_ioeventfd_flag_nr_read,
+	kvm_ioeventfd_flag_nr_nowrite,
 	kvm_ioeventfd_flag_nr_max,
 };
 
@@ -395,6 +396,7 @@ enum {
 #define KVM_IOEVENTFD_FLAG_PIO       (1 << kvm_ioeventfd_flag_nr_pio)
 #define KVM_IOEVENTFD_FLAG_DEASSIGN  (1 << kvm_ioeventfd_flag_nr_deassign)
 #define KVM_IOEVENTFD_FLAG_READ      (1 << kvm_ioeventfd_flag_nr_read)
+#define KVM_IOEVENTFD_FLAG_NOWRITE   (1 << kvm_ioeventfd_flag_nr_nowrite)
 
 #define KVM_IOEVENTFD_VALID_FLAG_MASK  ((1 << kvm_ioeventfd_flag_nr_max) - 1)
 
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index e0f24bf..5f2d203 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -429,6 +429,7 @@ struct _ioeventfd {
 	struct kvm_io_device dev;
 	bool                 wildcard;
 	bool                 track_reads;
+	bool                 track_writes;
 };
 
 static inline struct _ioeventfd *
@@ -516,6 +517,10 @@ ioeventfd_write(struct kvm_io_device *this, gpa_t addr, int len,
 {
 	struct _ioeventfd *p = to_ioeventfd(this);
 
+	/* Exit if signaling on writes isn't requested */
+	if (!p->track_writes)
+		return -EOPNOTSUPP;
+
 	if (!ioeventfd_in_range(p, addr, len, val))
 		return -EOPNOTSUPP;
 
@@ -624,6 +629,10 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
 	if (args->flags & KVM_IOEVENTFD_FLAG_READ)
 		p->track_reads = true;
 
+	/* Don't raise signal on writes to address if requested */
+	if (!(args->flags & KVM_IOEVENTFD_FLAG_NOWRITE))
+		p->track_writes = true;
+
 	kvm_iodevice_init(&p->dev, &ioeventfd_ops);
 
 	ret = kvm_io_bus_register_dev(kvm, bus_idx, &p->dev);
-- 
1.7.6


  parent reply	other threads:[~2011-07-06  4:38 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-06  4:37 [PATCH 1/5] ioeventfd: Remove natural sized length limitation Sasha Levin
2011-07-06  4:37 ` [PATCH 2/5] ioeventfd: Add helper functions for reading and writing Sasha Levin
2011-07-06  4:37 ` [PATCH 3/5] ioeventfd: Introduce KVM_IOEVENTFD_FLAG_READ Sasha Levin
2011-07-06  4:37 ` Sasha Levin [this message]
2011-07-06  4:37 ` [PATCH 5/5] ioeventfd: Introduce KVM_IOEVENTFD_FLAG_SOCKET Sasha Levin
2011-07-06 11:42   ` Michael S. Tsirkin
2011-07-06 15:01     ` Sasha Levin
2011-07-06 17:58       ` Michael S. Tsirkin
2011-07-10  5:34         ` Sasha Levin
2011-07-10  8:05           ` Michael S. Tsirkin
2011-07-12 11:23             ` Sasha Levin
2011-07-12 11:26               ` Avi Kivity
2011-07-13  6:37                 ` Pekka Enberg
2011-07-13  6:45                   ` Pekka Enberg
2011-07-13  7:07                     ` Avi Kivity
2011-07-13  8:02                       ` Pekka Enberg
2011-07-13 12:57                         ` Avi Kivity
2011-07-13 13:00                           ` Pekka Enberg
2011-07-13 13:32                             ` Avi Kivity
2011-07-14  7:26                               ` Pekka Enberg
2011-07-14  8:07                                 ` Sasha Levin
2011-07-14  8:09                                 ` Avi Kivity
2011-07-14  8:14                                   ` Pekka Enberg
2011-07-14  8:28                                     ` Avi Kivity
2011-07-14  8:59                                       ` Pekka Enberg
2011-07-14  9:48                                         ` Avi Kivity
     [not found]                                           ` <CAOJsxLHSeRuTOoiJssyrELRx-eXok3WinLr_+_G4dB+yHNBKdg@mail.gmai! l.com>
2011-07-14 10:30                                           ` Pekka Enberg
2011-07-14 11:54                                             ` Avi Kivity
2011-07-14 12:32                                               ` Sasha Levin
2011-07-14 12:46                                                 ` Avi Kivity
2011-07-14 13:00                                                   ` Sasha Levin
2011-07-14 13:05                                                     ` Avi Kivity
2011-07-14 13:17                                                       ` Pekka Enberg
2011-07-14 13:23                                                         ` Avi Kivity
2011-07-20  2:52                                                           ` Anthony Liguori
2011-07-20  6:16                                                             ` Sasha Levin
2011-07-20  9:42                                                               ` Pekka Enberg
2011-07-14 12:37                                               ` Pekka Enberg
2011-07-14 12:48                                                 ` Avi Kivity
2011-07-14 12:52                                                   ` Pekka Enberg
2011-07-14 12:54                                                     ` Avi Kivity
2011-07-14  8:19                                   ` Gleb Natapov
2011-07-14  8:25                                   ` Michael S. Tsirkin
2011-07-14  8:29                                     ` Avi Kivity
2011-07-20  2:49                       ` Anthony Liguori
2011-07-20  9:44                         ` Pekka Enberg
2011-07-20 21:10                           ` Anthony Liguori
2011-07-25 12:10                       ` Sasha Levin
2011-07-25 12:16                         ` Avi Kivity
2011-07-25 12:26                           ` Sasha Levin
2011-07-25 13:04                             ` Avi Kivity
2011-07-13  7:51           ` Pekka Enberg
2011-07-13 10:04             ` Pekka Enberg
2011-07-13 10:26               ` Sasha Levin
2011-07-13 10:56                 ` Pekka Enberg
2011-07-13 11:14                   ` Pekka Enberg
2011-07-06 12:39   ` Avi Kivity
2011-07-06 12:58     ` Sasha Levin
2011-07-06 13:04       ` Avi Kivity
2011-07-06 13:00   ` Avi Kivity
2011-07-20  2:42   ` Anthony Liguori
2011-07-20  8:19     ` Avi Kivity

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=1309927078-5983-4-git-send-email-levinsasha928@gmail.com \
    --to=levinsasha928@gmail.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=penberg@kernel.org \
    /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.