cryptospore / rpms / qemu-kvm

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