From: Jan Kiszka <[email protected]>

This logically reverts ee56c6d71a4e: While exporting our config vars
from the top level worked fine, kbuild seems to pull in the kernel's
variables on each subdir recursion. E.g., CONFIG_ARM_GIC_V3 can leak
this way from Linux where it has different semantics and will break
GICv2 targets.

Fix this by including config.mk in each makefile that makes use of
config vars and is in a separate subdir.

config.mk is generated unconditionally. So remove the optional inclusion
in hypervisor/Makefile at this chance.

Signed-off-by: Jan Kiszka <[email protected]>
---
 Kbuild                            | 13 +++++--------
 hypervisor/Makefile               |  2 +-
 hypervisor/arch/arm-common/Kbuild |  2 ++
 hypervisor/arch/x86/Kbuild        |  2 ++
 inmates/lib/arm/Makefile.lib      |  2 ++
 inmates/lib/arm64/Makefile.lib    |  2 ++
 6 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/Kbuild b/Kbuild
index 620c856c..420dedc1 100644
--- a/Kbuild
+++ b/Kbuild
@@ -14,17 +14,14 @@
 INC_CONFIG_H = $(src)/hypervisor/include/jailhouse/config.h
 export INC_CONFIG_H
 
-define sed_config_mk
-       "/^#define \([^[:space:]]*\)[[:space:]]*1/!d; \
-       s/^#define \([^[:space:]]*\)[[:space:]]*1/\1=y\nexport \1/"
-endef
-
 define filechk_config_mk
 (                                                                      \
-       echo "\$$(foreach config,\$$(filter CONFIG_%,                   \
-               \$$(.VARIABLES)), \$$(eval undefine \$$(config)))";     \
+       echo "\$$(foreach config,\$$(filter CONFIG_%, \$$(.VARIABLES)), \
+                         \$$(eval undefine \$$(config)))";             \
        if [ -f $(INC_CONFIG_H) ]; then \
-               sed -e $(sed_config_mk) $(INC_CONFIG_H);                \
+               sed -e "/^#define \([^[:space:]]*\)[[:space:]]*1/!d;    \
+                       s/^#define \([^[:space:]]*\)[[:space:]]*1/\1=y/"\
+                   $(INC_CONFIG_H);                                    \
        fi                                                              \
 )
 endef
diff --git a/hypervisor/Makefile b/hypervisor/Makefile
index 279c4c4e..83b4e6c8 100644
--- a/hypervisor/Makefile
+++ b/hypervisor/Makefile
@@ -16,7 +16,7 @@
 # Copyright (c) Linux kernel developers, 2014
 #
 
--include $(GEN_CONFIG_MK)
+include $(GEN_CONFIG_MK)
 
 LINUXINCLUDE := -I$(src)/arch/$(SRCARCH)/include \
                -I$(src)/arch/$(SRCARCH)/include/generated \
diff --git a/hypervisor/arch/arm-common/Kbuild 
b/hypervisor/arch/arm-common/Kbuild
index 7874b9e6..dc93c370 100644
--- a/hypervisor/arch/arm-common/Kbuild
+++ b/hypervisor/arch/arm-common/Kbuild
@@ -10,6 +10,8 @@
 # the COPYING file in the top-level directory.
 #
 
+include $(GEN_CONFIG_MK)
+
 GCOV_PROFILE := n
 ccflags-$(CONFIG_JAILHOUSE_GCOV) += -fprofile-arcs -ftest-coverage
 
diff --git a/hypervisor/arch/x86/Kbuild b/hypervisor/arch/x86/Kbuild
index 07bb04f0..a8483c14 100644
--- a/hypervisor/arch/x86/Kbuild
+++ b/hypervisor/arch/x86/Kbuild
@@ -12,6 +12,8 @@
 # the COPYING file in the top-level directory.
 #
 
+include $(GEN_CONFIG_MK)
+
 GCOV_PROFILE := n
 ccflags-$(CONFIG_JAILHOUSE_GCOV) += -fprofile-arcs -ftest-coverage
 
diff --git a/inmates/lib/arm/Makefile.lib b/inmates/lib/arm/Makefile.lib
index f84b84e8..369304bc 100644
--- a/inmates/lib/arm/Makefile.lib
+++ b/inmates/lib/arm/Makefile.lib
@@ -12,6 +12,8 @@
 # the COPYING file in the top-level directory.
 #
 
+include $(GEN_CONFIG_MK)
+
 KBUILD_AFLAGS := $(filter-out -include asm/unified.h,$(KBUILD_AFLAGS))
 
 LINUXINCLUDE += -I$(INMATES_LIB)/include
diff --git a/inmates/lib/arm64/Makefile.lib b/inmates/lib/arm64/Makefile.lib
index 7481f8d5..8a3d7543 100644
--- a/inmates/lib/arm64/Makefile.lib
+++ b/inmates/lib/arm64/Makefile.lib
@@ -12,6 +12,8 @@
 # the COPYING file in the top-level directory.
 #
 
+include $(GEN_CONFIG_MK)
+
 LINUXINCLUDE += -I$(INMATES_LIB)/include
 LINUXINCLUDE += -I$(INMATES_LIB)/../arm-common/include
 
-- 
2.12.3

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to