treewide: Import remaining Realme changes

* From https://github.com/realme-kernel-opensource/realme7_realme8_Narzo30_Narzo20pro-AndroidS-kernel-source

Signed-off-by: bengris32 <bengris32@protonmail.ch>
Change-Id: I3d395e16689828eea91be6a278814607234c5fcb
This commit is contained in:
bengris32
2022-07-11 13:33:48 +01:00
parent 5c0d5ca94b
commit 93d64a42d1
63 changed files with 2798 additions and 218 deletions

90
Android.mk Executable file
View File

@@ -0,0 +1,90 @@
# 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)
#ifdef OPLUS_FEATURE_FORCE_SELINUX
#Haoran.Zhang@ANDROID.BUILD, 2020/01/10, add for unset SECURITY_SELINUX_DEVELOP, set it only for debug
OBSOLETE_KEEP_ADB_SECURE=$(OBSOLETE_KEEP_ADB_SECURE) \
TARGET_MEMLEAK_DETECT_TEST=$(TARGET_MEMLEAK_DETECT_TEST) \
$(KERNEL_DIR)/tools/changeConfig.sh $(KERNEL_CONFIG_FILE)
#endif OPLUS_FEATURE_FORCE_SELINUX
$(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)
ifdef PROJECT_DTB_NAMES
# check the kernel image size
python device/mediatek/build/build/tools/check_kernel_size.py $(KERNEL_OUT) $(KERNEL_DIR) $(PROJECT_DTB_NAMES)
endif
$(BUILT_KERNEL_TARGET): $(KERNEL_ZIMAGE_OUT) $(TARGET_KERNEL_CONFIG) $(LOCAL_PATH)/Android.mk | $(ACP)
$(copy-file-to-target)
$(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
CUSTOMER_DTB_PLATFORM := $(subst $\",,$(shell grep DTB_IMAGE_NAMES $(KERNEL_CONFIG_FILE) | sed 's/.*=//' ))
MTK_DTBIMAGE_DTS:= $(addsuffix .dts,$(addprefix $(KERNEL_DIR)/arch/$(KERNEL_TARGET_ARCH)/boot/dts/,$(CUSTOMER_DTB_PLATFORM)))
include device/mediatek/build/core/build_dtbimage.mk
CUSTOMER_DTBO_PROJECT := $(subst $\",,$(shell grep DTB_OVERLAY_IMAGE_NAMES $(KERNEL_CONFIG_FILE) | sed 's/.*=//' ))
MTK_DTBOIMAGE_DTS := $(addsuffix .dts,$(addprefix $(KERNEL_DIR)/arch/$(KERNEL_TARGET_ARCH)/boot/dts/,$(CUSTOMER_DTBO_PROJECT)))
include device/mediatek/build/core/build_dtboimage.mk
endif#TARGET_NO_KERNEL
endif#LINUX_KERNEL_VERSION

16
CleanSpec.mk Normal file
View File

@@ -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

View File

@@ -0,0 +1,13 @@
What: /sys/class/misc/access-<region>/label
Date: May 16, 2017
KernelVersion: 3.18
Contact: Patrick Tjin <pattjin@google.com>
Description: This file exposes the region which is controlled by the driver.
What: /sys/class/misc/access-<region>/size
Date: June 6, 2017
KernelVersion: 3.18
Contact: Patrick Tjin <pattjin@google.com>
Description: This file exposes the size of the region which is controlled
by the driver.

2
Documentation/admin-guide/kernel-parameters.txt Normal file → Executable file
View File

@@ -2009,7 +2009,7 @@
Default is 'flush'.
For details see: Documentation/admin-guide/hw-vuln/l1tf.rst
For details see: Documentation/admin-guide/l1tf.rst
l2cr= [PPC]

View File

@@ -0,0 +1,24 @@
MediaTek GCE
===============
The Global Command Engine (GCE) is used to help read/write registers with
critical time limitation, such as updating display configuration during the
vblank. The GCE can be used to implement the Command Queue (CMDQ) driver.
Required properties:
- compatible: Must be "mediatek,gce"
- reg: Address range of the GCE unit
- interrupts: The interrupt signal from the GCE block
- clock: Clocks according to the common clock binding
- clock-names: Must be "GCE" to stand for GCE clock
Example:
gce: gce@10212000 {
compatible = "mediatek,gce";
reg = <0 0x10212000 0 0x1000>;
interrupts = <GIC_SPI 135 IRQ_TYPE_LEVEL_LOW>;
clocks = <&infracfg_ao INFRACFG_AO_GCE_CG>;
clock-names = "GCE";
};

View File

@@ -0,0 +1,25 @@
MediaTek GCE Secure Video Path Support Driver
===============
The Global Command Engine (GCE) is used to help read/write registers with
critical time limitation, such as updating display configuration during the
vblank. The GCE can be used to implement the Command Queue (CMDQ) driver.
Secure Video Path driver can protect premium video content leakage
Required properties:
- compatible: Must be "mediatek,mailbox-gce-svp"
- reg: Address range of the GCE unit
- interrupts: The interrupt signal from the GCE block
- clock: Clocks according to the common clock binding
- clock-names: Must be "gce" to stand for GCE clock
Example:
gce_mbox_svp: gce_mbox_svp@10238000 {
compatible = "mediatek,mailbox-gce-svp";
reg = <0 0x10238000 0 0x1000>;
interrupts = <GIC_SPI 154 IRQ_TYPE_LEVEL_LOW>;
clocks = <&infracfg_ao INFRACFG_AO_GCE_CG>;
clock-names = "gce";
};

View File

@@ -0,0 +1,24 @@
MediaTek GCE
===============
The Global Command Engine (GCE) is used to help read/write registers with
critical time limitation, such as updating display configuration during the
vblank. The GCE can be used to implement the Command Queue (CMDQ) driver.
Required properties:
- compatible: Must be "mediatek,mailbox-gce"
- reg: Address range of the GCE unit
- interrupts: The interrupt signal from the GCE block
- clock: Clocks according to the common clock binding
- clock-names: Must be "gce" to stand for GCE clock
Example:
gce_mbox: gce_mbox@10238000 {
compatible = "mediatek,mailbox-gce";
reg = <0 0x10238000 0 0x1000>;
interrupts = <GIC_SPI 154 IRQ_TYPE_LEVEL_LOW>;
clocks = <&infracfg_ao INFRACFG_AO_GCE_CG>;
clock-names = "gce";
};

View File

@@ -14,6 +14,7 @@ Required properties:
- "mediatek,mt2701-auxadc": For MT2701 family of SoCs
- "mediatek,mt7622-auxadc": For MT7622 family of SoCs
- "mediatek,mt8173-auxadc": For MT8173 family of SoCs
- "mediatek,mt6768-auxadc": For MT6768 family of SoCs
- reg: Address range of the AUXADC unit.
- clocks: Should contain a clock specifier for each entry in clock-names
- clock-names: Should contain "main".

View File

@@ -36,22 +36,33 @@ each local arbiter.
like display, video decode, and camera. And there are different ports
in each larb. Take a example, There are many ports like MC, PP, VLD in the
video decode local arbiter, all these ports are according to the video HW.
In some Socs, there may be a GALS(Global Async Local Sync) module between
smi-common and m4u, and additional GALS module between smi-larb and
smi-common. GALS can been seen as a "asynchronous fifo" which could help
synchronize for the modules in different clock frequence.
Required properties:
- compatible : must be one of the following string:
"mediatek,mt2701-m4u" for mt2701 which uses generation one m4u HW.
"mediatek,mt2712-m4u" for mt2712 which uses generation two m4u HW.
"mediatek,mt8173-m4u" for mt8173 which uses generation two m4u HW.
"mediatek,mt8183-m4u" for mt8183 which uses generation two m4u HW.
- reg : m4u register base and size.
- interrupts : the interrupt of m4u.
- clocks : must contain one entry for each clock-names.
- clock-names : must be "bclk", It is the block clock of m4u.
- clock-names : Only 1 optional clock:
- "bclk": the block clock of m4u.
Note that m4u use EMI clock which always has been enabled before kernel if
there is no this "bclk", like mt8183.
- mediatek,larbs : List of phandle to the local arbiters in the current Socs.
Refer to bindings/memory-controllers/mediatek,smi-larb.txt. It must sort
according to the local arbiter index, like larb0, larb1, larb2...
- iommu-cells : must be 1. This is the mtk_m4u_id according to the HW.
Specifies the mtk_m4u_id as defined in
dt-binding/memory/mt2701-larb-port.h for mt2701 and
dt-binding/memory/mt8173-larb-port.h for mt8173
dt-binding/memory/mt2701-larb-port.h for mt2701,
dt-binding/memory/mt2712-larb-port.h for mt2712,
dt-binding/memory/mt8173-larb-port.h for mt8173, and
dt-binding/memory/mt8183-larb-port.h for mt8183.
Example:
iommu: iommu@10205000 {

View File

@@ -0,0 +1,65 @@
MediaTek GCE
===============
The Global Command Engine (GCE) is used to help read/write registers with
critical time limitation, such as updating display configuration during the
vblank. The GCE can be used to implement the Command Queue (CMDQ) driver.
CMDQ driver uses mailbox framework for communication. Please refer to
mailbox.txt for generic information about mailbox device-tree bindings.
Required properties:
- compatible: Must be "mediatek,mt8173-gce"
- reg: Address range of the GCE unit
- interrupts: The interrupt signal from the GCE block
- clock: Clocks according to the common clock binding
- clock-names: Must be "gce" to stand for GCE clock
- thread-num: Maximum threads count of GCE.
- #mbox-cells: Should be 4.
<&phandle channel timeout priority atomic_exec>
phandle: Label name of a gce node.
channel: Channel of mailbox. Be equal to the thread id of GCE.
timeout: Maximum time of software waiting GCE processing done, in unit
of millisecond.
priority: Priority of GCE thread.
atomic_exec: GCE processing continuous packets of commands in atomic
way.
Required properties for a client device:
- mboxes: Client use mailbox to communicate with GCE, it should have this
property and list of phandle, mailbox specifiers.
- gce-subsys: Specify the sub-system id which is corresponding to the register
address.
Optional properties for a client device:
- gce-event: Specify the event if the client has any. Because the event is
parsed by client, so client can replace 'gce-event' with other meaningful
name.
Some vaules of properties are defined in 'dt-bindings/gce/mt8173-gce.h'. Such as
thread number, sub-system ids, thread priority, event ids.
Example:
gce: gce@10212000 {
compatible = "mediatek,mt8173-gce";
reg = <0 0x10212000 0 0x1000>;
interrupts = <GIC_SPI 135 IRQ_TYPE_LEVEL_LOW>;
clocks = <&infracfg CLK_INFRA_GCE>;
clock-names = "gce";
thread-num = CMDQ_THR_MAX_COUNT;
#mbox-cells = <4>;
};
Example for a client device:
mmsys: clock-controller@14000000 {
compatible = "mediatek,mt8173-mmsys";
mboxes = <&gce 0 2000 CMDQ_THR_PRIO_LOWEST 1>,
<&gce 1 2000 CMDQ_THR_PRIO_LOWEST 1>;
gce-subsys = <SUBSYS_1400XXXX>;
mutex-event-eof = <CMDQ_EVENT_MUTEX0_STREAM_EOF
CMDQ_EVENT_MUTEX1_STREAM_EOF>;
...
};

View File

@@ -2,8 +2,10 @@ SMI (Smart Multimedia Interface) Common
The hardware block diagram please check bindings/iommu/mediatek,iommu.txt
Mediatek SMI have two generations of HW architecture, mt8173 uses the second
generation of SMI HW while mt2701 uses the first generation HW of SMI.
Mediatek SMI have two generations of HW architecture, here is the list
which generation the Socs use:
generation 1: mt2701.
generation 2: mt2712, mt8173 and mt8183.
There's slight differences between the two SMI, for generation 2, the
register which control the iommu port is at each larb's register base. But
@@ -15,7 +17,9 @@ not needed for SMI generation 2.
Required properties:
- compatible : must be one of :
"mediatek,mt2701-smi-common"
"mediatek,mt2712-smi-common"
"mediatek,mt8173-smi-common"
"mediatek,mt8183-smi-common"
- reg : the register and size of the SMI block.
- power-domains : a phandle to the power domain of this local arbiter.
- clocks : Must contain an entry for each entry in clock-names.
@@ -27,6 +31,11 @@ Required properties:
They may be the same if both source clocks are the same.
- "async" : asynchronous clock, it help transform the smi clock into the emi
clock domain, this clock is only needed by generation 1 smi HW.
and these 2 option clocks for generation 2 smi HW:
- "gals0": the path0 clock of GALS(Global Async Local Sync).
- "gals1": the path1 clock of GALS(Global Async Local Sync).
Note that "gals0" and "gals1" clock only exist while the SMI HW has "GALS"
modules.
Example:
smi_common: smi@14022000 {

View File

@@ -4,8 +4,10 @@ The hardware block diagram please check bindings/iommu/mediatek,iommu.txt
Required properties:
- compatible : must be one of :
"mediatek,mt8173-smi-larb"
"mediatek,mt2701-smi-larb"
"mediatek,mt2712-smi-larb"
"mediatek,mt8173-smi-larb"
"mediatek,mt8183-smi-larb"
- reg : the register and size of this local arbiter.
- mediatek,smi : a phandle to the smi_common node.
- power-domains : a phandle to the power domain of this local arbiter.
@@ -14,8 +16,10 @@ Required properties:
- "apb" : Advanced Peripheral Bus clock, It's the clock for setting
the register.
- "smi" : It's the clock for transfer data and command.
and this optional clock name:
- "gals": the clock for gals(Global Async Local Sync).
Required property for mt2701:
Required property for mt2701 and mt2712:
- mediatek,larb-id :the hardware id of this larb.
Example:

View File

@@ -0,0 +1,14 @@
access_ramoops driver
=====================
The access_ramoops driver allows userspace access to the persistent RAM storage
used for oops and panics as well as the metadata required to decrypt that data.
Required properties:
- compatible: must be "access_ramoops"
- memory-region: phandle to a region of memory that is preserved between reboots
- label: name of the region, will be used to create the device node /dev/<label>

View File

@@ -7,10 +7,22 @@ This file documents differences between the core properties in mmc.txt
and the properties used by the msdc driver.
Required properties:
- compatible: Should be "mediatek,mt8173-mmc","mediatek,mt8135-mmc"
- compatible: value should be either of the following.
"mediatek,mt8135-mmc": for mmc host ip compatible with mt8135
"mediatek,mt8173-mmc": for mmc host ip compatible with mt8173
"mediatek,mt2701-mmc": for mmc host ip compatible with mt2701
"mediatek,mt2712-mmc": for mmc host ip compatible with mt2712
"mediatek,mt7622-mmc": for MT7622 SoC
"mediatek,mt7623-mmc", "mediatek,mt2701-mmc": for MT7623 SoC
"mediatek,mt8183-mmc": for mmc host ip compatible with mt8183
- reg: physical base address of the controller and length
- interrupts: Should contain MSDC interrupt number
- clocks: MSDC source clock, HCLK
- clock-names: "source", "hclk"
- clocks: Should contain phandle for the clock feeding the MMC controller
- clock-names: Should contain the following:
"source" - source clock (required)
"hclk" - HCLK which used for host (required)
"source_cg" - independent source clock gate (required for MT2712)
- pinctrl-names: should be "default", "state_uhs"
- pinctrl-0: should contain default/high speed pin ctrl
- pinctrl-1: should contain uhs mode pin ctrl
@@ -30,6 +42,10 @@ Optional properties:
- mediatek,hs400-cmd-resp-sel-rising: HS400 command response sample selection
If present,HS400 command responses are sampled on rising edges.
If not present,HS400 command responses are sampled on falling edges.
- mediatek,latch-ck: Some SoCs do not support enhance_rx, need set correct latch-ck to avoid data crc
error caused by stop clock(fifo full)
Valid range = [0:0x7]. if not present, default value is 0.
applied to compatible "mediatek,mt2701-mmc".
Examples:
mmc0: mmc@11230000 {

View File

@@ -0,0 +1,190 @@
# SPDX-License-Identifier: GPL-2.0
%YAML 1.2
---
$id: http://devicetree.org/schemas/regulator/mediatek,rt5133.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Richtek RT5133 voltage regulator
maintainers:
- Jeff Chang <jeff_chang@richtek.com>
- Tina Yang <tina_yang@richtek.com>
description: |
Richtek RT5133 is a integrated IC that includes 8 LDOs and 3 output only
GPIO. There's a limit for GPIO output. It tied to LDO1 output. For example,
if LDO1 is 1.8V, the GPIO output high level will be 1.8V.
properties:
compatible:
const: mediatek,rt5133
reg:
maxItems: 1
wakeup-source: true
interrupts:
maxItems: 1
enable-gpio:
maxItems: 1
description: A connection of the 'enable' gpio line.
gpio-controller: true
gpio-supply: true
"#gpio-cells":
const: 2
regulators:
type: object
patternProperties:
"BASE":
type: object
$ref: "regulator.yaml#"
properties:
oc_shutdown_all:
description: |
If any LDO OC event occurred, to disable all LDOs or not.
$ref: "/schemas/types.yaml#/definitions/uint32"
minimum: 0
maximum: 1
default: 0
pgb_shutdown_all:
description: |
If any LDO PGB event occurred, to disable all LDOs or not.
$ref: "/schemas/types.yaml#/definitions/uint32"
minimum: 0
maximum: 1
default: 0
unevaluatedProperties: false
"^LDO[1-8]$":
type: object
$ref: "regulator.yaml#"
properties:
oc_ptsel:
description: Specify OC protect behavior.
$ref: "/schemas/types.yaml#/definitions/uint32"
minimum: 0
maximum: 1
default: 1
pgb_ptsel:
description: Specify PGB protect behavior.
$ref: "/schemas/types.yaml#/definitions/uint32"
minimum: 0
maximum: 1
default: 1
soft_start_time_sel:
description: Specify soft start time selection.
$ref: "/schemas/types.yaml#/definitions/uint32"
minimum: 0
maximum: 3
default: 1
unevaluatedProperties: false
additionalProperties: false
additionalProperties: false
examples:
- |
#include <dt-bindings/interrupt-controller/irq.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
rt5133@18 {
compatible = "mediatek,rt5133-regulator";
reg = <0x18>;
wakeup-source;
interrupts-extend = <&gpio26 2 IRQ_TYPE_LEVEL_LOW>;
enable-gpio = <&gpio26 3 0>;
gpio-supply = <&ldo1>;
gpio-controller;
#gpio-cells = <2>;
regulators {
BASE {
regulator-name = "rt5133,base";
oc_shutdown_all = <0>;
pgb_shutdown_all = <0>;
};
ldo1: LDO1 {
regulator-name = "rt5133,ldo1";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3200000>;
oc_ptsel = <1>;
pgb_ptsel = <1>;
soft_start_time_sel = <1>;
};
LDO2 {
regulator-name = "rt5133,ldo2";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3200000>;
oc_ptsel = <1>;
pgb_ptsel = <1>;
soft_start_time_sel = <1>;
};
LDO3 {
regulator-name = "rt5133,ldo3";
regulator-min-microvolt = <1700000>;
regulator-max-microvolt = <3000000>;
oc_ptsel = <1>;
pgb_ptsel = <1>;
soft_start_time_sel = <1>;
};
LDO4 {
regulator-name = "rt5133,ldo4";
regulator-min-microvolt = <1700000>;
regulator-max-microvolt = <3000000>;
oc_ptsel = <1>;
pgb_ptsel = <1>;
soft_start_time_sel = <1>;
};
LDO5 {
regulator-name = "rt5133,ldo5";
regulator-min-microvolt = <1700000>;
regulator-max-microvolt = <3000000>;
oc_ptsel = <1>;
pgb_ptsel = <1>;
soft_start_time_sel = <1>;
};
LDO6 {
regulator-name = "rt5133,ldo6";
regulator-min-microvolt = <1700000>;
regulator-max-microvolt = <3000000>;
oc_ptsel = <1>;
pgb_ptsel = <1>;
soft_start_time_sel = <1>;
};
LDO7 {
regulator-name = "rt5133,ldo7";
regulator-min-microvolt = <900000>;
regulator-max-microvolt = <1800000>;
oc_ptsel = <1>;
pgb_ptsel = <1>;
soft_start_time_sel = <1>;
};
LDO8 {
regulator-name = "rt5133,ldo8";
regulator-min-microvolt = <900000>;
regulator-max-microvolt = <1800000>;
oc_ptsel = <1>;
pgb_ptsel = <1>;
soft_start_time_sel = <1>;
};
};
};
};
...

View File

@@ -3,8 +3,11 @@ found in Mediatek SoC family
Required properties:
- compatible : Should be
"mediatek,mt7622-rng", "mediatek,mt7623-rng" : for MT7622
"mediatek,mt7623-rng" : for MT7623
"mediatek,mt7622-rng", "mediatek,mt7623-rng" for MT7622
"mediatek,mt7623-rng" for MT7623
"mediatek,mt67xx-rng" for MT67xx ARMv8 SoCs
Optional properties:
- clocks : list of clock specifiers, corresponding to
entries in clock-names property;
- clock-names : Should contain "rng" entries;
@@ -18,3 +21,7 @@ rng: rng@1020f000 {
clocks = <&infracfg CLK_INFRA_TRNG>;
clock-names = "rng";
};
hwrng: hwrng {
compatible = "mediatek,mt67xx-rng";
};

View File

@@ -19,6 +19,11 @@ IP Pairing
Required properties in pwrap device node.
- compatible:
"mediatek,mt2701-pwrap" for MT2701/7623 SoCs
"mediatek,mt6739-pwrap" for MT6739 SoCs
"mediatek,mt6765-pwrap" for MT6765 SoCs
"mediatek,mt6768-pwrap" for MT6768 SoCs
"mediatek,mt6771-pwrap" for MT6771 SoCs
"mediatek,mt6785-pwrap" for MT6785 SoCs
"mediatek,mt8135-pwrap" for MT8135 SoCs
"mediatek,mt8173-pwrap" for MT8173 SoCs
- interrupts: IRQ for pwrap in SOC

View File

@@ -0,0 +1,46 @@
MediaTek Power Management Interface (PMIF) Driver
This document describes the binding for the MediaTek PMIF.
The PMIF is designed on MediaTek's SoC. It implements arbitration logic
to allow for multiple HW/SW channel to control PMIC by a single SPMI master.
See spmi.txt for the generic SPMI controller binding requirements for child
nodes.
See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt for
generic interrupt controller binding documentation.
Required properties:
- compatible:
"mediatek,mt6789-pmif" for MT6789 SoCs
- reg : address + size pairs describing the pmif/pmifmpu/spmimst register
sets. Must contain an entry for each entry in reg-names.
- reg-names: must contain:
"pmif" - power management interface registers
"pmifmpu" - pmif memory protection unit registers
"spmimst" - spmi master registers
- interrupts: IRQ for pmif in SOC
- interrupt-names: IRQ name for pmif in SOC
- swinf_ch_start: indicate the physical channel for pmif driver accessing
- ap_swinf_no: indicate the logical channel for ap sw interface number,
0: for MD interface
2: for AP interface
- interrupt-controller: indicator that the pmif is an interrupt controller
Optional properities:
Example:
spmi_bus: spmi@10027000 {
compatible = "mediatek,mt6789-pmif";
reg = <0 0x10027000 0 0x000E00>,
<0 0x10027F00 0 0x00008C>,
<0 0x10029000 0 0x000100>;
reg-names = "pmif", "pmifmpu", "spmimst";
interrupts = <GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "pmif_irq";
swinf_ch_start = <4>;
ap_swinf_no = <2>;
interrupt-controller;
};

View File

@@ -0,0 +1,12 @@
Kernel driver access_ramoops
============================
Author: Patrick Tjin <pattjin@google.com>
Description
-----------
The access_ramoops driver allows userspace access to the persistent RAM storage
used for oops and panics as well as the metadata required to decrypt that data.

View File

@@ -915,12 +915,14 @@ icmp_ratelimit - INTEGER
icmp_msgs_per_sec - INTEGER
Limit maximal number of ICMP packets sent per second from this host.
Only messages whose type matches icmp_ratemask (see below) are
controlled by this limit.
controlled by this limit. For security reasons, the precise count
of messages per second is randomized.
Default: 1000
icmp_msgs_burst - INTEGER
icmp_msgs_per_sec controls number of ICMP packets sent per second,
while icmp_msgs_burst controls the burst size of these packets.
For security reasons, the precise burst size is randomized.
Default: 50
icmp_ratemask - INTEGER

View File

@@ -84,15 +84,20 @@ Get a decent editor and don't leave whitespace at the end of lines.
Coding style is all about readability and maintainability using commonly
available tools.
The limit on the length of lines is 80 columns and this is a strongly
preferred limit.
The preferred limit on the length of a single line is 80 columns.
Statements longer than 80 columns will be broken into sensible chunks, unless
exceeding 80 columns significantly increases readability and does not hide
information. Descendants are always substantially shorter than the parent and
are placed substantially to the right. The same applies to function headers
with a long argument list. However, never break user-visible strings such as
printk messages, because that breaks the ability to grep for them.
Statements longer than 80 columns should be broken into sensible chunks,
unless exceeding 80 columns significantly increases readability and does
not hide information.
Descendants are always substantially shorter than the parent and are
are placed substantially to the right. A very commonly used style
is to align descendants to a function open parenthesis.
These same rules are applied to function headers with a long argument list.
However, never break user-visible strings such as printk messages because
that breaks the ability to grep for them.
3) Placing Braces and Spaces

View File

@@ -5,6 +5,12 @@
#
mainmenu "Linux/$ARCH $KERNELVERSION Kernel Configuration"
config OPLUS_FEATURE_PANIC_FLUSH
bool "fsync optimization "
default y
help
define this config to fsync optimization
config SRCARCH
string
option env="SRCARCH"

50
Makefile Normal file → Executable file
View File

@@ -235,6 +235,11 @@ ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
endif
endif
#ifdef OPLUS_ARCH_INJECT
#Sunliang@ANDROID.BUILD, 2020/04/08, export global native features to kernel
-include OplusKernelEnvConfig.mk
#endif /* OPLUS_ARCH_INJECT */
ifeq ($(KBUILD_EXTMOD),)
ifneq ($(filter config %config,$(MAKECMDGOALS)),)
config-targets := 1
@@ -412,6 +417,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)
@@ -430,6 +436,29 @@ KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
GCC_PLUGINS_CFLAGS :=
CLANG_FLAGS :=
#ifdef OPLUS_FEATURE_CHG_BASIC
ifeq ($(OPPO_HIGH_TEMP_VERSION),true)
KBUILD_CFLAGS += -DCONFIG_HIGH_TEMP_VERSION
endif
#endif /* OPLUS_FEATURE_CHG_BASIC */
#ifdef OPLUS_FEATURE_MEMLEAK_DETECT
ifeq ($(AGING_DEBUG_MASK),1)
# enable memleak detect daemon
OPLUS_MEMLEAK_DETECT := true
endif
ifeq ($(TARGET_MEMLEAK_DETECT_TEST),0)
# disable memleak detect daemon
OPLUS_MEMLEAK_DETECT := false
else ifeq ($(TARGET_MEMLEAK_DETECT_TEST),1)
# enable memleak detect daemon
OPLUS_MEMLEAK_DETECT := true
endif
export OPLUS_MEMLEAK_DETECT
#endif
export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
export CPP AR NM STRIP OBJCOPY OBJDUMP HOSTLDFLAGS HOST_LOADLIBES
export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE
@@ -504,6 +533,11 @@ endif
KBUILD_CPPFLAGS += -Qunused-arguments
endif
KBUILD_CFLAGS += -DOPLUS_FEATURE_CHG_BASIC
KBUILD_CPPFLAGS += -DOPLUS_FEATURE_CHG_BASIC
CFLAGS_KERNEL += -DOPLUS_FEATURE_CHG_BASIC
CFLAGS_MODULE += -DOPLUS_FEATURE_CHG_BASIC
RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register
RETPOLINE_VDSO_CFLAGS_GCC := -mindirect-branch=thunk-inline -mindirect-branch-register
RETPOLINE_CFLAGS_CLANG := -mretpoline-external-thunk
@@ -569,6 +603,12 @@ endif
export KBUILD_MODULES KBUILD_BUILTIN
-include OplusKernelEnvConfig.mk
KBUILD_CFLAGS += -DOPLUS_FEATURE_SENSOR
KBUILD_CFLAGS += -DOPLUS_FEATURE_SENSOR_ALGORITHM
KBUILD_CFLAGS += -DOPLUS_FEATURE_SENSOR_SMEM
KBUILD_CFLAGS += -DOPLUS_FEATURE_SENSOR_WISELIGHT
ifeq ($(KBUILD_EXTMOD),)
# Additional helpers built in scripts/
# Carefully list dependencies so we do not try to build scripts twice
@@ -1170,6 +1210,12 @@ include/config/kernel.release: include/config/auto.conf FORCE
$(call filechk,kernel.release)
KBUILD_CFLAGS += -DOPLUS_FEATURE_SENSOR
KBUILD_CFLAGS += -DOPLUS_FEATURE_SENSOR_ALGORITHM
KBUILD_CFLAGS += -DOPLUS_FEATURE_SENSOR_SMEM
KBUILD_CFLAGS += -DOPLUS_FEATURE_SENSOR_WISELIGHT
# Things we need to do before we recursively start building the kernel
# or the modules are listed in "prepare".
# A multi level approach is used. prepareN is processed before prepareN-1.
@@ -1411,7 +1457,9 @@ modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
$(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
@$(kecho) ' Building modules, stage 2.';
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
ifeq ($(CONFIG_MODULE_SIG), y)
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modsign
endif
modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
$(Q)$(AWK) '!x[$$0]++' $^ > $(objtree)/modules.builtin

183
OplusKernelEnvConfig.mk Executable file
View File

@@ -0,0 +1,183 @@
# Copyright (C), 2008-2030, OPPO Mobile Comm Corp., Ltd
### All rights reserved.
###
### File: - OplusKernelEnvConfig.mk
### Description:
### you can get the oplus feature variables set in android side in this file
### this file will add global macro for common oplus added feature
### BSP team can do customzation by referring the feature variables
### Version: 1.0
### Date: 2020-03-18
### Author: Liang.Sun
###
### ------------------------------- Revision History: ----------------------------
### <author> <date> <version> <desc>
### ------------------------------------------------------------------------------
### Liang.Sun@TECH.Build 2020-03-18 1.0 Create this moudle
##################################################################################
-include nativefeatures.mk
###ifdef OPLUS_ARCH_INJECT
OPLUS_CONNECTIVITY_NATIVE_FEATURE_SET :=
##Add OPLUS Debug/Feature Macro Support for kernel/driver
##ifeq ($(OPLUS_FEATURE_TEST), yes)
## OPLUS_CONNECTIVITY_NATIVE_FEATURE_SET += OPLUS_FEATURE_TEST
##endif
ifeq ($(OPLUS_FEATURE_WIFI_MTUDETECT), yes)
OPLUS_CONNECTIVITY_NATIVE_FEATURE_SET += OPLUS_FEATURE_WIFI_MTUDETECT
endif
$(foreach myfeature,$(OPLUS_CONNECTIVITY_NATIVE_FEATURE_SET),\
$( \
$(eval KBUILD_CFLAGS += -D$(myfeature)) \
$(eval KBUILD_CPPFLAGS += -D$(myfeature)) \
$(eval CFLAGS_KERNEL += -D$(myfeature)) \
$(eval CFLAGS_MODULE += -D$(myfeature)) \
) \
)
###endif OPLUS_ARCH_INJECT
ALLOWED_MCROS := OPLUS_FEATURE_HANS_FREEZE \
OPLUS_FEATURE_AOD \
OPLUS_FEATURE_DC \
OPLUS_FEATURE_ENABLE_MODEM_DB \
OPLUS_FEATURE_ENGINEERTOOLS \
OPLUS_FEATURE_HEALTHINFO \
OPLUS_FEATURE_TASK_CPUSTATS \
OPLUS_FEATURE_FACERECOGNITION \
OPLUS_FEATURE_FASTBOOT_UNLOCK_VERIFY \
OPLUS_FEATURE_FG_IO_OPT \
OPLUS_FEATURE_SCHED_ASSIST \
OPLUS_FEATURE_SDCARD_INFO \
OPLUS_FEATURE_FINGERPRINT \
OPLUS_FEATURE_SPECIALOPT \
OPLUS_FEATURE_UFSPLUS \
OPLUS_FEATURE_STORAGE_TOOL \
OPLUS_FEATURE_MIPICLKCHANGE \
OPLUS_FEATURE_MULTI_FREEAREA \
OPLUS_FEATURE_MULTI_KSWAPD \
OPLUS_FEATURE_NFC_CONSOFT \
OPLUS_FEATURE_ONSCREENFINGERPRINT \
OPLUS_FEATURE_OSC \
OPLUS_FEATURE_PHOENIX \
OPLUS_FEATURE_AGINGTEST \
OPLUS_FEATURE_PROCESS_RECLAIM \
OPLUS_FEATURE_RESET_ROLLBACK_INDEX \
OPLUS_FEATURE_SELINUX_CONTROL_LOG \
OPLUS_FEATURE_SENSOR \
OPLUS_FEATURE_SENSOR_ALGORITHM \
OPLUS_FEATURE_SENSOR_SMEM \
OPLUS_FEATURE_SENSOR_WISELIGHT \
OPLUS_FEATURE_IOMONITOR \
OPLUS_FEATURE_SPEAKER_MUTE \
OPLUS_FEATURE_MM_FEEDBACK \
OPLUS_FEATURE_TP_BSPFWUPDATE \
OPLUS_FEATURE_CHG_BASIC \
OPLUS_FEATURE_VIRTUAL_RESERVE_MEMORY \
OPLUS_FEATURE_MEMLEAK_DETECT \
OPLUS_FEATURE_WIFI_MTUDETECT \
OPLUS_FEATURE_WIFI_RUSUPGRADE \
OPLUS_FEATURE_WIFI_SLA \
OPLUS_FEATURE_DATA_EVAL \
OPLUS_FEATURE_WIFI_SMART_BW \
OPLUS_FEATURE_IPV6_OPTIMIZE \
OPLUS_FEATURE_ZRAM_OPT \
OPLUS_FEATURE_EXFAT_SUPPORT \
OPLUS_FEATURE_SDCARDFS_SUPPORT \
OPLUS_FEATURE_STORAGE_TOOL \
OPLUS_BUG_COMPATIBILITY \
OPLUS_FEATURE_MIDAS \
OPLUS_BUG_STABILITY \
OPLUS_BUG_DEBUG \
OPLUS_ARCH_INJECT \
OPLUS_ARCH_EXTENDS \
OPLUS_FEATURE_LOWMEM_DBG \
OPLUS_FEATURE_PERFORMANCE \
OPLUS_FEATURE_MTK_ION_SEPARATE_LOCK \
OPLUS_FEATURE_ALARMINFO_STANDBY \
OPLUS_FEATURE_POWERINFO_STANDBY \
OPLUS_FEATURE_POWERINFO_STANDBY_DEBUG \
OPLUS_FEATURE_POWERINFO_RPMH \
OPLUS_FEATURE_POWERINFO_FTM \
OPLUS_FEATURE_SCHEDUTIL_USE_TL \
OPLUS_FEATURE_CORE_CTL \
OPLUS_FEATURE_STORAGE_TOOL \
OPLUS_FEATURE_CAMERA_COMMON \
OPLUS_FEATURE_WIFI_OPLUSWFD
$(foreach myfeature,$(ALLOWED_MCROS),\
$(warning myfeature is $(myfeature)) \
$(eval KBUILD_CFLAGS += -D$(myfeature)) \
$(eval KBUILD_CPPFLAGS += -D$(myfeature)) \
$(eval CFLAGS_KERNEL += -D$(myfeature)) \
$(eval CFLAGS_MODULE += -D$(myfeature)) \
)
# BSP team can do customzation by referring the feature variables
ifeq ($(OPLUS_FEATURE_SECURE_GUARD),yes)
export CONFIG_OPLUS_SECURE_GUARD=y
KBUILD_CFLAGS += -DCONFIG_OPLUS_SECURE_GUARD
KBUILD_CPPFLAGS += -DCONFIG_OPLUS_SECURE_GUARD
CFLAGS_KERNEL += -DCONFIG_OPLUS_SECURE_GUARD
CFLAGS_MODULE += -DCONFIG_OPLUS_SECURE_GUARD
endif
ifeq ($(OPLUS_FEATURE_SECURE_ROOTGUARD),yes)
export CONFIG_OPLUS_ROOT_CHECK=y
KBUILD_CFLAGS += -DCONFIG_OPLUS_ROOT_CHECK
KBUILD_CPPFLAGS += -DCONFIG_OPLUS_ROOT_CHECK
CFLAGS_KERNEL += -DCONFIG_OPLUS_ROOT_CHECK
CFLAGS_MODULE += -DCONFIG_OPLUS_ROOT_CHECK
endif
ifeq ($(OPLUS_FEATURE_SECURE_MOUNTGUARD),yes)
export CONFIG_OPLUS_MOUNT_BLOCK=y
KBUILD_CFLAGS += -DCONFIG_OPLUS_MOUNT_BLOCK
endif
ifeq ($(OPLUS_FEATURE_SECURE_EXECGUARD),yes)
export CONFIG_OPLUS_EXECVE_BLOCK=y
KBUILD_CFLAGS += -DCONFIG_OPLUS_EXECVE_BLOCK
KBUILD_CFLAGS += -DCONFIG_OPLUS_EXECVE_REPORT
endif
ifeq ($(OPLUS_FEATURE_SECURE_KEVENTUPLOAD),yes)
export CONFIG_OPLUS_KEVENT_UPLOAD=y
KBUILD_CFLAGS += -DCONFIG_OPLUS_KEVENT_UPLOAD
KBUILD_CPPFLAGS += -DCONFIG_OPLUS_KEVENT_UPLOAD
CFLAGS_KERNEL += -DCONFIG_OPLUS_KEVENT_UPLOAD
CFLAGS_MODULE += -DCONFIG_OPLUS_KEVENT_UPLOAD
endif
ifeq ($(OPLUS_FEATURE_PREFER_SILVER),yes)
export CONFIG_OPLUS_PREFER_SILVER=y
KBUILD_CFLAGS += -DCONFIG_OPLUS_PREFER_SILVER
KBUILD_CPPFLAGS += -DCONFIG_OPLUS_PREFER_SILVER
CFLAGS_KERNEL += -DCONFIG_OPLUS_PREFER_SILVER
CFLAGS_MODULE += -DCONFIG_OPLUS_PREFER_SILVER
endif
ifeq ($(OPLUS_FEATURE_SECURE_KEYINTERFACESGUARD),yes)
KBUILD_CFLAGS += -DOPLUS_DISALLOW_KEY_INTERFACES
endif
#Zhijun.Ye@MM.Display.LCD.Machine, 2020/09/23, add for multibits backlight
ifeq ($(OPLUS_FEATURE_MULTIBITS_BL),yes)
KBUILD_CFLAGS += -DOPLUS_FEATURE_MULTIBITS_BL
KBUILD_CPPFLAGS += -DOPLUS_FEATURE_MULTIBITS_BL
CFLAGS_KERNEL += -DOPLUS_FEATURE_MULTIBITS_BL
CFLAGS_MODULE += -DOPLUS_FEATURE_MULTIBITS_BL
endif
ifeq ($(OPLUS_FEATURE_DFPS3_SUPPORT),yes)
KBUILD_CFLAGS += -DOPLUS_FEATURE_DFPS3_SUPPORT
KBUILD_CPPFLAGS += -DOPLUS_FEATURE_DFPS3_SUPPORT
CFLAGS_KERNEL += -DOPLUS_FEATURE_DFPS3_SUPPORT
CFLAGS_MODULE += -DOPLUS_FEATURE_DFPS3_SUPPORT
endif

12
build.config.mtk.aarch64 Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

9
build.config.mtk.arm Normal file
View File

@@ -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

64
certs/ko_test_prvk.pem Normal file
View File

@@ -0,0 +1,64 @@
-----BEGIN PRIVATE KEY-----
MIIG/wIBADANBgkqhkiG9w0BAQEFAASCBukwggblAgEAAoIBgQDNdeWYsCHdWS88
APb9Kwg9hyFjBqH5mUFMV4WOUvvN9kvzcrRk0iuBmxpi/IHX83EYoyMk4iV/suDN
Dxop+kwSnCxuKQZ0zsFbof/hFXePbEfxuRhScNYcVWIHVR8QCzRlpv9IfF4VgyS4
nYYhRwYp3mtntVzvE1+YUpVWW9mh+1xKgVD/NIijHi8gNhSrpeKMTEgvP3crT9e+
glR8g2XAoWWdYUKshPufwfwMSw60WYBZS7dbbclJSA/n2mlJUWOjDrnSTXSAzjw0
4MsZ0s0ayJ3CnZyWP5QWkyEl8/+qVthc1/Gg3bViSrf1x47+LCHJq5PSyPNSilbP
jgciEJo5DAZwrikIZrz4bZybrNvWeF3OguHcM9SsrcdDtwKqKxz0G8uTRKUXx2rK
BFCfcErHKGNKfj5pW5b2X8Eo+9f55OBebzXBkrC+rHBcP04mAMMZuE8q3kF9eAEa
NANjS1IcM5EI1JVNPyjSdK6H1FD/o5N0CbfHhF/Lu7bYEY/hHjkCAwEAAQKCAYBH
1graoeqVO9N6BVRWHC+bY53Ww8DqRh1AlfFKW9VSo+TWT6qm/ZzcieBl76duW92V
IaTuBmvaBC75Q2iAeNUURKp8MbfiK1ALu859YkYVTWSyLWdFm9IgwfGuYqKjt2cw
i30CWQmEOAAk1F7LT8vl47Bl6FF//aQU2/r+4MptCjewjRpGwJVtguYzOvVrNmrJ
ZvpuGqCN8jKal3L2vfJbsZKXviPTsgNQTkDUA4I2qHxpvEF1pCMWji2RgRoC2oN8
6HbalYJ9h8CJeKXJG7ocChNhwkHdbUsBK5chti2hw2M7RXf1lA0OT/BYwJ5YJun0
47ImYP/bSRZEiMb+V1mINZ+Asqk0+qPiwJJfm5lOE5zN1zW1J1fXdo/zq3qVITcM
oh+M6HInzJtCR6kw8TpaziKwPwnFxCGvSa+M/riwQ6C0DrCCPc+Yr/HMPbMvOt9q
RRbHmr/rl6pWSDFhFn9JhMCUe7UDRl6nZRWVEth9wkF/bH1dqY7z7SFEoLJJ2KEC
gcEA9/WWCmtzqYHMdFZ5khy8aXyVJLxrlPFE0iWjXpCncyquq9GhhDxzM2kPpkax
F8KZAFbwTKRl1BOzQDO76c42nPb7FXggpZkLVnAGt93lYgSKhkqMmdXSDoLANT2P
z4j3cRfo8rrUErpUZzZuxH1YQgx5yZau0VwuQattn4m1D8YwH5nmYeyHPESwUp8k
/Z0/LOZ4o4IAJYMJ5DTYU91Ad5kDP6f6FCkNWzV7wgmk99nHtLVpee8t6XI/4SNn
UKRtAoHBANQfgrXkOckKRiIVMoTP1klwJhGJ1DZWrxjqnd+M0rsJsle0yWhxxQFx
tF5rLjKA1p0/vDD/aeVqfRCUxkIK16B4nUMCnoth9jbu7/VN75ORZkURv9DS0NNS
KL/UEyVmavt1+UuQBC+KrHDwHquHi6sRFKsu6AvaxTInKtFY3k5gMQUUZ4R9z1gX
DxzHyKoHyMced7aw7G5UCr2TppDfX47LjdbNFu7ddwkuYmi+p9Kqz/8T/WRokPFe
V+iV6P0JfQKBwQC4hm+BE5PAalK/pPbVsELacZb//qRE9AOWK+JW5mlmwDW6scd0
BBRrBt1ZjTQPDYcVBJ3RO2p4F60Gszk9dnOX/gi+YmZRNgKE8dteC2i/t8dqxqG5
fbDTkaP+OvEBrdkOtY9qy3Q096sGIDDwUqNSi7w6M8OnE+Vsg2mSF0XCFmgLrFkR
OJcvV6Kr6bj6b4HrJRxT+dOoFstOo7D1QCrQlfMf9R6a0C4bWULfFJRKyivfJD35
OvA80QQOxG0HS0UCgcEAsiTwgk90VCmDstX4gl+FyFEeN3Z4OVZdYOCQy5CZ3aiM
FWpoB4YcfFUAtJbwyks3cgJ3yvKF/byL4eQACLDQXB1PfVpyyf3waDwMXAgi3tyq
dfEtFXQnGoISZN/3YF5+FEcEoXgGe+LLZWHTcBy6qGUE5arUCDinibIpHH203T+d
i3WSZku+WW2sLHCAToORE+C7iztUpGeCSan5pgtiVisPKMk+rEZj1NsWnH8ZtCvt
2HvyP2Qt7fdcfqF/dRqFAoHBANV2l0oLf9lFQFPQMMkLEaPUJ6lslRht+lRTcmYN
eHDP0SEqV8kWhf+wCc9T185NGSxLH4eh7pZA2aoVwI0/t1oNlyieMt6tOp6+QHjL
taWQYXVLidvGBe42FQcRTSn/y7J6HpAdRTLCicbsDVPlKb1z3G/PD6dI91TuSfUz
/f3dmLUKDmbnDAQG9KLVUEh8qZhhzqslGBtYs8kmT3GII09/0dGVFN6Oam7R29sN
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-----

View File

@@ -649,11 +649,73 @@ 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.
#ifdef OPLUS_FEATURE_SCHED_ASSIST
source "kernel/sched_assist/Kconfig"
#endif
endmenu
menu "FAIR Scheuler tunables"
choice
prompt "Utilization's PELT half-Life"
default PELT_UTIL_HALFLIFE_32
default PELT_UTIL_HALFLIFE_8
help
Allows choosing one of the possible values for the PELT half-life to
be used for the update of the utilization of tasks and CPUs.
@@ -852,6 +914,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 +1416,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
@@ -1788,7 +1872,7 @@ config HAVE_GENERIC_DMA_COHERENT
config SLABINFO
bool
depends on PROC_FS
depends on SLAB || SLUB_DEBUG
depends on SLAB || SLUB_DEBUG || KMALLOC_DEBUG
default y
config RT_MUTEXES

8
init/Makefile Normal file → Executable file
View File

@@ -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

0
init/do_mounts.c Normal file → Executable file
View File

0
init/do_mounts.h Normal file → Executable file
View File

0
init/do_mounts_dm.c Normal file → Executable file
View File

View File

@@ -95,6 +95,15 @@
#include <asm/sections.h>
#include <asm/cacheflush.h>
#ifdef CONFIG_MTK_RAM_CONSOLE
#include <mt-plat/mtk_ram_console.h>
#endif
#ifdef OPLUS_FEATURE_PHOENIX
// Kun.Hu@TECH.BSP.Stability.PHOENIX_PROJECT 2019/06/11, Add for phoenix project
#include "../drivers/soc/oplus/system/oplus_phoenix/oplus_phoenix.h"
#endif
static int kernel_init(void *);
extern void init_IRQ(void);
@@ -594,6 +603,10 @@ asmlinkage __visible void __init start_kernel(void)
sort_main_extable();
trap_init();
mm_init();
#ifdef OPLUS_FEATURE_PHOENIX
if(phx_set_boot_stage)
phx_set_boot_stage(KERNEL_MM_INIT_DONE);
#endif
ftrace_init();
@@ -647,6 +660,12 @@ asmlinkage __visible void __init start_kernel(void)
WARN(!irqs_disabled(), "Interrupts were enabled early\n");
early_boot_irqs_disabled = false;
local_irq_enable();
#ifdef OPLUS_FEATURE_PHOENIX
// Kun.Hu@TECH.BSP.Stability.PHOENIX_PROJECT 2019/06/11, Add for phoenix project
if(phx_set_boot_stage) {
phx_set_boot_stage(KERNEL_LOCAL_IRQ_ENABLE);
}
#endif
kmem_cache_init_late();
@@ -717,6 +736,11 @@ asmlinkage __visible void __init start_kernel(void)
cgroup_init();
taskstats_init_early();
delayacct_init();
#ifdef OPLUS_FEATURE_PHOENIX
if(phx_set_boot_stage) {
phx_set_boot_stage(KERNEL_DELAYACCT_INIT_DONE);
}
#endif
check_bugs();
@@ -834,21 +858,34 @@ static int __init_or_module do_one_initcall_debug(initcall_t fn)
return ret;
}
#ifdef CONFIG_MTPROF
#include <bootprof.h>
#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 +899,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 +960,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
}
/*
@@ -936,10 +977,21 @@ static void __init do_basic_setup(void)
cpuset_init_smp();
shmem_init();
driver_init();
#ifdef OPLUS_FEATURE_PHOENIX
// Kun.Hu@TECH.BSP.Stability.PHOENIX_PROJECT 2019/06/11, Add for phoenix project
if(phx_set_boot_stage) {
phx_set_boot_stage(KERNEL_DRIVER_INIT_DONE);
}
#endif
init_irq_proc();
do_ctors();
usermodehelper_enable();
do_initcalls();
#ifdef OPLUS_FEATURE_PHOENIX
// Kun.Hu@TECH.BSP.Stability.PHOENIX_PROJECT 2019/06/11, Add for phoenix project
if(phx_set_boot_stage)
phx_set_boot_stage(KERNEL_DO_INITCALLS_DONE);
#endif
}
static void __init do_pre_smp_initcalls(void)
@@ -1032,6 +1084,16 @@ static int __ref kernel_init(void *unused)
rcu_end_inkernel_boot();
#ifdef OPLUS_FEATURE_PHOENIX
// Kun.Hu@TECH.BSP.Stability.PHOENIX_PROJECT 2019/06/11, Add for phoenix project
if(phx_set_boot_stage) {
phx_set_boot_stage(KERNEL_INIT_DONE);
}
#endif
#ifdef CONFIG_MTPROF
log_boot("Kernel_init_done");
#endif
if (ramdisk_execute_command) {
ret = run_init_process(ramdisk_execute_command);
if (!ret)
@@ -1098,6 +1160,12 @@ static noinline void __init kernel_init_freeable(void)
do_basic_setup();
#ifdef OPLUS_FEATURE_PHOENIX
// Kun.Hu@TECH.BSP.Stability.PHOENIX_PROJECT 2019/06/11, Add for phoenix project
if(phx_set_boot_stage) {
phx_set_boot_stage(KERNEL_DO_BASIC_SETUP_DONE);
}
#endif
/* Open the /dev/console on the rootfs, this should never fail */
if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
pr_err("Warning: unable to open an initial console.\n");

141
kenv.mk Normal file
View File

@@ -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

View File

@@ -263,7 +263,7 @@ config UNUSED_SYMBOLS
config PAGE_OWNER
bool "Track page owner"
depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
depends on DEBUG_KERNEL && STACKTRACE_SUPPORT && !MTK_GMO_RAM_OPTIMIZE
select DEBUG_FS
select STACKTRACE
select STACKDEPOT
@@ -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.

View File

@@ -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

View File

@@ -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.

View File

@@ -264,6 +264,10 @@ UBSAN_SANITIZE_ubsan.o := n
KASAN_SANITIZE_ubsan.o := n
CFLAGS_ubsan.o := $(call cc-option, -fno-stack-protector) $(DISABLE_STACKLEAK_PLUGIN)
# ifdef OPLUS_FEATURE_MEMLEAK_DETECT
obj-$(CONFIG_VMALLOC_DEBUG) += memleak_debug_stackdepot.o
# endif
obj-$(CONFIG_SBITMAP) += sbitmap.o
obj-$(CONFIG_PARMAN) += parman.o

View File

@@ -14,6 +14,11 @@
#include <linux/spinlock.h>
#include <linux/debug_locks.h>
#ifdef CONFIG_LOCKDEP
#include <linux/sched/clock.h>
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;

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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;

2
lib/iov_iter.c Normal file → Executable file
View File

@@ -393,6 +393,7 @@ static size_t copy_page_to_iter_pipe(struct page *page, size_t offset, size_t by
return 0;
pipe->nrbufs++;
buf->ops = &page_cache_pipe_buf_ops;
buf->flags = 0;
get_page(buf->page = page);
buf->offset = offset;
buf->len = bytes;
@@ -517,6 +518,7 @@ static size_t push_pipe(struct iov_iter *i, size_t size,
break;
pipe->nrbufs++;
pipe->bufs[idx].ops = &default_pipe_buf_ops;
pipe->bufs[idx].flags = 0;
pipe->bufs[idx].page = page;
pipe->bufs[idx].offset = 0;
if (left <= PAGE_SIZE) {

View File

@@ -43,30 +43,36 @@
/*-*****************************
* Decompression functions
*******************************/
/* LZ4_decompress_generic() :
* This generic decompression function cover all use cases.
* It shall be instantiated several times, using different sets of directives
* Note that it is important this generic function is really inlined,
#define DEBUGLOG(l, ...) {} /* disabled */
#ifndef assert
#define assert(condition) ((void)0)
#endif
/*
* LZ4_decompress_generic() :
* This generic decompression function covers all use cases.
* It shall be instantiated several times, using different sets of directives.
* Note that it is important for performance that this function really get inlined,
* in order to remove useless branches during compilation optimization.
*/
static FORCE_INLINE int LZ4_decompress_generic(
const char * const source,
char * const dest,
int inputSize,
const char * const src,
char * const dst,
int srcSize,
/*
* If endOnInput == endOnInputSize,
* this value is the max size of Output Buffer.
* this value is `dstCapacity`
*/
int outputSize,
/* endOnOutputSize, endOnInputSize */
int endOnInput,
endCondition_directive endOnInput,
/* full, partial */
int partialDecoding,
/* only used if partialDecoding == partial */
int targetOutputSize,
earlyEnd_directive partialDecoding,
/* noDict, withPrefix64k, usingExtDict */
int dict,
/* == dest when no prefix */
dict_directive dict,
/* always <= dst, == dst when no prefix */
const BYTE * const lowPrefix,
/* only if dict == usingExtDict */
const BYTE * const dictStart,
@@ -74,35 +80,43 @@ static FORCE_INLINE int LZ4_decompress_generic(
const size_t dictSize
)
{
/* Local Variables */
const BYTE *ip = (const BYTE *) source;
const BYTE * const iend = ip + inputSize;
const BYTE *ip = (const BYTE *) src;
const BYTE * const iend = ip + srcSize;
BYTE *op = (BYTE *) dest;
BYTE *op = (BYTE *) dst;
BYTE * const oend = op + outputSize;
BYTE *cpy;
BYTE *oexit = op + targetOutputSize;
const BYTE * const lowLimit = lowPrefix - dictSize;
const BYTE * const dictEnd = (const BYTE *)dictStart + dictSize;
static const unsigned int dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 };
static const int dec64table[] = { 0, 0, 0, -1, 0, 1, 2, 3 };
static const unsigned int inc32table[8] = {0, 1, 2, 1, 0, 4, 4, 4};
static const int dec64table[8] = {0, 0, 0, -1, -4, 1, 2, 3};
const int safeDecode = (endOnInput == endOnInputSize);
const int checkOffset = ((safeDecode) && (dictSize < (int)(64 * KB)));
/* Set up the "end" pointers for the shortcut. */
const BYTE *const shortiend = iend -
(endOnInput ? 14 : 8) /*maxLL*/ - 2 /*offset*/;
const BYTE *const shortoend = oend -
(endOnInput ? 14 : 8) /*maxLL*/ - 18 /*maxML*/;
DEBUGLOG(5, "%s (srcSize:%i, dstSize:%i)", __func__,
srcSize, outputSize);
/* Special cases */
/* targetOutputSize too high => decode everything */
if ((partialDecoding) && (oexit > oend - MFLIMIT))
oexit = oend - MFLIMIT;
assert(lowPrefix <= op);
assert(src != NULL);
/* Empty output buffer */
if ((endOnInput) && (unlikely(outputSize == 0)))
return ((inputSize == 1) && (*ip == 0)) ? 0 : -1;
return ((srcSize == 1) && (*ip == 0)) ? 0 : -1;
if ((!endOnInput) && (unlikely(outputSize == 0)))
return (*ip == 0 ? 1 : -1);
if ((endOnInput) && unlikely(srcSize == 0))
return -1;
/* Main Loop : decode sequences */
while (1) {
size_t length;
@@ -111,12 +125,74 @@ static FORCE_INLINE int LZ4_decompress_generic(
/* get literal length */
unsigned int const token = *ip++;
length = token>>ML_BITS;
/* ip < iend before the increment */
assert(!endOnInput || ip <= iend);
/*
* A two-stage shortcut for the most common case:
* 1) If the literal length is 0..14, and there is enough
* space, enter the shortcut and copy 16 bytes on behalf
* of the literals (in the fast mode, only 8 bytes can be
* safely copied this way).
* 2) Further if the match length is 4..18, copy 18 bytes
* in a similar manner; but we ensure that there's enough
* space in the output for those 18 bytes earlier, upon
* entering the shortcut (in other words, there is a
* combined check for both stages).
*/
if ((endOnInput ? length != RUN_MASK : length <= 8)
/*
* strictly "less than" on input, to re-enter
* the loop with at least one byte
*/
&& likely((endOnInput ? ip < shortiend : 1) &
(op <= shortoend))) {
/* Copy the literals */
memcpy(op, ip, endOnInput ? 16 : 8);
op += length; ip += length;
/*
* The second stage:
* prepare for match copying, decode full info.
* If it doesn't work out, the info won't be wasted.
*/
length = token & ML_MASK; /* match length */
offset = LZ4_readLE16(ip);
ip += 2;
match = op - offset;
assert(match <= op); /* check overflow */
/* Do not deal with overlapping matches. */
if ((length != ML_MASK) &&
(offset >= 8) &&
(dict == withPrefix64k || match >= lowPrefix)) {
/* Copy the match. */
memcpy(op + 0, match + 0, 8);
memcpy(op + 8, match + 8, 8);
memcpy(op + 16, match + 16, 2);
op += length + MINMATCH;
/* Both stages worked, load the next token. */
continue;
}
/*
* The second stage didn't work out, but the info
* is ready. Propel it right to the point of match
* copying.
*/
goto _copy_match;
}
/* decode literal length */
if (length == RUN_MASK) {
unsigned int s;
if (unlikely(endOnInput ? ip >= iend - RUN_MASK : 0)) {
/* overflow detection */
goto _output_error;
}
do {
s = *ip++;
length += s;
@@ -125,14 +201,14 @@ static FORCE_INLINE int LZ4_decompress_generic(
: 1) & (s == 255));
if ((safeDecode)
&& unlikely(
(size_t)(op + length) < (size_t)(op))) {
&& unlikely((uptrval)(op) +
length < (uptrval)(op))) {
/* overflow detection */
goto _output_error;
}
if ((safeDecode)
&& unlikely(
(size_t)(ip + length) < (size_t)(ip))) {
&& unlikely((uptrval)(ip) +
length < (uptrval)(ip))) {
/* overflow detection */
goto _output_error;
}
@@ -140,16 +216,19 @@ static FORCE_INLINE int LZ4_decompress_generic(
/* copy literals */
cpy = op + length;
if (((endOnInput) && ((cpy > (partialDecoding ? oexit : oend - MFLIMIT))
LZ4_STATIC_ASSERT(MFLIMIT >= WILDCOPYLENGTH);
if (((endOnInput) && ((cpy > oend - MFLIMIT)
|| (ip + length > iend - (2 + 1 + LASTLITERALS))))
|| ((!endOnInput) && (cpy > oend - WILDCOPYLENGTH))) {
if (partialDecoding) {
if (cpy > oend) {
/*
* Error :
* write attempt beyond end of output buffer
* Partial decoding :
* stop in the middle of literal segment
*/
goto _output_error;
cpy = oend;
length = oend - op;
}
if ((endOnInput)
&& (ip + length > iend)) {
@@ -184,29 +263,43 @@ static FORCE_INLINE int LZ4_decompress_generic(
memcpy(op, ip, length);
ip += length;
op += length;
/* Necessarily EOF, due to parsing restrictions */
break;
}
LZ4_wildCopy(op, ip, cpy);
ip += length;
op = cpy;
/* Necessarily EOF, due to parsing restrictions */
if (!partialDecoding || (cpy == oend))
break;
} else {
/* may overwrite up to WILDCOPYLENGTH beyond cpy */
LZ4_wildCopy(op, ip, cpy);
ip += length;
op = cpy;
}
/* get offset */
offset = LZ4_readLE16(ip);
ip += 2;
match = op - offset;
if ((checkOffset) && (unlikely(match < lowLimit))) {
/* get matchlength */
length = token & ML_MASK;
_copy_match:
if ((checkOffset) && (unlikely(match + dictSize < lowPrefix))) {
/* Error : offset outside buffers */
goto _output_error;
}
/* costs ~1%; silence an msan warning when offset == 0 */
LZ4_write32(op, (U32)offset);
/*
* note : when partialDecoding, there is no guarantee that
* at least 4 bytes remain available in output buffer
*/
if (!partialDecoding) {
assert(oend > op);
assert(oend - op >= 4);
LZ4_write32(op, (U32)offset);
}
/* get matchlength */
length = token & ML_MASK;
if (length == ML_MASK) {
unsigned int s;
@@ -221,7 +314,7 @@ static FORCE_INLINE int LZ4_decompress_generic(
if ((safeDecode)
&& unlikely(
(size_t)(op + length) < (size_t)op)) {
(uptrval)(op) + length < (uptrval)op)) {
/* overflow detection */
goto _output_error;
}
@@ -229,24 +322,26 @@ static FORCE_INLINE int LZ4_decompress_generic(
length += MINMATCH;
/* check external dictionary */
/* match starting within external dictionary */
if ((dict == usingExtDict) && (match < lowPrefix)) {
if (unlikely(op + length > oend - LASTLITERALS)) {
/* doesn't respect parsing restriction */
goto _output_error;
if (!partialDecoding)
goto _output_error;
length = min(length, (size_t)(oend - op));
}
if (length <= (size_t)(lowPrefix - match)) {
/*
* match can be copied as a single segment
* from external dictionary
* match fits entirely within external
* dictionary : just copy
*/
memmove(op, dictEnd - (lowPrefix - match),
length);
op += length;
} else {
/*
* match encompass external
* match stretches into both external
* dictionary and current block
*/
size_t const copySize = (size_t)(lowPrefix - match);
@@ -254,7 +349,6 @@ static FORCE_INLINE int LZ4_decompress_generic(
memcpy(op, dictEnd - copySize, copySize);
op += copySize;
if (restSize > (size_t)(op - lowPrefix)) {
/* overlap copy */
BYTE * const endOfMatch = op + restSize;
@@ -267,23 +361,44 @@ static FORCE_INLINE int LZ4_decompress_generic(
op += restSize;
}
}
continue;
}
/* copy match within block */
cpy = op + length;
if (unlikely(offset < 8)) {
const int dec64 = dec64table[offset];
/*
* partialDecoding :
* may not respect endBlock parsing restrictions
*/
assert(op <= oend);
if (partialDecoding &&
(cpy > oend - MATCH_SAFEGUARD_DISTANCE)) {
size_t const mlen = min(length, (size_t)(oend - op));
const BYTE * const matchEnd = match + mlen;
BYTE * const copyEnd = op + mlen;
if (matchEnd > op) {
/* overlap copy */
while (op < copyEnd)
*op++ = *match++;
} else {
memcpy(op, match, mlen);
}
op = copyEnd;
if (op == oend)
break;
continue;
}
if (unlikely(offset < 8)) {
op[0] = match[0];
op[1] = match[1];
op[2] = match[2];
op[3] = match[3];
match += dec32table[offset];
match += inc32table[offset];
memcpy(op + 4, match, 4);
match -= dec64;
match -= dec64table[offset];
} else {
LZ4_copy8(op, match);
match += 8;
@@ -291,7 +406,7 @@ static FORCE_INLINE int LZ4_decompress_generic(
op += 8;
if (unlikely(cpy > oend - 12)) {
if (unlikely(cpy > oend - MATCH_SAFEGUARD_DISTANCE)) {
BYTE * const oCopyLimit = oend - (WILDCOPYLENGTH - 1);
if (cpy > oend - LASTLITERALS) {
@@ -307,60 +422,139 @@ static FORCE_INLINE int LZ4_decompress_generic(
match += oCopyLimit - op;
op = oCopyLimit;
}
while (op < cpy)
*op++ = *match++;
} else {
LZ4_copy8(op, match);
if (length > 16)
LZ4_wildCopy(op + 8, match + 8, cpy);
}
op = cpy; /* correction */
op = cpy; /* wildcopy correction */
}
/* end of decoding */
if (endOnInput) {
/* Nb of output bytes decoded */
return (int) (((char *)op) - dest);
return (int) (((char *)op) - dst);
} else {
/* Nb of input bytes read */
return (int) (((const char *)ip) - source);
return (int) (((const char *)ip) - src);
}
/* Overflow error detected */
_output_error:
return -1;
return (int) (-(((const char *)ip) - src)) - 1;
}
int LZ4_decompress_safe(const char *source, char *dest,
int compressedSize, int maxDecompressedSize)
{
return LZ4_decompress_generic(source, dest, compressedSize,
maxDecompressedSize, endOnInputSize, full, 0,
noDict, (BYTE *)dest, NULL, 0);
return LZ4_decompress_generic(source, dest,
compressedSize, maxDecompressedSize,
endOnInputSize, decode_full_block,
noDict, (BYTE *)dest, NULL, 0);
}
int LZ4_decompress_safe_partial(const char *source, char *dest,
int compressedSize, int targetOutputSize, int maxDecompressedSize)
int LZ4_decompress_safe_partial(const char *src, char *dst,
int compressedSize, int targetOutputSize, int dstCapacity)
{
return LZ4_decompress_generic(source, dest, compressedSize,
maxDecompressedSize, endOnInputSize, partial,
targetOutputSize, noDict, (BYTE *)dest, NULL, 0);
dstCapacity = min(targetOutputSize, dstCapacity);
return LZ4_decompress_generic(src, dst, compressedSize, dstCapacity,
endOnInputSize, partial_decode,
noDict, (BYTE *)dst, NULL, 0);
}
int LZ4_decompress_fast(const char *source, char *dest, int originalSize)
{
return LZ4_decompress_generic(source, dest, 0, originalSize,
endOnOutputSize, full, 0, withPrefix64k,
(BYTE *)(dest - 64 * KB), NULL, 64 * KB);
endOnOutputSize, decode_full_block,
withPrefix64k,
(BYTE *)dest - 64 * KB, NULL, 0);
}
/* ===== Instantiate a few more decoding cases, used more than once. ===== */
int LZ4_decompress_safe_withPrefix64k(const char *source, char *dest,
int compressedSize, int maxOutputSize)
{
return LZ4_decompress_generic(source, dest,
compressedSize, maxOutputSize,
endOnInputSize, decode_full_block,
withPrefix64k,
(BYTE *)dest - 64 * KB, NULL, 0);
}
static int LZ4_decompress_safe_withSmallPrefix(const char *source, char *dest,
int compressedSize,
int maxOutputSize,
size_t prefixSize)
{
return LZ4_decompress_generic(source, dest,
compressedSize, maxOutputSize,
endOnInputSize, decode_full_block,
noDict,
(BYTE *)dest - prefixSize, NULL, 0);
}
int LZ4_decompress_safe_forceExtDict(const char *source, char *dest,
int compressedSize, int maxOutputSize,
const void *dictStart, size_t dictSize)
{
return LZ4_decompress_generic(source, dest,
compressedSize, maxOutputSize,
endOnInputSize, decode_full_block,
usingExtDict, (BYTE *)dest,
(const BYTE *)dictStart, dictSize);
}
static int LZ4_decompress_fast_extDict(const char *source, char *dest,
int originalSize,
const void *dictStart, size_t dictSize)
{
return LZ4_decompress_generic(source, dest,
0, originalSize,
endOnOutputSize, decode_full_block,
usingExtDict, (BYTE *)dest,
(const BYTE *)dictStart, dictSize);
}
/*
* The "double dictionary" mode, for use with e.g. ring buffers: the first part
* of the dictionary is passed as prefix, and the second via dictStart + dictSize.
* These routines are used only once, in LZ4_decompress_*_continue().
*/
static FORCE_INLINE
int LZ4_decompress_safe_doubleDict(const char *source, char *dest,
int compressedSize, int maxOutputSize,
size_t prefixSize,
const void *dictStart, size_t dictSize)
{
return LZ4_decompress_generic(source, dest,
compressedSize, maxOutputSize,
endOnInputSize, decode_full_block,
usingExtDict, (BYTE *)dest - prefixSize,
(const BYTE *)dictStart, dictSize);
}
static FORCE_INLINE
int LZ4_decompress_fast_doubleDict(const char *source, char *dest,
int originalSize, size_t prefixSize,
const void *dictStart, size_t dictSize)
{
return LZ4_decompress_generic(source, dest,
0, originalSize,
endOnOutputSize, decode_full_block,
usingExtDict, (BYTE *)dest - prefixSize,
(const BYTE *)dictStart, dictSize);
}
/* ===== streaming decompression functions ===== */
int LZ4_setStreamDecode(LZ4_streamDecode_t *LZ4_streamDecode,
const char *dictionary, int dictSize)
{
LZ4_streamDecode_t_internal *lz4sd = (LZ4_streamDecode_t_internal *) LZ4_streamDecode;
LZ4_streamDecode_t_internal *lz4sd =
&LZ4_streamDecode->internal_donotuse;
lz4sd->prefixSize = (size_t) dictSize;
lz4sd->prefixEnd = (const BYTE *) dictionary + dictSize;
@@ -382,35 +576,51 @@ int LZ4_setStreamDecode(LZ4_streamDecode_t *LZ4_streamDecode,
int LZ4_decompress_safe_continue(LZ4_streamDecode_t *LZ4_streamDecode,
const char *source, char *dest, int compressedSize, int maxOutputSize)
{
LZ4_streamDecode_t_internal *lz4sd = &LZ4_streamDecode->internal_donotuse;
LZ4_streamDecode_t_internal *lz4sd =
&LZ4_streamDecode->internal_donotuse;
int result;
if (lz4sd->prefixEnd == (BYTE *)dest) {
result = LZ4_decompress_generic(source, dest,
compressedSize,
maxOutputSize,
endOnInputSize, full, 0,
usingExtDict, lz4sd->prefixEnd - lz4sd->prefixSize,
lz4sd->externalDict,
lz4sd->extDictSize);
if (lz4sd->prefixSize == 0) {
/* The first call, no dictionary yet. */
assert(lz4sd->extDictSize == 0);
result = LZ4_decompress_safe(source, dest,
compressedSize, maxOutputSize);
if (result <= 0)
return result;
lz4sd->prefixSize = result;
lz4sd->prefixEnd = (BYTE *)dest + result;
} else if (lz4sd->prefixEnd == (BYTE *)dest) {
/* They're rolling the current segment. */
if (lz4sd->prefixSize >= 64 * KB - 1)
result = LZ4_decompress_safe_withPrefix64k(source, dest,
compressedSize, maxOutputSize);
else if (lz4sd->extDictSize == 0)
result = LZ4_decompress_safe_withSmallPrefix(source,
dest, compressedSize, maxOutputSize,
lz4sd->prefixSize);
else
result = LZ4_decompress_safe_doubleDict(source, dest,
compressedSize, maxOutputSize,
lz4sd->prefixSize,
lz4sd->externalDict, lz4sd->extDictSize);
if (result <= 0)
return result;
lz4sd->prefixSize += result;
lz4sd->prefixEnd += result;
lz4sd->prefixEnd += result;
} else {
/*
* The buffer wraps around, or they're
* switching to another buffer.
*/
lz4sd->extDictSize = lz4sd->prefixSize;
lz4sd->externalDict = lz4sd->prefixEnd - lz4sd->extDictSize;
result = LZ4_decompress_generic(source, dest,
result = LZ4_decompress_safe_forceExtDict(source, dest,
compressedSize, maxOutputSize,
endOnInputSize, full, 0,
usingExtDict, (BYTE *)dest,
lz4sd->externalDict, lz4sd->extDictSize);
if (result <= 0)
return result;
lz4sd->prefixSize = result;
lz4sd->prefixEnd = (BYTE *)dest + result;
lz4sd->prefixEnd = (BYTE *)dest + result;
}
return result;
@@ -422,75 +632,66 @@ int LZ4_decompress_fast_continue(LZ4_streamDecode_t *LZ4_streamDecode,
LZ4_streamDecode_t_internal *lz4sd = &LZ4_streamDecode->internal_donotuse;
int result;
if (lz4sd->prefixEnd == (BYTE *)dest) {
result = LZ4_decompress_generic(source, dest, 0, originalSize,
endOnOutputSize, full, 0,
usingExtDict,
lz4sd->prefixEnd - lz4sd->prefixSize,
lz4sd->externalDict, lz4sd->extDictSize);
if (result <= 0)
return result;
lz4sd->prefixSize += originalSize;
lz4sd->prefixEnd += originalSize;
} else {
lz4sd->extDictSize = lz4sd->prefixSize;
lz4sd->externalDict = lz4sd->prefixEnd - lz4sd->extDictSize;
result = LZ4_decompress_generic(source, dest, 0, originalSize,
endOnOutputSize, full, 0,
usingExtDict, (BYTE *)dest,
lz4sd->externalDict, lz4sd->extDictSize);
if (lz4sd->prefixSize == 0) {
assert(lz4sd->extDictSize == 0);
result = LZ4_decompress_fast(source, dest, originalSize);
if (result <= 0)
return result;
lz4sd->prefixSize = originalSize;
lz4sd->prefixEnd = (BYTE *)dest + originalSize;
lz4sd->prefixEnd = (BYTE *)dest + originalSize;
} else if (lz4sd->prefixEnd == (BYTE *)dest) {
if (lz4sd->prefixSize >= 64 * KB - 1 ||
lz4sd->extDictSize == 0)
result = LZ4_decompress_fast(source, dest,
originalSize);
else
result = LZ4_decompress_fast_doubleDict(source, dest,
originalSize, lz4sd->prefixSize,
lz4sd->externalDict, lz4sd->extDictSize);
if (result <= 0)
return result;
lz4sd->prefixSize += originalSize;
lz4sd->prefixEnd += originalSize;
} else {
lz4sd->extDictSize = lz4sd->prefixSize;
lz4sd->externalDict = lz4sd->prefixEnd - lz4sd->extDictSize;
result = LZ4_decompress_fast_extDict(source, dest,
originalSize, lz4sd->externalDict, lz4sd->extDictSize);
if (result <= 0)
return result;
lz4sd->prefixSize = originalSize;
lz4sd->prefixEnd = (BYTE *)dest + originalSize;
}
return result;
}
/*
* Advanced decoding functions :
* *_usingDict() :
* These decoding functions work the same as "_continue" ones,
* the dictionary must be explicitly provided within parameters
*/
static FORCE_INLINE int LZ4_decompress_usingDict_generic(const char *source,
char *dest, int compressedSize, int maxOutputSize, int safe,
const char *dictStart, int dictSize)
int LZ4_decompress_safe_usingDict(const char *source, char *dest,
int compressedSize, int maxOutputSize,
const char *dictStart, int dictSize)
{
if (dictSize == 0)
return LZ4_decompress_generic(source, dest,
compressedSize, maxOutputSize, safe, full, 0,
noDict, (BYTE *)dest, NULL, 0);
if (dictStart + dictSize == dest) {
if (dictSize >= (int)(64 * KB - 1))
return LZ4_decompress_generic(source, dest,
compressedSize, maxOutputSize, safe, full, 0,
withPrefix64k, (BYTE *)dest - 64 * KB, NULL, 0);
return LZ4_decompress_generic(source, dest, compressedSize,
maxOutputSize, safe, full, 0, noDict,
(BYTE *)dest - dictSize, NULL, 0);
return LZ4_decompress_safe(source, dest,
compressedSize, maxOutputSize);
if (dictStart+dictSize == dest) {
if (dictSize >= 64 * KB - 1)
return LZ4_decompress_safe_withPrefix64k(source, dest,
compressedSize, maxOutputSize);
return LZ4_decompress_safe_withSmallPrefix(source, dest,
compressedSize, maxOutputSize, dictSize);
}
return LZ4_decompress_generic(source, dest, compressedSize,
maxOutputSize, safe, full, 0, usingExtDict,
(BYTE *)dest, (const BYTE *)dictStart, dictSize);
}
int LZ4_decompress_safe_usingDict(const char *source, char *dest,
int compressedSize, int maxOutputSize,
const char *dictStart, int dictSize)
{
return LZ4_decompress_usingDict_generic(source, dest,
compressedSize, maxOutputSize, 1, dictStart, dictSize);
return LZ4_decompress_safe_forceExtDict(source, dest,
compressedSize, maxOutputSize, dictStart, dictSize);
}
int LZ4_decompress_fast_usingDict(const char *source, char *dest,
int originalSize, const char *dictStart, int dictSize)
int originalSize,
const char *dictStart, int dictSize)
{
return LZ4_decompress_usingDict_generic(source, dest, 0,
originalSize, 0, dictStart, dictSize);
if (dictSize == 0 || dictStart + dictSize == dest)
return LZ4_decompress_fast(source, dest, originalSize);
return LZ4_decompress_fast_extDict(source, dest, originalSize,
dictStart, dictSize);
}
#ifndef STATIC

View File

@@ -75,6 +75,11 @@ typedef uintptr_t uptrval;
#define WILDCOPYLENGTH 8
#define LASTLITERALS 5
#define MFLIMIT (WILDCOPYLENGTH + MINMATCH)
/*
* ensure it's possible to write 2 x wildcopyLength
* without overflowing output buffer
*/
#define MATCH_SAFEGUARD_DISTANCE ((2 * WILDCOPYLENGTH) - MINMATCH)
/* Increase this value ==> compression run slower on incompressible data */
#define LZ4_SKIPTRIGGER 6
@@ -222,6 +227,8 @@ typedef enum { noDict = 0, withPrefix64k, usingExtDict } dict_directive;
typedef enum { noDictIssue = 0, dictSmall } dictIssue_directive;
typedef enum { endOnOutputSize = 0, endOnInputSize = 1 } endCondition_directive;
typedef enum { full = 0, partial = 1 } earlyEnd_directive;
typedef enum { decode_full_block = 0, partial_decode = 1 } earlyEnd_directive;
#define LZ4_STATIC_ASSERT(c) BUILD_BUG_ON(!(c))
#endif

334
lib/memleak_debug_stackdepot.c Executable file
View File

@@ -0,0 +1,334 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2018-2020 Oplus. All rights reserved.
*/
#include <linux/gfp.h>
#include <linux/jhash.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/percpu.h>
#include <linux/printk.h>
#include <linux/slab.h>
#include <linux/stacktrace.h>
#include <linux/memleak_stackdepot.h>
#include <linux/string.h>
#include <linux/types.h>
#include <linux/vmalloc.h>
#define DEPOT_STACK_BITS (sizeof(ml_depot_stack_handle_t) * 8)
#define STACK_ALLOC_NULL_PROTECTION_BITS 1
#define STACK_ALLOC_ORDER 0 /* 'Slab' size order for stack depot, 1 pages */
#define STACK_ALLOC_SIZE (1LL << (PAGE_SHIFT + STACK_ALLOC_ORDER))
#define STACK_ALLOC_ALIGN 4
#define STACK_ALLOC_OFFSET_BITS (STACK_ALLOC_ORDER + PAGE_SHIFT - \
STACK_ALLOC_ALIGN) //9
#define STACK_ALLOC_INDEX_BITS (DEPOT_STACK_BITS - \
STACK_ALLOC_NULL_PROTECTION_BITS - STACK_ALLOC_OFFSET_BITS) //22
#define STACK_ALLOC_SLABS_CAP 10240
#define STACK_ALLOC_MAX_SLABS \
(((1LL << (STACK_ALLOC_INDEX_BITS)) < STACK_ALLOC_SLABS_CAP) ? \
(1LL << (STACK_ALLOC_INDEX_BITS)) : STACK_ALLOC_SLABS_CAP)
/* The compact structure to store the reference to stacks. */
union ml_handle_parts {
ml_depot_stack_handle_t handle;
struct {
u32 slabindex : STACK_ALLOC_INDEX_BITS;
u32 offset : STACK_ALLOC_OFFSET_BITS;
u32 valid : STACK_ALLOC_NULL_PROTECTION_BITS;
};
};
struct ml_stack_record {
struct ml_stack_record *next; /* Link in the hashtable */
u32 hash; /* Hash in the hastable */
u32 size; /* Number of frames in the stack */
union ml_handle_parts handle;
unsigned long entries[1]; /* Variable-sized array of entries. */
};
static void **ml_stack_slabs = NULL;
static int ml_depot_index;
static int ml_next_slab_inited;
static size_t ml_depot_offset;
static DEFINE_SPINLOCK(ml_depot_lock);
static DEFINE_MUTEX(ml_depot_init_mutex);
static atomic_t ml_stack_depot_inited = ATOMIC_INIT(0);
static bool ml_init_stack_slab(void **prealloc)
{
if (!*prealloc)
return false;
/*
* This smp_load_acquire() pairs with smp_store_release() to
* |ml_next_slab_inited| below and in ml_depot_alloc_stack().
*/
if (smp_load_acquire(&ml_next_slab_inited))
return true;
if (ml_stack_slabs[ml_depot_index] == NULL) {
ml_stack_slabs[ml_depot_index] = *prealloc;
} else {
ml_stack_slabs[ml_depot_index + 1] = *prealloc;
/*
* This smp_store_release pairs with smp_load_acquire() from
* |ml_next_slab_inited| above and in ml_depot_save_stack().
*/
smp_store_release(&ml_next_slab_inited, 1);
}
*prealloc = NULL;
return true;
}
/* Allocation of a new stack in raw storage */
static struct ml_stack_record *ml_depot_alloc_stack(unsigned long *entries, int size,
u32 hash, void **prealloc, gfp_t alloc_flags)
{
int required_size = offsetof(struct ml_stack_record, entries) +
sizeof(unsigned long) * size;
struct ml_stack_record *stack;
required_size = ALIGN(required_size, 1 << STACK_ALLOC_ALIGN);
if (unlikely(ml_depot_offset + required_size > STACK_ALLOC_SIZE)) {
if (unlikely(ml_depot_index + 1 >= STACK_ALLOC_MAX_SLABS)) {
WARN_ONCE(1, "Stack depot reached limit capacity");
return NULL;
}
ml_depot_index++;
ml_depot_offset = 0;
/*
* smp_store_release() here pairs with smp_load_acquire() from
* |ml_next_slab_inited| in ml_depot_save_stack() and
* ml_init_stack_slab().
*/
if (ml_depot_index + 1 < STACK_ALLOC_MAX_SLABS)
smp_store_release(&ml_next_slab_inited, 0);
}
ml_init_stack_slab(prealloc);
if (ml_stack_slabs[ml_depot_index] == NULL)
return NULL;
stack = ml_stack_slabs[ml_depot_index] + ml_depot_offset;
stack->hash = hash;
stack->size = size;
stack->handle.slabindex = ml_depot_index;
stack->handle.offset = ml_depot_offset >> STACK_ALLOC_ALIGN;
stack->handle.valid = 1;
memcpy(stack->entries, entries, size * sizeof(unsigned long));
ml_depot_offset += required_size;
return stack;
}
#define STACK_HASH_SIZE (1L << 19)
#define STACK_HASH_MASK (STACK_HASH_SIZE - 1)
#define STACK_HASH_SEED 0x9747b28c
static struct ml_stack_record **ml_stack_table = NULL;
/* Calculate hash for a stack */
static inline u32 ml_hash_stack(unsigned long *entries, unsigned int size)
{
return jhash2((u32 *)entries,
size * sizeof(unsigned long) / sizeof(u32),
STACK_HASH_SEED);
}
/* Use our own, non-instrumented version of memcmp().
*
* We actually don't care about the order, just the equality.
*/
static inline
int ml_stackdepot_memcmp(const unsigned long *u1, const unsigned long *u2,
unsigned int n)
{
for ( ; n-- ; u1++, u2++) {
if (*u1 != *u2)
return 1;
}
return 0;
}
/* Find a stack that is equal to the one stored in entries in the hash */
static inline struct ml_stack_record *ml_find_stack(struct ml_stack_record *bucket,
unsigned long *entries, int size,
u32 hash)
{
struct ml_stack_record *found;
for (found = bucket; found; found = found->next) {
if (found->hash == hash &&
found->size == size &&
!ml_stackdepot_memcmp(entries, found->entries, size))
return found;
}
return NULL;
}
void ml_depot_fetch_stack(ml_depot_stack_handle_t handle, struct stack_trace *trace)
{
union ml_handle_parts parts = { .handle = handle };
void *slab;
size_t offset;
struct ml_stack_record *stack;
if (atomic_read(&ml_stack_depot_inited) == 0) {
pr_err("ml_stack_depot_inited is not inited\n");
return;
}
slab = ml_stack_slabs[parts.slabindex];
offset = parts.offset << STACK_ALLOC_ALIGN;
stack = slab + offset;
trace->nr_entries = trace->max_entries = stack->size;
trace->entries = stack->entries;
trace->skip = 0;
}
EXPORT_SYMBOL_GPL(ml_depot_fetch_stack);
/**
* ml_depot_save_stack - save stack in a stack depot.
* @trace - the stacktrace to save.
* @alloc_flags - flags for allocating additional memory if required.
*
* Returns the handle of the stack struct stored in depot.
*/
ml_depot_stack_handle_t ml_depot_save_stack(struct stack_trace *trace,
gfp_t alloc_flags)
{
u32 hash;
ml_depot_stack_handle_t retval = 0;
struct ml_stack_record *found = NULL, **bucket;
unsigned long flags;
struct page *page = NULL;
void *prealloc = NULL;
if (atomic_read(&ml_stack_depot_inited) == 0) {
pr_err("ml_stack_depot_inited is not inited\n");
goto fast_exit;
}
if (unlikely(trace->nr_entries == 0))
goto fast_exit;
hash = ml_hash_stack(trace->entries, trace->nr_entries);
bucket = &ml_stack_table[hash & STACK_HASH_MASK];
/*
* Fast path: look the stack trace up without locking.
* The smp_load_acquire() here pairs with smp_store_release() to
* |bucket| below.
*/
found = ml_find_stack(smp_load_acquire(bucket), trace->entries,
trace->nr_entries, hash);
if (found)
goto exit;
/*
* Check if the current or the next stack slab need to be initialized.
* If so, allocate the memory - we won't be able to do that under the
* lock.
*
* The smp_load_acquire() here pairs with smp_store_release() to
* |ml_next_slab_inited| in ml_depot_alloc_stack() and ml_init_stack_slab().
*/
if (unlikely(!smp_load_acquire(&ml_next_slab_inited))) {
/*
* Zero out zone modifiers, as we don't have specific zone
* requirements. Keep the flags related to allocation in atomic
* contexts and I/O.
*/
alloc_flags &= ~GFP_ZONEMASK;
alloc_flags &= (GFP_ATOMIC | GFP_KERNEL);
alloc_flags |= __GFP_NOWARN;
page = alloc_pages(alloc_flags, STACK_ALLOC_ORDER);
if (page)
prealloc = page_address(page);
}
spin_lock_irqsave(&ml_depot_lock, flags);
found = ml_find_stack(*bucket, trace->entries, trace->nr_entries, hash);
if (!found) {
struct ml_stack_record *new =
ml_depot_alloc_stack(trace->entries, trace->nr_entries,
hash, &prealloc, alloc_flags);
if (new) {
new->next = *bucket;
/*
* This smp_store_release() pairs with
* smp_load_acquire() from |bucket| above.
*/
smp_store_release(bucket, new);
found = new;
}
} else if (prealloc) {
/*
* We didn't need to store this stack trace, but let's keep
* the preallocated memory for the future.
*/
WARN_ON(!ml_init_stack_slab(&prealloc));
}
spin_unlock_irqrestore(&ml_depot_lock, flags);
if (prealloc) {
/* Nobody used this memory, ok to free it. */
free_pages((unsigned long)prealloc, STACK_ALLOC_ORDER);
}
exit:
if (found)
retval = found->handle.handle;
fast_exit:
return retval;
}
EXPORT_SYMBOL_GPL(ml_depot_save_stack);
int ml_depot_init(void)
{
int inited;
unsigned int size;
mutex_lock(&ml_depot_init_mutex);
inited = atomic_read(&ml_stack_depot_inited);
if (inited != 0) {
mutex_unlock(&ml_depot_init_mutex);
pr_err("ml_stack_depot_inited is inited, val %d\n", inited);
return 0;
}
size = sizeof(void *) * STACK_ALLOC_MAX_SLABS;
ml_stack_slabs = (void **)vmalloc(size);
if (!ml_stack_slabs) {
mutex_unlock(&ml_depot_init_mutex);
pr_err("vmalloc ml_stack_slabs %d failed.\n", size);
return -1;
}
memset(ml_stack_slabs, 0, size);
size = sizeof(struct ml_stack_record *) * STACK_HASH_SIZE;
ml_stack_table = (struct ml_stack_record **)vmalloc(size);
if (!ml_stack_table) {
mutex_unlock(&ml_depot_init_mutex);
pr_err("vmalloc ml_stack_table %d failed.\n", size);
vfree(ml_stack_slabs);
ml_stack_slabs = NULL;
return -1;
}
memset(ml_stack_table, 0, size);
atomic_set(&ml_stack_depot_inited, 1);
mutex_unlock(&ml_depot_init_mutex);
printk("ml_stack_depot_inited is inited.\n");
return 0;
}
EXPORT_SYMBOL_GPL(ml_depot_init);
int ml_get_depot_index(void)
{
return ml_depot_index;
}
EXPORT_SYMBOL_GPL(ml_get_depot_index);

View File

@@ -9,6 +9,10 @@
#include <linux/quicklist.h>
#include <linux/cma.h>
#ifdef OPLUS_FEATURE_HEALTHINFO
#include <linux/healthinfo/ion.h>
#endif /*OPLUS_FEATURE_HEALTHINFO*/
void show_mem(unsigned int filter, nodemask_t *nodemask)
{
pg_data_t *pgdat;
@@ -49,4 +53,7 @@ void show_mem(unsigned int filter, nodemask_t *nodemask)
#ifdef CONFIG_MEMORY_FAILURE
printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
#endif
#if defined(OPLUS_FEATURE_HEALTHINFO) && defined(CONFIG_OPLUS_HEALTHINFO)
printk("%lu pages ion total used\n", ion_total()>> PAGE_SHIFT);
#endif /*OPLUS_FEATURE_HEALTHINFO*/
}

View File

@@ -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.

View File

@@ -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) {

View File

@@ -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,

View File

@@ -2511,29 +2511,34 @@ int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args)
{
struct printf_spec spec = {0};
char *str, *end;
int width;
str = (char *)bin_buf;
end = (char *)(bin_buf + size);
#define save_arg(type) \
do { \
({ \
unsigned long long value; \
if (sizeof(type) == 8) { \
unsigned long long value; \
unsigned long long val8; \
str = PTR_ALIGN(str, sizeof(u32)); \
value = va_arg(args, unsigned long long); \
val8 = va_arg(args, unsigned long long); \
if (str + sizeof(type) <= end) { \
*(u32 *)str = *(u32 *)&value; \
*(u32 *)(str + 4) = *((u32 *)&value + 1); \
*(u32 *)str = *(u32 *)&val8; \
*(u32 *)(str + 4) = *((u32 *)&val8 + 1); \
} \
value = val8; \
} else { \
unsigned long value; \
unsigned int val4; \
str = PTR_ALIGN(str, sizeof(type)); \
value = va_arg(args, int); \
val4 = va_arg(args, int); \
if (str + sizeof(type) <= end) \
*(typeof(type) *)str = (type)value; \
*(typeof(type) *)str = (type)(long)val4; \
value = (unsigned long long)val4; \
} \
str += sizeof(type); \
} while (0)
value; \
})
while (*fmt) {
int read = format_decode(fmt, &spec);
@@ -2549,7 +2554,10 @@ do { \
case FORMAT_TYPE_WIDTH:
case FORMAT_TYPE_PRECISION:
save_arg(int);
width = (int)save_arg(int);
/* Pointers may require the width */
if (*fmt == 'p')
set_field_width(&spec, width);
break;
case FORMAT_TYPE_CHAR:
@@ -2571,7 +2579,27 @@ do { \
}
case FORMAT_TYPE_PTR:
save_arg(void *);
/* Dereferenced pointers must be done now */
switch (*fmt) {
/* Dereference of functions is still OK */
case 'S':
case 's':
case 'F':
case 'f':
save_arg(void *);
break;
default:
if (!isalnum(*fmt)) {
save_arg(void *);
break;
}
str = pointer(fmt, str, end, va_arg(args, void *),
spec);
if (str + 1 < end)
*str++ = '\0';
else
end[-1] = '\0'; /* Must be nul terminated */
}
/* skip all alphanumeric pointer suffixes */
while (isalnum(*fmt))
fmt++;
@@ -2723,11 +2751,39 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
break;
}
case FORMAT_TYPE_PTR:
str = pointer(fmt, str, end, get_arg(void *), spec);
case FORMAT_TYPE_PTR: {
bool process = false;
int copy, len;
/* Non function dereferences were already done */
switch (*fmt) {
case 'S':
case 's':
case 'F':
case 'f':
process = true;
break;
default:
if (!isalnum(*fmt)) {
process = true;
break;
}
/* Pointer dereference was already processed */
if (str < end) {
len = copy = strlen(args);
if (copy > end - str)
copy = end - str;
memcpy(str, args, copy);
str += len;
args += len + 1;
}
}
if (process)
str = pointer(fmt, str, end, get_arg(void *), spec);
while (isalnum(*fmt))
fmt++;
break;
}
case FORMAT_TYPE_PERCENT_CHAR:
if (str < end)

176
nativefeatures.mk Normal file
View File

@@ -0,0 +1,176 @@
#this is generated by oplus/build/make/core/soong_config.mk
OPLUS_BUG_STABILITY=yes
OPLUS_BUG_COMPATIBILITY=yes
OPLUS_BUG_DEBUG=yes
OPLUS_ARCH_INJECT=yes
OPLUS_ARCH_EXTENDS=yes
COLOROS_EDIT=yes
OPLUS_FEATURE_PLATFORM=MTK
OPLUS_FEATURE_PERFORMANCE=yes
OPLUS_FEATURE_ENGINEERTOOLS=true
OPLUS_FEATURE_SELINUX_CONTROL_LOG=true
OPLUS_FEATURE_SELINUX_DEBUG_BUILD=true
OPLUS_FEATURE_SELINUX_CONTEXTS=true
OPLUS_FEATURE_DYNAMIC_KEYMAP=yes
OPLUS_FEATURE_DROP_STATUSBAR=yes
OPLUS_FEATURE_GESTURE_SCREENSHOT=yes
OPLUS_FEATURE_DATE_FIXUP=true
OPLUS_FEATURE_DEXOPT_SPEED=true
OPLUS_FEATURE_APP_ACCESS_FILES=true
OPLUS_FEATURE_OTA_DATA_UPDATE=true
OPLUS_FEATURE_CUSTOM_GIDS=true
OPLUS_FEATURE_PHOENIX_RECOVERY=yes
OPLUS_FEATURE_ALLFILEACCESS=yes
OPLUS_FEATURE_CTS_FINGERPRINT=yes
OPLUS_FEATURE_STORAGE=yes
OPLUS_FEATURE_STORAGE_MOUNT=yes
OPLUS_FEATURE_STORAGE_RESIZE=yes
OPLUS_FEATURE_STORAGE_TRIM=yes
OPLUS_FEATURE_STORAGE_FBE=yes
OPLUS_FEATURE_STORAGE_MTP=yes
OPLUS_FEATURE_STORAGE_RESERVEPARTITION=yes
OPLUS_FEATURE_STORAGE_USB=yes
OPLUS_FEATURE_STORAGE_CUSTOMIZE_PARTITION=yes
OPLUS_FEATURE_STORAGE_FDE=yes
OPLUS_FEATURE_STORAGE_AUTOMATIC_TIMING=yes
OPLUS_BUG_UPDATABILITY=yes
OPLUS_FEATURE_RECOVERY_BUILD=yes
OPLUS_FEATURE_RECOVERY_BOOT=yes
OPLUS_FEATURE_RECOVERY_UI=yes
OPLUS_FEATURE_RECOVERY_RESET=yes
OPLUS_FEATURE_OTAPACKAGE_BUILD=yes
OPLUS_FEATURE_OTAPACKAGE_UPDATER=yes
OPLUS_FEATURE_OTAPACKAGE_SCRIPT=yes
OPLUS_FEATURE_BOOTANIMATION=yes
OPLUS_FEATURE_SECURE_GUARD=yes
OPLUS_FEATURE_SECURE_ROOTGUARD=yes
OPLUS_FEATURE_SECURE_MOUNTGUARD=yes
OPLUS_FEATURE_SECURE_EXECGUARD=yes
OPLUS_FEATURE_SECURE_KEVENTUPLOAD=yes
OPLUS_FEATURE_SECURE_KEYINTERFACESGUARD=yes
OPLUS_FEATURE_EDGE_PANEL=yes
OPLUS_FEATURE_SCREEN_FINGERPRINT=yes
OPLUS_FEATURE_ENGINEERING_FILEACCESS=yes
OPLUS_FEATURE_ORMS=yes
OPLUS_ARCH_CUSTOM_PARTITION=yes
OPLUS_FEATURE_MAINLINE=yes
OPLUS_FEATURE_DEXOPT_STRATEGY=true
OPLUS_FEATURE_CLOUD_COMPILE=yes
OPLUS_FEATURE_BATTERY_MANAGER=yes
OPLUS_FEATURE_PMS_EXCEPTION_FIX=true
OPLUS_FEATURE_PMS_BOOT_TIME_OPT=true
OPLUS_FEATURE_SHUTDOWN_DETECT=yes
OPLUS_FEATURE_PHOENIX=yes
OPLUS_FEATURE_AGINGTEST=yes
OPLUS_FEATURE_FINGERPRINT=yes
OPLUS_FEATURE_FINGERPRINTPAY=yes
FP_DCS_ENABLE=y
FP_OPLUS_PLATFORMCPU_ALL8_BIG67=y
FP_CONFIG_BINDCORE_BYTID=yes
FP_MTK_GREATER_THAN_TEE500=y
FP_GOODIX_OPTICAL_SUPPORT=y
FP_SETTINGS_ENABLE=y
FP_HBM_BRIGHTNESS_DELAY=yes
GF_OPEN_DUMP_TEMP=yes
FP_CONFIG_HYPNUSD_ENABLE=1
FP_JIIOV_OPTICAL_SUPPORT=y
FP_GOODIX_SUPPORT=y
FP_GOOIDX_VERSION=side_fp
FPC_FP_ENABLE=y
FP_FPC_VERSION=side_fpc_fp
OPLUS_FEATURE_FACERECOGNITION=yes
FACE_TEE_RUNTIME=TBASE
FACE_CONFIG_CPU_VERSION=1
LOW_ST_BUFFER_SIZE=1
FACE_DCS_ENABLE=y
OPLUS_FEATURE_HEALTHINFO=yes
OPLUS_FEATURE_SCHED_ASSIST=yes
OPLUS_FEATURE_PROCESS_RECLAIM=yes
OPLUS_FEATURE_FG_IO_OPT=yes
OPLUS_FEATURE_TP_BASIC=yes
OPLUS_FEATURE_TP_BSPFWUPDATE=yes
OPLUS_FEATURE_MULTI_KSWAPD=yes
OPLUS_FEATURE_ZRAM_OPT=yes
OPLUS_FEATURE_MULTI_FREEAREA=yes
OPLUS_FEATURE_VIRTUAL_RESERVE_MEMORY=yes
OPLUS_FEATURE_SENSOR=yes
OPLUS_FEATURE_SENSOR_ALGORITHM=yes
OPLUS_FEATURE_STORAGE_TOOL=yes
OPLUS_FEATURE_CHG_BASIC=yes
OPLUS_FEATURE_NEW_FTMFLASHLIGHT_NODE=yes
OPLUS_ARCH_EXTENDS_CAM_TUNING_LIB=yes
OPLUS_ARCH_EXTENDS_CAM_TUNING_PARAMS=yes
OPLUS_FEATURE_CAMERA_COMMON=yes
OPLUS_FEATURE_CAMERA_IZOOM=yes
OPLUS_FEATURE_CAMERA_AIS=yes
OPLUS_FEATURE_CAMERA_FB=yes
OPLUS_FEATURE_CAMERA_AISCP=yes
OPLUS_FEATURE_CAMERA_UPSCALE=yes
OPLUS_FEATURE_CAMERA_SUPERNIGHT=yes
OPLUS_FEATURE_CAMERA_VIDEO=yes
OPLUS_FEATURE_CAMERA_SMVR=yes
OPLUS_FEATURE_CAMERA_MSNR=yes
OPLUS_FEATURE_WIFI_DATASTALL=yes
OPLUS_FEATURE_WIFI_MTUDETECT=yes
OPLUS_FEATURE_WIFI_SLA=yes
OPLUS_FEATURE_WIFI_GBK=yes
OPLUS_FEATURE_WIFI_DUALSTA=yes
OPLUS_FEATURE_WIFI_OSHARE=yes
OPLUS_FEATURE_WIFI_SUPPLICANTHIDL=yes
OPLUS_FEATURE_WIFI_LIMMITBGSPEED=yes
OPLUS_FEATURE_BT_INTEROPLIST=yes
OPLUS_FEATURE_DATA_EVAL=yes
OPLUS_FEATURE_FONT_FLIP=yes
OPLUS_FEATURE_MOTION_INTERCEPT=yes
OPLUS_FEATURE_LINKERCONFIG_CUSTOM=yes
OPLUS_FEATURE_RESOURCES_COMPILE=yes
OPLUS_FEATURE_DARKMODE=yes
OPLUS_FEATURE_DUMP_SENSOR=yes
OPLUS_FEATURE_ATLAS=yes
OPLUS_FEATURE_AUDIO_FTM=yes
OPLUS_FEATURE_AUDIOSERVER_DEBUG=yes
OPLUS_FEATURE_VIP_RECORD=yes
OPLUS_FEATURE_PA_DUMMY=true
OPLUS_FEATURE_VOIP_ENHANCE=yes
OPLUS_FEATURE_GAMEVOICEOPTIMIZE=yes
OPLUS_FEATURE_KTV=true
OPLUS_FEATURE_PLAYBACKCAPTURE=yes
OPLUS_FEATURE_GAME_MUTE=yes
OPLUS_FEATURE_VOICE_CHANGER=yes
OPLUS_FEATURE_INPUTCHANNEL_CHOICE=yes
OPLUS_FEATURE_AUDIOVOICE_SCENCE=true
OPLUS_FEATURE_DOLBY=true
OPLUS_FEATURE_DIRAC=true
OPLUS_FEATURE_OPERATOR_RINGTONE=yes
OPLUS_FEATURE_CAMERASOUND_FORCE=yes
OPLUS_FEATURE_FORBID_RECORD=yes
OPLUS_FEATURE_SPEAKER_MUTE=true
OPLUS_FEATURE_AUDIO_LOWLATENCY=true
OPLUS_FEATURE_MULTISCENE_RECORD=yes
OPLUS_FEATURE_OPLUS_AVENHANCEMENT=yes
OPLUS_FEATURE_APE_DECODER=yes
OPLUS_FEATURE_VIDEO_TITLE=yes
OPLUS_FEATURE_MP3_RECORDER=yes
OPLUS_FEATURE_FFMPEG_INTEGRATION=yes
OPLUS_FEATURE_FEEDBACK_INFO=yes
OPLUS_FEATURE_IMAGE_PROCESSING=yes
OPLUS_FEATURE_ZEN_MODE=yes
OPLUS_FEATURE_MULTIBITS_BL=yes
OPLUS_FEATURE_DFPS3_SUPPORT=yes
OPLUS_FEATURE_ONSCREENFINGERPRINT=yes
OPLUS_FEATURE_DC=yes
OPLUS_FEATURE_AOD=yes
OPLUS_FEATURE_DRE=yes
OPLUS_FEATURE_OSC=yes
OPLUS_FEATURE_AUTOBRIGHTNESS=yes
OPLUS_FEATURE_GPU_MINIDUMP=yes
OPLUS_FEATURE_SCREENSHOT=yes
OPLUS_FEATURE_GIFT=yes
OPLUS_FEATURE_OSIE=yes
OPLUS_FEATURE_VPP=yes
OPLUS_FEATURE_GAME_OIFACE=yes
OPLUS_FEATURE_PLATFORM_MTK=yes
OPLUS_FEATURE_VOICE_WAKEUP=true
OPLUS_FEATURE_VOW_WAKEUP=true
OPLUS_FEATURE_VOICE_WAKEUP_LOG_ENABLE=true
TARGET_PRODUCT=vnd_k85v1_64

View File

@@ -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)

View File

@@ -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)))

View File

@@ -15,8 +15,12 @@ PHONY += $(modules)
__modsign: $(modules)
@:
quiet_cmd_sign_ko = SIGN [M] $(2)/$(notdir $@)
cmd_sign_ko = $(mod_sign_cmd) $(2)/$(notdir $@)
#quiet_cmd_sign_ko = SIGN [M] $(2)/$(notdir $@)
# cmd_sign_ko = $(mod_sign_cmd) $(2)/$(notdir $@)
# For temporary, change $(2)/$(notdir $@) to $@
quiet_cmd_sign_ko = SIGN [M] $@
cmd_sign_ko = $(mod_sign_cmd) $@
# Modules built outside the kernel source tree go into extra by default
INSTALL_MOD_DIR ?= extra

View File

@@ -6,7 +6,7 @@ ifdef CONFIG_UBSAN
CFLAGS_UBSAN += $(call cc-option, -fsanitize=vla-bound)
CFLAGS_UBSAN += $(call cc-option, -fsanitize=signed-integer-overflow)
CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds)
CFLAGS_UBSAN += $(call cc-option, -fsanitize=object-size)
# CFLAGS_UBSAN += $(call cc-option, -fsanitize=object-size)
CFLAGS_UBSAN += $(call cc-option, -fsanitize=returns-nonnull-attribute)
CFLAGS_UBSAN += $(call cc-option, -fsanitize=bool)
CFLAGS_UBSAN += $(call cc-option, -fsanitize=enum)
@@ -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)

309
scripts/check_defconfigs Executable file
View File

@@ -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

View File

@@ -48,7 +48,7 @@ my %ignore_type = ();
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 @@ Options:
--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) {

BIN
scripts/dtc/dtc_overlay Executable file

Binary file not shown.

BIN
scripts/dtc/ufdt_apply_overlay Executable file

Binary file not shown.