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

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