From patchwork Mon Jun 6 18:56:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9159015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3F88860573 for ; Mon, 6 Jun 2016 18:57:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D96128352 for ; Mon, 6 Jun 2016 18:57:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EF5D2835A; Mon, 6 Jun 2016 18:57:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 960A628352 for ; Mon, 6 Jun 2016 18:57:23 +0000 (UTC) Received: from localhost ([::1]:44570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9ziE-0007U0-Re for patchwork-qemu-devel@patchwork.kernel.org; Mon, 06 Jun 2016 14:57:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9zhs-0007SI-Ca for qemu-devel@nongnu.org; Mon, 06 Jun 2016 14:57:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9zhq-0003U3-8H for qemu-devel@nongnu.org; Mon, 06 Jun 2016 14:56:59 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:57512) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9zhq-0003Th-06 for qemu-devel@nongnu.org; Mon, 06 Jun 2016 14:56:58 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1b9zhm-0008OI-Vs; Mon, 06 Jun 2016 19:56:55 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 6 Jun 2016 19:56:54 +0100 Message-Id: <1465239414-4932-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH v2] linux-user: provide frame information in x86-64 safe_syscall X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Richard Henderson , patches@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use cfi directives in the x86-64 safe_syscall to allow gdb to get backtraces right from within it. (In particular this will be quite a common situation if the user interrupts QEMU while it's in a blocked safe-syscall: at the point of the syscall insn RBP is in use for something else, and so gdb can't find the frame then without assistance.) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Richard Henderson --- v1->v2 changes: minor tweaks as requested by rth I was planning to send this in a series with some other safe-syscall code for the other architectures, but I haven't got round to those yet, so might as well send out the fixed version of this by itself. linux-user/host/x86_64/safe-syscall.inc.S | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/linux-user/host/x86_64/safe-syscall.inc.S b/linux-user/host/x86_64/safe-syscall.inc.S index dde434c..e09368d 100644 --- a/linux-user/host/x86_64/safe-syscall.inc.S +++ b/linux-user/host/x86_64/safe-syscall.inc.S @@ -24,6 +24,7 @@ * -1-and-errno-set convention is done by the calling wrapper. */ safe_syscall_base: + .cfi_startproc /* This saves a frame pointer and aligns the stack for the syscall. * (It's unclear if the syscall ABI has the same stack alignment * requirements as the userspace function call ABI, but better safe than @@ -31,6 +32,8 @@ safe_syscall_base: * does not list any ABI differences regarding stack alignment.) */ push %rbp + .cfi_adjust_cfa_offset 8 + .cfi_rel_offset rbp, 0 /* The syscall calling convention isn't the same as the * C one: @@ -70,12 +73,19 @@ safe_syscall_start: safe_syscall_end: /* code path for having successfully executed the syscall */ pop %rbp + .cfi_remember_state + .cfi_def_cfa_offset 8 + .cfi_restore rbp ret return_ERESTARTSYS: /* code path when we didn't execute the syscall */ + .cfi_restore_state mov $-TARGET_ERESTARTSYS, %rax pop %rbp + .cfi_def_cfa_offset 8 + .cfi_restore rbp ret + .cfi_endproc .size safe_syscall_base, .-safe_syscall_base