Re: [Xen-devel] [PATCH v4 07/16] tables.h: add linker table support

2016-08-22 Thread Luis R. Rodriguez
On Fri, Aug 19, 2016 at 03:02:07PM -0700, Kees Cook wrote:
> On Fri, Aug 19, 2016 at 2:32 PM,   wrote:
> > diff --git a/arch/c6x/include/asm/tables.h b/arch/c6x/include/asm/tables.h
> > new file mode 100644
> > index ..09a9e31c573a
> > --- /dev/null
> > +++ b/arch/c6x/include/asm/tables.h
> > @@ -0,0 +1,26 @@
> > +#ifndef _ASM_C6X_ASM_TABLES_H
> > +#define _ASM_C6X_ASM_TABLES_H
> > +/*
> > + * Copyright (C) 2016 Luis R. Rodriguez 
> > + *
> > + * This program is free software; you can redistribute it and/or modify it
> > + * under the terms of copyleft-next (version 0.3.1 or later) as published
> > + * at http://copyleft-next.org/.
> > + */
> > +
> > +/*
> > + * The c6x toolchain has a bug present even on gcc-6 when non-weak 
> > attributes
> > + * are used and sends them to .rodata even though const data with weak
> > + * attributes are put in .const, this forces the linker to believe the 
> > address
> > + * is relative relative to the a base + offset and you end up with 
> > SB-relative
> > + * reloc error upon linking. Work around this by by forcing both start and
> > + * ending const RO waek linker table entry to be .const to fix this for 
> > now.
> 
> Type: waek -> weak

Thanks, fixed.

  Luis

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


Re: [Xen-devel] [PATCH v4 07/16] tables.h: add linker table support

2016-08-19 Thread Kees Cook
On Fri, Aug 19, 2016 at 2:32 PM,   wrote:
> From: "Luis R. Rodriguez" 
>
> A linker table is a data structure that is stitched together from items
> in multiple object files. Linux has historically implicitly used linker
> tables for ages, however they were all built in an adhoc manner which
> requires linker script modifications, per architecture. This adds a
> general linker table solution so that a new linker table can be
> implemented by changing C code only. The Linux linker table was
> inspired by Michael Brown's iPXE's linker table solution, it has been
> been completely re-written and adapted for integration and use on Linux.
>
> The same philosophy is borrowed, extended and further simplified:
>
> Linker tables enable an extremely light weight linker build time
> solution for feature ordering and selection, this can help to both
> simplify init sequences in a generic fashion and helps avoiding code
> bit-rotting when desirable. Further changes will be added later
> which will make more evident how code bit rot can be avoided using
> linker tables.
>
> v4:
>
> o Split out kbuild additions to help with code bit rot into
>   its own patch
> o tons of documentation love
> o fix arch/x86/tools/relocs.c typo - which caused compilation issues
>   on old toolchains
> o add c6x toolchain work around as discussed with Mark Salter
> o sprinkle a few more needed VMLINUX_SYMBOL() - fixes
>   compilation on blackfin
> o suggested name changes by boris:
> - %s/SECTION_TYPE_RANGES/rng/g
> - %s/SECTION_TYPE/SECTION_CORE/g
> - %s/section_type_asmtype/section_core_type/g
> - %s/section_type/section_core/g
> - %s/section_rng/set_section_rng/g
> - Drop DECLARE_SECTION_TBL() -- this is an asm equivalent
>   DEFINE_LINKTABLE() -- this however is not used yet, and it requires
>   a bit more work to match the C code definitions.
> o drop tools/include/linux/sections.h in favor of the more popular open
>   coding the names for tools
> o expand documentation to include module support
> o add maintaners
> o Use generic-y
> o move .text.tbl before unlikely to match the other sections
>
> v3:
>
> o addressed initial modular support test cases
> o added generic asm macros so linker tables can be used in
>   asm code / C asm calls
> o section ranges are now split up into their own set of files
> o use asm/sections.h instead of linux/sections.h for the linker
>   script
> o add a sections.h file for each architecture that was missing one,
>   this is needed now as we'll be relying on sections.h for custom
>   section types in code rather than custom architecture specific
>   linker script hacks.
> o full rewrite at this point, decided to pick copyleft-next license
>   for this work
>
> v2:
>
> o modified completely to match feedback by community, made equivalent
>   modifications to userspace solution. This is pretty much a complete
>   rewrite of how we present and use linker tables. By using standard
>   sections we no longer have to make custom linker script extensions
>   for each new linker table solution, you just pick a linker table
>   type by section type.
> o extend documention considerably, including use of kdoc
> o drop ICC hacks per popular request to ignore such issues for now
> o use sections.h - this lets us streamline a clean use case of
>   well documented sections. To help further with this make use of
>   SECTION_TBL() to allow use of these in code and SECTION_TBL_ALL()
>   on linker scripts, as well as SECTION_TBL_ALL_STR() on relocs.c
>   when needed.
>
> Cc: Michael Brown 
> Signed-off-by: Luis R. Rodriguez 
> ---
>  Documentation/sections/index.rst |   1 +
>  Documentation/sections/linker-tables.rst | 187 ++
>  MAINTAINERS  |  12 +
>  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/tables.h|  26 ++
>  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  

[Xen-devel] [PATCH v4 07/16] tables.h: add linker table support

2016-08-19 Thread mcgrof
From: "Luis R. Rodriguez" 

A linker table is a data structure that is stitched together from items
in multiple object files. Linux has historically implicitly used linker
tables for ages, however they were all built in an adhoc manner which
requires linker script modifications, per architecture. This adds a
general linker table solution so that a new linker table can be
implemented by changing C code only. The Linux linker table was
inspired by Michael Brown's iPXE's linker table solution, it has been
been completely re-written and adapted for integration and use on Linux.

The same philosophy is borrowed, extended and further simplified:

Linker tables enable an extremely light weight linker build time
solution for feature ordering and selection, this can help to both
simplify init sequences in a generic fashion and helps avoiding code
bit-rotting when desirable. Further changes will be added later
which will make more evident how code bit rot can be avoided using
linker tables.

v4:

o Split out kbuild additions to help with code bit rot into
  its own patch
o tons of documentation love
o fix arch/x86/tools/relocs.c typo - which caused compilation issues
  on old toolchains
o add c6x toolchain work around as discussed with Mark Salter
o sprinkle a few more needed VMLINUX_SYMBOL() - fixes
  compilation on blackfin
o suggested name changes by boris:
- %s/SECTION_TYPE_RANGES/rng/g
- %s/SECTION_TYPE/SECTION_CORE/g
- %s/section_type_asmtype/section_core_type/g
- %s/section_type/section_core/g
- %s/section_rng/set_section_rng/g
- Drop DECLARE_SECTION_TBL() -- this is an asm equivalent
  DEFINE_LINKTABLE() -- this however is not used yet, and it requires
  a bit more work to match the C code definitions.
o drop tools/include/linux/sections.h in favor of the more popular open
  coding the names for tools
o expand documentation to include module support
o add maintaners
o Use generic-y
o move .text.tbl before unlikely to match the other sections

v3:

o addressed initial modular support test cases
o added generic asm macros so linker tables can be used in
  asm code / C asm calls
o section ranges are now split up into their own set of files
o use asm/sections.h instead of linux/sections.h for the linker
  script
o add a sections.h file for each architecture that was missing one,
  this is needed now as we'll be relying on sections.h for custom
  section types in code rather than custom architecture specific
  linker script hacks.
o full rewrite at this point, decided to pick copyleft-next license
  for this work

v2:

o modified completely to match feedback by community, made equivalent
  modifications to userspace solution. This is pretty much a complete
  rewrite of how we present and use linker tables. By using standard
  sections we no longer have to make custom linker script extensions
  for each new linker table solution, you just pick a linker table
  type by section type.
o extend documention considerably, including use of kdoc
o drop ICC hacks per popular request to ignore such issues for now
o use sections.h - this lets us streamline a clean use case of
  well documented sections. To help further with this make use of
  SECTION_TBL() to allow use of these in code and SECTION_TBL_ALL()
  on linker scripts, as well as SECTION_TBL_ALL_STR() on relocs.c
  when needed.

Cc: Michael Brown 
Signed-off-by: Luis R. Rodriguez 
---
 Documentation/sections/index.rst |   1 +
 Documentation/sections/linker-tables.rst | 187 ++
 MAINTAINERS  |  12 +
 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/tables.h|  26 ++
 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 

[Xen-devel] [PATCH v4 07/16] tables.h: add linker table support

2016-08-19 Thread mcgrof
From: "Luis R. Rodriguez" 

A linker table is a data structure that is stitched together from items
in multiple object files. Linux has historically implicitly used linker
tables for ages, however they were all built in an adhoc manner which
requires linker script modifications, per architecture. This adds a
general linker table solution so that a new linker table can be
implemented by changing C code only. The Linux linker table was
inspired by Michael Brown's iPXE's linker table solution, it has been
been completely re-written and adapted for integration and use on Linux.

The same philosophy is borrowed, extended and further simplified:

Linker tables enable an extremely light weight linker build time
solution for feature ordering and selection, this can help to both
simplify init sequences in a generic fashion and helps avoiding code
bit-rotting when desirable. Further changes will be added later
which will make more evident how code bit rot can be avoided using
linker tables.

v4:

o Split out kbuild additions to help with code bit rot into
  its own patch
o tons of documentation love
o fix arch/x86/tools/relocs.c typo - which caused compilation issues
  on old toolchains
o add c6x toolchain work around as discussed with Mark Salter
o sprinkle a few more needed VMLINUX_SYMBOL() - fixes
  compilation on blackfin
o suggested name changes by boris:
- %s/SECTION_TYPE_RANGES/rng/g
- %s/SECTION_TYPE/SECTION_CORE/g
- %s/section_type_asmtype/section_core_type/g
- %s/section_type/section_core/g
- %s/section_rng/set_section_rng/g
- Drop DECLARE_SECTION_TBL() -- this is an asm equivalent
  DEFINE_LINKTABLE() -- this however is not used yet, and it requires
  a bit more work to match the C code definitions.
o drop tools/include/linux/sections.h in favor of the more popular open
  coding the names for tools
o expand documentation to include module support
o add maintaners
o Use generic-y
o move .text.tbl before unlikely to match the other sections

v3:

o addressed initial modular support test cases
o added generic asm macros so linker tables can be used in
  asm code / C asm calls
o section ranges are now split up into their own set of files
o use asm/sections.h instead of linux/sections.h for the linker
  script
o add a sections.h file for each architecture that was missing one,
  this is needed now as we'll be relying on sections.h for custom
  section types in code rather than custom architecture specific
  linker script hacks.
o full rewrite at this point, decided to pick copyleft-next license
  for this work

v2:

o modified completely to match feedback by community, made equivalent
  modifications to userspace solution. This is pretty much a complete
  rewrite of how we present and use linker tables. By using standard
  sections we no longer have to make custom linker script extensions
  for each new linker table solution, you just pick a linker table
  type by section type.
o extend documention considerably, including use of kdoc
o drop ICC hacks per popular request to ignore such issues for now
o use sections.h - this lets us streamline a clean use case of
  well documented sections. To help further with this make use of
  SECTION_TBL() to allow use of these in code and SECTION_TBL_ALL()
  on linker scripts, as well as SECTION_TBL_ALL_STR() on relocs.c
  when needed.

Cc: Michael Brown 
Signed-off-by: Luis R. Rodriguez 
---
 Documentation/sections/index.rst |   1 +
 Documentation/sections/linker-tables.rst | 187 ++
 MAINTAINERS  |  12 +
 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/tables.h|  26 ++
 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