Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LoongArch support for kpatch #1424

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Commits on Nov 8, 2024

  1. kpatch/LoongArch: Add LoongArch specific features

    Add section alt_instr check support for LoongArch.
    
    Signed-off-by: George Guo <guodongtai@kylinos.cn>
    georgejguo committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    6c50586 View commit details
    Browse the repository at this point in the history
  2. kpatch/LoongArch: Add initial support for kpatch

    Add initial support for LoongArch.
    
    Signed-off-by: George Guo <guodongtai@kylinos.cn>
    georgejguo committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    9a3d0e9 View commit details
    Browse the repository at this point in the history
  3. kpatch/LoongArch: create and process section __patchable_function_ent…

    …ries
    
    Generate 2 NOPs right at the beginning of each function with
    -fpatchable-function-entry=2 in LoongArch. So here create section
    __patchable_function_entries and check this situation.
    
    Co-developed-by: zhanghongchen <zhanghongchen@loongson.cn>
    Signed-off-by: George Guo <guodongtai@kylinos.cn>
    georgejguo committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    411bf6c View commit details
    Browse the repository at this point in the history
  4. kpatch/LoongArch: change local labels with sections symbols

    Here fix error like: "tcp.o: symbol changed sections: .LBB7266.
    create-diff-object: unreconcilable difference".
    Due to LoongArch GCC generating local labels such as .LBB7266,
    it is difficult to compare the modified sections in the
    corresponding object files of the two files before and after
    the patch, so change them with sections symbols in rela section,
    and delete them in other sections.
    
    Co-developed-by: zhanghongchen <zhanghongchen@loongson.cn>
    Signed-off-by: George Guo <guodongtai@kylinos.cn>
    georgejguo committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    bd6e184 View commit details
    Browse the repository at this point in the history
  5. kpatch/LoongArch: fix ld error

    Take tcp.o as an example. An ld error occurs as follows:
    "ld: __patchable_function_entries has both ordered and
    unordered sections" when linking patch-hook.o and output.o.
    
    The link error is triggered by running the command:
    "ld -r --unique=.parainstructions --unique=.altinstructions -o
    patch/tmp_output.o output/net/ipv4/tcp.o".
    
    With -fpatchable-function-entry, LoongArch GCC sets WAL flags
    for section __patchable_function_entries in object file
    (which includes patch-hook.o) by default.
    Meanwhile, Kpatch sets A flags for output.o in create_section_pair().
    To resolve the ld error, we set sh_flags = WAL.
    
    Signed-off-by: George Guo <guodongtai@kylinos.cn>
    georgejguo committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    4ce2754 View commit details
    Browse the repository at this point in the history
  6. kpatch/LoongArch: enable kpatch build

    Since kpatch now supports LoongArch basically, enable the build.
    
    Signed-off-by: George Guo <guodongtai@kylinos.cn>
    georgejguo committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    06f87de View commit details
    Browse the repository at this point in the history
  7. kpatch/LoongArch: short circuit for patchable sections

    Omit patchable sections compare processing, as we will rebuild it.
    
    Signed-off-by: George Guo <guodongtai@kylinos.cn>
    georgejguo committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    1f52740 View commit details
    Browse the repository at this point in the history
  8. kpatch/LoongArch: fix build error on non-LoongArch architectures

    Added conditional compilation to prevent 'R_LARCH_64' and 'EM_LOONGARCH'
    from being referenced on x86 and other non-LoongArch architectures. This
    ensures the code works across different architectures without errors.
    
    Signed-off-by: George Guo <guodongtai@kylinos.cn>
    georgejguo committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    5826776 View commit details
    Browse the repository at this point in the history