From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f41.google.com (mail-oi0-f41.google.com [209.85.218.41]) by kanga.kvack.org (Postfix) with ESMTP id 14EDB6B0009 for ; Wed, 27 Jan 2016 11:04:49 -0500 (EST) Received: by mail-oi0-f41.google.com with SMTP id p187so8154595oia.2 for ; Wed, 27 Jan 2016 08:04:49 -0800 (PST) Received: from emea01-db3-obe.outbound.protection.outlook.com (mail-db3on0091.outbound.protection.outlook.com. [157.55.234.91]) by mx.google.com with ESMTPS id dp7si3867112obb.40.2016.01.27.08.04.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Jan 2016 08:04:48 -0800 (PST) Subject: Re: [PATCH v2 RESEND 1/2] arm, arm64: change_memory_common with numpages == 0 should be no-op. References: <1453820393-31179-1-git-send-email-mika.penttila@nextfour.com> <1453820393-31179-2-git-send-email-mika.penttila@nextfour.com> <20160126155919.GA28238@arm.com> From: =?UTF-8?Q?Mika_Penttil=c3=a4?= Message-ID: <56A8EA96.9060305@nextfour.com> Date: Wed, 27 Jan 2016 18:04:38 +0200 MIME-Version: 1.0 In-Reply-To: <20160126155919.GA28238@arm.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 8bit Sender: owner-linux-mm@kvack.org List-ID: To: Will Deacon Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux@arm.linux.org.uk, catalin.marinas@arm.com Hi Will, On 26.01.2016 17:59, Will Deacon wrote: > Hi Mika, > > On Tue, Jan 26, 2016 at 04:59:52PM +0200, mika.penttila@nextfour.com wrote: >> From: Mika Penttila >> >> This makes the caller set_memory_xx() consistent with x86. >> >> arm64 part is rebased on 4.5.0-rc1 with Ard's patch >> lkml.kernel.org/g/<1453125665-26627-1-git-send-email-ard.biesheuvel@linaro.org> >> applied. >> >> Signed-off-by: Mika Penttila mika.penttila@nextfour.com >> Reviewed-by: Laura Abbott >> Acked-by: David Rientjes >> >> --- >> arch/arm/mm/pageattr.c | 3 +++ >> arch/arm64/mm/pageattr.c | 3 +++ >> 2 files changed, 6 insertions(+) >> >> diff --git a/arch/arm/mm/pageattr.c b/arch/arm/mm/pageattr.c >> index cf30daf..d19b1ad 100644 >> --- a/arch/arm/mm/pageattr.c >> +++ b/arch/arm/mm/pageattr.c >> @@ -49,6 +49,9 @@ static int change_memory_common(unsigned long addr, int numpages, >> WARN_ON_ONCE(1); >> } >> >> + if (!numpages) >> + return 0; >> + >> if (start < MODULES_VADDR || start >= MODULES_END) >> return -EINVAL; >> >> diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c >> index 1360a02..b582fc2 100644 >> --- a/arch/arm64/mm/pageattr.c >> +++ b/arch/arm64/mm/pageattr.c >> @@ -53,6 +53,9 @@ static int change_memory_common(unsigned long addr, int numpages, >> WARN_ON_ONCE(1); >> } >> >> + if (!numpages) >> + return 0; >> + > Thanks for this. I can reproduce the failure on my Juno board, so I'd > like to queue this for 4.5 since it fixes a real issue. I've taken the > liberty of rebasing the arm64 part to my fixes branch and writing a > commit message. Does the patch below look ok to you? > > Will > > --->8 > > From 57adec866c0440976c96a4b8f5b59fb411b1cacb Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?Mika=20Penttil=C3=A4?= > Date: Tue, 26 Jan 2016 15:47:25 +0000 > Subject: [PATCH] arm64: mm: avoid calling apply_to_page_range on empty range > MIME-Version: 1.0 > Content-Type: text/plain; charset=UTF-8 > Content-Transfer-Encoding: 8bit > > Calling apply_to_page_range with an empty range results in a BUG_ON > from the core code. This can be triggered by trying to load the st_drv > module with CONFIG_DEBUG_SET_MODULE_RONX enabled: > > kernel BUG at mm/memory.c:1874! > Internal error: Oops - BUG: 0 [#1] PREEMPT SMP > Modules linked in: > CPU: 3 PID: 1764 Comm: insmod Not tainted 4.5.0-rc1+ #2 > Hardware name: ARM Juno development board (r0) (DT) > task: ffffffc9763b8000 ti: ffffffc975af8000 task.ti: ffffffc975af8000 > PC is at apply_to_page_range+0x2cc/0x2d0 > LR is at change_memory_common+0x80/0x108 > > This patch fixes the issue by making change_memory_common (called by the > set_memory_* functions) a NOP when numpages == 0, therefore avoiding the > erroneous call to apply_to_page_range and bringing us into line with x86 > and s390. > > Cc: > Reviewed-by: Laura Abbott > Acked-by: David Rientjes > Signed-off-by: Mika Penttila > Signed-off-by: Will Deacon > --- > arch/arm64/mm/pageattr.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c > index 3571c7309c5e..cf6240741134 100644 > --- a/arch/arm64/mm/pageattr.c > +++ b/arch/arm64/mm/pageattr.c > @@ -57,6 +57,9 @@ static int change_memory_common(unsigned long addr, int numpages, > if (end < MODULES_VADDR || end >= MODULES_END) > return -EINVAL; > > + if (!numpages) > + return 0; > + > data.set_mask = set_mask; > data.clear_mask = clear_mask; > Yes I'm fine with that, Thanks! Mika -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933723AbcA0QEu (ORCPT ); Wed, 27 Jan 2016 11:04:50 -0500 Received: from mail-db3on0093.outbound.protection.outlook.com ([157.55.234.93]:43419 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754116AbcA0QEs (ORCPT ); Wed, 27 Jan 2016 11:04:48 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=mika.penttila@nextfour.com; Subject: Re: [PATCH v2 RESEND 1/2] arm, arm64: change_memory_common with numpages == 0 should be no-op. To: Will Deacon References: <1453820393-31179-1-git-send-email-mika.penttila@nextfour.com> <1453820393-31179-2-git-send-email-mika.penttila@nextfour.com> <20160126155919.GA28238@arm.com> CC: , , , From: =?UTF-8?Q?Mika_Penttil=c3=a4?= Message-ID: <56A8EA96.9060305@nextfour.com> Date: Wed, 27 Jan 2016 18:04:38 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20160126155919.GA28238@arm.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 8bit X-Originating-IP: [84.250.21.106] X-ClientProxiedBy: AM3PR07CA0029.eurprd07.prod.outlook.com (10.141.45.157) To VI1PR07MB0909.eurprd07.prod.outlook.com (25.161.108.27) X-Microsoft-Exchange-Diagnostics: 1;VI1PR07MB0909;2:dGlI5ERiLWKAwEAsAR9XI/uc6b0HUsKYqvdPnN05PqK6ybv1N57Ib74IxPca3nsU9L8VeNvVh06o0VT2TM/BOo31NdvN1jg24HJ4sjEr+09xFdMOA9u7xv4sJxDiwPS3p2seVJrCt4v/mgb1hFYVgw==;3:0m/nkdF8IBU6jdn3I/ShyWs+Zw12Q9IUhG/DsLR9K/EEhrP0NEziWemXQMRDn2J/Ic9oHKdjn10qR8eYBJjkHLYs4mZhr16RGco8/dwc/QmBpU3ZsuYzSI2gfozjbub+;25:vEql9Z+AqmzYpWEhHr0FNu08aduggdRlIL9XQSKWFibLHSmdMannviBVJ+hyp9UaEwKtkdiVIjGNG7+zHZ8tZr0YRD8swCwIQCYaqulWu0LSFis5ehLAkbXgimY204OguzbwG4n9+lN+61PhC71sKumG9GxnDO+fzikGwIbpPTDhq+hJRyKI/ifdH6tcAQKIFIvG+DODTxyM1TqrTrt6rNY4jw8XKWZnmEivc6fhGxO/flUK4RFXQLFBCEIVfy/D;4:cbD5XnSdpZdb7kZLwM3ECVGrQezYcTbOR1PQTWbThBr3AHEdVBJFw0m7aWr7u7dRVqHL4GzwTb5oHSZwbrHyntZ5qFN1MgCQQY8d5fGe0JvR8xNY1aLZ55nWL8ee6BpZ5uD/3GSS3O1eWiHX/nhr3QMduiAVUkfJW8ADjmSsWt/m599cd13S4plOAuv3h1DCv9kk38qruwlwOFm9MdDP7m3xaZUQPjhu/NKUfs92N2m3x9PTbi4hyfg56LVvJz+VBzXX5VlFuWSw6UefYrHMk5UEty+aHeHz524axS7DLYKS6IMwCZW5InDUMaDAf8HPrzYv0TAYthJeypHGKxzVbH3+tZ/8K4VQfIwBdIRwK/uSn5XcorKtcI1wlVkt37Mvdn0NgpnC2riYzm0Ul3klKiAw2uHSmAX/vEsebe+0TYc= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR07MB0909; X-MS-Office365-Filtering-Correlation-Id: dc1131e1-9362-4619-43d0-08d32733925b X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001);SRVR:VI1PR07MB0909;BCL:0;PCL:0;RULEID:;SRVR:VI1PR07MB0909; X-Forefront-PRVS: 0834BAF534 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(6009001)(199003)(189002)(24454002)(6116002)(47776003)(586003)(42186005)(77096005)(105586002)(122386002)(1096002)(4326007)(3846002)(2906002)(2950100001)(66066001)(65806001)(65956001)(40100003)(87976001)(50986999)(65816999)(76176999)(87266999)(54356999)(106356001)(5008740100001)(5004730100002)(19580395003)(19580405001)(97736004)(92566002)(81156007)(117156001)(86362001)(59896002)(23746002)(83506001)(101416001)(33656002)(80316001)(64126003)(189998001)(2870700001)(36756003)(4001350100001)(50466002)(110136002)(5001960100002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR07MB0909;H:[192.168.1.71];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;VI1PR07MB0909;23:vzu5THo+FAjy6/yk3b5P3phZ962HSsRh63NgK?= =?Windows-1252?Q?T6uwr69i4UDNGVLvlfCU0hT2LRCWMPFogGyF5LvdoI0Nloo39FSDq0na?= =?Windows-1252?Q?Hg81/+7nqS36lrrB4tDTkws9pPx/k+6Qz5Fb7I5HAN/4ZNXmWHpN97Zh?= =?Windows-1252?Q?QUVqqbiinngA9eGLIBEgsRPKsHm8M9SXd3jcZhzKEicn6fM8TxZSBDd3?= =?Windows-1252?Q?JxFiq6z8uSJ7q5Sa/Paztjfj3N6PDk80ICYozM2m3MPmY+y6N0xPhI6b?= =?Windows-1252?Q?q8kbYI4JVYqWYuem7BVdtbqbmIGVCqv1l076nm+TMWMZC4qLEyVF9BMo?= =?Windows-1252?Q?EnAKBmT1kvS0MahvQhOaKx5hy0KxTte7n7AS04Hjc/9OuYqDsVvSZxDV?= =?Windows-1252?Q?F7TcD5POnA4rQ7bfxWQeEgTqxXQ9zI5fOyMxE6Wx4dzl8z1YgIt7IeXF?= =?Windows-1252?Q?K+aMwrjq4zAan8JXoSn9J5YGBjR401yGvSY1E8WocDCdXCxfhB5hyggh?= =?Windows-1252?Q?myCWJpmqNcHiLW9jR6vjIZrpPdApY7JPt9GXLW7WpgED5bWC4mAvbkOq?= =?Windows-1252?Q?Huzyz9r67UkrMxyMxOASSU/HET0PkooqQ3iXW9cKCmzfQGhrAiAYYIxG?= =?Windows-1252?Q?tzCiAlrQwDeZB54xDYVnclYVMh5Duu7XXJBXLmxHc+X7jsihvH9+1jXI?= =?Windows-1252?Q?+LKpEjqv1koTfnHAJNo+wfQLJ+Pm6yJan9eC66h9gBbDlp41Z25JbBBE?= =?Windows-1252?Q?Z5l4RvkIKRT6F0xtjzRNncPIe+Z/qddwz2FEIEEMzZmVkDpnHOdT2UnO?= =?Windows-1252?Q?t6AvqLA/ePZFrsMhGdudF54T9gz2e5EQB0Tb5EOpvxElOGrq7Tmw+83K?= =?Windows-1252?Q?UNKAyjV0uKD21wui6hskt+r1+Z0lkkYk79LWUIpfiLT5yYj3Y3zkVV2J?= =?Windows-1252?Q?jSveHB9KdnMqtDirfSuXZ3L71IlqEIYx/XfFnIK8M+fSSUcvY55r3mhP?= =?Windows-1252?Q?XrwPKjQaWhEAVyCzgFdCsJSu5cJSK5YS8RIzD5vhdAD0qO5eavCYywbL?= =?Windows-1252?Q?mp7miuv4ItChc7Y+AnhMlZppP1SlvpeQMKQOMx55/vPeNlv5pzeM6Czz?= =?Windows-1252?Q?9r+lOyYC9jvMKVPEvm50uiQArKjRd4bvjKDLl04quGnUvVljL36gAKFu?= =?Windows-1252?Q?detr1JQsy/IzT+sxvrCi/Orl1PiOm0MNXBICOsTjZ8E4lBVnpnOXk3HO?= =?Windows-1252?Q?JFuKbGZVtFxdY1/8jdYDT2+1zL3HIlpmcYsX3RK7uZS4J6p8H0546tPh?= =?Windows-1252?Q?IHS3sYHT61rGSzmDuTSuRkyBRunmjIJgLAa45esHdnfL07zJKAykbAGT?= =?Windows-1252?Q?AcaHixMHt0X7hAfM12kong9QgBuXdkg3g=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;VI1PR07MB0909;5:iavGT/+HM+si7JZ/Tb0FQIXufPrVm0kb13wy6ahw1vW7YdZ1IVy0T/XPr+tsWGtG2UxoQZjG9/1I5rcY8505BOH17S10OPB2GWUgSzKnxNjYcP2sjCOTnmGKKt24H+7ZxyyRbytNj4hV0mqxCxDwlg==;24:UGynvmbeStbRcnBe+02KDnfB9XSyL274Hy8tutBkWX6lQNE1m69oJxa2z9UBH9jqtfoLfDBpAC88sxsCXVlEo3dwj+clxif0ggnUtvaFmeg= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nextfour.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2016 16:04:43.6641 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB0909 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Will, On 26.01.2016 17:59, Will Deacon wrote: > Hi Mika, > > On Tue, Jan 26, 2016 at 04:59:52PM +0200, mika.penttila@nextfour.com wrote: >> From: Mika Penttilä >> >> This makes the caller set_memory_xx() consistent with x86. >> >> arm64 part is rebased on 4.5.0-rc1 with Ard's patch >> lkml.kernel.org/g/<1453125665-26627-1-git-send-email-ard.biesheuvel@linaro.org> >> applied. >> >> Signed-off-by: Mika Penttilä mika.penttila@nextfour.com >> Reviewed-by: Laura Abbott >> Acked-by: David Rientjes >> >> --- >> arch/arm/mm/pageattr.c | 3 +++ >> arch/arm64/mm/pageattr.c | 3 +++ >> 2 files changed, 6 insertions(+) >> >> diff --git a/arch/arm/mm/pageattr.c b/arch/arm/mm/pageattr.c >> index cf30daf..d19b1ad 100644 >> --- a/arch/arm/mm/pageattr.c >> +++ b/arch/arm/mm/pageattr.c >> @@ -49,6 +49,9 @@ static int change_memory_common(unsigned long addr, int numpages, >> WARN_ON_ONCE(1); >> } >> >> + if (!numpages) >> + return 0; >> + >> if (start < MODULES_VADDR || start >= MODULES_END) >> return -EINVAL; >> >> diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c >> index 1360a02..b582fc2 100644 >> --- a/arch/arm64/mm/pageattr.c >> +++ b/arch/arm64/mm/pageattr.c >> @@ -53,6 +53,9 @@ static int change_memory_common(unsigned long addr, int numpages, >> WARN_ON_ONCE(1); >> } >> >> + if (!numpages) >> + return 0; >> + > Thanks for this. I can reproduce the failure on my Juno board, so I'd > like to queue this for 4.5 since it fixes a real issue. I've taken the > liberty of rebasing the arm64 part to my fixes branch and writing a > commit message. Does the patch below look ok to you? > > Will > > --->8 > > From 57adec866c0440976c96a4b8f5b59fb411b1cacb Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?Mika=20Penttil=C3=A4?= > Date: Tue, 26 Jan 2016 15:47:25 +0000 > Subject: [PATCH] arm64: mm: avoid calling apply_to_page_range on empty range > MIME-Version: 1.0 > Content-Type: text/plain; charset=UTF-8 > Content-Transfer-Encoding: 8bit > > Calling apply_to_page_range with an empty range results in a BUG_ON > from the core code. This can be triggered by trying to load the st_drv > module with CONFIG_DEBUG_SET_MODULE_RONX enabled: > > kernel BUG at mm/memory.c:1874! > Internal error: Oops - BUG: 0 [#1] PREEMPT SMP > Modules linked in: > CPU: 3 PID: 1764 Comm: insmod Not tainted 4.5.0-rc1+ #2 > Hardware name: ARM Juno development board (r0) (DT) > task: ffffffc9763b8000 ti: ffffffc975af8000 task.ti: ffffffc975af8000 > PC is at apply_to_page_range+0x2cc/0x2d0 > LR is at change_memory_common+0x80/0x108 > > This patch fixes the issue by making change_memory_common (called by the > set_memory_* functions) a NOP when numpages == 0, therefore avoiding the > erroneous call to apply_to_page_range and bringing us into line with x86 > and s390. > > Cc: > Reviewed-by: Laura Abbott > Acked-by: David Rientjes > Signed-off-by: Mika Penttilä > Signed-off-by: Will Deacon > --- > arch/arm64/mm/pageattr.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c > index 3571c7309c5e..cf6240741134 100644 > --- a/arch/arm64/mm/pageattr.c > +++ b/arch/arm64/mm/pageattr.c > @@ -57,6 +57,9 @@ static int change_memory_common(unsigned long addr, int numpages, > if (end < MODULES_VADDR || end >= MODULES_END) > return -EINVAL; > > + if (!numpages) > + return 0; > + > data.set_mask = set_mask; > data.clear_mask = clear_mask; > Yes I'm fine with that, Thanks! Mika