diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2021-07-26 19:19:36 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2021-07-26 19:19:36 +0100 |
| commit | 76bf66b9136ce373f006f68b0ef4819abc797054 (patch) | |
| tree | 1133f3cc4627a4ccbced686ecf17d35c9c94630d | |
| parent | 1d6f147f043bece029a795c6eb9d43c1abd909b6 (diff) | |
| parent | 15a730e7a3aaac180df72cd5730e0617bcf44a5a (diff) | |
| download | focaccia-qemu-76bf66b9136ce373f006f68b0ef4819abc797054.tar.gz focaccia-qemu-76bf66b9136ce373f006f68b0ef4819abc797054.zip | |
Merge remote-tracking branch 'remotes/stefanha-gitlab/tags/block-pull-request' into staging
Pull request Phil's block/nvme.c ENOSPC fix for newer Linux kernels that return this errno. # gpg: Signature made Mon 26 Jul 2021 09:53:01 BST # gpg: using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full] # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" [full] # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * remotes/stefanha-gitlab/tags/block-pull-request: block/nvme: Fix VFIO_MAP_DMA failed: No space left on device Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
| -rw-r--r-- | block/nvme.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/block/nvme.c b/block/nvme.c index 2b5421e7aa..e8dbbc2317 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1030,7 +1030,29 @@ try_map: r = qemu_vfio_dma_map(s->vfio, qiov->iov[i].iov_base, len, true, &iova); + if (r == -ENOSPC) { + /* + * In addition to the -ENOMEM error, the VFIO_IOMMU_MAP_DMA + * ioctl returns -ENOSPC to signal the user exhausted the DMA + * mappings available for a container since Linux kernel commit + * 492855939bdb ("vfio/type1: Limit DMA mappings per container", + * April 2019, see CVE-2019-3882). + * + * This block driver already handles this error path by checking + * for the -ENOMEM error, so we directly replace -ENOSPC by + * -ENOMEM. Beside, -ENOSPC has a specific meaning for blockdev + * coroutines: it triggers BLOCKDEV_ON_ERROR_ENOSPC and + * BLOCK_ERROR_ACTION_STOP which stops the VM, asking the operator + * to add more storage to the blockdev. Not something we can do + * easily with an IOMMU :) + */ + r = -ENOMEM; + } if (r == -ENOMEM && retry) { + /* + * We exhausted the DMA mappings available for our container: + * recycle the volatile IOVA mappings. + */ retry = false; trace_nvme_dma_flush_queue_wait(s); if (s->dma_map_count) { |