From: Tetsuya Mukawa <mukawa@igel.co.jp>
To: dev@dpdk.org
Cc: nakajima.yoshihiro@lab.ntt.co.jp, masutani.hitoshi@lab.ntt.co.jp
Subject: [dpdk-dev] [RFC PATCH 1/7] lib/librte_vhost: Fix host_memory_map() to handle various memory regions
Date: Thu, 6 Nov 2014 20:14:25 +0900 [thread overview]
Message-ID: <1415272471-3299-2-git-send-email-mukawa@igel.co.jp> (raw)
In-Reply-To: <1415272471-3299-1-git-send-email-mukawa@igel.co.jp>
Without this patch, host_memory_map() can only handle a region that
exists on head of a guest physical memory. The patch fixes the
host_memory_map() to handle regions exist on middle of the physical memory.
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
lib/librte_vhost/virtio-net.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
index 8015dd8..9155a68 100644
--- a/lib/librte_vhost/virtio-net.c
+++ b/lib/librte_vhost/virtio-net.c
@@ -83,6 +83,7 @@ const uint32_t BUFSIZE = PATH_MAX;
/* Structure containing information gathered from maps file. */
struct procmap {
uint64_t va_start; /* Start virtual address in file. */
+ uint64_t va_end; /* End virtual address in file. */
uint64_t len; /* Size of file. */
uint64_t pgoff; /* Not used. */
uint32_t maj; /* Not used. */
@@ -176,7 +177,7 @@ host_memory_map(struct virtio_net *dev, struct virtio_memory *mem,
return -1;
}
- procmap.len = strtoull(in[1], &end, 16);
+ procmap.va_end = strtoull(in[1], &end, 16);
if ((in[1] == '\0') || (end == NULL) || (*end != '\0') || (errno != 0)) {
fclose(fmap);
return -1;
@@ -209,8 +210,8 @@ host_memory_map(struct virtio_net *dev, struct virtio_memory *mem,
memcpy(&procmap.prot, in[2], PROT_SZ);
memcpy(&procmap.fname, in[7], PATH_MAX);
- if (procmap.va_start == addr) {
- procmap.len = procmap.len - procmap.va_start;
+ if ((procmap.va_start <= addr) && (procmap.va_end >= addr)) {
+ procmap.len = procmap.va_end - procmap.va_start;
found = 1;
break;
}
--
1.9.1
next prev parent reply other threads:[~2014-11-06 11:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-06 11:14 [dpdk-dev] [RFC PATCH 0/7] lib/librte_vhost: Add vhost-user extension Tetsuya Mukawa
2014-11-06 11:14 ` Tetsuya Mukawa [this message]
2014-11-06 11:14 ` [dpdk-dev] [RFC PATCH 2/7] lib/librte_vhost: Add an abstraction layer for vhost backends Tetsuya Mukawa
2014-11-06 11:14 ` [dpdk-dev] [RFC PATCH 3/7] lib/librte_vhost: Add an abstraction layer tointerpret messages Tetsuya Mukawa
2014-11-07 20:43 ` Xie, Huawei
2014-11-10 5:12 ` Tetsuya Mukawa
2014-11-10 8:07 ` Xie, Huawei
2014-11-10 8:44 ` Tetsuya Mukawa
2014-11-06 11:14 ` [dpdk-dev] [RFC PATCH 4/7] lib/librte_vhost: Move vhost vhost-cuse device list and accessor functions Tetsuya Mukawa
2014-11-06 11:14 ` [dpdk-dev] [RFC PATCH 5/7] lib/librte_vhost: Add a vhost session abstraction Tetsuya Mukawa
2014-11-06 11:14 ` [dpdk-dev] [RFC PATCH 6/7] lib/librte_vhost: Add vhost-cuse/user specific initialization Tetsuya Mukawa
2014-11-06 11:14 ` [dpdk-dev] [RFC PATCH 7/7] lib/librte_vhost: Add vhost-user implementation Tetsuya Mukawa
2014-11-07 21:25 ` Xie, Huawei
2014-11-10 5:11 ` Tetsuya Mukawa
2014-11-10 8:18 ` Xie, Huawei
2014-11-10 8:55 ` Tetsuya Mukawa
2014-11-14 0:07 ` Xie, Huawei
2014-11-14 4:41 ` Tetsuya Mukawa
2014-11-07 3:33 ` [dpdk-dev] [RFC PATCH 0/7] lib/librte_vhost: Add vhost-user extension Xie, Huawei
2014-11-07 5:09 ` Tetsuya Mukawa
[not found] ` <C37D651A908B024F974696C65296B57B0F2E3C93@SHSMSX101.ccr.corp.intel.com>
2014-11-07 6:16 ` Tetsuya Mukawa
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=1415272471-3299-2-git-send-email-mukawa@igel.co.jp \
--to=mukawa@igel.co.jp \
--cc=dev@dpdk.org \
--cc=masutani.hitoshi@lab.ntt.co.jp \
--cc=nakajima.yoshihiro@lab.ntt.co.jp \
/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;
as well as URLs for NNTP newsgroup(s).