|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v4 5/9] livepatch: Move code from prepare_payload to own routine
Specifically the code that is looking up f->old_addr - which
can be in its own routine instead of having it part of prepare_payload.
No functional change.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
---
Cc: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
v3: First submission.
v4: Added const to last parameter of livepatch_symbols_lookup function.
Rename function to resolve_old_address
Move comment describing function purpose above function
---
xen/common/livepatch.c | 44 +++++++++++++++++++++++++++-----------------
1 file changed, 27 insertions(+), 17 deletions(-)
diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
index bd65712..e5968a7 100644
--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -233,6 +233,30 @@ static const char *livepatch_symbols_lookup(unsigned long
addr,
return n;
}
+/* Lookup function's old address if not already resolved. */
+static int resolve_old_address(struct livepatch_func *f,
+ const struct livepatch_elf *elf)
+{
+ if ( f->old_addr )
+ return 0;
+
+ f->old_addr = (void *)symbols_lookup_by_name(f->name);
+ if ( !f->old_addr )
+ {
+ f->old_addr = (void *)livepatch_symbols_lookup_by_name(f->name);
+ if ( !f->old_addr )
+ {
+ dprintk(XENLOG_ERR, LIVEPATCH "%s: Could not resolve old address
of %s\n",
+ elf->name, f->name);
+ return -ENOENT;
+ }
+ }
+ dprintk(XENLOG_DEBUG, LIVEPATCH "%s: Resolved old address %s => %p\n",
+ elf->name, f->name, f->old_addr);
+
+ return 0;
+}
+
static struct payload *find_payload(const char *name)
{
struct payload *data, *found = NULL;
@@ -525,23 +549,9 @@ static int prepare_payload(struct payload *payload,
if ( rc )
return rc;
- /* Lookup function's old address if not already resolved. */
- if ( !f->old_addr )
- {
- f->old_addr = (void *)symbols_lookup_by_name(f->name);
- if ( !f->old_addr )
- {
- f->old_addr = (void
*)livepatch_symbols_lookup_by_name(f->name);
- if ( !f->old_addr )
- {
- dprintk(XENLOG_ERR, LIVEPATCH "%s: Could not resolve old
address of %s\n",
- elf->name, f->name);
- return -ENOENT;
- }
- }
- dprintk(XENLOG_DEBUG, LIVEPATCH "%s: Resolved old address %s =>
%p\n",
- elf->name, f->name, f->old_addr);
- }
+ rc = resolve_old_address(f, elf);
+ if ( rc )
+ return rc;
}
sec = livepatch_elf_sec_by_name(elf, ELF_BUILD_ID_NOTE);
--
2.4.11
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |