Skip to content

CONFIG_AMD_MEM_ENCRYPT will modify the size of SWIOTLB in TD guest

Test Environment

  • Host/Guest: CentOS Stream release 9
  • Host/Guest kernel version: 5.14.0-362.el9s.x86_64
  • Architecture: x86
  • QEMU flavor: qemu-system-x86_64(/usr/libexec/qemu-kvm)
  • QEMU version: qemu-kvm-8.0.0-14.el9s

Bug description CONFIG_AMD_MEM_ENCRYPT will modify the size of SWIOTLB in TD guest

  • QEMU command line:
/usr/libexec/qemu-kvm \
     -accel kvm \
     -m 64G -smp 64 \
     -name process=tdxvm,debug-threads=on \
     -cpu host \
     -object tdx-guest,id=tdx \
     -machine q35,hpet=off,kernel_irqchip=split,memory-encryption=tdx,memory-backend=ram1 \
     -object memory-backend-ram,id=ram1,size=64G,private=on \
     -nographic -vga none \
     -chardev stdio,id=mux,mux=on,signal=off -device virtio-serial -device virtconsole,chardev=mux \
     -bios /usr/share/edk2/ovmf/OVMF.inteltdx.fd \
     -serial chardev:mux \
     -nodefaults \
     -device virtio-net-pci,netdev=nic0 -netdev user,id=nic0,hostfwd=tcp::10022-:22 \
     -drive file=/home/tdx/centos9.qcow2,if=none,id=virtio-disk0 \
     -device virtio-blk-pci,drive=virtio-disk0 \

Reproduce steps

Boot td guest, check TLB in dmesg

[root@localhost ~]# dmesg|grep TLB

[ 0.017861] software IO TLB: SWIOTLB bounce buffer size adjusted to 1024MB

[ 0.774626] software IO TLB: area num 128.

[ 1.258124] Last level iTLB entries: 4KB 0, 2MB 0, 4MB 0

[ 1.258124] Last level dTLB entries: 4KB 0, 2MB 0, 4MB 0, 1GB 0

[ 6.863336] HugeTLB: registered 1.00 GiB page size, pre-allocated 0 pages

[ 6.863336] HugeTLB: 16380 KiB vmemmap can be freed for a 1.00 GiB page

[ 6.863336] HugeTLB: registered 2.00 MiB page size, pre-allocated 0 pages

[ 6.863336] HugeTLB: 28 KiB vmemmap can be freed for a 2.00 MiB page

[ 6.916226] iommu: DMA domain TLB invalidation policy: lazy mode

[ 7.171264] PCI-DMA: Using software bounce buffering for IO (SWIOTLB)

[ 7.171264] software IO TLB: mapped [mem 0x000000000a000000-0x000000004a000000] (1024MB)

[ 13.978567] software IO TLB: Memory encryption is active and system is using DMA bounce buffers

Expected result

CONFIG_AMD_MEM_ENCRYPT cannot change the SWIOTLB size of TD guest