From mboxrd@z Thu Jan 1 00:00:00 1970 Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 20 Oct 2016 22:29:36 +0200 (CEST) Received: from mailapp01.imgtec.com ([195.59.15.196]:32790 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S23993043AbcJTU2hMp2vK (ORCPT ); Thu, 20 Oct 2016 22:28:37 +0200 Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Forcepoint Email with ESMTPS id 9E1E5FE173FA0; Thu, 20 Oct 2016 21:28:26 +0100 (IST) Received: from localhost (10.100.200.119) by HHMAIL01.hh.imgtec.org (10.100.10.21) with Microsoft SMTP Server (TLS) id 14.3.294.0; Thu, 20 Oct 2016 21:28:30 +0100 From: Paul Burton To: CC: Ralf Baechle , Nicholas Piggin , Paul Burton Subject: [PATCH 5/6] MIPS: Ensure bss section ends on a long-aligned address Date: Thu, 20 Oct 2016 21:27:04 +0100 Message-ID: <20161020202705.3783-6-paul.burton@imgtec.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161020202705.3783-1-paul.burton@imgtec.com> References: <20161020202705.3783-1-paul.burton@imgtec.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.100.200.119] Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 55534 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: paul.burton@imgtec.com Precedence: bulk List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: linux-mips X-List-ID: linux-mips List-subscribe: List-owner: List-post: List-archive: X-list: linux-mips When clearing the .bss section in kernel_entry we do so using LONG_S instructions, and branch whilst the current write address doesn't equal the end of the .bss section minus the size of a long integer. The .bss section always begins at a long-aligned address and we always increment the write pointer by the size of a long integer - we therefore rely upon the .bss section ending at a long-aligned address. If this is not the case then the long-aligned write address can never be equal to the non-long-aligned end address & we will continue to increment past the end of the .bss section, attempting to zero the rest of memory. Despite this requirement that .bss end at a long-aligned address we pass 0 as the end alignment requirement to the BSS_SECTION macro and thus don't guarantee any particular alignment, allowing us to hit the error condition described above. Fix this by instead passing LONGSIZE as the end alignment argument to the BSS_SECTION macro. Signed-off-by: Paul Burton Cc: linux-mips@linux-mips.org Cc: Ralf Baechle Cc: Nicholas Piggin --- arch/mips/kernel/vmlinux.lds.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index d5de675..d1f5401 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -1,3 +1,4 @@ +#include #include #include @@ -182,7 +183,7 @@ SECTIONS * Force .bss to 64K alignment so that .bss..swapper_pg_dir * gets that alignment. .sbss should be empty, so there will be * no holes after __init_end. */ - BSS_SECTION(0, 0x10000, 0) + BSS_SECTION(0, 0x10000, LONGSIZE) _end = . ; -- 2.10.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailapp01.imgtec.com ([195.59.15.196]:32790 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S23993043AbcJTU2hMp2vK (ORCPT ); Thu, 20 Oct 2016 22:28:37 +0200 From: Paul Burton Subject: [PATCH 5/6] MIPS: Ensure bss section ends on a long-aligned address Date: Thu, 20 Oct 2016 21:27:04 +0100 Message-ID: <20161020202705.3783-6-paul.burton@imgtec.com> In-Reply-To: <20161020202705.3783-1-paul.burton@imgtec.com> References: <20161020202705.3783-1-paul.burton@imgtec.com> MIME-Version: 1.0 Content-Type: text/plain Return-Path: Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-subscribe: List-owner: List-post: List-archive: To: linux-mips@linux-mips.org Cc: Ralf Baechle , Nicholas Piggin , Paul Burton Message-ID: <20161020202704.f2GGX_o-2i7LUXUAwQ9wcH4crC7_idmWimsaArLBxHs@z> When clearing the .bss section in kernel_entry we do so using LONG_S instructions, and branch whilst the current write address doesn't equal the end of the .bss section minus the size of a long integer. The .bss section always begins at a long-aligned address and we always increment the write pointer by the size of a long integer - we therefore rely upon the .bss section ending at a long-aligned address. If this is not the case then the long-aligned write address can never be equal to the non-long-aligned end address & we will continue to increment past the end of the .bss section, attempting to zero the rest of memory. Despite this requirement that .bss end at a long-aligned address we pass 0 as the end alignment requirement to the BSS_SECTION macro and thus don't guarantee any particular alignment, allowing us to hit the error condition described above. Fix this by instead passing LONGSIZE as the end alignment argument to the BSS_SECTION macro. Signed-off-by: Paul Burton Cc: linux-mips@linux-mips.org Cc: Ralf Baechle Cc: Nicholas Piggin --- arch/mips/kernel/vmlinux.lds.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index d5de675..d1f5401 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -1,3 +1,4 @@ +#include #include #include @@ -182,7 +183,7 @@ SECTIONS * Force .bss to 64K alignment so that .bss..swapper_pg_dir * gets that alignment. .sbss should be empty, so there will be * no holes after __init_end. */ - BSS_SECTION(0, 0x10000, 0) + BSS_SECTION(0, 0x10000, LONGSIZE) _end = . ; -- 2.10.0