linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: "Luis R. Rodriguez" <mcgrof@kernel.org>
Cc: "gnomes@lxorguk.ukuu.org.uk" <gnomes@lxorguk.ukuu.org.uk>,
	linux-ia64@vger.kernel.org, Jiri Kosina <jkosina@suse.cz>,
	"benh@kernel.crashing.org" <benh@kernel.crashing.org>,
	Ming Lei <ming.lei@canonical.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	platform-driver-x86@vger.kernel.org,
	James Bottomley <James.Bottomley@hansenpartnership.com>,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	linux-arch <linux-arch@vger.kernel.org>,
	markus.heiser@darmarit.de,
	sparclinux <sparclinux@vger.kernel.org>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	Russell King - ARM Linux <linux@arm.linux.org.uk>,
	linux-sh <linux-sh@vger.kernel.org>, Will Deacon <will>
Subject: Re: [PATCH v4 04/16] generic-sections: add section core helpers
Date: Fri, 19 Aug 2016 14:47:48 -0700	[thread overview]
Message-ID: <CAGXu5jL4u13rR76y49qF=0cZMQW97Bg4apPXNFMAkGyzD2-a7Q@mail.gmail.com> (raw)
In-Reply-To: <1471642385-5629-5-git-send-email-mcgrof@kernel.org>

