On 1/18/21 1:28 PM, Takashi Iwai wrote:
Hi,

we've got a bug report recently about the garbage playback sound from
a PCI sound device with mem_encrypt on AMD Ryzen:
    
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.kernel.org%2Fshow_bug.cgi%3Fid%3D211117&data=04%7C01%7Cthomas.lendacky%40amd.com%7C8f5024e991b747d3aada08d8bbe73df5%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637465949142766079%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=4i6%2BUkt%2BebHJPlAvkDxgJkIcKq0eF9E4ssZC9vNBLHY%3D&reserved=0

The debug session showed that this happens only with the mmap using
dma_mmap_coherent() and mem_encrypt.  The mmap with the legacy page
fault (as done in ALSA PCM core) seems still working even with the
mem_encrypt.

This sounds like a mismatch between the encryption bit in the kernel and the encryption bit in userspace. It looks like that should be taken care of by the dma_pgprot() call in dma_mmap_attrs() or in iommu_dma_mmap(). But maybe the force_dma_unencrypted() in arch/x86/mm/mem_encrypt.c needs to understand if the IOMMU is doing the mapping. Since, even if the device doesn't support 48-bit or higher DMA, it will still done encrypted because of the IOMMU. Is the IOMMU enabled? What happens if you do iommu=pt on the kernel command line?

I'll also add this comment to the bug.

Thanks,
Tom


Since the problem could be observed on two different PCI drivers, it
looks like a generic problem of DMA-mmap implementation with AMD
memory encryption.

According to the reporter, it's seen on both 5.4.x and 5.10.x
kernels, hence it doesn't like a recent regression.

Can anyone take a look?


Thanks!

Takashi

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to