一个简单的低内存杀手内核驱动程序,适用于Android设备。请选择与您内核版本相对应的分支。

作者:Sec-Labs | 发布时间:

项目地址

https://github.com/kerneltoast/simple_lmk

项目简介

该项目是关于如何向Android Common Kernels提交补丁的说明,主要包括以下内容:

相关技术点

  • Linux内核编码标准和代码风格
  • script/checkpatch.pl工具使用
  • 构建gki_defconfig或allmodconfig的要求
  • Change-Id: 标签的使用
  • Signed-off-by: 标签的使用

项目用途

  • 向Android Common Kernels提交补丁
  • 补丁必须符合Linux内核的标准和要求
  • 如果补丁不是从上游分支合并过来的,则需要在主题中标记补丁类型
  • 所有补丁必须有一个 Change-Id: 标签
  • 如果分配了Android bug,则必须有一个 Bug: 标签
  • 补丁类型为 UPSTREAM:BACKPORT: 时有特定的要求,其他类型的补丁有不同的要求。

如何向 Android Common Kernels 提交补丁

  1. 最好的方法:将所有更改应用于上游 Linux。如果适当,可以将其回溯到稳定版本。这些补丁将自动合并到相应的通用内核中。如果补丁已经在上游 Linux 中,请发布符合下面的补丁要求的补丁的回溯版本。

    • 不要将仅包含符号导出的补丁发送到上游。要考虑用于上游 Linux 的 EXPORT_SYMBOL_GPL() 的添加,需要使用符号的内部模块驱动程序。因此,在同一补丁集中包括新驱动程序或对现有驱动程序的更改。
    • 发送补丁到上游时,提交消息必须包含为什么需要该补丁以及对社区有益的明确说明。启用外部驱动程序或功能不是一个有说服力的理由。
  2. 较差的方法:在上游 Linux 的角度来看,开发您的补丁。除非这些补丁修复了 Android 特定的错误,否则很难被接受,除非已与 kernel-team@android.com 协调。如果要继续,请发布符合下面的补丁要求的补丁。

Common Kernel 补丁要求

根据补丁类型,以下是其他要求

来自主线 Linux 的回溯要求:UPSTREAM:BACKPORT:

  • 如果补丁是从 Linux 主线上直接提取而没有任何更改

    • 使用 UPSTREAM: 标记补丁主题。

    • 添加上游提交信息和 (cherry picked from commit ...)

    • 例如:

      • 如果上游提交消息是 ``` important patch from upstream

      This is the detailed description of the important patch

      Signed-off-by: Fred Jones fred.jones@foo.org

      >- 那么 Joe Smith 会将该补丁上传到通用内核中
      

      UPSTREAM: important patch from upstream

      This is the detailed description of the important patch

      Signed-off-by: Fred Jones fred.jones@foo.org

      Bug: 135791357 Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01 (cherry picked from commit c31e73121f4c1ec41143423ac6ce3ce6dafdcec1) Signed-off-by: Joe Smith joe.smith@foo.org ```

  • 如果补丁需要来自上游版本的任何更改,请使用 BACKPORT: 而不是 UPSTREAM: 标记补丁。

    • 使用与 UPSTREAM: 相同的标记。

    • (cherry picked from commit ...) 行下添加有关更改的注释。

    • 例如:

        BACKPORT: important patch from upstream
      
        This is the detailed description of the important patch
      
        Signed-off-by: Fred Jones <fred.jones@foo.org>
      
        Bug: 135791357
        Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01
        (cherry picked from commit c31e73121f4c1ec41143423ac6ce3ce6dafdcec1)
        [joe: Resolved minor conflict in drivers/foo/bar.c ]
        Signed-off-by: Joe Smith <joe.smith@foo.org>
      

其他回溯要求:FROMGIT:FROMLIST:,如果补丁已合并到上游维护树,但尚未合并到Linux主线

  • 在补丁主题中标记为FROMGIT:

  • 添加补丁来源的信息,格式为(cherry picked from commit <sha1> <repo> <branch>)。 这必须是一个稳定的维护者分支(不要使用例如linux-next的分支)。

  • 如果需要更改,请使用BACKPORT:FROMGIT:

  • 示例:

    • 如果维护者树中的提交消息为

          important patch from upstream
      
          This is the detailed description of the important patch
      
          Signed-off-by: Fred Jones <fred.jones@foo.org>
      
    • 那么Joe Smith将将补丁上传到通用内核,格式如下:

          FROMGIT: important patch from upstream
      
          This is the detailed description of the important patch
      
          Signed-off-by: Fred Jones <fred.jones@foo.org>
      
          Bug: 135791357
          (cherry picked from commit 878a2fd9de10b03d11d2f622250285c7e63deace
           https://git.kernel.org/pub/scm/linux/kernel/git/foo/bar.git test-branch)
          Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01
          Signed-off-by: Joe Smith <joe.smith@foo.org>
      

如果补丁已提交到LKML,但尚未被接受到任何维护者树中

  • 在补丁主题中标记为FROMLIST:

  • 添加一个Link:标签,其中包含指向lore.kernel.org提交的链接

  • 添加一个Bug:标签,其中包含Android bug(对于未被接受到维护者树的补丁是必需的)

  • 如果需要更改,请使用BACKPORT:FROMLIST:

  • 示例:

          FROMLIST: important patch from upstream
    
          This is the detailed description of the important patch
    
          Signed-off-by: Fred Jones <fred.jones@foo.org>
    
          Bug: 135791357
          Link: https://lore.kernel.org/lkml/20190619171517.GA17557@someone.com/
          Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01
          Signed-off-by: Joe Smith <joe.smith@foo.org>
    

Android特定补丁的要求:ANDROID:

  • 如果补丁正在修复Android特定代码的错误

  • 在补丁主题中标记为ANDROID:

  • 添加一个Fixes:标记,引用带有该错误的补丁

  • 示例:

          ANDROID: fix android-specific bug in foobar.c
    
          This is the detailed description of the important fix
    
          Fixes: 1234abcd2468 ("foobar: add cool feature")
          Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01
          Signed-off-by: Joe Smith <joe.smith@foo.org>
    
  • 如果补丁是一个新功能

  • 在补丁主题中标记为ANDROID:

  • 添加一个Bug:标记,其中包含Android bug(对于Android特定功能是必需的)

标签:工具分享, APP分析, andriod学习