Blame SOURCES/kvm-intel-iommu-replace-more-vtd_err_-traces.patch

7711c0
From 20c0317b7984c5264e80c909227e1a78e82cc45a Mon Sep 17 00:00:00 2001
7711c0
From: Peter Xu <peterx@redhat.com>
7711c0
Date: Thu, 8 Nov 2018 05:37:17 +0100
7711c0
Subject: [PATCH 10/22] intel-iommu: replace more vtd_err_* traces
7711c0
MIME-Version: 1.0
7711c0
Content-Type: text/plain; charset=UTF-8
7711c0
Content-Transfer-Encoding: 8bit
7711c0
7711c0
RH-Author: Peter Xu <peterx@redhat.com>
7711c0
Message-id: <20181108053721.13162-4-peterx@redhat.com>
7711c0
Patchwork-id: 82953
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 3/7] intel-iommu: replace more vtd_err_* traces
7711c0
Bugzilla: 1627272
7711c0
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
7711c0
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
7711c0
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7711c0
7711c0
Replace all the trace_vtd_err_*() hooks with the new error_report_once()
7711c0
since they are similar to trace_vtd_err() - dumping the first error
7711c0
would be mostly enough, then we have them on by default too.
7711c0
7711c0
Signed-off-by: Peter Xu <peterx@redhat.com>
7711c0
Message-Id: <20180815095328.32414-4-peterx@redhat.com>
7711c0
[Use "%x" instead of "%" PRIx16 to print uint16_t, whitespace tidied up]
7711c0
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7711c0
(cherry picked from commit 4e4abd111a2af0179a4467368d695958844bf113)
7711c0
Signed-off-by: Peter Xu <peterx@redhat.com>
7711c0
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 hw/i386/intel_iommu.c | 64 ++++++++++++++++++++++++++++++++++++---------------
7711c0
 hw/i386/trace-events  | 12 ----------
7711c0
 2 files changed, 46 insertions(+), 30 deletions(-)
7711c0
7711c0
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
7711c0
index ab11cc4..aab86e9 100644
7711c0
--- a/hw/i386/intel_iommu.c
7711c0
+++ b/hw/i386/intel_iommu.c
7711c0
@@ -705,7 +705,8 @@ static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write,
7711c0
     uint64_t access_right_check;
7711c0
 
7711c0
     if (!vtd_iova_range_check(iova, ce, aw_bits)) {
7711c0
-        trace_vtd_err_dmar_iova_overflow(iova);
7711c0
+        error_report_once("%s: detected IOVA overflow (iova=0x%" PRIx64 ")",
7711c0
+                          __func__, iova);
7711c0
         return -VTD_FR_ADDR_BEYOND_MGAW;
7711c0
     }
7711c0
 
7711c0
@@ -717,7 +718,8 @@ static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write,
7711c0
         slpte = vtd_get_slpte(addr, offset);
7711c0
 
7711c0
         if (slpte == (uint64_t)-1) {
7711c0
-            trace_vtd_err_dmar_slpte_read_error(iova, level);
7711c0
+            error_report_once("%s: detected read error on DMAR slpte "
7711c0
+                              "(iova=0x%" PRIx64 ")", __func__, iova);
7711c0
             if (level == vtd_ce_get_level(ce)) {
7711c0
                 /* Invalid programming of context-entry */
7711c0
                 return -VTD_FR_CONTEXT_ENTRY_INV;
7711c0
@@ -728,11 +730,17 @@ static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write,
7711c0
         *reads = (*reads) && (slpte & VTD_SL_R);
7711c0
         *writes = (*writes) && (slpte & VTD_SL_W);
7711c0
         if (!(slpte & access_right_check)) {
7711c0
-            trace_vtd_err_dmar_slpte_perm_error(iova, level, slpte, is_write);
7711c0
+            error_report_once("%s: detected slpte permission error "
7711c0
+                              "(iova=0x%" PRIx64 ", level=0x%" PRIx32 ", "
7711c0
+                              "slpte=0x%" PRIx64 ", write=%d)", __func__,
7711c0
+                              iova, level, slpte, is_write);
7711c0
             return is_write ? -VTD_FR_WRITE : -VTD_FR_READ;
7711c0
         }
7711c0
         if (vtd_slpte_nonzero_rsvd(slpte, level)) {
7711c0
-            trace_vtd_err_dmar_slpte_resv_error(iova, level, slpte);
7711c0
+            error_report_once("%s: detected splte reserve non-zero "
7711c0
+                              "iova=0x%" PRIx64 ", level=0x%" PRIx32
7711c0
+                              "slpte=0x%" PRIx64 ")", __func__, iova,
7711c0
+                              level, slpte);
7711c0
             return -VTD_FR_PAGING_ENTRY_RSVD;
7711c0
         }
7711c0
 
7711c0
@@ -1697,7 +1705,10 @@ static void vtd_handle_gcmd_qie(IntelIOMMUState *s, bool en)
7711c0
             /* Ok - report back to driver */
7711c0
             vtd_set_clear_mask_long(s, DMAR_GSTS_REG, VTD_GSTS_QIES, 0);
7711c0
         } else {
7711c0
-            trace_vtd_err_qi_disable(s->iq_head, s->iq_tail, s->iq_last_desc_type);
7711c0
+            error_report_once("%s: detected improper state when disable QI "
7711c0
+                              "(head=0x%x, tail=0x%x, last_type=%d)",
7711c0
+                              __func__,
7711c0
+                              s->iq_head, s->iq_tail, s->iq_last_desc_type);
7711c0
         }
7711c0
     }
