From: Andrew Cooper Subject: [PATCH 5/6] xen/x86: Avoid using local labels for UNLIKELY() regions Date: Fri, 30 Oct 2015 19:59:23 +0000 Message-ID: <1446235164-29421-6-git-send-email-andrew.cooper3@citrix.com> References: <1446235164-29421-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1446235164-29421-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Andrew Cooper , Jan Beulich List-Id: xen-devel@lists.xenproject.org Using local labels causes the stack trace to use the last non-local label emitted by the compiler in the translation unit, which is almost always unrelated. e.g. A (contrived debug) example switches from: (XEN) ----[ Xen-4.7-unstable x86_64 debug=y Not tainted ]---- (XEN) CPU: 0 (XEN) RIP: e008:[] asm_domain_crash_synchronous+0x44/0x4c ... (XEN) Xen call trace: (XEN) [] asm_domain_crash_synchronous+0x44/0x4c (XEN) [] handle_keypress+0xa4/0xd9 to: (XEN) ----[ Xen-4.7-unstable x86_64 debug=y Not tainted ]---- (XEN) CPU: 0 (XEN) RIP: e008:[] unlikely.vmptrld.921+0/0x8 ... (XEN) Xen call trace: (XEN) [] unlikely.vmptrld.921+0/0x8 (XEN) [] handle_keypress+0xa4/0xd9 which is far more relevant when identifying %eip. Additionally, correct the inclusion of the tag parameter in the C UNLIKELY blocks, to use the passed tag, rather than a literal ".tag". Signed-off-by: Andrew Cooper --- CC: Jan Beulich It is not obvious from the documentation whether an expansion of %= is unique to the current translation unit, or entire linked binary; I suspect the former. There are no duplicate symbols introduced by this change in my current compile, but I realise that this is hardly a guarantee. --- xen/include/asm-x86/asm_defns.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/include/asm-x86/asm_defns.h b/xen/include/asm-x86/asm_defns.h index 95ea21d..1028375 100644 --- a/xen/include/asm-x86/asm_defns.h +++ b/xen/include/asm-x86/asm_defns.h @@ -95,9 +95,9 @@ void ret_from_intr(void); #define UNLIKELY_START(cond, tag) \ .Ldispatch.tag: \ - j##cond .Lunlikely.tag; \ + j##cond unlikely.tag; \ .subsection 1; \ - .Lunlikely.tag: + unlikely.tag: #define UNLIKELY_DISPATCH_LABEL(tag) \ .Ldispatch.tag @@ -153,15 +153,15 @@ void ret_from_intr(void); #endif -#define UNLIKELY_START(cond, tag) \ - "j" #cond " .Lunlikely%=.tag;\n\t" \ - UNLIKELY_START_SECTION "\n" \ - ".Lunlikely%=.tag:" +#define UNLIKELY_START(cond, tag) \ + "j" #cond " unlikely." #tag ".%=;\n\t" \ + UNLIKELY_START_SECTION "\n" \ + "unlikely." #tag ".%=:" #define UNLIKELY_END(tag) \ - "jmp .Llikely%=.tag;\n\t" \ + "jmp .Llikely." #tag ".%=;\n\t" \ UNLIKELY_END_SECTION "\n" \ - ".Llikely%=.tag:" + ".Llikely." #tag ".%=:" #endif -- 2.1.4