Skip to content

Commit b89fbb9

Browse files
authored
Merge pull request torvalds#603 from ddiss/lkl_mv_autoconf_to_kconfig
move some tools/lkl/Makefile.autoconf logic to kconfig
2 parents d2df129 + c9f0472 commit b89fbb9

File tree

6 files changed

+107
-126
lines changed

6 files changed

+107
-126
lines changed

arch/lkl/Kconfig

Lines changed: 89 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,112 @@
11
config LKL
2-
def_bool y
3-
depends on !SMP && !COREDUMP && !SECCOMP && !UPROBES && !COMPAT && !USER_RETURN_NOTIFIER
4-
select ARCH_THREAD_STACK_ALLOCATOR
5-
select GENERIC_ATOMIC64
6-
select GENERIC_HWEIGHT
7-
select FLATMEM
8-
select GENERIC_CLOCKEVENTS
9-
select GENERIC_CPU_DEVICES
10-
select NO_HZ_IDLE
11-
select NO_PREEMPT
12-
select ARCH_WANT_FRAME_POINTERS
13-
select UACCESS_MEMCPY
14-
select GENERIC_STRNCPY_FROM_USER
15-
select GENERIC_STRNLEN_USER
16-
select HAVE_ARCH_KASAN
17-
select TRACING
2+
def_bool y
3+
depends on !SMP && !COREDUMP && !SECCOMP && !UPROBES && !COMPAT && !USER_RETURN_NOTIFIER
4+
select ARCH_THREAD_STACK_ALLOCATOR
5+
select GENERIC_ATOMIC64
6+
select GENERIC_HWEIGHT
7+
select FLATMEM
8+
select GENERIC_CLOCKEVENTS
9+
select GENERIC_CPU_DEVICES
10+
select NO_HZ_IDLE
11+
select NO_PREEMPT
12+
select ARCH_WANT_FRAME_POINTERS
13+
select UACCESS_MEMCPY
14+
select GENERIC_STRNCPY_FROM_USER
15+
select GENERIC_STRNLEN_USER
16+
select HAVE_ARCH_KASAN
17+
select TRACING
1818

1919
config LKL_FUZZING
20-
bool "LLVM fuzzing instrumentation"
21-
default n
22-
help
23-
This configuration option enables fuzzing instrumentation
24-
for the Linux kernel source files to enable coverage-guided
25-
fuzzing. At the moment LKL supports libFuzzer fuzzing
26-
engine only.
20+
bool "LLVM fuzzing instrumentation"
21+
default n
22+
help
23+
This configuration option enables fuzzing instrumentation
24+
for the Linux kernel source files to enable coverage-guided
25+
fuzzing. At the moment LKL supports libFuzzer fuzzing
26+
engine only.
2727

2828
config LKL_LINE_COV
29-
bool "Code coverage instrumentation for fuzzers"
30-
depends on LKL_FUZZING && CC_IS_CLANG
31-
default n
32-
help
33-
This configuration option enables line code coverage
34-
instrumentation for the Linux kernel to generate fuzzing
35-
code coverage reports. When this option is enabled the
36-
kernel source files are built with LLVM SanitizerCoverage
37-
instrumentation.
29+
bool "Code coverage instrumentation for fuzzers"
30+
depends on LKL_FUZZING && CC_IS_CLANG
31+
default n
32+
help
33+
This configuration option enables line code coverage
34+
instrumentation for the Linux kernel to generate fuzzing
35+
code coverage reports. When this option is enabled the
36+
kernel source files are built with LLVM SanitizerCoverage
37+
instrumentation.
3838

3939
config OUTPUT_FORMAT
40-
string "Output format"
41-
default ""
40+
string "Output format"
41+
default $(shell,$(srctree)/arch/lkl/scripts/cc-objdump-file-format.sh)
4242

4343
config ARCH_DMA_ADDR_T_64BIT
44-
def_bool 64BIT
44+
def_bool 64BIT
4545

4646
config PHYS_ADDR_T_64BIT
47-
def_bool 64BIT
47+
def_bool 64BIT
4848