7711c0
 }
7711c0
@@ -2094,7 +2105,9 @@ static void vtd_fetch_inv_desc(IntelIOMMUState *s)
7711c0
 
7711c0
     if (s->iq_tail >= s->iq_size) {
7711c0
         /* Detects an invalid Tail pointer */
7711c0
-        trace_vtd_err_qi_tail(s->iq_tail, s->iq_size);
7711c0
+        error_report_once("%s: detected invalid QI tail "
7711c0
+                          "(tail=0x%x, size=0x%x)",
7711c0
+                          __func__, s->iq_tail, s->iq_size);
7711c0
         vtd_handle_inv_queue_error(s);
7711c0
         return;
7711c0
     }
7711c0
@@ -2507,10 +2520,12 @@ static IOMMUTLBEntry vtd_iommu_translate(IOMMUMemoryRegion *iommu, hwaddr addr,
7711c0
                                  iotlb.iova, iotlb.translated_addr,
7711c0
                                  iotlb.addr_mask);
7711c0
     } else {
7711c0
-        trace_vtd_err_dmar_translate(pci_bus_num(vtd_as->bus),
7711c0
-                                     VTD_PCI_SLOT(vtd_as->devfn),
7711c0
-                                     VTD_PCI_FUNC(vtd_as->devfn),
7711c0
-                                     iotlb.iova);
7711c0
+        error_report_once("%s: detected translation failure "
7711c0
+                          "(dev=%02x:%02x:%02x, iova=0x%" PRIx64 ")",
7711c0
+                          __func__, pci_bus_num(vtd_as->bus),
7711c0
+                          VTD_PCI_SLOT(vtd_as->devfn),
7711c0
+                          VTD_PCI_FUNC(vtd_as->devfn),
7711c0
+                          iotlb.iova);
7711c0
     }
7711c0
 
7711c0
     return iotlb;
7711c0
@@ -2626,15 +2641,19 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t index,
7711c0
                           le64_to_cpu(entry->data[0]));
7711c0
 
7711c0
     if (!entry->irte.present) {
7711c0
-        trace_vtd_err_irte(index, le64_to_cpu(entry->data[1]),
7711c0
-                           le64_to_cpu(entry->data[0]));
7711c0
+        error_report_once("%s: detected non-present IRTE "
7711c0
+                          "(index=%u, high=0x%" PRIx64 ", low=0x%" PRIx64 ")",
7711c0
+                          __func__, index, le64_to_cpu(entry->data[1]),
7711c0
+                          le64_to_cpu(entry->data[0]));
7711c0
         return -VTD_FR_IR_ENTRY_P;
7711c0
     }
7711c0
 
7711c0
     if (entry->irte.__reserved_0 || entry->irte.__reserved_1 ||
7711c0
         entry->irte.__reserved_2) {
7711c0
-        trace_vtd_err_irte(index, le64_to_cpu(entry->data[1]),
7711c0
-                           le64_to_cpu(entry->data[0]));
7711c0
+        error_report_once("%s: detected non-zero reserved IRTE "
7711c0
+                          "(index=%u, high=0x%" PRIx64 ", low=0x%" PRIx64 ")",
7711c0
+                          __func__, index, le64_to_cpu(entry->data[1]),
7711c0
+                          le64_to_cpu(entry->data[0]));
7711c0
         return -VTD_FR_IR_IRTE_RSVD;
7711c0
     }
7711c0
 
7711c0
@@ -2648,7 +2667,9 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t index,
7711c0
         case VTD_SVT_ALL:
7711c0
             mask = vtd_svt_mask[entry->irte.sid_q];
7711c0
             if ((source_id & mask) != (sid & mask)) {
7711c0
-                trace_vtd_err_irte_sid(index, sid, source_id);
7711c0
+                error_report_once("%s: invalid IRTE SID "
7711c0
+                                  "(index=%u, sid=%u, source_id=%u)",
7711c0
+                                  __func__, index, sid, source_id);
7711c0
                 return -VTD_FR_IR_SID_ERR;
7711c0
             }
7711c0
             break;
7711c0
@@ -2658,13 +2679,17 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t index,
7711c0
             bus_min = source_id & 0xff;
7711c0
             bus = sid >> 8;
