[{"id":1915078,"web_url":"http://patchwork.ozlabs.org/comment/1915078/","msgid":"<99079f7d-c447-d615-83c0-bb943557258d@redhat.com>","list_archive_url":null,"date":"2018-05-17T14:32:55","subject":"Re: [Qemu-devel] [PATCH v2 06/10] intel-iommu: pass in address\n\tspace when page walk","submitter":{"id":69187,"url":"http://patchwork.ozlabs.org/api/people/69187/","name":"Eric Auger","email":"eric.auger@redhat.com"},"content":"Hi Peter,\n\nOn 05/04/2018 05:08 AM, Peter Xu wrote:\n> We pass in the VTDAddressSpace to replace the aw bits when doing page\n> walk.  The VTDAddressSpace contains the aw bits information, meanwhile\n> we'll need to do something more in the follow up patches regarding to\n> the address spaces.\n> \n> Signed-off-by: Peter Xu <peterx@redhat.com>\nReviewed-by: Eric Auger <eric.auger@redhat.com>\n\nThanks\n\nEric\n> ---\n>  hw/i386/intel_iommu.c | 20 +++++++++++---------\n>  1 file changed, 11 insertions(+), 9 deletions(-)\n> \n> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c\n> index b2b2a0a441..83769f2b8c 100644\n> --- a/hw/i386/intel_iommu.c\n> +++ b/hw/i386/intel_iommu.c\n> @@ -753,13 +753,13 @@ typedef int (*vtd_page_walk_hook)(IOMMUTLBEntry *entry, void *private);\n>   * @hook_fn: hook func to be called when detected page\n>   * @private: private data to be passed into hook func\n>   * @notify_unmap: whether we should notify invalid entries\n> - * @aw: maximum address width\n> + * @as: VT-d address space of the device\n>   */\n>  typedef struct {\n> +    VTDAddressSpace *as;\n>      vtd_page_walk_hook hook_fn;\n>      void *private;\n>      bool notify_unmap;\n> -    uint8_t aw;\n>  } vtd_page_walk_info;\n>  \n>  static int vtd_page_walk_one(IOMMUTLBEntry *entry, int level,\n> @@ -796,6 +796,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,\n>      uint64_t iova = start;\n>      uint64_t iova_next;\n>      int ret = 0;\n> +    uint8_t aw = info->as->iommu_state->aw_bits;\n>  \n>      trace_vtd_page_walk_level(addr, level, start, end);\n>  \n> @@ -836,7 +837,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,\n>  \n>          if (vtd_is_last_slpte(slpte, level)) {\n>              /* NOTE: this is only meaningful if entry_valid == true */\n> -            entry.translated_addr = vtd_get_slpte_addr(slpte, info->aw);\n> +            entry.translated_addr = vtd_get_slpte_addr(slpte, aw);\n>              if (!entry_valid && !info->notify_unmap) {\n>                  trace_vtd_page_walk_skip_perm(iova, iova_next);\n>                  goto next;\n> @@ -862,7 +863,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,\n>                  }\n>                  goto next;\n>              }\n> -            ret = vtd_page_walk_level(vtd_get_slpte_addr(slpte, info->aw),\n> +            ret = vtd_page_walk_level(vtd_get_slpte_addr(slpte, aw),\n>                                        iova, MIN(iova_next, end), level - 1,\n>                                        read_cur, write_cur, info);\n>              if (ret < 0) {\n> @@ -885,19 +886,20 @@ next:\n>   * @end: IOVA range end address (start <= addr < end)\n>   * @hook_fn: the hook that to be called for each detected area\n>   * @private: private data for the hook function\n> - * @aw: maximum address width\n> + * @as: the VT-d address space of the device\n>   */\n>  static int vtd_page_walk(VTDContextEntry *ce, uint64_t start, uint64_t end,\n>                           vtd_page_walk_hook hook_fn, void *private,\n> -                         bool notify_unmap, uint8_t aw)\n> +                         bool notify_unmap, VTDAddressSpace *as)\n>  {\n>      dma_addr_t addr = vtd_ce_get_slpt_base(ce);\n>      uint32_t level = vtd_ce_get_level(ce);\n> +    uint8_t aw = as->iommu_state->aw_bits;\n>      vtd_page_walk_info info = {\n>          .hook_fn = hook_fn,\n>          .private = private,\n>          .notify_unmap = notify_unmap,\n> -        .aw = aw,\n> +        .as = as,\n>      };\n>  \n>      if (!vtd_iova_range_check(start, ce, aw)) {\n> @@ -1470,7 +1472,7 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s,\n>                   */\n>                  vtd_page_walk(&ce, addr, addr + size,\n>                                vtd_page_invalidate_notify_hook,\n> -                              (void *)&vtd_as->iommu, true, s->aw_bits);\n> +                              (void *)&vtd_as->iommu, true, vtd_as);\n>              } else {\n>                  /*\n>                   * For UNMAP-only notifiers, we don't need to walk the\n> @@ -2941,7 +2943,7 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n)\n>          if (vtd_as_notify_mappings(vtd_as)) {\n>              /* This is required only for MAP typed notifiers */\n>              vtd_page_walk(&ce, 0, ~0ULL, vtd_replay_hook, (void *)n, false,\n> -                          s->aw_bits);\n> +                          vtd_as);\n>          }\n>      } else {\n>          trace_vtd_replay_ce_invalid(bus_n, PCI_SLOT(vtd_as->devfn),\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 40mv1q5hckz9s47\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 18 May 2018 00:33:51 +1000 (AEST)","from localhost ([::1]:58596 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1fJJyX-0000Hy-Gj\n\tfor incoming@patchwork.ozlabs.org; Thu, 17 May 2018 10:33:49 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:33077)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eric.auger@redhat.com>) id 1fJJxj-0000Di-2a\n\tfor qemu-devel@nongnu.org; Thu, 17 May 2018 10:33:05 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eric.auger@redhat.com>) id 1fJJxh-0000Ai-TK\n\tfor qemu-devel@nongnu.org; Thu, 17 May 2018 10:32:59 -0400","from mx3-rdu2.redhat.com ([66.187.233.73]:56340\n\thelo=mx1.redhat.com)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eric.auger@redhat.com>)\n\tid 1fJJxh-0000Aa-N6\n\tfor qemu-devel@nongnu.org; Thu, 17 May 2018 10:32:57 -0400","from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 43E7CBB41F;\n\tThu, 17 May 2018 14:32:57 +0000 (UTC)","from localhost.localdomain (ovpn-117-111.ams2.redhat.com\n\t[10.36.117.111])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 0625F215CDA7;\n\tThu, 17 May 2018 14:32:55 +0000 (UTC)"],"To":"Peter Xu <peterx@redhat.com>, qemu-devel@nongnu.org","References":"<20180504030811.28111-1-peterx@redhat.com>\n\t<20180504030811.28111-7-peterx@redhat.com>","From":"Auger Eric <eric.auger@redhat.com>","Message-ID":"<99079f7d-c447-d615-83c0-bb943557258d@redhat.com>","Date":"Thu, 17 May 2018 16:32:55 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101\n\tThunderbird/45.4.0","MIME-Version":"1.0","In-Reply-To":"<20180504030811.28111-7-peterx@redhat.com>","Content-Type":"text/plain; charset=windows-1252","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.78 on 10.11.54.6","X-Greylist":["Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.1]);\n\tThu, 17 May 2018 14:32:57 +0000 (UTC)","inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.1]); \n\tThu, 17 May 2018 14:32:57 +0000 (UTC) for IP:'10.11.54.6'\n\tDOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com'\n\tHELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:''"],"X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"66.187.233.73","Subject":"Re: [Qemu-devel] [PATCH v2 06/10] intel-iommu: pass in address\n\tspace when page walk","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Jintack Lim <jintack@cs.columbia.edu>, Tian Kevin <kevin.tian@intel.com>,\n\tAlex Williamson <alex.williamson@redhat.com>,\n\tJason Wang <jasowang@redhat.com>, \"Michael S . Tsirkin\" <mst@redhat.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1915637,"web_url":"http://patchwork.ozlabs.org/comment/1915637/","msgid":"<20180518060212.GF2569@xz-mi>","list_archive_url":null,"date":"2018-05-18T06:02:12","subject":"Re: [Qemu-devel] [PATCH v2 06/10] intel-iommu: pass in address\n\tspace when page walk","submitter":{"id":67717,"url":"http://patchwork.ozlabs.org/api/people/67717/","name":"Peter Xu","email":"peterx@redhat.com"},"content":"On Thu, May 17, 2018 at 04:32:55PM +0200, Auger Eric wrote:\n> Hi Peter,\n> \n> On 05/04/2018 05:08 AM, Peter Xu wrote:\n> > We pass in the VTDAddressSpace to replace the aw bits when doing page\n> > walk.  The VTDAddressSpace contains the aw bits information, meanwhile\n> > we'll need to do something more in the follow up patches regarding to\n> > the address spaces.\n> > \n> > Signed-off-by: Peter Xu <peterx@redhat.com>\n> Reviewed-by: Eric Auger <eric.auger@redhat.com>\n\nThis one is also changed in version 3.  Please have a look there too.\n\nThanks,","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 40nHdq3STpz9s33\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 18 May 2018 16:02:55 +1000 (AEST)","from localhost ([::1]:36817 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1fJYTb-0003PR-2g\n\tfor incoming@patchwork.ozlabs.org; Fri, 18 May 2018 02:02:53 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:58951)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <peterx@redhat.com>) id 1fJYTC-0003PJ-5x\n\tfor qemu-devel@nongnu.org; Fri, 18 May 2018 02:02:27 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <peterx@redhat.com>) id 1fJYT4-0005en-NV\n\tfor qemu-devel@nongnu.org; Fri, 18 May 2018 02:02:26 -0400","from mx3-rdu2.redhat.com ([66.187.233.73]:35520\n\thelo=mx1.redhat.com)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <peterx@redhat.com>) id 1fJYT4-0005ee-J9\n\tfor qemu-devel@nongnu.org; Fri, 18 May 2018 02:02:18 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 22E9181FE141;\n\tFri, 18 May 2018 06:02:18 +0000 (UTC)","from xz-mi (dhcp-14-151.nay.redhat.com [10.66.14.151])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 54D222023582;\n\tFri, 18 May 2018 06:02:15 +0000 (UTC)"],"Date":"Fri, 18 May 2018 14:02:12 +0800","From":"Peter Xu <peterx@redhat.com>","To":"Auger Eric <eric.auger@redhat.com>","Message-ID":"<20180518060212.GF2569@xz-mi>","References":"<20180504030811.28111-1-peterx@redhat.com>\n\t<20180504030811.28111-7-peterx@redhat.com>\n\t<99079f7d-c447-d615-83c0-bb943557258d@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<99079f7d-c447-d615-83c0-bb943557258d@redhat.com>","User-Agent":"Mutt/1.9.5 (2018-04-13)","X-Scanned-By":"MIMEDefang 2.78 on 10.11.54.4","X-Greylist":["Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.8]);\n\tFri, 18 May 2018 06:02:18 +0000 (UTC)","inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.8]); \n\tFri, 18 May 2018 06:02:18 +0000 (UTC) for IP:'10.11.54.4'\n\tDOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com'\n\tHELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:''"],"X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"66.187.233.73","Subject":"Re: [Qemu-devel] [PATCH v2 06/10] intel-iommu: pass in address\n\tspace when page walk","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Tian Kevin <kevin.tian@intel.com>, \"Michael S . Tsirkin\" <mst@redhat.com>,\n\tJason Wang <jasowang@redhat.com>, qemu-devel@nongnu.org,\n\tAlex Williamson <alex.williamson@redhat.com>,\n\tJintack Lim <jintack@cs.columbia.edu>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]