Skip to content

Commit

Permalink
create-diff-object: tracepoint & jump label fixes
Browse files Browse the repository at this point in the history
The current approach of trying to include the tracepoint-related
sections doesn't work at all.  The new tracepoints don't show up in
"perf list".

And also, with one patch (issue dynup#219) I've seen a panic in
jump_label_del_module().  I suspect it's because the kernel is confused
by dynamic relocations' changing of the jump table after it was
registered with the jump table code.

I think the best approach for now is to just always exclude these
sections.  It should be harmless, with the only consequence being that
tracepoints and jump labels can't be enabled in patched functions (which
is already the case with the current code anyway).

Fixes dynup#221.
  • Loading branch information
jpoimboe committed May 30, 2014
1 parent f145b38 commit a180fc2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
29 changes: 20 additions & 9 deletions kpatch-build/create-diff-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,6 @@ int smp_locks_group_size(struct section *sec, int offset) { return 4; }
int parainstructions_group_size(struct section *sec, int offset) { return 16; }
int ex_table_group_size(struct section *sec, int offset) { return 8; }
int altinstructions_group_size(struct section *sec, int offset) { return 12; }
int jump_table_group_size(struct section *sec, int offset) { return 24; }

int fixup_group_size(struct section *sec, int offset)
{
Expand Down Expand Up @@ -1087,10 +1086,6 @@ struct special_section special_sections[] = {
.name = "__ex_table",
.group_size = ex_table_group_size,
},
{
.name = "__jump_table",
.group_size = jump_table_group_size,
},
{
.name = ".altinstructions",
.group_size = altinstructions_group_size,
Expand Down Expand Up @@ -1227,10 +1222,7 @@ void kpatch_process_special_sections(struct kpatch_elf *kelf)
* non-included symbols, so their entire rela section can be included.
*/
list_for_each_entry(sec, &kelf->sections, list) {
if (strcmp(sec->name, ".altinstr_replacement") &&
strcmp(sec->name, "__tracepoints") &&
strcmp(sec->name, "__tracepoints_ptrs") &&
strcmp(sec->name, "__tracepoints_strings"))
if (strcmp(sec->name, ".altinstr_replacement"))
continue;

/* include base section */
Expand All @@ -1249,6 +1241,25 @@ void kpatch_process_special_sections(struct kpatch_elf *kelf)
rela->sym->include = 1;
}
}

/*
* The following special sections aren't supported, so make sure we
* don't ever try to include them. Otherwise the kernel will see the
* jump table during module loading and get confused. Generally it
* should be safe to exclude them, it just means that you can't modify
* jump labels and enable tracepoints in a patched function.
*/
list_for_each_entry(sec, &kelf->sections, list) {
if (strcmp(sec->name, "__jump_table") &&
strcmp(sec->name, "__tracepoints") &&
strcmp(sec->name, "__tracepoints_ptrs") &&
strcmp(sec->name, "__tracepoints_strings"))
continue;

sec->status = SAME;
if (sec->rela)
sec->rela->status = SAME;
}
}

void print_strtab(char *buf, size_t size)
Expand Down
12 changes: 12 additions & 0 deletions test/integration/data-read-mostly.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Index: src/net/core/dev.c
===================================================================
--- src.orig/net/core/dev.c
+++ src/net/core/dev.c
@@ -3609,6 +3609,7 @@ ncls:
case RX_HANDLER_PASS:
break;
default:
+ printk("BUG!\n");
BUG();
}
}

0 comments on commit a180fc2

Please sign in to comment.