hw/nvme: fix validation of ASQ and ACQ
PATCH 1/1 hw/nvme: fix validation of ASQ and ACQ
From: Klaus Jensen <[email protected]>
Address 0x0 is a valid address. Fix the admin submission and completion queue address validation to not error out on this.
--- hw/nvme/ctrl.c | 8 -------- hw/nvme/trace-events | 2 -- 2 files changed, 10 deletions(-)
hw/nvme/ctrl.c +0 -8
@@ -5623,14 +5623,6 @@ static int nvme_start_ctrl(NvmeCtrl *n)trace_pci_nvme_err_startfail_sq ();return -1 ; } -if (unlikely (!asq)) { -trace_pci_nvme_err_startfail_nbarasq (); -return -1 ; - } -if (unlikely (!acq)) { -trace_pci_nvme_err_startfail_nbaracq (); -return -1 ; - }if (unlikely (asq & (page_size -1 ))) {trace_pci_nvme_err_startfail_asq_misaligned (asq);return -1 ;
hw/nvme/trace-events +0 -2
@@ -159,8 +159,6 @@ pci_nvme_err_invalid_setfeat(uint32_t dw10) "invalid set features, dw10=0x%"PRIx pci_nvme_err_invalid_log_page(uint16_t cid, uint16_t lid) "cid %"PRIu16" lid 0x%"PRIx16"" pci_nvme_err_startfail_cq(void) "nvme_start_ctrl failed because there are non-admin completion queues" pci_nvme_err_startfail_sq(void) "nvme_start_ctrl failed because there are non-admin submission queues" -pci_nvme_err_startfail_nbarasq(void) "nvme_start_ctrl failed because the admin submission queue address is null" -pci_nvme_err_startfail_nbaracq(void) "nvme_start_ctrl failed because the admin completion queue address is null" pci_nvme_err_startfail_asq_misaligned(uint64_t addr) "nvme_start_ctrl failed because the admin submission queue address is misaligned: 0x%"PRIx64"" pci_nvme_err_startfail_acq_misaligned(uint64_t addr) "nvme_start_ctrl failed because the admin completion queue address is misaligned: 0x%"PRIx64"" pci_nvme_err_startfail_page_too_small(uint8_t log2ps, uint8_t maxlog2ps) "nvme_start_ctrl failed because the page size is too small: log2size=%u, min=%u"
Signature · 1 line
2.32.0
Quoted 4 lines · Klaus Jensen
From: Klaus Jensen <[email protected]>
Address
0x0is a valid address. Fix the admin submission and completion queue address validation to not error out on this.
Indeed, there are environments that can use that address. It's a host error if the controller was enabled with invalid queue addresses anyway. The controller only needs to verify the lower bits are clear, which we do later.
Klaus Jensen
AppliedQuoted 12 lines · Keith Busch
Quoted 4 lines · Klaus Jensen
From: Klaus Jensen <[email protected]>
Address
0x0is a valid address. Fix the admin submission and completion queue address validation to not error out on this.Indeed, there are environments that can use that address. It's a host error if the controller was enabled with invalid queue addresses anyway. The controller only needs to verify the lower bits are clear, which we do later.
Reviewed-by Keith Busch <[email protected]>
Thanks Keith,
Yeah, I noticed this with a VFIO-based driver where the IOVAs typically start at 0x0.
And yes, I specifically refrained from adding any other sanity checks on the addresses. I.e., we could add a check for ASQ != ACQ, but who are we to judge ;)
Applied to nvme-next!