Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp6491708imm; Wed, 27 Jun 2018 08:29:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK1de1Xv6VAqXWiMSAL98J3I4ij3oHCvRxRv98BT9WXLLdjEl8OiMVJOOMBKkvRg9PMpLto X-Received: by 2002:a65:60cd:: with SMTP id r13-v6mr5691051pgv.232.1530113352494; Wed, 27 Jun 2018 08:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530113352; cv=none; d=google.com; s=arc-20160816; b=SvK/YRWlOpTPHlNrKCybWh7JTHO5kvgbFLVhppkQOJsCW3TU+Fi3c+U7bxJ0JqVUZh AAfvKCv9R2CMvybuwIXCJgbdGoKjGTLKDmsexBKM81Dbcc+D5n7+tnWXGSog1U/WKLKu uR8pgR24Tf5SkRDpR8Bnet123nNW9NQtRmOc8d42ROtvubmPePQY+DT80R/juPHc+CNX YaOSicgkbXCI5I6geCVLJlYITw7pjbm8wYDfwbeYWaYLhAvZAK/Dta9pbzuQCGuD7VKz sqU9y/dXdiwp3gYmiFATdO80bkSfylOactfivLEQWi7uCuiky+/6FZNNZzr/sGytqX92 G3rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=OyEJcaBYlGr1pe/DUkTWY88VpPjStKt/hB5EqVgM4UQ=; b=gouLgvkNIpKb6zIRin9c4bf3eQgQIgXaXV1SzcdTRqcM7GAwZK/FPlRjsG+A/fiQGJ dihBJ03AKKdAN+uws4Jt5RRajFbALdHwWuS8B6UInPimdT2+PhOwBBYU9q0tnP5SakzL VeCCXfSj4xsmejvVsi/RSKPRL6u/2lolKxxMqRurJ+wa+X/9HCJ6WMihqvDeLhjsB+bK tyhgbN8LmuYoT6AgHLvGca62ce2QOVMHpDBvajl+SLapGw8zXPFyosvmS7r+384tyLHs yg9+r+aLjSFy656DMKFKMSoAymYukrS+qoUb6J/7ZtZaKzQ0eSWXB9QlYqbc/DpBEa0v wE1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AcgtJBH8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j195-v6si3684548pgc.543.2018.06.27.08.28.58; Wed, 27 Jun 2018 08:29:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AcgtJBH8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965493AbeF0PVg (ORCPT + 99 others); Wed, 27 Jun 2018 11:21:36 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:33484 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964834AbeF0PVe (ORCPT ); Wed, 27 Jun 2018 11:21:34 -0400 Received: by mail-io0-f195.google.com with SMTP id d185-v6so2269916ioe.0 for ; Wed, 27 Jun 2018 08:21:34 -0700 (PDT) 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=OyEJcaBYlGr1pe/DUkTWY88VpPjStKt/hB5EqVgM4UQ=; b=AcgtJBH8IpM8+/773zi6y8ZCZZrivD8JV2rRGpkadvbNpnyu2HwJH2v4AtB29Y/NrO mlAcmn30OSRNhydo66u1ZDwUEY8WCJBGR0zakh0x+BjFucL8oi7qPQneu60Xb1WMC86a lfiEu9tVK3B2vIKlXa9wcBuWdJRnjQEzyD1ow= 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=OyEJcaBYlGr1pe/DUkTWY88VpPjStKt/hB5EqVgM4UQ=; b=rNHlKQoTMZ/4FZJV7rQVCAEfb7jj5I47/D9IR5N/P7+VI7aduhuSfEB2945HLyi3Ti 0Xmlu+0b1L8KKRYnaHEV6rOFBXltDGwQo+N4/jwMXci0K0G7fG+UV+FNjM9CXLOMDZDp +x67eEWsaJpqdMSGtpGJhB//zzOWEt4211xGr1JGoZNoSq8pD8bSnMKFRaZ69VR4P0qJ n2hnT5EtwJ3EeEHV6mxOEioj8+9LCMNaDM1LE1a24lA5pFr0rDdzoDEvyF/tcBHpL6Cu tERmY7LZdC5W9Y3QUVZQuuYO9c5lCnlzeel1D2gIx73IlSNIk4grGz88XM78EUOyWQ0m pupA== X-Gm-Message-State: APt69E1cRjT+L504gEYP6Kub0mxpmNqtGATqMAfS2hssol9o9T77Um4u wQySjvLjimkdet9yH8MP+DVHod42kN4dWs8gpamlwYl2 X-Received: by 2002:a6b:520d:: with SMTP id g13-v6mr5603421iob.60.1530112893657; Wed, 27 Jun 2018 08:21:33 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:bbc7:0:0:0:0:0 with HTTP; Wed, 27 Jun 2018 08:21:33 -0700 (PDT) In-Reply-To: <20180627151339.GD30631@arm.com> References: <20180626182802.19932-1-ard.biesheuvel@linaro.org> <20180626182802.19932-4-ard.biesheuvel@linaro.org> <20180627151339.GD30631@arm.com> From: Ard Biesheuvel Date: Wed, 27 Jun 2018 17:21:33 +0200 Message-ID: Subject: Re: [PATCH v9 3/6] module: use relative references for __ksymtab entries To: Will Deacon Cc: Linux Kernel Mailing List , Arnd Bergmann , Kees Cook , Michael Ellerman , Thomas Garnier , Thomas Gleixner , "Serge E. Hallyn" , Bjorn Helgaas , Benjamin Herrenschmidt , Russell King , Paul Mackerras , Catalin Marinas , Petr Mladek , Ingo Molnar , James Morris , Andrew Morton , Nicolas Pitre , Josh Poimboeuf , Steven Rostedt , Sergey Senozhatsky , Linus Torvalds , Jessica Yu , linux-arm-kernel , linuxppc-dev , "the arch/x86 maintainers" , Ingo Molnar Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27 June 2018 at 17:13, Will Deacon wrote: > Hi Ard, > > On Tue, Jun 26, 2018 at 08:27:58PM +0200, Ard Biesheuvel wrote: >> An ordinary arm64 defconfig build has ~64 KB worth of __ksymtab >> entries, each consisting of two 64-bit fields containing absolute >> references, to the symbol itself and to a char array containing >> its name, respectively. > > [...] > >> diff --git a/include/linux/export.h b/include/linux/export.h >> index ea7df303d68d..ae072bc5aacf 100644 >> --- a/include/linux/export.h >> +++ b/include/linux/export.h >> @@ -18,12 +18,6 @@ >> #define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x) >> >> #ifndef __ASSEMBLY__ >> -struct kernel_symbol >> -{ >> - unsigned long value; >> - const char *name; >> -}; >> - >> #ifdef MODULE >> extern struct module __this_module; >> #define THIS_MODULE (&__this_module) >> @@ -54,17 +48,47 @@ extern struct module __this_module; >> #define __CRC_SYMBOL(sym, sec) >> #endif >> >> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS >> +#include >> +/* >> + * Emit the ksymtab entry as a pair of relative references: this reduces >> + * the size by half on 64-bit architectures, and eliminates the need for >> + * absolute relocations that require runtime processing on relocatable >> + * kernels. >> + */ >> +#define __KSYMTAB_ENTRY(sym, sec) \ >> + __ADDRESSABLE(sym) \ >> + asm(" .section \"___ksymtab" sec "+" #sym "\", \"a\" \n" \ >> + " .balign 8 \n" \ > > Can we use KSYM_ALIGN here instead of 8, or do we need the 8-byte alignment > even on 32-bit architectures? > We don't *need* 8 byte alignment on any architecture, but since the structure itself is 8 bytes in size and we have a sizable array of them, it makes sense to align them to 8 bytes.