From patchwork Wed Jun 22 10:24:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Chen X-Patchwork-Id: 9192375 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 DF95E601C0 for ; Wed, 22 Jun 2016 10:35:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE24C283E6 for ; Wed, 22 Jun 2016 10:35:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C26A7283F1; Wed, 22 Jun 2016 10:35:08 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 1270E283F7 for ; Wed, 22 Jun 2016 10:35:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751077AbcFVKfE (ORCPT ); Wed, 22 Jun 2016 06:35:04 -0400 Received: from eu-smtp-delivery-143.mimecast.com ([146.101.78.143]:58530 "EHLO eu-smtp-delivery-143.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751390AbcFVKet convert rfc822-to-8bit (ORCPT ); Wed, 22 Jun 2016 06:34:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/HBR1kqJqbjMvZJgbrFKz9VYs1zTF7Yj5ps1IV5w4Xk=; b=ULJzQ+Ob34pCRCjXqXEFvbqIC6v2E1ZZuRiD9ruZ3HTzeoMrF7MmjvVqvk9t1vJvG+DvgkSPgzrw/CpS8l2PZJkVwHFCPcKHQEG7JWch2IxQzuGdRyS0kCWWusrmKy1YBj2aRq9+t5rPgm4Jed+wEDKHUsFK0unOGeRE8JqWB28= Received: from emea01-db3-obe.outbound.protection.outlook.com (mail-db3lrp0077.outbound.protection.outlook.com [213.199.154.77]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-21-dOY8hVB7PYaVTTsDTWNNAQ-1; Wed, 22 Jun 2016 11:25:33 +0100 Received: from DB4PR08CA0025.eurprd08.prod.outlook.com (10.161.12.35) by AM4PR08MB0899.eurprd08.prod.outlook.com (10.166.133.27) with Microsoft SMTP Server (TLS) id 15.1.523.12; Wed, 22 Jun 2016 10:25:32 +0000 Received: from AM1FFO11OLC009.protection.gbl (2a01:111:f400:7e00::188) by DB4PR08CA0025.outlook.office365.com (2a01:111:e400:9853::35) with Microsoft SMTP Server (TLS) id 15.1.523.12 via Frontend Transport; Wed, 22 Jun 2016 10:25:32 +0000 Received: from nebula.arm.com (217.140.96.140) by AM1FFO11OLC009.mail.protection.outlook.com (10.174.65.123) with Microsoft SMTP Server (TLS) id 15.1.517.7 via Frontend Transport; Wed, 22 Jun 2016 10:25:31 +0000 Received: from dennis-ws.asiapac.arm.com (10.1.2.79) by mail.arm.com (10.1.106.66) with Microsoft SMTP Server id 14.3.294.0; Wed, 22 Jun 2016 11:25:13 +0100 From: Dennis Chen To: CC: , Dennis Chen , Catalin Marinas , Steve Capper , "Ard Biesheuvel" , Will Deacon , Mark Rutland , "Rafael J . Wysocki" , Matt Fleming , , Subject: [PATCH] arm64:acpi fix the acpi alignment exception when 'mem=' specified Date: Wed, 22 Jun 2016 18:24:31 +0800 Message-ID: <1466591071-2833-1-git-send-email-dennis.chen@arm.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:217.140.96.140; IPV:CAL; SCL:-1; CTRY:GB; EFV:NLI; SFV:NSPM; SFS:(10009020)(979002)(6009001)(7916002)(2980300002)(438002)(189002)(199003)(48376002)(5003940100001)(104016004)(110136002)(586003)(11100500001)(77096005)(7696003)(50466002)(6806005)(246002)(19580405001)(19580395003)(36756003)(8676002)(50986999)(575784001)(356003)(229853001)(106466001)(50226002)(87936001)(8936002)(2351001)(2906002)(189998001)(7846002)(92566002)(33646002)(26826002)(47776003)(4326007)(86362001)(5003600100003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR08MB0899; H:nebula.arm.com; FPR:; SPF:Pass; PTR:fw-tnat.cambridge.arm.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11OLC009; 1:qq/kmSSyMQVSxesnbX4fQw7Qlz1D6p8fE8G2p8jmTrlc/QRm5IGnaFMyCxhVodyyhWJCP0aXbFuWk9JkBZLvMzFqsjIzbJTHwdE2N7aHB+ghYW8iRYo8sZibljiqSYhys6FEO5WdUYTkS4oIfNCGI7wFgwv1nd3d0B2yBeQ2NcRdEa2tVsMvlJHdfa6b0YBaCYFgSsiAmpPhrxbPwQCw/o+49GePBprFZ+v1/pD9gCb5mxM5KWsalkOfKayBA3X3qAzeTTEc0UOH3upOS6e4lOVLpL0TXAKL85pBltDR6xPl8Ivt8GV4ZhpcZ+WdlHYEEYNgyFbBGynUsyS6nb7KvtV7kJI6x5h8U0mtiz7Aj5XHHIKe9nwFGCZf4M1vFynOP+fx8Jyihynye/OD0zQfX/DpdG1j5nYfOMj3OStOZ9iCoZ4xC/d2hdweo6n4n/QY5jNTO4wuS0cAs49I3GaLe+38gGhu2LgXOF7dfrOWo2dblEf7ek/h4dQlofyfEgIGuE1pfXWOsLl6uvKh5uOS/e2gyA6xAnH/wke7EJljTKqSEOJDrBW7jeyPJVza7Vu4+bVAIzMq3zpwN8dWm+Yz6vWFFv6jdk8FMkz3cjUTgUU= X-MS-Office365-Filtering-Correlation-Id: 4fb50802-0fdf-4059-6a40-08d39a878a61 X-Microsoft-Exchange-Diagnostics: 1; AM4PR08MB0899; 2:aGNUcdhCJo1U/6i8koPflECkrN7g3Gc8lsbaRAmrya5Tl57r8RiRVOgp7DoCWjlWns2SRw8M/I8p1dO5JNqvx3K/wNhl906YG6DAqThCOtsac2xGIFpju25n5zncK5/y7nTVLOni5zjsONn0OqffoSgqaE88dAOU23xABsTl4t7yfjJEAheEPV6jsohSaZYf; 3:4eOiB3/ZyxgwyhUiv9Cj9qYKXPzcTMpMAC1wr1Vjx6zTsSj68nV/nY0UeXTXdiu6Iwa92NBO3AzwgdgqneET3n1cL/n8fmBt3sPKt4WetKNBN88YVIWjS+0n/SU2wYMX1x7oiWRZb26TnuOmBO7BKxZzy9E16xmLV/xFQ5Zx+LGxQtRGC9d8s4I3CCVCSqMLAwi+c98ej6CFFJpz0gMKb1jWV+Dapw23RU7ktwM5p6muYgb/nJNaYyHJOsbvTGw1LahE2gKeBHb59jgVPC2joQ==; 25:Sg1ix/vcYGtlAK30BycX2zzP0AjE0kQeBbtVUm+h2NQ0cUhAEDS37gNgQ58mOV/INp7eTuUyWqjIa0WzwHamZgSlcelTTow3sYNqzcM7T+cS+ReOokHQACypHFvO1JY6xkDkT7fchoSilsvbMFf+CnFJ1lJajNGzVsbCrKP5tG4BE42iYgDIHFQFA/10Ee5AZVyoC7yG+3cLnxV7CqCBM3eQN3a7kGwVC6qrywZJ4gu6cKLQnEc8EsX/ubgJLGchmxR83hlB7K6oJS7qjia4KS6VZ0wojLzLrpQm8dzHCEUSB1azpX90F5onxbYQPH38ymBu71r2XDYR9bhKi+qEcccW072oqxO3jqbH+QH9SwzUBS2XOuJ3orHSCHwKefTWuekbAXMA+I3ydmvcEoHimhJd0WpRBrakWyvsZrhyUic= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:AM4PR08MB0899; NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; AM4PR08MB0899; 20:qEaWm9gZy+BiR2nKz8UYqxPnYHchCRThbGc+qkkXLtCfs9PMiAXxq6Hyb8OgbwEqkbZaYedo5VTBYX04cxZTbj477DDM+UNAO6iCOPx46E1u2a734zPI8YJQ8Eczgaj0MBCH/OwdgB2dSQ8rIbgqi3OjjP+LY+qinMwOPoqnVBMOjG9mYTK3XX85pOyqePSsik25GQQv055XILEUIWRic9sBSxuXhYAAIdQf/a7amEMgMA+dM9dCv6n42bf2WKri; 4:JvsdxuH9fV81KuKfMprXz6Tm75oT8v4BPYqNRDtVPZRnIQ4K8sw2fJczv+N5IYjDOhWCl/aXYiBbKKk+/xZaevYHbFXOPorjQLnlwtzOUacdmIBUUuwVqHCSjbt6uxz+1Ydd4aIOcnEDqqhpoOIprkP0aNAjjyi5Bk+XFLQruviQs7rHUpyqZ/qCAkP1/dcq2szAII5+sbjhdrAdYOSPIRJXmXFeht25RnC8JQE/hIsLfgdS3ig/0ltSiZVNV/VHUneECsv92PGAryME2G3wHszwFlD4hCdARyfPB88T5f2fChh5iR1zZrG+lJ7Wf8HAZIr9dXJNV24kqEtsPh6nd2UyP/hJ2WYiZ9VdpzeTQOz4qmiulLWotUYJvKxBkzW2oKchp9yFI46M6+XLdcV/R4C87ShsWU/eU5PHK1A7ogdi7giJs6/kch66OBDCryCGCp6iWzsH1PC5krgPwv39CjC1oMMSl7CSOX8D/Pkql4h5OBgs1ZbRrCHNTqR8iBTDT3yneqIwFqbuUNkqOq4pCdiHtuF0Rtw2w6B1cadQKp9HFmPfP9boEWjW4l31JdWh X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(9452136761055)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13024025)(13013025)(8121501046)(5005006)(13020025)(13023025)(3002001)(10201501046)(6055026); SRVR:AM4PR08MB0899; BCL:0; PCL:0; RULEID:; SRVR:AM4PR08MB0899; X-Forefront-PRVS: 0981815F2F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR08MB0899; 23:QU3ZCQUdooWSGPdfutN10RQ/F1h62gsdXZwNrqIDn?= =?us-ascii?Q?3qRmpRUjiPKKIz3NePZws/b/LFpg0cE2gj8YjC6xDp1uPZM37yqQij5QTktC?= =?us-ascii?Q?f8OwetJeXg1N3F6YjpbSaCEF+FK9paCyy2uNZFgGQghlQj4r6oxws0LsXRDz?= =?us-ascii?Q?xTWFdwn4Y4J3Q3ggf3HP1xqRYGvwdS/vKBuvv/XYd3QCK35N8qJLjHIazWwU?= =?us-ascii?Q?f91fbo8zYGpqGhtAlWb4vNQ2yPGaCO7fjTEr+9waaUz28u+3omYhiyx3YfdK?= =?us-ascii?Q?quOFbQmDZ0zsz3w/Ijz7ES58lo3PhF+/EUZd2oKzB13HqC54ErFjRpAeVQDY?= =?us-ascii?Q?BktfE9BJU6chZq97G/r0CkSZHMENEY2yhf7gPuPmeZGhJfPpzGE4Va1wj6jY?= =?us-ascii?Q?3I7t6Snl5stt1jfkDiPMBxeHqMj2mTs+8P+Gw5K8mNBqQZJNB26HP7Z9S2go?= =?us-ascii?Q?4R5PjvGPosRo/9ta0/hh4LfhRTSgOCZVBw2SS2cLZvWO0ONQXsIP2MxKypwx?= =?us-ascii?Q?fvALcexvfO2dT2xChNoA/9Z2P7YcKdrnDYIypsaLO/nTrim3qAhnCRIxxCbV?= =?us-ascii?Q?Ab7w4G0zF8fpkJyTR7mTmMEdmy6gkUijFvOQ1Fr/gOMoSbLQt2tnKk2Lp4Om?= =?us-ascii?Q?nvKmN/eiYWoODN/FRO97aMhcbaFV68aIooHojACXPhOce6dG30LF4ZxH0752?= =?us-ascii?Q?PeesjExaxp0EjNceQ797wMYeNyDXWkY1iz04Uonm8V7IiwLdiGj6vCW/ANJf?= =?us-ascii?Q?/4WHswOwrkfjwafO+C/3G7jSSQJV8DZFyy25JPaoYIkMjOBShzaF+MVR9N6Y?= =?us-ascii?Q?13q7aeou3WioP01xRaa8X2MSVzhV9Tpg83g/AGj/aqHM3NwF4D3HJUE4mLte?= =?us-ascii?Q?g2z3zB7maGlIzqcMSsKuqhGg+8Dx+ftvw/tXojl7itWvzRJYwNCUyYeCAYfS?= =?us-ascii?Q?JxiHzAPbYyrr9Iv+edw/d/x0qjaS43ceP6NMmMQ3mweYqoZozCBXymq1BY8+?= =?us-ascii?Q?2sJcKNJJRDgnD9ffkxklA8ZC5PpvV73/VqsnkIZ4qKod+vwRjXzWnonRW05u?= =?us-ascii?Q?JLEgsBaWsYgDqSoR6iA8CkpwrPkRTvp6K4eOLM2Hb5WvOoXyWebV5W9a3rYb?= =?us-ascii?Q?lHoYIJT3hU=3D?= X-Microsoft-Exchange-Diagnostics: 1; AM4PR08MB0899; 6:RXdKJQqcuh9RfTBErsq1ry7DaU/jAW9MyKhNdRd+c4U/CtL47m+ZVRnoAH3EUcCN6R+uCP6UhgRHW+ZS/te2I5aDCVUSZJBG1baY7MK/mmnriIw5iQfjoIGeLlIxr5Dzdq7HKWGwf5khFKCnRBmbjVJJVGkDKd9FuSQOZ2mwUa+FYCeo016c7l7eBDYfylr5DoFZw1lW9GXBQn7VR7lduO4YNSaCdODlPhk0wNbD1iPtkVNj2A1UChfHNOzuf0k0xdbXTtrHU4FdEvyD3VEL9RbOzgbDQM+Ok13Q94g8pYkMxsdjJbGC1l3XihRollvsUSvFqaeTQAVs9Ek5cqASKppmgRGT/uS1MtRpz4QaKuc=; 5:AulTSF2DmzqndIDnDopzXsHikG+M76NW9J7FaAF4tXwWN/50n97nspn5AZZuW7m3WrB1Yh3B96RQhWvA2BPeqeGpMIlz0fZQnb7O1P4GUhfBV5gaAcfFYUHsGkxi9wmSJMNCYnKLp+Zsd4qw6QIGWw==; 24:mt/pr59kXasa3oecu7GRejdE+lalw9H4a13iYSy7vx1GFRvkYmXTKwCm3lZZr1QG9z5vm2zbdyptYeLTZsLAF3hue4d4LjsyXUENHx62gpk=; 7:4Rp3rAAi/CKFi2HfksjaZhtE0NEbxAP3SQYfpvFRcOGHJnx+bQ4ZnVAg8DJNMJliETbp7/5Q9mzG9k7FG4tDAU8Uov4O2FVlRG4hNqIv56r0ssp/fzhcjShNowMIel8g2kuU3bGxL1oUjfZVXcQP4BHTl8aWNRERVkERi8ShGkTBnGCgXSA7c6xUOnfsG2Xpm9qwC3hYLzJMvYYVYFL1IJo8DoVjUGYtQ/pUvR3q77gkAwHdyHrtVHL4PQhBP0nYW89bqITyxbHliAhZyW2ROA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM4PR08MB0899; 20:VIPBSyF3Rhxq5VqSOPZO2voI/R5JJWyKY4z4SzgRnPmr/9Kyg0mVyDwNE4lsnIk/jNz05je3L7EUjukxVZX1SAwgDGP+ofUF3TjZZAhz6zU7CVWqUGf6IW6YrcQtwuOEB1GgeFUMw3lKX/dNOBqc1cU05W2YMfUS5AgBKAlID08= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2016 10:25:31.9622 (UTC) X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[217.140.96.140]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB0899 X-MC-Unique: dOY8hVB7PYaVTTsDTWNNAQ-1 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When kernel parameter 'mem=x' is specified by the command line, probably the ACPI memory regions from firmware will beyond the scope of the physical memory space after limited, if we don't add back those regions into memblock in this case, then the ACPI core will map it as device memory type. Since the ACPI core will produce non-alignment access when parsing the AML data stream, alignment exception will be generated upon the device memory mapped region. Below is an alignment exception output observed on ARM platform with acpi enabled: ... [ 0.542475] Unable to handle kernel paging request at virtual address ffff0000080521e7 [ 0.550457] pgd = ffff000008aa0000 [ 0.553880] [ffff0000080521e7] *pgd=000000801fffe003, *pud=000000801fffd003, *pmd=000000801fffc003, *pte=00e80083ff1c1707 [ 0.564939] Internal error: Oops: 96000021 [#1] PREEMPT SMP [ 0.570553] Modules linked in: [ 0.573626] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.7.0-rc3-next-20160616+ #172 [ 0.581344] Hardware name: AMD Overdrive/Supercharger/Default string, BIOS ROD1001A 02/09/2016 [ 0.590025] task: ffff800001ef0000 ti: ffff800001ef8000 task.ti: ffff800001ef8000 [ 0.597571] PC is at acpi_ns_lookup+0x520/0x734 [ 0.602134] LR is at acpi_ns_lookup+0x4a4/0x734 [ 0.606693] pc : [] lr : [] pstate: 60000045 [ 0.614145] sp : ffff800001efb8b0 [ 0.617478] x29: ffff800001efb8c0 x28: 000000000000001b [ 0.622829] x27: 0000000000000001 x26: 0000000000000000 [ 0.628181] x25: ffff800001efb9e8 x24: ffff000008a10000 [ 0.633531] x23: 0000000000000001 x22: 0000000000000001 [ 0.638881] x21: ffff000008724000 x20: 000000000000001b [ 0.644230] x19: ffff0000080521e7 x18: 000000000000000d [ 0.649580] x17: 00000000000038ff x16: 0000000000000002 [ 0.654929] x15: 0000000000000007 x14: 0000000000007fff [ 0.660278] x13: ffffff0000000000 x12: 0000000000000018 [ 0.665627] x11: 000000001fffd200 x10: 00000000ffffff76 [ 0.670978] x9 : 000000000000005f x8 : ffff000008725fa8 [ 0.676328] x7 : ffff000008a8df70 x6 : ffff000008a8df70 [ 0.681679] x5 : ffff000008a8d000 x4 : 0000000000000010 [ 0.687027] x3 : 0000000000000010 x2 : 000000000000000c [ 0.692378] x1 : 0000000000000006 x0 : 0000000000000000 ... [ 1.262235] [] acpi_ns_lookup+0x520/0x734 [ 1.267845] [] acpi_ds_load1_begin_op+0x174/0x4fc [ 1.274156] [] acpi_ps_build_named_op+0xf8/0x220 [ 1.280380] [] acpi_ps_create_op+0x208/0x33c [ 1.286254] [] acpi_ps_parse_loop+0x204/0x838 [ 1.292215] [] acpi_ps_parse_aml+0x1bc/0x42c [ 1.298090] [] acpi_ns_one_complete_parse+0x1e8/0x22c [ 1.304753] [] acpi_ns_parse_table+0x8c/0x128 [ 1.310716] [] acpi_ns_load_table+0xc0/0x1e8 [ 1.316591] [] acpi_tb_load_namespace+0xf8/0x2e8 [ 1.322818] [] acpi_load_tables+0x7c/0x110 [ 1.328516] [] acpi_init+0x90/0x2c0 [ 1.333603] [] do_one_initcall+0x38/0x12c [ 1.339215] [] kernel_init_freeable+0x148/0x1ec [ 1.345353] [] kernel_init+0x10/0xec [ 1.350529] [] ret_from_fork+0x10/0x40 [ 1.355878] Code: b9009fbc 2a00037b 36380057 3219037b (b9400260) [ 1.362035] ---[ end trace 03381e5eb0a24de4 ]--- [ 1.366691] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b With 'efi=debug', we can see those ACPI regions from firmware as: [ 0.000000] efi: 0x0083ff1b5000-0x0083ff1c2fff [ACPI Reclaim Memory| | | | | | | | |WB|WT|WC|UC]* [ 0.000000] efi: 0x0083ff223000-0x0083ff224fff [ACPI Memory NVS | | | | | | | | |WB|WT|WC|UC]* This patch is trying to add back those regions into memblock, make ACPI core map it as normal memory instead of device memory type. Signed-off-by: Dennis Chen Cc: Catalin Marinas Cc: Steve Capper Cc: Ard Biesheuvel Cc: Will Deacon Cc: Mark Rutland Cc: Rafael J. Wysocki Cc: Matt Fleming Cc: linux-acpi@vger.kernel.org Cc: linux-efi@vger.kernel.org --- arch/arm64/include/asm/memblock.h | 14 +++++++++++++- arch/arm64/kernel/acpi.c | 23 +++++++++++++++++++++++ arch/arm64/mm/init.c | 3 ++- drivers/firmware/efi/arm-init.c | 19 +++++++++++++++++++ 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/memblock.h b/arch/arm64/include/asm/memblock.h index 6afeed2..8f2e887 100644 --- a/arch/arm64/include/asm/memblock.h +++ b/arch/arm64/include/asm/memblock.h @@ -16,6 +16,18 @@ #ifndef __ASM_MEMBLOCK_H #define __ASM_MEMBLOCK_H -extern void arm64_memblock_init(void); +#ifdef CONFIG_ACPI +typedef struct { + u64 base; + u64 size; + int resv; +} efi_acpi_reg_t; + +#define MAX_ACPI_REGS 4 +extern unsigned int nr_acpi_regs; +extern efi_acpi_reg_t acpi_regs[MAX_ACPI_REGS]; +#endif +extern void arm64_memblock_init(void); +extern phys_addr_t memory_limit; #endif diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 3e4f1a4..5b92a8c 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -28,6 +28,7 @@ #include #include #include +#include #ifdef CONFIG_ACPI_APEI # include @@ -196,6 +197,8 @@ out: */ void __init acpi_boot_table_init(void) { + int i; + /* * Enable ACPI instead of device tree unless * - ACPI has been disabled explicitly (acpi=off), or @@ -226,6 +229,26 @@ void __init acpi_boot_table_init(void) if (!param_acpi_force) disable_acpi(); } + + /* + * For the case of 'mem=x' kernel parameter specified by cmdline: + * when ACPI parses raw AML data within the ACPI data region, + * sometimes it will produce non-alignment memory access, in order + * to make kernel avoid generating alignment fault in this case, we + * need to add back the firmware ACPI memory region into memblock, + * thus the ACPI core will map it as normal memory, otherwise ACPI + * will map the region as device memory type which trigers alignment + * exception. + */ + if (!acpi_disabled && memory_limit != (phys_addr_t)ULLONG_MAX) { + for (i = 0; i < nr_acpi_regs; i++) { + memblock_add(acpi_regs[i].base, acpi_regs[i].size); + /* MEMBLOCK_NOMAP maybe cleaned before, re-flag it */ + if (acpi_regs[i].resv) + memblock_mark_nomap(acpi_regs[i].base, + acpi_regs[i].size); + } + } } #ifdef CONFIG_ACPI_APEI diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index d45f862..2a20d02 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -46,6 +46,7 @@ #include #include #include +#include #include "mm.h" @@ -172,7 +173,7 @@ static void __init arm64_memory_present(void) } #endif -static phys_addr_t memory_limit = (phys_addr_t)ULLONG_MAX; +phys_addr_t memory_limit = (phys_addr_t)ULLONG_MAX; /* * Limit the memory size that was specified via FDT. diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c index c49d50e..645eb19 100644 --- a/drivers/firmware/efi/arm-init.c +++ b/drivers/firmware/efi/arm-init.c @@ -23,9 +23,15 @@ #include #include +#include u64 efi_system_table; +#ifdef CONFIG_ACPI +unsigned int nr_acpi_regs; +efi_acpi_reg_t acpi_regs[MAX_ACPI_REGS]; +#endif + static int __init is_normal_ram(efi_memory_desc_t *md) { if (md->attribute & EFI_MEMORY_WB) @@ -210,6 +216,19 @@ static __init void reserve_regions(void) if (resv) memblock_mark_nomap(paddr, size); +#ifdef CONFIG_ACPI + if (md->type == EFI_ACPI_RECLAIM_MEMORY || + md->type == EFI_ACPI_MEMORY_NVS) { + if (nr_acpi_regs >= MAX_ACPI_REGS) { + WARN_ONCE(1, "Too many ACPI mem regions: %d\n", nr_acpi_regs); + continue; + } + acpi_regs[nr_acpi_regs].base = paddr; + acpi_regs[nr_acpi_regs].size = size; + acpi_regs[nr_acpi_regs].resv = resv; + nr_acpi_regs++; + } +#endif } set_bit(EFI_MEMMAP, &efi.flags);