From patchwork Mon Sep 4 12:25:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111560 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1466177qge; Mon, 4 Sep 2017 05:32:03 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6Js4roTuzBMElIbwEIp6Z2ItoLHvbngjaKola943F6KHWGQTLimc4l0PhcYT8m8W7Fvw8W X-Received: by 10.200.58.165 with SMTP id x34mr294070qte.261.1504528323140; Mon, 04 Sep 2017 05:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528323; cv=none; d=google.com; s=arc-20160816; b=NcwcnEOpwEkIpSgxpMAsgiwsmwFRbsMMHGSygnF+iiW6lLa7I5UbhwFdE6C/Nll35E BXWzqEH2I1Wj/le73ZRMebFCGlCIEPSv4WpN9GlYSAz8EbHhB4wIz4Bu92QpS8BoJU6i 5RjUc1vOSf/lxnA6Y+tt3EHV8sJrFUAwmfNeKnntrr1Uz6hiYb0CUxKp72jcy30LysGo +8O0zNHgXzwIe57MfWWkptcs3qTX9k0bTjaUiEKEr4qJKxDJARULgDP2MLLZpgtbJubt ZBHmkodLDkXiuCZzCu15mvCihO0TS/4qpjgJdXZd6yWx6/MhUKoJrJVJ2o9wC7VRCyyM FoFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=ETkFounxx5PIf8YbyyW98PMlGhf2tYvqEt28r/N2oIU=; b=fnfn64XVMtpRdiosfKko8WYSJRJp1RM4vb/2g8PFTdS07gUWjHUMqmJ/BvMLjqnuUK uZBY4OCaqI4hkk/WA9vZfDmuUL01U97aui6wD9736VcbfqtDoBm3FrBPYB2ZeAU/UWFT ezr3eINls2L72t2/2M/QbBhXhqedmyDhXGH8ybM3+P2nrG7e70u9l3ofpM5wJjW93y+l +enFIqbxu7P+MDnWImDUC3+El3MyISGtWT34WlW7i14HESHOyKb4oonhxwDs6wg842Na W6BseW3vcKV89Z7C1TRAEddN4TUsOp4KAvDkplAAN1FIEAP+4Y/BVX1L/ZTnioIo1uww 9CkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m65si5538775qkm.547.2017.09.04.05.32.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:32:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqXp-0000Sh-30 for patch@linaro.org; Mon, 04 Sep 2017 08:32:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSI-0004tp-50 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqS7-0004he-4m for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:18 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37110) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqS6-0004ej-Tm for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:07 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqS5-0005Ts-RL for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:05 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:42 +0100 Message-Id: <1504527967-29248-12-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 11/36] target/arm: Make arm_cpu_dump_state() handle the M-profile XPSR 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Make the arm_cpu_dump_state() debug logging handle the M-profile XPSR rather than assuming it's an A-profile CPSR. On M profile the PSR line of a register dump will now look like this: XPSR=41000000 -Z-- T priv-thread Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias Reviewed-by: Richard Henderson Message-id: 1501692241-23310-12-git-send-email-peter.maydell@linaro.org --- target/arm/translate.c | 58 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 18 deletions(-) -- 2.7.4 diff --git a/target/arm/translate.c b/target/arm/translate.c index 3c14cb0..e52a6d7 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -12215,8 +12215,6 @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; int i; - uint32_t psr; - const char *ns_status; if (is_a64(env)) { aarch64_cpu_dump_state(cs, f, cpu_fprintf, flags); @@ -12230,24 +12228,48 @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, else cpu_fprintf(f, " "); } - psr = cpsr_read(env); - if (arm_feature(env, ARM_FEATURE_EL3) && - (psr & CPSR_M) != ARM_CPU_MODE_MON) { - ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; + if (arm_feature(env, ARM_FEATURE_M)) { + uint32_t xpsr = xpsr_read(env); + const char *mode; + + if (xpsr & XPSR_EXCP) { + mode = "handler"; + } else { + if (env->v7m.control & R_V7M_CONTROL_NPRIV_MASK) { + mode = "unpriv-thread"; + } else { + mode = "priv-thread"; + } + } + + cpu_fprintf(f, "XPSR=%08x %c%c%c%c %c %s\n", + xpsr, + xpsr & XPSR_N ? 'N' : '-', + xpsr & XPSR_Z ? 'Z' : '-', + xpsr & XPSR_C ? 'C' : '-', + xpsr & XPSR_V ? 'V' : '-', + xpsr & XPSR_T ? 'T' : 'A', + mode); } else { - ns_status = ""; - } - - cpu_fprintf(f, "PSR=%08x %c%c%c%c %c %s%s%d\n", - psr, - psr & (1 << 31) ? 'N' : '-', - psr & (1 << 30) ? 'Z' : '-', - psr & (1 << 29) ? 'C' : '-', - psr & (1 << 28) ? 'V' : '-', - psr & CPSR_T ? 'T' : 'A', - ns_status, - cpu_mode_names[psr & 0xf], (psr & 0x10) ? 32 : 26); + uint32_t psr = cpsr_read(env); + const char *ns_status = ""; + + if (arm_feature(env, ARM_FEATURE_EL3) && + (psr & CPSR_M) != ARM_CPU_MODE_MON) { + ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; + } + + cpu_fprintf(f, "PSR=%08x %c%c%c%c %c %s%s%d\n", + psr, + psr & CPSR_N ? 'N' : '-', + psr & CPSR_Z ? 'Z' : '-', + psr & CPSR_C ? 'C' : '-', + psr & CPSR_V ? 'V' : '-', + psr & CPSR_T ? 'T' : 'A', + ns_status, + cpu_mode_names[psr & 0xf], (psr & 0x10) ? 32 : 26); + } if (flags & CPU_DUMP_FPU) { int numvfpregs = 0;