linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kbuild: limit dtc+cpp include path
@ 2013-02-12 22:03 Stephen Warren
  2013-02-12 23:09 ` Grant Likely
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Warren @ 2013-02-12 22:03 UTC (permalink / raw)
  To: Grant Likely, Rob Herring
  Cc: devicetree-discuss, Michal Marek, linux-kbuild, linux-kernel,
	Stephen Warren

From: Stephen Warren <swarren@nvidia.com>

Device tree source files may now include header files. The intent is
that those header files define/name constants used as part of the DT
bindings. Currently this feature is open to abuse, since any kernel
header file at all can be included, This could allow device tree files
to become dependant on kernel headers files, and thus make them no
longer OS-independent. This would also prevent separating the device
tree source files from the kernel repository.

Solve this by limiting the cpp include path for device tree files to
separate directories.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
Here, I allow header files in the .dts source directory, or in a per-arch
include directory. Perhaps rather than:

-I$(srctree)/arch/$(SRCARCH)/include/dts

The following might be better?:

-I$(srctree)/Documentation/devicetree/bindings

i.e. is there a need to separate binding-related headers per arch?

 scripts/Makefile.lib |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 7910229..07125e6 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -156,6 +156,11 @@ cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
 
 ld_flags       = $(LDFLAGS) $(ldflags-y)
 
+dtc_cpp_flags  = -Wp,-MD,$(depfile) -nostdinc                            \
+		 -I$(srctree)/arch/$(SRCARCH)/boot/dts                   \
+		 -I$(srctree)/arch/$(SRCARCH)/include/dts                \
+		 -undef -D__DTS__
+
 # Finds the multi-part object the current object will be linked into
 modname-multi = $(sort $(foreach m,$(multi-used),\
 		$(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))
@@ -272,8 +277,7 @@ $(obj)/%.dtb: $(src)/%.dts FORCE
 dtc-tmp = $(subst $(comma),_,$(dot-target).dts)
 
 quiet_cmd_dtc_cpp = DTC+CPP $@
-cmd_dtc_cpp = $(CPP) $(cpp_flags) -x assembler-with-cpp -undef -D__DTS__  \
-			-o $(dtc-tmp) $< ; \
+cmd_dtc_cpp = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
 	$(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) $(dtc-tmp)
 
 $(obj)/%.dtb: $(src)/%.dtsp FORCE
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kbuild: limit dtc+cpp include path
  2013-02-12 22:03 [PATCH] kbuild: limit dtc+cpp include path Stephen Warren
@ 2013-02-12 23:09 ` Grant Likely
  0 siblings, 0 replies; 2+ messages in thread
From: Grant Likely @ 2013-02-12 23:09 UTC (permalink / raw)
  To: Stephen Warren, Rob Herring
  Cc: devicetree-discuss, Michal Marek, linux-kbuild, linux-kernel,
	Stephen Warren

On Tue, 12 Feb 2013 15:03:37 -0700, Stephen Warren <swarren@wwwdotorg.org> wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> Device tree source files may now include header files. The intent is
> that those header files define/name constants used as part of the DT
> bindings. Currently this feature is open to abuse, since any kernel
> header file at all can be included, This could allow device tree files
> to become dependant on kernel headers files, and thus make them no
> longer OS-independent. This would also prevent separating the device
> tree source files from the kernel repository.
> 
> Solve this by limiting the cpp include path for device tree files to
> separate directories.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
> Here, I allow header files in the .dts source directory, or in a per-arch
> include directory. Perhaps rather than:
> 
> -I$(srctree)/arch/$(SRCARCH)/include/dts

That seems reasonable for now.

Applied, thanks.
g.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-02-12 23:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-12 22:03 [PATCH] kbuild: limit dtc+cpp include path Stephen Warren
2013-02-12 23:09 ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).