From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f180.google.com (mail-pd0-f180.google.com [209.85.192.180]) by dpdk.org (Postfix) with ESMTP id 7D3417E80 for ; Thu, 6 Nov 2014 12:05:30 +0100 (CET) Received: by mail-pd0-f180.google.com with SMTP id ft15so968320pdb.11 for ; Thu, 06 Nov 2014 03:14:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=01y779PhVDx7SPuAyiXbzChZosjWT8AlGNRlbdDGaaw=; b=WT2lgd715OOrFjgrDk6Hz+PkLILIEpkqXCpcOVIjnLn1sIph5y4Bw+lkQUVDSImXPt o50DcUgb31TbOVJKa8zNN83fBSmwbKQBwTNgfx9iamIM59fCGPSNPbyPYyp8Zwj+ltc8 tm8xceNMxYlPCMOxG1rhazU0SR6x4HZqlY/rt+sIDxJX/8DQ9P45mEw7sFXpOIn69wMr En6RsqlUlpZ4H9HSopbEltPNeW89iacau3STrTNDZaLi6R9M/2Xzyp7U00JIKwUjl+Eq pVpmfTi9gFGAgMw69C5nYB48SgPrkdVjLKSnwK3Er2mDgHpBOCSGGnvZur8VgsaplOGk 29KQ== X-Gm-Message-State: ALoCoQmKH07dDxCvYFam2JYvvi23BehJpJ0wZ0lSIVWM7AuFf+BdwP5fOglJkXO48Pvp0RxBXje3 X-Received: by 10.68.213.8 with SMTP id no8mr3749548pbc.92.1415272497152; Thu, 06 Nov 2014 03:14:57 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id jc3sm5652315pbb.49.2014.11.06.03.14.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Nov 2014 03:14:56 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Thu, 6 Nov 2014 20:14:25 +0900 Message-Id: <1415272471-3299-2-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415272471-3299-1-git-send-email-mukawa@igel.co.jp> References: <1415272471-3299-1-git-send-email-mukawa@igel.co.jp> 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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Nov 2014 11:05:30 -0000 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 --- 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