NAK/cmnt: [SRU][PATCH v2 0/9][f/gcp] Fix nvme errors w/ swiotlb in confidential VMs

Kleber Souza kleber.souza at canonical.com
Tue Sep 21 09:53:03 UTC 2021


On 21.09.21 03:28, Khalid Elmously wrote:
> 
> v2:
>    Merged the NVME_CTRL_PAGE_[SIZE|SHIFT] definitions into last patch
> 
> 
> 
> 
> 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

I think that at least the index var type issue on the above commit
should be fixed, and potentially the other comments/issues as well.

> 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
> 
>   drivers/nvme/host/pci.c     |   8 +
>   include/linux/device.h      |   1 +
>   include/linux/dma-mapping.h |  16 +++
>   include/linux/swiotlb.h     |   1 +
>   kernel/dma/swiotlb.c        | 264 ++++++++++++++++++++----------------
>   5 files changed, 176 insertions(+), 117 deletions(-)
> 




More information about the kernel-team mailing list