From 1ef678eccf179c95ee955eff5797205f25ed3b2c Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Tue, 9 Jun 2015 13:01:34 +0200 Subject: [PATCH 1/3] Kconfiglib scripts/kconfig/Makefile patch --- scripts/kconfig/Makefile | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index e46df0a2d4f9..5f04f0502f0c 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -25,6 +25,35 @@ xconfig: $(obj)/qconf gconfig: $(obj)/gconf $(Q)$< $(silent) $(Kconfig) +PHONY += scriptconfig iscriptconfig kmenuconfig guiconfig dumpvarsconfig + +PYTHONCMD ?= python +kpython := PYTHONPATH=$(srctree)/Kconfiglib:$$PYTHONPATH $(PYTHONCMD) + +ifneq ($(filter scriptconfig,$(MAKECMDGOALS)),) +ifndef SCRIPT +$(error Use "make scriptconfig SCRIPT= [SCRIPT_ARG=]") +endif +endif + +scriptconfig: + $(Q)$(kpython) $(SCRIPT) $(Kconfig) $(if $(SCRIPT_ARG),"$(SCRIPT_ARG)") + +iscriptconfig: + $(Q)$(kpython) -i -c \ + "import kconfiglib; \ + kconf = kconfiglib.Kconfig('$(Kconfig)'); \ + print('A Kconfig instance \'kconf\' for the architecture $(ARCH) has been created.')" + +kmenuconfig: + $(Q)$(kpython) $(srctree)/Kconfiglib/menuconfig.py $(Kconfig) + +guiconfig: + $(Q)$(kpython) $(srctree)/Kconfiglib/guiconfig.py $(Kconfig) + +dumpvarsconfig: + $(Q)$(kpython) $(srctree)/Kconfiglib/examples/dumpvars.py $(Kconfig) + menuconfig: $(obj)/mconf $(Q)$< $(silent) $(Kconfig) -- Gitee From cb709e6dd958f3ffb0dd986dbe1ae072b47cc425 Mon Sep 17 00:00:00 2001 From: huangjieliang Date: Thu, 4 May 2023 09:57:02 +0800 Subject: [PATCH 2/3] feat: Support pointer authentication for linux kernel. Signed-off-by: huangjieliang Change-Id: Ia6f2d6699b9e228bdabefea5958da3d22053389b --- arch/arm64/Kconfig | 111 ++++++++++++++++++---- arch/arm64/Makefile | 33 ++++++- arch/arm64/include/asm/asm_pointer_auth.h | 13 +++ arch/arm64/include/asm/pointer_auth.h | 22 ++++- arch/arm64/include/asm/processor.h | 4 +- arch/arm64/kernel/asm-offsets.c | 19 +++- arch/arm64/kernel/entry.S | 7 ++ arch/arm64/kernel/head.S | 3 + 8 files changed, 186 insertions(+), 26 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index ab6cbb944b36..b653345d26f4 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1530,31 +1530,20 @@ menu "ARMv8.3 architectural features" config ARM64_PTR_AUTH bool "Enable support for pointer authentication" - default y - depends on (CC_HAS_SIGN_RETURN_ADDRESS || CC_HAS_BRANCH_PROT_PAC_RET) && AS_HAS_PAC - # Modern compilers insert a .note.gnu.property section note for PAC - # which is only understood by binutils starting with version 2.33.1. - depends on LD_IS_LLD || LD_VERSION >= 233010000 || (CC_IS_GCC && GCC_VERSION < 90100) - depends on !CC_IS_CLANG || AS_HAS_CFI_NEGATE_RA_STATE - depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_REGS) + default n + depends on AS_HAS_PAC help Pointer authentication (part of the ARMv8.3 Extensions) provides - instructions for signing and authenticating pointers against secret - keys, which can be used to mitigate Return Oriented Programming (ROP) - and other attacks. + instructions for signing and authenticating pointers or data fields against + secret keys, which can be used to mitigate Return Oriented Programming (ROP), + Jump Oriented Programming (JOP), Data Oriented Programming (DOP) and other + attacks. This option enables these instructions at EL0 (i.e. for userspace). Choosing this option will cause the kernel to initialise secret keys for each process at exec() time, with these keys being context-switched along with the process. - If the compiler supports the -mbranch-protection or - -msign-return-address flag (e.g. GCC 7 or later), then this option - will also cause the kernel itself to be compiled with return address - protection. In this case, and if the target hardware is known to - support pointer authentication, then CONFIG_STACKPROTECTOR can be - disabled with minimal loss of protection. - The feature is detected at runtime. If the feature is not present in hardware it will not be advertised to userspace/KVM guest nor will it be enabled. @@ -1565,8 +1554,92 @@ config ARM64_PTR_AUTH but with the feature disabled. On such a system, this option should not be selected. - This feature works with FUNCTION_GRAPH_TRACER option only if - DYNAMIC_FTRACE_WITH_REGS is enabled. +config ARM64_PTR_AUTH_USER + bool "Use pointer authentication for user" + default n + depends on ARM64_PTR_AUTH + select ARM64_PTR_AUTH_KERNEL + help + Set the secret keys for the process userspace. This protects against + Return Oriented Programming, Jump Oriented Programming and Data Oriented + Programming attacks in case of userspace bugs. + +config ARM64_PTR_AUTH_KERNEL + bool "Use pointer authentication for kernel" + default n + depends on ARM64_PTR_AUTH + help + Enable ARM64_PTR_AUTH_BACK_CFI to protect against return-oriented + programming attacks. + Enable ARM64_PTR_AUTH_FWD_CFI to protect against jump-oriented + programming attacks. + Enable ARM64_PTR_AUTH_DATA_PTR to protect against (data pointers)-oriented + programming attacks. + Enable ARM64_PTR_AUTH_DATA_FIELD to protect against (data fields)-oriented + programming attacks. + +config ARM64_PTR_AUTH_BACK_CFI + bool "Kernel pointer authentication for backward-edge CFI" + default n + depends on ARM64_PTR_AUTH_KERNEL && (CC_HAS_PAC_BACK_CFI || CC_HAS_SIGN_RETURN_ADDRESS || CC_HAS_BRANCH_PROT_PAC_RET) + depends on LD_IS_LLD || LD_VERSION >= 233010000 || (CC_IS_GCC && GCC_VERSION < 90100) + depends on !CC_IS_CLANG || AS_HAS_CFI_NEGATE_RA_STATE + depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_REGS) + help + If the compiler supports the -mbranch-protection or + -msign-return-address flag (e.g. GCC 7 or later), then this option + will also cause the kernel itself to be compiled with return address + protection. In this case, and if the target hardware is known to + support pointer authentication, then CONFIG_STACKPROTECTOR can be + disabled with minimal loss of protection. + +config ARM64_PTR_AUTH_FWD_CFI + bool "Kernel pointer authentication for forward-edge CFI" + default n + depends on ARM64_PTR_AUTH_KERNEL && CC_HAS_PAC_FWD_CFI + help + This option will cause the kernel itself to be compiled with function pointers + protection. + +config ARM64_PTR_AUTH_FWD_CFI_DEBUG + bool "Debug forward-edge CFI type conflict" + default n + depends on ARM64_PTR_AUTH_KERNEL && CC_HAS_PAC_FWD_CFI + select ARM64_PTR_AUTH_FWD_CFI + help + Print all function address about type conflict. + +config ARM64_PTR_AUTH_DATA_PTR + bool "Kernel pointer authentication for data pointer" + default n + depends on ARM64_PTR_AUTH_KERNEL && CC_HAS_PAC_DATA_PTR + help + This option will cause the kernel itself to be compiled with data pointers + protection. + +config ARM64_PTR_AUTH_DATA_FIELD + bool "Kernel authentication for data field" + default n + depends on ARM64_PTR_AUTH_KERNEL && CC_HAS_PAC_DATA_FIELD + help + This option will cause the kernel itself to be compiled with data fields + protection. + +config ARM64_PTR_AUTH_EXT + def_bool y + depends on (ARM64_PTR_AUTH_BACK_CFI && CC_HAS_PAC_BACK_CFI) || (ARM64_PTR_AUTH_FWD_CFI || ARM64_PTR_AUTH_DATA_PTR || ARM64_PTR_AUTH_DATA_FIELD) + +config CC_HAS_PAC_FWD_CFI + def_bool $(cc-option,-mllvm -FECFI=true) + +config CC_HAS_PAC_BACK_CFI + def_bool $(cc-option,-mllvm -FGBECFI=true) + +config CC_HAS_PAC_DATA_PTR + def_bool $(cc-option,-mllvm -DFIDPP=true) + +config CC_HAS_PAC_DATA_FIELD + def_bool $(cc-option,-mllvm -DFIDPTAG=true) config CC_HAS_BRANCH_PROT_PAC_RET # GCC 9 or later, clang 8 or later diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 485b7dbd4f9e..8f9d0aa0b479 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -70,7 +70,13 @@ endif # off, this will be overridden if we are using branch protection. branch-prot-flags-y += $(call cc-option,-mbranch-protection=none) -ifeq ($(CONFIG_ARM64_PTR_AUTH),y) +ifeq ($(CONFIG_ARM64_PTR_AUTH_BACK_CFI),y) +ifeq ($(CONFIG_CC_HAS_PAC_BACK_CFI),y) +KBUILD_CFLAGS += -mllvm -FGBECFI=true -msign-return-address=none +ifeq ($(CONFIG_ARM64_BTI_KERNEL),y) +branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET_BTI) := -mbranch-protection=bti +endif +else branch-prot-flags-$(CONFIG_CC_HAS_SIGN_RETURN_ADDRESS) := -msign-return-address=all # We enable additional protection for leaf functions as there is some # narrow potential for ROP protection benefits and no substantial @@ -80,6 +86,26 @@ branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET_BTI) := -mbranch-protectio else branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET) := -mbranch-protection=pac-ret+leaf endif +endif +endif + +ifeq ($(CONFIG_ARM64_PTR_AUTH_FWD_CFI),y) +KBUILD_CFLAGS += -mllvm -FECFI=true +endif + +ifeq ($(CONFIG_ARM64_PTR_AUTH_DATA_PTR),y) +KBUILD_CFALGS += -mllvm -DFIDPP=true +endif + +ifeq ($(CONFIG_ARM64_PTR_AUTH_DATA_FIELD),y) +KBUILD_CFLAGS += -mllvm -DFIDPTAG=true +endif + +ifeq ($(CONFIG_ARM64_PTR_AUTH_EXT),y) +core-y += $(srctree)/../common_modules/pac/ +LINUXINCLUDE += -I$(srctree)/../common_modules/pac/arm64/include +endif + # -march=armv8.3-a enables the non-nops instructions for PAC, to avoid the # compiler to generate them and consequently to break the single image contract # we pass it only to the assembler. This option is utilized only in case of non @@ -87,7 +113,6 @@ endif ifeq ($(CONFIG_AS_HAS_PAC), y) asm-arch := armv8.3-a endif -endif KBUILD_CFLAGS += $(branch-prot-flags-y) @@ -99,6 +124,10 @@ endif ifdef asm-arch KBUILD_CFLAGS += -Wa,-march=$(asm-arch) \ -DARM64_ASM_ARCH='"$(asm-arch)"' +ifeq ($(CONFIG_AS_HAS_PAC), y) +KBUILD_CFLAGS += -march=$(asm-arch) +KBUILD_AFLAGS += -march=$(asm-arch) +endif endif ifeq ($(CONFIG_SHADOW_CALL_STACK), y) diff --git a/arch/arm64/include/asm/asm_pointer_auth.h b/arch/arm64/include/asm/asm_pointer_auth.h index 52dead2a8640..482b05aa1744 100644 --- a/arch/arm64/include/asm/asm_pointer_auth.h +++ b/arch/arm64/include/asm/asm_pointer_auth.h @@ -6,6 +6,9 @@ #include #include #include +#ifdef CONFIG_ARM64_PTR_AUTH_EXT +#include +#endif #ifdef CONFIG_ARM64_PTR_AUTH /* @@ -42,9 +45,15 @@ alternative_else_nop_endif .macro __ptrauth_keys_install_kernel_nosync tsk, tmp1, tmp2, tmp3 mov \tmp1, #THREAD_KEYS_KERNEL add \tmp1, \tsk, \tmp1 +#ifdef CONFIG_ARM64_PTR_AUTH_EXT + ldp \tmp2, \tmp3, [\tmp1, #PTRAUTH_KERNEL_KEY_APIB] + msr_s SYS_APIBKEYLO_EL1, \tmp2 + msr_s SYS_APIBKEYLO_EL1, \tmp3 +#else ldp \tmp2, \tmp3, [\tmp1, #PTRAUTH_KERNEL_KEY_APIA] msr_s SYS_APIAKEYLO_EL1, \tmp2 msr_s SYS_APIAKEYHI_EL1, \tmp3 +#endif .endm .macro ptrauth_keys_install_kernel_nosync tsk, tmp1, tmp2, tmp3 @@ -69,7 +78,11 @@ alternative_else_nop_endif mrs \tmp2, sctlr_el1 orr \tmp2, \tmp2, \tmp1 msr sctlr_el1, \tmp2 +#ifdef CONFIG_ARM64_PTR_AUTH_EXT + __ptrauth_keys_install_kernel_all \tsk, \tmp1, \tmp2, \tmp3 +#else __ptrauth_keys_install_kernel_nosync \tsk, \tmp1, \tmp2, \tmp3 +#endif isb .Lno_addr_auth\@: .endm diff --git a/arch/arm64/include/asm/pointer_auth.h b/arch/arm64/include/asm/pointer_auth.h index c6b4f0603024..54b6a10a7158 100644 --- a/arch/arm64/include/asm/pointer_auth.h +++ b/arch/arm64/include/asm/pointer_auth.h @@ -31,9 +31,22 @@ struct ptrauth_keys_user { }; struct ptrauth_keys_kernel { +#ifdef CONFIG_ARM64_PTR_AUTH_EXT + struct ptrauth_key apib; +#else struct ptrauth_key apia; +#endif }; +#ifdef CONFIG_ARM64_PTR_AUTH_EXT +struct ptrauth_keys_kernel_common { + struct ptrauth_key apia; + struct ptrauth_key apda; + struct ptrauth_key apdb; + struct ptrauth_key apga; +}; +#endif + static inline void ptrauth_keys_init_user(struct ptrauth_keys_user *keys) { if (system_supports_address_auth()) { @@ -57,15 +70,22 @@ do { \ static __always_inline void ptrauth_keys_init_kernel(struct ptrauth_keys_kernel *keys) { if (system_supports_address_auth()) +#ifdef CONFIG_ARM64_PTR_AUTH_EXT + get_random_bytes(&keys->apib, sizeof(keys->apib)); +#else get_random_bytes(&keys->apia, sizeof(keys->apia)); +#endif } static __always_inline void ptrauth_keys_switch_kernel(struct ptrauth_keys_kernel *keys) { if (!system_supports_address_auth()) return; - +#ifdef CONFIG_ARM64_PTR_AUTH_EXT + __ptrauth_key_install_nosync(APIB, keys->apib); +#else __ptrauth_key_install_nosync(APIA, keys->apia); +#endif isb(); } diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index 7c546c3487c9..ebecdc40af8a 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -148,8 +148,10 @@ struct thread_struct { unsigned long fault_address; /* fault info */ unsigned long fault_code; /* ESR_EL1 value */ struct debug_info debug; /* debugging */ -#ifdef CONFIG_ARM64_PTR_AUTH +#ifdef CONFIG_ARM64_PTR_AUTH_USER struct ptrauth_keys_user keys_user; +#endif +#ifdef CONFIG_ARM64_PTR_AUTH_KERNEL struct ptrauth_keys_kernel keys_kernel; #endif #ifdef CONFIG_ARM64_MTE diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c index 34ef70877de4..781fa3de0045 100644 --- a/arch/arm64/kernel/asm-offsets.c +++ b/arch/arm64/kernel/asm-offsets.c @@ -44,8 +44,10 @@ int main(void) #endif BLANK(); DEFINE(THREAD_CPU_CONTEXT, offsetof(struct task_struct, thread.cpu_context)); -#ifdef CONFIG_ARM64_PTR_AUTH +#ifdef CONFIG_ARM64_PTR_AUTH_USER DEFINE(THREAD_KEYS_USER, offsetof(struct task_struct, thread.keys_user)); +#endif +#ifdef CONFIG_ARM64_PTR_AUTH_KERNEL DEFINE(THREAD_KEYS_KERNEL, offsetof(struct task_struct, thread.keys_kernel)); #endif BLANK(); @@ -137,13 +139,24 @@ int main(void) DEFINE(SDEI_EVENT_INTREGS, offsetof(struct sdei_registered_event, interrupted_regs)); DEFINE(SDEI_EVENT_PRIORITY, offsetof(struct sdei_registered_event, priority)); #endif -#ifdef CONFIG_ARM64_PTR_AUTH +#ifdef CONFIG_ARM64_PTR_AUTH_USER DEFINE(PTRAUTH_USER_KEY_APIA, offsetof(struct ptrauth_keys_user, apia)); DEFINE(PTRAUTH_USER_KEY_APIB, offsetof(struct ptrauth_keys_user, apib)); DEFINE(PTRAUTH_USER_KEY_APDA, offsetof(struct ptrauth_keys_user, apda)); DEFINE(PTRAUTH_USER_KEY_APDB, offsetof(struct ptrauth_keys_user, apdb)); DEFINE(PTRAUTH_USER_KEY_APGA, offsetof(struct ptrauth_keys_user, apga)); - DEFINE(PTRAUTH_KERNEL_KEY_APIA, offsetof(struct ptrauth_keys_kernel, apia)); + BLANK(); +#endif +#ifdef CONFIG_ARM64_PTR_AUTH_KERNEL +#ifdef CONFIG_ARM64_PTR_AUTH_EXT + DEFINE(PTRAUTH_KERNEL_KEY_APIB, offsetof(struct ptrauth_keys_kernel, apib)); + DEFINE(PTRAUTH_KERNEL_KEY_APIA, offsetof(struct ptrauth_keys_kernel_common, apia)); + DEFINE(PTRAUTH_KERNEL_KEY_APDA, offsetof(struct ptrauth_keys_kernel_common, apda)); + DEFINE(PTRAUTH_KERNEL_KEY_APDB, offsetof(struct ptrauth_keys_kernel_common, apdb)); + DEFINE(PTRAUTH_KERNEL_KEY_APGA, offsetof(struct ptrauth_keys_kernel_common, apga)); +#else + DEFINE(PTRAUTH_KERNEL_KEY_APIA, offsetof(struct ptrauth_keys_kernel, apia)); +#endif BLANK(); #endif return 0; diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index d5bc1dbdd2fd..2f53e787447f 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -28,6 +28,9 @@ #include #include #include +#ifdef CONFIG_ARM64_PTR_AUTH_EXT +#include +#endif /* * Context tracking and irqflag tracing need to instrument transitions between @@ -219,7 +222,11 @@ alternative_else_nop_endif check_mte_async_tcf x22, x23 apply_ssbd 1, x22, x23 +#ifdef CONFIG_ARM64_PTR_AUTH_EXT + ptrauth_keys_install_kernel_all tsk, x20, x22, x23 +#else ptrauth_keys_install_kernel tsk, x20, x22, x23 +#endif scs_load tsk, x20 .else diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index f9119eea735e..444db57d6d7a 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -420,6 +420,9 @@ SYM_FUNC_START_LOCAL(__primary_switched) adr_l x5, init_task msr sp_el0, x5 // Save thread_info +#ifdef CONFIG_ARM64_PTR_AUTH_EXT + bl ptrauth_kernel_keys_init +#endif #ifdef CONFIG_ARM64_PTR_AUTH __ptrauth_keys_init_cpu x5, x6, x7, x8 #endif -- Gitee From 184a5a625f5cdfe63acb5f852283ece204450831 Mon Sep 17 00:00:00 2001 From: JerryH Date: Thu, 4 May 2023 02:00:14 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20scri?= =?UTF-8?q?pts/kconfig/Makefile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/kconfig/Makefile | 245 --------------------------------------- 1 file changed, 245 deletions(-) delete mode 100644 scripts/kconfig/Makefile diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile deleted file mode 100644 index 5f04f0502f0c..000000000000 --- a/scripts/kconfig/Makefile +++ /dev/null @@ -1,245 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# =========================================================================== -# Kernel configuration targets -# These targets are used from top-level makefile - -PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig \ - build_menuconfig build_nconfig build_gconfig build_xconfig - -ifdef KBUILD_KCONFIG -Kconfig := $(KBUILD_KCONFIG) -else -Kconfig := Kconfig -endif - -ifeq ($(quiet),silent_) -silent := -s -endif - -# We need this, in case the user has it in its environment -unexport CONFIG_ - -xconfig: $(obj)/qconf - $(Q)$< $(silent) $(Kconfig) - -gconfig: $(obj)/gconf - $(Q)$< $(silent) $(Kconfig) - -PHONY += scriptconfig iscriptconfig kmenuconfig guiconfig dumpvarsconfig - -PYTHONCMD ?= python -kpython := PYTHONPATH=$(srctree)/Kconfiglib:$$PYTHONPATH $(PYTHONCMD) - -ifneq ($(filter scriptconfig,$(MAKECMDGOALS)),) -ifndef SCRIPT -$(error Use "make scriptconfig SCRIPT= [SCRIPT_ARG=]") -endif -endif - -scriptconfig: - $(Q)$(kpython) $(SCRIPT) $(Kconfig) $(if $(SCRIPT_ARG),"$(SCRIPT_ARG)") - -iscriptconfig: - $(Q)$(kpython) -i -c \ - "import kconfiglib; \ - kconf = kconfiglib.Kconfig('$(Kconfig)'); \ - print('A Kconfig instance \'kconf\' for the architecture $(ARCH) has been created.')" - -kmenuconfig: - $(Q)$(kpython) $(srctree)/Kconfiglib/menuconfig.py $(Kconfig) - -guiconfig: - $(Q)$(kpython) $(srctree)/Kconfiglib/guiconfig.py $(Kconfig) - -dumpvarsconfig: - $(Q)$(kpython) $(srctree)/Kconfiglib/examples/dumpvars.py $(Kconfig) - -menuconfig: $(obj)/mconf - $(Q)$< $(silent) $(Kconfig) - -config: $(obj)/conf - $(Q)$< $(silent) --oldaskconfig $(Kconfig) - -nconfig: $(obj)/nconf - $(Q)$< $(silent) $(Kconfig) - -build_menuconfig: $(obj)/mconf - -build_nconfig: $(obj)/nconf - -build_gconfig: $(obj)/gconf - -build_xconfig: $(obj)/qconf - -localyesconfig localmodconfig: $(obj)/conf - $(Q)$(PERL) $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config - $(Q)if [ -f .config ]; then \ - cmp -s .tmp.config .config || \ - (mv -f .config .config.old.1; \ - mv -f .tmp.config .config; \ - $< $(silent) --oldconfig $(Kconfig); \ - mv -f .config.old.1 .config.old) \ - else \ - mv -f .tmp.config .config; \ - $< $(silent) --oldconfig $(Kconfig); \ - fi - $(Q)rm -f .tmp.config - -# These targets map 1:1 to the commandline options of 'conf' -# -# Note: -# syncconfig has become an internal implementation detail and is now -# deprecated for external use -simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \ - alldefconfig randconfig listnewconfig olddefconfig syncconfig \ - helpnewconfig yes2modconfig mod2yesconfig - -PHONY += $(simple-targets) - -$(simple-targets): $(obj)/conf - $(Q)$< $(silent) --$@ $(Kconfig) - -PHONY += savedefconfig defconfig - -savedefconfig: $(obj)/conf - $(Q)$< $(silent) --$@=defconfig $(Kconfig) - -defconfig: $(obj)/conf -ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),) - @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" - $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) -else - @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'" - $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG) -endif - -%_defconfig: $(obj)/conf - $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) - -configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@) - -%.config: $(obj)/conf - $(if $(call configfiles),, $(error No configuration exists for this target on this architecture)) - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles) - $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig - -PHONY += kvmconfig -kvmconfig: kvm_guest.config - @echo >&2 "WARNING: 'make $@' will be removed after Linux 5.10" - @echo >&2 " Please use 'make $<' instead." - -PHONY += xenconfig -xenconfig: xen.config - @echo >&2 "WARNING: 'make $@' will be removed after Linux 5.10" - @echo >&2 " Please use 'make $<' instead." - -PHONY += tinyconfig -tinyconfig: - $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config - -# CHECK: -o cache_dir= working? -PHONY += testconfig -testconfig: $(obj)/conf - $(Q)$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ - -o cache_dir=$(abspath $(obj)/tests/.cache) \ - $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no) -clean-files += tests/.cache - -# Help text used by make help -help: - @echo ' config - Update current config utilising a line-oriented program' - @echo ' nconfig - Update current config utilising a ncurses menu based program' - @echo ' menuconfig - Update current config utilising a menu based program' - @echo ' xconfig - Update current config utilising a Qt based front-end' - @echo ' gconfig - Update current config utilising a GTK+ based front-end' - @echo ' oldconfig - Update current config utilising a provided .config as base' - @echo ' localmodconfig - Update current config disabling modules not loaded' - @echo ' except those preserved by LMC_KEEP environment variable' - @echo ' localyesconfig - Update current config converting local mods to core' - @echo ' except those preserved by LMC_KEEP environment variable' - @echo ' defconfig - New config with default from ARCH supplied defconfig' - @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' - @echo ' allnoconfig - New config where all options are answered with no' - @echo ' allyesconfig - New config where all options are accepted with yes' - @echo ' allmodconfig - New config selecting modules when possible' - @echo ' alldefconfig - New config with all symbols set to default' - @echo ' randconfig - New config with random answer to all options' - @echo ' yes2modconfig - Change answers from yes to mod if possible' - @echo ' mod2yesconfig - Change answers from mod to yes if possible' - @echo ' listnewconfig - List new options' - @echo ' helpnewconfig - List new options and help text' - @echo ' olddefconfig - Same as oldconfig but sets new symbols to their' - @echo ' default value without prompting' - @echo ' tinyconfig - Configure the tiniest possible kernel' - @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' - -# =========================================================================== -# object files used by all kconfig flavours -common-objs := confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \ - symbol.o util.o - -$(obj)/lexer.lex.o: $(obj)/parser.tab.h -HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src) -HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src) - -# conf: Used for defconfig, oldconfig and related targets -hostprogs += conf -conf-objs := conf.o $(common-objs) - -# nconf: Used for the nconfig target based on ncurses -hostprogs += nconf -nconf-objs := nconf.o nconf.gui.o $(common-objs) - -HOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs) -HOSTCFLAGS_nconf.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) -HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) - -$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg - -# mconf: Used for the menuconfig target based on lxdialog -hostprogs += mconf -lxdialog := $(addprefix lxdialog/, \ - checklist.o inputbox.o menubox.o textbox.o util.o yesno.o) -mconf-objs := mconf.o $(lxdialog) $(common-objs) - -HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs) -$(foreach f, mconf.o $(lxdialog), \ - $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags))) - -$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg - -# qconf: Used for the xconfig target based on Qt -hostprogs += qconf -qconf-cxxobjs := qconf.o qconf-moc.o -qconf-objs := images.o $(common-objs) - -HOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs) -HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) -HOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) - -$(obj)/qconf.o: $(obj)/qconf-cfg - -quiet_cmd_moc = MOC $@ - cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@ - -$(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE - $(call if_changed,moc) - -targets += qconf-moc.cc - -# gconf: Used for the gconfig target based on GTK+ -hostprogs += gconf -gconf-objs := gconf.o images.o $(common-objs) - -HOSTLDLIBS_gconf = $(shell . $(obj)/gconf-cfg && echo $$libs) -HOSTCFLAGS_gconf.o = $(shell . $(obj)/gconf-cfg && echo $$cflags) - -$(obj)/gconf.o: $(obj)/gconf-cfg - -# check if necessary packages are available, and configure build flags -filechk_conf_cfg = $(CONFIG_SHELL) $< - -$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE - $(call filechk,conf_cfg) - -clean-files += *conf-cfg -- Gitee