From patchwork Fri Jul 7 13:44:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 9830443 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8EEDA602CA for ; Fri, 7 Jul 2017 13:47:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1621E28514 for ; Fri, 7 Jul 2017 13:46:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0883A285EB; Fri, 7 Jul 2017 13:46:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DED128514 for ; Fri, 7 Jul 2017 13:46:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752893AbdGGNqp (ORCPT ); Fri, 7 Jul 2017 09:46:45 -0400 Received: from mail-co1nam03on0044.outbound.protection.outlook.com ([104.47.40.44]:57264 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752609AbdGGNoj (ORCPT ); Fri, 7 Jul 2017 09:44:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=LsaeHY+KYuKqHxAF38N7gGQGfkXExXHhxLtqqPIY3H4=; b=QXY45xB4jm3c663pjxfcy3pMeQAEyRhDxugjpk1mNGEp4KwTr9EOp2hFY6eFvDg8BpkU8tPNwfxj/Y6gARDKHcOUF6P+7PuQvHKcvQWAykCQjl1oPjlzSC00fs/8ab+s7LfDhzwn7VByjH1kSmvEXiyAKw3r4Gzp4dkHaCndBu0= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from tlendack-t1.amdoffice.net (165.204.77.1) by MWHPR12MB1149.namprd12.prod.outlook.com (10.169.204.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1240.13; Fri, 7 Jul 2017 13:44:22 +0000 From: Tom Lendacky Subject: [PATCH v9 33/38] x86/mm: Use proper encryption attributes with /dev/mem To: linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, xen-devel@lists.xen.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org Cc: Brijesh Singh , Toshimitsu Kani , Radim =?utf-8?b?S3LEjW3DocWZ?= , Matt Fleming , Alexander Potapenko , "H. Peter Anvin" , Larry Woodman , Jonathan Corbet , Joerg Roedel , "Michael S. Tsirkin" , Ingo Molnar , Andrey Ryabinin , Dave Young , Rik van Riel , Arnd Bergmann , Konrad Rzeszutek Wilk , Borislav Petkov , Andy Lutomirski , Boris Ostrovsky , Dmitry Vyukov , Juergen Gross , Thomas Gleixner , Paolo Bonzini Date: Fri, 07 Jul 2017 08:44:18 -0500 Message-ID: <20170707134418.29711.84189.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20170707133804.29711.1616.stgit@tlendack-t1.amdoffice.net> References: <20170707133804.29711.1616.stgit@tlendack-t1.amdoffice.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR06CA0033.namprd06.prod.outlook.com (10.174.172.174) To MWHPR12MB1149.namprd12.prod.outlook.com (10.169.204.13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cb2c4940-42de-48d2-eb41-08d4c53e47c6 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:MWHPR12MB1149; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1149; 3:RBNvueqEBk42kCCtlQBaerbmKL5MxT+35j78zi6nx7OdiCp+Zzl4IoNfRNe2Xuw/l+e9s/N6wz+2+gNXd2Im1WWaApAfxgq4vK7BXdqGMXCKxL4LiUzfW48dLd300kBg16qs7VP34oFVCEJHJDcSG7elIWhVGKg41c95spIrudlaR5KJ9l9etFN4wmYBi+Fjgn2rPuEdUB2ItzLy6FPbLujvd0wdCkZF2qPM/CUKRx8H5bS+wgoVYAZpWKgzUBBI6TKZ/B8a/83wPNsu5uc0lD0yfJI8HkISFeHyf7+aMaDFZYnLq63Iw49qk9uSlOcviqc3FG73copgpcwXJYuW/FmZlptacUYO79Li4Uryq0Vdegv0JDyHGVDPyXha37Eb0PQnot80MnZDoSGR/lmL7a8XJDAOFhgaYnyuw4Ozl6eM4XuHKfiMWSJ0+dShRvNI9Dl+rD9o1fL9886uLAh0TxwuXI9LFmrFKAA+8lHONeNydRLvHn5KfTMav/uNjHCM5XEW3M7agRMqbhlDf6hxbc/+1eUgjC3FB35mbnwkry/S+bh1+HTNUGNiRq5ujJjqDJ5ei6vK2eqNiRCdRUzoasBNn62VYCfTsPvDTBEvjNnGzHImtYkjgP/38Y/2F5e+SEVia1ExBSgW3UHqxKD1qccx33t0u1inz8IuE+3EZjFc4Th8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v6U9uF/vlVaDXZ3aOB8LadkFE0ogToU0D19UMMIDlooU GU= X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1149; 31:IW9XMG8EYUyxypTikFGa3SRCYcJEfo3mpt9/nuVPQnehwWXhyMxdfYCyFVzGL/40vgwmuPh++zlJIH7HXv9Gr0FZhzFbMiTIVGAyNiuB6Btv/nL9ZbBO59XYRzWNi5kH9MXdu4HHO4AY59e8U+dKf38hNMOMRGm/ez4DGXSh2Z2ncRl0UVrok0lJqqF9QEHB++Ai5P9TjyzN1TYwYIiqyanBoE4DPWy1M74LNZGAS5Od8+BZr+WEb8HaJbzlkNpGYfizmWmFRLiU/JWsbAjsHzyHO0gF03JXgqjfLehtCmBkunqb0rpxOo5aYrNpoDd/BfYy8LErU8J9PFEytlZvM2cClKBxJlTPGueLMrg2jHJVoX09pRT3BRr37V3xz9dykJekksC6mlEoQj1NQRI6UYDB3or2z8EOESQ6B/ypTgavXICQMKahgXskpEIfNgWe8kZOE2kG/+OllcmMaJGck9n6+HGiliwhHsLPtSFgYJMhrU3pCPaQpO43a2aEy79OlSoEYoqKEdy+3c69UCOiVx0SY4goZMJuIY9uVzskrnd6CQTMsB9dhAwqPrVgKPJxdjclSNuSbZAPguNisV6voKGOtjnnfbbm0G0UrF3o3E0cEvbwbhvolhUjd0WVeZL919kGRKL717ZfgbPbZeRqtBm+qp3jiCU3ar6/lwPmpSo= X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1149; 20:2l0VASe4xg5btH8wsQ/DfFRh+UDHW2YkA+qLEycNrEwIEQe2iIxWL65ikShcEWkJkwUIMECIno1O7zudFeZhcCP6bcJ6Tw2X+3yFn2kSneHE+VTWeOv7TBxeJElaPYB125eTgCwki9jCajssh2r5Pewy39jzQIgv37rALds/XrrpFLY31sDTtsHdPbjtmTJuo881BSP71ltqEbj22R2vRBC45QQZLKOohBDqY8svjVlMTP9Rlh4WTz5s/OJAF9D3zz5+njKkcSRrccZqwDBYqxJWVwj3p1V68GEeEKN+yMGvBp6FlOnnjTGAChrC6KLo4MX0tPbdWa1K4Nz8IGnQHzc/u7F8TQ8dDcx0r1QKI2lbYhc2wT8OFXjWiUpG4UJMwoxzt/ODoBhVp5V/3LOLqJuQFSSEbrPg5gjeIUyDqR/FM+4Iro4C8l0tBnSyWjlli2c7fFAb13rRlDLlBn1uXhB5b7AnToEuTMCsVEnR9SUN+oyf/Bnje9jhBcPAK4pg X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236129657087228)(767451399110)(148574349560750)(167848164394848); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(2017060910064)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123564025)(20161123558100)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR12MB1149; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR12MB1149; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxMTQ5OzQ6clJBKytaVXA0ZGJwTUozUG9USUtrd2k0RFF4?= =?utf-8?B?STZaNDl3NWQweDNjSlpTVFJjWHRWeTNzcVNHUWhRV0JTODNCWlNudnEzN1p5?= =?utf-8?B?bUxuVGh4aGRQNmN1VG5rYW9MVUN6Z2k4bGhHSGhTYmZuZ2pkUkttaFdYMTdx?= =?utf-8?B?RkQzNjBuMERxQXg0TFAxeVhMTnQ3czdzUDVhcnhFb1NkeDgzNUhvZURMNUVq?= =?utf-8?B?Yk52bzZsVUR6ckJMUWJsV1VJZVNvcjNZVS8vdTEvYlVlZFN6SExKaHltR0tQ?= =?utf-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T0x3U2dKV3JQN3RM?= =?utf-8?B?MEFjOU8yd25uUEZKbm0yREpMbDNwaU11bFk5SXA3bnhVdHN1T3VuNVVpMnQw?= =?utf-8?B?MEZYd3V6MlRGVm5lWmVXSFBlK1lrdGRTcGF0Rkl5WnRSN0g3aU1FVmh5cExZ?= =?utf-8?B?MmRrMTJnUXZaR3Rma0FwUmZnZnBrUDdXYkJYZUhLRzBSRjB3Wm5GVGM2T3JY?= =?utf-8?B?d2VwMDI2bkN5VkhGTVYrVk1nT1FpdVYvbThkcitUMitubHBxaDliKysycXVy?= =?utf-8?B?ZUZVSmJiTDdRUTdsV2k2NkVJMGtkR3QzeG42ZkVWWlNYazhxVTVDVXowRkxO?= =?utf-8?B?R3IxdlQzTFFNNnowVCtCd3BYTXhEd21tNFJuaTR3eUZ6Z3h1Y1NvZ1VBcllo?= =?utf-8?B?TmlONTVqT1luOGZqTE13T1BnendLS2ZGbDd6dlUxRFh0RWFTRThENGFHTzli?= =?utf-8?B?QVdyOUIxRGVUcEdJcVRYcFB6SUxXZ21wR3llTzNDNjY3QlR3M2NLVUdvb3pW?= =?utf-8?B?K2dxSkNhczhpZldjc0tpYlZHUlVDZTVIWHJHblU1RkY4VEpBc3lmRGxPZ2ZX?= =?utf-8?B?TlBvaExpSkY4RHcrWDJGWU9rTkxPdmZBTXhOSlJnbzVVSHV5eE9qLytORWNl?= =?utf-8?Q?9PQAmwGm/4Ta?= X-Forefront-PRVS: 0361212EA8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39400400002)(39850400002)(39410400002)(39450400003)(39840400002)(39860400002)(9686003)(54906002)(53936002)(33646002)(47776003)(103116003)(6116002)(3846002)(25786009)(54356999)(76176999)(110136004)(38730400002)(42186005)(1076002)(53416004)(4326008)(50986999)(230700001)(66066001)(6506006)(86362001)(55016002)(6666003)(2950100002)(2906002)(23676002)(305945005)(189998001)(50466002)(97746001)(478600001)(72206003)(81166006)(8676002)(83506001)(7736002)(7406005)(5660300001)(7416002)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1149; H:tlendack-t1.amdoffice.net; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxMTQ5OzIzOlhFYTFXRkpYLzZKVGxvRFZSaVphZS9YdmY1?= =?utf-8?B?YWJGQk90QWdEam8xRVBuejAvU0FEZGdvNGJnQlp4bUlaSW9Xb0NrUTBxc3ht?= =?utf-8?B?Uk9uS2h2OFA1ZlRrS25CcHI5a1NTYVk1SFMwQTR1RGowZ3BZMFgyNUpmekFI?= =?utf-8?B?ZE14K0JvVHhJZi8xL3ZPSzZzT0RpRWJ6QmVFeFg5emdNWVJIMVFseTRraGZ5?= =?utf-8?B?YXNUSU5XZmZVVEMxaVJiMm85R1g3cHUyRWplZUsyL2RvandxZTJ4QW5STlNT?= =?utf-8?B?cCsrRjJlQ2JJZ2hiMzRGYkNlenA5K2pOcVVqcUppMHJSTDlWb1M3UHVUSWo5?= =?utf-8?B?RFNodlhhRVcyUXRDRDdrTm1SRmhJRy9MVFU5QWxNRnNaakMrS0J0WUtzMTdE?= =?utf-8?B?WG9MV1pITlNCT3NPdzN2djExTG9EeUtEc0hLYmhtRWJzQU9DR0JKTVNlbE5v?= =?utf-8?B?QlpMTlI2UTdZMktYREdSVWZMbURVdExmQ1dUQ254VllEWWx1LzhkVkphMGhr?= =?utf-8?B?aXNINzhiTlRTTkxncDV0c0tRd0llQlRVaTQxWitPRHRCeWRjSnUxcno5aFBJ?= =?utf-8?B?Mi9UUzROZmZObjkxaEIvcHEvTDlpUWRFdGRpamlsL0FTcTJnMmVUSHJvRHll?= =?utf-8?B?VXNaTVk2eWh2Si9hTTVsYlB5WnBnUjhlcUJEZlhCRFp1MllSbWFYMWFxT1gx?= =?utf-8?B?TGoxV0ZjVzQ0WkY3MDFmOEg2YjRDWHlZYXVqVmlvNkFuaCsxYldpQUJCUDVi?= =?utf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BcjkU4srDufDsSucSHHVoE+nqOv44YjybCO151wr9RGMlvBDs= X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1149; 20:MT+XKG7nnLte/sFFzipcvKg0+SaXHdsF7sQczMPL3/2QTCzGsmn8iA41gZ/i6ofgxAyXvorKzQRSrgwaSGYea4BkiivRU7ZV1XHTrPkM3Epdv0kIpn4Aobes+3R8BHK66GfRts1qYf268n2ZcuaEdincb2bNrZvnRSu1jg1LNdtnvcSwb3UcHra7rbKHJ7YttFSrd27E6lL/U+20wcqJcFVvai3hHPF4UYbKdNZ7xQUYzq+ArNTJyDiMuQb39KZ+ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2017 13:44:22.8988 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1149 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When accessing memory using /dev/mem (or /dev/kmem) use the proper encryption attributes when mapping the memory. To insure the proper attributes are applied when reading or writing /dev/mem, update the xlate_dev_mem_ptr() function to use memremap() which will essentially perform the same steps of applying __va for RAM or using ioremap() if not RAM. To insure the proper attributes are applied when mmapping /dev/mem, update the phys_mem_access_prot() to call phys_mem_access_encrypted(), a new function which will check if the memory should be mapped encrypted or not. If it is not to be mapped encrypted then the VMA protection value is updated to remove the encryption bit. Reviewed-by: Borislav Petkov Signed-off-by: Tom Lendacky --- arch/x86/include/asm/io.h | 3 +++ arch/x86/mm/ioremap.c | 18 +++++++++--------- arch/x86/mm/pat.c | 3 +++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 09c5557..e080a39 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -386,4 +386,7 @@ extern bool arch_memremap_can_ram_remap(resource_size_t offset, unsigned long flags); #define arch_memremap_can_ram_remap arch_memremap_can_ram_remap +extern bool phys_mem_access_encrypted(unsigned long phys_addr, + unsigned long size); + #endif /* _ASM_X86_IO_H */ diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index effa529..71d4ca7 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -396,12 +396,10 @@ void *xlate_dev_mem_ptr(phys_addr_t phys) unsigned long offset = phys & ~PAGE_MASK; void *vaddr; - /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */ - if (page_is_ram(start >> PAGE_SHIFT)) - return __va(phys); + /* memremap() maps if RAM, otherwise falls back to ioremap() */ + vaddr = memremap(start, PAGE_SIZE, MEMREMAP_WB); - vaddr = ioremap_cache(start, PAGE_SIZE); - /* Only add the offset on success and return NULL if the ioremap() failed: */ + /* Only add the offset on success and return NULL if memremap() failed */ if (vaddr) vaddr += offset; @@ -410,10 +408,7 @@ void *xlate_dev_mem_ptr(phys_addr_t phys) void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr) { - if (page_is_ram(phys >> PAGE_SHIFT)) - return; - - iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK)); + memunmap((void *)((unsigned long)addr & PAGE_MASK)); } /* @@ -622,6 +617,11 @@ pgprot_t __init early_memremap_pgprot_adjust(resource_size_t phys_addr, return prot; } +bool phys_mem_access_encrypted(unsigned long phys_addr, unsigned long size) +{ + return arch_memremap_can_ram_remap(phys_addr, size, 0); +} + #ifdef CONFIG_ARCH_USE_MEMREMAP_PROT /* Remap memory with encryption */ void __init *early_memremap_encrypted(resource_size_t phys_addr, diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index 88990ab..fe7d57a 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -744,6 +744,9 @@ void arch_io_free_memtype_wc(resource_size_t start, resource_size_t size) pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, unsigned long size, pgprot_t vma_prot) { + if (!phys_mem_access_encrypted(pfn << PAGE_SHIFT, size)) + vma_prot = pgprot_decrypted(vma_prot); + return vma_prot; }