[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 84/91] hw/i386/amd_iommu: Fix IOMMU event log encoding errors
From: |
Michael S. Tsirkin |
Subject: |
[PULL 84/91] hw/i386/amd_iommu: Fix IOMMU event log encoding errors |
Date: |
Mon, 16 May 2022 06:40:30 -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 75/91] qmp: add QMP commands for virtio/vhost queue-status, (continued)
- [PULL 75/91] qmp: add QMP commands for virtio/vhost queue-status, Michael S. Tsirkin, 2022/05/16
- [PULL 74/91] qmp: decode feature & status bits in virtio-status, Michael S. Tsirkin, 2022/05/16
- [PULL 76/91] qmp: add QMP command x-query-virtio-queue-element, Michael S. Tsirkin, 2022/05/16
- [PULL 78/91] vhost-user: more master/slave things, Michael S. Tsirkin, 2022/05/16
- [PULL 77/91] hmp: add virtio commands, Michael S. Tsirkin, 2022/05/16
- [PULL 80/91] include/hw/pci/pcie_host: Correct PCIE_MMCFG_BUS_MASK, Michael S. Tsirkin, 2022/05/16
- [PULL 81/91] include/hw/pci/pcie_host: Correct PCIE_MMCFG_SIZE_MAX, Michael S. Tsirkin, 2022/05/16
- [PULL 82/91] hw/i386: Make pit a property of common x86 base machine type, Michael S. Tsirkin, 2022/05/16
- [PULL 83/91] hw/i386: Make pic a property of common x86 base machine type, Michael S. Tsirkin, 2022/05/16
- [PULL 79/91] docs/vhost-user: Clarifications for VHOST_USER_ADD/REM_MEM_REG, Michael S. Tsirkin, 2022/05/16
- [PULL 84/91] hw/i386/amd_iommu: Fix IOMMU event log encoding errors,
Michael S. Tsirkin <=
- [PULL 86/91] virtio-net: align ctrl_vq index for non-mq guest for vhost_vdpa, Michael S. Tsirkin, 2022/05/16
- [PULL 87/91] vhost-vdpa: fix improper cleanup in net_init_vhost_vdpa, Michael S. Tsirkin, 2022/05/16
- [PULL 88/91] vhost-net: fix improper cleanup in vhost_net_start, Michael S. Tsirkin, 2022/05/16
- [PULL 89/91] vhost-vdpa: backend feature should set only once, Michael S. Tsirkin, 2022/05/16
- [PULL 91/91] virtio-net: don't handle mq request in userspace handler for vhost-vdpa, Michael S. Tsirkin, 2022/05/16
- [PULL 90/91] vhost-vdpa: change name and polarity for vhost_vdpa_one_time_request(), Michael S. Tsirkin, 2022/05/16
- [PULL 85/91] virtio-net: setup vhost_dev and notifiers for cvq only when feature is negotiated, Michael S. Tsirkin, 2022/05/16
- Re: [PULL 00/91] virtio,pc,pci: fixes,cleanups,features, Richard Henderson, 2022/05/16