On Fri, Aug 19, 2016 at 2:32 PM,  <mcgrof@kernel.org> wrote:
> From: "Luis R. Rodriguez" <mcgrof@kernel.org>
>
> Linux makes extensive use of custom ELF header sections,
> documentation for these are well scatterred. Unify this
> documentation in a central place and provide helpers to
> build custom Linux sections.
>
> This also generalizes sections code to enable avoiding
> modifying the linker scripts when we want to add new
> custom Linux sections. In order to make this generally
> useful we need to ensure all architectures can make use of
> core section helpers but that they can also override should
> this be needed. Instead of relying on section.h this adds
> a sections-core.h since this will be targetted to be safe
> to be used on asm code, linker scripts and C code.
>
> v4:
>
> o Port to shiny new sphinx documentation format
>
> o fix a unicore32 build, turns out this actually fixes unicore32
>   defconfig builds which were failing for a long while. unicore32
>   does not seem to grok well the type passed on a section declaration,
>   this ignores it.
>
> o Use VMLINUX_SYMBOL() in more user symbols (extern C code), not doing
>   this was causing final linker issues with blackfin -- this is
>   a CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX=y architecture. The other one
>   being metatag. metatag is not supported on 0-day so I cannot confirm
>   compilation there.
>
> o Added SECTION_CORE() for C code, used later by __LINUX_RANGE()
>
> o Since SECTION_CORE() is defined for linker script and C code, share
>   the same helper and just use a __stringify() for the C code as is done
>   for the other C helpers.
>
> o move generic sections to asm-generic/section-core.h instead.
>   PowerPC compilation blows up if asm/jump_labels.h gets
>   section.h included, fixing this is not in any way easy.
>   The list of issues are endless. Moving new data to a new
>   simple file resolves this.
>
> o since things are now in asm-generic/section-core.h the
>   guard changes on asm-generic/sections.h and each architecture
>   sections.h are no longer needed
>
> o Give generic sections some maintainer love, that change is
>   Acked-by Arnd Bergmann, Josh and hpa.
>
> o A few checkpatch.pl style fixes
>
> o As suggested by James Hogan use generic-y to copy generic
>   header files on architectures that do not have a sections.h
>   instead of writing a simple file only to include the generic one.
>
> v3:
>
> o add missing sections.h for architectures that did not
>   have it
>
> o move generic sections to asm-generic/sections.h
>
> o add generic asm helpers section_type(), section_type_asmtype(),
>   push_section_type() -- these helpers enable easy use for
>   for later declaring and using of custom linux sections using
>   more standard APIs in both C code, asm code (C asm calls, or
>   asm files), enabling future standardized section types to
>   be more immediately accessible to asm code, not just C code.
>   Note for ASM_CMD_SEP we use by default "\n", architectures needed
>   to override can do so on their own sections.h prior to inclusion
>   of asm-generic/sections.h
>
> Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
> ---
>  Documentation/index.rst                   |   1 +
>  Documentation/sections/conf.py            |   4 +
>  Documentation/sections/index.rst          |  11 +
>  Documentation/sections/section-core.rst   | 153 ++++++++++++++
>  MAINTAINERS                               |  14 ++
>  arch/alpha/include/asm/Kbuild             |   1 +
>  arch/arc/include/asm/Kbuild               |   1 +
>  arch/arm/include/asm/Kbuild               |   1 +
>  arch/arm64/include/asm/Kbuild             |   1 +
>  arch/avr32/include/asm/Kbuild             |   1 +
>  arch/blackfin/include/asm/Kbuild          |   1 +
>  arch/c6x/include/asm/Kbuild               |   1 +
>  arch/cris/include/asm/Kbuild              |   1 +
>  arch/frv/include/asm/Kbuild               |   1 +
>  arch/h8300/include/asm/Kbuild             |   1 +
>  arch/hexagon/include/asm/Kbuild           |   1 +
>  arch/ia64/include/asm/Kbuild              |   1 +
>  arch/m32r/include/asm/Kbuild              |   1 +
>  arch/m68k/include/asm/Kbuild              |   1 +
>  arch/metag/include/asm/Kbuild             |   1 +
>  arch/microblaze/include/asm/Kbuild        |   1 +
>  arch/mips/include/asm/Kbuild              |   1 +
>  arch/mn10300/include/asm/Kbuild           |   1 +
>  arch/nios2/include/asm/Kbuild             |   1 +
>  arch/openrisc/include/asm/Kbuild          |   1 +
>  arch/parisc/include/asm/Kbuild            |   1 +
>  arch/powerpc/include/asm/Kbuild           |   1 +
>  arch/s390/include/asm/Kbuild              |   1 +
>  arch/score/include/asm/Kbuild             |   1 +
>  arch/sh/include/asm/Kbuild                |   1 +
>  arch/sparc/include/asm/Kbuild             |   1 +
>  arch/tile/include/asm/Kbuild              |   1 +
>  arch/um/include/asm/Kbuild                |   1 +
>  arch/unicore32/include/asm/section-core.h |  19 ++
>  arch/x86/include/asm/Kbuild               |   1 +
>  arch/xtensa/include/asm/Kbuild            |   1 +
>  include/asm-generic/section-core.h        | 341 ++++++++++++++++++++++++++++++
>  include/asm-generic/sections.h            |   2 +
>  include/asm-generic/vmlinux.lds.h         |  27 +--
>  include/linux/sections.h                  | 111 ++++++++++
>  40 files changed, 700 insertions(+), 13 deletions(-)
>  create mode 100644 Documentation/sections/conf.py
>  create mode 100644 Documentation/sections/index.rst
>  create mode 100644 Documentation/sections/section-core.rst
>  create mode 100644 arch/unicore32/include/asm/section-core.h
>  create mode 100644 include/asm-generic/section-core.h
>  create mode 100644 include/linux/sections.h
>
> diff --git a/Documentation/index.rst b/Documentation/index.rst
> index a15f81855b39..10c9b867e326 100644
> --- a/Documentation/index.rst
> +++ b/Documentation/index.rst
> @@ -14,6 +14,7 @@ Contents:
>     kernel-documentation
>     media/index
>     gpu/index
> +   sections/index
>
>  Indices and tables
>  ==================
> diff --git a/Documentation/sections/conf.py b/Documentation/sections/conf.py
> new file mode 100644
> index 000000000000..faa1c57595e1
> --- /dev/null
> +++ b/Documentation/sections/conf.py
> @@ -0,0 +1,4 @@
> +# -*- coding: utf-8; mode: python -*-
> +
> +project = 'Linux Kernel ELF sections'
> +html_search_language = 'en'
> diff --git a/Documentation/sections/index.rst b/Documentation/sections/index.rst
> new file mode 100644
> index 000000000000..d411e9b22eb3
> --- /dev/null
> +++ b/Documentation/sections/index.rst
> @@ -0,0 +1,11 @@
> +=========================
> +Linux Kernel ELF sections
> +=========================
> +
> +This book documents the Linux kernel's use of ELF sections, as well as helpers
> +used throughout the kernel to help declare and define them.
> +
> +.. toctree::
> +   :maxdepth: 4
> +
> +   section-core
> diff --git a/Documentation/sections/section-core.rst b/Documentation/sections/section-core.rst
> new file mode 100644
> index 000000000000..ecf4228bc4f8
> --- /dev/null
> +++ b/Documentation/sections/section-core.rst
> @@ -0,0 +1,153 @@
> +==============================
> +Core Linux kernel ELF sections
> +==============================
> +
> +About
> +=====
> +
> +This book documents the different standard and custom ELF sections used
> +on the Linux kernel, which we refer to as the ``core Linux sections``. We
> +start off by documenting the standard ELF sections used by Linux and move
> +on to the basic custom ELF sections, followed by a set of helpers. Each
> +section documented describes the goal of the section, and addresses
> +concurrency considerations when applicable.
> +
> +.. kernel-doc:: include/asm-generic/section-core.h
> +   :doc: Custom linker script
> +
> +Standard ELF section use in Linux
> +=================================
> +
> +.. kernel-doc:: include/asm-generic/section-core.h
> +   :doc: Standard ELF section use in Linux
> +
> +SECTION_RODATA
> +--------------
> +.. kernel-doc:: include/asm-generic/section-core.h
> +   :doc: SECTION_RODATA
> +
> +SECTION_RODATA

Typo: should this be called SECTION_TEXT instead?

> +--------------
> +.. kernel-doc:: include/asm-generic/section-core.h
> +   :doc: SECTION_TEXT
> +
> +SECTION_DATA
> +------------
> +.. kernel-doc:: include/asm-generic/section-core.h
> +   :doc: SECTION_DATA

