[Xen-devel] [PATCH v1 6/7] tools: add __section() to compiler.h

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

This will be used later by the userspace linker table.

Signed-off-by: Luis R. Rodriguez 
---
 tools/include/linux/compiler.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 556c991de212..6321265df00a 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -132,4 +132,6 @@ static __always_inline void __write_once_size(volatile void 
*p, void *res, int s
 #define WRITE_ONCE(x, val) \
({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; 
__write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
 
+#define __section(S)   __attribute__ ((__section__(#S)))
+
 #endif /* _TOOLS_LINUX_COMPILER_H */
-- 
2.9.2


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


[Xen-devel] [PATCH v1 5/7] tools: expand export.h with VMLINUX_SYMBOL()

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

This will be used later by the linker-table userspace sandbox.

Signed-off-by: Luis R. Rodriguez 
---
 tools/include/linux/export.h | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/tools/include/linux/export.h b/tools/include/linux/export.h
index d07e586b9ba0..cb7d6b490e08 100644
--- a/tools/include/linux/export.h
+++ b/tools/include/linux/export.h
@@ -1,6 +1,28 @@
 #ifndef _TOOLS_LINUX_EXPORT_H_
 #define _TOOLS_LINUX_EXPORT_H_
 
+/*
+ * Export symbols from the kernel to modules.  Forked from module.h
+ * to reduce the amount of pointless cruft we feed to gcc when only
+ * exporting a simple symbol or two.
+ *
+ * Try not to add #includes here.  It slows compilation and makes kernel
+ * hackers place grumpy comments in header files.
+ */
+
+/* Some toolchains use a `_' prefix for all user symbols. */
+#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
+#define __VMLINUX_SYMBOL(x) _##x
+#define __VMLINUX_SYMBOL_STR(x) "_" #x
+#else
+#define __VMLINUX_SYMBOL(x) x
+#define __VMLINUX_SYMBOL_STR(x) #x
+#endif
+
+/* Indirect, so macros are expanded before pasting. */
+#define VMLINUX_SYMBOL(x) __VMLINUX_SYMBOL(x)
+#define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x)
+
 #define EXPORT_SYMBOL(sym)
 #define EXPORT_SYMBOL_GPL(sym)
 #define EXPORT_SYMBOL_GPL_FUTURE(sym)
-- 
2.9.2


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


[Xen-devel] [PATCH v1 3/7] tools: add init.h for tools

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

Start off with just __ref -- we enalbe you to override, if you do
that then you can define your own. The way you'd use this, if you
do override, is define your own __ref and then use include_next.

Signed-off-by: Luis R. Rodriguez 
---
 tools/include/linux/init.h | 9 +
 1 file changed, 9 insertions(+)
 create mode 100644 tools/include/linux/init.h

diff --git a/tools/include/linux/init.h b/tools/include/linux/init.h
new file mode 100644
index ..6d970a360a05
--- /dev/null
+++ b/tools/include/linux/init.h
@@ -0,0 +1,9 @@
+#ifndef _TOOLS_LINUX_INIT_H
+#define _TOOLS_LINUX_INIT_H
+
+/* this means you can add your own to fit you own userspace needs */
+#ifndef __ref
+#define __ref
+#endif
+
+#endif /* _TOOLS_LINUX_INIT_H */
-- 
2.9.2


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


[Xen-devel] [PATCH v1 0/7] tools: add linker table userspace sandbox

2016-08-19 Thread mcgrof
From: "Luis R. Rodriguez" <mcg...@kernel.org>

The original v3 series for linker tables made reference only to
an external repository userspace sandbox application, however
Boris noted it'd be difficult ot keep this in sync with the
kernel so advised to consider integrate with the kernel. I've
taken steps in this direction.

A bit of prepping is done to help make use of the tools/include
and tools/arch/$(ARCH)/include/asm directories. For now the tool
only supports x86_64, however quite a bit of work was done to
help make it work with a cross compiler, and try to make as
architecture agnostic as possible. Adding suppor for another 
architecture should not require much work, mosty just generating
a userspace custom linker script, modifying it for linker tables,
section ranges, and finally testing this with its toolchain.

This is being submitted separately than the patches which adds
linker table support into the kernel. This should be considered
only if that gets merged.

If you'd like this in git-form, you can get it on the 20160819-linker-table-v4  
branch of my linux-next tree on kernel.org, this also includes the series of
that introduces linker tables into the kernel:

https://git.kernel.org/cgit/linux/kernel/git/mcgrof/linux-next.git/log/?h=20160819-linker-table-v4

Please let me know if there are any issue or questions.

Luis R. Rodriguez (7):
  tools: add a userspace tools bug.h
  tools: add a basic tools printk.h
  tools: add init.h for tools
  tools: add __used and enable to override
  tools: expand export.h with VMLINUX_SYMBOL()
  tools: add __section() to compiler.h
  tools: add userspace linker table sandbox

 Documentation/sections/linker-tables.rst   |   4 +-
 MAINTAINERS|   1 +
 include/linux/tables.h |   5 +-
 tools/Makefile |   3 +-
 .../arch/x86/include/generated/asm/section-core.h  |   1 +
 tools/arch/x86/include/generated/ranges.h  |   1 +
 tools/arch/x86/include/generated/tables.h  |   1 +
 tools/include/asm-generic/bug.h|  24 +
 tools/include/asm-generic/ranges.h | 103 
 tools/include/asm-generic/section-core.h   | 341 +++
 tools/include/asm-generic/tables.h |  50 ++
 tools/include/linux/bug.h  |   6 +
 tools/include/linux/compiler.h |   8 +
 tools/include/linux/export.h   |  22 +
 tools/include/linux/init.h |   9 +
 tools/include/linux/kernel.h   |   3 +
 tools/include/linux/printk.h   |  14 +
 tools/include/linux/ranges.h   | 128 
 tools/include/linux/sections.h | 111 
 tools/include/linux/string.h   |   1 +
 tools/include/linux/tables.h   | 664 +
 tools/linker-tables/.gitignore |   2 +
 tools/linker-tables/Makefile   | 184 ++
 tools/linker-tables/README | 114 
 tools/linker-tables/arch/x86/include/asm/asm.h |  17 +
 tools/linker-tables/arch/x86/include/asm/boot.h|   1 +
 .../linker-tables/arch/x86/include/asm/bootparam.h |  32 +
 tools/linker-tables/arch/x86/include/asm/kprobes.h |   7 +
 .../linker-tables/arch/x86/include/asm/ps_const.h  |  21 +
 tools/linker-tables/arch/x86/include/asm/ranges.h  |   6 +
 .../arch/x86/include/asm/section-core.h|   1 +
 tools/linker-tables/arch/x86/include/asm/setup.h   |   6 +
 tools/linker-tables/arch/x86/include/asm/tables.h  |   6 +
 tools/linker-tables/arch/x86/include/asm/x86.h |   4 +
 .../arch/x86/include/asm/x86_init_fn.h | 169 ++
 tools/linker-tables/arch/x86/kernel/alpha.c|   9 +
 tools/linker-tables/arch/x86/kernel/alternative.c  |  31 +
 tools/linker-tables/arch/x86/kernel/beta.c |   9 +
 tools/linker-tables/arch/x86/kernel/head64.c   |  58 ++
 tools/linker-tables/arch/x86/kernel/init.c |  42 ++
 tools/linker-tables/arch/x86/kernel/kasan.c|  10 +
 tools/linker-tables/arch/x86/kernel/kprobes.c  |  51 ++
 tools/linker-tables/arch/x86/kernel/vmlinux.lds.S  | 273 +
 tools/linker-tables/arch/x86/mm/init.c |  10 +
 tools/linker-tables/arch/x86/xen/init.c|  13 +
 tools/linker-tables/drivers/acme.c |  32 +
 tools/linker-tables/drivers/synth/common.c |  16 +
 tools/linker-tables/drivers/synth/common.h |   2 +
 tools/linker-tables/drivers/synth/main.c   |  35 ++
 tools/linker-tables/drivers/synth/or.S |  39 ++
 tools/linker-tables/drivers/synth/synth.h  |   2 +
 tools/linker-tables/drivers/xen-driver.c   |  11 +
 .../include/asm-generic/arch_init_fn.h |  50 

[Xen-devel] [PATCH v1 1/7] tools: add a userspace tools bug.h

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

This will be used later by the userspace linker-tables sandbox.
As a convenience, include bug.h on kernel.h -- this is not done
on upstream kernel.h, however most header files do include bug.h
eventually, if we were to only add the ones that need it we'd
need to copy a lot of headers to tools for the ony purpose of
includeing bug.h. This simplifies that.

Signed-off-by: Luis R. Rodriguez 
---
 tools/include/asm-generic/bug.h | 24 
 tools/include/linux/bug.h   |  6 ++
 tools/include/linux/kernel.h|  2 ++
 3 files changed, 32 insertions(+)
 create mode 100644 tools/include/asm-generic/bug.h
 create mode 100644 tools/include/linux/bug.h

diff --git a/tools/include/asm-generic/bug.h b/tools/include/asm-generic/bug.h
new file mode 100644
index ..7b0f48b60dbe
--- /dev/null
+++ b/tools/include/asm-generic/bug.h
@@ -0,0 +1,24 @@
+#ifndef __TOOLS_ASM_GENERIC_BUG
+#define __TOOLS_ASM_GENERIC_BUG
+
+#include 
+#include 
+
+#define BUG() do { 
\
+   fprintf(stderr, 
"--\n");\
+   fprintf (stderr, "BUG on %s at %s: %i\n", __func__, __FILE__, 
__LINE__);\
+   abort();
\
+}  
\
+while (0)
+
+#define BUG_ON(cond) do { if (cond) BUG(); } while (0)
+
+#define WARN_ON(__test) do {   
\
+   if (__test) {   
\
+   fprintf(stderr, 
"--\n");\
+   fprintf (stderr, "WARN_ON on %s at %s: %i\n", __func__, 
__FILE__, __LINE__);\
+   }   
\
+}  
\
+while (0)
+
+#endif /* __TOOLS_ASM_GENERIC_BUG */
diff --git a/tools/include/linux/bug.h b/tools/include/linux/bug.h
new file mode 100644
index ..9be515b40b5c
--- /dev/null
+++ b/tools/include/linux/bug.h
@@ -0,0 +1,6 @@
+#ifndef _TOOLS_LINUX_BUG_H
+#define _TOOLS_LINUX_BUG_H
+
+#include 
+
+#endif /* _TOOLS_LINUX_BUG_H */
diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h
index 28607db02bd3..3d385a6d4fc1 100644
--- a/tools/include/linux/kernel.h
+++ b/tools/include/linux/kernel.h
@@ -5,6 +5,8 @@
 #include 
 #include 
 
+#include 
+
 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
 
 #define PERF_ALIGN(x, a)   __PERF_ALIGN_MASK(x, (typeof(x))(a)-1)
-- 
2.9.2


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


[Xen-devel] [PATCH v1 2/7] tools: add a basic tools printk.h

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

This will be used later by the userspace linker-tables sandbox.
Since upstream kernel.h includes printk.h mimic this so we can
match and replicate C code as-is on userspace sandbox tools.

Signed-off-by: Luis R. Rodriguez 
---
 tools/include/linux/kernel.h |  1 +
 tools/include/linux/printk.h | 14 ++
 2 files changed, 15 insertions(+)
 create mode 100644 tools/include/linux/printk.h

diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h
index 3d385a6d4fc1..afdf760bf35c 100644
--- a/tools/include/linux/kernel.h
+++ b/tools/include/linux/kernel.h
@@ -6,6 +6,7 @@
 #include 
 
 #include 
+#include 
 
 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
 
diff --git a/tools/include/linux/printk.h b/tools/include/linux/printk.h
new file mode 100644
index ..7e34e9c817e8
--- /dev/null
+++ b/tools/include/linux/printk.h
@@ -0,0 +1,14 @@
+#ifndef __TOOLS_KERNEL_PRINTK__
+#define __TOOLS_KERNEL_PRINTK__
+
+#include 
+
+#ifndef pr_fmt
+#define pr_fmt(fmt)fmt
+#endif
+
+#define pr_info(fmt, ...)  printf(pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_err(fmt, ...)   printf(pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_debug(fmt, ...) printf(pr_fmt(fmt), ##__VA_ARGS__)
+
+#endif /* __TOOLS_KERNEL_PRINTK__ */
-- 
2.9.2


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


[Xen-devel] [PATCH v1 4/7] tools: add __used and enable to override

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

This adds __used, to be used later in the userspace linker-tables
sandbox. If any userspace applicaiton wants to override they can
add their own definition and then use include_next.

This definition should probably suffice for most uses cases though.

Signed-off-by: Luis R. Rodriguez 
---
 tools/include/linux/compiler.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index e33fc1df3935..556c991de212 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -5,6 +5,12 @@
 /* The "volatile" is due to gcc bugs */
 #define barrier() __asm__ __volatile__("": : :"memory")
 
+
+/* You can override as you see fit on your userspace tool */
+#ifndef __used
+#define __used  __attribute__((__used__))
+#endif
+
 #ifndef __always_inline
 # define __always_inline   inline __attribute__((always_inline))
 #endif
-- 
2.9.2


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


[Xen-devel] [PATCH v4 15/16] kprobes: port .kprobes.text to section range

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

kprobe makes use of two custom sections, each custom section
is folded into one of the standard Linux sections types as follows,
it currently relies on the linker script to fold the custom section
onto the respective Linux section:

type  Linux-section custom section name  beginend
table .init.data_kprobe_blacklist__start_kprobe_blacklist 
__stop_kprobe_blacklist
range .text .kprobes.text__kprobes_text_start 
__kprobes_text_end

This ports the .kprobes.text custom section to the standard
Linux ranges API allowing us remove all the custom kprobe section
declarations from the linker script.

Tested with CONFIG_KPROBES_SANITY_TEST, it passes with:

Kprobe smoke test: started
Kprobe smoke test: passed successfully

Then tested CONFIG_SAMPLE_KPROBES on do_fork, and the kprobe bites
and kicks as expected.

Also ran ./ftracetest with no issues:

$ sudo ./ftracetest
=== Ftrace unit tests ===
[1] Basic trace file check  [PASS]
[2] Basic test for tracers  [PASS]
[3] Basic trace clock test  [PASS]
[4] Basic event tracing check   [PASS]
[5] event tracing - enable/disable with event level files   [PASS]
[6] event tracing - restricts events based on pid   [PASS]
[7] event tracing - enable/disable with subsystem level files   [PASS]
[8] event tracing - enable/disable with top level files [PASS]
[9] ftrace - function graph filters with stack tracer   [PASS]
[10] ftrace - function graph filters[PASS]
[11] ftrace - function profiler with function tracing   [PASS]
[12] Test creation and deletion of trace instances while setting an event[PASS]
[13] Test creation and deletion of trace instances  [PASS]
[14] Kprobe dynamic event - adding and removing [PASS]
[15] Kprobe dynamic event - busy event check[PASS]
[16] Kprobe dynamic event with arguments[PASS]
[17] Kprobe dynamic event with function tracer  [PASS]
[18] Kretprobe dynamic event with arguments [PASS]
[19] event trigger - test event enable/disable trigger  [PASS]
[20] event trigger - test trigger filter[PASS]
[21] event trigger - test histogram modifiers   [PASS]
[22] event trigger - test histogram trigger [PASS]
[23] event trigger - test multiple histogram triggers   [PASS]
[24] event trigger - test snapshot-trigger  [PASS]
[25] event trigger - test stacktrace-trigger[PASS]
[26] event trigger - test traceon/off trigger   [PASS]

 # of passed:  26
 # of failed:  0
 # of unresolved:  0
 # of untested:  0
 # of unsupported:  0
 # of xfailed:  0
 # of undefined(test bug):  0

v4:

o arm64 build fixes with allmodconfig

o build fix suggested for avr32 with allnoconfig, otherwise we end up with:

arch/avr32/kernel/built-in.o: In function `save_full_context_ex':
(.ex.text+0x1c4): relocation truncated to fit: R_AVR32_16N_PCREL against
symbol `debug_trampoline' defined in .text.rng.kprobes.any section in
arch/avr32/kernel/built-in.o
arch/avr32/kernel/built-in.o: In function `debug_exit_work':
(.text.rng.kprobes.any+0xa8): relocation truncated to fit:
R_AVR32_16N_PCREL against `.ex.text'+3aa
make: *** [Makefile:953: vmlinux] Error 1

o open-code section use on scripts/ code -- folks to prefer the
  simplicity over dealing with having more tool code access kernel
  headers.

o NOPE: include #include  on compiler.h -- solves
  a few 0-day compilation issues

v3:

o after v2 arch/arm/kernel/vmlinux-xip.lds.S got kprobe support,
  this just removes the custom linker script reference to kprobes as
  that is no longer needed with linker tables.

o split kprobe linker table and kprobe section ranges use into
  two separate patches. This should make it easier to review and
  also demos both distinct use types, one a linker table another
  a simple section range.

v2: introduced this patch in this series

Signed-off-by: Luis R. Rodriguez 
---
 arch/arc/kernel/vmlinux.lds.S|  1 -
 arch/arm/kernel/entry-armv.S |  3 ++-
 arch/arm/kernel/vmlinux-xip.lds.S|  1 -
 arch/arm/kernel/vmlinux.lds.S|  1 -
 arch/arm64/kernel/armv8_deprecated.c |  1 +
 arch/arm64/kernel/probes/kprobes.c   |  4 ++--
 arch/arm64/kernel/vmlinux.lds.S  |  1 -
 arch/avr32/kernel/entry-avr32b.S | 13 +++--
 arch/avr32/kernel/vmlinux.lds.S  |  1 -
 arch/blackfin/kernel/vmlinux.lds.S   |  1 -
 arch/c6x/kernel/vmlinux.lds.S|  1 -
 arch/hexagon/kernel/vmlinux.lds.S|  1 -
 arch/ia64/kernel/jprobes.S   |  3 ++-
 arch/ia64/kernel/vmlinux.lds.S   |  1 -
 arch/ia64/lib/flush.S|  6 +++---
 arch/metag/kernel/vmlinux.lds.S  |  1 -
 arch/microblaze/kernel/vmlinux.lds.S |  1 -
 arch/mips/kernel/vmlinux.lds.S   |  1 -
 arch/mn10300/kernel/vmlinux.lds.S|  1 -
 arch/nios2/kernel/vmlinux.lds.S  |  1 -
 arch/openrisc/kernel/vmlinux.lds.S   |  1 -
 arch/parisc/kernel/vmlinux.lds.S |  1 -
 arch/powerpc/include/asm/ppc_asm.h   |  7 ---
 

[Xen-devel] [PATCH v4 09/16] firmware/Makefile: force recompilation if makefile changes

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

If you modify the target asm we currently do not force the
recompilation of the firmware files. The target asm is in
the firmware/Makefile, peg this file as a dependency to
require re-compilation of firmware targets when the asm
changes.

v3: introduced in this series

Signed-off-by: Luis R. Rodriguez 
---
 firmware/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/firmware/Makefile b/firmware/Makefile
index e297e1b52636..fa3e81c2a97b 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -176,7 +176,8 @@ quiet_cmd_fwbin = MK_FW   $@
 wordsize_deps := $(wildcard include/config/64bit.h include/config/32bit.h \
include/config/ppc32.h include/config/ppc64.h \
include/config/superh32.h include/config/superh64.h \
-   include/config/x86_32.h include/config/x86_64.h)
+   include/config/x86_32.h include/config/x86_64.h \
+   firmware/Makefile)
 
 $(patsubst %,$(obj)/%.gen.S, $(fw-shipped-y)): %: $(wordsize_deps)
