• C
    livepatch/core: allow implementation without ftrace · 1348c3cc
    Cheng Jian 提交于
    euler inclusion
    category: feature
    Bugzilla: 5507
    CVE: N/A
    
    ----------------------------------------
    
    support for livepatch without ftrace mode
    
    new config for WO_FTRACE
    	CONFIG_LIVEPATCH_WO_FTRACE=y
    	CONFIG_LIVEPATCH_STACK=y
    
    Implements livepatch without ftrace by direct jump, we
    directly modify the first few instructions(usually one,
    but four for long jumps under ARM64) of the old function
    as jump instructions by stop_machine, so it will jump to
    the first address of the new function when livepatch enable
    
    KERNEL/MODULE
    call/bl A---------------old_A------------
                            | jump new_A----+--------|
                            |               |        |
                            |               |        |
                            -----------------        |
                                                     |
                                                     |
                                                     |
    livepatch_module-------------                    |
    |                           |                    |
    |new_A <--------------------+--------------------|
    |                           |
    |                           |
    |---------------------------|
    | .plt                      |
    | ......PLTS for livepatch  |
    -----------------------------
    
    something we need to consider under different architectures:
    
    1. jump instruction
    2. partial relocation in new function requires for livepatch.
    3. long jumps may be required if the jump address exceeds the
       offset. both for livepatch relocation and livepatch enable.
    Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
    Reviewed-by: NLi Bin <huawei.libin@huawei.com>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    1348c3cc
core.c 30.0 KB