yeahuh / rpms / qemu-kvm

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