Merge branch 'android14-5.15' into arpi-5.15.92
This commit is contained in:
@@ -86,7 +86,8 @@ ifdef need-builtin
|
||||
targets-for-builtin += $(obj)/built-in.a
|
||||
endif
|
||||
|
||||
targets-for-modules := $(patsubst %.o, %.mod, $(filter %.o, $(obj-m)))
|
||||
targets-for-modules := $(foreach x, o mod $(if $(CONFIG_TRIM_UNUSED_KSYMS), usyms), \
|
||||
$(patsubst %.o, %.$x, $(filter %.o, $(obj-m))))
|
||||
|
||||
ifdef CONFIG_LTO_CLANG
|
||||
targets-for-modules += $(patsubst %.o, %.lto.o, $(filter %.o, $(obj-m)))
|
||||
@@ -261,9 +262,6 @@ objtool_dep = $(objtool_obj) \
|
||||
ifdef CONFIG_TRIM_UNUSED_KSYMS
|
||||
cmd_gen_ksymdeps = \
|
||||
$(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd
|
||||
|
||||
# List module undefined symbols
|
||||
undefined_syms = $(NM) $< | $(AWK) '$$1 == "U" { printf("%s%s", x++ ? " " : "", $$2) }';
|
||||
endif
|
||||
|
||||
define rule_cc_o_c
|
||||
@@ -310,14 +308,18 @@ $(obj)/%.lto.o: $(obj)/%.o FORCE
|
||||
$(call if_changed,cc_lto_link_modules)
|
||||
endif
|
||||
|
||||
cmd_mod = { \
|
||||
echo $(if $($*-objs)$($*-y)$($*-m), $(addprefix $(obj)/, $($*-objs) $($*-y) $($*-m)), $(@:.mod=.o)); \
|
||||
$(undefined_syms) echo; \
|
||||
} > $@
|
||||
cmd_mod = printf '%s\n' $(call real-search, $*.o, .o, -objs -y -m) | \
|
||||
$(AWK) '!x[$$0]++ { print("$(obj)/"$$0) }' > $@
|
||||
|
||||
$(obj)/%.mod: $(obj)/%$(mod-prelink-ext).o FORCE
|
||||
$(obj)/%.mod: FORCE
|
||||
$(call if_changed,mod)
|
||||
|
||||
# List module undefined symbols
|
||||
cmd_undefined_syms = $(NM) $< | sed -n 's/^ *U //p' > $@
|
||||
|
||||
$(obj)/%.usyms: $(obj)/%$(mod-prelink-ext).o FORCE
|
||||
$(call if_changed,undefined_syms)
|
||||
|
||||
quiet_cmd_cc_lst_c = MKLST $@
|
||||
cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
|
||||
$(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
|
||||
@@ -467,26 +469,21 @@ quiet_cmd_ar_lib = AR $@
|
||||
$(obj)/lib.a: $(lib-y) FORCE
|
||||
$(call if_changed,ar_lib)
|
||||
|
||||
# NOTE:
|
||||
# Do not replace $(filter %.o,^) with $(real-prereqs). When a single object
|
||||
# module is turned into a multi object module, $^ will contain header file
|
||||
# dependencies recorded in the .*.cmd file.
|
||||
ifdef CONFIG_LTO_CLANG
|
||||
quiet_cmd_link_multi-m = AR [M] $@
|
||||
cmd_link_multi-m = \
|
||||
$(cmd_update_lto_symversions); \
|
||||
rm -f $@; \
|
||||
$(AR) cDPrsT $@ $(filter %.o,$^)
|
||||
$(AR) cDPrsT $@ @$(patsubst %.o,%.mod,$@)
|
||||
else
|
||||
quiet_cmd_link_multi-m = LD [M] $@
|
||||
cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^)
|
||||
cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ @$(patsubst %.o,%.mod,$@)
|
||||
endif
|
||||
|
||||
$(multi-obj-m): FORCE
|
||||
$(multi-obj-m): %.o: %.mod FORCE
|
||||
$(call if_changed,link_multi-m)
|
||||
$(call multi_depend, $(multi-obj-m), .o, -objs -y -m)
|
||||
|
||||
targets += $(multi-obj-m)
|
||||
targets := $(filter-out $(PHONY), $(targets))
|
||||
|
||||
# Add intermediate targets:
|
||||
|
||||
@@ -219,7 +219,9 @@ cpp_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
|
||||
|
||||
ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F))
|
||||
|
||||
DTC_INCLUDE := $(srctree)/scripts/dtc/include-prefixes
|
||||
# ANDROID: Allow DTC_INCLUDE to be set by the BUILD_CONFIG. This allows one to
|
||||
# compile an out-of-tree device tree.
|
||||
DTC_INCLUDE += $(srctree)/scripts/dtc/include-prefixes
|
||||
|
||||
dtc_cpp_flags = -Wp,-MMD,$(depfile).pre.tmp -nostdinc \
|
||||
$(addprefix -I,$(DTC_INCLUDE)) \
|
||||
@@ -236,9 +238,9 @@ endif
|
||||
# Usage:
|
||||
# $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
|
||||
define multi_depend
|
||||
$(foreach m, $(notdir $1), \
|
||||
$(eval $(obj)/$m: \
|
||||
$(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
|
||||
$(foreach m, $1, \
|
||||
$(eval $m: \
|
||||
$(addprefix $(obj)/, $(call suffix-search, $(patsubst $(obj)/%,%,$m), $2, $3))))
|
||||
endef
|
||||
|
||||
quiet_cmd_copy = COPY $@
|
||||
@@ -415,19 +417,31 @@ printf "%08x\n" $$dec_size | \
|
||||
)
|
||||
|
||||
quiet_cmd_bzip2 = BZIP2 $@
|
||||
cmd_bzip2 = { cat $(real-prereqs) | $(KBZIP2) -9; $(size_append); } > $@
|
||||
cmd_bzip2 = cat $(real-prereqs) | $(KBZIP2) -9 > $@
|
||||
|
||||
quiet_cmd_bzip2_with_size = BZIP2 $@
|
||||
cmd_bzip2_with_size = { cat $(real-prereqs) | $(KBZIP2) -9; $(size_append); } > $@
|
||||
|
||||
# Lzma
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
quiet_cmd_lzma = LZMA $@
|
||||
cmd_lzma = { cat $(real-prereqs) | $(LZMA) -9; $(size_append); } > $@
|
||||
cmd_lzma = cat $(real-prereqs) | $(LZMA) -9 > $@
|
||||
|
||||
quiet_cmd_lzma_with_size = LZMA $@
|
||||
cmd_lzma_with_size = { cat $(real-prereqs) | $(LZMA) -9; $(size_append); } > $@
|
||||
|
||||
quiet_cmd_lzo = LZO $@
|
||||
cmd_lzo = { cat $(real-prereqs) | $(KLZOP) -9; $(size_append); } > $@
|
||||
cmd_lzo = cat $(real-prereqs) | $(KLZOP) -9 > $@
|
||||
|
||||
quiet_cmd_lzo_with_size = LZO $@
|
||||
cmd_lzo_with_size = { cat $(real-prereqs) | $(KLZOP) -9; $(size_append); } > $@
|
||||
|
||||
quiet_cmd_lz4 = LZ4 $@
|
||||
cmd_lz4 = { cat $(real-prereqs) | $(LZ4) -l -c1 stdin stdout; \
|
||||
cmd_lz4 = cat $(real-prereqs) | $(LZ4) -l -12 --favor-decSpeed stdin stdout > $@
|
||||
|
||||
quiet_cmd_lz4_with_size = LZ4 $@
|
||||
cmd_lz4_with_size = { cat $(real-prereqs) | $(LZ4) -l -12 --favor-decSpeed stdin stdout; \
|
||||
$(size_append); } > $@
|
||||
|
||||
# U-Boot mkimage
|
||||
@@ -470,7 +484,10 @@ quiet_cmd_uimage = UIMAGE $@
|
||||
# big dictionary would increase the memory usage too much in the multi-call
|
||||
# decompression mode. A BCJ filter isn't used either.
|
||||
quiet_cmd_xzkern = XZKERN $@
|
||||
cmd_xzkern = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh; \
|
||||
cmd_xzkern = cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh > $@
|
||||
|
||||
quiet_cmd_xzkern_with_size = XZKERN $@
|
||||
cmd_xzkern_with_size = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh; \
|
||||
$(size_append); } > $@
|
||||
|
||||
quiet_cmd_xzmisc = XZMISC $@
|
||||
@@ -496,7 +513,10 @@ quiet_cmd_zstd = ZSTD $@
|
||||
cmd_zstd = { cat $(real-prereqs) | $(ZSTD) -19; $(size_append); } > $@
|
||||
|
||||
quiet_cmd_zstd22 = ZSTD22 $@
|
||||
cmd_zstd22 = { cat $(real-prereqs) | $(ZSTD) -22 --ultra; $(size_append); } > $@
|
||||
cmd_zstd22 = cat $(real-prereqs) | $(ZSTD) -22 --ultra > $@
|
||||
|
||||
quiet_cmd_zstd22_with_size = ZSTD22 $@
|
||||
cmd_zstd22_with_size = { cat $(real-prereqs) | $(ZSTD) -22 --ultra; $(size_append); } > $@
|
||||
|
||||
# ASM offsets
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@@ -12,6 +12,8 @@ include $(srctree)/scripts/Kbuild.include
|
||||
# for c_flags and mod-prelink-ext
|
||||
include $(srctree)/scripts/Makefile.lib
|
||||
|
||||
mixed-build-prefix = $(if $(KBUILD_MIXED_TREE),$(KBUILD_MIXED_TREE)/)
|
||||
|
||||
# find all modules listed in modules.order
|
||||
modules := $(sort $(shell cat $(MODORDER)))
|
||||
|
||||
@@ -39,10 +41,10 @@ quiet_cmd_ld_ko_o = LD [M] $@
|
||||
|
||||
quiet_cmd_btf_ko = BTF [M] $@
|
||||
cmd_btf_ko = \
|
||||
if [ -f vmlinux ]; then \
|
||||
LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) --btf_base vmlinux $@; \
|
||||
if [ -f $(mixed-build-prefix)vmlinux ]; then \
|
||||
LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) --btf_base $(mixed-build-prefix)vmlinux $@; \
|
||||
else \
|
||||
printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \
|
||||
printf "Skipping BTF generation for %s due to unavailability of $(mixed-build-prefix)vmlinux\n" $@ 1>&2; \
|
||||
fi;
|
||||
|
||||
# Same as newer-prereqs, but allows to exclude specified extra dependencies
|
||||
@@ -55,8 +57,8 @@ if_changed_except = $(if $(call newer_prereqs_except,$(2))$(cmd-check), \
|
||||
|
||||
|
||||
# Re-generate module BTFs if either module's .ko or vmlinux changed
|
||||
$(modules): %.ko: %$(mod-prelink-ext).o %.mod.o scripts/module.lds $(if $(KBUILD_BUILTIN),vmlinux) FORCE
|
||||
+$(call if_changed_except,ld_ko_o,vmlinux)
|
||||
$(modules): %.ko: %$(mod-prelink-ext).o %.mod.o scripts/module.lds $(if $(KBUILD_BUILTIN),$(mixed-build-prefix)vmlinux) FORCE
|
||||
+$(call if_changed_except,ld_ko_o,$(mixed-build-prefix)vmlinux)
|
||||
ifdef CONFIG_DEBUG_INFO_BTF_MODULES
|
||||
+$(if $(newer-prereqs),$(call cmd,btf_ko))
|
||||
endif
|
||||
|
||||
@@ -24,6 +24,10 @@ suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz
|
||||
suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zst
|
||||
|
||||
modules := $(patsubst $(extmod_prefix)%, $(dst)/%$(suffix-y), $(modules))
|
||||
ifneq ($(KBUILD_EXTMOD),)
|
||||
extmod_suffix := $(shell echo "${KBUILD_EXTMOD}" | md5sum | cut -d " " -f 1)
|
||||
modules += $(dst)/modules.order.$(extmod_suffix)
|
||||
endif
|
||||
|
||||
__modinst: $(modules)
|
||||
@:
|
||||
@@ -82,6 +86,12 @@ $(dst)/%.ko: $(extmod_prefix)%.ko FORCE
|
||||
$(call cmd,strip)
|
||||
$(call cmd,sign)
|
||||
|
||||
ifneq ($(KBUILD_EXTMOD),)
|
||||
$(dst)/modules.order.$(extmod_suffix): $(MODORDER) FORCE
|
||||
$(call cmd,install)
|
||||
@sed -i "s:^$(KBUILD_EXTMOD):$(INSTALL_MOD_DIR):g" $@
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
$(dst)/%.ko: FORCE
|
||||
|
||||
@@ -44,6 +44,8 @@ include $(srctree)/scripts/Kbuild.include
|
||||
# for mod-prelink-ext
|
||||
include $(srctree)/scripts/Makefile.lib
|
||||
|
||||
mixed-build-prefix = $(if $(KBUILD_MIXED_TREE),$(KBUILD_MIXED_TREE)/)
|
||||
|
||||
MODPOST = scripts/mod/modpost \
|
||||
$(if $(CONFIG_MODVERSIONS),-m) \
|
||||
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \
|
||||
@@ -64,16 +66,17 @@ else
|
||||
|
||||
ifeq ($(KBUILD_EXTMOD),)
|
||||
|
||||
input-symdump := vmlinux.symvers
|
||||
input-symdump := $(mixed-build-prefix)vmlinux.symvers
|
||||
output-symdump := modules-only.symvers
|
||||
module_srcpath := $(srctree)
|
||||
|
||||
quiet_cmd_cat = GEN $@
|
||||
cmd_cat = cat $(real-prereqs) > $@
|
||||
|
||||
ifneq ($(wildcard vmlinux.symvers),)
|
||||
ifneq ($(wildcard $(mixed-build-prefix)vmlinux.symvers),)
|
||||
|
||||
__modpost: Module.symvers
|
||||
Module.symvers: vmlinux.symvers modules-only.symvers FORCE
|
||||
Module.symvers: $(mixed-build-prefix)vmlinux.symvers modules-only.symvers FORCE
|
||||
$(call if_changed,cat)
|
||||
|
||||
targets += Module.symvers
|
||||
@@ -95,6 +98,27 @@ MODPOST += -e
|
||||
input-symdump := Module.symvers $(KBUILD_EXTRA_SYMBOLS)
|
||||
output-symdump := $(KBUILD_EXTMOD)/Module.symvers
|
||||
|
||||
# Get the external module's source path. KBUILD_EXTMOD could either be an
|
||||
# absolute path or relative path from $(srctree). This makes sure that we
|
||||
# aren't using a relative path from a separate working directory (O= or
|
||||
# KBUILD_OUTPUT) since that may not be the actual module's SCM project path. So
|
||||
# check the path relative to $(srctree) first.
|
||||
ifneq ($(realpath $(srctree)/$(KBUILD_EXTMOD) 2>/dev/null),)
|
||||
module_srcpath := $(srctree)/$(KBUILD_EXTMOD)
|
||||
else
|
||||
module_srcpath := $(KBUILD_EXTMOD)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_MODULE_SCMVERSION),y)
|
||||
# Get the SCM version of the module. `sed` verifies setlocalversion returns
|
||||
# a proper revision based on the SCM type, e.g. git, mercurial, or svn.
|
||||
module_scmversion := $(shell $(srctree)/scripts/setlocalversion $(module_srcpath) | \
|
||||
sed -n 's/.*-\(\(g\|hg\)[a-fA-F0-9]\+\(-dirty\)\?\|svn[0-9]\+\).*/\1/p')
|
||||
ifneq ($(module_scmversion),)
|
||||
MODPOST += -v $(module_scmversion)
|
||||
endif
|
||||
endif
|
||||
|
||||
existing-input-symdump := $(wildcard $(input-symdump))
|
||||
|
||||
@@ -35,7 +35,7 @@ case "$KBUILD_VERBOSE" in
|
||||
esac
|
||||
|
||||
# Generate a new symbol list file
|
||||
$CONFIG_SHELL $srctree/scripts/gen_autoksyms.sh "$new_ksyms_file"
|
||||
$CONFIG_SHELL $srctree/scripts/gen_autoksyms.sh --modorder "$new_ksyms_file"
|
||||
|
||||
# Extract changes between old and new list and touch corresponding
|
||||
# dependency files.
|
||||
|
||||
@@ -157,10 +157,10 @@ def cmdfiles_for_modorder(modorder):
|
||||
if ext != '.ko':
|
||||
sys.exit('{}: module path must end with .ko'.format(ko))
|
||||
mod = base + '.mod'
|
||||
# The first line of *.mod lists the objects that compose the module.
|
||||
# Read from *.mod, to get a list of objects that compose the module.
|
||||
with open(mod) as m:
|
||||
for obj in m.readline().split():
|
||||
yield to_cmdfile(obj)
|
||||
for mod_line in m:
|
||||
yield to_cmdfile(mod_line.rstrip())
|
||||
|
||||
|
||||
def process_line(root_directory, command_prefix, file_path):
|
||||
|
||||
@@ -3,14 +3,15 @@
|
||||
#
|
||||
# A depmod wrapper used by the toplevel Makefile
|
||||
|
||||
if test $# -ne 2; then
|
||||
echo "Usage: $0 /sbin/depmod <kernelrelease>" >&2
|
||||
if test $# -ne 2 -a $# -ne 3; then
|
||||
echo "Usage: $0 /sbin/depmod <kernelrelease> [System.map folder]" >&2
|
||||
exit 1
|
||||
fi
|
||||
DEPMOD=$1
|
||||
KERNELRELEASE=$2
|
||||
KBUILD_MIXED_TREE=$3
|
||||
|
||||
if ! test -r System.map ; then
|
||||
if ! test -r ${KBUILD_MIXED_TREE}System.map ; then
|
||||
echo "Warning: modules_install: missing 'System.map' file. Skipping depmod." >&2
|
||||
exit 0
|
||||
fi
|
||||
@@ -41,7 +42,7 @@ if $depmod_hack_needed; then
|
||||
KERNELRELEASE=99.98.$KERNELRELEASE
|
||||
fi
|
||||
|
||||
set -- -ae -F System.map
|
||||
set -- -ae -F ${KBUILD_MIXED_TREE}System.map
|
||||
if test -n "$INSTALL_MOD_PATH"; then
|
||||
set -- "$@" -b "$INSTALL_MOD_PATH"
|
||||
fi
|
||||
|
||||
@@ -56,6 +56,7 @@ static void display_openssl_errors(int l)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_IS_BORINGSSL
|
||||
static void drain_openssl_errors(void)
|
||||
{
|
||||
const char *file;
|
||||
@@ -65,6 +66,7 @@ static void drain_openssl_errors(void)
|
||||
return;
|
||||
while (ERR_get_error_line(&file, &line)) {}
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ERR(cond, fmt, ...) \
|
||||
do { \
|
||||
@@ -119,6 +121,10 @@ int main(int argc, char **argv)
|
||||
fclose(f);
|
||||
exit(0);
|
||||
} else if (!strncmp(cert_src, "pkcs11:", 7)) {
|
||||
#ifdef OPENSSL_IS_BORINGSSL
|
||||
ERR(1, "BoringSSL does not support extracting from PKCS#11");
|
||||
exit(1);
|
||||
#else
|
||||
ENGINE *e;
|
||||
struct {
|
||||
const char *cert_id;
|
||||
@@ -141,6 +147,7 @@ int main(int argc, char **argv)
|
||||
ENGINE_ctrl_cmd(e, "LOAD_CERT_CTRL", 0, &parms, NULL, 1);
|
||||
ERR(!parms.cert, "Get X.509 from PKCS#11");
|
||||
write_cert(parms.cert);
|
||||
#endif
|
||||
} else {
|
||||
BIO *b;
|
||||
X509 *x509;
|
||||
|
||||
@@ -2,13 +2,10 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
# Create an autoksyms.h header file from the list of all module's needed symbols
|
||||
# as recorded on the second line of *.mod files and the user-provided symbol
|
||||
# whitelist.
|
||||
# as recorded in *.usyms files and the user-provided symbol whitelist.
|
||||
|
||||
set -e
|
||||
|
||||
output_file="$1"
|
||||
|
||||
# Use "make V=1" to debug this script.
|
||||
case "$KBUILD_VERBOSE" in
|
||||
*1*)
|
||||
@@ -19,6 +16,15 @@ esac
|
||||
# We need access to CONFIG_ symbols
|
||||
. include/config/auto.conf
|
||||
|
||||
read_modorder=
|
||||
|
||||
if [ "$1" = --modorder ]; then
|
||||
shift
|
||||
read_modorder=1
|
||||
fi
|
||||
|
||||
output_file="$1"
|
||||
|
||||
needed_symbols=
|
||||
|
||||
# Special case for modversions (see modpost.c)
|
||||
@@ -46,10 +52,8 @@ cat > "$output_file" << EOT
|
||||
|
||||
EOT
|
||||
|
||||
[ -f modules.order ] && modlist=modules.order || modlist=/dev/null
|
||||
|
||||
{
|
||||
sed 's/ko$/mod/' $modlist | xargs -n1 sed -n -e '2p'
|
||||
[ -n "${read_modorder}" ] && sed 's/ko$/usyms/' modules.order | xargs cat
|
||||
echo "$needed_symbols"
|
||||
[ -n "$ksym_wl" ] && cat "$ksym_wl"
|
||||
} | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' |
|
||||
@@ -57,4 +61,7 @@ EOT
|
||||
# point addresses.
|
||||
sed -e 's/^\.//' |
|
||||
sort -u |
|
||||
# Ignore __this_module. It's not an exported symbol, and will be resolved
|
||||
# when the final .ko's are linked.
|
||||
grep -v '^__this_module$' |
|
||||
sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file"
|
||||
|
||||
107
scripts/gen_gki_modules_headers.sh
Executable file
107
scripts/gen_gki_modules_headers.sh
Executable file
@@ -0,0 +1,107 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Copyright 2022 Google LLC
|
||||
# Author: ramjiyani@google.com (Ramji Jiyani)
|
||||
#
|
||||
|
||||
#
|
||||
# Generates hearder file with list of unprotected symbols
|
||||
#
|
||||
# Called By: KERNEL_SRC/kernel/Makefile if CONFIG_MODULE_SIG_PROTECT=y
|
||||
#
|
||||
# gki_module_unprotected.h: Symbols allowed to _access_ by unsigned modules
|
||||
#
|
||||
# If valid symbol file doesn't exists then still generates valid C header files for
|
||||
# compilation to proceed with no symbols to protect
|
||||
#
|
||||
|
||||
# Collect arguments from Makefile
|
||||
TARGET=$1
|
||||
SRCTREE=$2
|
||||
SYMBOL_LIST=$3
|
||||
|
||||
set -e
|
||||
|
||||
#
|
||||
# Common Definitions
|
||||
#
|
||||
# Use "make V=1" to debug this script.
|
||||
case "$KBUILD_VERBOSE" in
|
||||
*1*)
|
||||
set -x
|
||||
;;
|
||||
esac
|
||||
|
||||
#
|
||||
# generate_header():
|
||||
# Args: $1 = Name of the header file
|
||||
# $2 = Input symbol list
|
||||
# $3 = Symbol type (protected/exported)
|
||||
#
|
||||
generate_header() {
|
||||
local header_file=$1
|
||||
local symbol_file=$2
|
||||
local symbol_type=$3
|
||||
|
||||
if [ -f "${header_file}" ]; then
|
||||
rm -f -- "${header_file}"
|
||||
fi
|
||||
|
||||
# If symbol_file exist preprocess it and find maximum name length
|
||||
if [ -s "${symbol_file}" ]; then
|
||||
# Remove White Spaces, empty lines and symbol list markers if any
|
||||
sed -i '/^[[:space:]]*$/d; /^#/d; /\[abi_symbol_list\]/d' "${symbol_file}"
|
||||
|
||||
# Sort in byte order for kernel binary search at runtime
|
||||
LC_ALL=C sort -u -o "${symbol_file}" "${symbol_file}"
|
||||
|
||||
# Trim white spaces & +1 for null termination
|
||||
local max_name_len=$(awk '
|
||||
{
|
||||
$1=$1;
|
||||
if ( length > L ) {
|
||||
L=length
|
||||
}
|
||||
} END { print ++L }' "${symbol_file}")
|
||||
else
|
||||
# Set to 1 to generate valid C header file
|
||||
local max_name_len=1
|
||||
fi
|
||||
|
||||
# Header generation
|
||||
cat > "${header_file}" <<- EOT
|
||||
/*
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* Build generated header file with ${symbol_type}
|
||||
*/
|
||||
|
||||
#define NR_$(printf ${symbol_type} | tr [:lower:] [:upper:])_SYMBOLS \\
|
||||
$(printf '\t')(ARRAY_SIZE(gki_${symbol_type}_symbols))
|
||||
#define MAX_$(printf ${symbol_type} | tr [:lower:] [:upper:])_NAME_LEN (${max_name_len})
|
||||
|
||||
static const char gki_${symbol_type}_symbols[][MAX_$(printf ${symbol_type} |
|
||||
tr [:lower:] [:upper:])_NAME_LEN] = {
|
||||
EOT
|
||||
|
||||
# If a valid symbol_file present add symbols in an array except the 1st line
|
||||
if [ -s "${symbol_file}" ]; then
|
||||
sed -e 's/^[ \t]*/\t"/;s/[ \t]*$/",/' "${symbol_file}" >> "${header_file}"
|
||||
fi
|
||||
|
||||
# Terminate the file
|
||||
echo "};" >> "${header_file}"
|
||||
}
|
||||
|
||||
if [ "$(basename "${TARGET}")" = "gki_module_unprotected.h" ]; then
|
||||
# Union of vendor symbol lists
|
||||
GKI_VENDOR_SYMBOLS="${SYMBOL_LIST}"
|
||||
generate_header "${TARGET}" "${GKI_VENDOR_SYMBOLS}" "unprotected"
|
||||
else
|
||||
# Sorted list of exported symbols
|
||||
GKI_EXPORTED_SYMBOLS="${SYMBOL_LIST}"
|
||||
|
||||
generate_header "${TARGET}" "${GKI_EXPORTED_SYMBOLS}" "protected_exports"
|
||||
fi
|
||||
|
||||
@@ -111,7 +111,8 @@ static bool is_ignored_symbol(const char *name, char type)
|
||||
".LASANPC", /* s390 kasan local symbols */
|
||||
"__crc_", /* modversions */
|
||||
"__efistub_", /* arm64 EFI stub namespace */
|
||||
"__kvm_nvhe_", /* arm64 non-VHE KVM namespace */
|
||||
"__kvm_nvhe_$", /* arm64 local symbols in non-VHE KVM namespace */
|
||||
"__kvm_nvhe_.L", /* arm64 local symbols in non-VHE KVM namespace */
|
||||
"__AArch64ADRPThunk_", /* arm64 lld */
|
||||
"__ARMV5PILongThunk_", /* arm lld */
|
||||
"__ARMV7PILongThunk_",
|
||||
|
||||
@@ -28,6 +28,8 @@ static int modversions = 0;
|
||||
static int all_versions = 0;
|
||||
/* If we are modposting external module set to 1 */
|
||||
static int external_module = 0;
|
||||
#define MODULE_SCMVERSION_SIZE 64
|
||||
static char module_scmversion[MODULE_SCMVERSION_SIZE];
|
||||
/* Only warn about unresolved symbols */
|
||||
static int warn_unresolved = 0;
|
||||
/* How a symbol is exported */
|
||||
@@ -418,10 +420,9 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod,
|
||||
s = new_symbol(name, mod, export);
|
||||
} else if (!external_module || s->module->is_vmlinux ||
|
||||
s->module == mod) {
|
||||
warn("%s: '%s' exported twice. Previous export was in %s%s\n",
|
||||
mod->name, name, s->module->name,
|
||||
s->module->is_vmlinux ? "" : ".ko");
|
||||
return s;
|
||||
fatal("%s: '%s' exported twice. Previous export was in %s%s\n",
|
||||
mod->name, name, s->module->name,
|
||||
s->module->is_vmlinux ? "" : ".ko");
|
||||
}
|
||||
|
||||
s->module = mod;
|
||||
@@ -2235,6 +2236,20 @@ static void add_intree_flag(struct buffer *b, int is_intree)
|
||||
buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* add_scmversion() - Adds the MODULE_INFO macro for the scmversion.
|
||||
* @b: Buffer to append to.
|
||||
*
|
||||
* This function fills in the module attribute `scmversion` for the kernel
|
||||
* module. This is useful for determining a given module's SCM version on
|
||||
* device via /sys/modules/<module>/scmversion and/or using the modinfo tool.
|
||||
*/
|
||||
static void add_scmversion(struct buffer *b)
|
||||
{
|
||||
if (module_scmversion[0] != '\0')
|
||||
buf_printf(b, "\nMODULE_INFO(scmversion, \"%s\");\n", module_scmversion);
|
||||
}
|
||||
|
||||
/* Cannot check for assembler */
|
||||
static void add_retpoline(struct buffer *b)
|
||||
{
|
||||
@@ -2504,7 +2519,7 @@ int main(int argc, char **argv)
|
||||
struct dump_list *dump_read_start = NULL;
|
||||
struct dump_list **dump_read_iter = &dump_read_start;
|
||||
|
||||
while ((opt = getopt(argc, argv, "ei:mnT:o:awENd:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "ei:mnT:o:awENd:v:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'e':
|
||||
external_module = 1;
|
||||
@@ -2542,6 +2557,9 @@ int main(int argc, char **argv)
|
||||
case 'd':
|
||||
missing_namespace_deps = optarg;
|
||||
break;
|
||||
case 'v':
|
||||
strncpy(module_scmversion, optarg, sizeof(module_scmversion) - 1);
|
||||
break;
|
||||
default:
|
||||
exit(1);
|
||||
}
|
||||
@@ -2581,6 +2599,7 @@ int main(int argc, char **argv)
|
||||
add_depends(&buf, mod);
|
||||
add_moddevtable(&buf, mod);
|
||||
add_srcversion(&buf, mod);
|
||||
add_scmversion(&buf);
|
||||
|
||||
sprintf(fname, "%s.mod.c", mod->name);
|
||||
write_if_changed(&buf, fname);
|
||||
|
||||
@@ -387,7 +387,7 @@ out_file:
|
||||
/* Calc and record src checksum. */
|
||||
void get_src_version(const char *modname, char sum[], unsigned sumlen)
|
||||
{
|
||||
char *buf, *pos, *firstline;
|
||||
char *buf;
|
||||
struct md4_ctx md;
|
||||
char *fname;
|
||||
char filelist[PATH_MAX + 1];
|
||||
@@ -397,15 +397,8 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
|
||||
|
||||
buf = read_text_file(filelist);
|
||||
|
||||
pos = buf;
|
||||
firstline = get_line(&pos);
|
||||
if (!firstline) {
|
||||
warn("bad ending versions file for %s\n", modname);
|
||||
goto free;
|
||||
}
|
||||
|
||||
md4_init(&md);
|
||||
while ((fname = strsep(&firstline, " "))) {
|
||||
while ((fname = strsep(&buf, "\n"))) {
|
||||
if (!*fname)
|
||||
continue;
|
||||
if (!(is_static_library(fname)) &&
|
||||
|
||||
@@ -33,7 +33,36 @@ SECTIONS {
|
||||
|
||||
__patchable_function_entries : { *(__patchable_function_entries) }
|
||||
|
||||
#ifdef CONFIG_LTO_CLANG
|
||||
#if IS_ENABLED(CONFIG_CRYPTO_FIPS140_MOD)
|
||||
/*
|
||||
* The FIPS140 module incorporates copies of builtin code, which gets
|
||||
* integrity checked at module load time, and registered in a way that
|
||||
* ensures that the integrity checked versions supersede the builtin
|
||||
* ones. These objects are compiled as builtin code, and so their init
|
||||
* hooks will be exported from the binary in the same way as builtin
|
||||
* initcalls are, i.e., annotated with a level that defines the order
|
||||
* in which the hooks are expected to be invoked.
|
||||
*/
|
||||
#define INIT_CALLS_LEVEL(level) \
|
||||
KEEP(*(.initcall##level##.init*)) \
|
||||
KEEP(*(.initcall##level##s.init*))
|
||||
|
||||
.initcalls : {
|
||||
*(.initcalls._start)
|
||||
INIT_CALLS_LEVEL(0)
|
||||
INIT_CALLS_LEVEL(1)
|
||||
INIT_CALLS_LEVEL(2)
|
||||
INIT_CALLS_LEVEL(3)
|
||||
INIT_CALLS_LEVEL(4)
|
||||
INIT_CALLS_LEVEL(5)
|
||||
INIT_CALLS_LEVEL(rootfs)
|
||||
INIT_CALLS_LEVEL(6)
|
||||
INIT_CALLS_LEVEL(7)
|
||||
*(.initcalls._end)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_LTO_CLANG) || IS_ENABLED(CONFIG_CRYPTO_FIPS140_MOD)
|
||||
/*
|
||||
* With CONFIG_LTO_CLANG, LLD always enables -fdata-sections and
|
||||
* -ffunction-sections, which increases the size of the final module.
|
||||
@@ -50,8 +79,10 @@ SECTIONS {
|
||||
}
|
||||
|
||||
.rodata : {
|
||||
*(.rodata.._start)
|
||||
*(.rodata .rodata.[0-9a-zA-Z_]*)
|
||||
*(.rodata..L*)
|
||||
*(.rodata.._end)
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -59,8 +90,11 @@ SECTIONS {
|
||||
* of the .text section, and is aligned to PAGE_SIZE.
|
||||
*/
|
||||
.text : ALIGN_CFI {
|
||||
*(.text.._start)
|
||||
*(.text.__cfi_check)
|
||||
*(.text .text.[0-9a-zA-Z_]* .text..L.cfi*)
|
||||
*(.text.._end)
|
||||
*(.text.._fips140_unchecked)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -34,9 +34,8 @@ generate_deps() {
|
||||
local mod=${1%.ko:}
|
||||
shift
|
||||
local namespaces="$*"
|
||||
local mod_source_files="`cat $mod.mod | sed -n 1p \
|
||||
| sed -e 's/\.o/\.c/g' \
|
||||
| sed "s|[^ ]* *|${src_prefix}&|g"`"
|
||||
local mod_source_files=$(sed "s|^\(.*\)\.o$|${src_prefix}\1.c|" $mod.mod)
|
||||
|
||||
for ns in $namespaces; do
|
||||
echo "Adding namespace $ns to module $mod.ko."
|
||||
generate_deps_for_ns $ns "$mod_source_files"
|
||||
|
||||
@@ -11,12 +11,14 @@
|
||||
#
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [--save-scmversion] [srctree]" >&2
|
||||
echo "Usage: $0 [--save-scmversion] [srctree] [branch] [kmi-generation]" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
scm_only=false
|
||||
srctree=.
|
||||
android_release=
|
||||
kmi_generation=
|
||||
if test "$1" = "--save-scmversion"; then
|
||||
scm_only=true
|
||||
shift
|
||||
@@ -25,6 +27,22 @@ if test $# -gt 0; then
|
||||
srctree=$1
|
||||
shift
|
||||
fi
|
||||
if test $# -gt 0; then
|
||||
# Extract the Android release version. If there is no match, then return 255
|
||||
# and clear the var $android_release
|
||||
android_release=`echo "$1" | sed -e '/android[0-9]\{2,\}/!{q255}; \
|
||||
s/^\(android[0-9]\{2,\}\)-.*/\1/'`
|
||||
if test $? -ne 0; then
|
||||
android_release=
|
||||
fi
|
||||
shift
|
||||
|
||||
if test $# -gt 0; then
|
||||
kmi_generation=$1
|
||||
[ $(expr $kmi_generation : '^[0-9]\+$') -eq 0 ] && usage
|
||||
shift
|
||||
fi
|
||||
fi
|
||||
if test $# -gt 0 -o ! -d "$srctree"; then
|
||||
usage
|
||||
fi
|
||||
@@ -44,8 +62,13 @@ scm_version()
|
||||
fi
|
||||
|
||||
# Check for git and a git repo.
|
||||
if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
|
||||
head=$(git rev-parse --verify HEAD 2>/dev/null); then
|
||||
if head=$(git rev-parse --verify HEAD 2>/dev/null); then
|
||||
|
||||
if [ -n "$android_release" ] && [ -n "$kmi_generation" ]; then
|
||||
printf '%s' "-$android_release-$kmi_generation"
|
||||
elif [ -n "$android_release" ]; then
|
||||
printf '%s' "-$android_release"
|
||||
fi
|
||||
|
||||
# If we are at a tagged commit (like "v2.6.30-rc6"), we ignore
|
||||
# it, because this version is defined in the top level Makefile.
|
||||
@@ -143,4 +166,9 @@ elif [ "${LOCALVERSION+set}" != "set" ]; then
|
||||
res="$res${scm:++}"
|
||||
fi
|
||||
|
||||
# finally, add the abXXX number if BUILD_NUMBER is set
|
||||
if test -n "${BUILD_NUMBER}"; then
|
||||
res="$res-ab${BUILD_NUMBER}"
|
||||
fi
|
||||
|
||||
echo "$res"
|
||||
|
||||
@@ -99,6 +99,7 @@ static void display_openssl_errors(int l)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
static void drain_openssl_errors(void)
|
||||
{
|
||||
const char *file;
|
||||
@@ -108,6 +109,7 @@ static void drain_openssl_errors(void)
|
||||
return;
|
||||
while (ERR_get_error_line(&file, &line)) {}
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ERR(cond, fmt, ...) \
|
||||
do { \
|
||||
@@ -142,7 +144,9 @@ static int pem_pw_cb(char *buf, int len, int w, void *v)
|
||||
static EVP_PKEY *read_private_key(const char *private_key_name)
|
||||
{
|
||||
EVP_PKEY *private_key;
|
||||
BIO *b;
|
||||
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (!strncmp(private_key_name, "pkcs11:", 7)) {
|
||||
ENGINE *e;
|
||||
|
||||
@@ -160,17 +164,16 @@ static EVP_PKEY *read_private_key(const char *private_key_name)
|
||||
private_key = ENGINE_load_private_key(e, private_key_name,
|
||||
NULL, NULL);
|
||||
ERR(!private_key, "%s", private_key_name);
|
||||
} else {
|
||||
BIO *b;
|
||||
|
||||
b = BIO_new_file(private_key_name, "rb");
|
||||
ERR(!b, "%s", private_key_name);
|
||||
private_key = PEM_read_bio_PrivateKey(b, NULL, pem_pw_cb,
|
||||
NULL);
|
||||
ERR(!private_key, "%s", private_key_name);
|
||||
BIO_free(b);
|
||||
return private_key;
|
||||
}
|
||||
#endif
|
||||
|
||||
b = BIO_new_file(private_key_name, "rb");
|
||||
ERR(!b, "%s", private_key_name);
|
||||
private_key = PEM_read_bio_PrivateKey(b, NULL, pem_pw_cb,
|
||||
NULL);
|
||||
ERR(!private_key, "%s", private_key_name);
|
||||
BIO_free(b);
|
||||
return private_key;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user