From patchwork Tue Nov 3 17:52:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Brandt X-Patchwork-Id: 7545851 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9364DBEEA4 for ; Tue, 3 Nov 2015 17:54:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BA87E2063B for ; Tue, 3 Nov 2015 17:54:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 95C0920499 for ; Tue, 3 Nov 2015 17:54:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ztflr-0000ew-CS; Tue, 03 Nov 2015 17:53:23 +0000 Received: from relmlor2.renesas.com ([210.160.252.172] helo=relmlie1.idc.renesas.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ztfln-0000bt-GT for linux-arm-kernel@lists.infradead.org; Tue, 03 Nov 2015 17:53:20 +0000 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie1.idc.renesas.com with ESMTP; 04 Nov 2015 02:52:56 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 0BB00413E5; Wed, 4 Nov 2015 02:52:57 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id DA92C480A3; Wed, 4 Nov 2015 02:52:56 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id D447A48014; Wed, 4 Nov 2015 02:52:56 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac4.idc.renesas.com with ESMTP id CAD23392; Wed, 4 Nov 2015 02:52:56 +0900 X-IronPort-AV: E=Sophos;i="5.20,239,1444662000"; d="scan'208";a="197761998" Received: from mail-pu1apc01lp0017.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.17]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 04 Nov 2015 02:52:55 +0900 Received: from HK2PR06MB0561.apcprd06.prod.outlook.com (10.161.183.154) by HK2PR06MB0563.apcprd06.prod.outlook.com (10.161.183.156) with Microsoft SMTP Server (TLS) id 15.1.312.18; Tue, 3 Nov 2015 17:52:54 +0000 Received: from HK2PR06MB0561.apcprd06.prod.outlook.com ([10.161.183.154]) by HK2PR06MB0561.apcprd06.prod.outlook.com ([10.161.183.154]) with mapi id 15.01.0312.014; Tue, 3 Nov 2015 17:52:54 +0000 From: Chris Brandt To: =?iso-8859-1?Q?Uwe_Kleine-K=F6nig?= , Ezequiel Garcia Subject: RE: v7-M: Fixing XIP when the kernel is in ROM Thread-Topic: v7-M: Fixing XIP when the kernel is in ROM Thread-Index: AQHRD44+Yi7vy4D/qUmP0p+fjwXyB559axWAgABV24CAAboOgIAAB/KAgABJG4CAAAJ2gIAAEH6AgAAD2ACAAAGEAIAABKEAgACgdQCAChClwA== Date: Tue, 3 Nov 2015 17:52:53 +0000 Message-ID: References: <20151026080537.GW4931@pengutronix.de> <562FA053.6010208@st.com> <85aea33b93066d0959d98b56f8787ba3@agner.ch> <20151028074304.GN4931@pengutronix.de> In-Reply-To: <20151028074304.GN4931@pengutronix.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Chris.Brandt@renesas.com; x-originating-ip: [4.59.13.106] x-microsoft-exchange-diagnostics: 1; HK2PR06MB0563; 5:QJJGf+Xn5Lx8JAGvXZVz7Ld8XBcPrWNV1bahJwfS4ccS7MlRDoBWx9R7ePQeOMn86AcqhpR3gsJUxDUSjt0IHL9yJdJW0dyCutq/YvBILA+zkRVYb+09HVLvvrL+BnzfajLQ3gx1G4LNPbfPdANC9g==; 24:jORWnHLHYFUUWVktBM5Yy5KEjFDtKePIEW4ITxbUrucFnQ1CK1M1sYJlWOHuwXizNgQrkr8A5+ojzILYgA4VjKXtI9GyzObh0AJ4SagEq3Q=; 20:EftNxYztFfDziUXcEqllpA0YhIGAT4GBZWL8PIFhFdGMCE5l9oIAmZ4gyUMl3qNIlSjhToqbQqW+Qm18iqR6MmMDBXHgb3/fQR78rY5+m+hfbOYD4gtl1leJwTwTJDC2B7iWp2EbwjOLLcqqV7L6M1Yl2MTUnoRZ0RKLJ487e9Q= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HK2PR06MB0563; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(3002001)(10201501046); SRVR:HK2PR06MB0563; BCL:0; PCL:0; RULEID:; SRVR:HK2PR06MB0563; x-forefront-prvs: 0749DC2CE6 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(189002)(199003)(5008740100001)(50986999)(77096005)(106356001)(66066001)(5004730100002)(11100500001)(74316001)(102836002)(106116001)(5001770100001)(5002640100001)(105586002)(97736004)(93886004)(40100003)(189998001)(81156007)(122556002)(92566002)(5007970100001)(5001960100002)(76576001)(76176999)(10400500002)(86362001)(33656002)(5003600100002)(54356999)(2950100001)(101416001)(2900100001)(87936001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR06MB0563; H:HK2PR06MB0561.apcprd06.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Nov 2015 17:52:53.9329 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR06MB0563 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151103_095319_927236_2D36F75C X-CRM114-Status: UNSURE ( 8.89 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Russell King , Catalin Marinas , Joachim Eastwood , Magnus Damm , Stefan Agner , Maxime Coquelin , linux-arm-kernel Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP > So the right fix is to move __v7m_setup_stack to .data I guess. Since my set of patches went nowhere, last week we had a look at doing just that (using a pre-allocated stack in .data instead of hard coding to the top of PLAT_PHYS_OFFSET). Here's the code we came up with. Seems to work on XIP and non-XIP builds as well as SMP and non-SMP. Maybe you can try this technique to allocate the temporary stack in the data section. (and if your patch gets in...then maybe I'll try submitting again...) -Chris arch/arm/mm/proc-v7.S | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) --- 0001/arch/arm/mm/proc-v7.S +++ work/arch/arm/mm/proc-v7.S 2015-10-28 15:44:48.980513000 +0900 @@ -274,7 +274,15 @@ __v7_ca15mp_setup: __v7_b15mp_setup: __v7_ca17mp_setup: mov r10, #0 -1: adr r12, __v7_setup_stack @ the local stack +1: adr r11, __v7_setup_stack_ptr @ pointer to local stack + ldmia r11, {r0, r12} +#ifdef CONFIG_XIP_KERNEL + ldr r11, =PLAT_PHYS_OFFSET @ fixed address +#else + sub r11, r11, r0 @ position independent offset +#endif + add r12, r12, r11 @ phys address + sub r12, #PAGE_OFFSET stmia r12, {r0-r5, lr} @ v7_invalidate_l1 touches r0-r6 bl v7_invalidate_l1 ldmia r12, {r0-r5, lr} @@ -415,7 +423,15 @@ __v7_pj4b_setup: #endif /* CONFIG_CPU_PJ4B */ __v7_setup: - adr r12, __v7_setup_stack @ the local stack + adr r11, __v7_setup_stack_ptr @ pointer to local stack + ldmia r11, {r0, r12} +#ifdef CONFIG_XIP_KERNEL + ldr r11, =PLAT_PHYS_OFFSET @ fixed address +#else + sub r11, r11, r0 @ position independent offset +#endif + add r12, r12, r11 @ phys address + sub r12, #PAGE_OFFSET stmia r12, {r0-r5, lr} @ v7_invalidate_l1 touches r0-r6 bl v7_invalidate_l1 ldmia r12, {r0-r5, lr} @@ -482,6 +498,11 @@ __errata_finish: ret lr @ return to head.S:__ret ENDPROC(__v7_setup) +__v7_setup_stack_ptr: + .long . + .long __v7_setup_stack + + .data .align 2 __v7_setup_stack: .space 4 * 7 @ 12 registers