[SRU][PATCH v3 0/13][f/gcp] Fix nvme errors w/ swiotlb in confidential VMs

Khalid Elmously khalid.elmously at canonical.com
Thu Oct 7 18:06:31 UTC 2021

BugLink: https://bugs.launchpad.net/bugs/1943902

Using nvme with swiotlb in confidential VMs can encounter hardware read/write errors.

The following upstream patches from v5.12 address this:

3d2d861eb03e nvme-pci: set min_align_mask
1f221a0d0dbf swiotlb: respect min_align_mask
16fc3cef33a0 swiotlb: don't modify orig_addr in swiotlb_tbl_sync_single
26a7e094783d swiotlb: refactor swiotlb_tbl_map_single
ca10d0f8e530 swiotlb: clean up swiotlb_tbl_unmap_single
c32a77fd1878 swiotlb: factor out a nr_slots helper
c7fbeca757fe swiotlb: factor out an io_tlb_offset helper
b5d7ccb7aac3 swiotlb: add a IO_TLB_SIZE define

Using a confidential VM, with 'swiotlb=force' set on the kernel command line, and an additional nvme device attached:

$ sudo mkfs.xfs -f /dev/nvme2n1
meta-data=/dev/nvme2n1 isize=512 agcount=4, agsize=131072 blks
         = sectsz=512 attr=2, projid32bit=1
         = crc=1 finobt=1, sparse=0, rmapbt=0, refl
data = bsize=4096 blocks=524288, imaxpct=25
         = sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
         = sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
mkfs.xfs: pwrite failed: Input/output error

Note the input/output error

The error no longer happens with the fixes applied.

[Regression Potential]
Potential regression in swiotlb could cause hardware read/write errors

  Merged the NVME_CTRL_PAGE_[SIZE|SHIFT] definitions into last patch

  Included further follow-up fixes.

Bumyong Lee (1):
  swiotlb: manipulate orig_addr when tlb_addr has offset

Christoph Hellwig (9):
  swiotlb: add a IO_TLB_SIZE define
  swiotlb: factor out an io_tlb_offset helper
  swiotlb: factor out a nr_slots helper
  swiotlb: clean up swiotlb_tbl_unmap_single
  swiotlb: refactor swiotlb_tbl_map_single
  swiotlb: don't modify orig_addr in swiotlb_tbl_sync_single
  swiotlb: respect min_align_mask
  swiotlb: remove the tbl_dma_addr argument to swiotlb_tbl_map_single
  swiotlb: move orig addr and size validation into swiotlb_bounce

Claire Chang (1):
  swiotlb: Fix the type of index

Jianxiong Gao (2):
  driver core: add a min_align_mask field to struct
  nvme-pci: set min_align_mask

 drivers/iommu/intel-iommu.c |   1 -
 drivers/nvme/host/pci.c     |   9 ++
 drivers/xen/swiotlb-xen.c   |   3 +-
 include/linux/device.h      |   1 +
 include/linux/dma-mapping.h |  16 ++
 include/linux/swiotlb.h     |  11 +-
 kernel/dma/swiotlb.c        | 306 ++++++++++++++++++++----------------
 7 files changed, 199 insertions(+), 148 deletions(-)


More information about the kernel-team mailing list