diff mbox

[v2,1/6] lib: Add a generic implementation of current_text_addr()

Message ID 1488995215-7647-2-git-send-email-ross.lagerwall@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ross Lagerwall March 8, 2017, 5:46 p.m. UTC
Remove the unused x86 implementation.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---

Changes in v2:
* Include Clang in the comment.

 xen/common/lib.c                | 12 ++++++++++++
 xen/include/asm-x86/processor.h | 10 ----------
 xen/include/xen/lib.h           |  2 ++
 3 files changed, 14 insertions(+), 10 deletions(-)

Comments

Dario Faggioli March 9, 2017, 8:52 a.m. UTC | #1
On Wed, 2017-03-08 at 17:46 +0000, Ross Lagerwall wrote:
> Remove the unused x86 implementation.
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
>
FWIW,

Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>

Regards,
Dario
Jan Beulich March 9, 2017, 10:29 a.m. UTC | #2
>>> On 08.03.17 at 18:46, <ross.lagerwall@citrix.com> wrote:
> Remove the unused x86 implementation.

Unused or not - what's wrong with it? (I can guess it from the
context of the series, but the justification should be put here.)
After all it's there for debugging purposes, so if it's unused it
also can't cause any issues for LivePatch, can it?

Jan
diff mbox

Patch

diff --git a/xen/common/lib.c b/xen/common/lib.c
index 6233020..7674d3a 100644
--- a/xen/common/lib.c
+++ b/xen/common/lib.c
@@ -501,6 +501,18 @@  void __init init_constructors(void)
 }
 
 /*
+ * The GCC and Clang docs state that the function must be marked noinline to
+ * have the expected result. From the GCC docs:
+ * "When inlining the expected behavior is that the function returns the
+ * address of the function that is returned to. To work around this behavior
+ * use the noinline function attribute."
+ */
+noinline void *current_text_addr(void)
+{
+    return __builtin_return_address(0);
+}
+
+/*
  * Local variables:
  * mode: C
  * c-file-style: "BSD"
diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h
index dda8b83..f9de357 100644
--- a/xen/include/asm-x86/processor.h
+++ b/xen/include/asm-x86/processor.h
@@ -98,16 +98,6 @@ 
 struct domain;
 struct vcpu;
 
-/*
- * Default implementation of macro that returns current
- * instruction pointer ("program counter").
- */
-#define current_text_addr() ({                      \
-    void *pc;                                       \
-    asm ( "leaq 1f(%%rip),%0\n1:" : "=r" (pc) );    \
-    pc;                                             \
-})
-
 struct x86_cpu_id {
     uint16_t vendor;
     uint16_t family;
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index 995a85a..6b4f1e4 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -162,6 +162,8 @@  extern void add_taint(unsigned int taint);
 struct cpu_user_regs;
 void dump_execstate(struct cpu_user_regs *);
 
+void *current_text_addr(void);
+
 void init_constructors(void);
 
 void *bsearch(const void *key, const void *base, size_t num, size_t size,