[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 78/86] hw/i386/amd_iommu: Fix IOMMU event log encoding errors
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 78/86] hw/i386/amd_iommu: Fix IOMMU event log encoding errors |
Date: |
Mon, 16 May 2022 16:55:33 -0400 |
From: Wei Huang <wei.huang2@amd.com>
Coverity issues several UNINIT warnings against amd_iommu.c [1]. This
patch fixes them by clearing evt before encoding. On top of it, this
patch changes the event log size to 16 bytes per IOMMU specification,
and fixes the event log entry format in amdvi_encode_event().
[1] CID 1487116/1487200/1487190/1487232/1487115/1487258
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Wei Huang <wei.huang2@amd.com>
Message-Id: <20220422055146.3312226-1-wei.huang2@amd.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/amd_iommu.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index ea8eaeb330..725f69095b 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -201,15 +201,18 @@ static void amdvi_setevent_bits(uint64_t *buffer,
uint64_t value, int start,
/*
* AMDVi event structure
* 0:15 -> DeviceID
- * 55:63 -> event type + miscellaneous info
- * 63:127 -> related address
+ * 48:63 -> event type + miscellaneous info
+ * 64:127 -> related address
*/
static void amdvi_encode_event(uint64_t *evt, uint16_t devid, uint64_t addr,
uint16_t info)
{
+ evt[0] = 0;
+ evt[1] = 0;
+
amdvi_setevent_bits(evt, devid, 0, 16);
- amdvi_setevent_bits(evt, info, 55, 8);
- amdvi_setevent_bits(evt, addr, 63, 64);
+ amdvi_setevent_bits(evt, info, 48, 16);
+ amdvi_setevent_bits(evt, addr, 64, 64);
}
/* log an error encountered during a page walk
*
@@ -218,7 +221,7 @@ static void amdvi_encode_event(uint64_t *evt, uint16_t
devid, uint64_t addr,
static void amdvi_page_fault(AMDVIState *s, uint16_t devid,
hwaddr addr, uint16_t info)
{
- uint64_t evt[4];
+ uint64_t evt[2];
info |= AMDVI_EVENT_IOPF_I | AMDVI_EVENT_IOPF;
amdvi_encode_event(evt, devid, addr, info);
@@ -234,7 +237,7 @@ static void amdvi_page_fault(AMDVIState *s, uint16_t devid,
static void amdvi_log_devtab_error(AMDVIState *s, uint16_t devid,
hwaddr devtab, uint16_t info)
{
- uint64_t evt[4];
+ uint64_t evt[2];
info |= AMDVI_EVENT_DEV_TAB_HW_ERROR;
@@ -248,7 +251,8 @@ static void amdvi_log_devtab_error(AMDVIState *s, uint16_t
devid,
*/
static void amdvi_log_command_error(AMDVIState *s, hwaddr addr)
{
- uint64_t evt[4], info = AMDVI_EVENT_COMMAND_HW_ERROR;
+ uint64_t evt[2];
+ uint16_t info = AMDVI_EVENT_COMMAND_HW_ERROR;
amdvi_encode_event(evt, 0, addr, info);
amdvi_log_event(s, evt);
@@ -261,7 +265,7 @@ static void amdvi_log_command_error(AMDVIState *s, hwaddr
addr)
static void amdvi_log_illegalcom_error(AMDVIState *s, uint16_t info,
hwaddr addr)
{
- uint64_t evt[4];
+ uint64_t evt[2];
info |= AMDVI_EVENT_ILLEGAL_COMMAND_ERROR;
amdvi_encode_event(evt, 0, addr, info);
@@ -276,7 +280,7 @@ static void amdvi_log_illegalcom_error(AMDVIState *s,
uint16_t info,
static void amdvi_log_illegaldevtab_error(AMDVIState *s, uint16_t devid,
hwaddr addr, uint16_t info)
{
- uint64_t evt[4];
+ uint64_t evt[2];
info |= AMDVI_EVENT_ILLEGAL_DEVTAB_ENTRY;
amdvi_encode_event(evt, devid, addr, info);
@@ -288,7 +292,7 @@ static void amdvi_log_illegaldevtab_error(AMDVIState *s,
uint16_t devid,
static void amdvi_log_pagetab_error(AMDVIState *s, uint16_t devid,
hwaddr addr, uint16_t info)
{
- uint64_t evt[4];
+ uint64_t evt[2];
info |= AMDVI_EVENT_PAGE_TAB_HW_ERROR;
amdvi_encode_event(evt, devid, addr, info);
--
MST
- [PULL v2 68/86] hw/virtio/vhost-user: don't suppress F_CONFIG when supported, (continued)
- [PULL v2 68/86] hw/virtio/vhost-user: don't suppress F_CONFIG when supported, Michael S. Tsirkin, 2022/05/16
- [PULL v2 69/86] virtio/vhost-user: dynamically assign VhostUserHostNotifiers, Michael S. Tsirkin, 2022/05/16
- [PULL v2 70/86] virtio: drop name parameter for virtio_init(), Michael S. Tsirkin, 2022/05/16
- [PULL v2 71/86] virtio: add vhost support for virtio devices, Michael S. Tsirkin, 2022/05/16
- [PULL v2 75/86] include/hw/pci/pcie_host: Correct PCIE_MMCFG_SIZE_MAX, Michael S. Tsirkin, 2022/05/16
- [PULL v2 72/86] vhost-user: more master/slave things, Michael S. Tsirkin, 2022/05/16
- [PULL v2 73/86] docs/vhost-user: Clarifications for VHOST_USER_ADD/REM_MEM_REG, Michael S. Tsirkin, 2022/05/16
- [PULL v2 74/86] include/hw/pci/pcie_host: Correct PCIE_MMCFG_BUS_MASK, Michael S. Tsirkin, 2022/05/16
- [PULL v2 76/86] hw/i386: Make pit a property of common x86 base machine type, Michael S. Tsirkin, 2022/05/16
- [PULL v2 77/86] hw/i386: Make pic a property of common x86 base machine type, Michael S. Tsirkin, 2022/05/16
- [PULL v2 78/86] hw/i386/amd_iommu: Fix IOMMU event log encoding errors,
Michael S. Tsirkin <=
- [PULL v2 79/86] virtio-net: setup vhost_dev and notifiers for cvq only when feature is negotiated, Michael S. Tsirkin, 2022/05/16
- [PULL v2 80/86] virtio-net: align ctrl_vq index for non-mq guest for vhost_vdpa, Michael S. Tsirkin, 2022/05/16
- [PULL v2 81/86] vhost-vdpa: fix improper cleanup in net_init_vhost_vdpa, Michael S. Tsirkin, 2022/05/16
- [PULL v2 83/86] vhost-vdpa: backend feature should set only once, Michael S. Tsirkin, 2022/05/16
- [PULL v2 82/86] vhost-net: fix improper cleanup in vhost_net_start, Michael S. Tsirkin, 2022/05/16
- [PULL v2 84/86] vhost-vdpa: change name and polarity for vhost_vdpa_one_time_request(), Michael S. Tsirkin, 2022/05/16
- [PULL v2 85/86] virtio-net: don't handle mq request in userspace handler for vhost-vdpa, Michael S. Tsirkin, 2022/05/16
- [PULL v2 86/86] vhost-user-scsi: avoid unlink(NULL) with fd passing, Michael S. Tsirkin, 2022/05/16
- Re: [PULL v2 00/86] virtio,pc,pci: fixes,cleanups,features, Richard Henderson, 2022/05/16