From: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
live-patching@vger.kernel.org,
Josh Poimboeuf <jpoimboe@redhat.com>,
Balbir Singh <bsingharora@gmail.com>,
"Naveen N . Rao" <naveen.n.rao@linux.vnet.ibm.com>,
Jessica Yu <jeyu@kernel.org>,
Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>,
Aravinda Prasad <aravinda@linux.vnet.ibm.com>,
Torsten Duwe <duwe@lst.de>
Subject: [PATCH v4 1/3] kernel/modules: Add REL24 relocation support of livepatch symbols
Date: Tue, 14 Nov 2017 04:29:08 -0500 [thread overview]
Message-ID: <20171114092910.20399-2-kamalesh@linux.vnet.ibm.com> (raw)
In-Reply-To: <20171114092910.20399-1-kamalesh@linux.vnet.ibm.com>
Livepatch re-uses module loader function apply_relocate_add() to write
relocations, instead of managing them by arch-dependent
klp_write_module_reloc() function.
apply_relocate_add() doesn't understand livepatch symbols (marked with
SHN_LIVEPATCH symbol section index) and assumes them to be local symbols
by default for R_PPC64_REL24 relocation type. It fails with an error,
when trying to calculate offset with local_entry_offset():
module_64: kpatch_meminfo: REL24 -1152921504897399800 out of range!
Whereas livepatch symbols are essentially SHN_UNDEF, should be
called via stub used for global calls. This issue can be fixed by
teaching apply_relocate_add() to handle both SHN_UNDEF/SHN_LIVEPATCH
symbols via the same stub. This patch extends SHN_UNDEF code to handle
livepatch symbols too.
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
CC: Balbir Singh <bsingharora@gmail.com>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Jessica Yu <jeyu@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
Cc: Torsten Duwe <duwe@lst.de>
---
arch/powerpc/kernel/module_64.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 0b0f896..39b01fd 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -613,7 +613,8 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
case R_PPC_REL24:
/* FIXME: Handle weak symbols here --RR */
- if (sym->st_shndx == SHN_UNDEF) {
+ if (sym->st_shndx == SHN_UNDEF ||
+ sym->st_shndx == SHN_LIVEPATCH) {
/* External: go via stub */
value = stub_for_addr(sechdrs, value, me);
if (!value)
--
2.9.3
next prev parent reply other threads:[~2017-11-14 9:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-14 9:29 [PATCH v4 0/3] ppc64le: Add REL24 relocation support of livepatch symbols Kamalesh Babulal
2017-11-14 9:29 ` Kamalesh Babulal [this message]
2017-12-12 11:39 ` [v4, 1/3] kernel/modules: " Michael Ellerman
2017-11-14 9:29 ` [PATCH v4 2/3] powerpc/modules: Don't try to restore r2 after a sibling call Kamalesh Babulal
2017-11-14 10:29 ` Naveen N. Rao
2017-11-14 15:53 ` Josh Poimboeuf
2017-11-15 5:38 ` Kamalesh Babulal
2017-11-15 9:28 ` Naveen N. Rao
2017-11-16 1:26 ` Josh Poimboeuf
2017-11-16 13:09 ` Naveen N. Rao
2017-11-16 17:45 ` [PATCH v4.2] " Josh Poimboeuf
2017-11-17 8:17 ` Kamalesh Babulal
2017-11-18 8:33 ` Naveen N. Rao
2017-12-12 11:39 ` [v4.2] " Michael Ellerman
2017-11-14 9:29 ` [PATCH v4 3/3] powerpc/modules: Improve restore_r2() error message Kamalesh Babulal
2017-12-06 4:32 ` Michael Ellerman
2017-12-12 11:39 ` [v4,3/3] " Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171114092910.20399-2-kamalesh@linux.vnet.ibm.com \
--to=kamalesh@linux.vnet.ibm.com \
--cc=ananth@linux.vnet.ibm.com \
--cc=aravinda@linux.vnet.ibm.com \
--cc=bsingharora@gmail.com \
--cc=duwe@lst.de \
--cc=jeyu@kernel.org \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=live-patching@vger.kernel.org \
--cc=mpe@ellerman.id.au \
--cc=naveen.n.rao@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).