[SRU][PATCH 00/10][f/gcp] Fix nvme errors w/ swiotlb in confidential VMs

Khalid Elmously khalid.elmously at canonical.com
Fri Sep 17 05:48:46 UTC 2021


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

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

[Fix]
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

[Test]
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
ink=0
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


Christoph Hellwig (7):
  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

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

Khalid Elmously (1):
  UBUNTU: SAUCE: Add definitions for NVME_CTRL_PAGE_(SHIFT|SIZE)

 drivers/nvme/host/nvme.h    |  10 ++
 drivers/nvme/host/pci.c     |   1 +
 include/linux/device.h      |   1 +
 include/linux/dma-mapping.h |  16 +++
 include/linux/swiotlb.h     |   1 +
 kernel/dma/swiotlb.c        | 264 ++++++++++++++++++++----------------
 6 files changed, 176 insertions(+), 117 deletions(-)

-- 
2.17.1




More information about the kernel-team mailing list