From: Sasha Levin <levinsasha928@gmail.com>
To: penberg@kernel.org
Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com,
gorcunov@gmail.com, prasadjoshi124@gmail.com,
Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH 3/4] kvm tools: Add a void ptr to be passed to mmio callback
Date: Thu, 28 Jul 2011 12:01:54 +0300 [thread overview]
Message-ID: <1311843715-5464-3-git-send-email-levinsasha928@gmail.com> (raw)
In-Reply-To: <1311843715-5464-1-git-send-email-levinsasha928@gmail.com>
This makes MMIO callback similar to it's PIO counterpart by passing
a void* value provided in the registration to the callback function.
This allows to keep context within the MMIO callback function.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
tools/kvm/include/kvm/kvm.h | 2 +-
tools/kvm/mmio.c | 8 +++++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h
index eeb55b6..5f3cbbf 100644
--- a/tools/kvm/include/kvm/kvm.h
+++ b/tools/kvm/include/kvm/kvm.h
@@ -64,7 +64,7 @@ void kvm__irq_line(struct kvm *kvm, int irq, int level);
bool kvm__emulate_io(struct kvm *kvm, u16 port, void *data, int direction, int size, u32 count);
bool kvm__emulate_mmio(struct kvm *kvm, u64 phys_addr, u8 *data, u32 len, u8 is_write);
void kvm__register_mem(struct kvm *kvm, u64 guest_phys, u64 size, void *userspace_addr);
-bool kvm__register_mmio(struct kvm *kvm, u64 phys_addr, u64 phys_addr_len, void (*kvm_mmio_callback_fn)(u64 addr, u8 *data, u32 len, u8 is_write));
+bool kvm__register_mmio(struct kvm *kvm, u64 phys_addr, u64 phys_addr_len, void (*kvm_mmio_callback_fn)(u64 addr, u8 *data, u32 len, u8 is_write, void *ptr), void *ptr);
bool kvm__deregister_mmio(struct kvm *kvm, u64 phys_addr);
void kvm__pause(void);
void kvm__continue(void);
diff --git a/tools/kvm/mmio.c b/tools/kvm/mmio.c
index 64bef37..9a7f84a 100644
--- a/tools/kvm/mmio.c
+++ b/tools/kvm/mmio.c
@@ -14,7 +14,8 @@
struct mmio_mapping {
struct rb_int_node node;
- void (*kvm_mmio_callback_fn)(u64 addr, u8 *data, u32 len, u8 is_write);
+ void (*kvm_mmio_callback_fn)(u64 addr, u8 *data, u32 len, u8 is_write, void *ptr);
+ void *ptr;
};
static struct rb_root mmio_tree = RB_ROOT;
@@ -55,7 +56,7 @@ static const char *to_direction(u8 is_write)
return "read";
}
-bool kvm__register_mmio(struct kvm *kvm, u64 phys_addr, u64 phys_addr_len, void (*kvm_mmio_callback_fn)(u64 addr, u8 *data, u32 len, u8 is_write))
+bool kvm__register_mmio(struct kvm *kvm, u64 phys_addr, u64 phys_addr_len, void (*kvm_mmio_callback_fn)(u64 addr, u8 *data, u32 len, u8 is_write, void *ptr), void *ptr)
{
struct mmio_mapping *mmio;
struct kvm_coalesced_mmio_zone zone;
@@ -68,6 +69,7 @@ bool kvm__register_mmio(struct kvm *kvm, u64 phys_addr, u64 phys_addr_len, void
*mmio = (struct mmio_mapping) {
.node = RB_INT_INIT(phys_addr, phys_addr + phys_addr_len),
.kvm_mmio_callback_fn = kvm_mmio_callback_fn,
+ .ptr = ptr,
};
zone = (struct kvm_coalesced_mmio_zone) {
@@ -120,7 +122,7 @@ bool kvm__emulate_mmio(struct kvm *kvm, u64 phys_addr, u8 *data, u32 len, u8 is_
mmio = mmio_search(&mmio_tree, phys_addr, len);
if (mmio)
- mmio->kvm_mmio_callback_fn(phys_addr, data, len, is_write);
+ mmio->kvm_mmio_callback_fn(phys_addr, data, len, is_write, mmio->ptr);
else
fprintf(stderr, "Warning: Ignoring MMIO %s at %016llx (length %u)\n",
to_direction(is_write), phys_addr, len);
--
1.7.6
next prev parent reply other threads:[~2011-07-28 9:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-28 9:01 [PATCH 1/4] kvm tools: Use GSI routing Sasha Levin
2011-07-28 9:01 ` [PATCH 2/4] kvm tools: Fix PCI probing Sasha Levin
2011-07-28 9:31 ` Pekka Enberg
2011-07-28 9:38 ` Cyrill Gorcunov
2011-07-28 9:43 ` Pekka Enberg
2011-07-28 9:01 ` Sasha Levin [this message]
2011-07-28 9:42 ` [PATCH 3/4] kvm tools: Add a void ptr to be passed to mmio callback Cyrill Gorcunov
2011-07-28 9:43 ` Pekka Enberg
2011-07-28 9:01 ` [PATCH 4/4] kvm tools: Implement MSI-X for virtio-rng Sasha Levin
2011-07-28 9:33 ` Pekka Enberg
2011-07-28 9:27 ` [PATCH 1/4] kvm tools: Use GSI routing Pekka Enberg
2011-07-28 9:43 ` Cyrill Gorcunov
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=1311843715-5464-3-git-send-email-levinsasha928@gmail.com \
--to=levinsasha928@gmail.com \
--cc=asias.hejun@gmail.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=penberg@kernel.org \
--cc=prasadjoshi124@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox