From patchwork Wed Jan 18 22:37:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 716870 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v3hhb4cB4z9sf9 for ; Thu, 19 Jan 2017 09:38:39 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="USVoXnWl"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3v3hhb3YB2zDqLm for ; Thu, 19 Jan 2017 09:38:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="USVoXnWl"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-it0-x230.google.com (mail-it0-x230.google.com [IPv6:2607:f8b0:4001:c0b::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3v3hg03jbFzDqGb for ; Thu, 19 Jan 2017 09:37:16 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="USVoXnWl"; dkim-atps=neutral Received: by mail-it0-x230.google.com with SMTP id r185so21756424ita.0 for ; Wed, 18 Jan 2017 14:37:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=pK3cU34jnfd7LlnzmnHK1P1OOPnaRo6pf7bFTHJcaVo=; b=USVoXnWlvu6OvAYJOmJ6Nc+Lh5uCbWAT2cHoiOIxAiqkpeSQlmyLda0Isg6uMLrISY VD+CTPSQWonAXF6C4cV2+V31/WA+4lPnUhueJVbZN+HHIbqXMnCApRfuBy9ehelXdHl3 dYwlrTSUzGEUhpjknRgCIaYoBAaE2CNl28fxY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=pK3cU34jnfd7LlnzmnHK1P1OOPnaRo6pf7bFTHJcaVo=; b=lsNTu4Vb/V+erz1p0GL2UqNrTd6sdukuQEnsnB84JxJls4vu9uKeW01uFtNfR2H7No 5Vf09RvuSKj6hkpIR1hIh7qaTm0FEKLc3yJCA0XXeVcOUGTbwTHfodKN41IRJiPrthNc 5Y4lAde+cghEPOFO/HRHgveyhLN8CFYfeLPlp/D28Hd6lV/sV6Gno81Q2Cit2WiAQdvj +h3/fSEOgmulrnmgV/uKZVA/Twk+qKGq+3PVRj0jp4rC0/cs9Rex77FWBdI5mAQ8TFma 9I4ZySlz117ws+W9DbmZyvFJU/5ExjpNtQ6yzYjCLNZd9HPi38Wz8A4BNozanvqnKBbs iNtw== X-Gm-Message-State: AIkVDXLfOLn4iQb/xVE898CWmUeuhpsCZn1ZRU9q/PpnvsRRqrhnOXSJU4Bt+KFYyrK0HsYzSvoZgRHv4Lz1oJ9A X-Received: by 10.36.107.194 with SMTP id v185mr26529396itc.59.1484779034075; Wed, 18 Jan 2017 14:37:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.144.135 with HTTP; Wed, 18 Jan 2017 14:37:13 -0800 (PST) In-Reply-To: References: <1484681173-11644-1-git-send-email-ard.biesheuvel@linaro.org> <1484681173-11644-4-git-send-email-ard.biesheuvel@linaro.org> From: Ard Biesheuvel Date: Wed, 18 Jan 2017 22:37:13 +0000 Message-ID: Subject: Re: [PATCH v4 3/3] modversions: treat symbol CRCs as 32 bit quantities on 64 bit archs To: Linus Torvalds X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jessica Yu , Arnd Bergmann , "Suzuki K. Poulose" , Rusty Russell , Will Deacon , Linux Kernel Mailing List , Paul Mackerras , Al Viro , Andrew Morton , ppc-dev Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 18 January 2017 at 18:35, Linus Torvalds wrote: > On Wed, Jan 18, 2017 at 10:27 AM, Linus Torvalds > wrote: >> >> I wonder what happened to gold, and why it didn't take over. I'm >> assuming it had _other_ bugs.. Oh well. > > Google for gold problems, I note that it has been reported to get > "internal error"s during kernel builds - and at least some of them > have been due to ksyms. > > So the core problem seems to mainly be that gcc normally itself never > generates any absolute symbols, so the whole ksyms model depends on > things that get almost zero testing in the toolchain. > > Oh well. > There is one alternative that gets rid of all the hackiness, but it does increase the CRC footprint on 32-bit platforms: (and an equivalent change in include/linux/export.h) So the kcrctab contains the relative (signed) offset to where the CRC is stored, which gets rid of any absolute relocations. To grab the CRC, we only have to add the value of the kcrctab entry to its address, and dereference the resulting pointer. This would remove the need for patches 1 and 2, and get rid of the overhead of the runtime relocation entries not only for arm64 but for powerpc as well. It would also get rid of the abuse of ELF symbols once and for all, hopefully avoiding bugs in GNU ld and gold in the future. For a ballpark number of 10,000 CRCs in the core kernel, this would increase the size of the image by 40 KB for 32-bit architectures (and if saving 40 KB is essential, chances are you won't be using modversions in the first place). For 64-bit architectures, there would be no change in size, of course, except for saving 24 bytes of __init space *per CRC* for arm64 and powerpc64 with CONFIG_RELOCATABLE=y I will send out a separate RFC so we can discuss this alternative diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c index 06121ce524a7..9f739c7224c3 100644 --- a/scripts/genksyms/genksyms.c +++ b/scripts/genksyms/genksyms.c @@ -693,7 +693,10 @@ void export_symbol(const char *name) fputs(">\n", debugfile); /* Used as a linker script. */ - printf("%s__crc_%s = 0x%08lx ;\n", mod_prefix, name, crc); + printf("SECTIONS { .rodata.__crc_%s : ALIGN(4) " + "{ %s__crcp_%s = .; LONG(0x%08lx); } }\n" + "%s__crc_%s = 0x%08lx;\n", + name, mod_prefix, name, crc, mod_prefix, name, crc); } } diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h index e3508a3d6e53..5e95a552a871 100644 --- a/include/asm-generic/export.h +++ b/include/asm-generic/export.h @@ -49,8 +49,8 @@ KSYM(__kstrtab_\name): .section ___kcrctab\sec+\name,"a" .balign KCRC_ALIGN KSYM(__kcrctab_\name): - .long KSYM(__crc_\name) - .weak KSYM(__crc_\name) + .long KSYM(__crcp_\name) - . + .weak KSYM(__crcp_\name) .previous #endif #endif