mirror of
https://github.com/dynup/kpatch
synced 2025-04-20 14:05:19 +00:00
kpatch-build: ppc64le - Add special section support
Add support for ppc64le specific special sections: - __ftr_fixup - __mmu_ftr_fixup - __fw_ftr_fixup - __lwsync_fixup This patch also add #ifdef guards for architecture specific special sections. Cc: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
This commit is contained in:
parent
c14e6e9118
commit
77f8fd09f1
@ -1454,21 +1454,6 @@ static int bug_table_group_size(struct kpatch_elf *kelf, int offset)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parainstructions_group_size(struct kpatch_elf *kelf, int offset)
|
|
||||||
{
|
|
||||||
static int size = 0;
|
|
||||||
char *str;
|
|
||||||
|
|
||||||
if (!size) {
|
|
||||||
str = getenv("PARA_STRUCT_SIZE");
|
|
||||||
if (!str)
|
|
||||||
ERROR("PARA_STRUCT_SIZE not set");
|
|
||||||
size = atoi(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ex_table_group_size(struct kpatch_elf *kelf, int offset)
|
static int ex_table_group_size(struct kpatch_elf *kelf, int offset)
|
||||||
{
|
{
|
||||||
static int size = 0;
|
static int size = 0;
|
||||||
@ -1484,6 +1469,22 @@ static int ex_table_group_size(struct kpatch_elf *kelf, int offset)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __x86_64__
|
||||||
|
static int parainstructions_group_size(struct kpatch_elf *kelf, int offset)
|
||||||
|
{
|
||||||
|
static int size = 0;
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
if (!size) {
|
||||||
|
str = getenv("PARA_STRUCT_SIZE");
|
||||||
|
if (!str)
|
||||||
|
ERROR("PARA_STRUCT_SIZE not set");
|
||||||
|
size = atoi(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
static int altinstructions_group_size(struct kpatch_elf *kelf, int offset)
|
static int altinstructions_group_size(struct kpatch_elf *kelf, int offset)
|
||||||
{
|
{
|
||||||
static int size = 0;
|
static int size = 0;
|
||||||
@ -1503,6 +1504,28 @@ static int smp_locks_group_size(struct kpatch_elf *kelf, int offset)
|
|||||||
{
|
{
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef __powerpc__
|
||||||
|
static int fixup_entry_group_size(struct kpatch_elf *kelf, int offset)
|
||||||
|
{
|
||||||
|
static int size = 0;
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
if (!size) {
|
||||||
|
str = getenv("FIXUP_STRUCT_SIZE");
|
||||||
|
if (!str)
|
||||||
|
ERROR("FIXUP_STRUCT_SIZE not set");
|
||||||
|
size = atoi(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int fixup_lwsync_group_size(struct kpatch_elf *kelf, int offset)
|
||||||
|
{
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The rela groups in the .fixup section vary in size. The beginning of each
|
* The rela groups in the .fixup section vary in size. The beginning of each
|
||||||
@ -1557,6 +1580,7 @@ static struct special_section special_sections[] = {
|
|||||||
.name = "__bug_table",
|
.name = "__bug_table",
|
||||||
.group_size = bug_table_group_size,
|
.group_size = bug_table_group_size,
|
||||||
},
|
},
|
||||||
|
#ifdef __x86_64__
|
||||||
{
|
{
|
||||||
.name = ".smp_locks",
|
.name = ".smp_locks",
|
||||||
.group_size = smp_locks_group_size,
|
.group_size = smp_locks_group_size,
|
||||||
@ -1565,6 +1589,7 @@ static struct special_section special_sections[] = {
|
|||||||
.name = ".parainstructions",
|
.name = ".parainstructions",
|
||||||
.group_size = parainstructions_group_size,
|
.group_size = parainstructions_group_size,
|
||||||
},
|
},
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
.name = ".fixup",
|
.name = ".fixup",
|
||||||
.group_size = fixup_group_size,
|
.group_size = fixup_group_size,
|
||||||
@ -1573,10 +1598,30 @@ static struct special_section special_sections[] = {
|
|||||||
.name = "__ex_table", /* must come after .fixup */
|
.name = "__ex_table", /* must come after .fixup */
|
||||||
.group_size = ex_table_group_size,
|
.group_size = ex_table_group_size,
|
||||||
},
|
},
|
||||||
|
#ifdef __x86_64__
|
||||||
{
|
{
|
||||||
.name = ".altinstructions",
|
.name = ".altinstructions",
|
||||||
.group_size = altinstructions_group_size,
|
.group_size = altinstructions_group_size,
|
||||||
},
|
},
|
||||||
|
#endif
|
||||||
|
#ifdef __powerpc__
|
||||||
|
{
|
||||||
|
.name = "__ftr_fixup",
|
||||||
|
.group_size = fixup_entry_group_size,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "__mmu_ftr_fixup",
|
||||||
|
.group_size = fixup_entry_group_size,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "__fw_ftr_fixup",
|
||||||
|
.group_size = fixup_entry_group_size,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "__lwsync_fixup",
|
||||||
|
.group_size = fixup_lwsync_group_size,
|
||||||
|
},
|
||||||
|
#endif
|
||||||
{},
|
{},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -180,8 +180,41 @@ gcc_version_check() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
find_special_section_data_ppc64le() {
|
||||||
|
SPECIAL_VARS=$(readelf -wi "$VMLINUX" |
|
||||||
|
gawk --non-decimal-data '
|
||||||
|
BEGIN { f = b = e = 0 }
|
||||||
|
|
||||||
|
# Set state if name matches
|
||||||
|
f == 0 && /DW_AT_name.* fixup_entry[[:space:]]*$/ {f = 1; next}
|
||||||
|
b == 0 && /DW_AT_name.* bug_entry[[:space:]]*$/ {b = 1; next}
|
||||||
|
e == 0 && /DW_AT_name.* exception_table_entry[[:space:]]*$/ {e = 1; next}
|
||||||
|
|
||||||
|
# Reset state unless this abbrev describes the struct size
|
||||||
|
f == 1 && !/DW_AT_byte_size/ { f = 0; next }
|
||||||
|
b == 1 && !/DW_AT_byte_size/ { b = 0; next }
|
||||||
|
e == 1 && !/DW_AT_byte_size/ { e = 0; next }
|
||||||
|
|
||||||
|
# Now that we know the size, stop parsing for it
|
||||||
|
f == 1 {printf("export FIXUP_STRUCT_SIZE=%d\n", $4); a = 2}
|
||||||
|
b == 1 {printf("export BUG_STRUCT_SIZE=%d\n", $4); b = 2}
|
||||||
|
e == 1 {printf("export EX_STRUCT_SIZE=%d\n", $4); e = 2}
|
||||||
|
|
||||||
|
# Bail out once we have everything
|
||||||
|
f == 2 && b == 2 && e == 2 {exit}')
|
||||||
|
|
||||||
|
[[ -n $SPECIAL_VARS ]] && eval "$SPECIAL_VARS"
|
||||||
|
|
||||||
|
[[ -z $FIXUP_STRUCT_SIZE ]] && die "can't find special struct fixup_entry size"
|
||||||
|
[[ -z $BUG_STRUCT_SIZE ]] && die "can't find special struct bug_entry size"
|
||||||
|
[[ -z $EX_STRUCT_SIZE ]] && die "can't find special struct exception_table_entry size"
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
find_special_section_data() {
|
find_special_section_data() {
|
||||||
if [[ $ARCH = "ppc64le" ]]; then
|
if [[ $ARCH = "ppc64le" ]]; then
|
||||||
|
find_special_section_data_ppc64le
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -218,6 +251,7 @@ find_special_section_data() {
|
|||||||
[[ -z $EX_STRUCT_SIZE ]] && die "can't find special struct paravirt_patch_site size"
|
[[ -z $EX_STRUCT_SIZE ]] && die "can't find special struct paravirt_patch_site size"
|
||||||
[[ -z $PARA_STRUCT_SIZE && $CONFIG_PARAVIRT -ne 0 ]] && die "can't find special struct paravirt_patch_site size"
|
[[ -z $PARA_STRUCT_SIZE && $CONFIG_PARAVIRT -ne 0 ]] && die "can't find special struct paravirt_patch_site size"
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
find_parent_obj() {
|
find_parent_obj() {
|
||||||
|
Loading…
Reference in New Issue
Block a user