Blame SOURCES/kvm-intel-iommu-start-to-use-error_report_once.patch

7711c0
From 6c5d8bb3a12e24bdd909beb2ed2c9d6adffdef36 Mon Sep 17 00:00:00 2001
7711c0
From: Peter Xu <peterx@redhat.com>
7711c0
Date: Thu, 8 Nov 2018 05:37:16 +0100
7711c0
Subject: [PATCH 09/22] intel-iommu: start to use error_report_once
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-3-peterx@redhat.com>
7711c0
Patchwork-id: 82954
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 2/7] intel-iommu: start to use error_report_once
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 existing trace_vtd_err() with error_report_once() then stderr
7711c0
will capture something if any of the error happens, meanwhile we don't
7711c0
suffer from any DDOS.  Then remove the trace point.  Since at it,
7711c0
provide more information where proper (now we can pass parameters into
7711c0
the report function).
7711c0
7711c0
Signed-off-by: Peter Xu <peterx@redhat.com>
7711c0
Message-Id: <20180815095328.32414-3-peterx@redhat.com>
7711c0
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7711c0
[Two format strings fixed, whitespace tidied up]
7711c0
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7711c0
(cherry picked from commit 1376211f77bdcd84dc4acb877690f7399d8cf58a)
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 | 65 +++++++++++++++++++++++++++++----------------------
7711c0
 hw/i386/trace-events  |  1 -
7711c0
 2 files changed, 37 insertions(+), 29 deletions(-)
