Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756744AbdGXTM5 (ORCPT ); Mon, 24 Jul 2017 15:12:57 -0400 Received: from mail-bn3nam01on0045.outbound.protection.outlook.com ([104.47.33.45]:41632 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756136AbdGXTJ6 (ORCPT ); Mon, 24 Jul 2017 15:09:58 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: linux-kernel@vger.kernel.org, x86@kernel.org, linux-efi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Borislav Petkov , Andy Lutomirski , Tony Luck , Piotr Luc , Tom Lendacky , Fenghua Yu , Lu Baolu , Reza Arbab , David Howells , Matt Fleming , "Kirill A . Shutemov" , Laura Abbott , Ard Biesheuvel , Andrew Morton , Eric Biederman , Benjamin Herrenschmidt , Paul Mackerras , Konrad Rzeszutek Wilk , Jonathan Corbet , Dave Airlie , Kees Cook , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Arnd Bergmann , Tejun Heo , Christoph Lameter , Brijesh Singh Subject: [RFC Part1 PATCH v3 11/17] x86/mm, resource: Use PAGE_KERNEL protection for ioremap of memory pages Date: Mon, 24 Jul 2017 14:07:51 -0500 Message-Id: <20170724190757.11278-12-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170724190757.11278-1-brijesh.singh@amd.com> References: <20170724190757.11278-1-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: CY4PR04CA0049.namprd04.prod.outlook.com (10.171.243.142) To CY1PR12MB0150.namprd12.prod.outlook.com (10.161.173.20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9c111c07-5911-4018-52d3-08d4d2c7621f 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:CY1PR12MB0150; X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0150;3:O8rxNl6uagupYfWrz8vQ+9PGdwSQav6ZA0yoACandd6XuzFPRWA9AgUZLHYHOIBzqygbNwCYNNi/CvuSiQspaJuXI9xpcMfGU148jmkJmRedshoe4V7E5ZsbqtRbisR6mqS/80j0+TptoY3oo2bmhHq1vXOWp/ChKcPDGxDz4AHl9O0oMsRzzyfRSXdnIdjp98FU0GJ5V3V4REbEMizLfYpn6na6ro1iKBxZFJvdx8i61Jjj8jpo05nElm6HVqFmzCO1yfICVyu9UzoJkBWU3ycZsiG0qdRPpzsbSt/m+nWMTUPdGEtkUE971NSRPxFn6KGUwNoAKhGa6Xs/jOGK378mRa04Cw0EyGXdMY8s9ahkJDBOUXMQbJZzFcA+RcakIyvHqzc6usAVN0SsPrkrSpheLDhuNG8eQ4ltONCDheBhbpUG6XciGB/xbuEYTuJzx4fjFBZLZzoeN8YDHJwe1z1t7V1OXl6coWD/PWOOduWC2BJFaGU2y+sAm1s3YTuyXmOuLC2FfGpjqR7VQF31OU8NT6972FY1kT4y6G2PrOQ9zAjkY1C5toOL/KF+WAOlQHoOiL7UHYqKNu5xe/bTX5A74kwzMegAaaBLtPMp86dArAmfcqgSVyQTIWSd73nlIDhhoSJZJL2cIVRqf3eVrNC0LLKISLWAbo7EC4qdZpSLyY32brrN+J9hpq+qvUREGZtAodXSN7KOYJEKvDdxOnEe+es0tY7709BjDZwmaQBOnM4frltwyY5xWLVqNer/EPB0sUUmGnmuiL/hCc9pGQ== X-MS-TrafficTypeDiagnostic: CY1PR12MB0150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2u3XT4Ns4yY0c9cqxAfCV8P+1o9JNI/zl1V/YwjrWOTXuo+ec4/VDVJEvMVeQPJpvmfeNhbGTFwY9lFIOfSi5kCPa5xsPsTj X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123564025)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY1PR12MB0150;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY1PR12MB0150; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR12MB0150;4:glOaiclVv7q+wdEBDfsMqiUjzrF6jwit5EwGM5vY08?= =?us-ascii?Q?h/zp8X2kITdUD41KX2LbtqvyxNl6aQCGQ6LsdDoMOn4Hf9DxiRbh1Ax3BL2f?= =?us-ascii?Q?WNLB473L259MpPMwLHGgTlNyPIrmxGK7IAzbrPYDEeb1kPnOkyq0o252pB2O?= =?us-ascii?Q?f7ELLNoggxt5MEpw+WxmfKsh9UGXZskdLMR3jzQysfSZDyKz4IA9gsUJKGtA?= =?us-ascii?Q?iqUQ5F5v5zWEGgjpmnq2YfxbectmpBRw09qJhEYy3WKwly+HDv12jFRtcBA3?= =?us-ascii?Q?WM4qaKoRz7q02W02PKWXOhFNhjdRkHvEbK+a3399cSYpHlYQylF2dgFXs4l2?= =?us-ascii?Q?LmOz73kz9zOnKw8ZdoUIWvkygdpY3/YMdsI5DcOqh1hEQkfhDOk9JAHi5KVS?= =?us-ascii?Q?rrf0ZT23CmoYU1SMl2WxGcjirQpf0KJldIt+5oWNwGdtRcMsHWUwzit3wuuK?= =?us-ascii?Q?28y7m1USnJNWGRVwPB7i1bCPyRDqET1RZ+v94++PUmB31/DQNj92ELIh7KT1?= =?us-ascii?Q?/0qLBPGLJ3rgMHmwhuhcYcA5MPShY9UWZwkJ2enSRTzv2wrFQP7dxcXPlR+Y?= =?us-ascii?Q?QZ1fkt/XCTXsgdjyVk0am3wBx87hNhCC/MayNQ7paVlAk7L8C7gb3AGTFJ1V?= =?us-ascii?Q?5BFTRjVj7VyJmdnvObXtjpgaPXribWU8Iv9eeXSzgK1THAiTEvvp7yS4nuxE?= =?us-ascii?Q?ee8wb9akkzGvnJldTtzJ1w6WlZS08fYpMRo7fkcmbXD3EJ8/r4tQ3iUAJEAJ?= =?us-ascii?Q?5lOye9EvI9J6z+Lp6iIkyxV8pcZkPk0YEvaYArZOMhnMxIKmhjy3MjT0MhDH?= =?us-ascii?Q?EvPOo0rdjAotxXoapXEIwP0yyIT9048InWwuQB1RKZ7Ap8y5S//ue4ESjhUk?= =?us-ascii?Q?RP8Gmy4PfyRnpopa61m8DHV+FYg64+lqHf+m+2FAxL8C3U5oX20nifrp6mNC?= =?us-ascii?Q?JUo69HB26IsBzO0sYYo1waimtwO6uSPn1eBMU0vHKCzVjitGFiRnmSOrT0Nb?= =?us-ascii?Q?QxajfUwmmPcJ8OjlMv8IgxWJuF+ooVXebeWHOOd791zFxi4/Gl3cjAV5pvQe?= =?us-ascii?Q?RfM9HrAX3gOXmNHeCV4FCUK1w+hy+RJvmhD4NC6Fum/RCQ6VsgXwN0kLfeGz?= =?us-ascii?Q?WXPuPr0voObmES5TkQzgsKvhuUWW/RmMW8w2JW332dvxImDlVeDAScBt7RsY?= =?us-ascii?Q?qOmnsMjPqSJJZJNRagLXIzRH1Jtm9LtEzG?= X-Forefront-PRVS: 0378F1E47A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(7370300001)(6009001)(39840400002)(39850400002)(39450400003)(39400400002)(39410400002)(39860400002)(199003)(189002)(4326008)(81156014)(7350300001)(81166006)(50226002)(50466002)(68736007)(36756003)(38730400002)(1076002)(110136004)(53936002)(6116002)(25786009)(48376002)(575784001)(8676002)(86362001)(305945005)(54906002)(7736002)(2950100002)(6666003)(50986999)(101416001)(47776003)(105586002)(5660300001)(5003940100001)(7416002)(33646002)(106356001)(66066001)(6486002)(7406005)(97736004)(189998001)(3846002)(76176999)(2906002)(53416004)(42186005)(478600001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR12MB0150;H:ubuntu-010236106000.amd.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR12MB0150;23:Vr9c0QxRZhl/RiMkUyJYyZp1MC4bQDznNJokteLQb?= =?us-ascii?Q?mD86DY1cxu7Goa/BSy79wZ5vQbGI4rtHQMjsSG5B1Wz6nJwlB/YvOH+4yh35?= =?us-ascii?Q?Fc3CpXBzM4yW8M0KLIJdJWqIru7IMdZFVtDup7AsIpZ9RLokbdSbH1uo8qrm?= =?us-ascii?Q?eZkEFmSsvS5czpNPiDfZ5KoiAgAJNPvqt+8UrbX57M/lNO+SXnhnhTS8HjT4?= =?us-ascii?Q?b9mIUwEjBIF7E2LgMDkuSqzKEZzb9Q0Nhpi63AAD1QKcZNhEd2mg3yPFAIiw?= =?us-ascii?Q?YOx5rZSc7n/y7SRRqjzalU/EpcyF2gxTfWpNzt3TNt4fol+NhDNo78xUP+d5?= =?us-ascii?Q?p9e1RjEaM8tqdCRTWe8FBAv5rCpRn6apURwuyrLmcvO73wcEVlVbIi2V0AIx?= =?us-ascii?Q?g7OjSGMdX8ZD4qqX7K6U9qzRyBC1RnoMICxIlUui4DbGjB0U7d9xPyTYYziN?= =?us-ascii?Q?xtfnxIpOehWyHa44z0ka+PhgNDudmvJXdRbEd01MgjHXtRWZKzBT9BmFtM5Q?= =?us-ascii?Q?OwCt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QUv8sL6yqb3jEIBsaXG2Syd4I4Xyelm0fqnR5sAoimFzWPH?= =?us-ascii?Q?2/McLoXPGqXctfcxa/w9YpAwoBin1Um5/tC47ekqbTnSZ10Gm2yZLcENJx3G?= =?us-ascii?Q?F3OqyL7R6hPy/bguqxx5ty?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0150;5:AyQGeJ+msmVphV5b3z6mfb4YK6jgnrhOTxszhHmvG4W68SYGCKjW8lFOhfmPj2foN1m/i1W+X8MggHnrBP+ZEEvCprpERtBx5m4+9BOkD8kJVIPZO5rTx8dMcxHfv/yFNSuQDhKUkuHfZ4ehuhCMoEjeYpZg2v3kXFdEkFAMnUvQmgmnLZjZ5vn+0nyBSWx00RKB7WPvPOh3FIyH5r+mjClTDPlamogpe5zkkcOf91CiiVJLLekaoYT1WIOEPYul0BAmjA7obBxFLPc1SVdoBUFOIoNO/9hjTlIJNpYmh05lJlMmwwx2fnit1K97DZmPlfl6DkCNXwnVWZBifOUe/Dg7rMEvndEd+26sPyDgSyx71aLoZARPE9uA7gjumtCWczNJQ215SJYXo7qL42SIYICtud3PnWJy9IBMzrRWaNia/R6VnOFrF/qMP6G50vm8yGz0DLw+DIUTa6CEqQmVscAb+WeaRngWzDIpHSRc7+SJzQtEM4R344h/wC9AUrkJ;24:4Q2Nr0KI9dNAJfxwAxUxtPyjdAKQa/y7noGhDydQsSzEbLpZOAXuIhSSdBIMsN312+4IFuEbp8yJCr2IDgX4bMOREhWkDKjv3vyJtvaJBq4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0150;7:OM0kuiUoDQAY9wlnMND8h+lAmXYysNnmMszl/0gF1ItHE/xy10NS5umJ3AguKnfZxs66BDujtj8Whq0bIib3HmJR+DfK8PPJazfAVqSkXCrHUE/PRqXuLDMXxyZ+KYfXKVO6cDcAnepHdiZn8LMhlP5M9lWmm4VHhk1jW4oxNpT5MnY33706SbEbfugWcUODeLiLNt48qce0oKQQlSKwNShHFDV1QqSX1uaadk7ZE6byrh63wyxefN1sIlVEQW9LWkpwf7by1bfxQKduUF2ERtfK0kYTpi2YGImEZNeujPYiLw5jmwdGQGEW8JAJsS+2afYqxEMLv7uS0nGgaeZEU0uCbf4ekdu6hX2slFU2+2uOy7gHKJlJVvOGjOJFxWD5N92juqooeO7h/Q6c7Qx521kp6hJq0GmE3c0XIfFrWFAzgZCNKryla/GvXsRHaFkH9OemHrZb1udcfzWJSZExulJ4cOo3v+Ea+NuwaIOXE1B+hPmCjHx6/cO0O7lwIZknu7F0B2IhW5OGiPRF1f3OCykXSjoHgZBiZilgTs464Va12j7tGsuXIGjX+awcs9lJHTFH9rBPPgUHUwQwKnDf6wRVrbOVa0TutiTIrklEUyy+BAmaNOaP3vIqZO/6RijPk44fIdhydiMKxRSF10y0Omaq7R5NFLk2xnJ/NJNTtGiZLHBSlnQEB1j6IBJ9ije8HWF0Ao8OgTPUVDgCtTdgI2k7pe1SlbMu/5xSKd+WMpK0tBkeO7QiTHqg/78lEkeOanfxh/vU7ExE9OGMLti5sCcxkYdZ2RY7QcU1y12cyp0= X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0150;20:oRrfazwRZAreUnt6+lFSZ7bcSGzLbp1379XMumyCWaycPlAcjZl0iPwwfJyD0AWEs67Hpf1xp+SMR9rkkAIP5+Kw08CjQzjVbCyGHWa2dUgHI9jorqYZ8W/Ubg4sE2o17Wv4rBG8/aPYyd0/g7HQuZbvK88jywnu4vE/414DPiDPuTxH75lF14xu9e+7f196ss1NgJhe158mZYOsDvmJb3XSroA57HSllOmANVR9pLjiZhGXAdG7Epaaji3w5QbP X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2017 19:08:33.7940 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0150 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3260 Lines: 106 From: Tom Lendacky In order for memory pages to be properly mapped when SEV is active, we need to use the PAGE_KERNEL protection attribute as the base protection. This will insure that memory mapping of, e.g. ACPI tables, receives the proper mapping attributes. Signed-off-by: Tom Lendacky Signed-off-by: Brijesh Singh --- arch/x86/mm/ioremap.c | 28 ++++++++++++++++++++++++++++ include/linux/ioport.h | 3 +++ kernel/resource.c | 17 +++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index c0be7cf..7b27332 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -69,6 +69,26 @@ static int __ioremap_check_ram(unsigned long start_pfn, unsigned long nr_pages, return 0; } +static int __ioremap_res_desc_other(struct resource *res, void *arg) +{ + return (res->desc != IORES_DESC_NONE); +} + +/* + * This function returns true if the target memory is marked as + * IORESOURCE_MEM and IORESOURCE_BUSY and described as other than + * IORES_DESC_NONE (e.g. IORES_DESC_ACPI_TABLES). + */ +static bool __ioremap_check_if_mem(resource_size_t addr, unsigned long size) +{ + u64 start, end; + + start = (u64)addr; + end = start + size - 1; + + return (walk_mem_res(start, end, NULL, __ioremap_res_desc_other) == 1); +} + /* * Remap an arbitrary physical address space into the kernel virtual * address space. It transparently creates kernel huge I/O mapping when @@ -146,7 +166,15 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr, pcm = new_pcm; } + /* + * If the page being mapped is in memory and SEV is active then + * make sure the memory encryption attribute is enabled in the + * resulting mapping. + */ prot = PAGE_KERNEL_IO; + if (sev_active() && __ioremap_check_if_mem(phys_addr, size)) + prot = pgprot_encrypted(prot); + switch (pcm) { case _PAGE_CACHE_MODE_UC: default: diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 1c66b9c..297f5b8 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -268,6 +268,9 @@ extern int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, void *arg, int (*func)(unsigned long, unsigned long, void *)); extern int +walk_mem_res(u64 start, u64 end, void *arg, + int (*func)(struct resource *, void *)); +extern int walk_system_ram_res(u64 start, u64 end, void *arg, int (*func)(struct resource *, void *)); extern int diff --git a/kernel/resource.c b/kernel/resource.c index 5f9ee7bb0..ec3fa0c 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -468,6 +468,23 @@ int walk_system_ram_res(u64 start, u64 end, void *arg, arg, func); } +/* + * This function calls the @func callback against all memory ranges, which + * are ranges marked as IORESOURCE_MEM and IORESOUCE_BUSY. + */ +int walk_mem_res(u64 start, u64 end, void *arg, + int (*func)(struct resource *, void *)) +{ + struct resource res; + + res.start = start; + res.end = end; + res.flags = IORESOURCE_MEM | IORESOURCE_BUSY; + + return __walk_iomem_res_desc(&res, IORES_DESC_NONE, true, + arg, func); +} + #if !defined(CONFIG_ARCH_HAS_WALK_MEMORY) /* -- 2.9.4