4949
config 64BIT
50-
bool "64bit kernel"
51-
default n
50+
bool "64bit kernel"
51+
default y if OUTPUT_FORMAT = "pe-x86-64"
52+
default $(success,$(srctree)/arch/lkl/scripts/cc-objdump-file-format.sh|grep -q '^elf64-') if OUTPUT_FORMAT != "pe-x86-64"
5253

5354
config MMU
54-
bool "LKL MMU implementation"
55-
depends on 64BIT
56-
default n
55+
bool "LKL MMU implementation"
56+
depends on 64BIT
57+
default n
5758

5859
if MMU
5960
config PGTABLE_LEVELS
60-
int
61-
default 3
61+
int
62+
default 3
6263

6364
config LKL_MEMORY_START
64-
hex
65-
default 0x50000000
66-
help
67-
Base address of kernel virtual address space for LKL. No particular
68-
reason for picking this specific value. It is assumed that the host
69-
mmap is able to map requested amount of memory at this address.
70-
STACK_TOP and VMALLOC_START values depend on it.
71-
65+
hex
66+
default 0x50000000
67+
help
68+
Base address of kernel virtual address space for LKL. No particular
69+
reason for picking this specific value. It is assumed that the host
70+
mmap is able to map requested amount of memory at this address.
71+
STACK_TOP and VMALLOC_START values depend on it.
7272

7373
config LKL_TASK_UNMAPPED_BASE
74-
hex
75-
default 0x100000
76-
help
77-
Starting virtual address for LKL user-space mmap. It is assumed that
78-
the host mmap is able to map requested amount of memory starting from
79-
this address.
74+
hex
75+
default 0x100000
76+
help
77+
Starting virtual address for LKL user-space mmap. It is assumed that
78+
the host mmap is able to map requested amount of memory starting from
79+
this address.
8080

8181
config LKL_MMU_KUNIT_TEST
82-
bool "Kunit tests for LKL MMU"
83-
default n
84-
depends on KUNIT
85-
help
86-
Kunit tests to test correctness of MMU-related kernel interfaces (such
87-
as vmalloc, for example) which are difficult to test in user-space.
82+
bool "Kunit tests for LKL MMU"
83+
default n
84+
depends on KUNIT
85+
help
86+
Kunit tests to test correctness of MMU-related kernel interfaces (such
87+
as vmalloc, for example) which are difficult to test in user-space.
8888
endif
8989

9090
config COREDUMP
91-
def_bool n
91+
def_bool n
9292

9393
config CPU_BIG_ENDIAN
94-
bool "Big-endian kernel"
95-
default n
94+
bool "Big-endian kernel"
95+
default y if OUTPUT_FORMAT = "elf64-s390"
96+
default n if OUTPUT_FORMAT != "elf64-s390"
9697

9798
config GENERIC_CSUM
98-
def_bool y
99+
def_bool y
99100

100101
config GENERIC_HWEIGHT
101-
def_bool y
102+
def_bool y
102103

103104
config NO_IOPORT_MAP
104-
def_bool y
105+
def_bool y
105106

106107
config HZ
107-
int
108-
default 100
108+
int
109+
default 100
109110

110111
config CONSOLE_LOGLEVEL_QUIET
111112
int "quiet console loglevel (1-15)"
@@ -131,16 +132,18 @@ config RAID6_PQ_BENCHMARK
131132
default n
132133

133134
config STACKTRACE_SUPPORT
134-
def_bool y
135+
def_bool y
135136

136137
if KASAN
137138
config KASAN_SHADOW_OFFSET
138-
hex "KASAN shadow offset"
139-
default "0"
139+
hex "KASAN shadow offset"
140+
default "0x0000200000000000" if OUTPUT_FORMAT = "elf64-x86-64"
141+
default "0" if OUTPUT_FORMAT != "elf64-x86-64"
140142

141143
config KASAN_SHADOW_SIZE
142-
hex "KASAN shadow size"
143-
default "0"
144+
hex "KASAN shadow size"
145+
default "0x0000100000000000" if OUTPUT_FORMAT = "elf64-x86-64"
146+
default "0" if OUTPUT_FORMAT != "elf64-x86-64"
144147
endif
145148

146149
config BUILTIN_CMDLINE
@@ -154,21 +157,22 @@ config BUILTIN_CMDLINE
154157