$(call cmd,fwbin,$(patsubst %.gen.S,%,$@))
-- 
2.9.2


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


[Xen-devel] [PATCH v4 13/16] dynamic_debug: port to use linker tables

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

This removes the custom vmlinux.lds.h hacks and uses
the generalized solution for .data (SECTION_DATA)
entries.

This is much more potential for further fine tuning here
though in the future. For instance, linker tables enable
an extra postfix for order level annotations, this could
easily be used as the KBUILD_MODNAME and with a bit of
linker table changes we may be able to get a direct O(1)
count of the entries for that KBUILD_MODNAME: it would
just be a count on the number of entries for the given
order level. This should help make dynamic_debug_init()
cleaner and also reduce the amount of time it takes at
boot time. Instead of iterating over each print until we
have all for a KBUILD_MODNAME, we'd instead directly
operate on each KBUILD_MODNAME directly.

Tested dynamic debug with dyndbg query ana debugfs control
and it works as expected, for both built-in code and modules.

v4: fix compilation on blackfin
v3: added modular support
v2: introduced this patch into the series

Cc: Barry Song 
Cc: Mike Frysinger 
Cc: Steven Miao 
Cc: Michael Matz 
Cc: Guenter Roeck 
Cc: Fengguang Wu 
Signed-off-by: Luis R. Rodriguez 
---
 include/asm-generic/vmlinux.lds.h |  5 -
 include/linux/dynamic_debug.h |  5 +++--
 lib/dynamic_debug.c   | 13 ++---
 scripts/module-common.lds.S   |  1 +
 4 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h 
b/include/asm-generic/vmlinux.lds.h
index 140fbed4a817..ba49b7ad7af2 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -211,11 +211,6 @@
*(.data.unlikely)   \
STRUCT_ALIGN(); \
*(__tracepoints)\
-   /* implement dynamic printk debug */\
-   . = ALIGN(8);   \
-   VMLINUX_SYMBOL(__start___verbose) = .;  \
-   *(__verbose)\
-   VMLINUX_SYMBOL(__stop___verbose) = .;   \
LIKELY_PROFILE()\
BRANCH_PROFILE()\
TRACE_PRINTKS() \
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index 546d68057e3b..a52618a77b09 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -4,6 +4,7 @@
 #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
 #include 
 #endif
+#include 
 
 /*
  * An instance of this structure is created in a special
@@ -50,6 +51,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
const char *modname);
 
 #if defined(CONFIG_DYNAMIC_DEBUG)
+DECLARE_LINKTABLE(struct _ddebug, __verbose);
 extern int ddebug_remove_module(const char *mod_name);
 extern __printf(2, 3)
 void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...);
@@ -71,8 +73,7 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor,
  const char *fmt, ...);
 
 #define DEFINE_DYNAMIC_DEBUG_METADATA_KEY(name, fmt, key, init)\
-   static struct _ddebug  __aligned(8) \
-   __attribute__((section("__verbose"))) name = {  \
+   static LINKTABLE(__verbose, SECTION_ORDER_ANY) name = { \
.modname = KBUILD_MODNAME,  \
.function = __func__,   \
.filename = __FILE__,   \
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index da796e2dc4f5..f0060c84c654 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -37,8 +37,7 @@
 #include 
 #include 
 
-extern struct _ddebug __start___verbose[];
-extern struct _ddebug __stop___verbose[];
+DEFINE_LINKTABLE(struct _ddebug, __verbose);
 
 struct ddebug_table {
struct list_head link;
@@ -978,14 +977,14 @@ static int __init dynamic_debug_init(void)
int n = 0, entries = 0, modct = 0;
int verbose_bytes = 0;
 
-   if (__start___verbose == __stop___verbose) {
-   pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG 
build\n");
+   if (LINUX_SECTION_EMPTY(__verbose)) {
+   pr_warn("dynamic debug linker table empty on 
CONFIG_DYNAMIC_DEBUG build\n");
return 1;
}
-   iter = __start___verbose;
+   iter = LINUX_SECTION_START(__verbose);
modname = iter->modname;
iter_start = iter;
-   for (; iter < __stop___verbose; iter++) {
+   LINKTABLE_FOR_EACH(iter, __verbose) {

[Xen-devel] [PATCH v4 16/16] kprobes: port blacklist kprobes to linker table

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

kprobe makes use of two sections, the one dealing with the actual
kprobes was recently ported using the standard section range API.
The blacklist functionality of kprobes is still using a custom
section and declaring its custom section using the linker script
as follows:

type  Linux-section custom section name  beginend
table .init.data_kprobe_blacklist__start_kprobe_blacklist 
__stop_kprobe_blacklist

This ports the _kprobe_blacklist custom section to the standard
Linux linker table API allowing us remove all the custom blacklist
kprobe section declarations from the linker script.

This has been tested by trying to register a kprobe on a blacklisted
symbol (these are declared with NOKPROBE_SYMBOL()), and confirms that
this fails to work as expected. This was tested with:

 # insmod samples/kprobes/kprobe_example.ko symbol="get_kprobe"

This fails to load as expected with:

insmod: ERROR: could not insert module samples/kprobes/kprobe_example.ko: 
Invalid parameters

v3: this patch was introduced in this series

Acked-by: Masami Hiramatsu 
Signed-off-by: Luis R. Rodriguez 
---
 include/asm-generic/kprobes.h |  4 ++--
 include/asm-generic/vmlinux.lds.h | 10 --
 include/linux/kprobes.h   |  2 ++
 kernel/kprobes.c  | 11 ---
 4 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/include/asm-generic/kprobes.h b/include/asm-generic/kprobes.h
index 7b986f4b7ccd..23a49a4c7a38 100644
--- a/include/asm-generic/kprobes.h
+++ b/include/asm-generic/kprobes.h
@@ -3,14 +3,14 @@
 
 #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
 #ifdef CONFIG_KPROBES
+#include 
 #include 
 /*
  * Blacklist ganerating macro. Specify functions which is not probed
  * by using this macro.
  */
 # define __NOKPROBE_SYMBOL(fname)  \
-static unsigned long __used\
-   __attribute__((__section__("_kprobe_blacklist")))   \
+static LINKTABLE_INIT_DATA(_kprobe_blacklist, all) \
_kbl_addr_##fname = (unsigned long)fname;
 # define NOKPROBE_SYMBOL(fname)__NOKPROBE_SYMBOL(fname)
 /* Use this to forbid a kprobes attach on very low level functions */
diff --git a/include/asm-generic/vmlinux.lds.h 
b/include/asm-generic/vmlinux.lds.h
index f2444d82d02a..47ef04de9958 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -114,15 +114,6 @@
 #define BRANCH_PROFILE()
 #endif
 
-#ifdef CONFIG_KPROBES
-#define KPROBE_BLACKLIST() . = ALIGN(8); \
-   VMLINUX_SYMBOL(__start_kprobe_blacklist) = .; \
-   *(_kprobe_blacklist)  \
-   VMLINUX_SYMBOL(__stop_kprobe_blacklist) = .;
-#else
-#define KPROBE_BLACKLIST()
-#endif
-
 #ifdef CONFIG_EVENT_TRACING
 #define FTRACE_EVENTS(). = ALIGN(8);   
