Skip to content

Commit

Permalink
scripts/: Import alps-release-q0.mp1-V9.156.1 kernel changes
Browse files Browse the repository at this point in the history
Signed-off-by: Hadenix <vsegda_online_007@bk.ru>
  • Loading branch information
Hadenix committed Feb 2, 2024
1 parent 414b3b3 commit fa87044
Show file tree
Hide file tree
Showing 14 changed files with 2,382 additions and 10 deletions.
12 changes: 11 additions & 1 deletion scripts/Makefile.kasan
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ else
call_threshold := 0
endif

ifdef CONFIG_KASAN_ENHANCEMENT
KASAN_SHADOW_OFFSET ?= 0xefffff8800000000
else
KASAN_SHADOW_OFFSET ?= $(CONFIG_KASAN_SHADOW_OFFSET)
endif

CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-address

Expand All @@ -23,20 +27,26 @@ else
$(call cc-option, -fsanitize=kernel-address \
-mllvm -asan-mapping-offset=$(KASAN_SHADOW_OFFSET)))


ifeq ($(strip $(CFLAGS_KASAN_SHADOW)),)
CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL)
else
# Now add all the compiler specific options that are valid standalone
CFLAGS_KASAN := $(CFLAGS_KASAN_SHADOW) \
$(call cc-param,asan-globals=1) \
$(call cc-param,asan-instrumentation-with-call-threshold=$(call_threshold)) \
$(call cc-param,asan-stack=1) \
$(call cc-param,asan-stack=0) \
$(call cc-param,asan-use-after-scope=1) \
$(call cc-param,asan-instrument-allocas=1)
endif

endif

ifdef CONFIG_KASAN_ENHANCEMENT
CFLAGS_KASAN += $(call cc-param,asan-mapping-scale=4)
endif


CFLAGS_KASAN_NOSANITIZE := -fno-builtin

endif
4 changes: 3 additions & 1 deletion scripts/Makefile.lib
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \
-I$(srctree)/arch/$(SRCARCH)/boot/dts \
-I$(srctree)/arch/$(SRCARCH)/boot/dts/include \
-I$(srctree)/drivers/of/testcase-data \
-I$(objtree)/include/ \
-Iarch/$(SRCARCH)/boot/dts \
-undef -D__DTS__