Missing from this list are things like the __read_mostly
(".data..read_mostly") and __ro_after_init (".data..ro_after_init")
sections. Should those be included too, or are you only doing the "top
level" sections?

-Kees

-- 
Kees Cook
Nexus Security

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-08-19 21:47 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-19 21:32 [PATCH v4 00/16] linux: generalize sections, ranges and linker tables mcgrof
2016-08-19 21:32 ` mcgrof
2016-08-19 21:32 ` [PATCH v4 01/16] x86: remove LTO_REFERENCE_INITCALL() mcgrof
2016-08-19 21:32   ` mcgrof
2016-08-19 21:32 ` [PATCH v4 02/16] dell-smo8800: include uaccess.h mcgrof
2016-08-19 21:32   ` mcgrof
2016-08-19 21:32 ` [PATCH v4 03/16] scripts/module-common.lds: enable generation mcgrof
2016-08-19 21:32   ` mcgrof
2016-08-19 21:32 ` [PATCH v4 04/16] generic-sections: add section core helpers mcgrof
2016-08-19 21:32   ` mcgrof
2016-08-19 21:47   ` Kees Cook [this message]
2016-08-22 23:13     ` Luis R. Rodriguez
2016-08-19 21:32 ` [PATCH v4 05/16] xtensa: skip adding literal when SORT() is used mcgrof
2016-08-19 21:32   ` mcgrof
2016-08-19 21:32 ` [PATCH v4 06/16] ranges.h: add helpers to build and identify Linux section ranges mcgrof
2016-08-19 21:32   ` mcgrof
2016-08-19 21:55   ` Kees Cook
2016-08-22 23:48     ` Luis R. Rodriguez
2016-08-19 21:32 ` [PATCH v4 07/16] tables.h: add linker table support mcgrof
2016-08-19 21:32   ` mcgrof
2016-08-19 22:02   ` Kees Cook
2016-08-22 23:53     ` Luis R. Rodriguez
2016-08-19 21:32 ` [PATCH v4 08/16] kbuild: enable option to force compile force-obj-y and force-lib-y mcgrof
2016-08-19 21:32   ` mcgrof
2016-08-19 22:10   ` Kees Cook
2016-08-22 23:59     ` Luis R. Rodriguez
2016-08-30 20:15       ` Luis R. Rodriguez
2016-08-19 21:32 ` [PATCH v4 09/16] firmware/Makefile: force recompilation if makefile changes mcgrof
2016-08-19 21:32   ` mcgrof
2016-08-19 21:32 ` [PATCH v4 10/16] firmware: port built-in section to linker table mcgrof
2016-08-19 21:32   ` mcgrof
2016-08-19 22:29 ` [PATCH v4 00/16] linux: generalize sections, ranges and linker tables Kees Cook
2016-08-22 23:06   ` Luis R. Rodriguez
2016-08-19 21:33 mcgrof
2016-08-19 21:34 ` [PATCH v4 04/16] generic-sections: add section core helpers mcgrof
2016-08-19 21:34   ` mcgrof
2016-08-23  1:26   ` Nicholas Piggin
2016-08-23  1:26     ` Nicholas Piggin
2016-08-23 17:33     ` Luis R. Rodriguez
2016-08-23 17:33       ` Luis R. Rodriguez
2016-08-24  3:51       ` Nicholas Piggin
2016-08-24  3:51         ` Nicholas Piggin
2016-08-24 20:12         ` Luis R. Rodriguez
2016-08-24 20:12           ` Luis R. Rodriguez
2016-08-25  2:06           ` Nicholas Piggin
2016-08-25  2:06             ` Nicholas Piggin
2016-08-25  6:05             ` Luis R. Rodriguez
2016-08-25  6:05               ` Luis R. Rodriguez
2016-08-25  6:51               ` Nicholas Piggin
2016-08-25  6:51                 ` Nicholas Piggin
2016-08-25 17:52                 ` Luis R. Rodriguez
2016-08-25 17:52                   ` Luis R. Rodriguez
2016-08-26  3:00                   ` Nicholas Piggin
2016-08-26  6:38                     ` Luis R. Rodriguez
2016-08-26  7:33                       ` Nicholas Piggin
2016-08-26  7:33                         ` Nicholas Piggin
2016-08-26 13:22                         ` Luis R. Rodriguez
2016-08-26 13:22                           ` Luis R. Rodriguez
2016-08-26 13:28                           ` Nicholas Piggin
2016-08-26 13:28                             ` Nicholas Piggin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGXu5jL4u13rR76y49qF=0cZMQW97Bg4apPXNFMAkGyzD2-a7Q@mail.gmail.com' \
    --to=keescook@chromium.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=benh@kernel.crashing.org \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hpa@zytor.com \
    --cc=jkosina@suse.cz \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=markus.heiser@darmarit.de \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mcgrof@kernel.org \
    --cc=mchehab@osg.samsung.com \
    --cc=ming.lei@canonical.com \
    --cc=mpe@ellerman.id.au \
    --cc=paul.gortmaker@windriver.com \
    --cc=paulus@samba.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=sparclinux@vger.kernel.org \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).