From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from 8bytes.org ([81.169.241.247]:54388 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728447AbeJEP2m (ORCPT ); Fri, 5 Oct 2018 11:28:42 -0400 Date: Fri, 5 Oct 2018 10:31:01 +0200 From: Joerg Roedel To: "Singh, Brijesh" Cc: "linux-kernel@vger.kernel.org" , "iommu@lists.linux-foundation.org" , "Lendacky, Thomas" , Borislav Petkov , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , "kvm@vger.kernel.org" , Boris Ostrovsky , "# 4 . 14+" Subject: Re: [PATCH] iommu/amd: Clear memory encryption mask from physical address Message-ID: <20181005083101.GD3630@8bytes.org> References: <1538689210-14524-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1538689210-14524-1-git-send-email-brijesh.singh@amd.com> Sender: stable-owner@vger.kernel.org List-ID: On Thu, Oct 04, 2018 at 09:40:23PM +0000, Singh, Brijesh wrote: > 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(). Merged and on its way upstream, thanks Brijesh.