From 946c5d356ae545e38d0b3826a2332c4f5dab6048 Mon Sep 17 00:00:00 2001 From: techyminati Date: Tue, 13 Jul 2021 12:45:27 +0000 Subject: [PATCH] android: Import remaining from merlin-r-oss Signed-off-by: techyminati --- .cocciconfig | 3 - .get_maintainer.ignore | 1 - .gitattributes | 2 - .gitignore | 127 -------------- .mailmap | 191 -------------------- Android.mk | 83 +++++++++ CleanSpec.mk | 16 ++ Makefile | 25 +++ build.config.mtk.aarch64 | 12 ++ build.config.mtk.aarch64.gcc | 6 + build.config.mtk.aarch64.kasan | 12 ++ build.config.mtk.aarch64.ubsan | 12 ++ build.config.mtk.arm | 9 + certs/ko_test_prvk.pem | 64 +++++++ init/Kconfig | 83 ++++++++- init/Makefile | 8 + init/main.c | 29 +++- kenv.mk | 141 +++++++++++++++ lib/Kconfig.debug | 2 - lib/Kconfig.kasan | 8 + lib/Kconfig.ubsan | 10 -- lib/debug_locks.c | 8 + lib/dec_and_lock.c | 17 ++ lib/dma-debug.c | 20 ++- lib/dynamic_debug.c | 140 +++++++++++++++ lib/stackdepot.c | 40 +++++ lib/swiotlb.c | 10 ++ lib/ubsan.c | 17 ++ ll.sh | 2 + scripts/Makefile.lib | 6 +- scripts/Makefile.modpost | 2 +- scripts/Makefile.ubsan | 4 - scripts/check_defconfigs | 309 +++++++++++++++++++++++++++++++++ scripts/checkpatch.pl | 14 +- scripts/setlocalversion | 18 +- 35 files changed, 1089 insertions(+), 362 deletions(-) delete mode 100644 .cocciconfig delete mode 100644 .get_maintainer.ignore delete mode 100644 .gitattributes delete mode 100644 .gitignore delete mode 100644 .mailmap create mode 100644 Android.mk create mode 100644 CleanSpec.mk create mode 100644 build.config.mtk.aarch64 create mode 100644 build.config.mtk.aarch64.gcc create mode 100644 build.config.mtk.aarch64.kasan create mode 100644 build.config.mtk.aarch64.ubsan create mode 100644 build.config.mtk.arm create mode 100644 certs/ko_test_prvk.pem create mode 100644 kenv.mk create mode 100644 ll.sh create mode 100644 scripts/check_defconfigs diff --git a/.cocciconfig b/.cocciconfig deleted file mode 100644 index 43967c6b2015..000000000000 --- a/.cocciconfig +++ /dev/null @@ -1,3 +0,0 @@ -[spatch] - options = --timeout 200 - options = --use-gitgrep diff --git a/.get_maintainer.ignore b/.get_maintainer.ignore deleted file mode 100644 index cca6d870f7a5..000000000000 --- a/.get_maintainer.ignore +++ /dev/null @@ -1 +0,0 @@ -Christoph Hellwig diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 89c411b5ce6b..000000000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -*.c diff=cpp -*.h diff=cpp diff --git a/.gitignore b/.gitignore deleted file mode 100644 index be92dfa89957..000000000000 --- a/.gitignore +++ /dev/null @@ -1,127 +0,0 @@ -# -# NOTE! Don't add files that are generated in specific -# subdirectories here. Add them in the ".gitignore" file -# in that subdirectory instead. -# -# NOTE! Please use 'git ls-files -i --exclude-standard' -# command after changing this file, to see if there are -# any tracked files which get ignored after the change. -# -# Normal rules (sorted alphabetically) -# -.* -*.a -*.bin -*.bz2 -*.c.[012]*.* -*.dtb -*.dtb.S -*.dwo -*.elf -*.gcno -*.gz -*.i -*.ko -*.ll -*.lst -*.lz4 -*.lzma -*.lzo -*.mod.c -*.o -*.o.* -*.order -*.patch -*.s -*.so -*.so.dbg -*.su -*.symtypes -*.tar -*.xz -Module.symvers -modules.builtin - -# -# Top-level generic files -# -/tags -/TAGS -/linux -/vmlinux -/vmlinux.32 -/vmlinux-gdb.py -/vmlinuz -/System.map -/Module.markers - -# -# RPM spec file (make rpm-pkg) -# -/*.spec - -# -# Debian directory (make deb-pkg) -# -/debian/ - -# -# tar directory (make tar*-pkg) -# -/tar-install/ - -# -# git files that we don't want to ignore even if they are dot-files -# -!.gitignore -!.mailmap -!.cocciconfig - -# -# Generated include files -# -include/config -include/generated -arch/*/include/generated - -# stgit generated dirs -patches-* - -# quilt's files -patches -series - -# cscope files -cscope.* -ncscope.* - -# gnu global files -GPATH -GRTAGS -GSYMS -GTAGS - -# id-utils files -ID - -*.orig -*~ -\#*# - -# -# Leavings from module signing -# -extra_certificates -signing_key.pem -signing_key.priv -signing_key.x509 -x509.genkey - -# Kconfig presets -all.config - -# Kdevelop4 -*.kdev4 - -# fetched Android config fragments -kernel/configs/android-*.cfg diff --git a/.mailmap b/.mailmap deleted file mode 100644 index c021f29779a7..000000000000 --- a/.mailmap +++ /dev/null @@ -1,191 +0,0 @@ -# -# This list is used by git-shortlog to fix a few botched name translations -# in the git archive, either because the author's full name was messed up -# and/or not always written the same way, making contributions from the -# same person appearing not to be so or badly displayed. -# -# repo-abbrev: /pub/scm/linux/kernel/git/ -# - -Aaron Durbin -Adam Oldham -Adam Radford -Adrian Bunk -Adriana Reus -Alan Cox -Alan Cox -Aleksey Gorelov -Aleksandar Markovic -Al Viro -Al Viro -Andreas Herrmann -Andrey Ryabinin -Andrew Morton -Andrew Vasquez -Andy Adamson -Antoine Tenart -Antonio Ospite -Archit Taneja -Arnaud Patard -Arnd Bergmann -Axel Dyks -Axel Lin -Ben Gardner -Ben M Cahill -Björn Steinbrink -Boris Brezillon -Boris Brezillon -Boris Brezillon -Brian Avery -Brian King -Christoph Hellwig -Christophe Ricard -Corey Minyard -Damian Hobson-Garcia -David Brownell -David Woodhouse -Deng-Cheng Zhu -Dmitry Eremin-Solenikov -Domen Puncer -Douglas Gilbert -Ed L. Cashin -Evgeniy Polyakov -Felipe W Damasio -Felix Kuhling -Felix Moeller -Filipe Lautert -Franck Bui-Huu -Frank Rowand -Frank Rowand -Frank Rowand -Frank Zago -Greg Kroah-Hartman -Greg Kroah-Hartman -Greg Kroah-Hartman -Henk Vergonet -Henrik Kretzschmar -Henrik Rydberg -Herbert Xu -Jacob Shin -James Bottomley -James Bottomley -James E Wilson -James Hogan -James Hogan -James Ketrenos -Javi Merino - -Jean Tourrilhes -Jeff Garzik -Jens Axboe -Jens Osterkamp -Johan Hovold -Johan Hovold -John Paul Adrian Glaubitz -John Stultz - - - - - -Juha Yrjola -Juha Yrjola -Juha Yrjola -Kay Sievers -Kenneth W Chen -Konstantin Khlebnikov -Koushik -Krzysztof Kozlowski -Krzysztof Kozlowski -Kuninori Morimoto -Leonid I Ananiev -Linas Vepstas -Linus Lüssing -Linus Lüssing -Maciej W. Rozycki -Marcin Nowakowski -Mark Brown -Martin Kepplinger -Martin Kepplinger -Matthieu CASTET -Mauro Carvalho Chehab -Mauro Carvalho Chehab -Mauro Carvalho Chehab -Mauro Carvalho Chehab -Mauro Carvalho Chehab -Mauro Carvalho Chehab -Mauro Carvalho Chehab -Matt Ranostay Matthew Ranostay -Matt Ranostay -Matt Ranostay -Matt Redfearn -Mayuresh Janorkar -Michael Buesch -Michel Dänzer -Miodrag Dinic -Mitesh shah -Mohit Kumar -Morten Welinder -Morten Welinder -Morten Welinder -Morten Welinder -Mythri P K -Nguyen Anh Quynh -Paolo 'Blaisorblade' Giarrusso -Patrick Mochel -Paul Burton -Peter A Jonsson -Peter Oruba -Peter Oruba -Pratyush Anand -Praveen BP -Qais Yousef -Rajesh Shah -Ralf Baechle -Ralf Wildenhues -Randy Dunlap -Rémi Denis-Courmont -Ricardo Ribalda Delgado -Rudolf Marek -Rui Saraiva -Sachin P Sant -Sarangdhar Joshi -Sam Ravnborg -Santosh Shilimkar -Santosh Shilimkar -Sascha Hauer -S.Çağlar Onur -Sebastian Reichel -Sebastian Reichel -Shiraz Hashim -Shuah Khan -Shuah Khan -Shuah Khan -Shuah Khan -Simon Kelley -Stéphane Witzmann -Stephen Hemminger -Subash Abhinov Kasiviswanathan -Subhash Jadavani -Sudeep Holla Sudeep KarkadaNagesha -Sumit Semwal -Tejun Heo -Thomas Graf -Thomas Pedersen -Tony Luck -Tsuneo Yoshioka -Uwe Kleine-König -Uwe Kleine-König -Uwe Kleine-König -Valdis Kletnieks -Viresh Kumar -Viresh Kumar -Viresh Kumar -Vlad Dogaru -Vladimir Davydov -Vladimir Davydov -Takashi YOSHII -Yakir Yang -Yusuke Goda -Gustavo Padovan -Gustavo Padovan diff --git a/Android.mk b/Android.mk new file mode 100644 index 000000000000..e3d2d4334f79 --- /dev/null +++ b/Android.mk @@ -0,0 +1,83 @@ +# Copyright (C) 2017 MediaTek Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See http://www.gnu.org/licenses/gpl-2.0.html for more details. + +LOCAL_PATH := $(call my-dir) + +ifeq ($(notdir $(LOCAL_PATH)),$(strip $(LINUX_KERNEL_VERSION))) +ifneq ($(strip $(TARGET_NO_KERNEL)),true) +include $(LOCAL_PATH)/kenv.mk + +ifeq ($(wildcard $(TARGET_PREBUILT_KERNEL)),) +KERNEL_MAKE_DEPENDENCIES := $(shell find $(KERNEL_DIR) -name .git -prune -o -type f | sort) +KERNEL_MAKE_DEPENDENCIES := $(filter-out %/.git %/.gitignore %/.gitattributes,$(KERNEL_MAKE_DEPENDENCIES)) + +$(TARGET_KERNEL_CONFIG): PRIVATE_DIR := $(KERNEL_DIR) +$(TARGET_KERNEL_CONFIG): $(KERNEL_CONFIG_FILE) $(LOCAL_PATH)/Android.mk +$(TARGET_KERNEL_CONFIG): $(KERNEL_MAKE_DEPENDENCIES) + $(hide) mkdir -p $(dir $@) + $(PREBUILT_MAKE_PREFIX)$(MAKE) -C $(PRIVATE_DIR) $(KERNEL_MAKE_OPTION) $(KERNEL_DEFCONFIG) + +$(BUILT_DTB_OVERLAY_TARGET): $(KERNEL_ZIMAGE_OUT) + +.KATI_RESTAT: $(KERNEL_ZIMAGE_OUT) +$(KERNEL_ZIMAGE_OUT): PRIVATE_DIR := $(KERNEL_DIR) +$(KERNEL_ZIMAGE_OUT): $(TARGET_KERNEL_CONFIG) $(KERNEL_MAKE_DEPENDENCIES) + $(hide) mkdir -p $(dir $@) + $(PREBUILT_MAKE_PREFIX)$(MAKE) -C $(PRIVATE_DIR) $(KERNEL_MAKE_OPTION) + $(hide) $(call fixup-kernel-cmd-file,$(KERNEL_OUT)/arch/$(KERNEL_TARGET_ARCH)/boot/compressed/.piggy.xzkern.cmd) + # check the kernel image size + python device/mediatek/build/build/tools/check_kernel_size.py $(KERNEL_OUT) $(KERNEL_DIR) $(PROJECT_DTB_NAMES) + +ifeq ($(strip $(MTK_HEADER_SUPPORT)), yes) +$(BUILT_KERNEL_TARGET): $(KERNEL_ZIMAGE_OUT) $(TARGET_KERNEL_CONFIG) $(LOCAL_PATH)/Android.mk | $(HOST_OUT_EXECUTABLES)/mkimage$(HOST_EXECUTABLE_SUFFIX) + $(hide) $(HOST_OUT_EXECUTABLES)/mkimage$(HOST_EXECUTABLE_SUFFIX) $< KERNEL 0xffffffff > $@ +else +$(BUILT_KERNEL_TARGET): $(KERNEL_ZIMAGE_OUT) $(TARGET_KERNEL_CONFIG) $(LOCAL_PATH)/Android.mk | $(ACP) + $(copy-file-to-target) +endif + +$(TARGET_PREBUILT_KERNEL): $(BUILT_KERNEL_TARGET) $(LOCAL_PATH)/Android.mk | $(ACP) + $(copy-file-to-new-target) + +endif#TARGET_PREBUILT_KERNEL is empty + +$(INSTALLED_KERNEL_TARGET): $(BUILT_KERNEL_TARGET) $(LOCAL_PATH)/Android.mk | $(ACP) + $(copy-file-to-target) + +.PHONY: kernel save-kernel kernel-savedefconfig kernel-menuconfig menuconfig-kernel savedefconfig-kernel clean-kernel +kernel: $(INSTALLED_KERNEL_TARGET) +save-kernel: $(TARGET_PREBUILT_KERNEL) + +kernel-savedefconfig: $(TARGET_KERNEL_CONFIG) + cp $(TARGET_KERNEL_CONFIG) $(KERNEL_CONFIG_FILE) + +kernel-menuconfig: + $(hide) mkdir -p $(KERNEL_OUT) + $(MAKE) -C $(KERNEL_DIR) $(KERNEL_MAKE_OPTION) menuconfig + +menuconfig-kernel savedefconfig-kernel: + $(hide) mkdir -p $(KERNEL_OUT) + $(MAKE) -C $(KERNEL_DIR) $(KERNEL_MAKE_OPTION) $(patsubst %config-kernel,%config,$@) + +clean-kernel: + $(hide) rm -rf $(KERNEL_OUT) $(KERNEL_MODULES_OUT) $(INSTALLED_KERNEL_TARGET) + $(hide) rm -f $(INSTALLED_DTB_OVERLAY_TARGET) + +### DTB build template +MTK_DTBIMAGE_DTS := $(addsuffix .dts,$(addprefix $(KERNEL_DIR)/arch/$(KERNEL_TARGET_ARCH)/boot/dts/,$(PLATFORM_DTB_NAME))) +include device/mediatek/build/core/build_dtbimage.mk + +MTK_DTBOIMAGE_DTS := $(addsuffix .dts,$(addprefix $(KERNEL_DIR)/arch/$(KERNEL_TARGET_ARCH)/boot/dts/,$(PROJECT_DTB_NAMES))) +include device/mediatek/build/core/build_dtboimage.mk + + +endif#TARGET_NO_KERNEL +endif#LINUX_KERNEL_VERSION diff --git a/CleanSpec.mk b/CleanSpec.mk new file mode 100644 index 000000000000..f725b370aa95 --- /dev/null +++ b/CleanSpec.mk @@ -0,0 +1,16 @@ +# Copyright (c) 2015 MediaTek Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# dummy file +# To avoid scanning kernel when using findleaves.py to search CleanSpec.mk diff --git a/Makefile b/Makefile index 7e755ef81a8d..0aa8435bd042 100644 --- a/Makefile +++ b/Makefile @@ -412,6 +412,7 @@ LINUXINCLUDE := \ -I$(srctree)/arch/$(hdr-arch)/include \ -I$(objtree)/arch/$(hdr-arch)/include/generated \ $(if $(KBUILD_SRC), -I$(srctree)/include) \ + -I$(srctree)/drivers/misc/mediatek/include \ -I$(objtree)/include \ $(USERINCLUDE) @@ -968,6 +969,30 @@ KBUILD_CPPFLAGS += $(ARCH_CPPFLAGS) $(KCPPFLAGS) KBUILD_AFLAGS += $(ARCH_AFLAGS) $(KAFLAGS) KBUILD_CFLAGS += $(ARCH_CFLAGS) $(KCFLAGS) +# =============FACTORY================================== +# Add macros only for factory version +ifeq ($(strip $(FACTORY_VERSION_MODE)) , true) +KBUILD_CFLAGS += -DFACTORY_VERSION_ENABLE +endif +# =============FACTORY================================== + +# =============PROJECT================================== +# Add macros by TARGET_PRODUCT for different projects +ifeq ($(strip $(TARGET_PRODUCT)) , lancelot) +# Define macros here only for lancelot project +KBUILD_CFLAGS += -DTARGET_PRODUCT_LANCELOT +else ifeq ($(strip $(TARGET_PRODUCT)) , shiva) +# Define macros here only for shiva project +KBUILD_CFLAGS += -DTARGET_PRODUCT_SHIVA +else +endif + +ifneq (,$(filter merlin merlinin merlinnfc, $(TARGET_PRODUCT))) +# Define macros here only for merlin common project +KBUILD_CFLAGS += -DTARGET_PRODUCT_MERLINCOMMON +endif +# =============PROJECT================================== + # Use --build-id when available. LDFLAGS_BUILD_ID := $(patsubst -Wl$(comma)%,%,\ $(call cc-ldoption, -Wl$(comma)--build-id,)) diff --git a/build.config.mtk.aarch64 b/build.config.mtk.aarch64 new file mode 100644 index 000000000000..dc9f1f66e69b --- /dev/null +++ b/build.config.mtk.aarch64 @@ -0,0 +1,12 @@ +ARCH=arm64 +CLANG_TRIPLE=aarch64-linux-gnu- +CROSS_COMPILE=aarch64-linux-androidkernel- +CC=clang +LD=ld.lld +LD_LIBRARY_PATH=prebuilts/clang/host/linux-x86/clang-r383902/lib64:$$LD_LIBRARY_PATH +NM=llvm-nm +OBJCOPY=llvm-objcopy +# DEFCONFIG=defconfig +KERNEL_DIR=kernel-4.14 +CLANG_PREBUILT_BIN=prebuilts/clang/host/linux-x86/clang-r383902/bin +LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN=prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin diff --git a/build.config.mtk.aarch64.gcc b/build.config.mtk.aarch64.gcc new file mode 100644 index 000000000000..e5f0086b6e98 --- /dev/null +++ b/build.config.mtk.aarch64.gcc @@ -0,0 +1,6 @@ +ARCH=arm64 +CROSS_COMPILE=aarch64-linux-gnu- +CC=gcc +# DEFCONFIG=defconfig +KERNEL_DIR=kernel-4.14 +LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN=prebuilts/gcc/linux-x86/aarch64/aarch64-linux-gnu-6.3.1/bin diff --git a/build.config.mtk.aarch64.kasan b/build.config.mtk.aarch64.kasan new file mode 100644 index 000000000000..dc9f1f66e69b --- /dev/null +++ b/build.config.mtk.aarch64.kasan @@ -0,0 +1,12 @@ +ARCH=arm64 +CLANG_TRIPLE=aarch64-linux-gnu- +CROSS_COMPILE=aarch64-linux-androidkernel- +CC=clang +LD=ld.lld +LD_LIBRARY_PATH=prebuilts/clang/host/linux-x86/clang-r383902/lib64:$$LD_LIBRARY_PATH +NM=llvm-nm +OBJCOPY=llvm-objcopy +# DEFCONFIG=defconfig +KERNEL_DIR=kernel-4.14 +CLANG_PREBUILT_BIN=prebuilts/clang/host/linux-x86/clang-r383902/bin +LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN=prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin diff --git a/build.config.mtk.aarch64.ubsan b/build.config.mtk.aarch64.ubsan new file mode 100644 index 000000000000..dc9f1f66e69b --- /dev/null +++ b/build.config.mtk.aarch64.ubsan @@ -0,0 +1,12 @@ +ARCH=arm64 +CLANG_TRIPLE=aarch64-linux-gnu- +CROSS_COMPILE=aarch64-linux-androidkernel- +CC=clang +LD=ld.lld +LD_LIBRARY_PATH=prebuilts/clang/host/linux-x86/clang-r383902/lib64:$$LD_LIBRARY_PATH +NM=llvm-nm +OBJCOPY=llvm-objcopy +# DEFCONFIG=defconfig +KERNEL_DIR=kernel-4.14 +CLANG_PREBUILT_BIN=prebuilts/clang/host/linux-x86/clang-r383902/bin +LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN=prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin diff --git a/build.config.mtk.arm b/build.config.mtk.arm new file mode 100644 index 000000000000..c17571319425 --- /dev/null +++ b/build.config.mtk.arm @@ -0,0 +1,9 @@ +ARCH=arm +CLANG_TRIPLE=arm-linux-gnueabi- +CROSS_COMPILE=arm-linux-androidkernel- +CC=clang +LD=ld.lld +# DEFCONFIG=defconfig +KERNEL_DIR=kernel-4.14 +CLANG_PREBUILT_BIN=prebuilts/clang/host/linux-x86/clang-r383902/bin +LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN=prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin diff --git a/certs/ko_test_prvk.pem b/certs/ko_test_prvk.pem new file mode 100644 index 000000000000..8da2aae13e31 --- /dev/null +++ b/certs/ko_test_prvk.pem @@ -0,0 +1,64 @@ +-----BEGIN PRIVATE KEY----- +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 +xcmFZBbJlmHCb+fowzgbLOBxQQ== +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIEBDCCAmygAwIBAgIJAJLaPqIhcK6LMA0GCSqGSIb3DQEBCwUAMBExDzANBgNV +BAMMBk1vZHVsZTAgFw0xNzEwMjYwNTA1MTlaGA8yMTE3MTAwMjA1MDUxOVowETEP +MA0GA1UEAwwGTW9kdWxlMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA +zXXlmLAh3VkvPAD2/SsIPYchYwah+ZlBTFeFjlL7zfZL83K0ZNIrgZsaYvyB1/Nx +GKMjJOIlf7LgzQ8aKfpMEpwsbikGdM7BW6H/4RV3j2xH8bkYUnDWHFViB1UfEAs0 +Zab/SHxeFYMkuJ2GIUcGKd5rZ7Vc7xNfmFKVVlvZoftcSoFQ/zSIox4vIDYUq6Xi +jExILz93K0/XvoJUfINlwKFlnWFCrIT7n8H8DEsOtFmAWUu3W23JSUgP59ppSVFj +ow650k10gM48NODLGdLNGsidwp2clj+UFpMhJfP/qlbYXNfxoN21Ykq39ceO/iwh +yauT0sjzUopWz44HIhCaOQwGcK4pCGa8+G2cm6zb1nhdzoLh3DPUrK3HQ7cCqisc +9BvLk0SlF8dqygRQn3BKxyhjSn4+aVuW9l/BKPvX+eTgXm81wZKwvqxwXD9OJgDD +GbhPKt5BfXgBGjQDY0tSHDORCNSVTT8o0nSuh9RQ/6OTdAm3x4Rfy7u22BGP4R45 +AgMBAAGjXTBbMAwGA1UdEwEB/wQCMAAwCwYDVR0PBAQDAgeAMB0GA1UdDgQWBBQ/ +CgDyf6vS+2sf0jb/uIO15jnPejAfBgNVHSMEGDAWgBQ/CgDyf6vS+2sf0jb/uIO1 +5jnPejANBgkqhkiG9w0BAQsFAAOCAYEAJStMFbpTSPWWZsh74lJ1eMMgH84+pQ2S +wuoWzM86KouIzDWxornDnxGT/f+WZ5Z+zbuP98TF1i2YxowM4CtAaDhdPBt12Pi/ +SZCsIQmlUcngnbJz/YzL8jd5/sNGHxB+B+V+0JLTtaoklq8ZDU+mZ6gJxSScbEvU +sYxcvNKKwEQLibAQ9/cFtlM0usglZKgKRmp2+d/W17WAhHWuWJFdMUNw7RJ72ZiS +9GkjPuXcazdpBEgNJ8FCTJvPUzwVs/y6EA4di4lqDb0e8BBYtFH1VlE9ugMTB8qO +bpmfw63HSKdxUue4/THfMYSuo7ainolUCRiP0J2V4wWBPjYHlajQ9FQqz6xvzK03 +mqxoECsKlv3X0LCXjq1vhOVl7HeClxwa8g9MfTrscr6AV23XpclRqMgcDjki92BW +hDx6O0cbuAN0zPYpADLbjgLXyCdpaRseNewjduMp6IBWJLC5LLBxOB4RwEkMBwJL +Zm6BFiInPH69XNr97Z+TsoJsghttLccP +-----END CERTIFICATE----- diff --git a/init/Kconfig b/init/Kconfig index 2ebd9ff7f552..c8ca71df333b 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -649,6 +649,65 @@ config HAVE_UNSTABLE_SCHED_CLOCK config GENERIC_SCHED_CLOCK bool +menu "Scheduler features" + +config UCLAMP_TASK + bool "Enable utilization clamping for RT/FAIR tasks" + depends on CPU_FREQ_GOV_SCHEDUTIL + default n + help + This feature enables the scheduler to track the clamped utilization + of each CPU based on RUNNABLE tasks currently scheduled on that CPU. + + When this option is enabled, the user can specify a min and max CPU + bandwidth which is allowed for a task. + The max bandwidth allows to clamp the maximum frequency a task can + use, while the min bandwidth allows to define a minimum frequency a + task will always use. + + If in doubt, say N. + +config UCLAMP_GROUPS_COUNT + int "Number of different utilization clamp values supported" + range 0 32 + default 5 + depends on UCLAMP_TASK + help + This defines the maximum number of different utilization clamp + values which can be concurrently enforced for each utilization + clamp index (i.e. minimum and maximum utilization). + + Only a limited number of clamp values are supported because: + 1. there are usually only few classes of workloads for which it + makes sense to boost/cap for different frequencies, + e.g. background vs foreground, interactive vs low-priority. + 2. it allows a simpler and more memory/time efficient tracking of + the per-CPU clamp values. + + If in doubt, use the default value. + +config UCLAMP_MAP_OPP + bool "Map utilization clamping to opp corresponding capacity" + depends on UCLAMP_TASK + depends on MTK_UNIFY_POWER + default n + help + This feature map utilization clamping value to cpu opp capacity. + + If in doubt, say N. + +config NONLINEAR_FREQ_CTL + bool "Non-linear frequency control" + depends on MTK_CPU_FREQ + depends on MTK_UNIFY_POWER + default n + help + Use power table capacity to control DVFS, cpu capacity/ + loading tracking/opp calculation will be affected. + If unsure, say N. + +endmenu + menu "FAIR Scheuler tunables" choice @@ -852,6 +911,28 @@ config RT_GROUP_SCHED endif #CGROUP_SCHED +config UCLAMP_TASK_GROUP + bool "Utilization clamping per group of tasks" + depends on CGROUP_SCHED + depends on UCLAMP_TASK + default n + help + This feature enables the scheduler to track the clamped utilization + of each CPU based on RUNNABLE tasks currently scheduled on that CPU. + + When this option is enabled, the user can specify a min and max + CPU bandwidth which is allowed for each single task in a group. + The max bandwidth allows to clamp the maximum frequency a task + can use, while the min bandwidth allows to define a minimum + frequency a task will always use. + + When task group based utilization clamping is enabled, an eventually + specified task-specific clamp value is constrained by the cgroup + specified clamp value. Both minimum and maximum task clamping cannot + be bigger than the corresponding clamping defined at task group level. + + If in doubt, say N. + config CGROUP_PIDS bool "PIDs controller" help @@ -1332,7 +1413,7 @@ config KALLSYMS_ABSOLUTE_PERCPU default X86_64 && SMP config KALLSYMS_BASE_RELATIVE - bool + bool "Enable KALLSYMS_BASE_RELATIVE or not" depends on KALLSYMS default !IA64 && !(TILE && 64BIT) help diff --git a/init/Makefile b/init/Makefile index edb39edd0241..6ca89a9ba92b 100644 --- a/init/Makefile +++ b/init/Makefile @@ -5,6 +5,14 @@ ccflags-y := -fno-function-sections -fno-data-sections +ifdef CONFIG_MTPROF +ccflags-y += -Idrivers/misc/mediatek/mtprof/ +endif + +ifdef CONFIG_MTK_RAM_CONSOLE +ccflags-y += -Idrivers/misc/mediatek/include/ +endif + obj-y := main.o version.o mounts.o obj-y += noinitramfs.o obj-$(CONFIG_BLK_DEV_INITRD) += initramfs.o diff --git a/init/main.c b/init/main.c index cef82a2957a0..4120b1bcc240 100644 --- a/init/main.c +++ b/init/main.c @@ -95,6 +95,10 @@ #include #include +#ifdef CONFIG_MTK_RAM_CONSOLE +#include +#endif + static int kernel_init(void *); extern void init_IRQ(void); @@ -834,21 +838,34 @@ static int __init_or_module do_one_initcall_debug(initcall_t fn) return ret; } +#ifdef CONFIG_MTPROF +#include +#else +#define TIME_LOG_START() +#define TIME_LOG_END() +#define bootprof_initcall(fn, ts) +#endif int __init_or_module do_one_initcall(initcall_t fn) { int count = preempt_count(); int ret; char msgbuf[64]; - +#ifdef CONFIG_MTPROF + unsigned long long ts = 0; +#endif if (initcall_blacklisted(fn)) return -EPERM; +#ifdef CONFIG_MTK_RAM_CONSOLE + aee_rr_rec_last_init_func((unsigned long)fn); +#endif + TIME_LOG_START(); if (initcall_debug) ret = do_one_initcall_debug(fn); else ret = fn(); - + TIME_LOG_END(); msgbuf[0] = 0; if (preempt_count() != count) { @@ -862,6 +879,7 @@ int __init_or_module do_one_initcall(initcall_t fn) WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf); add_latent_entropy(); + bootprof_initcall(fn, ts); return ret; } @@ -922,6 +940,9 @@ static void __init do_initcalls(void) for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++) do_initcall_level(level); +#ifdef CONFIG_MTK_RAM_CONSOLE + aee_rr_rec_last_init_func(~(unsigned long)(0)); +#endif } /* @@ -1031,7 +1052,9 @@ static int __ref kernel_init(void *unused) numa_default_policy(); rcu_end_inkernel_boot(); - +#ifdef CONFIG_MTPROF + log_boot("Kernel_init_done"); +#endif if (ramdisk_execute_command) { ret = run_init_process(ramdisk_execute_command); if (!ret) diff --git a/kenv.mk b/kenv.mk new file mode 100644 index 000000000000..d9062e6cc92c --- /dev/null +++ b/kenv.mk @@ -0,0 +1,141 @@ +# Copyright (C) 2017 MediaTek Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See http://www.gnu.org/licenses/gpl-2.0.html for more details. + +KERNEL_ENV_PATH := $(call my-dir) +KERNEL_ROOT_DIR := $(PWD) + +define touch-kernel-image-timestamp +if [ -e $(1) ] && [ -e $(2) ] && cmp -s $(1) $(2); then \ + echo $(2) has no change;\ + mv -f $(1) $(2);\ +else \ + rm -f $(1);\ +fi +endef + +define move-kernel-module-files +v=`cat $(2)/include/config/kernel.release`;\ +for i in `grep -h '\.ko' /dev/null $(2)/.tmp_versions/*.mod`; do \ + o=`basename $$i`;\ + if [ -e $(1)/lib/modules/$$o ] && cmp -s $(1)/lib/modules/$$v/kernel/$$i $(1)/lib/modules/$$o; then \ + echo $(1)/lib/modules/$$o has no change;\ + else \ + echo Update $(1)/lib/modules/$$o;\ + mv -f $(1)/lib/modules/$$v/kernel/$$i $(1)/lib/modules/$$o;\ + fi;\ +done +endef + +define clean-kernel-module-dirs +rm -rf $(1)/lib/modules/$(if $(2),`cat $(2)/include/config/kernel.release`,*/) +endef + +# '\\' in command is wrongly replaced to '\\\\' in kernel/out/arch/arm/boot/compressed/.piggy.xzkern.cmd +define fixup-kernel-cmd-file +if [ -e $(1) ]; then cp $(1) $(1).bak; sed -e 's/\\\\\\\\/\\\\/g' < $(1).bak > $(1); rm -f $(1).bak; fi +endef + +ifneq ($(strip $(TARGET_NO_KERNEL)),true) + KERNEL_DIR := $(KERNEL_ENV_PATH) + mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) + current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) + + ifeq ($(KERNEL_TARGET_ARCH),arm64) + ifeq ($(strip $(TARGET_KERNEL_USE_CLANG)),true) + include $(current_dir)/build.config.mtk.aarch64 + else + include $(current_dir)/build.config.mtk.aarch64.gcc + endif + else + ifeq ($(strip $(TARGET_KERNEL_USE_CLANG)),true) + include $(current_dir)/build.config.mtk.arm + else + $(error TARGET_KERNEL_USE_CLANG is not set) + endif + endif + + ARGS := CROSS_COMPILE=$(CROSS_COMPILE) + ifneq ($(CLANG_TRIPLE),) + ARGS += CLANG_TRIPLE=$(CLANG_TRIPLE) + endif + ifneq ($(LD),) + ARGS += LD=$(LD) + endif + ifneq ($(LD_LIBRARY_PATH),) + ARGS += LD_LIBRARY_PATH=$(KERNEL_ROOT_DIR)/$(LD_LIBRARY_PATH) + endif + ifneq ($(NM),) + ARGS += NM=$(NM) + endif + ifneq ($(OBJCOPY),) + ARGS += OBJCOPY=$(OBJCOPY) + endif + ifeq ("$(CC)", "gcc") + CC := + endif + + ifneq ($(filter-out false,$(USE_CCACHE)),) + CCACHE_EXEC ?= /usr/bin/ccache + CCACHE_EXEC := $(abspath $(wildcard $(CCACHE_EXEC))) + else + CCACHE_EXEC := + endif + ifneq ($(CCACHE_EXEC),) + ifneq ($(CC),) + ARGS += CCACHE_CPP2=yes CC='$(CCACHE_EXEC) $(CC)' + endif + else + ifneq ($(CC),) + ARGS += CC=$(CC) + endif + endif + + TARGET_KERNEL_CROSS_COMPILE := $(KERNEL_ROOT_DIR)/$(LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN)/$(CROSS_COMPILE) + + ifeq ($(wildcard $(TARGET_PREBUILT_KERNEL)),) + KERNEL_OUT ?= $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ + KERNEL_ROOT_OUT := $(if $(filter /% ~%,$(KERNEL_OUT)),,$(KERNEL_ROOT_DIR)/)$(KERNEL_OUT) + ifeq ($(KERNEL_TARGET_ARCH), arm64) + ifeq ($(MTK_APPENDED_DTB_SUPPORT), yes) + KERNEL_ZIMAGE_OUT := $(KERNEL_OUT)/arch/$(KERNEL_TARGET_ARCH)/boot/Image.gz-dtb + else + KERNEL_ZIMAGE_OUT := $(KERNEL_OUT)/arch/$(KERNEL_TARGET_ARCH)/boot/Image.gz + endif + else + ifeq ($(MTK_APPENDED_DTB_SUPPORT), yes) + KERNEL_ZIMAGE_OUT := $(KERNEL_OUT)/arch/$(KERNEL_TARGET_ARCH)/boot/zImage-dtb + else + KERNEL_ZIMAGE_OUT := $(KERNEL_OUT)/arch/$(KERNEL_TARGET_ARCH)/boot/zImage + endif + endif + + BUILT_KERNEL_TARGET := $(KERNEL_ZIMAGE_OUT).bin + INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel + INSTALLED_DTB_OVERLAY_TARGET := $(PRODUCT_OUT)/odmdtbo.img + BUILT_DTB_OVERLAY_TARGET := $(KERNEL_OUT)/arch/$(KERNEL_TARGET_ARCH)/boot/dts/odmdtbo.img + TARGET_KERNEL_CONFIG := $(KERNEL_OUT)/.config + KERNEL_HEADERS_INSTALL := $(KERNEL_OUT)/usr + KERNEL_CONFIG_FILE := $(KERNEL_DIR)/arch/$(KERNEL_TARGET_ARCH)/configs/$(word 1,$(KERNEL_DEFCONFIG)) + #KERNEL_CONFIG_MODULES := $(shell grep ^CONFIG_MODULES=y $(KERNEL_CONFIG_FILE)) + #KERNEL_MODULES_OUT := $(if $(filter /% ~%,$(TARGET_OUT)),,$(KERNEL_ROOT_DIR)/)$(TARGET_OUT) + #KERNEL_MODULES_DEPS := $(if $(wildcard $(KERNEL_MODULES_OUT)/lib/modules/*.ko),$(wildcard $(KERNEL_MODULES_OUT)/lib/modules/*.ko),$(KERNEL_MODULES_OUT)/lib/modules) + #KERNEL_MODULES_SYMBOLS_OUT := $(if $(filter /% ~%,$(TARGET_OUT_UNSTRIPPED)),,$(KERNEL_ROOT_DIR)/)$(TARGET_OUT_UNSTRIPPED)/system + KERNEL_MAKE_OPTION := O=$(KERNEL_ROOT_OUT) ARCH=$(KERNEL_TARGET_ARCH) $(ARGS) ROOTDIR=$(KERNEL_ROOT_DIR) + KERNEL_MAKE_PATH_OPTION := /usr/bin:/bin + KERNEL_MAKE_OPTION += PATH=$(KERNEL_ROOT_DIR)/$(CLANG_PREBUILT_BIN):$(KERNEL_ROOT_DIR)/$(LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN):$(KERNEL_MAKE_PATH_OPTION):$$PATH + ifdef MTK_DTBO_FEATURE + KERNEL_MAKE_OPTION += MTK_DTBO_FEATURE=$(MTK_DTBO_FEATURE) + endif + else + BUILT_KERNEL_TARGET := $(TARGET_PREBUILT_KERNEL) + endif#TARGET_PREBUILT_KERNEL is empty + KERNEL_MAKE_OPTION += PROJECT_DTB_NAMES='$(PROJECT_DTB_NAMES)' +endif#TARGET_NO_KERNEL diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 0ac19cca4654..8eb1c163a11c 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -280,7 +280,6 @@ config PAGE_OWNER config DEBUG_FS bool "Debug Filesystem" - select SRCU help debugfs is a virtual file system that kernel developers use to put debugging files into. Enable this option to be able to read and @@ -338,7 +337,6 @@ config DEBUG_SECTION_MISMATCH config SECTION_MISMATCH_WARN_ONLY bool "Make section mismatch errors non-fatal" - default y help If you say N here, the build process will fail if there are any section mismatch, instead of just throwing warnings. diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan index 4f20a5cdeb9d..9105467c1db2 100644 --- a/lib/Kconfig.kasan +++ b/lib/Kconfig.kasan @@ -127,6 +127,14 @@ config KASAN_STACK default 1 if KASAN_STACK_ENABLE || CC_IS_GCC default 0 +config KASAN_SW_TAGS_IDENTIFY + bool "Enable memory corruption identification" + depends on KASAN_SW_TAGS + help + This option enables best-effort identification of bug type + (use-after-free or out-of-bounds) at the cost of increased + memory consumption. + config TEST_KASAN tristate "Module for testing KASAN for bug detection" depends on m && KASAN diff --git a/lib/Kconfig.ubsan b/lib/Kconfig.ubsan index a669c193b878..2ae214449a9a 100644 --- a/lib/Kconfig.ubsan +++ b/lib/Kconfig.ubsan @@ -1,9 +1,6 @@ config ARCH_HAS_UBSAN_SANITIZE_ALL bool -config ARCH_WANTS_UBSAN_NO_NULL - def_bool n - config UBSAN bool "Undefined behaviour sanity checker" help @@ -39,10 +36,3 @@ config UBSAN_ALIGNMENT Enabling this option on architectures that support unaligned accesses may produce a lot of false positives. -config UBSAN_NULL - bool "Enable checking of null pointers" - depends on UBSAN - default y if !ARCH_WANTS_UBSAN_NO_NULL - help - This option enables detection of memory accesses via a - null pointer. diff --git a/lib/debug_locks.c b/lib/debug_locks.c index 124fdf238b3d..639ed448c73a 100644 --- a/lib/debug_locks.c +++ b/lib/debug_locks.c @@ -14,6 +14,11 @@ #include #include +#ifdef CONFIG_LOCKDEP +#include +unsigned long long debug_locks_off_ts; +#endif + /* * We want to turn all lock-debugging facilities on/off at once, * via a global flag. The reason is that once a single bug has been @@ -38,6 +43,9 @@ EXPORT_SYMBOL_GPL(debug_locks_silent); int debug_locks_off(void) { if (debug_locks && __debug_locks_off()) { +#ifdef CONFIG_LOCKDEP + debug_locks_off_ts = sched_clock(); +#endif if (!debug_locks_silent) { console_verbose(); return 1; diff --git a/lib/dec_and_lock.c b/lib/dec_and_lock.c index 9555b68bb774..f7cb553124cb 100644 --- a/lib/dec_and_lock.c +++ b/lib/dec_and_lock.c @@ -34,6 +34,23 @@ int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock) EXPORT_SYMBOL(_atomic_dec_and_lock); +/* It's the lock irq safe version of _atomic_dec_and_lock */ +int _atomic_dec_and_lock_irqsafe(atomic_t *atomic, spinlock_t *lock, + unsigned long *flags) +{ + /* Subtract 1 from counter unless that drops it to 0 (ie. it was 1) */ + if (atomic_add_unless(atomic, -1, 1)) + return 0; + + /* Otherwise do it the slow way */ + spin_lock_irqsave(lock, *flags); + if (atomic_dec_and_test(atomic)) + return 1; + spin_unlock_irqrestore(lock, *flags); + return 0; +} +EXPORT_SYMBOL(_atomic_dec_and_lock_irqsafe); + int _atomic_dec_and_lock_irqsave(atomic_t *atomic, spinlock_t *lock, unsigned long *flags) { diff --git a/lib/dma-debug.c b/lib/dma-debug.c index 61e7240947f5..028e593287a6 100644 --- a/lib/dma-debug.c +++ b/lib/dma-debug.c @@ -1492,18 +1492,26 @@ void debug_dma_alloc_coherent(struct device *dev, size_t size, if (unlikely(virt == NULL)) return; + /* handle vmalloc and linear addresses */ + if (!is_vmalloc_addr(virt) && !virt_addr_valid(virt)) + return; + entry = dma_entry_alloc(); if (!entry) return; entry->type = dma_debug_coherent; entry->dev = dev; - entry->pfn = page_to_pfn(virt_to_page(virt)); entry->offset = offset_in_page(virt); entry->size = size; entry->dev_addr = dma_addr; entry->direction = DMA_BIDIRECTIONAL; + if (is_vmalloc_addr(virt)) + entry->pfn = vmalloc_to_pfn(virt); + else + entry->pfn = page_to_pfn(virt_to_page(virt)); + add_dma_entry(entry); } EXPORT_SYMBOL(debug_dma_alloc_coherent); @@ -1514,13 +1522,21 @@ void debug_dma_free_coherent(struct device *dev, size_t size, struct dma_debug_entry ref = { .type = dma_debug_coherent, .dev = dev, - .pfn = page_to_pfn(virt_to_page(virt)), .offset = offset_in_page(virt), .dev_addr = addr, .size = size, .direction = DMA_BIDIRECTIONAL, }; + /* handle vmalloc and linear addresses */ + if (!is_vmalloc_addr(virt) && !virt_addr_valid(virt)) + return; + + if (is_vmalloc_addr(virt)) + ref.pfn = vmalloc_to_pfn(virt); + else + ref.pfn = page_to_pfn(virt_to_page(virt)); + if (unlikely(dma_debug_disabled())) return; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 3f4a49c3c03b..e3b553e47e37 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -548,6 +548,146 @@ static char *dynamic_emit_prefix(const struct _ddebug *desc, char *buf) return buf; } +void __dynamic_pr_emerg(struct _ddebug *descriptor, const char *fmt, ...) +{ + va_list args; + struct va_format vaf; + char buf[PREFIX_SIZE]; + + BUG_ON(!descriptor); + BUG_ON(!fmt); + + va_start(args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + + printk(KERN_EMERG "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); + + va_end(args); +} +EXPORT_SYMBOL(__dynamic_pr_emerg); + +void __dynamic_pr_alert(struct _ddebug *descriptor, const char *fmt, ...) +{ + va_list args; + struct va_format vaf; + char buf[PREFIX_SIZE]; + + BUG_ON(!descriptor); + BUG_ON(!fmt); + + va_start(args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + + printk(KERN_ALERT "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); + + va_end(args); +} +EXPORT_SYMBOL(__dynamic_pr_alert); + +void __dynamic_pr_crit(struct _ddebug *descriptor, const char *fmt, ...) +{ + va_list args; + struct va_format vaf; + char buf[PREFIX_SIZE]; + + BUG_ON(!descriptor); + BUG_ON(!fmt); + + va_start(args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + + printk(KERN_CRIT "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); + + va_end(args); +} +EXPORT_SYMBOL(__dynamic_pr_crit); + +void __dynamic_pr_err(struct _ddebug *descriptor, const char *fmt, ...) +{ + va_list args; + struct va_format vaf; + char buf[PREFIX_SIZE]; + + BUG_ON(!descriptor); + BUG_ON(!fmt); + + va_start(args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + + printk(KERN_ERR "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); + + va_end(args); +} +EXPORT_SYMBOL(__dynamic_pr_err); + +void __dynamic_pr_warn(struct _ddebug *descriptor, const char *fmt, ...) +{ + va_list args; + struct va_format vaf; + char buf[PREFIX_SIZE]; + + BUG_ON(!descriptor); + BUG_ON(!fmt); + + va_start(args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + + printk(KERN_WARNING "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); + + va_end(args); +} +EXPORT_SYMBOL(__dynamic_pr_warn); + +void __dynamic_pr_notice(struct _ddebug *descriptor, const char *fmt, ...) +{ + va_list args; + struct va_format vaf; + char buf[PREFIX_SIZE]; + + BUG_ON(!descriptor); + BUG_ON(!fmt); + + va_start(args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + + printk(KERN_NOTICE "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); + + va_end(args); +} +EXPORT_SYMBOL(__dynamic_pr_notice); + +void __dynamic_pr_info(struct _ddebug *descriptor, const char *fmt, ...) +{ + va_list args; + struct va_format vaf; + char buf[PREFIX_SIZE]; + + BUG_ON(!descriptor); + BUG_ON(!fmt); + + va_start(args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + + printk(KERN_INFO "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); + + va_end(args); +} +EXPORT_SYMBOL(__dynamic_pr_info); + void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) { va_list args; diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 759ff419fe61..8d0d0da59074 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -69,6 +69,7 @@ struct stack_record { struct stack_record *next; /* Link in the hashtable */ u32 hash; /* Hash in the hastable */ u32 size; /* Number of frames in the stack */ + u32 hit; union handle_parts handle; unsigned long entries[1]; /* Variable-sized array of entries. */ }; @@ -79,6 +80,9 @@ static int depot_index; static int next_slab_inited; static size_t depot_offset; static DEFINE_SPINLOCK(depot_lock); +static struct stack_record *max_found; +static DEFINE_SPINLOCK(max_found_lock); + static bool init_stack_slab(void **prealloc) { @@ -141,6 +145,7 @@ static struct stack_record *depot_alloc_stack(unsigned long *entries, int size, stack->hash = hash; stack->size = size; + stack->hit = 0; stack->handle.slabindex = depot_index; stack->handle.offset = depot_offset >> STACK_ALLOC_ALIGN; stack->handle.valid = 1; @@ -198,6 +203,41 @@ void depot_fetch_stack(depot_stack_handle_t handle, struct stack_trace *trace) } EXPORT_SYMBOL_GPL(depot_fetch_stack); +void depot_hit_stack(depot_stack_handle_t handle, struct stack_trace *trace, + int cnt) +{ + union handle_parts parts = { .handle = handle }; + void *slab = stack_slabs[parts.slabindex]; + size_t offset = parts.offset << STACK_ALLOC_ALIGN; + struct stack_record *stack = slab + offset; + unsigned long flags; + + stack->hit += cnt; + spin_lock_irqsave(&max_found_lock, flags); + if ((!max_found) || (stack->hit > max_found->hit)) + max_found = stack; + spin_unlock_irqrestore(&max_found_lock, flags); +} +EXPORT_SYMBOL_GPL(depot_hit_stack); + +void show_max_hit_page(void) +{ + unsigned long entries[16]; + unsigned long flags; + struct stack_trace trace = { + .nr_entries = 0, + .entries = entries, + .max_entries = 16, + .skip = 0 + }; + spin_lock_irqsave(&max_found_lock, flags); + depot_fetch_stack(max_found->handle.handle, &trace); + pr_info("max found hit=%d\n", max_found->hit); + print_stack_trace(&trace, 2); + spin_unlock_irqrestore(&max_found_lock, flags); +} +EXPORT_SYMBOL_GPL(show_max_hit_page); + /** * depot_save_stack - save stack in a stack depot. * @trace - the stacktrace to save. diff --git a/lib/swiotlb.c b/lib/swiotlb.c index b4c768de3344..461ca30d8047 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c @@ -715,6 +715,9 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size, void *ret; int order = get_order(size); u64 dma_mask = DMA_BIT_MASK(32); +#ifdef CONFIG_MTK_BOUNCING_CHECK + dma_addr_t dev_addr_end; +#endif if (hwdev && hwdev->coherent_dma_mask) dma_mask = hwdev->coherent_dma_mask; @@ -728,6 +731,13 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size, */ free_pages((unsigned long) ret, order); ret = NULL; +#ifdef CONFIG_MTK_BOUNCING_CHECK + dev_addr_end = dev_addr + size - 1; + aee_kernel_warning("Bounce Buffering", + "Incorrect dma_mask(%llx), addr+size-1(%pad)", + dma_mask, &dev_addr_end); + +#endif } } if (!ret) { diff --git a/lib/ubsan.c b/lib/ubsan.c index c652b4a820cc..3b4b71fc756e 100644 --- a/lib/ubsan.c +++ b/lib/ubsan.c @@ -20,6 +20,9 @@ #include "ubsan.h" +#include "../kernel/sched/sched.h" +#include "../drivers/misc/mediatek/include/mt-plat/aee.h" + const char *type_check_kinds[] = { "load of", "store to", @@ -163,11 +166,25 @@ static void ubsan_prologue(struct source_location *location, static void ubsan_epilogue(unsigned long *flags) { + int cpu; + struct rq *rq; + dump_stack(); pr_err("========================================" "========================================\n"); spin_unlock_irqrestore(&report_lock, *flags); current->in_ubsan--; + + cpu = raw_smp_processor_id(); + rq = cpu_rq(cpu); + if (!raw_spin_is_locked(&rq->lock)) { + /* AEE Kernel API Dump for UBSan */ + aee_kernel_warning_api(__FILE__, __LINE__, DB_OPT_DEFAULT, + "UBSan error", + "[UBSan report]"); + } else { + BUG(); + } } static void handle_overflow(struct overflow_data *data, void *lhs, diff --git a/ll.sh b/ll.sh new file mode 100644 index 000000000000..f98bffd4ecb0 --- /dev/null +++ b/ll.sh @@ -0,0 +1,2 @@ +#!/bin/bash + `date +%Y-%m-%d/%H:%M:%S` user begin >> ./time.log diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 85a82e22b14f..23741c7fbace 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -178,6 +178,10 @@ DTC_INCLUDE := $(srctree)/scripts/dtc/include-prefixes dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ $(addprefix -I,$(DTC_INCLUDE)) \ + -I$(srctree)/arch/$(SRCARCH)/boot/dts \ + -I$(srctree)/arch/$(SRCARCH)/boot/dts/include \ + -I$(objtree)/include/ \ + -Iarch/$(SRCARCH)/boot/dts \ -undef -D__DTS__ # Finds the multi-part object the current object will be linked into @@ -308,7 +312,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 \ $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \ -d $(depfile).dtc.tmp $(dtc-tmp) ; \ cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 2fd5d98afbbc..375fced58953 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -79,7 +79,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))) diff --git a/scripts/Makefile.ubsan b/scripts/Makefile.ubsan index 8fd4d44fbcd1..2d268b84b907 100644 --- a/scripts/Makefile.ubsan +++ b/scripts/Makefile.ubsan @@ -15,10 +15,6 @@ ifdef CONFIG_UBSAN_ALIGNMENT CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment) endif -ifdef CONFIG_UBSAN_NULL - CFLAGS_UBSAN += $(call cc-option, -fsanitize=null) -endif - # -fsanitize=* options makes GCC less smart than usual and # increase number of 'maybe-uninitialized false-positives CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized) diff --git a/scripts/check_defconfigs b/scripts/check_defconfigs new file mode 100644 index 000000000000..f51f8f46e601 --- /dev/null +++ b/scripts/check_defconfigs @@ -0,0 +1,309 @@ +# SPDX-License-Identifier: GPL-2.0 +# +#!/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 +} + +function build_config_parse () +{ + build_config=$1 + + CC= + LD= + cc=`cat ${build_config} | grep ^CC= | cut -d'=' -f 2` + ld=`cat ${build_config} | grep ^LD= | cut -d'=' -f 2` + + if [ $cc == clang ]; then + toolchain=`cat ${build_config} | grep CLANG_PREBUILT_BIN | cut -d'=' -f 2` + CC="${PWD}/../${toolchain}/${cc}" + LD="${PWD}/../${toolchain}/${ld}" + else + toolchain=`cat ${build_config} | grep LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN | cut -d'=' -f 2` + cross_compile=`cat ${build_config} | grep ^CROSS_COMPILE | cut -d'=' -f 2` + CC="${PWD}/../${toolchain}/${cross_compile}${cc}" + fi +} + +function build_config_read () +{ + build_config_parse ${ARM_CONFIG} + CC_ARM="${CC}" + LD_ARM="${LD}" + + build_config_parse ${ARM64_CONFIG} + CC_ARM64="${CC}" + LD_ARM64="${LD}" + + build_config_parse ${ARM64_GCC_CONFIG} + CC_ARM64_GCC="${CC}" + LD_ARM64_GCC="${LD}" + + build_config_parse ${KASAN_CONFIG} + CC_KASAN="${CC}" + LD_KASAN="${LD}" + + build_config_parse ${UBSAN_CONFIG} + CC_UBSAN="${CC}" + LD_UBSAN="${LD}" +} + +function toolchain_check () +{ + if [ ! -d "../${TOOLCHAIN_CLANG_PATH}/linux-x86" ]; then + echo "CLANG does not exist, clone it" + mkdir -p "../${TOOLCHAIN_CLANG_PATH}" + cd "../${TOOLCHAIN_CLANG_PATH}" + git clone "http://gerrit.mediatek.inc:8080/${TOOLCHAIN_CLANG_REPO}" + cd linux-x86 + git reset --hard ${TOOLCHAIN_CLANG_COMMIT} + else + echo "update CLANG to specific commit" + cd "../${TOOLCHAIN_CLANG_PATH}/linux-x86" + git reset --hard ${TOOLCHAIN_CLANG_COMMIT} + fi + cd ${KERNEL_PATH} + + if [ ! -d "../${TOOLCHAIN_GCC_PATH}/bin" ]; then + echo "GCC does not exist, clone it" + rm -rf "../${TOOLCHAIN_GCC_PATH}" + mkdir -p "../prebuilts/gcc/linux-x86/aarch64" + cd "../prebuilts/gcc/linux-x86/aarch64" + git clone "http://gerrit.mediatek.inc:8080/${TOOLCHAIN_GCC_REPO}" -b alps-trunk-r0.basic + else + echo "update GCC to the latest codebase" + cd "../${TOOLCHAIN_GCC_PATH}" + git pull + fi + cd ${KERNEL_PATH} +} + +CONFIGS= +UPDATE=0 +CHECK_COMMIT=0 +CHECK_SERVICE=0 +CC= +LD= +CC_ARM= +CC_ARM64= +CC_ARM64_GCC= +CC_KASAN= +CC_UBSAN= +LD_ARM= +LD_ARM64= +LD_ARM64_GCC= +LD_KASAN= +LD_UBSAN= +ARM_CONFIG='build.config.mtk.arm' +ARM64_CONFIG='build.config.mtk.aarch64' +ARM64_GCC_CONFIG='build.config.mtk.aarch64.gcc' +KASAN_CONFIG='build.config.mtk.aarch64.kasan' +UBSAN_CONFIG='build.config.mtk.aarch64.ubsan' +TOOLCHAIN_CLANG_PATH='prebuilts/clang/host' +TOOLCHAIN_GCC_PATH='prebuilts/gcc/linux-x86/aarch64/aarch64-linux-gnu-6.3.1' +TOOLCHAIN_CLANG_REPO='platform/prebuilts/clang/host/linux-x86' +TOOLCHAIN_GCC_REPO='alps/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-gnu-6.3.1' +TOOLCHAIN_CLANG_COMMIT='252aba16f513a857bc923172f67b0e55e23de35f' +KERNEL_PATH=${PWD} +build_config_read + +echo "CC_ARM=${CC_ARM}" +echo "CC_ARM64=${CC_ARM64}" +echo "CC_ARM64_GCC=${CC_ARM64_GCC}" +echo "CC_KASAN=${CC_KASAN}" +echo "CC_UBSAN=${CC_UBSAN}" +echo "LD_ARM=${LD_ARM}" +echo "LD_ARM64=${LD_ARM64}" +echo "LD_ARM64_GCC=${LD_ARM64_GCC}" +echo "LD_KASAN=${LD_KASAN}" +echo "LD_UBSAN=${LD_UBSAN}" + +while getopts "cuh" opt; do + case $opt in + c) + if [ $# == 2 ]; then + CHECK_COMMIT=$2 + if [ ${CHECK_COMMIT} == FETCH_HEAD ]; then + CHECK_SERVICE=1 + echo Checking from check service + fi + 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 + else + echo "Nothing to check" + exit 0 + 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} + CC_ARM=${3} + CC_ARM64=${4} + CC_ARM64_GCC=${5} + CC_KASAN=${6} + CC_UBSAN=${7} + LD_ARM=${8} + LD_ARM64=${9} + LD_ARM64_GCC=${10} + LD_KASAN=${11} + LD_UBSAN=${12} + 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 + CC=${CC_ARM} + LD=${LD_ARM} + else + ARCH=arm64 + CC=${CC_ARM64} + LD=${LD_ARM64} + fi + + echo $CONFIG | grep kasan > /dev/null + RETVAL=$? + if [ $RETVAL == 0 ]; then + CC=${CC_KASAN} + LD=${LD_KASAN} + fi + + echo $CONFIG | grep ubsan > /dev/null + RETVAL=$? + if [ $RETVAL == 0 ]; then + CC=${CC_UBSAN} + LD=${LD_UBSAN} + fi + + OUT=out-$$ + mkdir ${OUT} + + ARGS=() + + if [ -n "${CC}" ]; then + ARGS+=("CC=${CC}") + fi + + if [ -n "${LD}" ]; then + ARGS+=("LD=${LD}") + fi + + CMD="make ARCH=${ARCH} ${ARGS[@]} O=${OUT} `basename ${CONFIG}` savedefconfig 2>&1" + echo $CMD + + OUTPUT="$(${CMD})" + 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 + +toolchain_check +parallel check_defconfig ::: $CONFIGS ::: $UPDATE ::: $CC_ARM ::: $CC_ARM64 ::: $CC_ARM64_GCC ::: $CC_KASAN ::: $CC_UBSAN ::: $LD_ARM ::: $LD_ARM64 ::: $LD_ARM64_GCC ::: $LD_KASAN ::: $LD_UBSAN +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 + +if [ ${CHECK_SERVICE} == 1 ]; then + rm -rf /tmp/prebuilts + echo Remove toolchain in check service +fi + +exit $RETVAL diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index bfc5dfcbbc9c..0b50aebad445 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -48,7 +48,7 @@ my @ignore = (); my $help = 0; my $configuration_file = ".checkpatch.conf"; -my $max_line_length = 80; +my $max_line_length = 100; my $ignore_perl_version = 0; my $minimum_perl_version = 5.10.0; my $min_conf_desc_length = 4; @@ -91,7 +91,9 @@ sub help { --types TYPE(,TYPE2...) show only these comma separated message types --ignore TYPE(,TYPE2...) ignore various comma separated message types --show-types show the specific message type in the output - --max-line-length=n set the maximum line length, if exceeded, warn + --max-line-length=n set the maximum line length, (default $max_line_length) + if exceeded, warn on patches + requires --strict for use with --file --min-conf-desc-length=n set the min description length, if shorter, warn --root=PATH PATH to the kernel tree root --no-summary suppress the per-file summary @@ -2919,8 +2921,10 @@ sub process { if ($msg_type ne "" && (show_type("LONG_LINE") || show_type($msg_type))) { - WARN($msg_type, - "line over $max_line_length characters\n" . $herecurr); + my $msg_level = \&WARN; + $msg_level = \&CHK if ($file); + &{$msg_level}($msg_type, + "line length of $length exceeds $max_line_length columns\n" . $herecurr); } } @@ -5957,7 +5961,7 @@ sub process { # check for function declarations that have arguments without identifier names if (defined $stat && - $stat =~ /^.\s*(?:extern\s+)?$Type\s*$Ident\s*\(\s*([^{]+)\s*\)\s*;/s && + $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) { diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 365b3c2b8f43..c06ff0eea437 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -79,12 +79,12 @@ scm_version() # it fails. Note that git-diff-index does not refresh the # index, so it may give misleading results. See # git-update-index(1), git-diff-index(1), and git-status(1). - if { - git --no-optional-locks status -uno --porcelain 2>/dev/null || - git diff-index --name-only HEAD - } | grep -qvE '^(.. )?scripts/package'; then - printf '%s' -dirty - fi + #if { + # git --no-optional-locks status -uno --porcelain 2>/dev/null || + # git diff-index --name-only HEAD + #} | grep -qvE '^(.. )?scripts/package'; then + # printf '%s' -dirty + #fi # All done with git return @@ -106,9 +106,9 @@ scm_version() # Are there uncommitted changes? # These are represented by + after the changeset id. - case "$hgid" in - *+|*+\ *) printf '%s' -dirty ;; - esac + #case "$hgid" in + # *+|*+\ *) printf '%s' -dirty ;; + #esac # All done with mercurial return