[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 5/6] x86_emulate: Remove dependency on __LINE__ for release builds



When using LivePatch, use of __LINE__ can generate spurious changes in
functions due to embedded line numbers.  For release builds with
LivePatch enabled, remove the use of these line numbers and print the
current text address instead.

Signed-off-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
---
 xen/arch/x86/x86_emulate/x86_emulate.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c 
b/xen/arch/x86/x86_emulate/x86_emulate.c
index 613648e..cf05544 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -776,6 +776,22 @@ do{ asm volatile (                                         
             \
 #define __emulate_1op_8byte(_op, _dst, _eflags)
 #endif /* __i386__ */
 
+#if defined(NDEBUG) && defined(CONFIG_LIVEPATCH)
+#define invoke_stub_exception(trapnr, ec)                                   \
+    do {                                                                    \
+        gprintk(XENLOG_WARNING,                                             \
+                "exception %u (ec=%04x) in emulation stub (address %pS)\n", \
+                trapnr, ec, current_text_addr());                           \
+    } while (0)
+#else
+#define invoke_stub_exception(trapnr, ec)                                   \
+    do {                                                                    \
+        gprintk(XENLOG_WARNING,                                             \
+                "exception %u (ec=%04x) in emulation stub (line %u)\n",     \
+                trapnr, ec, __LINE__);                                      \
+    } while (0)
+#endif
+
 #ifdef __XEN__
 # define invoke_stub(pre, post, constraints...) do {                    \
     union stub_exception_token res_ = { .raw = ~0 };                    \
@@ -791,9 +807,7 @@ do{ asm volatile (                                          
            \
                      [stub] "rm" (stub.func) );                         \
     if ( unlikely(~res_.raw) )                                          \
     {                                                                   \
-        gprintk(XENLOG_WARNING,                                         \
-                "exception %u (ec=%04x) in emulation stub (line %u)\n", \
-                res_.fields.trapnr, res_.fields.ec, __LINE__);          \
+        invoke_stub_exception(res_.fields.trapnr, res_.fields.ec);      \
         gprintk(XENLOG_INFO, "stub: %"__stringify(MAX_INST_LEN)"ph\n",  \
                 stub.func);                                             \
         generate_exception_if(res_.fields.trapnr == EXC_UD, EXC_UD);    \
-- 
2.7.4


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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.