Skip to contentSkip to conversation

Patch "iommu/amd: Clear memory encryption mask from physical address" has been added to the 4.14-stable tree

PATCH [email protected] 1 participant 1 message Oct 8, 2018 IOMMU

lore
Share & tools
lore

[email protected]

author Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

iommu/amd: Clear memory encryption mask from physical address

to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
iommu-amd-clear-memory-encryption-mask-from-physical-address.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From b3e9b515b08e407ab3a026dc2e4d935c48d05f69 Mon Sep 17 00:00:00 2001
From: "Singh, Brijesh" <[email protected]>
Date: Thu, 4 Oct 2018 21:40:23 +0000
Subject: iommu/amd: Clear memory encryption mask from physical address
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

From: Singh, Brijesh <[email protected]>

commit b3e9b515b08e407ab3a026dc2e4d935c48d05f69 upstream.

Boris Ostrovsky reported a memory leak with device passthrough when SME is active.

The VFIO driver uses iommu_iova_to_phys() to get the physical address for an iova. This physical address is later passed into vfio_unmap_unpin() to unpin the memory. The vfio_unmap_unpin() uses pfn_valid() before unpinning the memory. The pfn_valid() check was failing because encryption mask was part of the physical address returned. This resulted in the memory not being unpinned and therefore leaked after the guest terminates.

The memory encryption mask must be cleared from the physical address in iommu_iova_to_phys().

Fixes 2543a786aa25 ("iommu/amd: Allow the AMD IOMMU to work with memory encryption")
Cc Tom Lendacky <[email protected]>
Cc Joerg Roedel <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Radim Krčmář <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc <[email protected]> # 4.14+
---
 drivers/iommu/amd_iommu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/amd_iommu.c +1 -1
@@ -3071,7 +3071,7 @@ static phys_addr_t amd_iommu_iova_to_phy
 		return 0;
 
 	offset_mask = pte_pgsize - 1;
-	__pte	    = *pte & PM_ADDR_MASK;
+	__pte	    = __sme_clr(*pte & PM_ADDR_MASK);
 
 	return (__pte & ~offset_mask) | (iova & offset_mask);
 }

Patches currently in stable-queue which might be from [email protected] are

queue-4.14/iommu-amd-clear-memory-encryption-mask-from-physical-address.patch
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu