From patchwork Wed Oct 28 20:46:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 311713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD32EC55179 for ; Wed, 28 Oct 2020 22:04:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87B3F246CD for ; Wed, 28 Oct 2020 22:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603922692; bh=gacJxhPFaV7MzWGuIG1Bkmd7QlRpAFNicJ9/Ih7v/T0=; h=Date:From:To:Subject:List-ID:From; b=QuOJqcmrm/9cRQDN5ff+C1L2LBuRptAZ9nldujAljDudL7bFHxUFBbNCUuppX5G8t ndEOaBzbFTornczxwCJQiIwC45MVpC8s3fjlEAh89eMaM/7Z/gB+bRlH32uM0arwxt alFb+6XalbOWRgiHJENhpb/xvB71vnj9vSx3pcq8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729253AbgJ1WEv (ORCPT ); Wed, 28 Oct 2020 18:04:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:50708 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729506AbgJ1WCX (ORCPT ); Wed, 28 Oct 2020 18:02:23 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 251B52481F; Wed, 28 Oct 2020 20:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603917981; bh=gacJxhPFaV7MzWGuIG1Bkmd7QlRpAFNicJ9/Ih7v/T0=; h=Date:From:To:Subject:From; b=IF2/gMm766vdXRX9qSJh4fTqdJdbY6YrIckS2mQ4uUyDRbKxNlM6krs+L3/Tn+Ypx 7BJVSrx8pHfbZZv2/x5LSanA/JpgjnhwXCK7NYOu2aRg34FPW2v/6c3SuluG0veqBc Nt0oNUjrfA60KKFdXhM9HdrgtdlU4gTCb2hqaZg8= Date: Wed, 28 Oct 2020 13:46:19 -0700 From: akpm@linux-foundation.org To: aryabinin@virtuozzo.com, bp@alien8.de, brijesh.singh@amd.com, corbet@lwn.net, dvyukov@google.com, dyoung@redhat.com, glider@google.com, jgg@nvidia.com, konrad.wilk@oracle.com, luto@kernel.org, lwoodman@redhat.com, matt@codeblueprint.co.uk, mingo@kernel.org, mm-commits@vger.kernel.org, mst@redhat.com, pbonzini@redhat.com, peterz@infradead.org, riel@redhat.com, stable@vger.kernel.org, tglx@linutronix.de, thomas.lendacky@amd.com, toshi.kani@hpe.com Subject: + mm-always-have-io_remap_pfn_range-set-pgprot_decrypted.patch added to -mm tree Message-ID: <20201028204619.tp952CPe7%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch titled Subject: mm: always have io_remap_pfn_range() set pgprot_decrypted() has been added to the -mm tree. Its filename is mm-always-have-io_remap_pfn_range-set-pgprot_decrypted.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-always-have-io_remap_pfn_range-set-pgprot_decrypted.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-always-have-io_remap_pfn_range-set-pgprot_decrypted.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Jason Gunthorpe Subject: mm: always have io_remap_pfn_range() set pgprot_decrypted() The purpose of io_remap_pfn_range() is to map IO memory, such as a memory mapped IO exposed through a PCI BAR. IO devices do not understand encryption, so this memory must always be decrypted. Automatically call pgprot_decrypted() as part of the generic implementation. This fixes a bug where enabling AMD SME causes subsystems, such as RDMA, using io_remap_pfn_range() to expose BAR pages to user space to fail. The CPU will encrypt access to those BAR pages instead of passing unencrypted IO directly to the device. Places not mapping IO should use remap_pfn_range(). Link: https://lkml.kernel.org/r/0-v1-025d64bdf6c4+e-amd_sme_fix_jgg@nvidia.com Fixes: aca20d546214 ("x86/mm: Add support to make use of Secure Memory Encryption") Signed-off-by: Jason Gunthorpe Cc: Tom Lendacky Cc: Thomas Gleixner CcK Arnd Bergmann Cc: Andrey Ryabinin Cc: Borislav Petkov Cc: Brijesh Singh Cc: Jonathan Corbet Cc: Dmitry Vyukov Cc: "Dave Young" Cc: Alexander Potapenko Cc: Konrad Rzeszutek Wilk Cc: Andy Lutomirski Cc: Larry Woodman Cc: Matt Fleming Cc: Ingo Molnar Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Peter Zijlstra Cc: Rik van Riel Cc: Toshimitsu Kani Cc: Signed-off-by: Andrew Morton --- include/linux/mm.h | 9 +++++++++ include/linux/pgtable.h | 4 ---- 2 files changed, 9 insertions(+), 4 deletions(-) --- a/include/linux/mm.h~mm-always-have-io_remap_pfn_range-set-pgprot_decrypted +++ a/include/linux/mm.h @@ -2759,6 +2759,15 @@ static inline vm_fault_t vmf_insert_page return VM_FAULT_NOPAGE; } +#ifndef io_remap_pfn_range +static inline int io_remap_pfn_range(struct vm_area_struct *vma, + unsigned long addr, unsigned long pfn, + unsigned long size, pgprot_t prot) +{ + return remap_pfn_range(vma, addr, pfn, size, pgprot_decrypted(prot)); +} +#endif + static inline vm_fault_t vmf_error(int err) { if (err == -ENOMEM) --- a/include/linux/pgtable.h~mm-always-have-io_remap_pfn_range-set-pgprot_decrypted +++ a/include/linux/pgtable.h @@ -1427,10 +1427,6 @@ typedef unsigned int pgtbl_mod_mask; #endif /* !__ASSEMBLY__ */ -#ifndef io_remap_pfn_range -#define io_remap_pfn_range remap_pfn_range -#endif - #ifndef has_transparent_hugepage #ifdef CONFIG_TRANSPARENT_HUGEPAGE #define has_transparent_hugepage() 1