From patchwork Fri May 24 10:25:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 165102 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp3384551ili; Fri, 24 May 2019 03:26:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvQpCuDYDww/4AeOcmwnCHyTT7LCnlN6EfilyEfKQx8Ptub9SsyTqd+zNv3WnblCrHvVh/ X-Received: by 2002:a63:e645:: with SMTP id p5mr103812838pgj.4.1558693605803; Fri, 24 May 2019 03:26:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558693605; cv=none; d=google.com; s=arc-20160816; b=jjt5ZBqNiGhqot+TQ0g4GZ6uLZ4l1LhY1L7i5Sc/MMS4E4ZzSwow99cqgo6pN1GbAt zfu0lsKOF9rpdm+9JXcY5aBQpIrSG1p2E6GL+Cc8D2nOrWdCXEoogf2m6BSxTkkzfKNh X8KR04jzlTBa6xcuLtSS8NWBugWfiyFY3S/6+zzmYVsHxgFr4Ifl3XPtx8ZjFZGNcxxa eBCKVZn4Kj5hEO4UJ3kWXYRe3XzKNrGe8JVFurGNiVAZKabegp0hSRRkTipO+0cmyzxb M6mZpzCQ6ACv4YZUY7t91vQNHEwnjq/sNSjSuyRVWdes7xQ8sj9GTK47Tv7yx8XX01Sx kDkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=PR9MnhVr1aYy+Ys3/ZdiAx07GuT/CLOTijM0XW4sbbQ=; b=LkGi+bYfMAkU/siwxyFP3OOzub2cPLBT9B6jomUVZUakBKPPxKmOi0radQE58QPThp EdSZnLDO09fU2QH7vJdGXXwkNPcBRuYGy6Lvl247T5QO8tjgoikiy8H9mezQlL71VBb1 mSJGEEaX0y1uguWSS2/hZ30203dhA9LvBOqXrQLoc10xD0mI+/ZWMYw7HPxN9+DS5yCN pZUxiMh2xIs2HEM/eSMhSE6VSlUz1Ej4HO3GQAeYy5vZxSem1rZigiwx5EtG2K2vH5GT mj/+3oJzXRH1J/5HLdMQ5gW/peSfUjJuEQEvcM/z0hyJOCKlZUvJ8rXWqAiLvlrO/56d dykw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x65si3726705pfd.44.2019.05.24.03.26.45; Fri, 24 May 2019 03:26:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390721AbfEXK0o (ORCPT + 30 others); Fri, 24 May 2019 06:26:44 -0400 Received: from foss.arm.com ([217.140.101.70]:39318 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390672AbfEXK0m (ORCPT ); Fri, 24 May 2019 06:26:42 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 867CFA78; Fri, 24 May 2019 03:26:41 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4DEF03F703; Fri, 24 May 2019 03:26:39 -0700 (PDT) From: Dave Martin To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Yu-cheng Yu , "H.J. Lu" , Arnd Bergmann , Richard Henderson , Andrew Jones , Will Deacon , Catalin Marinas , =?utf-8?q?Kristina_Mart=C5=A1enko?= , Szabolcs Nagy , Sudakshina Das , Paul Elliott Subject: [PATCH 8/8] arm64: BTI: Decode BYTPE bits when printing PSTATE Date: Fri, 24 May 2019 11:25:33 +0100 Message-Id: <1558693533-13465-9-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1558693533-13465-1-git-send-email-Dave.Martin@arm.com> References: <1558693533-13465-1-git-send-email-Dave.Martin@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current code to print PSTATE symbolically when generating backtraces etc., does not include the BYTPE field used by Branch Target Identification. So, decode BYTPE and print it too. In the interests of human-readability, print the classes of BTI matched. The symbolic motation, BYTPE (PSTATE[11:10]) and permitted classes of subsequent instruction are: -- (BTYPE=0b00): any insn jc (BTYPE=0b01): BTI jc, BTI j, BTI c, PACIxSP -c (BYTPE=0b10): BTI jc, BTI c, PACIxSP j- (BTYPE=0b11): BTI jc, BTI j Signed-off-by: Dave Martin --- arch/arm64/include/asm/ptrace.h | 4 +++- arch/arm64/kernel/process.c | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) -- 2.1.4 diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h index b868ef11..f91e51c 100644 --- a/arch/arm64/include/asm/ptrace.h +++ b/arch/arm64/include/asm/ptrace.h @@ -40,8 +40,10 @@ #define GIC_PRIO_IRQOFF (GIC_PRIO_IRQON & ~0x80) /* Additional SPSR bits not exposed in the UABI */ +#define PSR_BTYPE_SHIFT 10 + #define PSR_IL_BIT (1 << 20) -#define PSR_BTYPE_CALL (2 << 10) +#define PSR_BTYPE_CALL (2 << PSR_BTYPE_SHIFT) /* AArch32-specific ptrace requests */ #define COMPAT_PTRACE_GETREGS 12 diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 104b0d8..dde5c40 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -236,7 +236,11 @@ static void print_pstate(struct pt_regs *regs) pstate & PSR_AA32_I_BIT ? 'I' : 'i', pstate & PSR_AA32_F_BIT ? 'F' : 'f'); } else { - printk("pstate: %08llx (%c%c%c%c %c%c%c%c %cPAN %cUAO)\n", + static const char *const btypes[] = { "--", "jc", "-c", "j-" }; + const char *btype_str = btypes[(pstate & PSR_BTYPE_MASK) >> + PSR_BTYPE_SHIFT]; + + printk("pstate: %08llx (%c%c%c%c %c%c%c%c %cPAN %cUAO BTYPE=%s)\n", pstate, pstate & PSR_N_BIT ? 'N' : 'n', pstate & PSR_Z_BIT ? 'Z' : 'z', @@ -247,7 +251,8 @@ static void print_pstate(struct pt_regs *regs) pstate & PSR_I_BIT ? 'I' : 'i', pstate & PSR_F_BIT ? 'F' : 'f', pstate & PSR_PAN_BIT ? '+' : '-', - pstate & PSR_UAO_BIT ? '+' : '-'); + pstate & PSR_UAO_BIT ? '+' : '-', + btype_str); } }