From patchwork Mon Jul 17 21:10:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 9846231 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 91DB560392 for ; Mon, 17 Jul 2017 21:20:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C596C25223 for ; Mon, 17 Jul 2017 21:20:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA3DB27F92; Mon, 17 Jul 2017 21:20:55 +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 DEE9F274D0 for ; Mon, 17 Jul 2017 21:20:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751882AbdGQVUZ (ORCPT ); Mon, 17 Jul 2017 17:20:25 -0400 Received: from mail-bn3nam01on0076.outbound.protection.outlook.com ([104.47.33.76]:46539 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751953AbdGQVMJ (ORCPT ); Mon, 17 Jul 2017 17:12:09 -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=SHhNcz3wgf3YBpxD9XupMm2iN6vTZsmqV+sajITj2mY=; b=TV1bMnwpXtnhDrGGhOpfn5KpbSV9rxIhBhHKcdsOW7WOvk3xcnhF/ys98epqsP4uxrmDjszcB7zJ+h5PPIA+YInDgPCmm1Icc4P353bKaDwPEOgPG5ZNIVEo0Y9WJrdeApJETxzk2oNEYJ+G83H1ZepxTsWtPHnYbV0Ae/BQEEc= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=amd.com; Received: from tlendack-t1.amdoffice.net (165.204.77.1) by MWHPR12MB1151.namprd12.prod.outlook.com (10.169.204.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.13; Mon, 17 Jul 2017 21:11:57 +0000 From: Tom Lendacky To: x86@kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org, kasan-dev@googlegroups.com Cc: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Arnd Bergmann , Jonathan Corbet , Matt Fleming , Konrad Rzeszutek Wilk , Andrey Ryabinin , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , Paolo Bonzini , Alexander Potapenko , Thomas Gleixner , Dmitry Vyukov , Rik van Riel , Larry Woodman , Dave Young , Toshimitsu Kani , "Michael S. Tsirkin" , Brijesh Singh Subject: [PATCH v10 19/38] x86/mm: Add support to access boot related data in the clear Date: Mon, 17 Jul 2017 16:10:16 -0500 Message-Id: <81fb6b4117a5df6b9f2eda342f81bbef4b23d2e5.1500319216.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BN6PR03CA0008.namprd03.prod.outlook.com (10.168.230.146) To MWHPR12MB1151.namprd12.prod.outlook.com (10.169.204.15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b41c4389-406f-444a-0915-08d4cd587765 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:MWHPR12MB1151; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1151; 3:+BatuOICxS1ukGgyiUN9FO4gBY0hHIgnwSnAcYWOJsaitDWhw2Lesj0vZ59uaMtPvRllvtvJJrCz2W3gco/9dIHbFtj+ftwnj9GDUsVDzgJ2nqfeQ3Z+nGYNr7YlrItQcIJLahS7zNnV4rCCdN8gFef+GJdVzZjtuC5CpVHs80V9JupLOdsszHopkLkGF8BvNTxBju88gSEXesSvHhA0L+N7183VrOxf4HwabRUBo1nsKbkMXL3BShFWmxCFKs7ampNz9e3diohz0lJbfq2sOsxEtWUzu2JwhkEKvhJmgquv/sg5x9k6NSpVnS1MQByMQ1AZd9EEydEGlWAEhx3jqUz/GhSJg6cgdDWjHXTtXJXQZs5+X0nrj+ko8tQWYz3J9I0GGDQefiD5yH8WUYn/9IN1BCx23qdIECvd3X3Y8S3a4T1I3m/YL/4ChLzQt1poHAWQSshp6FWg7PHDjipPql27KsRyv1GpgW6kK234Ty3DnXzUyNPPxUdSobmhu4xJCfQfr3bRAEW7R792Ky4sDTxpbNjw8XeCQjmol55XYyvmrl6P459/T3sIwAA/9Y+QfnmdlPWN3RatRGHwJO7Y+NaoOBOSAkmRdUIYqp/tYw8SpI/OilA13Pv4Dm9m1qO0qe8NxlxalR/ftO3fhH/acjnim9NXaE1qWMwMR+eyKSr8FjzM4Ekgly5RFzEgIpWldRumQRXdO3SxKMhUwbvb9tHGPcjDKy0X+OYl/zHOmQekJ8YrFo+PjN0CFXIV4zMdlcPQHwPTU45lV+b7J7Anbg== X-MS-TrafficTypeD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Ofv5Vx9a5qAi8EFLOgSt9yE65waFlW7l40s8QzbiAbcJNGRv6pGqEklW5eiDcxRVXc9zHAi6vWVH2E2l+BXxr7KWjPYoVw/Z7dKgqoeQtFHks+1/kNu7egNaL X-Exchange-Antispam-Report-Test: UriScan:(133145235818549)(236129657087228)(767451399110)(148574349560750)(167848164394848); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(2017060910075)(5005006)(8121501046)(100000703101)(100105400095)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123558100)(20161123555025)(20161123562025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR12MB1151; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR12MB1151; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR12MB1151; 4:MoA3AcZAd8ujutD6eqOmvKjszJZRNL4yVWEOSKXf0x?= =?us-ascii?Q?kSLV7gtxNjA5xcMtm0FHibdMyC/Qw/rkwljmLLf/M9HkP0ZabnCvXL+p2hD9?= =?us-ascii?Q?3tBg0mQRsWm5Z+CnCdinnci1qfrDNZo0i55hZVwXOOUYaImg1RNHFaYNLWoM?= =?us-ascii?Q?8FgyzfkYYctGgY9SxEamyQy52iOnj78S8Nw6NXWALt9d2iSwlrmYkedi/JIh?= =?us-ascii?Q?2rxPh2ncBPOjAAh8vEFaW+vcHHHIvfRGrZ5lfEa53G864Ndd6INMcji146g7?= =?us-ascii?Q?wActnY/p8Nzup3/2gYj/G76a6OCd36t15pBaCx2DUCgK8Y5kqtbH0JID/KSW?= =?us-ascii?Q?szSUukxdBFgAExXuTA7+H5Um5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/OJlcH?= =?us-ascii?Q?ZlcbQpaukfpOW6ryJUhSrrzzMdJ+/NsYckQOtVmNgLlFSMvAvlprKjI3VRH/?= =?us-ascii?Q?jFS/WmB7an4x0ueBu7K03tbo/FYxckSCauzqmgVQBlz0kwH50GdjAvREGBnZ?= =?us-ascii?Q?/tWvF7nf0LDAx2bkGRONboVaA=3D?= X-Forefront-PRVS: 0371762FE7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39410400002)(39850400002)(39840400002)(39860400002)(39400400002)(39450400003)(25786009)(6506006)(33646002)(54906002)(7416002)(76176999)(478600001)(8676002)(50986999)(6486002)(47776003)(5660300001)(189998001)(42186005)(38730400002)(305945005)(72206003)(53416004)(66066001)(50466002)(48376002)(110136004)(118296001)(2950100002)(81166006)(5003940100001)(3846002)(6666003)(36756003)(53936002)(7350300001)(6512007)(2906002)(7736002)(6116002)(86362001)(4326008)(50226002)(575784001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1151; H:tlendack-t1.amdoffice.net; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR12MB1151; 23:VEbJZrmixzbE5Ra3chl+VQM9ezYq+wfndjVTPMO5e?= =?us-ascii?Q?g3i+BfRxU6CfPRZqFSQBRr4WYZazGJFfm8xMNvXX+9c3McPqjt8o95QCnmSJ?= =?us-ascii?Q?o1jw8y5mvPXQgDq2w8HwH2vlMmdhLkEShDuGQZKLBRAOo+zCvwPyVFgyLqPD?= =?us-ascii?Q?3f9xfyfU9/Ggvb3j8xja2aZfQYhQh52swbe9xcThHXyjBhl9YmbXUZQvOGjj?= =?us-ascii?Q?ffIxuteKYNoHzULT4yi/1H6D2DWsOZ7x/8otN9do07D7ZJZsprEtWVPgYq39?= =?us-ascii?Q?8Ah6toECHYv64fdUiySFPaba6umaEnYLyAA2DDwqxMHOsdWd2oSkscGLdw3W?= =?us-ascii?Q?0Q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/gkhc0bNyXyp+WJvz+yvw=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR12MB1151; 6:BormFKNp0x/cCvZCpuAsKhEiIjJNy151jzy26Uegug?= =?us-ascii?Q?Xq+u1hGSEIeaWJTS3ue+0Qea5XvmRIlgNkErTx2JY2WcH6ZAEHEhAsZCgvdA?= =?us-ascii?Q?VZdZ2ESxym2nkkDps3jxx4UcV4xqMIk5Ogtz6oCRCr5QpYNy12EUGM5778kg?= =?us-ascii?Q?cpcCQ5EIgJ9jF4fq6umFOfppvSNlgmRuUooVncj6LxsBJbqaTkBhqVJKWIDB?= =?us-ascii?Q?IwbhN7DEJrd08BOmynlssamf8yFdWSico+uDMpJAD4GL0i0I+LlYc8jOaFm5?= =?us-ascii?Q?DzGS4UMNyP/n8vawnCRubWRnMwBzokHSL0CM16HC2Ak5wYHKgeDQbsyFY7kJ?= =?us-ascii?Q?uawXecxGZurN1GyBOLtn/fUDirqcbfPBL4Y4CBFkOXF51IJlFhvA4udJkVl/?= =?us-ascii?Q?lflf+Gyo67/ImJW0I9pSjcXvgsbiCq7lciQzwAl/YXDmRQ2gVP2jYpaBBUuY?= =?us-ascii?Q?Sj5H2daVgbYV19xAp9q8fbrKx2SpAMRd83wdm1gSn3b6qcMqV483pQ0LWvrr?= =?us-ascii?Q?eas3b7KWi/DEpTPR3jp8ovZDF123uadLcCFFmOrqyVokXAu578jKvVGClCSN?= =?us-ascii?Q?og699awRzi/Nv8xR1H9EjilJxqNELPGKNp0v0OrBycwErpiMhS4s9Kgy2YYd?= =?us-ascii?Q?M4ypEgx59zdmg0h48pG6oi44h08mSn5rLsCglR6lnKKo8GGA3FOyVpeFVBwn?= =?us-ascii?Q?AI6TbRTFrJwhHHs6We8MZyyWLpnRHJdPjOzzxOfw+DH59sgwEmjK5U7v4aw2?= =?us-ascii?Q?g8KO0+TvRUG8Zvo20VxZmdJ0sXwSgOxzxo79F6rs4DyIZNMOVWpaFyR/COcw?= =?us-ascii?Q?sQPct1Vq9lN8vu4dTNZj9eojJ04N6eUw8Lxes2exPAqVFfnMzKPBExoPibhk?= =?us-ascii?Q?U6Bl7e7bgxNmkuskpasP/mhK9ZbnRJHBT4llQs6Rgn//dZI7+MzP/X6UZYtd?= =?us-ascii?Q?j9KjnuVpkw4lot7AqIlqU269gcofKoDxFj5IJwweyAeOGPYBCLpLS/wAY8FZ?= =?us-ascii?Q?XO2o7FA2/DxcU/BdNDVd3F?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1151; 5:fVUmPoBXNmBio8/U1/Syw/76yX+/8sdf6OFtlMalaxN9rxQ6h8QeQ8Zls9UsJbD3G7sM/F1jAbWN5twPUHDEDrJ8FKVVhZKXCoCMd/D2Y+sIlgl83T5NyDrTDG9OWejd76v9ElLPI9micKevpqLZuiwrmS6P8rI13V9H0HGvMk1OWXdoMshngkATUM+SSMLMSCYmYnP0gfxMIwK3ljuBBClKK7NgluD5vNNBwBm18i6yR+MQ3ctGGlPpjzGHBcf2aeEvXELPoFimsqc6HWJP1WDJRGNzLp+lXjXQRWwjCZJnXxHviSoRusVLsLOTvYmTcLzIlTxnDPPJqYggdK063UAZuiqOZk1B2JrlvPCA3vQBdbsUD3XTxdahCRrUzOdhfpsKCFxbKVmXKdic5otE2F1xb2CvsEgztTmGQJdw52jX2GIkwsorf0Ha1nZlO51aT7ejao4602tqlOKYSi9MD9Z5Z0AsywRWdqTabq3aHh7tVB4BzizeBIOIU11PiYJx; 24:KQ/tT4tNSSZT8chwUeDd+k08D4d6Hz8jrFTMI2tTO7DpwCxenJOuPMlM2B8RwUyvbBu4yCXheE8nFVVZv/GkOQ+ML4w7neCKFHwrWRlcU7E= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1151; 7:cDUkBSdxLCyFzVz/T20o5BaRzgVBVW05Po0Y6U8tKDNM+EBA2AcZtfsDtVAQlx9gJqml1q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-OriginalArrivalTime: 17 Jul 2017 21:11:57.5319 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1151 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Boot data (such as EFI related data) is not encrypted when the system is booted because UEFI/BIOS does not run with SME active. In order to access this data properly it needs to be mapped decrypted. Update early_memremap() to provide an arch specific routine to modify the pagetable protection attributes before they are applied to the new mapping. This is used to remove the encryption mask for boot related data. Update memremap() to provide an arch specific routine to determine if RAM remapping is allowed. RAM remapping will cause an encrypted mapping to be generated. By preventing RAM remapping, ioremap_cache() will be used instead, which will provide a decrypted mapping of the boot related data. Reviewed-by: Matt Fleming Reviewed-by: Borislav Petkov Signed-off-by: Tom Lendacky --- arch/x86/include/asm/io.h | 5 ++ arch/x86/mm/ioremap.c | 180 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/io.h | 2 + kernel/memremap.c | 20 ++++-- mm/early_ioremap.c | 18 ++++- 5 files changed, 218 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 7afb0e2..09c5557 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -381,4 +381,9 @@ extern int __must_check arch_phys_wc_add(unsigned long base, #define arch_io_reserve_memtype_wc arch_io_reserve_memtype_wc #endif +extern bool arch_memremap_can_ram_remap(resource_size_t offset, + unsigned long size, + unsigned long flags); +#define arch_memremap_can_ram_remap arch_memremap_can_ram_remap + #endif /* _ASM_X86_IO_H */ diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index 570201b..8986b28 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include @@ -21,6 +23,7 @@ #include #include #include +#include #include "physaddr.h" @@ -417,6 +420,183 @@ void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr) iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK)); } +/* + * Examine the physical address to determine if it is an area of memory + * that should be mapped decrypted. If the memory is not part of the + * kernel usable area it was accessed and created decrypted, so these + * areas should be mapped decrypted. + */ +static bool memremap_should_map_decrypted(resource_size_t phys_addr, + unsigned long size) +{ + /* Check if the address is outside kernel usable area */ + switch (e820__get_entry_type(phys_addr, phys_addr + size - 1)) { + case E820_TYPE_RESERVED: + case E820_TYPE_ACPI: + case E820_TYPE_NVS: + case E820_TYPE_UNUSABLE: + return true; + default: + break; + } + + return false; +} + +/* + * Examine the physical address to determine if it is EFI data. Check + * it against the boot params structure and EFI tables and memory types. + */ +static bool memremap_is_efi_data(resource_size_t phys_addr, + unsigned long size) +{ + u64 paddr; + + /* Check if the address is part of EFI boot/runtime data */ + if (!efi_enabled(EFI_BOOT)) + return false; + + paddr = boot_params.efi_info.efi_memmap_hi; + paddr <<= 32; + paddr |= boot_params.efi_info.efi_memmap; + if (phys_addr == paddr) + return true; + + paddr = boot_params.efi_info.efi_systab_hi; + paddr <<= 32; + paddr |= boot_params.efi_info.efi_systab; + if (phys_addr == paddr) + return true; + + if (efi_is_table_address(phys_addr)) + return true; + + switch (efi_mem_type(phys_addr)) { + case EFI_BOOT_SERVICES_DATA: + case EFI_RUNTIME_SERVICES_DATA: + return true; + default: + break; + } + + return false; +} + +/* + * Examine the physical address to determine if it is boot data by checking + * it against the boot params setup_data chain. + */ +static bool memremap_is_setup_data(resource_size_t phys_addr, + unsigned long size) +{ + struct setup_data *data; + u64 paddr, paddr_next; + + paddr = boot_params.hdr.setup_data; + while (paddr) { + unsigned int len; + + if (phys_addr == paddr) + return true; + + data = memremap(paddr, sizeof(*data), + MEMREMAP_WB | MEMREMAP_DEC); + + paddr_next = data->next; + len = data->len; + + memunmap(data); + + if ((phys_addr > paddr) && (phys_addr < (paddr + len))) + return true; + + paddr = paddr_next; + } + + return false; +} + +/* + * Examine the physical address to determine if it is boot data by checking + * it against the boot params setup_data chain (early boot version). + */ +static bool __init early_memremap_is_setup_data(resource_size_t phys_addr, + unsigned long size) +{ + struct setup_data *data; + u64 paddr, paddr_next; + + paddr = boot_params.hdr.setup_data; + while (paddr) { + unsigned int len; + + if (phys_addr == paddr) + return true; + + data = early_memremap_decrypted(paddr, sizeof(*data)); + + paddr_next = data->next; + len = data->len; + + early_memunmap(data, sizeof(*data)); + + if ((phys_addr > paddr) && (phys_addr < (paddr + len))) + return true; + + paddr = paddr_next; + } + + return false; +} + +/* + * Architecture function to determine if RAM remap is allowed. By default, a + * RAM remap will map the data as encrypted. Determine if a RAM remap should + * not be done so that the data will be mapped decrypted. + */ +bool arch_memremap_can_ram_remap(resource_size_t phys_addr, unsigned long size, + unsigned long flags) +{ + if (!sme_active()) + return true; + + if (flags & MEMREMAP_ENC) + return true; + + if (flags & MEMREMAP_DEC) + return false; + + if (memremap_is_setup_data(phys_addr, size) || + memremap_is_efi_data(phys_addr, size) || + memremap_should_map_decrypted(phys_addr, size)) + return false; + + return true; +} + +/* + * Architecture override of __weak function to adjust the protection attributes + * used when remapping memory. By default, early_memremap() will map the data + * as encrypted. Determine if an encrypted mapping should not be done and set + * the appropriate protection attributes. + */ +pgprot_t __init early_memremap_pgprot_adjust(resource_size_t phys_addr, + unsigned long size, + pgprot_t prot) +{ + if (!sme_active()) + return prot; + + if (early_memremap_is_setup_data(phys_addr, size) || + memremap_is_efi_data(phys_addr, size) || + memremap_should_map_decrypted(phys_addr, size)) + prot = pgprot_decrypted(prot); + else + prot = pgprot_encrypted(prot); + + return prot; +} + #ifdef CONFIG_ARCH_USE_MEMREMAP_PROT /* Remap memory with encryption */ void __init *early_memremap_encrypted(resource_size_t phys_addr, diff --git a/include/linux/io.h b/include/linux/io.h index 2195d9e..32e30e8 100644 --- a/include/linux/io.h +++ b/include/linux/io.h @@ -157,6 +157,8 @@ enum { MEMREMAP_WB = 1 << 0, MEMREMAP_WT = 1 << 1, MEMREMAP_WC = 1 << 2, + MEMREMAP_ENC = 1 << 3, + MEMREMAP_DEC = 1 << 4, }; void *memremap(resource_size_t offset, size_t size, unsigned long flags); diff --git a/kernel/memremap.c b/kernel/memremap.c index 124bed7..9afdc43 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -34,13 +34,24 @@ static void *arch_memremap_wb(resource_size_t offset, unsigned long size) } #endif -static void *try_ram_remap(resource_size_t offset, size_t size) +#ifndef arch_memremap_can_ram_remap +static bool arch_memremap_can_ram_remap(resource_size_t offset, size_t size, + unsigned long flags) +{ + return true; +} +#endif + +static void *try_ram_remap(resource_size_t offset, size_t size, + unsigned long flags) { unsigned long pfn = PHYS_PFN(offset); /* In the simple case just return the existing linear address */ - if (pfn_valid(pfn) && !PageHighMem(pfn_to_page(pfn))) + if (pfn_valid(pfn) && !PageHighMem(pfn_to_page(pfn)) && + arch_memremap_can_ram_remap(offset, size, flags)) return __va(offset); + return NULL; /* fallback to arch_memremap_wb */ } @@ -48,7 +59,8 @@ static void *try_ram_remap(resource_size_t offset, size_t size) * memremap() - remap an iomem_resource as cacheable memory * @offset: iomem resource start address * @size: size of remap - * @flags: any of MEMREMAP_WB, MEMREMAP_WT and MEMREMAP_WC + * @flags: any of MEMREMAP_WB, MEMREMAP_WT, MEMREMAP_WC, + * MEMREMAP_ENC, MEMREMAP_DEC * * memremap() is "ioremap" for cases where it is known that the resource * being mapped does not have i/o side effects and the __iomem @@ -95,7 +107,7 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags) * the requested range is potentially in System RAM. */ if (is_ram == REGION_INTERSECTS) - addr = try_ram_remap(offset, size); + addr = try_ram_remap(offset, size, flags); if (!addr) addr = arch_memremap_wb(offset, size); } diff --git a/mm/early_ioremap.c b/mm/early_ioremap.c index d7d30da..b1dd4a9 100644 --- a/mm/early_ioremap.c +++ b/mm/early_ioremap.c @@ -30,6 +30,13 @@ static int __init early_ioremap_debug_setup(char *str) static int after_paging_init __initdata; +pgprot_t __init __weak early_memremap_pgprot_adjust(resource_size_t phys_addr, + unsigned long size, + pgprot_t prot) +{ + return prot; +} + void __init __weak early_ioremap_shutdown(void) { } @@ -215,14 +222,19 @@ void __init early_iounmap(void __iomem *addr, unsigned long size) void __init * early_memremap(resource_size_t phys_addr, unsigned long size) { - return (__force void *)__early_ioremap(phys_addr, size, - FIXMAP_PAGE_NORMAL); + pgprot_t prot = early_memremap_pgprot_adjust(phys_addr, size, + FIXMAP_PAGE_NORMAL); + + return (__force void *)__early_ioremap(phys_addr, size, prot); } #ifdef FIXMAP_PAGE_RO void __init * early_memremap_ro(resource_size_t phys_addr, unsigned long size) { - return (__force void *)__early_ioremap(phys_addr, size, FIXMAP_PAGE_RO); + pgprot_t prot = early_memremap_pgprot_adjust(phys_addr, size, + FIXMAP_PAGE_RO); + + return (__force void *)__early_ioremap(phys_addr, size, prot); } #endif