Blame SOURCES/kvm-exec-simplify-address_space_get_iotlb_entry.patch

9bac43
From 134252b0775bcb125487eacc4d9f5a6921b0aa96 Mon Sep 17 00:00:00 2001
9bac43
From: Maxime Coquelin <maxime.coquelin@redhat.com>
9bac43
Date: Fri, 20 Oct 2017 14:17:07 +0200
9bac43
Subject: [PATCH 05/19] exec: simplify address_space_get_iotlb_entry
9bac43
9bac43
RH-Author: Maxime Coquelin <maxime.coquelin@redhat.com>
9bac43
Message-id: <20171020141707.17637-3-maxime.coquelin@redhat.com>
9bac43
Patchwork-id: 77418
9bac43
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 2/2] exec: simplify address_space_get_iotlb_entry
9bac43
Bugzilla: 1498817
9bac43
RH-Acked-by: Peter Xu <peterx@redhat.com>
9bac43
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
9bac43
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
9bac43
9bac43
From: Peter Xu <peterx@redhat.com>
9bac43
9bac43
This patch let address_space_get_iotlb_entry() to use the newly
9bac43
introduced page_mask parameter in address_space_do_translate().
9bac43
Then we will be sure the IOTLB can be aligned to page mask, also
9bac43
we should nicely support huge pages now when introducing a764040.
9bac43
9bac43
Fixes: a764040 ("exec: abstract address_space_do_translate()")
9bac43
Signed-off-by: Peter Xu <peterx@redhat.com>
9bac43
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
9bac43
Acked-by: Michael S. Tsirkin <mst@redhat.com>
9bac43
Message-Id: <20171010094247.10173-3-maxime.coquelin@redhat.com>
9bac43
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9bac43
(cherry picked from commit 076a93d7972c9c1e3839d2f65edc32568a2cce93)
9bac43
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
9bac43
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
9bac43
Conflicts:
9bac43
	exec.c (Skipping 166206845f7f)
9bac43
---
9bac43
 exec.c | 31 ++++++++++---------------------
9bac43
 1 file changed, 10 insertions(+), 21 deletions(-)
9bac43
9bac43
diff --git a/exec.c b/exec.c
9bac43
index e5f97fd..ae37a60 100644
9bac43
--- a/exec.c
9bac43
+++ b/exec.c
9bac43
@@ -540,14 +540,14 @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
9bac43
                                             bool is_write)
9bac43
 {
9bac43
     MemoryRegionSection section;
9bac43
-    hwaddr xlat, plen;
9bac43
+    hwaddr xlat, page_mask;
9bac43
 
9bac43
-    /* Try to get maximum page mask during translation. */
9bac43
-    plen = (hwaddr)-1;
9bac43
-
9bac43
-    /* This can never be MMIO. */
9bac43
-    section = address_space_do_translate(as, addr, &xlat, &plen,
9bac43
-                                         NULL, is_write, false);
9bac43
+     /*
9bac43
+     * This can never be MMIO, and we don't really care about plen,
9bac43
+     * but page mask.
9bac43
+     */
9bac43
+    section = address_space_do_translate(as, addr, &xlat, NULL,
9bac43
+                                         &page_mask, is_write, false);
9bac43
 
9bac43
     /* Illegal translation */
9bac43
     if (section.mr == &io_mem_unassigned) {
9bac43
@@ -558,22 +558,11 @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
9bac43
     xlat += section.offset_within_address_space -
9bac43
         section.offset_within_region;
9bac43
 
9bac43
-    if (plen == (hwaddr)-1) {
9bac43
-        /*
9bac43
-         * We use default page size here. Logically it only happens
9bac43
-         * for identity mappings.
9bac43
-         */
9bac43
-        plen = TARGET_PAGE_SIZE;
9bac43
-    }
9bac43
-
9bac43
-    /* Convert to address mask */
9bac43
-    plen -= 1;
9bac43
-
9bac43
     return (IOMMUTLBEntry) {
9bac43
         .target_as = section.address_space,
9bac43
-        .iova = addr & ~plen,
9bac43
-        .translated_addr = xlat & ~plen,
9bac43
-        .addr_mask = plen,
9bac43
+        .iova = addr & ~page_mask,
9bac43
+        .translated_addr = xlat & ~page_mask,
9bac43
+        .addr_mask = page_mask,
9bac43
         /* IOTLBs are for DMAs, and DMA only allows on RAMs. */
9bac43
         .perm = IOMMU_RW,
9bac43
     };
9bac43
-- 
9bac43
1.8.3.1
9bac43