xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: konrad@kernel.org, xen-devel@lists.xenproject.org
Cc: Ross Lagerwall <ross.lagerwall@citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH v2 3/3] livepatch: Sync cache of build-id before using it first time.
Date: Thu,  4 Aug 2016 11:49:24 -0400	[thread overview]
Message-ID: <1470325764-12566-4-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1470325764-12566-1-git-send-email-konrad.wilk@oracle.com>

We don't print at bootup time the build-id. The reason is
that xen_build_init and livepatch_init are both __initcall
type routines. This meant that when livepatch_init called
xen_build_id, it would return -ENODATA as build_id_len was
not setup yet (b/c xen_build_init would be called later).

We fix this by calling xen_build_init in livepatch_init which
allows us to print the build-id of the hypervisor.

We also keep xen_build_init as __initcall because build-id
can be built without livepatching being enabled (so
no livepatch_init being called).

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

---
Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
---
 xen/common/livepatch.c      | 1 +
 xen/common/version.c        | 6 +++++-
 xen/include/xen/livepatch.h | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
index f6dbd51..88a79d8 100644
--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -1597,6 +1597,7 @@ static int __init livepatch_init(void)
     const void *binary_id;
     unsigned int len;
 
+    xen_build_init();
     if ( !xen_build_id(&binary_id, &len) )
         printk(XENLOG_INFO LIVEPATCH ": build-id: %*phN\n", len, binary_id);
 
diff --git a/xen/common/version.c b/xen/common/version.c
index 0f96849..4114664 100644
--- a/xen/common/version.c
+++ b/xen/common/version.c
@@ -117,11 +117,15 @@ int xen_build_id_check(const Elf_Note *n, unsigned int n_sz,
     return 0;
 }
 
-static int __init xen_build_init(void)
+int __init xen_build_init(void)
 {
     const Elf_Note *n = __note_gnu_build_id_start;
     unsigned int sz;
 
+    /* We may have been called already. */
+    if ( build_id_len )
+        return 0;
+
     /* --build-id invoked with wrong parameters. */
     if ( __note_gnu_build_id_end <= &n[0] )
         return -ENODATA;
diff --git a/xen/include/xen/livepatch.h b/xen/include/xen/livepatch.h
index ed49843..cfc9601 100644
--- a/xen/include/xen/livepatch.h
+++ b/xen/include/xen/livepatch.h
@@ -44,7 +44,7 @@ unsigned long livepatch_symbols_lookup_by_name(const char *symname);
 bool_t is_patch(const void *addr);
 int xen_build_id_check(const Elf_Note *n, unsigned int n_sz,
                        const void **p, unsigned int *len);
-
+void xen_build_init(void);
 /* Arch hooks. */
 int arch_livepatch_verify_elf(const struct livepatch_elf *elf);
 int arch_livepatch_perform_rel(struct livepatch_elf *elf,
-- 
2.5.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-08-04 15:50 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04 15:49 [PATCH v1] Livepatch patches for v4.8 (v1) Konrad Rzeszutek Wilk
2016-08-04 15:49 ` [PATCH v2 1/3] livepach: Add .livepatch.hooks functions and test-case Konrad Rzeszutek Wilk
2016-08-05 15:35   ` Jan Beulich
2016-08-05 21:08     ` Konrad Rzeszutek Wilk
2016-08-08  6:23       ` Jan Beulich
2016-08-09 18:01         ` Konrad Rzeszutek Wilk
2016-08-10  9:46           ` Jan Beulich
2016-08-11  1:20             ` Konrad Rzeszutek Wilk
2016-08-11  8:52             ` Jan Beulich
2016-08-11 10:56               ` Ian Jackson
2016-08-11 11:13                 ` Jan Beulich
2016-08-08 13:42     ` George Dunlap
2016-08-08 14:01       ` Jan Beulich
2016-08-08 14:10         ` George Dunlap
2016-08-08 15:15           ` Jan Beulich
2016-08-08 16:07             ` Andrew Cooper
2016-08-04 15:49 ` [PATCH v2 2/3] symbols: Generate an xen-sym.map Konrad Rzeszutek Wilk
2016-08-04 19:24   ` Konrad Rzeszutek Wilk
2016-08-05 15:56   ` Jan Beulich
2016-08-04 15:49 ` Konrad Rzeszutek Wilk [this message]
2016-08-05 15:40   ` [PATCH v2 3/3] livepatch: Sync cache of build-id before using it first time Jan Beulich
2016-08-05 20:53     ` Konrad Rzeszutek Wilk
2016-08-08  6:26       ` Jan Beulich

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=1470325764-12566-4-git-send-email-konrad.wilk@oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=konrad@kernel.org \
    --cc=ross.lagerwall@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /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).