Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9038262pxu; Mon, 28 Dec 2020 05:07:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwiHuts8Jt8P8A14toelQ9uZG9jNZj1Ng9d3ZTHsjZ1lm0uq3n8m2lK+C1m9qjdUq4T6bFP X-Received: by 2002:a17:906:4756:: with SMTP id j22mr1796186ejs.353.1609160843905; Mon, 28 Dec 2020 05:07:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609160843; cv=none; d=google.com; s=arc-20160816; b=Sep1iHfki2vHR90U0aPKGn35SIUuLJUtwIR8By9v0AXsQR7U40KlhTkNQPiOUQe6NJ 4GM8OZwrimFoh5AlLPJrXRLMYawMy5o7MekbhVjnD1ZzkdWdq3eWGRHtcpwEp++OXyTg NCPUBeCCNxCo195m+MGjPS23ldVgQDYa06HXywGBoZSn4/4wqq7XUDTL1ZpPHnWQu8cF r+PUcHPOlftP+/br6CayhrlvJkPUTYP5S2LJqtAmeEDZ897Bn9LT0p4wYvwAQzSHRMeF gxQ3jRh1wE/KhN9ULVsxfa1dblk48ki4quatfKdTTY7suepdtzmjlgn4B3QGf/eoaBSE 8Mew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4OJ9l+zTUXvR7ajSQpTjgwPLDWLAV/3bZvUrM+v916k=; b=i0F7gYJv/d1rfKFxxNWHLXwGJMN51MGVxbrS7/t5hbw8KbdgXVG0Je+eOOD/kDHLxE IVPEfiwIRPV8zxjvJF6dEWdT7BndemtlzEKps48R/1r07igM5NVfEr0P6zpLd7U8ezB/ nROqb8g+SuPDRrNch7GQCNt8htwl/NzwxMVy5xbQZ+kwEoRxLWQ57YP8sAWtcNnOxv9G B8R5iREsfj0v1Y/3RU3janssHDilY8QFTWuBZAl4En3rU/rVWgv6Xdnm/hjIQ0ULbn8K BGovJVX2wxWoDDFLhZbXzZGymj2ld/hT/UwpsFzUzvGPRhwLTooIlpKZRTkQt+/kKF+l meyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jSHsDGZE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d3si22355295edj.258.2020.12.28.05.07.00; Mon, 28 Dec 2020 05:07:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jSHsDGZE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730542AbgL1NFA (ORCPT + 99 others); Mon, 28 Dec 2020 08:05:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:60856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730503AbgL1NEo (ORCPT ); Mon, 28 Dec 2020 08:04:44 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 58B86207C9; Mon, 28 Dec 2020 13:04:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160641; bh=ceZIMqhfPUh1tw8dIvdLwto0g4ZmHkjNQh09UorvhTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jSHsDGZEdpmKt3VxqRRo2ZFkWxo16X1j3NOAt6b/O+5tDhJiXVmXW/n40QfbpLZ2/ 0HffvWd5CDbkWAzELBWOkvgcD0ZSqgzSfn4PGeQefeWzZ1ZiZTXimXU/zRxExSqI39 e5Gy5yJ5NVjTC2QNmPj0e+3MMywh25pGbQe8SMjc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Gunthorpe , Peter Xu , Tom Lendacky , Alex Williamson , Sasha Levin Subject: [PATCH 4.9 090/175] vfio-pci: Use io_remap_pfn_range() for PCI IO memory Date: Mon, 28 Dec 2020 13:49:03 +0100 Message-Id: <20201228124857.610339811@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Gunthorpe [ Upstream commit 7b06a56d468b756ad6bb43ac21b11e474ebc54a0 ] commit f8f6ae5d077a ("mm: always have io_remap_pfn_range() set pgprot_decrypted()") allows drivers using mmap to put PCI memory mapped BAR space into userspace to work correctly on AMD SME systems that default to all memory encrypted. Since vfio_pci_mmap_fault() is working with PCI memory mapped BAR space it should be calling io_remap_pfn_range() otherwise it will not work on SME systems. Fixes: 11c4cd07ba11 ("vfio-pci: Fault mmaps to enable vma tracking") Signed-off-by: Jason Gunthorpe Acked-by: Peter Xu Tested-by: Tom Lendacky Signed-off-by: Alex Williamson Signed-off-by: Sasha Levin --- drivers/vfio/pci/vfio_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 237d5aceb302d..f9a3da02c631b 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -1403,8 +1403,8 @@ static int vfio_pci_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) mutex_unlock(&vdev->vma_lock); - if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, - vma->vm_end - vma->vm_start, vma->vm_page_prot)) + if (io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, + vma->vm_end - vma->vm_start, vma->vm_page_prot)) ret = VM_FAULT_SIGBUS; up_out: -- 2.27.0