From mboxrd@z Thu Jan 1 00:00:00 1970 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=-17.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 D5CD5C3A59E for ; Wed, 21 Aug 2019 11:54:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AAF1222CF7 for ; Wed, 21 Aug 2019 11:54:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DOxh31Nr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727658AbfHULyQ (ORCPT ); Wed, 21 Aug 2019 07:54:16 -0400 Received: from mail-qk1-f201.google.com ([209.85.222.201]:37125 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727383AbfHULyP (ORCPT ); Wed, 21 Aug 2019 07:54:15 -0400 Received: by mail-qk1-f201.google.com with SMTP id d203so1860981qke.4 for ; Wed, 21 Aug 2019 04:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=nD4+pr26g4cM7Abylq2YdggXawupPAle/yWOlQ9vc8k=; b=DOxh31Nrb03sM8H1oUNc/SVF2V7y/0vFExiRJJgdMdiN30mVr3RC1MfCEE5URJx/9s euViN+wOAdb0uefuOXo9aYhuz/0O0gqn2n/SzMBUj7jjtfaltSeTgZ15HJ38di+aUGIM F8G/nRzSIa6PixIYTJkKut2j1UFjHglXvCaD3m1y8DrfYqq35gH/EVssCG3oAKyJQnF+ Z2f5Y9uk0m6LWa5KklhJ5t8mL2OICsjEgE1tllDIGBrt1fJDcUr7C6MrDSVo2amKr9ke 67mL5njYhSCUr8mP3KYNAULfpX2oTqsXrN1gwY6Z3xLlDZjbSZtrbZTV9Hc3B1DaLq8S rXRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=nD4+pr26g4cM7Abylq2YdggXawupPAle/yWOlQ9vc8k=; b=nqc0evIAvGMgv/sWuFt5ePi5uDkOjuqq9p9qXhuI96NR+AYBAM98omE7+XHZSgbgGj grN/le6uHbNULFtuhwpkwciPGMQyBvKlNzF6oqnWMXNz18uXsRHRlkeOYyoh7/Q6my6P g+FmbSrYc550AOCR1RJQ5y9HW80XkKuaH+6Q/yRVBOKSX+nQMTAov4GlDhLIMsJ+e1zs ftj2GG/VlLBqhx2QYi5CknYcRRd8BLgNhIlm+EZuF64V4AXzkBrKtPI2xN+7jPsng4WF Rf/+Y6at/SwU6xmpo+bNhlG0dcwmdLOMiKo/M4Gvt+5IikdQft3MKCCvUUw81ud5i1Yy AARg== X-Gm-Message-State: APjAAAVfN8ES/zIahKfFO6pP8grPHWo4kPyml08CvWrXPlxNbZA2giMk NRoTQHIcfm0wj0KEhczyWs8oOShC7qdM4IJjxAASkfyNs4GFp5Rf5hCtJQOaX0Z5ZOu7AzSHLU0 4qiM08hPJxk+XDqNWLskUpIMECRteSi/H/EncrUZ1Pd8AHpOfZW7Mm7oRcAAzeEcUmHJMiNHb3I E= X-Google-Smtp-Source: APXvYqwWVNmxSD/0c8yyOghSaNHjxd0C3N899CBfY/SVjrqJdhabkiQKrjyEST/xgvzfWrXzm6+qJGpMb3iBpw== X-Received: by 2002:ae9:e714:: with SMTP id m20mr29443807qka.72.1566388453855; Wed, 21 Aug 2019 04:54:13 -0700 (PDT) Date: Wed, 21 Aug 2019 12:49:17 +0100 In-Reply-To: <20190821114955.12788-1-maennich@google.com> Message-Id: <20190821114955.12788-3-maennich@google.com> Mime-Version: 1.0 References: <20190813121733.52480-1-maennich@google.com> <20190821114955.12788-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog Subject: [PATCH v3 02/11] export: explicitly align struct kernel_symbol From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, geert@linux-m68k.org, gregkh@linuxfoundation.org, hpa@zytor.com, jeyu@kernel.org, joel@joelfernandes.org, kstewart@linuxfoundation.org, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-modules@vger.kernel.org, linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org, lucas.de.marchi@gmail.com, maco@android.com, maco@google.com, michal.lkml@markovi.net, mingo@redhat.com, oneukum@suse.com, pombredanne@nexb.com, sam@ravnborg.org, sspatil@google.com, stern@rowland.harvard.edu, tglx@linutronix.de, usb-storage@lists.one-eyed-alien.net, x86@kernel.org, yamada.masahiro@socionext.com, Ingo Molnar , Andrew Morton , Ard Biesheuvel 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 This change allows growing struct kernel_symbol without wasting bytes to alignment. It also concretized the alignment of ksymtab entries if relative references are used for ksymtab entries. struct kernel_symbol was already implicitly being aligned to the word size, except on x86_64 and m68k, where it is aligned to 16 and 2 bytes, respectively. As far as I can tell there is no requirement for aligning struct kernel_symbol to 16 bytes on x86_64, but gcc aligns structs to their size, and the linker aligns the custom __ksymtab sections to the largest data type contained within, so setting KSYM_ALIGN to 16 was necessary to stay consistent with the code generated for non-ASM EXPORT_SYMBOL(). Now that non-ASM EXPORT_SYMBOL() explicitly aligns to word size (8), KSYM_ALIGN is no longer necessary. In case of relative references, the alignment has been changed accordingly to not waste space when adding new struct members. As for m68k, struct kernel_symbol is aligned to 2 bytes even though the structure itself is 8 bytes; using a 4-byte alignment shouldn't hurt. I manually verified the output of the __ksymtab sections didn't change on x86, x86_64, arm, arm64 and m68k. As expected, the section contents didn't change, and the ELF section alignment only changed on x86_64 and m68k. Feedback from other archs more than welcome. Co-developed-by: Martijn Coenen Signed-off-by: Martijn Coenen Reviewed-by: Greg Kroah-Hartman Signed-off-by: Matthias Maennich --- arch/m68k/include/asm/export.h | 1 - include/asm-generic/export.h | 8 +++----- include/linux/export.h | 3 ++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/arch/m68k/include/asm/export.h b/arch/m68k/include/asm/export.h index 0af20f48bd07..b53008b67ce1 100644 --- a/arch/m68k/include/asm/export.h +++ b/arch/m68k/include/asm/export.h @@ -1,3 +1,2 @@ -#define KSYM_ALIGN 2 #define KCRC_ALIGN 2 #include diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h index 294d6ae785d4..63f54907317b 100644 --- a/include/asm-generic/export.h +++ b/include/asm-generic/export.h @@ -4,15 +4,13 @@ #ifndef KSYM_FUNC #define KSYM_FUNC(x) x #endif -#ifdef CONFIG_64BIT -#ifndef KSYM_ALIGN +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS +#define KSYM_ALIGN 4 +#elif defined(CONFIG_64BIT) #define KSYM_ALIGN 8 -#endif #else -#ifndef KSYM_ALIGN #define KSYM_ALIGN 4 #endif -#endif #ifndef KCRC_ALIGN #define KCRC_ALIGN 4 #endif diff --git a/include/linux/export.h b/include/linux/export.h index fd8711ed9ac4..28a4d2150689 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -52,7 +52,7 @@ extern struct module __this_module; #define __KSYMTAB_ENTRY(sym, sec) \ __ADDRESSABLE(sym) \ asm(" .section \"___ksymtab" sec "+" #sym "\", \"a\" \n" \ - " .balign 8 \n" \ + " .balign 4 \n" \ "__ksymtab_" #sym ": \n" \ " .long " #sym "- . \n" \ " .long __kstrtab_" #sym "- . \n" \ @@ -66,6 +66,7 @@ struct kernel_symbol { #define __KSYMTAB_ENTRY(sym, sec) \ static const struct kernel_symbol __ksymtab_##sym \ __attribute__((section("___ksymtab" sec "+" #sym), used)) \ + __aligned(sizeof(void *)) \ = { (unsigned long)&sym, __kstrtab_##sym } struct kernel_symbol { -- 2.23.0.rc1.153.gdeed80330f-goog