From patchwork Thu Jan 7 12:34:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 358903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDAC1C433DB for ; Thu, 7 Jan 2021 12:35:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FA7B23358 for ; Thu, 7 Jan 2021 12:35:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728119AbhAGMfd (ORCPT ); Thu, 7 Jan 2021 07:35:33 -0500 Received: from mail-40134.protonmail.ch ([185.70.40.134]:39474 "EHLO mail-40134.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727765AbhAGMfc (ORCPT ); Thu, 7 Jan 2021 07:35:32 -0500 Date: Thu, 07 Jan 2021 12:34:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1610022890; bh=Hhk9OJTluJ5KWBmdxz+W1q3+eakKWb3hNy44poTwuNA=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=l5GVk4sCvt8vCoYVw0sPrYtfanVAMJIAYRjscOnpxyU9uMfcf0KfgJs3gJYKc6WR9 Rd5fCvH/l8aC5UaiBJ0Ox3AumM0Cv14/wKLw/JT6vgzKN2EgDkfHrYmFwXDqZfnXGr rH9Y4HZKVbGq4o277yjpACwZZ/u0A8eJ3V0IDI6fNKiaKSa/N8ShJeDriSxpaCnnRs dHMGbCAO09EcojIUbyaHDGhDR8avm1x0QHGYq6fMfQy2wgWfmOSZ3sqTjP9huowfnA 2IcDDcBnck63tmzZ0Z6vqNM8ettTkwhSFm3/PdSxYIjjRaC6jV82q0kRFNmf8KWOqL XpHoYfy/nvyvg== To: Thomas Bogendoerfer From: Alexander Lobakin Cc: Arnd Bergmann , Kees Cook , Nathan Chancellor , Nick Desaulniers , Fangrui Song , Huacai Chen , Pei Huang , Jiaxun Yang , Alexander Lobakin , Sami Tolvanen , Ingo Molnar , Ralf Baechle , Corey Minyard , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, stable@vger.kernel.org, clang-built-linux@googlegroups.com Reply-To: Alexander Lobakin Subject: [PATCH v4 mips-next 1/7] MIPS: vmlinux.lds.S: add missing PAGE_ALIGNED_DATA() section Message-ID: <20210107123428.354231-1-alobakin@pm.me> In-Reply-To: <20210107123331.354075-1-alobakin@pm.me> References: <20210107123331.354075-1-alobakin@pm.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org MIPS uses its own declaration of rwdata, and thus it should be kept in sync with the asm-generic one. Currently PAGE_ALIGNED_DATA() is missing from the linker script, which emits the following ld warnings: mips-alpine-linux-musl-ld: warning: orphan section `.data..page_aligned' from `arch/mips/kernel/vdso.o' being placed in section `.data..page_aligned' mips-alpine-linux-musl-ld: warning: orphan section `.data..page_aligned' from `arch/mips/vdso/vdso-image.o' being placed in section `.data..page_aligned' Add the necessary declaration, so the mentioned structures will be placed in vmlinux as intended: ffffffff80630580 D __end_once ffffffff80630580 D __start___dyndbg ffffffff80630580 D __start_once ffffffff80630580 D __stop___dyndbg ffffffff80634000 d mips_vdso_data ffffffff80638000 d vdso_data ffffffff80638580 D _gp ffffffff8063c000 T __init_begin ffffffff8063c000 D _edata ffffffff8063c000 T _sinittext -> ffffffff805a4000 D __end_init_task ffffffff805a4000 D __nosave_begin ffffffff805a4000 D __nosave_end ffffffff805a4000 d mips_vdso_data ffffffff805a8000 d vdso_data ffffffff805ac000 D mmlist_lock ffffffff805ac080 D tasklist_lock Fixes: ebb5e78cc634 ("MIPS: Initial implementation of a VDSO") Cc: stable@vger.kernel.org # 4.4+ Signed-off-by: Alexander Lobakin Reviewed-by: Kees Cook Reviewed-by: Nathan Chancellor Reviewed-by: Nathan Chancellor --- arch/mips/kernel/vmlinux.lds.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index 5e97e9d02f98..83e27a181206 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -90,6 +90,7 @@ SECTIONS INIT_TASK_DATA(THREAD_SIZE) NOSAVE_DATA + PAGE_ALIGNED_DATA(PAGE_SIZE) CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) READ_MOSTLY_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) DATA_DATA From patchwork Thu Jan 7 12:34:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 359726 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25439C433E0 for ; Thu, 7 Jan 2021 12:35:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E355723356 for ; Thu, 7 Jan 2021 12:35:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728208AbhAGMfk (ORCPT ); Thu, 7 Jan 2021 07:35:40 -0500 Received: from mail-40136.protonmail.ch ([185.70.40.136]:23509 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727871AbhAGMfk (ORCPT ); Thu, 7 Jan 2021 07:35:40 -0500 Date: Thu, 07 Jan 2021 12:34:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1610022898; bh=012vDHOxvqVPo52Yrh8ZCe0PscXXJoRaQmC+Qol94bs=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=SvZOZeHRjbzSSnW4dvfM9BrtRGjLLTvIhxnVV3QgsCdA69aUJroaV24Xk9SFhlx+u sHD65gs8WP+lrkH3PIpa/Epk4dVLI8R4mARZ+do02zCYBZU0l36zTPiCSCG7IxDvJl vfv/aRCcswEfBYznLPw+IM4hpYm15nOy4rJQYP3BUAiw7L/JXI44SysEpxSxHp3Ahn o9sVf29pNp0w/t/SsQ9D2o/j5lx5/WLvT8sjVIczhfyXYjdWhdevSc0Y02Kp8Ecb2H 3GysfZh18+0wEbte2CXW9SSiFBSXXe2hFWip2eAR86tHqBY1ABt95QqvfCuSuoVA/P 9FnpbO50thbVw== To: Thomas Bogendoerfer From: Alexander Lobakin Cc: Arnd Bergmann , Kees Cook , Nathan Chancellor , Nick Desaulniers , Fangrui Song , Huacai Chen , Pei Huang , Jiaxun Yang , Alexander Lobakin , Sami Tolvanen , Ingo Molnar , Ralf Baechle , Corey Minyard , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, stable@vger.kernel.org, clang-built-linux@googlegroups.com Reply-To: Alexander Lobakin Subject: [PATCH v4 mips-next 2/7] MIPS: vmlinux.lds.S: add ".gnu.attributes" to DISCARDS Message-ID: <20210107123428.354231-2-alobakin@pm.me> In-Reply-To: <20210107123428.354231-1-alobakin@pm.me> References: <20210107123331.354075-1-alobakin@pm.me> <20210107123428.354231-1-alobakin@pm.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Discard GNU attributes (MIPS FP type, GNU Hash etc.) at link time as kernel doesn't use it at all. Solves a dozen of the following ld warnings (one per every file): mips-alpine-linux-musl-ld: warning: orphan section `.gnu.attributes' from `arch/mips/kernel/head.o' being placed in section `.gnu.attributes' mips-alpine-linux-musl-ld: warning: orphan section `.gnu.attributes' from `init/main.o' being placed in section `.gnu.attributes' Signed-off-by: Alexander Lobakin --- arch/mips/kernel/vmlinux.lds.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index 83e27a181206..16468957cba2 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -221,6 +221,7 @@ SECTIONS /* ABI crap starts here */ *(.MIPS.abiflags) *(.MIPS.options) + *(.gnu.attributes) *(.options) *(.pdr) *(.reginfo) From patchwork Thu Jan 7 12:35:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 358902 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2189C433E9 for ; Thu, 7 Jan 2021 12:36:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80DD323356 for ; Thu, 7 Jan 2021 12:36:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728202AbhAGMfz (ORCPT ); Thu, 7 Jan 2021 07:35:55 -0500 Received: from mail1.protonmail.ch ([185.70.40.18]:17678 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728247AbhAGMfx (ORCPT ); Thu, 7 Jan 2021 07:35:53 -0500 Date: Thu, 07 Jan 2021 12:35:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1610022909; bh=eO/PHJsxC/BU0o916BcRj7k2ZJn51umK9YSTysF7W78=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=kciYVe03J5dOgcjBjgbL9dsEjwXLN50MloldQqPfktixp4SpXMEiQi130FWwV/OYi mVpGtod8b2IFKlLCKi0UDe2HLSeSpbGEMb6vBxfC0FqULBmXCnBkkqzEGTep3bu73g bH3yZxK7+dIHrRCss90VaaUcDhykUqDvALa7Q9ey0pA5CwVLvHxAqI53vk4yH9DHAv pLhqJbygw/gnK17FBYRjZGWrEWXvlm0bgYRESsNT+BprTpTwq539KdUJQFsfxWJy5b Awc9dOon0SdbDRlySpNKa2JRvhVizUsyHqatGx5XcYXGm5dX8m196NisGw9xsly99O dOyb420EDYYwg== To: Thomas Bogendoerfer From: Alexander Lobakin Cc: Arnd Bergmann , Kees Cook , Nathan Chancellor , Nick Desaulniers , Fangrui Song , Huacai Chen , Pei Huang , Jiaxun Yang , Alexander Lobakin , Sami Tolvanen , Ingo Molnar , Ralf Baechle , Corey Minyard , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, stable@vger.kernel.org, clang-built-linux@googlegroups.com Reply-To: Alexander Lobakin Subject: [PATCH v4 mips-next 3/7] MIPS: properly stop .eh_frame generation Message-ID: <20210107123428.354231-3-alobakin@pm.me> In-Reply-To: <20210107123428.354231-1-alobakin@pm.me> References: <20210107123331.354075-1-alobakin@pm.me> <20210107123428.354231-1-alobakin@pm.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Commit 866b6a89c6d1 ("MIPS: Add DWARF unwinding to assembly") added -fno-asynchronous-unwind-tables to KBUILD_CFLAGS to prevent compiler from emitting .eh_frame symbols. However, as MIPS heavily uses CFI, that's not enough. Use the approach taken for x86 (as it also uses CFI) and explicitly put CFI symbols into the .debug_frame section (except for VDSO). This allows us to drop .eh_frame from DISCARDS as it's no longer being generated. Fixes: 866b6a89c6d1 ("MIPS: Add DWARF unwinding to assembly") Suggested-by: Kees Cook Signed-off-by: Alexander Lobakin Reviewed-by: Kees Cook Reviewed-by: Nathan Chancellor --- arch/mips/include/asm/asm.h | 18 ++++++++++++++++++ arch/mips/kernel/vmlinux.lds.S | 1 - 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/mips/include/asm/asm.h b/arch/mips/include/asm/asm.h index 3682d1a0bb80..908f6d6ae24b 100644 --- a/arch/mips/include/asm/asm.h +++ b/arch/mips/include/asm/asm.h @@ -20,10 +20,27 @@ #include #include +#ifndef __VDSO__ +/* + * Emit CFI data in .debug_frame sections, not .eh_frame sections. + * We don't do DWARF unwinding at runtime, so only the offline DWARF + * information is useful to anyone. Note we should change this if we + * ever decide to enable DWARF unwinding at runtime. + */ +#define CFI_SECTIONS .cfi_sections .debug_frame +#else + /* + * For the vDSO, emit both runtime unwind information and debug + * symbols for the .dbg file. + */ +#define CFI_SECTIONS +#endif + /* * LEAF - declare leaf routine */ #define LEAF(symbol) \ + CFI_SECTIONS; \ .globl symbol; \ .align 2; \ .type symbol, @function; \ @@ -36,6 +53,7 @@ symbol: .frame sp, 0, ra; \ * NESTED - declare nested routine entry point */ #define NESTED(symbol, framesize, rpc) \ + CFI_SECTIONS; \ .globl symbol; \ .align 2; \ .type symbol, @function; \ diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index 16468957cba2..0f4e46ea4458 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -225,6 +225,5 @@ SECTIONS *(.options) *(.pdr) *(.reginfo) - *(.eh_frame) } } From patchwork Thu Jan 7 13:20:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 358901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23315C433E6 for ; Thu, 7 Jan 2021 13:21:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E05422312F for ; Thu, 7 Jan 2021 13:21:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727562AbhAGNVU (ORCPT ); Thu, 7 Jan 2021 08:21:20 -0500 Received: from mail-40131.protonmail.ch ([185.70.40.131]:23470 "EHLO mail-40131.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728427AbhAGNVU (ORCPT ); Thu, 7 Jan 2021 08:21:20 -0500 Date: Thu, 07 Jan 2021 13:20:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1610025637; bh=1iHiRQzHqAO/hOdIJm7931oVSjvi8g99iSxotTA/NNE=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=Awz+ntc9XFxB3byalr3Ar0uBftjJ34q+4h01Xb55pnPE3Cb64NIpk3HqGpInQ7lEm f6b/iJ6qEzjkGHR/WVYiIP8MGtzwz2845rJwK73wU8Ca2Z+RDR1feEDja745CtaX13 YL8g99zm6cGpd9uCDzGTF1tR8xxXYSFAi4zGQ5URQZpECQtUr6pbWAQS6qbfg7eoDx eDJ4NEonCsAwafi18yssbLCIDOb6C6nDO/8r9kWQtP/cMPh0/BWIQJWzoocZknZmb8 zV0Qqo5jWC/DQqDm1Mx42/kayzt2kVW1LGADT3FpV0r+XKZngqbmWdTPz7np+oFPXR l9sncFXbotHKg== To: Thomas Bogendoerfer From: Alexander Lobakin Cc: Arnd Bergmann , Kees Cook , Nathan Chancellor , Nick Desaulniers , Fangrui Song , Huacai Chen , Pei Huang , Jiaxun Yang , Alexander Lobakin , Sami Tolvanen , Ingo Molnar , Ralf Baechle , Corey Minyard , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, stable@vger.kernel.org, clang-built-linux@googlegroups.com Reply-To: Alexander Lobakin Subject: [PATCH v4 mips-next 4/7] MIPS: vmlinux.lds.S: catch bad .rel.dyn at link time Message-ID: <20210107132010.463129-1-alobakin@pm.me> In-Reply-To: <20210107123331.354075-1-alobakin@pm.me> References: <20210107123331.354075-1-alobakin@pm.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Catch any symbols placed in .rel.dyn and check for these sections to be zero-sized at link time. Eliminates following ld warning: mips-alpine-linux-musl-ld: warning: orphan section `.rel.dyn' from `init/main.o' being placed in section `.rel.dyn' Adopted from x86/kernel/vmlinux.lds.S. Suggested-by: Fangrui Song Signed-off-by: Alexander Lobakin Reviewed-by: Kees Cook Reviewed-by: Nathan Chancellor Reviewed-by: Nathan Chancellor Reviewed-by: Nathan Chancellor --- arch/mips/kernel/vmlinux.lds.S | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index 0f4e46ea4458..0f736d60d43e 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -226,4 +226,15 @@ SECTIONS *(.pdr) *(.reginfo) } + + /* + * Sections that should stay zero sized, which is safer to + * explicitly check instead of blindly discarding. + */ + + .rel.dyn : { + *(.rel.*) + *(.rel_*) + } + ASSERT(SIZEOF(.rel.dyn) == 0, "Unexpected run-time relocations (.rel) detected!") } From patchwork Thu Jan 7 13:20:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 359725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACB35C433E9 for ; Thu, 7 Jan 2021 13:21:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7305822475 for ; Thu, 7 Jan 2021 13:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728325AbhAGNVe (ORCPT ); Thu, 7 Jan 2021 08:21:34 -0500 Received: from mail-40134.protonmail.ch ([185.70.40.134]:64020 "EHLO mail-40134.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728390AbhAGNVd (ORCPT ); Thu, 7 Jan 2021 08:21:33 -0500 Date: Thu, 07 Jan 2021 13:20:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1610025651; bh=9oCj7QKLJWJNGcOnNqI17iIRyczWE6M4kFx9CTLO44o=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=lrLPAOvww0VvEA4BtSTnnUTYtcgzLetcZIBJZI7GJT8o5QacEQyCtZ4AUc6x8k323 jMAKgxOIP62fj4sou0ajm07YYRlfNW0D36sPcxS8N4l1i7zGK+xA6tw6GEFLKtE7l9 zIHmFSEar2TLaHvwmFRtMohUoQFC/j/68PHBVMswYWSIYJ57JpBFWtvGroeUBqL7Qz 9cgckGv6AZjZhxZtQDK7zA0609rtDrXdPmaEq9N8Z6p3pqxbksf3Gycm61TBb4aXPZ guCuLJi8d9Bwh4bS4ApL0AQHSlG8QNR6l8FhH/rJhXAo40NCnfGEkHEUg89uyhEu8c jyYk0VWsux/5g== To: Thomas Bogendoerfer From: Alexander Lobakin Cc: Arnd Bergmann , Kees Cook , Nathan Chancellor , Nick Desaulniers , Fangrui Song , Huacai Chen , Pei Huang , Jiaxun Yang , Alexander Lobakin , Sami Tolvanen , Ingo Molnar , Ralf Baechle , Corey Minyard , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, stable@vger.kernel.org, clang-built-linux@googlegroups.com Reply-To: Alexander Lobakin Subject: [PATCH v4 mips-next 5/7] MIPS: vmlinux.lds.S: explicitly declare .got table Message-ID: <20210107132010.463129-2-alobakin@pm.me> In-Reply-To: <20210107132010.463129-1-alobakin@pm.me> References: <20210107123331.354075-1-alobakin@pm.me> <20210107132010.463129-1-alobakin@pm.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org LLVM stack generates GOT table when building the kernel: ld.lld: warning: :(.got) is being placed in '.got' According to the debug assertions, it's not zero-sized and thus can't be handled the same way as .rel.dyn (like it's done for x86). Use the ARM/ARM64 path here and place it at the end of .text section. Reported-by: Nathan Chancellor Signed-off-by: Alexander Lobakin Reviewed-by: Nathan Chancellor --- arch/mips/kernel/vmlinux.lds.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index 0f736d60d43e..4709959f6985 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -69,6 +69,7 @@ SECTIONS *(.text.*) *(.fixup) *(.gnu.warning) + *(.got) } :text = 0 _etext = .; /* End of text section */ From patchwork Thu Jan 7 13:20:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 358900 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E72D5C4332E for ; Thu, 7 Jan 2021 13:21:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C22C922475 for ; Thu, 7 Jan 2021 13:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728167AbhAGNVr (ORCPT ); Thu, 7 Jan 2021 08:21:47 -0500 Received: from mail2.protonmail.ch ([185.70.40.22]:16120 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727327AbhAGNVr (ORCPT ); Thu, 7 Jan 2021 08:21:47 -0500 Date: Thu, 07 Jan 2021 13:20:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1610025664; bh=tAhGyp2geX19Adc0pmsweHYMg6GqMIq+Zk7djwr/y7M=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=fMAChsxhN37qCfBmEwpgDN7pHIELWE4oEMllD4cxn+PyA8L+hPw26OwD3+JVccWui 06aq+eRq8a4InUotyP1RyI0X20Y6x90l5cn3bCTogmA5RDs9ZRyJdfaPxfk1LoPDkG 4YlRElx0ohdWxN2Aw8xwxLRmlS2gLO2df0Mb+VfVYurfgdocVZpjzFRjCfH3jP/EUr X3x1gBCSI/k767qtRhMWqgWuhl/it4x0GswYdykTHF457MqkBtrr0wVXAUCUn8x1oe WX9CaY4VsDc6h3fnJ6Mglf5ZWRqX9GktvLw3A1N27oJdSfauGXUtacdsSp3qDgbI0t ZwudvWYogKkCw== To: Thomas Bogendoerfer From: Alexander Lobakin Cc: Arnd Bergmann , Kees Cook , Nathan Chancellor , Nick Desaulniers , Fangrui Song , Huacai Chen , Pei Huang , Jiaxun Yang , Alexander Lobakin , Sami Tolvanen , Ingo Molnar , Ralf Baechle , Corey Minyard , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, stable@vger.kernel.org, clang-built-linux@googlegroups.com Reply-To: Alexander Lobakin Subject: [PATCH v4 mips-next 6/7] vmlinux.lds.h: catch compound literals into data and BSS Message-ID: <20210107132010.463129-3-alobakin@pm.me> In-Reply-To: <20210107132010.463129-1-alobakin@pm.me> References: <20210107123331.354075-1-alobakin@pm.me> <20210107132010.463129-1-alobakin@pm.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org When building kernel with LD_DEAD_CODE_DATA_ELIMINATION, LLVM stack generates separate sections for compound literals, just like in case with enabled LTO [0]: ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o): (.data..compoundliteral.14) is being placed in '.data..compoundliteral.14' ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o): (.data..compoundliteral.15) is being placed in '.data..compoundliteral.15' ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o): (.data..compoundliteral.16) is being placed in '.data..compoundliteral.16' ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o): (.data..compoundliteral.17) is being placed in '.data..compoundliteral.17' [...] Handle this by adding the related sections to generic definitions as suggested by Sami [0]. [0] https://lore.kernel.org/lkml/20201211184633.3213045-3-samitolvanen@google.com Suggested-by: Kees Cook Signed-off-by: Alexander Lobakin Reviewed-by: Nathan Chancellor --- include/asm-generic/vmlinux.lds.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index b2b3d81b1535..5f2f5b1db84f 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -95,10 +95,10 @@ */ #ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION #define TEXT_MAIN .text .text.[0-9a-zA-Z_]* -#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..LPBX* +#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]* -#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* -#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* +#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L* +#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral* #define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]* #else #define TEXT_MAIN .text From patchwork Thu Jan 7 13:21:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 359724 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31F20C43333 for ; Thu, 7 Jan 2021 13:22:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 107F12065E for ; Thu, 7 Jan 2021 13:22:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728510AbhAGNVx (ORCPT ); Thu, 7 Jan 2021 08:21:53 -0500 Received: from mail-40134.protonmail.ch ([185.70.40.134]:34988 "EHLO mail-40134.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728505AbhAGNVw (ORCPT ); Thu, 7 Jan 2021 08:21:52 -0500 Date: Thu, 07 Jan 2021 13:21:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1610025670; bh=1c0zIRSp5j+9jPf96D96lWaXSqjKgRxuaqZWXnp1GJA=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=j9+A6Rzo1K+21lSv9jbkpyTi94X4L1AEwY8GcldoLZ22ZOUGSJ2Z47oH8suBecI7Q WiRlK625R9bjiAh+jufBUDUGMSs/+RDV5y4Z6dvm9fEWFltioUP7EwDFJb+s9kN4Cx XM7hZQ/se4n+AoYwpLsiG7RfO9+npoochn7IoUxYMEA67UpupTAQQv+YdFOBjPUQFy J2dBlB1x62phBmSEqHe2bRSGtOAf2fvUCxi8b3A6w81TRJtNYKkMQmxZdj65DOdbWB 6Xr4F4YSvphfRHebhxl8jGB6JoJhsj3a3AhsD0l6YhAEk0Lf9Lf9aehhOvwabr1DLz 6lbOrPfdehkLA== To: Thomas Bogendoerfer From: Alexander Lobakin Cc: Arnd Bergmann , Kees Cook , Nathan Chancellor , Nick Desaulniers , Fangrui Song , Huacai Chen , Pei Huang , Jiaxun Yang , Alexander Lobakin , Sami Tolvanen , Ingo Molnar , Ralf Baechle , Corey Minyard , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, stable@vger.kernel.org, clang-built-linux@googlegroups.com Reply-To: Alexander Lobakin Subject: [PATCH v4 mips-next 7/7] MIPS: select ARCH_WANT_LD_ORPHAN_WARN Message-ID: <20210107132010.463129-4-alobakin@pm.me> In-Reply-To: <20210107132010.463129-1-alobakin@pm.me> References: <20210107123331.354075-1-alobakin@pm.me> <20210107132010.463129-1-alobakin@pm.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Now, after that all the sections are explicitly described and declared in vmlinux.lds.S, we can enable ld orphan warnings to prevent from missing any new sections in future. Signed-off-by: Alexander Lobakin Reviewed-by: Kees Cook Reviewed-by: Nathan Chancellor --- arch/mips/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index d68df1febd25..d3e64cc0932b 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -18,6 +18,7 @@ config MIPS select ARCH_USE_QUEUED_SPINLOCKS select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU select ARCH_WANT_IPC_PARSE_VERSION + select ARCH_WANT_LD_ORPHAN_WARN select BUILDTIME_TABLE_SORT select CLONE_BACKWARDS select CPU_NO_EFFICIENT_FFS if (TARGET_ISA_REV < 1)