\
VMLINUX_SYMBOL(__start_ftrace_events) = .;  \
@@ -525,7 +516,6 @@
*(SECTION_INIT_RODATA)  \
FTRACE_EVENTS() \
TRACE_SYSCALLS()\
-   KPROBE_BLACKLIST()  \
MEM_DISCARD(init.rodata)\
CLK_OF_TABLES() \
RESERVEDMEM_OF_TABLES() \
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 445cc6fe7afa..2707820cbb56 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -44,8 +44,10 @@
 
 #ifdef CONFIG_KPROBES
 #include 
+#include 
 
 DECLARE_SECTION_RANGE(kprobes);
+DECLARE_LINKTABLE(unsigned long, _kprobe_blacklist);
 
 /* kprobe_status settings */
 #define KPROBE_HIT_ACTIVE  0x0001
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 387605682622..4801aa3b4adf 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -2053,14 +2053,13 @@ NOKPROBE_SYMBOL(dump_kprobe);
  * since a kprobe need not necessarily be at the beginning
  * of a function.
  */
-static int __init populate_kprobe_blacklist(unsigned long *start,
-unsigned long *end)
+static int __init populate_kprobe_blacklist(void)
 {
unsigned long *iter;
struct kprobe_blacklist_entry *ent;
unsigned long entry, offset = 0, size = 0;
 
-   for (iter = start; iter < end; iter++) {
+   LINKTABLE_FOR_EACH(iter, _kprobe_blacklist) {
entry = arch_deref_entry_point((void *)*iter);
 
if (!kernel_text_address(entry) ||
@@ -2125,8 +2124,7 @@ static struct notifier_block kprobe_module_nb = {
 };
 
 /* Markers of _kprobe_blacklist section */

[Xen-devel] [PATCH v4 08/16] kbuild: enable option to force compile force-obj-y and force-lib-y

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

Linux provides a rich array of features, enabling each feature
however increases the size of the kernel and there are many
features which users often want disabled. The traditional
solution to this problem is for each feature to have its own
Kconfig symbol, followed by a series of #ifdef statements
in C code and header files, allowing the feature to be compiled
only when desirable. As the variability of Linux increases build
tests can and are often done with random kernel configurations,
allyesconfig, and allmodconfig to help find code issues. This
however doesn't catch all errors and as a consequence code that
is typically not enabled often can suffer from bit-rot over time.

An alternative approach for subsystems, which refer to as the 'build-all
link-selectively philosophy' is to keep the Kconfig symbols, replace
the #ifdef approach by having each feature implemented it its own C file,
and force compilation for all features to avoid the code bit-rot problem.
With this strategy only features that are enabled via Kconfig get
linked into the kernel, so the forced compilation has no size impact
on the kernel. The practice of having each feature implemented in its own
C file is already prevalent in many subsystems, however #ifdefs are still
typically required during feature initialization. For instance in:

  #ifdef CONFIG_FOO
  foo_init();
  #endif

We cannot remove the #ifdef and leave foo_init() as we'd either
need to always enable the feature or add a respective #ifdef in a
foo.h which makes foo_init() do nothing when CONFIG_FOO is disabled.

Linker tables enable lifting the requirement to use of #ifdefs during
initialization. With linker tables initialization sequences can instead
be aggregated into a custom ELF section at link time, during run time
the table can be iterated over and each init sequence enabled can be called.
A feature's init routine is only added to a table when its respective
Kconfig symbols has been enabled and therefore linked in. Linker tables
enable subsystems to completely do away with #ifdefs if one is comfortable
in accepting all subsystem's feature's structural size implications.

Subsystems which want to follow the 'build-all link-selectively
philosophy' still need a way to easily express and annotate that they
wish for all code to always be compiled to help avoid code bit rot,
as such two new targets force-obj-y and force-lib-y are provided to
help with this. Its not fair to require everyone to force compilation
of all features of a subsystem though, so as a compromise, the new
targets only force compilation when CONFIG_BUILD_AVOID_BITROT is
enabled.

Only built-in features are supported at the moment. Module support
is expected to be added after a generic solution to add linker
tables to modules more easily is developed.

v4: this patch was added to this series, it was split off from the
linker tables addition due to the confusion over the code bit
rot alternatives that are possible with linker tables.

Signed-off-by: Luis R. Rodriguez 
---
 Documentation/kbuild/makefiles.txt   | 36 
 Documentation/sections/linker-tables.rst | 15 +++
 include/linux/tables.h   | 71 
 init/Kconfig | 22 ++
 scripts/Makefile.build   |  7 ++--
 scripts/Makefile.lib | 11 +
 6 files changed, 159 insertions(+), 3 deletions(-)

diff --git a/Documentation/kbuild/makefiles.txt 
b/Documentation/kbuild/makefiles.txt
index 385a5ef41c17..01c260913f5c 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -1089,6 +1089,42 @@ When kbuild executes, the following steps are followed 
(roughly):
In this example, extra-y is used to list object files that
shall be built, but shall not be linked as part of built-in.o.
 
+force-obj-y force-lib-y
+
+   When CONFIG_BUILD_AVOID_BITROT is enabled using these targets for your
+   kconfig symbols forces compilation of the associated objects if the
+   kconfig's symbol's dependencies are met, the objects however are only
+   linked into to the kernel if and only if the kconfig symbol was
+   enabled. If CONFIG_BUILD_AVOID_BITROT is disabled the force-obj-y and
+   force-lib-y targets are functionally equilvalent to obj-y and lib-y
+   respectively.
+
+   Using force-obj-y and force-lib-y are part of a code architecture and
+   build philosophy further enabled by linker tables, for more details
+   refer to the documention in include/linux/tables.h, refer to the
+   sections:
+
+   o The code bit-rot problem
+   o The build-all selective-link philosophy
+   o Avoiding the code bit-rot problem with linker tables
+   o Linker table module support
+
+   Modules support is expected to be enhanced in the 

[Xen-devel] [PATCH v4 06/16] ranges.h: add helpers to build and identify Linux section ranges

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

Section ranges are on one of the types of custom sections
types used in Linux. This provides a series of helpers for
defining them and using them. Most importantly this also
enables us to avoid modifying the linker script when we
add a new section range.

It turns out a lot of custom sections are actually section ranges,
and these are typically spelled out in their architecture specific
asm/sections.h file -- we anable architectures to override what asm
is used for section ranges but start by default trusting the
asm-generic version all around.

v4:

o tons of documentation love
o fix arch/x86/tools/relocs.c typo - which caused compilation issues
  on old toolchains
o port to new shiny sphinx documentation
o sprinkle a few more needed VMLINUX_SYMBOL() - fixes
  compilation on blackfin
o name changes as suggested 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
- rebrand DECLARE_SECTION_RNG() as DEFINE_SECTION_RANGE() - this is
  the asm version of the respective C version, this will have a
  userspace C demo added later.
o move __LINUX_RANGE() and __LINUX_RANGE_ORDER() - fixes builds
  on sparc
o adds section ranges to linker script
o rename SECTION_RANGE_ALL()
o use default alignment, fixes builds on powerpc and arm for both
  __LINUX_RANGE() and __LINUX_RANGE_ORDER()
o expand documentation to document modules support
o add maintainers
o use generic-y

v3: new in this series, uses copyleft-next

Signed-off-by: Luis R. Rodriguez 
---
 Documentation/sections/index.rst   |   1 +
 Documentation/sections/ranges.rst  |  49 ++
 MAINTAINERS|  10 +++
 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/Kbuild  |   1 +
 arch/x86/include/asm/Kbuild|   1 +
 arch/x86/tools/relocs.c|   2 +
 arch/xtensa/include/asm/Kbuild |   1 +
 include/asm-generic/ranges.h   |  89 ++
 include/asm-generic/vmlinux.lds.h  |  12 +++-
 include/linux/ranges.h | 128 +
 38 files changed, 320 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/sections/ranges.rst
 create mode 100644 include/asm-generic/ranges.h
 create mode 100644 include/linux/ranges.h

diff --git a/Documentation/sections/index.rst b/Documentation/sections/index.rst
index d411e9b22eb3..6dd93ddd5dbe 100644
--- a/Documentation/sections/index.rst
+++ b/Documentation/sections/index.rst
@@ -9,3 +9,4 @@ used throughout the kernel to help declare and define them.
:maxdepth: 4
 
section-core
+   ranges
diff --git a/Documentation/sections/ranges.rst 
b/Documentation/sections/ranges.rst
new file mode 100644
index ..1293dcb3ab38
--- /dev/null
+++ b/Documentation/sections/ranges.rst
@@ -0,0 +1,49 @@
+
+Linux section ranges
+
+
+This documents Linux' use of section ranges, how you can use
+them and how they work.
+
+About section ranges
+
+
+Introduction
+
+.. kernel-doc:: include/linux/ranges.h
+   :doc: Introduction
+
+Section range module support
+
+.. kernel-doc:: include/linux/ranges.h
+   :doc: Section range module support
+
+Section range helpers
+=
+.. kernel-doc:: include/linux/ranges.h
+   :doc: Section range helpers
+
+DECLARE_SECTION_RANGE
+-
+.. kernel-doc:: include/linux/ranges.h
+   :functions: DECLARE_SECTION_RANGE
+
+DEFINE_SECTION_RANGE
+
+.. kernel-doc:: include/linux/ranges.h
+   :functions: DEFINE_SECTION_RANGE
+
+SECTION_ADDR_IN_RANGE
+-

[Xen-devel] [PATCH v4 11/16] jump_label: move guard #endif down where it belongs

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

The ending header guard is misplaced. This has no
functional change, this is just an eye-sore.

Signed-off-by: Luis R. Rodriguez 
---
 include/linux/jump_label.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 661af564fae8..1256f543b002 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -384,6 +384,6 @@ extern bool wrong_branch_error(void);
 #define static_branch_enable(x)static_key_enable(&(x)->key)
 #define static_branch_disable(x)   static_key_disable(&(x)->key)
 
-#endif /* _LINUX_JUMP_LABEL_H */
-
 #endif /* __ASSEMBLY__ */
+
+#endif /* _LINUX_JUMP_LABEL_H */
-- 
2.9.2


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


[Xen-devel] [PATCH v4 05/16] xtensa: skip adding literal when SORT() is used

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

When SORT(foo.*) is used the current sed replacements add
SORT(foo.literal foo.*), this breaks linking. Avoid adding
literals for SORT globs, if needed, these need to be added
manually.

Signed-off-by: Luis R. Rodriguez 
---
 arch/xtensa/kernel/Makefile | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/xtensa/kernel/Makefile b/arch/xtensa/kernel/Makefile
index c31f5d5afc7d..8180850ed147 100644
--- a/arch/xtensa/kernel/Makefile
+++ b/arch/xtensa/kernel/Makefile
@@ -29,10 +29,10 @@ AFLAGS_mxhead.o += -mtext-section-literals
 #
 # Replicate rules in scripts/Makefile.build
 
-sed-y = -e ':a; s/\*(\([^)]*\)\.text\.unlikely/*(\1.literal.unlikely 
.{text}.unlikely/; ta; ' \
-   -e ':b; s/\*(\([^)]*\)\.text\(\.[a-z]*\)/*(\1.{text}\2.literal 
.{text}\2/; tb; ' \
-   -e ':c; s/\*(\([^)]*\)\(\.[a-z]*it\|\.ref\)\.text/*(\1\2.literal 
\2.{text}/; tc; ' \
-   -e ':d; s/\*(\([^)]\+ \|\)\.text/*(\1.literal .{text}/; td; ' \
+sed-y = -e ':a; s/\*(\([^)SORT]*\)\.text\.unlikely/*(\1.literal.unlikely 
.{text}.unlikely/; ta; ' \
+   -e ':b; s/\*(\([^)SORT]*\)\.text\(\.[a-z]*\)/*(\1.{text}\2.literal 
.{text}\2/; tb; ' \
+   -e ':c; s/\*(\([^SORT)]*\)\(\.[a-z]*it\|\.ref\)\.text/*(\1\2.literal 
\2.{text}/; tc; ' \
+   -e ':d; s/\*(\([^SORT)]\+ \|\)\.text/*(\1.literal .{text}/; td; ' \
-e 's/\.{text}/.text/g'
 
 quiet_cmd__cpp_lds_S = LDS $@
-- 
2.9.2


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


[Xen-devel] [PATCH v4 12/16] jump_label: port __jump_table to linker tables

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

Move the __jump_table from the a custom section solution
to a generic solution, this avoiding extra vmlinux.lds.h
customizations.

This also demos the use of the .data (SECTION_DATA) linker
table and of the shared asm call push_section_tbl().

Built-in kernel functionality was tested with CONFIG_STATIC_KEYS_SELFTEST.
Moduler  kernel functionality was tested with CONFIG_TEST_STATIC_KEYS.
Both work as expected.

Since __jump_table sections are also supported per
module this also required expanding module-common.lds.S
to capture and fold all .data.tlb.__jump_table.* onto
the the section __jump_table -- in this case for modules
need to keep a reference in place, given the alternative
is to use DEFINE_LINKTABLE(struct jump_entry, __jump_table)
per module -- and later through macro hacks instantiate
the jump entries per module upon init. This is doable but
we'd loose out on the sorting of the table using the
linker, to sort we'd always still need to expand the
module common linker script. An alternative mechanism
is possible which would make these custom module sections
extensions dynamic without requiring manual changes, this
however is best done later through a separate evolution
once linker tables are in place.

A careful reviewer may note that some architectures use
"\n\t" to separate asm code, while others just use a new line.
Upon review last time it was deemed reasonable to for all
architectures to just use "\n", this is defined as ASM_CMD_SEP,
and if an architecture needs to override they can do so on their
architecture sections.h prior to including asm-generic/sections.h

v4:

o Some architectures allow linker scripts to follow including header
  files, some others do not, so if you need a helper on a linker script
  you need to explicitly include it. So for instance although
  scripts/module-common.lds.S includes  and this file
  includes , you still need to explicitly
  include it on the linker script. This issue is present on ARM.

o as per Josh Poimboeuf open code the section table name instead
  of including the kernel section headers, the simplicity and
  independence from the kernel is preferred.

v3:

o More elaborate tests performed
o first modular support use case, module tested was
  CONFIG_TEST_STATIC_KEYS (lib/test_static_keys.ko), this
  required us to extend module-common.lds.S
o use generic push_section_tbl_any() for all architectures
o Makes use of ASM_CMD_SEP to enable architectures to override later
  if needed
o guard tables.h inclusion and table definition with __KERNEL__

v2: introduced in this series

Signed-off-by: Luis R. Rodriguez 
---
 arch/arm/include/asm/jump_label.h |  6 --
 arch/arm64/include/asm/jump_label.h   |  6 --
 arch/mips/include/asm/jump_label.h|  6 --
 arch/powerpc/include/asm/jump_label.h |  8 +---
 arch/s390/include/asm/jump_label.h|  6 --
 arch/sparc/include/asm/jump_label.h   |  6 --
 arch/x86/include/asm/jump_label.h | 10 ++
 include/asm-generic/vmlinux.lds.h |  4 
 include/linux/jump_label.h|  4 ++--
 kernel/jump_label.c   | 17 ++---
 scripts/module-common.lds.S   |  5 +
 tools/objtool/special.c   |  2 +-
 12 files changed, 49 insertions(+), 31 deletions(-)

diff --git a/arch/arm/include/asm/jump_label.h 
b/arch/arm/include/asm/jump_label.h
index 34f7b6980d21..960135a7b88e 100644
--- a/arch/arm/include/asm/jump_label.h
+++ b/arch/arm/include/asm/jump_label.h
@@ -1,6 +1,8 @@
 #ifndef _ASM_ARM_JUMP_LABEL_H
 #define _ASM_ARM_JUMP_LABEL_H
 
+#include 
+
 #ifndef __ASSEMBLY__
 
 #include 
@@ -12,7 +14,7 @@ static __always_inline bool arch_static_branch(struct 
static_key *key, bool bran
 {
asm_volatile_goto("1:\n\t"
 WASM(nop) "\n\t"
-".pushsection __jump_table,  \"aw\"\n\t"
+push_section_tbl_any(SECTION_DATA, __jump_table, aw)
 ".word 1b, %l[l_yes], %c0\n\t"
 ".popsection\n\t"
 : :  "i" (&((char *)key)[branch]) :  : l_yes);
@@ -26,7 +28,7 @@ static __always_inline bool arch_static_branch_jump(struct 
static_key *key, bool
 {
asm_volatile_goto("1:\n\t"
 WASM(b) " %l[l_yes]\n\t"
-".pushsection __jump_table,  \"aw\"\n\t"
+push_section_tbl_any(SECTION_DATA, __jump_table, aw)
 ".word 1b, %l[l_yes], %c0\n\t"
 ".popsection\n\t"
 : :  "i" (&((char *)key)[branch]) :  : l_yes);
diff --git a/arch/arm64/include/asm/jump_label.h 
b/arch/arm64/include/asm/jump_label.h
index 1b5e0e843c3a..aa52cd2607e3 100644
--- a/arch/arm64/include/asm/jump_label.h
+++ b/arch/arm64/include/asm/jump_label.h
@@ -19,6 +19,8 @@
 #ifndef __ASM_JUMP_LABEL_H
 #define __ASM_JUMP_LABEL_H
 
+#include 
+
 #ifndef __ASSEMBLY__
 
 #include 
@@ -29,7 +31,7 @@
 static __always_inline bool arch_static_branch(struct 

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

2016-08-19 Thread mcgrof
tions: DEFINE_LINKTABLE_TEXT
+
+DEFINE_LINKTABLE_RO
+---
+.. kernel-doc:: include/linux/tables.h
+   :functions: DEFINE_LINKTABLE_RO
+
+DEFINE_LINKTABLE_INIT
+-
+.. kernel-doc:: include/linux/tables.h
+   :functions: DEFINE_LINKTABLE_INIT
+
+DEFINE_LINKTABLE_INIT_DATA
+--
+.. kernel-doc:: include/linux/tables.h
+   :functions: DEFINE_LINKTABLE_INIT_DATA
+
+Iterating over Linker tables
+
+
+.. kernel-doc:: include/linux/tables.h
+   :doc: Iterating over Linker tables
+
+LINKTABLE_FOR_EACH
+--
+.. kernel-doc:: include/linux/tables.h
+   :functions: LINKTABLE_FOR_EACH
+
+LINKTABLE_RUN_ALL
+-
+.. kernel-doc:: include/linux/tables.h
+   :functions: LINKTABLE_RUN_ALL
+
+LINKTABLE_RUN_ERR
+-
+.. kernel-doc:: include/linux/tables.h
+   :functions: LINKTABLE_RUN_ERR
diff --git a/MAINTAINERS b/MAINTAINERS
index 1a217751aa8a..e3569ed12c86 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5200,6 +5200,18 @@ S:   Maintained
 F: include/asm-generic/
 F: include/uapi/asm-generic/
 
+GENERIC LINKER TABLES
+M: "Luis R. Rodriguez" <mcg...@kernel.org>
+M: "H. Peter Anvin" <h...@zytor.com>
+L: linux-a...@vger.kernel.org
+L: linux-ker...@vger.kernel.org
+T: git git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git 
sections
+T: git git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git 
sections
+S: Supported
+F: include/asm-generic/tables.h
+F: include/linux/tables.h
+F: Documentation/sections/linker-tables.rst
+
 GENERIC PHY FRAMEWORK
 M: Kishon Vijay Abraham I <kis...@ti.com>
 L: linux-ker...@vger.kernel.org
diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild
index e44c896b91c4..f3bdc31d3c97 100644
--- a/arch/alpha/include/asm/Kbuild
+++ b/arch/alpha/include/asm/Kbuild
@@ -12,3 +12,4 @@ generic-y += sections.h
 generic-y += trace_clock.h
 generic-y += section-core.h
 generic-y += ranges.h
+generic-y += tables.h
diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
index e5295413fdf8..70f252472cb9 100644
--- a/arch/arc/include/asm/Kbuild
+++ b/arch/arc/include/asm/Kbuild
@@ -52,3 +52,4 @@ generic-y += word-at-a-time.h
 generic-y += xor.h
 generic-y += section-core.h
 generic-y += ranges.h
+generic-y += tables.h
diff --git a/arch/arm/include/asm/Kbuild b/arch/arm/include/asm/Kbuild
index 8e52300e1eed..d13700f573d0 100644
--- a/arch/arm/include/asm/Kbuild
+++ b/arch/arm/include/asm/Kbuild
@@ -41,3 +41,4 @@ generic-y += trace_clock.h
 generic-y += unaligned.h
 generic-y += section-core.h
 generic-y += ranges.h
+generic-y += tables.h
diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
index 5ff184574976..a1991517aad6 100644
--- a/arch/arm64/include/asm/Kbuild
+++ b/arch/arm64/include/asm/Kbuild
@@ -54,3 +54,4 @@ generic-y += vga.h
 generic-y += xor.h
 generic-y += section-core.h
 generic-y += ranges.h
+generic-y += tables.h
diff --git a/arch/avr32/include/asm/Kbuild b/arch/avr32/include/asm/Kbuild
index edc176348d7c..a6cd145515ae 100644
--- a/arch/avr32/include/asm/Kbuild
+++ b/arch/avr32/include/asm/Kbuild
@@ -24,3 +24,4 @@ generic-y += word-at-a-time.h
 generic-y += xor.h
 generic-y += section-core.h
 generic-y += ranges.h
+generic-y += tables.h
diff --git a/arch/blackfin/include/asm/Kbuild b/arch/blackfin/include/asm/Kbuild
index 35b7752e65c0..b71893b1cd53 100644
--- a/arch/blackfin/include/asm/Kbuild
+++ b/arch/blackfin/include/asm/Kbuild
@@ -50,3 +50,4 @@ generic-y += word-at-a-time.h
 generic-y += xor.h
 generic-y += section-core.h
 generic-y += ranges.h
+generic-y += tables.h
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 <mcg...@kernel.org>
+ *
+ * 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.
+ *
+ * [0] https://lkml.kernel.org/r/1470798247.3551.94.ca...@redhat.com
+ */
+
+#define SECTION_TBL_RO .const
+
+#include 
+
+#endif /* _ASM_C6X_ASM_TABLES_H */
diff --git a/arch/cris/include/asm/Kbuild b/arch/cris/include/asm/Kbuild
index fb8bb4112773..7062c1be79

[Xen-devel] [PATCH v4 10/16] firmware: port built-in section to linker table

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

This ports built-in firmware to use linker tables,
this replaces the custom section solution with a
generic solution.

This also demos the use of the .rodata (SECTION_RO)
linker tables.

Tested with 0 built-in firmware, 1 and 2 built-in
firmwares successfully.

v4:

o work around c6x toolchain bug by using SECTION_TBL_RO

o fix compilation on blackfin

v3:
o explicitly include tables.h as we no longer include
  tables.h from sections.h

o use new section_tbl_asmtype() helper on firmware/Makefile
  to enable having to unfold things on our own.

v2: introduced this file in this version of the series

Cc: Barry Song 
Cc: Mike Frysinger 
Cc: Steven Miao 
Cc: Michael Matz 
Cc: Guenter Roeck 
Cc: Fengguang Wu 
Signed-off-by: Luis R. Rodriguez 
---
 arch/x86/kernel/cpu/microcode/core.c |  8 
 drivers/base/firmware_class.c| 12 ++--
 firmware/Makefile|  3 ++-
 include/asm-generic/vmlinux.lds.h|  7 ---
 4 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c 
b/arch/x86/kernel/cpu/microcode/core.c
index df04b2d033f6..3e7c08d99601 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -91,15 +92,14 @@ static bool __init check_loader_disabled_bsp(void)
return *res;
 }
 
-extern struct builtin_fw __start_builtin_fw[];
-extern struct builtin_fw __end_builtin_fw[];
+DECLARE_LINKTABLE_RO(struct builtin_fw, builtin_fw);
 
 bool get_builtin_firmware(struct cpio_data *cd, const char *name)
 {
 #ifdef CONFIG_FW_LOADER
-   struct builtin_fw *b_fw;
+   const struct builtin_fw *b_fw;
 
-   for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) {
+   LINKTABLE_FOR_EACH(b_fw, builtin_fw) {
if (!strcmp(name, b_fw->name)) {
cd->size = b_fw->size;
cd->data = b_fw->data;
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 22d1760a4278..8fbf03c3e4c2 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -43,15 +44,14 @@ MODULE_LICENSE("GPL");
 
 #ifdef CONFIG_FW_LOADER
 
-extern struct builtin_fw __start_builtin_fw[];
-extern struct builtin_fw __end_builtin_fw[];
+DEFINE_LINKTABLE_RO(struct builtin_fw, builtin_fw);
 
 static bool fw_get_builtin_firmware(struct firmware *fw, const char *name,
void *buf, size_t size)
 {
-   struct builtin_fw *b_fw;
+   const struct builtin_fw *b_fw;
 
-   for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) {
+   LINKTABLE_FOR_EACH(b_fw, builtin_fw) {
if (strcmp(name, b_fw->name) == 0) {
fw->size = b_fw->size;
fw->data = b_fw->data;
@@ -67,9 +67,9 @@ static bool fw_get_builtin_firmware(struct firmware *fw, 
const char *name,
 
 static bool fw_is_builtin_firmware(const struct firmware *fw)
 {
-   struct builtin_fw *b_fw;
+   const struct builtin_fw *b_fw;
 
-   for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++)
+   LINKTABLE_FOR_EACH(b_fw, builtin_fw)
if (fw->data == b_fw->data)
return true;
 
diff --git a/firmware/Makefile b/firmware/Makefile
index fa3e81c2a97b..9e701bf4ced2 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -155,6 +155,7 @@ quiet_cmd_fwbin = MK_FW   $@
  ASM_ALIGN=$(if $(CONFIG_64BIT),3,2);   \
  PROGBITS=$(if $(CONFIG_ARM),%,@)progbits;  \
  echo "/* Generated by firmware/Makefile */"   > $@;\
+ echo "\#include "   >>$@;\
  echo ".section .rodata"   >>$@;\
  echo ".p2align $${ASM_ALIGN}" >>$@;\
  echo "_fw_$${FWSTR}_bin:" >>$@;\
@@ -164,7 +165,7 @@ quiet_cmd_fwbin = MK_FW   $@
  echo ".p2align $${ASM_ALIGN}" >>$@;\
  echo "_fw_$${FWSTR}_name:">>$@;\
  echo ".string \"$$FWNAME\""   >>$@;\
- echo ".section .builtin_fw,\"a\",$${PROGBITS}">>$@;\
+ echo "set_section_tbl_type(SECTION_TBL_RO, builtin_fw, 
SECTION_ORDER_ANY, a,$${PROGBITS})" >>$@;\
  echo ".p2align $${ASM_ALIGN}" >>$@;\
  echo "$${ASM_WORD} _fw_$${FWSTR}_name">>$@;\
  echo "$${ASM_WORD} 

[Xen-devel] [PATCH v4 04/16] generic-sections: add section core helpers

2016-08-19 Thread mcgrof
l-doc:: include/linux/sections.h
+   :functions: LINUX_SECTION_SIZE
+
+LINUX_SECTION_EMPTY
+---
+.. kernel-doc:: include/linux/sections.h
+   :functions: LINUX_SECTION_EMPTY
+
+LINUX_SECTION_START
+---
+.. kernel-doc:: include/linux/sections.h
+   :functions: LINUX_SECTION_START
+
+LINUX_SECTION_END
+-
+.. kernel-doc:: include/linux/sections.h
+   :functions: LINUX_SECTION_END
+
+DECLARE_LINUX_SECTION
+-
+.. kernel-doc:: include/linux/sections.h
+   :functions: DECLARE_LINUX_SECTION
+
+DECLARE_LINUX_SECTION_RO
+
+.. kernel-doc:: include/linux/sections.h
+   :functions: DECLARE_LINUX_SECTION_RO
diff --git a/MAINTAINERS b/MAINTAINERS
index 5aec01883020..689c12075842 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5217,6 +5217,20 @@ S:   Supported
 F: drivers/base/power/domain*.c
 F: include/linux/pm_domain.h
 
+GENERIC SECTIONS
+M: "Luis R. Rodriguez" <mcg...@kernel.org>
+M: Josh Poimboeuf <jpoim...@redhat.com>
+M: "H. Peter Anvin" <h...@zytor.com>
+L: linux-a...@vger.kernel.org
+L: linux-ker...@vger.kernel.org
+T: git git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git 
for-arnd
+T: git git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git 
for-arnd
+S: Supported
+F: include/asm-generic/section-core.h
+F: include/asm-generic/sections.h
+F: include/asm-generic/vmlinux.lds.h
+F: Documentation/sections/section-core.rst
+
 GENERIC UIO DRIVER FOR PCI DEVICES
 M: "Michael S. Tsirkin" <m...@redhat.com>
 L: k...@vger.kernel.org
diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild
index bf8475ce85ee..5422827f1585 100644
--- a/arch/alpha/include/asm/Kbuild
+++ b/arch/alpha/include/asm/Kbuild
@@ -10,3 +10,4 @@ generic-y += mm-arch-hooks.h
 generic-y += preempt.h
 generic-y += sections.h
 generic-y += trace_clock.h
+generic-y += section-core.h
diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
index 0b10ef2a4372..9a0929576de1 100644
--- a/arch/arc/include/asm/Kbuild
+++ b/arch/arc/include/asm/Kbuild
@@ -50,3 +50,4 @@ generic-y += user.h
 generic-y += vga.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+generic-y += section-core.h
diff --git a/arch/arm/include/asm/Kbuild b/arch/arm/include/asm/Kbuild
index 0745538b26d3..47923635be16 100644
--- a/arch/arm/include/asm/Kbuild
+++ b/arch/arm/include/asm/Kbuild
@@ -39,3 +39,4 @@ generic-y += termios.h
 generic-y += timex.h
 generic-y += trace_clock.h
 generic-y += unaligned.h
+generic-y += section-core.h
diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
index f43d2c44c765..42d00806e4fb 100644
--- a/arch/arm64/include/asm/Kbuild
+++ b/arch/arm64/include/asm/Kbuild
@@ -52,3 +52,4 @@ generic-y += unaligned.h
 generic-y += user.h
 generic-y += vga.h
 generic-y += xor.h
+generic-y += section-core.h
diff --git a/arch/avr32/include/asm/Kbuild b/arch/avr32/include/asm/Kbuild
index 241b9b9729d8..f2c3b656a0e7 100644
--- a/arch/avr32/include/asm/Kbuild
+++ b/arch/avr32/include/asm/Kbuild
@@ -22,3 +22,4 @@ generic-y += trace_clock.h
 generic-y += vga.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+generic-y += section-core.h
diff --git a/arch/blackfin/include/asm/Kbuild b/arch/blackfin/include/asm/Kbuild
index 91d49c0a3118..7de674411bed 100644
--- a/arch/blackfin/include/asm/Kbuild
+++ b/arch/blackfin/include/asm/Kbuild
@@ -48,3 +48,4 @@ generic-y += unaligned.h
 generic-y += user.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+generic-y += section-core.h
diff --git a/arch/c6x/include/asm/Kbuild b/arch/c6x/include/asm/Kbuild
index 64465e7e2245..38127ce747be 100644
--- a/arch/c6x/include/asm/Kbuild
+++ b/arch/c6x/include/asm/Kbuild
@@ -62,3 +62,4 @@ generic-y += user.h
 generic-y += vga.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+generic-y += section-core.h
diff --git a/arch/cris/include/asm/Kbuild b/arch/cris/include/asm/Kbuild
index 1778805f6380..385cd88a9d9e 100644
--- a/arch/cris/include/asm/Kbuild
+++ b/arch/cris/include/asm/Kbuild
@@ -45,3 +45,4 @@ generic-y += types.h
 generic-y += vga.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+generic-y += section-core.h
diff --git a/arch/frv/include/asm/Kbuild b/arch/frv/include/asm/Kbuild
index 1fa084cf1a43..46d7c599d9b8 100644
--- a/arch/frv/include/asm/Kbuild
+++ b/arch/frv/include/asm/Kbuild
@@ -8,3 +8,4 @@ generic-y += mm-arch-hooks.h
 generic-y += preempt.h
 generic-y += trace_clock.h
 generic-y += word-at-a-time.h
+generic-y += section-core.h
diff --git a/arch/h8300/include/asm/Kbuild b/arch/h8300/include/asm/Kbuild
index 373cb23301e3..1ec04ec1c82b 100644
--- a/arch/h8300/include/asm/Kbuild
+++ b/arch/h8300/include/asm/Kbuild
@@ -75,3 +75,4 @@ generic-y += unaligned.h
 generic-y += vga.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+generic-y += section-core.h
diff --git a/arch/hexagon/includ

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

2016-08-19 Thread mcgrof
tions: DEFINE_LINKTABLE_TEXT
+
+DEFINE_LINKTABLE_RO
+---
+.. kernel-doc:: include/linux/tables.h
+   :functions: DEFINE_LINKTABLE_RO
+
+DEFINE_LINKTABLE_INIT
+-
+.. kernel-doc:: include/linux/tables.h
+   :functions: DEFINE_LINKTABLE_INIT
+
+DEFINE_LINKTABLE_INIT_DATA
+--
+.. kernel-doc:: include/linux/tables.h
+   :functions: DEFINE_LINKTABLE_INIT_DATA
+
+Iterating over Linker tables
+
+
+.. kernel-doc:: include/linux/tables.h
+   :doc: Iterating over Linker tables
+
+LINKTABLE_FOR_EACH
+--
+.. kernel-doc:: include/linux/tables.h
+   :functions: LINKTABLE_FOR_EACH
+
+LINKTABLE_RUN_ALL
+-
+.. kernel-doc:: include/linux/tables.h
+   :functions: LINKTABLE_RUN_ALL
+
+LINKTABLE_RUN_ERR
+-
+.. kernel-doc:: include/linux/tables.h
+   :functions: LINKTABLE_RUN_ERR
diff --git a/MAINTAINERS b/MAINTAINERS
index 1a217751aa8a..e3569ed12c86 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5200,6 +5200,18 @@ S:   Maintained
 F: include/asm-generic/
 F: include/uapi/asm-generic/
 
+GENERIC LINKER TABLES
+M: "Luis R. Rodriguez" <mcg...@kernel.org>
+M: "H. Peter Anvin" <h...@zytor.com>
+L: linux-a...@vger.kernel.org
+L: linux-ker...@vger.kernel.org
+T: git git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git 
sections
+T: git git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git 
sections
+S: Supported
+F: include/asm-generic/tables.h
+F: include/linux/tables.h
+F: Documentation/sections/linker-tables.rst
+
 GENERIC PHY FRAMEWORK
 M: Kishon Vijay Abraham I <kis...@ti.com>
 L: linux-ker...@vger.kernel.org
diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild
index e44c896b91c4..f3bdc31d3c97 100644
--- a/arch/alpha/include/asm/Kbuild
+++ b/arch/alpha/include/asm/Kbuild
@@ -12,3 +12,4 @@ generic-y += sections.h
 generic-y += trace_clock.h
 generic-y += section-core.h
 generic-y += ranges.h
+generic-y += tables.h
diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
index e5295413fdf8..70f252472cb9 100644
--- a/arch/arc/include/asm/Kbuild
+++ b/arch/arc/include/asm/Kbuild
@@ -52,3 +52,4 @@ generic-y += word-at-a-time.h
 generic-y += xor.h
 generic-y += section-core.h
 generic-y += ranges.h
+generic-y += tables.h
diff --git a/arch/arm/include/asm/Kbuild b/arch/arm/include/asm/Kbuild
index 8e52300e1eed..d13700f573d0 100644
--- a/arch/arm/include/asm/Kbuild
+++ b/arch/arm/include/asm/Kbuild
@@ -41,3 +41,4 @@ generic-y += trace_clock.h
 generic-y += unaligned.h
 generic-y += section-core.h
 generic-y += ranges.h
+generic-y += tables.h
diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
index 5ff184574976..a1991517aad6 100644
--- a/arch/arm64/include/asm/Kbuild
+++ b/arch/arm64/include/asm/Kbuild
@@ -54,3 +54,4 @@ generic-y += vga.h
 generic-y += xor.h
 generic-y += section-core.h
 generic-y += ranges.h
+generic-y += tables.h
diff --git a/arch/avr32/include/asm/Kbuild b/arch/avr32/include/asm/Kbuild
index edc176348d7c..a6cd145515ae 100644
--- a/arch/avr32/include/asm/Kbuild
+++ b/arch/avr32/include/asm/Kbuild
@@ -24,3 +24,4 @@ generic-y += word-at-a-time.h
 generic-y += xor.h
 generic-y += section-core.h
 generic-y += ranges.h
+generic-y += tables.h
diff --git a/arch/blackfin/include/asm/Kbuild b/arch/blackfin/include/asm/Kbuild
index 35b7752e65c0..b71893b1cd53 100644
--- a/arch/blackfin/include/asm/Kbuild
+++ b/arch/blackfin/include/asm/Kbuild
@@ -50,3 +50,4 @@ generic-y += word-at-a-time.h
 generic-y += xor.h
 generic-y += section-core.h
 generic-y += ranges.h
+generic-y += tables.h
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 <mcg...@kernel.org>
+ *
+ * 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.
+ *
+ * [0] https://lkml.kernel.org/r/1470798247.3551.94.ca...@redhat.com
+ */
+
+#define SECTION_TBL_RO .const
+
+#include 
+
+#endif /* _ASM_C6X_ASM_TABLES_H */
diff --git a/arch/cris/include/asm/Kbuild b/arch/cris/include/asm/Kbuild
index fb8bb4112773..7062c1be79

[Xen-devel] [PATCH v4 00/16] linux: generalize sections, ranges and linker tables

2016-08-19 Thread mcgrof
From: "Luis R. Rodriguez" <mcg...@kernel.org>

This v4 addresses feedback from the previous v3 series [0], and also
addresses a huge array of additional tests against many architectures
outside of what 0-day provides. As I mentioned in my last v3 series,
0-day had only found one issue with the series, a blackfin architecture
linker issue with the last series. Guenter Rock was kind enough to give
my series a test spin on his test bed and he found quite a bit of other
oddball issues with obscure architectures, and even on x86 with an old
toolchain. After a lot of work and coordinating with a few maintainers
I'm happy to report all issues found so far through all possible testing
I could do are now fixed, this series also addresses all feedback from
the last series, as such this goes submitted as PATCH form.

In addressing fixing this work on a few architectures some of the previous
patches are further simplified. The kprobes port to linker tables is made
much easier now that I've addressed moving out core kprobe declarations
into asm-generic/kprobes.h. Refer to the patch "kprobes: move kprobe
declarations to asm-generic/kprobes.h". This makes for a much cleaner
solution across architectures.

Boris feedback on making the code bit rot feature optional is addressed
by using a new Kconfig symbol for this, CONFIG_BUILD_AVOID_BITROT,
but given Greg's concerns over lack of clarity over what this was all about
I've ripped that functionality out into its own patch with a bit more
extensive documentation and re-wording. See the patch "kbuild: enable option
to force compile force-obj-y and force-lib-y". I hope makes it clear how
linker tables can help with avoiding code bit rot. I've gone with a new
Kconfig symbol CONFIG_BUILD_AVOID_BITROT given CONFIG_COMPILE_TEST is
not available on UML, this feature is desirable on all architectures.

The documentation is revamped, now that the DocBook format is deprecated
I ported the documention into the trendy hipster Sphinx documentation
format.

AT Boris' request I've adapated the userspace linker table application
forintegration into the kernel under tools/ to make it easier to keep
things in sync, however since this requires a bit of changes to some headers
in tools/ I'll submit that separately.

[0] https://lkml.kernel.org/r/1469222687-1600-1-git-send-email-mcg...@kernel.org

If you'd like this in git-form, you can get it on the 20160819-linker-table-v4
branch of my linux-next tree on kernel.org, this also includes the series of
the linker table userspace sandbox:

https://git.kernel.org/cgit/linux/kernel/git/mcgrof/linux-next.git/log/?h=20160819-linker-table-v4

Please let me know if there are any concerns or questions.

Luis R. Rodriguez (16):
  x86: remove LTO_REFERENCE_INITCALL()
  dell-smo8800: include uaccess.h
  scripts/module-common.lds: enable generation
  generic-sections: add section core helpers
  xtensa: skip adding literal when SORT() is used
  ranges.h: add helpers to build and identify Linux section ranges
  tables.h: add linker table support
  kbuild: enable option to force compile force-obj-y and force-lib-y
  firmware/Makefile: force recompilation if makefile changes
  firmware: port built-in section to linker table
  jump_label: move guard #endif down where it belongs
  jump_label: port __jump_table to linker tables
  dynamic_debug: port to use linker tables
  kprobes: move kprobe declarations to asm-generic/kprobes.h
  kprobes: port .kprobes.text to section range
  kprobes: port blacklist kprobes to linker table

 .gitignore |   2 +
 Documentation/index.rst|   1 +
 Documentation/kbuild/makefiles.txt |  36 ++
 Documentation/sections/conf.py |   4 +
 Documentation/sections/index.rst   |  13 +
 Documentation/sections/linker-tables.rst   | 202 +++
 Documentation/sections/ranges.rst  |  49 ++
 Documentation/sections/section-core.rst| 153 +
 MAINTAINERS|  37 ++
 Makefile   |   6 +-
 arch/alpha/include/asm/Kbuild  |   4 +
 arch/arc/include/asm/Kbuild|   3 +
 arch/arc/include/asm/kprobes.h |   6 +-
 arch/arc/kernel/vmlinux.lds.S  |   1 -
 arch/arm/include/asm/Kbuild|   3 +
 arch/arm/include/asm/jump_label.h  |   6 +-
 arch/arm/include/asm/kprobes.h |   4 +
 arch/arm/kernel/entry-armv.S   |   3 +-
 arch/arm/kernel/vmlinux-xip.lds.S  |   1 -
 arch/arm/kernel/vmlinux.lds.S  |   1 -
 arch/arm/probes/decode.h   |   1 +
 arch/arm64/include/asm/Kbuild  |   3 +
 arch/arm64/include/asm/jump_label.h|   6 +-
 arch/arm64/include/asm/kprob

[Xen-devel] [PATCH v4 01/16] x86: remove LTO_REFERENCE_INITCALL()

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

The setup for LTO never made it upstream, and although this has
some users, this is now really old stuff for a gcc 4.7 LTO problem.
We know that at least LTO_REFERENCE_INITCALL() work around can
be removed if LTO is not supported on v4.7 anymore.

As per Andi the DISABLE_LTO and LTO_CFLAGS are still neeeded though.

v3: added to this series, removing LTO_REFERENCE_INITCALL()
justifies that other future similar macros do not need
a respective LTO_REFERENCE_INITCALL() on them therefore
simplifying new code.

Acked-by: Andi Kleen 
Signed-off-by: Luis R. Rodriguez 
---
 include/linux/init.h | 20 +---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/include/linux/init.h b/include/linux/init.h
index 1e5c131d5c9a..aa662ad80d9c 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -151,23 +151,6 @@ extern bool initcall_debug;
 
 #ifndef __ASSEMBLY__
 
-#ifdef CONFIG_LTO
-/* Work around a LTO gcc problem: when there is no reference to a variable
- * in a module it will be moved to the end of the program. This causes
- * reordering of initcalls which the kernel does not like.
- * Add a dummy reference function to avoid this. The function is
- * deleted by the linker.
- */
-#define LTO_REFERENCE_INITCALL(x) \
-   ; /* yes this is needed */  \
-   static __used __exit void *reference_##x(void)  \
-   {   \
-   return   \
-   }
-#else
-#define LTO_REFERENCE_INITCALL(x)
-#endif
-
 /* initcalls are now grouped by functionality into separate 
  * subsections. Ordering inside the subsections is determined
  * by link order. 
@@ -180,8 +163,7 @@ extern bool initcall_debug;
 
 #define __define_initcall(fn, id) \
static initcall_t __initcall_##fn##id __used \
-   __attribute__((__section__(".initcall" #id ".init"))) = fn; \
-   LTO_REFERENCE_INITCALL(__initcall_##fn##id)
+   __attribute__((__section__(".initcall" #id ".init"))) = fn;
 
 /*
  * Early initcalls run before initializing SMP.
-- 
2.9.2


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


[Xen-devel] [PATCH v4 03/16] scripts/module-common.lds: enable generation

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

scripts/module-common.lds is currently pretty static, in the
future this may change and we will want access to kernel macros
to help expands certain areas. To get access to use macros we
need to generate module-common.lds from module-common.lds.S, for
now though only enable the generation. We'll later expand on this
as needed.

Since this file is now generated add it to .gitignore.

v4: add file to MAINTAINERS
v3: new to this series

Signed-off-by: Luis R. Rodriguez 
---
 .gitignore | 2 ++
 MAINTAINERS| 1 +
 Makefile   | 6 +-
 scripts/Makefile.modpost   | 2 +-
 scripts/{module-common.lds => module-common.lds.S} | 0
 5 files changed, 9 insertions(+), 2 deletions(-)
 rename scripts/{module-common.lds => module-common.lds.S} (100%)

diff --git a/.gitignore b/.gitignore
index c2ed4ecb0acd..0f0702054fdb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -114,3 +114,5 @@ all.config
 
 # Kdevelop4
 *.kdev4
+
+scripts/module-common.lds
diff --git a/MAINTAINERS b/MAINTAINERS
index d635ab047f3a..5aec01883020 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7887,6 +7887,7 @@ M:Rusty Russell 
 S: Maintained
 F: include/linux/module.h
 F: kernel/module.c
+F: scripts/module-common.lds.S
 
 MOTION EYE VAIO PICTUREBOOK CAMERA DRIVER
 W: http://popies.net/meye/
diff --git a/Makefile b/Makefile
index 5c18baad7218..b3e5ea78d582 100644
--- a/Makefile
+++ b/Makefile
@@ -408,6 +408,10 @@ KBUILD_AFLAGS_MODULE  := -DMODULE
 KBUILD_CFLAGS_MODULE  := -DMODULE
 KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
 
+$(srctree)/scripts/module-common.lds: $(srctree)/scripts/module-common.lds.S
+   $(Q)$(CC) $(CFLAGS) $(INCLUDES) $(LINUXINCLUDE) -E -P \
+   -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
+
 # Read KERNELRELEASE from include/config/kernel.release (if it exists)
 KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
 KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if 
$(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
@@ -1174,7 +1178,7 @@ all: modules
 # using awk while concatenating to the final file.
 
 PHONY += modules
-modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
+modules: $(srctree)/scripts/module-common.lds $(vmlinux-dirs) $(if 
$(KBUILD_BUILTIN),vmlinux) modules.builtin
$(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > 
$(objtree)/modules.order
@$(kecho) '  Building modules, stage 2.';
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 1366a94b6c39..2d8aff7735d6 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -121,7 +121,7 @@ quiet_cmd_ld_ko_o = LD [M]  $@
  $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
  -o $@ $(filter-out FORCE,$^)
 
-$(modules): %.ko :%.o %.mod.o FORCE
+$(modules): %.ko : $(srctree)/scripts/module-common.lds %.o %.mod.o FORCE
$(call if_changed,ld_ko_o)
 
 targets += $(modules)
diff --git a/scripts/module-common.lds b/scripts/module-common.lds.S
similarity index 100%
rename from scripts/module-common.lds
rename to scripts/module-common.lds.S
-- 
2.9.2


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


[Xen-devel] [PATCH v4 10/16] firmware: port built-in section to linker table

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

This ports built-in firmware to use linker tables,
this replaces the custom section solution with a
generic solution.

This also demos the use of the .rodata (SECTION_RO)
linker tables.

Tested with 0 built-in firmware, 1 and 2 built-in
firmwares successfully.

v4:

o work around c6x toolchain bug by using SECTION_TBL_RO

o fix compilation on blackfin

v3:
o explicitly include tables.h as we no longer include
  tables.h from sections.h

o use new section_tbl_asmtype() helper on firmware/Makefile
  to enable having to unfold things on our own.

v2: introduced this file in this version of the series

Cc: Barry Song 
Cc: Mike Frysinger 
Cc: Steven Miao 
Cc: Michael Matz 
Cc: Guenter Roeck 
Cc: Fengguang Wu 
Signed-off-by: Luis R. Rodriguez 
---
 arch/x86/kernel/cpu/microcode/core.c |  8 
 drivers/base/firmware_class.c| 12 ++--
 firmware/Makefile|  3 ++-
 include/asm-generic/vmlinux.lds.h|  7 ---
 4 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c 
b/arch/x86/kernel/cpu/microcode/core.c
index df04b2d033f6..3e7c08d99601 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -91,15 +92,14 @@ static bool __init check_loader_disabled_bsp(void)
return *res;
 }
 
-extern struct builtin_fw __start_builtin_fw[];
-extern struct builtin_fw __end_builtin_fw[];
+DECLARE_LINKTABLE_RO(struct builtin_fw, builtin_fw);
 
 bool get_builtin_firmware(struct cpio_data *cd, const char *name)
 {
 #ifdef CONFIG_FW_LOADER
-   struct builtin_fw *b_fw;
+   const struct builtin_fw *b_fw;
 
-   for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) {
+   LINKTABLE_FOR_EACH(b_fw, builtin_fw) {
if (!strcmp(name, b_fw->name)) {
cd->size = b_fw->size;
cd->data = b_fw->data;
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 22d1760a4278..8fbf03c3e4c2 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -43,15 +44,14 @@ MODULE_LICENSE("GPL");
 
 #ifdef CONFIG_FW_LOADER
 
-extern struct builtin_fw __start_builtin_fw[];
-extern struct builtin_fw __end_builtin_fw[];
+DEFINE_LINKTABLE_RO(struct builtin_fw, builtin_fw);
 
 static bool fw_get_builtin_firmware(struct firmware *fw, const char *name,
void *buf, size_t size)
 {
-   struct builtin_fw *b_fw;
+   const struct builtin_fw *b_fw;
 
-   for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) {
+   LINKTABLE_FOR_EACH(b_fw, builtin_fw) {
if (strcmp(name, b_fw->name) == 0) {
fw->size = b_fw->size;
fw->data = b_fw->data;
@@ -67,9 +67,9 @@ static bool fw_get_builtin_firmware(struct firmware *fw, 
const char *name,
 
 static bool fw_is_builtin_firmware(const struct firmware *fw)
 {
-   struct builtin_fw *b_fw;
+   const struct builtin_fw *b_fw;
 
-   for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++)
+   LINKTABLE_FOR_EACH(b_fw, builtin_fw)
if (fw->data == b_fw->data)
return true;
 
diff --git a/firmware/Makefile b/firmware/Makefile
index fa3e81c2a97b..9e701bf4ced2 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -155,6 +155,7 @@ quiet_cmd_fwbin = MK_FW   $@
  ASM_ALIGN=$(if $(CONFIG_64BIT),3,2);   \
  PROGBITS=$(if $(CONFIG_ARM),%,@)progbits;  \
  echo "/* Generated by firmware/Makefile */"   > $@;\
+ echo "\#include "   >>$@;\
  echo ".section .rodata"   >>$@;\
  echo ".p2align $${ASM_ALIGN}" >>$@;\
  echo "_fw_$${FWSTR}_bin:" >>$@;\
@@ -164,7 +165,7 @@ quiet_cmd_fwbin = MK_FW   $@
  echo ".p2align $${ASM_ALIGN}" >>$@;\
  echo "_fw_$${FWSTR}_name:">>$@;\
  echo ".string \"$$FWNAME\""   >>$@;\
- echo ".section .builtin_fw,\"a\",$${PROGBITS}">>$@;\
+ echo "set_section_tbl_type(SECTION_TBL_RO, builtin_fw, 
SECTION_ORDER_ANY, a,$${PROGBITS})" >>$@;\
  echo ".p2align $${ASM_ALIGN}" >>$@;\
  echo "$${ASM_WORD} _fw_$${FWSTR}_name">>$@;\
  echo "$${ASM_WORD} 

[Xen-devel] [PATCH v4 09/16] firmware/Makefile: force recompilation if makefile changes

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

If you modify the target asm we currently do not force the
recompilation of the firmware files. The target asm is in
the firmware/Makefile, peg this file as a dependency to
require re-compilation of firmware targets when the asm
changes.

v3: introduced in this series

Signed-off-by: Luis R. Rodriguez 
---
 firmware/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/firmware/Makefile b/firmware/Makefile
index e297e1b52636..fa3e81c2a97b 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -176,7 +176,8 @@ quiet_cmd_fwbin = MK_FW   $@
 wordsize_deps := $(wildcard include/config/64bit.h include/config/32bit.h \
include/config/ppc32.h include/config/ppc64.h \
include/config/superh32.h include/config/superh64.h \
-   include/config/x86_32.h include/config/x86_64.h)
+   include/config/x86_32.h include/config/x86_64.h \
+   firmware/Makefile)
 
 $(patsubst %,$(obj)/%.gen.S, $(fw-shipped-y)): %: $(wordsize_deps)
$(call cmd,fwbin,$(patsubst %.gen.S,%,$@))
-- 
2.9.2


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


[Xen-devel] [PATCH v4 02/16] dell-smo8800: include uaccess.h

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

sections.h is currently included and it provides dell-smo8800
with what it needs, an upcoming change will decouple uaccess.h
from sections.h. This driver needs to explicitly require uaccess.h
before this change.

v3: new to this series -- needed due to collateral of the split of
old linker tables from tables.h into 3 files: sections.h, ranges.h
and tables.h

Reviewed-by: Pali Rohár 
Signed-off-by: Luis R. Rodriguez 
---
 drivers/platform/x86/dell-smo8800.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/platform/x86/dell-smo8800.c 
b/drivers/platform/x86/dell-smo8800.c
index 0aec4fd4c48e..37e646034ef8 100644
--- a/drivers/platform/x86/dell-smo8800.c
+++ b/drivers/platform/x86/dell-smo8800.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct smo8800_device {
u32 irq; /* acpi device irq */
-- 
2.9.2


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


[Xen-devel] [PATCH v4 00/16] linux: generalize sections, ranges and linker tables

2016-08-19 Thread mcgrof
From: "Luis R. Rodriguez" <mcg...@kernel.org>

This v4 addresses feedback from the previous v3 series [0], and also
addresses a huge array of additional tests against many architectures
outside of what 0-day provides. As I mentioned in my last v3 series,
0-day had only found one issue with the series, a blackfin architecture
linker issue with the last series. Guenter Rock was kind enough to give
my series a test spin on his test bed and he found quite a bit of other
oddball issues with obscure architectures, and even on x86 with an old
toolchain. After a lot of work and coordinating with a few maintainers
I'm happy to report all issues found so far through all possible testing
I could do are now fixed, this series also addresses all feedback from
the last series, as such this goes submitted as PATCH form.

In addressing fixing this work on a few architectures some of the previous
patches are further simplified. The kprobes port to linker tables is made
much easier now that I've addressed moving out core kprobe declarations
into asm-generic/kprobes.h. Refer to the patch "kprobes: move kprobe
declarations to asm-generic/kprobes.h". This makes for a much cleaner
solution across architectures.

Boris feedback on making the code bit rot feature optional is addressed
by using a new Kconfig symbol for this, CONFIG_BUILD_AVOID_BITROT,
but given Greg's concerns over lack of clarity over what this was all about
I've ripped that functionality out into its own patch with a bit more
extensive documentation and re-wording. See the patch "kbuild: enable option
to force compile force-obj-y and force-lib-y". I hope makes it clear how
linker tables can help with avoiding code bit rot. I've gone with a new
Kconfig symbol CONFIG_BUILD_AVOID_BITROT given CONFIG_COMPILE_TEST is
not available on UML, this feature is desirable on all architectures.

The documentation is revamped, now that the DocBook format is deprecated
I ported the documention into the trendy hipster Sphinx documentation
format.

AT Boris' request I've adapated the userspace linker table application
forintegration into the kernel under tools/ to make it easier to keep
things in sync, however since this requires a bit of changes to some headers
in tools/ I'll submit that separately.

[0] https://lkml.kernel.org/r/1469222687-1600-1-git-send-email-mcg...@kernel.org

If you'd like this in git-form, you can get it on the 20160819-linker-table-v4
branch of my linux-next tree on kernel.org, this also includes the series of
the linker table userspace sandbox:

https://git.kernel.org/cgit/linux/kernel/git/mcgrof/linux-next.git/log/?h=20160819-linker-table-v4

Please let me know if there are any concerns or questions.

Luis R. Rodriguez (16):
  x86: remove LTO_REFERENCE_INITCALL()
  dell-smo8800: include uaccess.h
  scripts/module-common.lds: enable generation
  generic-sections: add section core helpers
  xtensa: skip adding literal when SORT() is used
  ranges.h: add helpers to build and identify Linux section ranges
  tables.h: add linker table support
  kbuild: enable option to force compile force-obj-y and force-lib-y
  firmware/Makefile: force recompilation if makefile changes
  firmware: port built-in section to linker table
  jump_label: move guard #endif down where it belongs
  jump_label: port __jump_table to linker tables
  dynamic_debug: port to use linker tables
  kprobes: move kprobe declarations to asm-generic/kprobes.h
  kprobes: port .kprobes.text to section range
  kprobes: port blacklist kprobes to linker table

 .gitignore |   2 +
 Documentation/index.rst|   1 +
 Documentation/kbuild/makefiles.txt |  36 ++
 Documentation/sections/conf.py |   4 +
 Documentation/sections/index.rst   |  13 +
 Documentation/sections/linker-tables.rst   | 202 +++
 Documentation/sections/ranges.rst  |  49 ++
 Documentation/sections/section-core.rst| 153 +
 MAINTAINERS|  37 ++
 Makefile   |   6 +-
 arch/alpha/include/asm/Kbuild  |   4 +
 arch/arc/include/asm/Kbuild|   3 +
 arch/arc/include/asm/kprobes.h |   6 +-
 arch/arc/kernel/vmlinux.lds.S  |   1 -
 arch/arm/include/asm/Kbuild|   3 +
 arch/arm/include/asm/jump_label.h  |   6 +-
 arch/arm/include/asm/kprobes.h |   4 +
 arch/arm/kernel/entry-armv.S   |   3 +-
 arch/arm/kernel/vmlinux-xip.lds.S  |   1 -
 arch/arm/kernel/vmlinux.lds.S  |   1 -
 arch/arm/probes/decode.h   |   1 +
 arch/arm64/include/asm/Kbuild  |   3 +
 arch/arm64/include/asm/jump_label.h|   6 +-
 arch/arm64/include/asm/kprob

[Xen-devel] [PATCH v4 04/16] generic-sections: add section core helpers

2016-08-19 Thread mcgrof
l-doc:: include/linux/sections.h
+   :functions: LINUX_SECTION_SIZE
+
+LINUX_SECTION_EMPTY
+---
+.. kernel-doc:: include/linux/sections.h
+   :functions: LINUX_SECTION_EMPTY
+
+LINUX_SECTION_START
+---
+.. kernel-doc:: include/linux/sections.h
+   :functions: LINUX_SECTION_START
+
+LINUX_SECTION_END
+-
+.. kernel-doc:: include/linux/sections.h
+   :functions: LINUX_SECTION_END
+
+DECLARE_LINUX_SECTION
+-
+.. kernel-doc:: include/linux/sections.h
+   :functions: DECLARE_LINUX_SECTION
+
+DECLARE_LINUX_SECTION_RO
+
+.. kernel-doc:: include/linux/sections.h
+   :functions: DECLARE_LINUX_SECTION_RO
diff --git a/MAINTAINERS b/MAINTAINERS
index 5aec01883020..689c12075842 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5217,6 +5217,20 @@ S:   Supported
 F: drivers/base/power/domain*.c
 F: include/linux/pm_domain.h
 
+GENERIC SECTIONS
+M: "Luis R. Rodriguez" <mcg...@kernel.org>
+M: Josh Poimboeuf <jpoim...@redhat.com>
+M: "H. Peter Anvin" <h...@zytor.com>
+L: linux-a...@vger.kernel.org
+L: linux-ker...@vger.kernel.org
+T: git git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git 
for-arnd
+T: git git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git 
for-arnd
+S: Supported
+F: include/asm-generic/section-core.h
+F: include/asm-generic/sections.h
+F: include/asm-generic/vmlinux.lds.h
+F: Documentation/sections/section-core.rst
+
 GENERIC UIO DRIVER FOR PCI DEVICES
 M: "Michael S. Tsirkin" <m...@redhat.com>
 L: k...@vger.kernel.org
diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild
index bf8475ce85ee..5422827f1585 100644
--- a/arch/alpha/include/asm/Kbuild
+++ b/arch/alpha/include/asm/Kbuild
@@ -10,3 +10,4 @@ generic-y += mm-arch-hooks.h
 generic-y += preempt.h
 generic-y += sections.h
 generic-y += trace_clock.h
+generic-y += section-core.h
diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
index 0b10ef2a4372..9a0929576de1 100644
--- a/arch/arc/include/asm/Kbuild
+++ b/arch/arc/include/asm/Kbuild
@@ -50,3 +50,4 @@ generic-y += user.h
 generic-y += vga.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+generic-y += section-core.h
diff --git a/arch/arm/include/asm/Kbuild b/arch/arm/include/asm/Kbuild
index 0745538b26d3..47923635be16 100644
--- a/arch/arm/include/asm/Kbuild
+++ b/arch/arm/include/asm/Kbuild
@@ -39,3 +39,4 @@ generic-y += termios.h
 generic-y += timex.h
 generic-y += trace_clock.h
 generic-y += unaligned.h
+generic-y += section-core.h
diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
index f43d2c44c765..42d00806e4fb 100644
--- a/arch/arm64/include/asm/Kbuild
+++ b/arch/arm64/include/asm/Kbuild
@@ -52,3 +52,4 @@ generic-y += unaligned.h
 generic-y += user.h
 generic-y += vga.h
 generic-y += xor.h
+generic-y += section-core.h
diff --git a/arch/avr32/include/asm/Kbuild b/arch/avr32/include/asm/Kbuild
index 241b9b9729d8..f2c3b656a0e7 100644
--- a/arch/avr32/include/asm/Kbuild
+++ b/arch/avr32/include/asm/Kbuild
@@ -22,3 +22,4 @@ generic-y += trace_clock.h
 generic-y += vga.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+generic-y += section-core.h
diff --git a/arch/blackfin/include/asm/Kbuild b/arch/blackfin/include/asm/Kbuild
index 91d49c0a3118..7de674411bed 100644
--- a/arch/blackfin/include/asm/Kbuild
+++ b/arch/blackfin/include/asm/Kbuild
@@ -48,3 +48,4 @@ generic-y += unaligned.h
 generic-y += user.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+generic-y += section-core.h
diff --git a/arch/c6x/include/asm/Kbuild b/arch/c6x/include/asm/Kbuild
index 64465e7e2245..38127ce747be 100644
--- a/arch/c6x/include/asm/Kbuild
+++ b/arch/c6x/include/asm/Kbuild
@@ -62,3 +62,4 @@ generic-y += user.h
 generic-y += vga.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+generic-y += section-core.h
diff --git a/arch/cris/include/asm/Kbuild b/arch/cris/include/asm/Kbuild
index 1778805f6380..385cd88a9d9e 100644
--- a/arch/cris/include/asm/Kbuild
+++ b/arch/cris/include/asm/Kbuild
@@ -45,3 +45,4 @@ generic-y += types.h
 generic-y += vga.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+generic-y += section-core.h
diff --git a/arch/frv/include/asm/Kbuild b/arch/frv/include/asm/Kbuild
index 1fa084cf1a43..46d7c599d9b8 100644
--- a/arch/frv/include/asm/Kbuild
+++ b/arch/frv/include/asm/Kbuild
@@ -8,3 +8,4 @@ generic-y += mm-arch-hooks.h
 generic-y += preempt.h
 generic-y += trace_clock.h
 generic-y += word-at-a-time.h
+generic-y += section-core.h
diff --git a/arch/h8300/include/asm/Kbuild b/arch/h8300/include/asm/Kbuild
index 373cb23301e3..1ec04ec1c82b 100644
--- a/arch/h8300/include/asm/Kbuild
+++ b/arch/h8300/include/asm/Kbuild
@@ -75,3 +75,4 @@ generic-y += unaligned.h
 generic-y += vga.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+generic-y += section-core.h
diff --git a/arch/hexagon/includ

[Xen-devel] [PATCH v4 08/16] kbuild: enable option to force compile force-obj-y and force-lib-y

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

Linux provides a rich array of features, enabling each feature
however increases the size of the kernel and there are many
features which users often want disabled. The traditional
solution to this problem is for each feature to have its own
Kconfig symbol, followed by a series of #ifdef statements
in C code and header files, allowing the feature to be compiled
only when desirable. As the variability of Linux increases build
tests can and are often done with random kernel configurations,
allyesconfig, and allmodconfig to help find code issues. This
however doesn't catch all errors and as a consequence code that
is typically not enabled often can suffer from bit-rot over time.

An alternative approach for subsystems, which refer to as the 'build-all
link-selectively philosophy' is to keep the Kconfig symbols, replace
the #ifdef approach by having each feature implemented it its own C file,
and force compilation for all features to avoid the code bit-rot problem.
With this strategy only features that are enabled via Kconfig get
linked into the kernel, so the forced compilation has no size impact
on the kernel. The practice of having each feature implemented in its own
C file is already prevalent in many subsystems, however #ifdefs are still
typically required during feature initialization. For instance in:

  #ifdef CONFIG_FOO
  foo_init();
  #endif

We cannot remove the #ifdef and leave foo_init() as we'd either
need to always enable the feature or add a respective #ifdef in a
foo.h which makes foo_init() do nothing when CONFIG_FOO is disabled.

Linker tables enable lifting the requirement to use of #ifdefs during
initialization. With linker tables initialization sequences can instead
be aggregated into a custom ELF section at link time, during run time
the table can be iterated over and each init sequence enabled can be called.
A feature's init routine is only added to a table when its respective
Kconfig symbols has been enabled and therefore linked in. Linker tables
enable subsystems to completely do away with #ifdefs if one is comfortable
in accepting all subsystem's feature's structural size implications.

Subsystems which want to follow the 'build-all link-selectively
philosophy' still need a way to easily express and annotate that they
wish for all code to always be compiled to help avoid code bit rot,
as such two new targets force-obj-y and force-lib-y are provided to
help with this. Its not fair to require everyone to force compilation
of all features of a subsystem though, so as a compromise, the new
targets only force compilation when CONFIG_BUILD_AVOID_BITROT is
enabled.

Only built-in features are supported at the moment. Module support
is expected to be added after a generic solution to add linker
tables to modules more easily is developed.

v4: this patch was added to this series, it was split off from the
linker tables addition due to the confusion over the code bit
rot alternatives that are possible with linker tables.

Signed-off-by: Luis R. Rodriguez 
---
 Documentation/kbuild/makefiles.txt   | 36 
 Documentation/sections/linker-tables.rst | 15 +++
 include/linux/tables.h   | 71 
 init/Kconfig | 22 ++
 scripts/Makefile.build   |  7 ++--
 scripts/Makefile.lib | 11 +
 6 files changed, 159 insertions(+), 3 deletions(-)

diff --git a/Documentation/kbuild/makefiles.txt 
b/Documentation/kbuild/makefiles.txt
index 385a5ef41c17..01c260913f5c 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -1089,6 +1089,42 @@ When kbuild executes, the following steps are followed 
(roughly):
In this example, extra-y is used to list object files that
shall be built, but shall not be linked as part of built-in.o.
 
+force-obj-y force-lib-y
+
+   When CONFIG_BUILD_AVOID_BITROT is enabled using these targets for your
+   kconfig symbols forces compilation of the associated objects if the
+   kconfig's symbol's dependencies are met, the objects however are only
+   linked into to the kernel if and only if the kconfig symbol was
+   enabled. If CONFIG_BUILD_AVOID_BITROT is disabled the force-obj-y and
+   force-lib-y targets are functionally equilvalent to obj-y and lib-y
+   respectively.
+
+   Using force-obj-y and force-lib-y are part of a code architecture and
+   build philosophy further enabled by linker tables, for more details
+   refer to the documention in include/linux/tables.h, refer to the
+   sections:
+
+   o The code bit-rot problem
+   o The build-all selective-link philosophy
+   o Avoiding the code bit-rot problem with linker tables
+   o Linker table module support
+
+   Modules support is expected to be enhanced in the 

[Xen-devel] [PATCH v4 01/16] x86: remove LTO_REFERENCE_INITCALL()

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

The setup for LTO never made it upstream, and although this has
some users, this is now really old stuff for a gcc 4.7 LTO problem.
We know that at least LTO_REFERENCE_INITCALL() work around can
be removed if LTO is not supported on v4.7 anymore.

As per Andi the DISABLE_LTO and LTO_CFLAGS are still neeeded though.

v3: added to this series, removing LTO_REFERENCE_INITCALL()
justifies that other future similar macros do not need
a respective LTO_REFERENCE_INITCALL() on them therefore
simplifying new code.

Acked-by: Andi Kleen 
Signed-off-by: Luis R. Rodriguez 
---
 include/linux/init.h | 20 +---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/include/linux/init.h b/include/linux/init.h
index 1e5c131d5c9a..aa662ad80d9c 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -151,23 +151,6 @@ extern bool initcall_debug;
 
 #ifndef __ASSEMBLY__
 
-#ifdef CONFIG_LTO
-/* Work around a LTO gcc problem: when there is no reference to a variable
- * in a module it will be moved to the end of the program. This causes
- * reordering of initcalls which the kernel does not like.
- * Add a dummy reference function to avoid this. The function is
- * deleted by the linker.
- */
-#define LTO_REFERENCE_INITCALL(x) \
-   ; /* yes this is needed */  \
-   static __used __exit void *reference_##x(void)  \
-   {   \
-   return   \
-   }
-#else
-#define LTO_REFERENCE_INITCALL(x)
-#endif
-
 /* initcalls are now grouped by functionality into separate 
  * subsections. Ordering inside the subsections is determined
  * by link order. 
@@ -180,8 +163,7 @@ extern bool initcall_debug;
 
 #define __define_initcall(fn, id) \
static initcall_t __initcall_##fn##id __used \
-   __attribute__((__section__(".initcall" #id ".init"))) = fn; \
-   LTO_REFERENCE_INITCALL(__initcall_##fn##id)
+   __attribute__((__section__(".initcall" #id ".init"))) = fn;
 
 /*
  * Early initcalls run before initializing SMP.
-- 
2.9.2


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


[Xen-devel] [PATCH v4 06/16] ranges.h: add helpers to build and identify Linux section ranges

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

Section ranges are on one of the types of custom sections
types used in Linux. This provides a series of helpers for
defining them and using them. Most importantly this also
enables us to avoid modifying the linker script when we
add a new section range.

It turns out a lot of custom sections are actually section ranges,
and these are typically spelled out in their architecture specific
asm/sections.h file -- we anable architectures to override what asm
is used for section ranges but start by default trusting the
asm-generic version all around.

v4:

o tons of documentation love
o fix arch/x86/tools/relocs.c typo - which caused compilation issues
  on old toolchains
o port to new shiny sphinx documentation
o sprinkle a few more needed VMLINUX_SYMBOL() - fixes
  compilation on blackfin
o name changes as suggested 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
- rebrand DECLARE_SECTION_RNG() as DEFINE_SECTION_RANGE() - this is
  the asm version of the respective C version, this will have a
  userspace C demo added later.
o move __LINUX_RANGE() and __LINUX_RANGE_ORDER() - fixes builds
  on sparc
o adds section ranges to linker script
o rename SECTION_RANGE_ALL()
o use default alignment, fixes builds on powerpc and arm for both
  __LINUX_RANGE() and __LINUX_RANGE_ORDER()
o expand documentation to document modules support
o add maintainers
o use generic-y

v3: new in this series, uses copyleft-next

Signed-off-by: Luis R. Rodriguez 
---
 Documentation/sections/index.rst   |   1 +
 Documentation/sections/ranges.rst  |  49 ++
 MAINTAINERS|  10 +++
 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/Kbuild  |   1 +
 arch/x86/include/asm/Kbuild|   1 +
 arch/x86/tools/relocs.c|   2 +
 arch/xtensa/include/asm/Kbuild |   1 +
 include/asm-generic/ranges.h   |  89 ++
 include/asm-generic/vmlinux.lds.h  |  12 +++-
 include/linux/ranges.h | 128 +
 38 files changed, 320 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/sections/ranges.rst
 create mode 100644 include/asm-generic/ranges.h
 create mode 100644 include/linux/ranges.h

diff --git a/Documentation/sections/index.rst b/Documentation/sections/index.rst
index d411e9b22eb3..6dd93ddd5dbe 100644
--- a/Documentation/sections/index.rst
+++ b/Documentation/sections/index.rst
@@ -9,3 +9,4 @@ used throughout the kernel to help declare and define them.
:maxdepth: 4
 
section-core
+   ranges
diff --git a/Documentation/sections/ranges.rst 
b/Documentation/sections/ranges.rst
new file mode 100644
index ..1293dcb3ab38
--- /dev/null
+++ b/Documentation/sections/ranges.rst
@@ -0,0 +1,49 @@
+
+Linux section ranges
+
+
+This documents Linux' use of section ranges, how you can use
+them and how they work.
+
+About section ranges
+
+
+Introduction
+
+.. kernel-doc:: include/linux/ranges.h
+   :doc: Introduction
+
+Section range module support
+
+.. kernel-doc:: include/linux/ranges.h
+   :doc: Section range module support
+
+Section range helpers
+=
+.. kernel-doc:: include/linux/ranges.h
+   :doc: Section range helpers
+
+DECLARE_SECTION_RANGE
+-
+.. kernel-doc:: include/linux/ranges.h
+   :functions: DECLARE_SECTION_RANGE
+
+DEFINE_SECTION_RANGE
+
+.. kernel-doc:: include/linux/ranges.h
+   :functions: DEFINE_SECTION_RANGE
+
+SECTION_ADDR_IN_RANGE
+-

[Xen-devel] [PATCH v4 05/16] xtensa: skip adding literal when SORT() is used

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

When SORT(foo.*) is used the current sed replacements add
SORT(foo.literal foo.*), this breaks linking. Avoid adding
literals for SORT globs, if needed, these need to be added
manually.

Signed-off-by: Luis R. Rodriguez 
---
 arch/xtensa/kernel/Makefile | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/xtensa/kernel/Makefile b/arch/xtensa/kernel/Makefile
index c31f5d5afc7d..8180850ed147 100644
--- a/arch/xtensa/kernel/Makefile
+++ b/arch/xtensa/kernel/Makefile
@@ -29,10 +29,10 @@ AFLAGS_mxhead.o += -mtext-section-literals
 #
 # Replicate rules in scripts/Makefile.build
 
-sed-y = -e ':a; s/\*(\([^)]*\)\.text\.unlikely/*(\1.literal.unlikely 
.{text}.unlikely/; ta; ' \
-   -e ':b; s/\*(\([^)]*\)\.text\(\.[a-z]*\)/*(\1.{text}\2.literal 
.{text}\2/; tb; ' \
-   -e ':c; s/\*(\([^)]*\)\(\.[a-z]*it\|\.ref\)\.text/*(\1\2.literal 
\2.{text}/; tc; ' \
-   -e ':d; s/\*(\([^)]\+ \|\)\.text/*(\1.literal .{text}/; td; ' \
+sed-y = -e ':a; s/\*(\([^)SORT]*\)\.text\.unlikely/*(\1.literal.unlikely 
.{text}.unlikely/; ta; ' \
+   -e ':b; s/\*(\([^)SORT]*\)\.text\(\.[a-z]*\)/*(\1.{text}\2.literal 
.{text}\2/; tb; ' \
+   -e ':c; s/\*(\([^SORT)]*\)\(\.[a-z]*it\|\.ref\)\.text/*(\1\2.literal 
\2.{text}/; tc; ' \
+   -e ':d; s/\*(\([^SORT)]\+ \|\)\.text/*(\1.literal .{text}/; td; ' \
-e 's/\.{text}/.text/g'
 
 quiet_cmd__cpp_lds_S = LDS $@
-- 
2.9.2


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


[Xen-devel] [PATCH v4 03/16] scripts/module-common.lds: enable generation

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

scripts/module-common.lds is currently pretty static, in the
future this may change and we will want access to kernel macros
to help expands certain areas. To get access to use macros we
need to generate module-common.lds from module-common.lds.S, for
now though only enable the generation. We'll later expand on this
as needed.

Since this file is now generated add it to .gitignore.

v4: add file to MAINTAINERS
v3: new to this series

Signed-off-by: Luis R. Rodriguez 
---
 .gitignore | 2 ++
 MAINTAINERS| 1 +
 Makefile   | 6 +-
 scripts/Makefile.modpost   | 2 +-
 scripts/{module-common.lds => module-common.lds.S} | 0
 5 files changed, 9 insertions(+), 2 deletions(-)
 rename scripts/{module-common.lds => module-common.lds.S} (100%)

diff --git a/.gitignore b/.gitignore
index c2ed4ecb0acd..0f0702054fdb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -114,3 +114,5 @@ all.config
 
 # Kdevelop4
 *.kdev4
+
+scripts/module-common.lds
diff --git a/MAINTAINERS b/MAINTAINERS
index d635ab047f3a..5aec01883020 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7887,6 +7887,7 @@ M:Rusty Russell 
 S: Maintained
 F: include/linux/module.h
 F: kernel/module.c
+F: scripts/module-common.lds.S
 
 MOTION EYE VAIO PICTUREBOOK CAMERA DRIVER
 W: http://popies.net/meye/
diff --git a/Makefile b/Makefile
index 5c18baad7218..b3e5ea78d582 100644
--- a/Makefile
+++ b/Makefile
@@ -408,6 +408,10 @@ KBUILD_AFLAGS_MODULE  := -DMODULE
 KBUILD_CFLAGS_MODULE  := -DMODULE
 KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
 
+$(srctree)/scripts/module-common.lds: $(srctree)/scripts/module-common.lds.S
+   $(Q)$(CC) $(CFLAGS) $(INCLUDES) $(LINUXINCLUDE) -E -P \
+   -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
+
 # Read KERNELRELEASE from include/config/kernel.release (if it exists)
 KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
 KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if 
$(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
@@ -1174,7 +1178,7 @@ all: modules
 # using awk while concatenating to the final file.
 
 PHONY += modules
-modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
+modules: $(srctree)/scripts/module-common.lds $(vmlinux-dirs) $(if 
$(KBUILD_BUILTIN),vmlinux) modules.builtin
$(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > 
$(objtree)/modules.order
@$(kecho) '  Building modules, stage 2.';
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 1366a94b6c39..2d8aff7735d6 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -121,7 +121,7 @@ quiet_cmd_ld_ko_o = LD [M]  $@
  $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
  -o $@ $(filter-out FORCE,$^)
 
-$(modules): %.ko :%.o %.mod.o FORCE
+$(modules): %.ko : $(srctree)/scripts/module-common.lds %.o %.mod.o FORCE
$(call if_changed,ld_ko_o)
 
 targets += $(modules)
diff --git a/scripts/module-common.lds b/scripts/module-common.lds.S
similarity index 100%
rename from scripts/module-common.lds
rename to scripts/module-common.lds.S
-- 
2.9.2


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


[Xen-devel] [PATCH v4 02/16] dell-smo8800: include uaccess.h

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

sections.h is currently included and it provides dell-smo8800
with what it needs, an upcoming change will decouple uaccess.h
from sections.h. This driver needs to explicitly require uaccess.h
before this change.

v3: new to this series -- needed due to collateral of the split of
old linker tables from tables.h into 3 files: sections.h, ranges.h
and tables.h

Reviewed-by: Pali Rohár 
Signed-off-by: Luis R. Rodriguez 
---
 drivers/platform/x86/dell-smo8800.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/platform/x86/dell-smo8800.c 
b/drivers/platform/x86/dell-smo8800.c
index 0aec4fd4c48e..37e646034ef8 100644
--- a/drivers/platform/x86/dell-smo8800.c
+++ b/drivers/platform/x86/dell-smo8800.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct smo8800_device {
u32 irq; /* acpi device irq */
-- 
2.9.2


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