S390x kpatch support by sumanthkorikkar · Pull Request #1203 · dynup/kpatch (original) (raw)

Conversation

This file contains hidden or 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

[ Show hidden characters]({{ revealButtonHref }})

sumanthkorikkar

joe-lawrence

joe-lawrence

keiya-nobuta added a commit to keiya-nobuta/kpatch that referenced this pull request

Oct 6, 2021

@keiya-nobuta

keiya-nobuta added a commit to keiya-nobuta/kpatch that referenced this pull request

Oct 6, 2021

@keiya-nobuta

This commit is still dirty because I'm jumbling cut & pasted referring to dynup#1010 and dynup#1203.

Vasily Gorbik and others added 6 commits

May 20, 2022 15:50

@sumanthkorikkar

symtab_read tries to skip '.dynsym' symbol table and only read '.symtab' symbol table. Newer readelf from binutils 2.37 now adds section names (see the diff):

--- vmlinux.symtab 2022-02-18 02:10:06.691220932 +0100 +++ vmlinux.symtab.new 2022-02-18 01:16:06.161210458 +0100 Symbol table '.dynsym' contains 1541 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000100000 0 SECTION LOCAL DEFAULT 1 .text 2: 00000000017a3ac0 4 OBJECT GLOBAL DEFAULT 19 sclp_console_pages Symbol table '.symtab' contains 159980 entries: Num: Value Size Type Bind Vis Ndx Name

...

... 54: 0000000000000000 0 FILE LOCAL DEFAULT ABS main.c

Simple matching of ".dynsym" in the line buffer is not enough anymore, because it hits not just

Symbol table '.dynsym' contains 1541 entries:

line, but also

41: 0000000001a93600     0 SECTION LOCAL  DEFAULT   41 .dynsym

skipping the rest of the file and leading to an error:

create-diff-object: ERROR: *.o: find_local_syms: 189: couldn't find matching *.c local symbols in vmlinux symbol table

Limit matching only to lines containing "Symbol table" header. This works with readelf from the binutils, as well as readelf from elfutils (its output looks slightly different).

Symbol table [41] '.dynsym' contains 1541 entries:

Signed-off-by: Vasily Gorbik gor@linux.ibm.com

@sumanthkorikkar

  1. -mno-pic-data-is-text-relative prevents relative addressing between code and data. This is needed to avoid relocation error when klp text and data are too far apart

  2. Avoid generation of LANCHOR symbols through -fno-section-anchors. kpatch-build does not handle it well.

Signed-off-by: Sumanth Korikkar sumanthk@linux.ibm.com

@sumanthkorikkar

Signed-off-by: Sumanth Korikkar sumanthk@linux.ibm.com

@sumanthkorikkar

Add object exclusion for s390

Signed-off-by: Sumanth Korikkar sumanthk@linux.ibm.com

@sumanthkorikkar

  1. static const struct inet_sock fake_sk = { /* makes ip6_route_output set RT6_LOOKUP_F_IFACE: */ .sk.sk_bound_dev_if = 1, .pinet6 = (struct ipv6_pinfo *) &fake_pinfo, };

gcc can place fake_sk in .data.rel.ro.local: ndx 38, data 0x3ffb3280a58, size 960, name .data.rel.ro.local.fake_sk.1 ndx 39, data 0x3ffb32be5e8, size 24, name .rela.data.rel.ro.local.fake_sk.1

  1. static LIST_HEAD(patch_objects);

gcc can place patch_objects relocation in .data.rel.local: sym 56, type 1, bind 0, ndx 34, name patch_objects -> .data.rel.local

Signed-off-by: Sumanth Korikkar sumanthk@linux.ibm.com

@sumanthkorikkar

Signed-off-by: Sumanth Korikkar sumanthk@linux.ibm.com

jpoimboe

@sumanthkorikkar

Signed-off-by: Sumanth Korikkar sumanthk@linux.ibm.com

jpoimboe

This was referenced

Jun 16, 2022

fengjixuchui added a commit to fengjixuchui/kpatch that referenced this pull request

Jul 3, 2022

@fengjixuchui

Merge pull request dynup#1203 from sumanthkorikkar/s390x-kpatch-support

bella485 pushed a commit to bella485/centos-stream-9 that referenced this pull request

May 1, 2024

Upstream-status: RHEL-only Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2072713

s390x support in upstream kpatch tooling will have a requirement on thunk-extern [1] as "external" expoline code will simplify binary ELF comparison and generation of kpatch kernel modules.

Turning on CONFIG_EXPOLINE_EXTERN will place expolines in arch/s390/lib/expoline.o, which must be available to any out-of-tree module build. Ship the file in the -devel package if it is found.

[1] dynup/kpatch#1203 (comment)

Signed-off-by: C. Erastus Toe ctoe@redhat.com