From patchwork Sun Aug 19 20:22:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcel Apfelbaum X-Patchwork-Id: 959679 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="V+ffYZPo"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41vDLR67R5z9s8T for ; Mon, 20 Aug 2018 22:55:27 +1000 (AEST) Received: from localhost ([::1]:46925 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frjiP-0007gY-Ex for incoming@patchwork.ozlabs.org; Mon, 20 Aug 2018 08:55:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frjYr-0000Cv-45 for qemu-devel@nongnu.org; Mon, 20 Aug 2018 08:45:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frjYp-0000jm-Bx for qemu-devel@nongnu.org; Mon, 20 Aug 2018 08:45:33 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:52368) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1frjYl-0000h8-Ns for qemu-devel@nongnu.org; Mon, 20 Aug 2018 08:45:29 -0400 Received: by mail-wm0-x243.google.com with SMTP id o11-v6so14084851wmh.2 for ; Mon, 20 Aug 2018 05:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+VL5fahtdL/1D3QAfSdncEBv0sUBzU+7fvTRRLp/6Yc=; b=V+ffYZPoVDimsXCCMbOwb1H3McIxA4eo3u20LyCVTn2u/DFrYisDOIi9GpTIZRIRzD EVBH0v8BhpLWxsGSnTxGGpOnKcHRM7CzH4dtwrKb+wTyrEsfor2KH3JqMMsNm+jRCy3l jAPAAlNcbApC0BHpJgW001Y7gSEUwzqxE9iHknaoOVGSM32+zVkr6yU+1u5mTj2BfwBe x9uDNy6ee5cIaIOQXHt+7PaQOqvjda/irTA9goZY07ZCo69wvfiTeEBvEfmr+XvaAz2v /EBMAG4W6OnsIb+ANaSSETxVqopmJA1ZhQKc97zFE6aBHNi0tpHp6hEK9ha0YUKEDFuD E7RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+VL5fahtdL/1D3QAfSdncEBv0sUBzU+7fvTRRLp/6Yc=; b=C0IzSOdSJ4Jho1yEC8WNrwykABc7G1ljZcF/l/1ulIhcC/pQND8PcE4tVk2EGGfwoK Ytxnym9bOAQpTWSG7Orb/FtRNwz007vIgi+9booiTN1ucLJ7F8HUfNbq1PMMM9+xwS2Q LtY/So39/riV/9SOoTv8AO/v1yIcAp/s7Xud0t3nsGQiQV9AU4f0hCBn5nNGX3YvVoEc iV8f47etZnU8tSGawLMIVbxDkOBajzoPGYey+5S88ycZQTgNw8tcQUy6mBmvftLlBgYX C9O9ykNsCqQEyUIY2UZHltQX/T9qx49aGec5JZTOw1M0CcIVzEaXoeYg63UoazlX7EoD 1UCw== X-Gm-Message-State: AOUpUlGPK9D2r66c1W7lOrOQFcNslteDhnZpVc8TG21dzwznjjM969NL y3imGYkRhiOdYHerFGCeISgnhe2c X-Google-Smtp-Source: AA+uWPxy9TEPpS5fuwO+I7gyevk/7wO7azVztANYGzOK5YDKxHj+YJV9R8pGt4ONs9u2hLafOK1ttg== X-Received: by 2002:a1c:6d1c:: with SMTP id i28-v6mr27209922wmc.97.1534769124297; Mon, 20 Aug 2018 05:45:24 -0700 (PDT) Received: from localhost.localdomain ([176.228.154.53]) by smtp.gmail.com with ESMTPSA id g2-v6sm26704613wrd.71.2018.08.20.05.45.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Aug 2018 05:45:23 -0700 (PDT) From: Marcel Apfelbaum To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Sun, 19 Aug 2018 23:22:57 +0300 Message-Id: <20180819202300.10590-13-marcel.apfelbaum@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180819202300.10590-1-marcel.apfelbaum@gmail.com> References: <20180819202300.10590-1-marcel.apfelbaum@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PATCH PULL 12/15] hw/rdma: Bugfix - Support non-aligned buffers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, yuval.shaia@oracle.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Yuval Shaia RDMA application can provide non-aligned buffers to be registered. In such case the DMA address passed by driver is pointing to the beginning of the physical address of the mapped page so we can't distinguish between two addresses from the same page. Fix it by keeping the offset of the virtual address in mr->virt. Signed-off-by: Yuval Shaia Reviewed-by: Marcel Apfelbaum Message-Id: <20180805153518.2983-13-yuval.shaia@oracle.com> Signed-off-by: Marcel Apfelbaum --- hw/rdma/rdma_rm.c | 2 ++ hw/rdma/vmw/pvrdma_cmd.c | 1 + 2 files changed, 3 insertions(+) diff --git a/hw/rdma/rdma_rm.c b/hw/rdma/rdma_rm.c index 859c900003..8d59a42cd1 100644 --- a/hw/rdma/rdma_rm.c +++ b/hw/rdma/rdma_rm.c @@ -166,6 +166,7 @@ int rdma_rm_alloc_mr(RdmaDeviceResources *dev_res, uint32_t pd_handle, mr->virt = host_virt; mr->start = guest_start; mr->length = guest_length; + mr->virt += (mr->start & (TARGET_PAGE_SIZE - 1)); ret = rdma_backend_create_mr(&mr->backend_mr, &pd->backend_pd, mr->virt, mr->length, access_flags); @@ -203,6 +204,7 @@ void rdma_rm_dealloc_mr(RdmaDeviceResources *dev_res, uint32_t mr_handle) rdma_backend_destroy_mr(&mr->backend_mr); pr_dbg("start=0x%" PRIx64 "\n", mr->start); if (mr->start) { + mr->virt -= (mr->start & (TARGET_PAGE_SIZE - 1)); munmap(mr->virt, mr->length); } res_tbl_dealloc(&dev_res->mr_tbl, mr_handle); diff --git a/hw/rdma/vmw/pvrdma_cmd.c b/hw/rdma/vmw/pvrdma_cmd.c index 4f74b29936..b74b0b48d0 100644 --- a/hw/rdma/vmw/pvrdma_cmd.c +++ b/hw/rdma/vmw/pvrdma_cmd.c @@ -59,6 +59,7 @@ static void *pvrdma_map_to_pdir(PCIDevice *pdev, uint64_t pdir_dma, } host_virt = mremap(curr_page, 0, length, MREMAP_MAYMOVE); + pr_dbg("mremap %p -> %p\n", curr_page, host_virt); if (host_virt == MAP_FAILED) { host_virt = NULL; error_report("PVRDMA: Failed to remap memory for host_virt");