155158
config LKL_HOST_MEMCPY
156159
bool "Host provides memcpy"
157-
default n
160+
default $(success,$(srctree)/arch/lkl/scripts/cc-objdump-file-format.sh|grep -q '^elf64-') if 64BIT
161+
default $(success,$(srctree)/arch/lkl/scripts/cc-objdump-file-format.sh|grep -q '^elf32-') if !64BIT
158162
help
159-
This options should be set (in tools/lkl/Makefile.autoconf)
160-
if the host provides a memcpy implementation.
163+
Set to "y" if LKL should call the host memcpy hook instead of
164+
performing memory copies manually.
161165

162166
config LKL_HOST_MEMSET
163167
bool "Host provides memset"
164-
default n
168+
default LKL_HOST_MEMCPY
165169
help
166-
This options should be set (in tools/lkl/Makefile.autoconf)
167-
if the host provides a memset implementation.
170+
Set to "y" if LKL should call the host memset hook instead of
171+
performing memory sets manually.
168172

169173
config LKL_HOST_MEMMOVE
170174
bool "Host provides memmove"
171-
default n
175+
default LKL_HOST_MEMCPY
172176
help
173-
This options should be set (in tools/lkl/Makefile.autoconf)
174-
if the host provides a memmove implementation.
177+
Set to "y" if LKL should call the host memmove hook instead of
178+
performing memory moves manually.

arch/lkl/configs/fuzzing_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
CONFIG_LKL_FUZZING=y
12
# CONFIG_LOCALVERSION_AUTO is not set
23
CONFIG_NO_HZ_IDLE=y
34
CONFIG_HIGH_RES_TIMERS=y
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
# Print the C compiler output file format, as determined by objdump.
5+
t=`mktemp` || exit 1
6+
echo 'void foo(void) {}' | $CC -x c - -c -o "$t" \
7+
&& $OBJDUMP -p "$t" | awk '/file format/ {print $4}'
8+
rm "$t"

include/linux/shmem_fs.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,17 @@ extern struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
110110
extern void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end);
111111
int shmem_unuse(unsigned int type);
112112

113+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
113114
extern bool shmem_is_huge(struct inode *inode, pgoff_t index, bool shmem_huge_force,
114115
struct mm_struct *mm, unsigned long vm_flags);
116+
#else
117+
static __always_inline bool shmem_is_huge(struct inode *inode, pgoff_t index, bool shmem_huge_force,
118+
struct mm_struct *mm, unsigned long vm_flags)
119+
{
120+
return false;
121+
}
122+
#endif
123+
115124
#ifdef CONFIG_SHMEM
116125
extern unsigned long shmem_swap_usage(struct vm_area_struct *vma);
117126
#else

