Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9118670pxu; Mon, 28 Dec 2020 07:06:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCbkiFl3g2MFqrXBGlAybJYqX+NVtHDCnNopZtg5YySb/voarLDlSLaICQj3k1fVSqvSWl X-Received: by 2002:a17:906:c00c:: with SMTP id e12mr31466975ejz.103.1609167979517; Mon, 28 Dec 2020 07:06:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167979; cv=none; d=google.com; s=arc-20160816; b=glk1KQKP++XRUjyiODfL0sUeHuDY7ckX01IJWYfLWMAc5ErEvte505aePgMOv0P4K/ ofBxC4yLp9CJIvVVJW/Au/eTfStqSBMlAkOG/xyohyPtfhYKIXDmmAMZLXVF+yPdcfO2 kyYfPUU5lZkPAJthAcmKGGemIY9Yk/MKaowSHng9PC7Z9wROu+NPrwzfg6q8Lpr1oRUq 9mRBYBKWubHZCNjn110PrxcY1mYMnAcZdd7T7qXVUN2qa8rzmPxcbz82pjO/JRrrRTQN wbpifoEVajCSDIWej6jXkFRdrVyUPh5ZLYtVgNYIjvjgqSp5gWNvLU8eMOo7QW3Ny6VG HbxQ== 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=4Yun45d/5pIxkKaZw0NFxvrfU1NFNgtSBPZhJyd8KFo=; b=NAtVtzwnoElb6CgeD05PM9GxQ3SnMs8IY9Zje7r3zMvsGYRyTY3xLzCKZ5AfeDuEXY UtDjeLG+k4gyxUVIV75+AazAxWsYIjeS0OTnErf5dKiAtnBKQIQnu1VlNO7VPStVfU+a i+cfHsahRQ9CLvF6NoE/H4g6MPm73G0L4LzkkgjKi0Xhlho8+6lrjVTvx78YEJa9og1S Q2KJkb362zjZ+vGQl3JkZt2Xr0pW5yYL2QRAqZlSEivzP0t3fGchXmj/OzfNjgLLEJ6B aYGsoZnbQP6iEVF/cpaEQVjaFP/gjqMYYs7K9g0zlSV8QVRdoDkoBtgdpDDMdzjTP6Kn FmaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AY75YjIe; 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 x13si19478515ejb.243.2020.12.28.07.05.56; Mon, 28 Dec 2020 07:06:19 -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=AY75YjIe; 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 S2408163AbgL1PC7 (ORCPT + 99 others); Mon, 28 Dec 2020 10:02:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:47404 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439939AbgL1OMp (ORCPT ); Mon, 28 Dec 2020 09:12:45 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 87F11206D4; Mon, 28 Dec 2020 14:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164725; bh=HgKUPluJdE/RxiBOMmBpeTvxKGLKCWxO9nN7QGeN6i4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AY75YjIeRIuKhVmOQtCCFoVcHZymONA6cEzK7oMOukU6Lr4GxasVICKFrFX/pNK1X UGG7saaPSaQrgyB0ri97IUoPzLYDuOcSqQfa0Qdln9LNzwAh8zeU8qKdFJe7bE1kgt SofHDYnbPEbgpy1qH4sWZVRXId7rJC0TWWVm08Cg= 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 5.10 274/717] vfio-pci: Use io_remap_pfn_range() for PCI IO memory Date: Mon, 28 Dec 2020 13:44:32 +0100 Message-Id: <20201228125034.145098805@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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 e6190173482c7..89e451615729a 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -1635,8 +1635,8 @@ static vm_fault_t 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