7711c0
7711c0
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
7711c0
index b5a09b7..ab11cc4 100644
7711c0
--- a/hw/i386/intel_iommu.c
7711c0
+++ b/hw/i386/intel_iommu.c
7711c0
@@ -311,14 +311,14 @@ static void vtd_generate_fault_event(IntelIOMMUState *s, uint32_t pre_fsts)
7711c0
 {
7711c0
     if (pre_fsts & VTD_FSTS_PPF || pre_fsts & VTD_FSTS_PFO ||
7711c0
         pre_fsts & VTD_FSTS_IQE) {
7711c0
-        trace_vtd_err("There are previous interrupt conditions "
7711c0
-                      "to be serviced by software, fault event "
7711c0
-                      "is not generated.");
7711c0
+        error_report_once("There are previous interrupt conditions "
7711c0
+                          "to be serviced by software, fault event "
7711c0
+                          "is not generated");
7711c0
         return;
7711c0
     }
7711c0
     vtd_set_clear_mask_long(s, DMAR_FECTL_REG, 0, VTD_FECTL_IP);
7711c0
     if (vtd_get_long_raw(s, DMAR_FECTL_REG) & VTD_FECTL_IM) {
7711c0
-        trace_vtd_err("Interrupt Mask set, irq is not generated.");
7711c0
+        error_report_once("Interrupt Mask set, irq is not generated");
7711c0
     } else {
7711c0
         vtd_generate_interrupt(s, DMAR_FEADDR_REG, DMAR_FEDATA_REG);
7711c0
         vtd_set_clear_mask_long(s, DMAR_FECTL_REG, VTD_FECTL_IP, 0);
7711c0
@@ -426,20 +426,20 @@ static void vtd_report_dmar_fault(IntelIOMMUState *s, uint16_t source_id,
7711c0
     trace_vtd_dmar_fault(source_id, fault, addr, is_write);
7711c0
 
7711c0
     if (fsts_reg & VTD_FSTS_PFO) {
7711c0
-        trace_vtd_err("New fault is not recorded due to "
7711c0
-                      "Primary Fault Overflow.");
7711c0
+        error_report_once("New fault is not recorded due to "
7711c0
+                          "Primary Fault Overflow");
7711c0
         return;
7711c0
     }
7711c0
 
7711c0
     if (vtd_try_collapse_fault(s, source_id)) {
7711c0
-        trace_vtd_err("New fault is not recorded due to "
7711c0
-                      "compression of faults.");
7711c0
+        error_report_once("New fault is not recorded due to "
7711c0
+                          "compression of faults");
7711c0
         return;
7711c0
     }
7711c0
 
7711c0
     if (vtd_is_frcd_set(s, s->next_frcd_reg)) {
7711c0
-        trace_vtd_err("Next Fault Recording Reg is used, "
7711c0
-                      "new fault is not recorded, set PFO field.");
7711c0
+        error_report_once("Next Fault Recording Reg is used, "
7711c0
+                          "new fault is not recorded, set PFO field");
7711c0
         vtd_set_clear_mask_long(s, DMAR_FSTS_REG, 0, VTD_FSTS_PFO);
7711c0
         return;
7711c0
     }
7711c0
@@ -447,8 +447,8 @@ static void vtd_report_dmar_fault(IntelIOMMUState *s, uint16_t source_id,
7711c0
     vtd_record_frcd(s, s->next_frcd_reg, source_id, addr, fault, is_write);
7711c0
 
7711c0
     if (fsts_reg & VTD_FSTS_PPF) {
7711c0
-        trace_vtd_err("There are pending faults already, "
7711c0
-                      "fault event is not generated.");
7711c0
+        error_report_once("There are pending faults already, "
7711c0
+                          "fault event is not generated");
7711c0
         vtd_set_frcd_and_update_ppf(s, s->next_frcd_reg);
7711c0
         s->next_frcd_reg++;
7711c0
         if (s->next_frcd_reg == DMAR_FRCD_REG_NR) {
7711c0
@@ -1056,8 +1056,10 @@ static int vtd_sync_shadow_page_table_range(VTDAddressSpace *vtd_as,
7711c0
              * we just skip the sync for this time.  After all we even
7711c0
              * don't have the root table pointer!
7711c0
              */
7711c0
-            trace_vtd_err("Detected invalid context entry when "
7711c0
-                          "trying to sync shadow page table");
7711c0
+            error_report_once("%s: invalid context entry for bus 0x%x"
7711c0
+                              " devfn 0x%x",
7711c0
+                              __func__, pci_bus_num(vtd_as->bus),
7711c0
+                              vtd_as->devfn);
7711c0
             return 0;
7711c0
         }
7711c0
     }
7711c0
@@ -1514,7 +1516,8 @@ static uint64_t vtd_context_cache_invalidate(IntelIOMMUState *s, uint64_t val)
7711c0
         break;
7711c0
 
7711c0
     default:
7711c0
-        trace_vtd_err("Context cache invalidate type error.");
7711c0
+        error_report_once("%s: invalid context: 0x%" PRIx64,
7711c0
+                          __func__, val);
7711c0
         caig = 0;
7711c0
     }
7711c0
     return caig;
7711c0
@@ -1634,7 +1637,8 @@ static uint64_t vtd_iotlb_flush(IntelIOMMUState *s, uint64_t val)
7711c0
         am = VTD_IVA_AM(addr);
7711c0
         addr = VTD_IVA_ADDR(addr);
7711c0
         if (am > VTD_MAMV) {
7711c0
-            trace_vtd_err("IOTLB PSI flush: address mask overflow.");
7711c0
+            error_report_once("%s: address mask overflow: 0x%" PRIx64,
7711c0
+                              __func__, vtd_get_quad_raw(s, DMAR_IVA_REG));
7711c0
             iaig = 0;
7711c0
             break;
7711c0
         }
7711c0
@@ -1643,7 +1647,8 @@ static uint64_t vtd_iotlb_flush(IntelIOMMUState *s, uint64_t val)
7711c0
         break;
7711c0
 
7711c0
     default:
7711c0
-        trace_vtd_err("IOTLB flush: invalid granularity.");
7711c0
+        error_report_once("%s: invalid granularity: 0x%" PRIx64,
7711c0
+                          __func__, val);
7711c0
         iaig = 0;
7711c0
     }
7711c0
     return iaig;
7711c0
@@ -1793,8 +1798,8 @@ static void vtd_handle_ccmd_write(IntelIOMMUState *s)
7711c0
     /* Context-cache invalidation request */
7711c0
     if (val & VTD_CCMD_ICC) {
7711c0
         if (s->qi_enabled) {
7711c0
-            trace_vtd_err("Queued Invalidation enabled, "
7711c0
-                          "should not use register-based invalidation");
7711c0
+            error_report_once("Queued Invalidation enabled, "
7711c0
+                              "should not use register-based invalidation");
7711c0
             return;
7711c0
         }
7711c0
         ret = vtd_context_cache_invalidate(s, val);
7711c0
@@ -1814,8 +1819,8 @@ static void vtd_handle_iotlb_write(IntelIOMMUState *s)
7711c0
     /* IOTLB invalidation request */
7711c0
     if (val & VTD_TLB_IVT) {
7711c0
         if (s->qi_enabled) {
7711c0
-            trace_vtd_err("Queued Invalidation enabled, "
7711c0
-                          "should not use register-based invalidation.");
7711c0
+            error_report_once("Queued Invalidation enabled, "
7711c0
+                              "should not use register-based invalidation");
7711c0
             return;
7711c0
         }
7711c0
         ret = vtd_iotlb_flush(s, val);
7711c0
@@ -1833,7 +1838,7 @@ static bool vtd_get_inv_desc(dma_addr_t base_addr, uint32_t offset,
7711c0
     dma_addr_t addr = base_addr + offset * sizeof(*inv_desc);
7711c0
     if (dma_memory_read(&address_space_memory, addr, inv_desc,
7711c0
         sizeof(*inv_desc))) {
7711c0
-        trace_vtd_err("Read INV DESC failed.");
7711c0
+        error_report_once("Read INV DESC failed");
7711c0
         inv_desc->lo = 0;
7711c0
         inv_desc->hi = 0;
7711c0
         return false;
7711c0
@@ -2188,7 +2193,8 @@ static uint64_t vtd_mem_read(void *opaque, hwaddr addr, unsigned size)
7711c0
     trace_vtd_reg_read(addr, size);
7711c0
 
7711c0
     if (addr + size > DMAR_REG_SIZE) {
7711c0
-        trace_vtd_err("Read MMIO over range.");
7711c0
+        error_report_once("%s: MMIO over range: addr=0x%" PRIx64
7711c0
+                          " size=0x%u", __func__, addr, size);
7711c0
         return (uint64_t)-1;
7711c0
     }
7711c0
 
7711c0
@@ -2239,7 +2245,8 @@ static void vtd_mem_write(void *opaque, hwaddr addr,
7711c0
     trace_vtd_reg_write(addr, size, val);
7711c0
 
7711c0
     if (addr + size > DMAR_REG_SIZE) {
7711c0
-        trace_vtd_err("Write MMIO over range.");
7711c0
+        error_report_once("%s: MMIO over range: addr=0x%" PRIx64
7711c0
+                          " size=0x%u", __func__, addr, size);
7711c0
         return;
7711c0
     }
7711c0
 
7711c0
@@ -2610,7 +2617,8 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t index,
7711c0
     addr = iommu->intr_root + index * sizeof(*entry);
7711c0
     if (dma_memory_read(&address_space_memory, addr, entry,
7711c0
                         sizeof(*entry))) {
7711c0
-        trace_vtd_err("Memory read failed for IRTE.");
7711c0
+        error_report_once("%s: read failed: ind=0x%x addr=0x%" PRIx64,
7711c0
+                          __func__, index, addr);
7711c0
         return -VTD_FR_IR_ROOT_INVAL;
7711c0
     }
7711c0
 
7711c0
@@ -2742,14 +2750,15 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu,
7711c0
     }
7711c0
 
7711c0
     if (origin->address & VTD_MSI_ADDR_HI_MASK) {
7711c0
-        trace_vtd_err("MSI address high 32 bits non-zero when "
7711c0
-                      "Interrupt Remapping enabled.");
7711c0
+        error_report_once("%s: MSI address high 32 bits non-zero detected: "
7711c0
+                          "address=0x%" PRIx64, __func__, origin->address);
7711c0
         return -VTD_FR_IR_REQ_RSVD;
7711c0
     }
7711c0
 
7711c0
     addr.data = origin->address & VTD_MSI_ADDR_LO_MASK;
7711c0
     if (addr.addr.__head != 0xfee) {
7711c0
-        trace_vtd_err("MSI addr low 32 bit invalid.");
7711c0
+        error_report_once("%s: MSI address low 32 bit invalid: 0x%" PRIx32,
7711c0
+                          __func__, addr.data);
7711c0
         return -VTD_FR_IR_REQ_RSVD;
7711c0
     }
7711c0
 
7711c0
diff --git a/hw/i386/trace-events b/hw/i386/trace-events
7711c0
index e14d06e..922431b 100644
7711c0
--- a/hw/i386/trace-events
7711c0
+++ b/hw/i386/trace-events
7711c0
@@ -69,7 +69,6 @@ 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(const char *str) "%s"
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
-- 
7711c0
1.8.3.1
7711c0