From patchwork Fri Jan 15 15:24:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 8042691 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8AEFFBEEE5 for ; Fri, 15 Jan 2016 15:24:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D69B120357 for ; Fri, 15 Jan 2016 15:24:40 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id F3D9E202D1 for ; Fri, 15 Jan 2016 15:24:39 +0000 (UTC) Received: from localhost ([::1]:47580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK6Ex-0008Em-A2 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 15 Jan 2016 10:24:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK6EZ-000801-MW for qemu-devel@nongnu.org; Fri, 15 Jan 2016 10:24:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aK6EY-0000vZ-GN for qemu-devel@nongnu.org; Fri, 15 Jan 2016 10:24:15 -0500 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:59462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK6EY-0000u7-8h for qemu-devel@nongnu.org; Fri, 15 Jan 2016 10:24:14 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1aK6EQ-00017L-Cd for qemu-devel@nongnu.org; Fri, 15 Jan 2016 15:24:06 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 15 Jan 2016 15:24:04 +0000 Message-Id: <1452871445-4221-11-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1452871445-4221-1-git-send-email-peter.maydell@linaro.org> References: <1452871445-4221-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 10/11] target-arm: dump-guest-memory: add vfp notes for arm X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andrew Jones gdb won't actually dump these with 'info all-registers' since it first tries to confirm that it should by checking the VFP hwcap in the .auxv note. Well, we don't generate an .auxv note. Signed-off-by: Andrew Jones Reviewed-by: Peter Maydell Message-id: 1452542185-10914-9-git-send-email-drjones@redhat.com Signed-off-by: Peter Maydell --- target-arm/arch_dump.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/target-arm/arch_dump.c b/target-arm/arch_dump.c index d7b63a0..f45125f 100644 --- a/target-arm/arch_dump.c +++ b/target-arm/arch_dump.c @@ -183,15 +183,28 @@ struct arm_elf_prstatus { QEMU_BUILD_BUG_ON(sizeof(struct arm_elf_prstatus) != 148); +/* struct user_vfp from arch/arm/include/asm/user.h */ +struct arm_user_vfp_state { + uint64_t vregs[32]; + uint32_t fpscr; +} QEMU_PACKED; + +QEMU_BUILD_BUG_ON(sizeof(struct arm_user_vfp_state) != 260); + struct arm_note { Elf32_Nhdr hdr; - char name[8]; /* align_up(sizeof("CORE"), 4) */ - struct arm_elf_prstatus prstatus; + char name[8]; /* align_up(sizeof("LINUX"), 4) */ + union { + struct arm_elf_prstatus prstatus; + struct arm_user_vfp_state vfp; + }; } QEMU_PACKED; #define ARM_NOTE_HEADER_SIZE offsetof(struct arm_note, prstatus) #define ARM_PRSTATUS_NOTE_SIZE \ (ARM_NOTE_HEADER_SIZE + sizeof(struct arm_elf_prstatus)) +#define ARM_VFP_NOTE_SIZE \ + (ARM_NOTE_HEADER_SIZE + sizeof(struct arm_user_vfp_state)) static void arm_note_init(struct arm_note *note, DumpState *s, const char *name, Elf32_Word namesz, @@ -206,17 +219,40 @@ static void arm_note_init(struct arm_note *note, DumpState *s, memcpy(note->name, name, namesz); } +static int arm_write_elf32_vfp(WriteCoreDumpFunction f, CPUARMState *env, + int cpuid, DumpState *s) +{ + struct arm_note note; + int ret, i; + + arm_note_init(¬e, s, "LINUX", 6, NT_ARM_VFP, sizeof(note.vfp)); + + for (i = 0; i < 32; ++i) { + note.vfp.vregs[i] = cpu_to_dump64(s, float64_val(env->vfp.regs[i])); + } + + note.vfp.fpscr = cpu_to_dump32(s, vfp_get_fpscr(env)); + + ret = f(¬e, ARM_VFP_NOTE_SIZE, s); + if (ret < 0) { + return -1; + } + + return 0; +} + int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, void *opaque) { struct arm_note note; CPUARMState *env = &ARM_CPU(cs)->env; DumpState *s = opaque; - int ret, i; + int ret, i, fpvalid = !!arm_feature(env, ARM_FEATURE_VFP); arm_note_init(¬e, s, "CORE", 5, NT_PRSTATUS, sizeof(note.prstatus)); note.prstatus.pr_pid = cpu_to_dump32(s, cpuid); + note.prstatus.pr_fpvalid = cpu_to_dump32(s, fpvalid); for (i = 0; i < 16; ++i) { note.prstatus.pr_reg.regs[i] = cpu_to_dump32(s, env->regs[i]); @@ -226,6 +262,8 @@ int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, ret = f(¬e, ARM_PRSTATUS_NOTE_SIZE, s); if (ret < 0) { return -1; + } else if (fpvalid) { + return arm_write_elf32_vfp(f, env, cpuid, s); } return 0; @@ -280,6 +318,8 @@ int cpu_get_dump_info(ArchDumpInfo *info, ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) { + ARMCPU *cpu = ARM_CPU(first_cpu); + CPUARMState *env = &cpu->env; size_t note_size; if (class == ELFCLASS64) { @@ -287,6 +327,9 @@ ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) note_size += AARCH64_PRFPREG_NOTE_SIZE; } else { note_size = ARM_PRSTATUS_NOTE_SIZE; + if (arm_feature(env, ARM_FEATURE_VFP)) { + note_size += ARM_VFP_NOTE_SIZE; + } } return note_size * nr_cpus;