-
Notifications
You must be signed in to change notification settings - Fork 305
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 v2 #1427
Open
georgejguo
wants to merge
7
commits into
dynup:master
Choose a base branch
from
georgejguo:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8368005
kpatch/LoongArch: Add LoongArch specific features
georgejguo e2ad05f
kpatch/LoongArch: Add initial support for kpatch
georgejguo f27619f
kpatch/LoongArch: process section __patchable_function_entries
georgejguo ace5550
kpatch/LoongArch: change local labels with sections symbols
georgejguo dcf1188
kpatch/LoongArch: skip section .rela.orc_unwind_ip
georgejguo 3b637df
kpatch/LoongArch: enable kpatch build
georgejguo 31b8eb5
kpatch/LoongArch: fix build error on non-LoongArch architectures
georgejguo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,6 +142,8 @@ unsigned int absolute_rela_type(struct kpatch_elf *kelf) | |
return R_X86_64_64; | ||
case S390: | ||
return R_390_64; | ||
case LOONGARCH64: | ||
return R_LARCH_64; | ||
default: | ||
ERROR("unsupported arch"); | ||
} | ||
|
@@ -206,6 +208,7 @@ long rela_target_offset(struct kpatch_elf *kelf, struct section *relasec, | |
|
||
switch(kelf->arch) { | ||
case PPC64: | ||
case LOONGARCH64: | ||
add_off = 0; | ||
break; | ||
case X86_64: | ||
|
@@ -261,6 +264,7 @@ unsigned int insn_length(struct kpatch_elf *kelf, void *addr) | |
return decoded_insn.length; | ||
|
||
case PPC64: | ||
case LOONGARCH64: | ||
return 4; | ||
|
||
case S390: | ||
|
@@ -332,6 +336,22 @@ static void kpatch_create_rela_list(struct kpatch_elf *kelf, | |
rela->sym->name, rela->addend); | ||
} | ||
|
||
if (kelf->arch == LOONGARCH64) { | ||
/* | ||
* LoongArch GCC creates local labels such as .LBB7266, | ||
* replace them with section symbols. | ||
*/ | ||
if (rela->sym->sec && (rela->sym->type == STT_NOTYPE) && | ||
(rela->sym->bind == STB_LOCAL)) { | ||
log_debug("local label: %s -> ", rela->sym->name); | ||
|
||
rela->addend += rela->sym->sym.st_value; | ||
rela->sym = rela->sym->sec->secsym; | ||
log_debug("section symbol: %s\n", rela->sym->name); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious, which kernel source files are generating these symbols? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okey, I will try to find it. |
||
|
||
|
||
if (skip) | ||
continue; | ||
log_debug("offset %d, type %d, %s %s %ld", rela->offset, | ||
|
@@ -593,6 +613,9 @@ struct kpatch_elf *kpatch_elf_open(const char *name) | |
case EM_S390: | ||
kelf->arch = S390; | ||
break; | ||
case EM_LOONGARCH: | ||
kelf->arch = LOONGARCH64; | ||
break; | ||
default: | ||
ERROR("Unsupported target architecture"); | ||
} | ||
|
@@ -618,6 +641,18 @@ struct kpatch_elf *kpatch_elf_open(const char *name) | |
if (find_section_by_name(&kelf->sections, "__patchable_function_entries")) | ||
kelf->has_pfe = true; | ||
|
||
if (kelf->arch == LOONGARCH64) { | ||
struct symbol *sym, *tmp; | ||
|
||
/* Delete local labels created by LoongArch GCC */ | ||
list_for_each_entry_safe(sym, tmp, &kelf->symbols, list) { | ||
if (sym->sec && !is_rela_section(sym->sec) && | ||
(sym->type == STT_NOTYPE) && | ||
(sym->bind == STB_LOCAL)) | ||
list_del(&sym->list); | ||
} | ||
} | ||
|
||
return kelf; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I m not sure here, so just commit "to be done". Actually it can pass my simple test case.