From: Avi Kivity <avi@qumranet.com>
To: benami@il.ibm.com
Cc: kvm-devel@lists.sourceforge.net, andrea@qumranet.com,
allen.m.kay@intel.com
Subject: Re: [PATCH 1/1] Enble a guest to access a device's memory mapped I/O regions directly.
Date: Fri, 18 Apr 2008 18:56:41 +0300 [thread overview]
Message-ID: <4808C4B9.7040804@qumranet.com> (raw)
In-Reply-To: <1208352372-31540-1-git-send-email-benami@il.ibm.com>
benami@il.ibm.com wrote:
> From: Ben-Ami Yassour <benami@il.ibm.com>
>
> Signed-off-by: Ben-Ami Yassour <benami@il.ibm.com>
> Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com>
> ---
> libkvm/libkvm.c | 24 ++++++++----
> qemu/hw/pci-passthrough.c | 89 +++++++++++----------------------------------
> qemu/hw/pci-passthrough.h | 2 +
> 3 files changed, 40 insertions(+), 75 deletions(-)
>
> diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
> index de91328..8c02af9 100644
> --- a/libkvm/libkvm.c
> +++ b/libkvm/libkvm.c
> @@ -400,7 +400,7 @@ void *kvm_create_userspace_phys_mem(kvm_context_t kvm, unsigned long phys_start,
> {
> int r;
> int prot = PROT_READ;
> - void *ptr;
> + void *ptr = NULL;
> struct kvm_userspace_memory_region memory = {
> .memory_size = len,
> .guest_phys_addr = phys_start,
> @@ -410,16 +410,24 @@ void *kvm_create_userspace_phys_mem(kvm_context_t kvm, unsigned long phys_start,
> if (writable)
> prot |= PROT_WRITE;
>
> - ptr = mmap(NULL, len, prot, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
> - if (ptr == MAP_FAILED) {
> - fprintf(stderr, "create_userspace_phys_mem: %s", strerror(errno));
> - return 0;
> - }
> + if (len > 0) {
> + ptr = mmap(NULL, len, prot, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
> + if (ptr == MAP_FAILED) {
> + fprintf(stderr, "create_userspace_phys_mem: %s",
> + strerror(errno));
> + return 0;
> + }
>
> - memset(ptr, 0, len);
> + memset(ptr, 0, len);
> + }
>
> memory.userspace_addr = (unsigned long)ptr;
> - memory.slot = get_free_slot(kvm);
> +
> + if (len > 0)
> + memory.slot = get_free_slot(kvm);
> + else
> + memory.slot = get_slot(phys_start);
> +
> r = ioctl(kvm->vm_fd, KVM_SET_USER_MEMORY_REGION, &memory);
> if (r == -1) {
> fprintf(stderr, "create_userspace_phys_mem: %s", strerror(errno));
>
This looks like support for zero-length memory slots? Why is it needed?
It needs to be in a separate patch.
> diff --git a/qemu/hw/pci-passthrough.c b/qemu/hw/pci-passthrough.c
> index 7ffcc7b..a5894d9 100644
> --- a/qemu/hw/pci-passthrough.c
> +++ b/qemu/hw/pci-passthrough.c
> @@ -25,18 +25,6 @@ typedef __u64 resource_size_t;
> extern kvm_context_t kvm_context;
> extern FILE *logfile;
>
> -CPUReadMemoryFunc *pt_mmio_read_cb[3] = {
> - pt_mmio_readb,
> - pt_mmio_readw,
> - pt_mmio_readl
> -};
> -
> -CPUWriteMemoryFunc *pt_mmio_write_cb[3] = {
> - pt_mmio_writeb,
> - pt_mmio_writew,
> - pt_mmio_writel
> -};
> -
>
There's at least one use case for keeping mmio in userspace:
reverse-engineering a device driver. So if it doesn't cause too much
trouble, please keep this an option.
--
Any sufficiently difficult bug is indistinguishable from a feature.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
next prev parent reply other threads:[~2008-04-18 15:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-16 13:26 [PATCH 1/1] Enble a guest to access a device's memory mapped I/O regions directly benami
2008-04-16 13:26 ` benami
2008-04-18 15:56 ` Avi Kivity [this message]
2008-04-19 14:56 ` Muli Ben-Yehuda
-- strict thread matches above, loose matches on Subject: below --
2008-04-16 13:25 direct mmio for passthrough - kernel part benami
2008-04-16 13:25 ` [PATCH 1/1] Enble a guest to access a device's memory mapped I/O regions directly benami
2008-04-16 13:25 ` benami
2008-04-18 15:50 ` Avi Kivity
2008-04-19 14:35 ` Muli Ben-Yehuda
2008-04-20 10:29 ` 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=4808C4B9.7040804@qumranet.com \
--to=avi@qumranet.com \
--cc=allen.m.kay@intel.com \
--cc=andrea@qumranet.com \
--cc=benami@il.ibm.com \
--cc=kvm-devel@lists.sourceforge.net \
/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