Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9173252pxu; Mon, 28 Dec 2020 08:23:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3KTMbrwniKjhKySnO1rCPLEvimvp1RWTzOT31mk/mjL173NnEMj3/hYavvgBZ+txowzjz X-Received: by 2002:a17:906:e291:: with SMTP id gg17mr42783909ejb.31.1609172623227; Mon, 28 Dec 2020 08:23:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609172623; cv=none; d=google.com; s=arc-20160816; b=PMdGjgXAdYNZA8+1DqcX9drwpm+aMlHiTamyffxiJXwvNcUsarHvRSTGp3YnxVs4eY JlwijwYRfqJ97PN3EP0WYfDYrdHeRwtXDUBpBJGrP41sWIlzl6424syCciEWnF0aGePZ KTDNsApPFfKaJnf4/1VqZBdbCJrFxPOkRMeRkEYUaM//HJUaRflL+DIp1j4ZXe49RR4X KmXqCvRRf8QAhK5Y5peeuxYV2xp5YEHsY6ZkBnOLRIS0o5ClJOHlTtR474shYsjgokRP 28nqM7zUZEJnT9BjBOMykKLkN5Yu1k/9DEMLyx0lSfGGixl1Z9SvpUdFxcMhoe9N2+Pc HtXw== 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=LoiFS9XJZ80EMMT7kK7jcr5Gy96jFC0JNdDPyewChKY=; b=x4kIrR/dtOBmqM7a7N0CiwcH0CNSL5r9o/Sga+H5uJ2L9e0LbWR/M+cufRxJh2+QaS fsC8K9ahwQ0bA2V+1XwfKMSgiWubLcUVq0FxLOs4uQT4QiN/hcl5xgZTULHjU70kr5z8 Mh9/15qZ6WhIR1klMX9FQSDj3TfN16Al5FCdSTyN2wIWAwpo3pGj4h1/DE3WDQhv88kG 3NJkFlgY1SY4BAyEfCPDOncLv/OEvi7sYwXhipbq1IeD2fY+b5W7aic9p8Bv5ezZW2kr qHw8ZabB2FMgvHX+MYsNoyK1VE/m5fXaDEhRIlVO7G50/soHCuRwRt2hzwJy50OzO5b7 M11w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hwMZUFam; 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 g20si19964222edm.288.2020.12.28.08.23.20; Mon, 28 Dec 2020 08:23:43 -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=hwMZUFam; 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 S1732275AbgL1NNl (ORCPT + 99 others); Mon, 28 Dec 2020 08:13:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:41832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732227AbgL1NNl (ORCPT ); Mon, 28 Dec 2020 08:13:41 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id CCFDA22AAD; Mon, 28 Dec 2020 13:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161180; bh=1b/fIMg3IWYi4cQ4mqSoGTUdKQFkfICjXpcA5uI8n5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hwMZUFam2JwpGkHvsZNC/P2eUkIu0BgcT1no64TnpjP23wF0YrG13zxGtF6NW59dF GMKqHuCKs5bKPQa/THrvM/HYCtCWhf/41XjVVVgp4QZJF5v9tgc9PDDoZRluDXhdsU 6Xi2CIU2TmuAg/+S0ES+W7qB62M2AzElo90ggUtU= 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.14 128/242] vfio-pci: Use io_remap_pfn_range() for PCI IO memory Date: Mon, 28 Dec 2020 13:48:53 +0100 Message-Id: <20201228124910.999527634@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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 ac1c54bcfe8fb..6fceefcab81db 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -1380,8 +1380,8 @@ static int vfio_pci_mmap_fault(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