# Finds the multi-part object the current object will be linked into
Expand Down Expand Up @@ -304,7 +306,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb
quiet_cmd_dtc = DTC $@
cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
$(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
$(DTC) -O dtb -o $@ -b 0 \
$(srctree)/scripts/dtc/dtc_overlay -@ -O dtb -o $@ -b 0 \
-i $(dir $<) $(DTC_FLAGS) \
-d $(depfile).dtc.tmp $(dtc-tmp) ; \
cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
Expand Down
2 changes: 1 addition & 1 deletion scripts/Makefile.modpost
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ modpost = scripts/mod/modpost \
$(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
$(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \
$(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \
$(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w)
$(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),$(if $(KBUILD_MODPOST_FAIL_ON_WARNINGS),,-w))

MODPOST_OPT=$(subst -i,-n,$(filter -i,$(MAKEFLAGS)))

Expand Down
143 changes: 143 additions & 0 deletions scripts/check_defconfigs
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#!/bin/bash

function usage ()
{
echo $0 'Check for kernel defconfig mismacth'
echo 'Usage:'
echo ' '$0' [-c] [-u] [defconfig-files]'
echo ' -c Check changed defconfigs from last git commit'
echo ' -u Update defconfig if no mismatch is found'
echo ' -h This help'
exit 0
}

CONFIGS=
UPDATE=0
CHECK_COMMIT=0

while getopts "cuh" opt; do
case $opt in
c)
if [ $# == 2 ]; then
CHECK_COMMIT=$2
else
CHECK_COMMIT="HEAD"
fi

KCONFIG=`git show ${CHECK_COMMIT} --stat | gawk '/\/Kconfig.* +\| +[0-9]*/{print $1}'`
if [ ".$KCONFIG" != "." ]; then
echo From git commit: Checking all defconfig due to Kconfig is changed.
CONFIGS=`grep -rl "CONFIG_MTK_PLATFORM" arch/arm/configs arch/arm64/configs`
fi

CONFIGS+=" `git show ${CHECK_COMMIT} --stat-width=500 | gawk '/arch\/(arm64|arm)\/configs\/.*_defconfig +\| +[0-9]*/{print $1}'`"
CONFIGS=`echo $CONFIGS | xargs -n1 | sort -u | xargs`
if [ ".$CONFIGS" != "." ]; then
echo From git commit: Checking $CONFIGS
fi
;;
u)
UPDATE=1
;;
h)
usage
;;
esac
done

if [ $# == 0 ]; then
usage
fi

if [ $CHECK_COMMIT == 0 ]; then
shift $((OPTIND-1))
CONFIGS="${CONFIGS} $*"
fi

check_defconfig() {
CONFIG=$1
UPDATE=$2
FAIL=0
echo "Checking ${CONFIG}"
if [ ! -e ${CONFIG} ]; then
echo warning: defconfig file $CONFIG not found
return $FAIL
fi

echo $CONFIG | grep arch/arm64 > /dev/null
RETVAL=$?
if [ $RETVAL != 0 ]; then
ARCH=arm
else
ARCH=arm64
fi

OUT=out-$$
mkdir ${OUT}

OUTPUT="$(make ARCH=${ARCH} O=${OUT} `basename ${CONFIG}` savedefconfig 2>&1)"
RETVAL=$?
echo "$OUTPUT"

if [ $RETVAL != 0 ]; then
echo error: Make ${CONFIG} error
rm -rf ${OUT}
FAIL=1
return $FAIL
fi

# Check if there is a warning message
if echo "$OUTPUT" | grep -q "^warning:"; then
echo error: there is a warning message with Kconfig
rm -rf ${OUT}
FAIL=1
return $FAIL
fi

# Check option mismatch
gawk 'BEGIN{lastf="";} { if (lastf != FILENAME) { if (lastf != "") CHECK=1; lastf=FILENAME; } } \
/CONFIG_/ { match($0, /CONFIG_[^ =]*/); option=substr($0, RSTART, RLENGTH); \
if (CHECK==1) { if (option in opts && opts[option]==$0) delete opts[option]; } \
else { if (option in opts && opts[option]!=$0) dups[option]=$0; opts[option]=$0; } } \
END { C=0; RET=0; for (i in dups) { RET=1; C++; printf("error: %s duplicate in defconfig\n", i); } \
for (i in opts) { RET=1; C++; printf("error: %s mismatch\n", i); } exit(RET);}' ${CONFIG} ${OUT}/.config
RETVAL=$?

if [ $RETVAL != 0 ]; then
echo error: ${CONFIG}: defconfig mismatch. Please check Kconfig and follow SOP to update _defconfig.
rm -rf ${OUT}
FAIL=1
return $FAIL
fi

if [ $UPDATE == 0 ]; then
# Compare output, make sure format is correct
OUTPUT="$(diff -u ${OUT}/defconfig ${CONFIG} 2>&1)"
RETVAL=$?
if [ $RETVAL != 0 ]; then
echo error: ${CONFIG} compare error. Please follow SOP to update _defconfig
echo "$OUTPUT"
rm -rf ${OUT}
FAIL=1
return $FAIL
fi
else
cp ${OUT}/defconfig ${CONFIG}
fi

rm -rf ${OUT}
return $FAIL
}
export -f check_defconfig

parallel check_defconfig ::: $CONFIGS ::: $UPDATE
RETVAL=$?

if [ $RETVAL != 0 ]; then
echo
echo Please check the following wiki for detail, thanks!
echo http://wiki.mediatek.inc/display/KernelStandardization/Check+defconfig+in+kernel+preflight
echo http://wiki.mediatek.inc/display/KernelStandardization/SOP+to+update+kernel+config
fi

exit $RETVAL
54 changes: 48 additions & 6 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ sub hash_show_words {
our $zero_initializer = qr{(?:(?:0[xX])?0+$Int_type?|NULL|false)\b};

our $logFunctions = qr{(?x:
printk(?:_ratelimited|_once|)|
printk(?:_ratelimited|_once|_deferred_once|_deferred|)|
(?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)|
WARN(?:_RATELIMIT|_ONCE|)|
panic|
Expand Down Expand Up @@ -2134,7 +2134,7 @@ sub process {
my $in_header_lines = $file ? 0 : 1;
my $in_commit_log = 0; #Scanning lines before patch
my $has_commit_log = 0; #Encountered lines before patch
my $commit_log_possible_stack_dump = 0;
my $commit_log_possible_stack_dump = 0;
my $commit_log_long_line = 0;
my $commit_log_has_diff = 0;
my $reported_maintainer_file = 0;
Expand All @@ -2154,6 +2154,7 @@ sub process {
my $realline = 0;
my $realcnt = 0;
my $here = '';
my $context_function; #undef'd unless there's a known function
my $in_comment = 0;
my $comment_edge = 0;
my $first_line = 0;
Expand Down Expand Up @@ -2192,7 +2193,8 @@ sub process {
}
#next;
}
if ($rawline=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
if ($rawline=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@(.*)/) {
my $context = $4;
$realline=$1-1;
if (defined $2) {
$realcnt=$3+1;
Expand All @@ -2201,6 +2203,12 @@ sub process {
}
$in_comment = 0;

if ($context =~ /\b(\w+)\s*\(/) {
$context_function = $1;
} else {
undef $context_function;
}

# Guestimate if this is a continuing comment. Run
# the context looking for a comment "edge". If this
# edge is a close comment then we must be in a comment
Expand Down Expand Up @@ -3180,7 +3188,7 @@ sub process {
my ($stat, $cond, $line_nr_next, $remain_next, $off_next,
$realline_next);
#print "LINE<$line>\n";
if ($linenr >= $suppress_statement &&
if ($linenr > $suppress_statement &&
$realcnt && $sline =~ /.\s*\S/) {
($stat, $cond, $line_nr_next, $remain_next, $off_next) =
ctx_statement_block($linenr, $realcnt, 0);
Expand Down Expand Up @@ -5145,6 +5153,16 @@ sub process {
"break quoted strings at a space character\n" . $hereprev);
}

#check for an embedded function name in a string when the function is known
# as part of a diff. This does not work for -f --file checking as it
#depends on patch context providing the function name
if ($line =~ /^\+.*$String/ &&
defined($context_function) &&
get_quoted_string($line, $rawline) =~ /\b$context_function\b/) {
WARN("EMBEDDED_FUNCTION_NAME",
"Prefer using \"%s\", __func__ to embedded function names\n" . $herecurr);
}

# check for spaces before a quoted newline
if ($rawline =~ /^.*\".*\s\\n/) {
if (WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE",
Expand Down Expand Up @@ -5825,8 +5843,9 @@ sub process {
"externs should be avoided in .c files\n" . $herecurr);
}

if ($realfile =~ /\.[ch]$/ && defined $stat &&
$stat =~ /^.\s*(?:extern\s+)?$Type\s*$Ident\s*\(\s*([^{]+)\s*\)\s*;/s &&
# check for function declarations that have arguments without identifier names
if (defined $stat &&
$stat =~ /^.\s*(?:extern\s+)?$Type\s*(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*\(\s*([^{]+)\s*\)\s*;/s &&
$1 ne "void") {
my $args = trim($1);
while ($args =~ m/\s*($Type\s*(?:$Ident|\(\s*\*\s*$Ident?\s*\)\s*$balanced_parens)?)/g) {
Expand All @@ -5838,6 +5857,29 @@ sub process {
}
}

# check for function definitions
if ($^V && $^V ge 5.10.0 &&
defined $stat &&
$stat =~ /^.\s*(?:$Storage\s+)?$Type\s*($Ident)\s*$balanced_parens\s*{/s) {
$context_function = $1;

# check for multiline function definition with misplaced open brace
my $ok = 0;
my $cnt = statement_rawlines($stat);
my $herectx = $here . "\n";
for (my $n = 0; $n < $cnt; $n++) {
my $rl = raw_line($linenr, $n);
$herectx .= $rl . "\n";
$ok = 1 if ($rl =~ /^[ \+]\{/);
$ok = 1 if ($rl =~ /\{/ && $n == 0);
last if $rl =~ /^[ \+].*\{/;
}
if (!$ok) {
ERROR("OPEN_BRACE",
"open brace '{' following function definitions go on the next line\n" . $herectx);
}
}

# checks for new __setup's
if ($rawline =~ /\b__setup\("([^"]*)"/) {
my $name = $1;
Expand Down
Loading

0 comments on commit fa87044

Please sign in to comment.