7711c0
             if (bus > bus_max || bus < bus_min) {
7711c0
-                trace_vtd_err_irte_sid_bus(index, bus, bus_min, bus_max);
7711c0
+                error_report_once("%s: invalid SVT_BUS "
7711c0
+                                  "(index=%u, bus=%u, min=%u, max=%u)",
7711c0
+                                  __func__, index, bus, bus_min, bus_max);
7711c0
                 return -VTD_FR_IR_SID_ERR;
7711c0
             }
7711c0
             break;
7711c0
 
7711c0
         default:
7711c0
-            trace_vtd_err_irte_svt(index, entry->irte.sid_vtype);
7711c0
+            error_report_once("%s: detected invalid IRTE SVT "
7711c0
+                              "(index=%u, type=%d)", __func__,
7711c0
+                              index, entry->irte.sid_vtype);
7711c0
             /* Take this as verification failure. */
7711c0
             return -VTD_FR_IR_SID_ERR;
7711c0
             break;
7711c0
@@ -2786,7 +2811,10 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu,
7711c0
     if (addr.addr.sub_valid) {
7711c0
         trace_vtd_ir_remap_type("MSI");
7711c0
         if (origin->data & VTD_IR_MSI_DATA_RESERVED) {
7711c0
-            trace_vtd_err_ir_msi_invalid(sid, origin->address, origin->data);
7711c0
+            error_report_once("%s: invalid IR MSI "
7711c0
+                              "(sid=%u, address=0x%" PRIx64
7711c0
+                              ", data=0x%" PRIx32 ")",
7711c0
+                              __func__, sid, origin->address, origin->data);
7711c0
             return -VTD_FR_IR_REQ_RSVD;
7711c0
         }
7711c0
     } else {
7711c0
diff --git a/hw/i386/trace-events b/hw/i386/trace-events
7711c0
index 922431b..9e6fc4d 100644
7711c0
--- a/hw/i386/trace-events
7711c0
+++ b/hw/i386/trace-events
7711c0
@@ -69,19 +69,7 @@ vtd_ir_remap_msi_req(uint64_t addr, uint64_t data) "addr 0x%"PRIx64" data 0x%"PR
7711c0
 vtd_fsts_ppf(bool set) "FSTS PPF bit set to %d"
7711c0
 vtd_fsts_clear_ip(void) ""
7711c0
 vtd_frr_new(int index, uint64_t hi, uint64_t lo) "index %d high 0x%"PRIx64" low 0x%"PRIx64
7711c0
-vtd_err_dmar_iova_overflow(uint64_t iova) "iova 0x%"PRIx64
7711c0
-vtd_err_dmar_slpte_read_error(uint64_t iova, int level) "iova 0x%"PRIx64" level %d"
7711c0
-vtd_err_dmar_slpte_perm_error(uint64_t iova, int level, uint64_t slpte, bool is_write) "iova 0x%"PRIx64" level %d slpte 0x%"PRIx64" write %d"
7711c0
-vtd_err_dmar_slpte_resv_error(uint64_t iova, int level, uint64_t slpte) "iova 0x%"PRIx64" level %d slpte 0x%"PRIx64
7711c0
-vtd_err_dmar_translate(uint8_t bus, uint8_t slot, uint8_t func, uint64_t iova) "dev %02x:%02x.%02x iova 0x%"PRIx64
7711c0
 vtd_warn_invalid_qi_tail(uint16_t tail) "tail 0x%"PRIx16
7711c0
-vtd_err_qi_disable(uint16_t head, uint16_t tail, int type) "head 0x%"PRIx16" tail 0x%"PRIx16" last_desc_type %d"
7711c0
-vtd_err_qi_tail(uint16_t tail, uint16_t size) "tail 0x%"PRIx16" size 0x%"PRIx16
7711c0
-vtd_err_irte(int index, uint64_t lo, uint64_t hi) "index %d low 0x%"PRIx64" high 0x%"PRIx64
7711c0
-vtd_err_irte_sid(int index, uint16_t req, uint16_t target) "index %d SVT_ALL sid 0x%"PRIx16" (should be: 0x%"PRIx16")"
7711c0
-vtd_err_irte_sid_bus(int index, uint8_t bus, uint8_t min, uint8_t max) "index %d SVT_BUS bus 0x%"PRIx8" (should be: 0x%"PRIx8"-0x%"PRIx8")"
7711c0
-vtd_err_irte_svt(int index, int type) "index %d SVT type %d"
7711c0
-vtd_err_ir_msi_invalid(uint16_t sid, uint64_t addr, uint64_t data) "sid 0x%"PRIx16" addr 0x%"PRIx64" data 0x%"PRIx64
7711c0
 vtd_warn_ir_vector(uint16_t sid, int index, int vec, int target) "sid 0x%"PRIx16" index %d vec %d (should be: %d)"
7711c0
 vtd_warn_ir_trigger(uint16_t sid, int index, int trig, int target) "sid 0x%"PRIx16" index %d trigger %d (should be: %d)"
7711c0
 
7711c0
-- 
7711c0
1.8.3.1
7711c0