mm/shmem.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -742,12 +742,6 @@ static long shmem_unused_huge_count(struct super_block *sb,
742742

743743
#define shmem_huge SHMEM_HUGE_DENY
744744

745-
bool shmem_is_huge(struct inode *inode, pgoff_t index, bool shmem_huge_force,
746-
struct mm_struct *mm, unsigned long vm_flags)
747-
{
748-
return false;
749-
}
750-
751745
static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
752746
struct shrink_control *sc, unsigned long nr_to_split)
753747
{

tools/lkl/Makefile.autoconf

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ define posix_host
8484
$(if $(filter $(1),elf32-i386),$(call set_autoconf_var,I386,y))
8585
$(if $(strip $(call find_include,jsmn.h)),$(call set_autoconf_var,JSMN,y))
8686
$(if $(filter %,$(zpoline)),$(call zpoline_conf,$(zpoline)))
87-
$(call set_kernel_config,LKL_HOST_MEMCPY,y)
88-
$(call set_kernel_config,LKL_HOST_MEMSET,y)
89-
$(call set_kernel_config,LKL_HOST_MEMMOVE,y)
9087
endef
9188

9289
define nt64_host
@@ -113,21 +110,6 @@ define nt_host
113110
$(if $(filter $(1),pe-x86-64),$(call nt64_host))
114111
endef
115112

116-
define s390_host
117-
$(call set_kernel_config,CPU_BIG_ENDIAN,y)
118-
endef
119-
120-
define 64bit_host
121-
$(call set_kernel_config,64BIT,y)
122-
endef
123-
124-
define kasan_x86_64
125-
$(call set_autoconf_var,KASAN_SHADOW_OFFSET,0x0000200000000000)
126-
$(call set_kernel_config,KASAN_SHADOW_OFFSET,0x0000200000000000)
127-
$(call set_autoconf_var,KASAN_SHADOW_SIZE,0x0000100000000000)
128-
$(call set_kernel_config,KASAN_SHADOW_SIZE,0x0000100000000000)
129-
endef
130-
131113
define kasan_test_enable
132114
$(call set_autoconf_var,KASAN_TEST,y)
133115
$(call set_kernel_config,KUNIT,y)
@@ -138,10 +120,6 @@ endef
138120
define kasan_enable
139121
$(call set_autoconf_var,KASAN,y)
140122
$(call set_kernel_config,KASAN,y)
141-
# default is 20 which should be 1MB but observed 8MB of reserved
142-
# memory - half of what we use
143-
$(call set_kernel_config,STACK_HASH_ORDER,12)
144-
$(if $(filter $(1),elf64-x86-64),$(call kasan_x86_64))
145123
$(if $(filter yes,$(kasan_test)), $(call kasan_test_enable))
146124
endef
147125

@@ -255,7 +233,6 @@ define do_autoconf_fuzzing
255233
$(eval LLVM := 1)
256234
$(eval CROSS_COMPILE := x86_64-linux-gnu)
257235
$(eval kasan := yes)
258-
$(call set_kernel_config,LKL_FUZZING,y)
259236
$(if $(LKL_LINE_COV),$(call set_kernel_config,LKL_LINE_COV,y))
260237
$(if $(MMU),$(call set_kernel_config,ANDROID_BINDER_IPC,y))
261238
$(if $(PROTOBUF_MUTATOR_DIR),$(call define_libprotobuf_mutator))
@@ -271,25 +248,13 @@ endef
271248
define do_autoconf_mmu
272249
$(call set_autoconf_var,MMU,y)
273250
$(call set_kernel_config,MMU,y)
274-
# Explicitly set LKL MMU configuration parameters for Kconfig
275-
$(call set_autoconf_var,LKL_MEMORY_START,0x50000000)
276-
$(call set_kernel_config,LKL_MEMORY_START,0x50000000)
277-
$(call set_autoconf_var,LKL_TASK_UNMAPPED_BASE,0x100000)
278-
$(call set_kernel_config,LKL_TASK_UNMAPPED_BASE,0x100000)
279-
# Don't need swap in LKL. CONFIG_SHMEM generates a compile-time assertion
280-
# when build with gcc, however, works fine with clang. The issues is in macro
281-
# HPAGE_PMD_SIZE which should be optimized out but is not in case of gcc.
282-
$(call set_kernel_config,SHMEM,n)
283251
$(if $(MMU_KUNIT), $(call mmu_test_enable))
284252
endef
285253

286254
define do_autoconf
287255
$(if $(LKL_FUZZING),$(call do_autoconf_fuzzing))
288256
$(if $(LLVM),$(call do_autoconf_llvm),$(call do_autoconf_gnu))
289257
$(eval EXEC_FMT := $(shell echo $(LD_FMT) | cut -d "-" -f1))
290-
$(call set_kernel_config,OUTPUT_FORMAT,\"$(LD_FMT)\")
291-
$(if $(or $(filter $(EXEC_FMT),elf64),$(filter $(LD_FMT),pe-x86-64)),$(call 64bit_host))
292-
$(if $(filter $(LD_FMT),elf64-s390),$(call s390_host))
293258
$(if $(filter $(EXEC_FMT),$(POSIX_HOSTS)),$(call posix_host,$(LD_FMT)))
294259
$(if $(filter $(EXEC_FMT),$(NT_HOSTS)),$(call nt_host,$(LD_FMT)))
295260
$(if $(and $(filter yes,$(kasan)),$(filter $(LD_FMT),$(KASAN_HOSTS))),$(call kasan_enable,$(LD_FMT)))

0 commit comments

Comments
 (0)