From patchwork Fri Oct 18 17:25:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 176912 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1160486ill; Fri, 18 Oct 2019 10:27:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyK/KSXrBNU4Mwk0sBG9VoRzFSJt2dkwho1Fx9xOKIMHKgUPspo0EPkl+ldxkvyHXde7JMi X-Received: by 2002:a17:906:5fc1:: with SMTP id k1mr10035855ejv.268.1571419659369; Fri, 18 Oct 2019 10:27:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571419659; cv=none; d=google.com; s=arc-20160816; b=JHvLIEusmxEQsPkAJYotUKhsalFo2iV9jrLkGLnp9IxFQLkiWx95O2moeLdDCOrUoa epyCJYsohbMG52FF/rnPnWGkHXls/6zDXX3rt7yFfdc50UqgALKX54q+im4HuY6+lwgX Fz/b6Q3Ze1oag5wNvQYOS68VvtJ47GVeBkw2SarxQb6O+uIrDt4WgtffEOjYbDNHsygB ifwX3mpyK9DvjfiXGUUOeNoTMm75EkBjC1jvakHqWR1Qv8U4Rv5fjZBANYIyvE51kUTq Njza4wwb+2GLxYIjRzxkm3uZyl7WpLmzBIBUPfSFABlEsy7blQwkFk/Y/dbY1+z86P2e 3DEQ== 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=O2mohHlD/qYLMVnYlc9ECkLgnYUEQoeh7tCTKIZ05is=; b=r1N9IOcufVZCnfAHEhmLyWtsJkm4Gi5nRO7aAoITau875Cvg6YdYhdm4Yf7dymK4Vt OSQShB6t+IHLrIK9qqCk75J3kpYWOMZFI4pyTOBMJXPwzq/HP+b3WHo1xQRT/nbveEJb SHqjL0Nf76dGsyfhPhXqnmwm0I9AAI9bUrNgx5NJoze0MFiYIvTXaEkbdg/uXbb5peDL zpIVqDcK4kT3N/1zyhkDqO/RGFdF1P5Pjbpp4d316qrZII58hLTRyPzfrPAgGrhpbWbK Obs0WyvAaH4APrTABwtQZRDtL1X7hntG1/z5iQgG2VW8uNBzDJXNOtUSNWMBKFr1XnEG yJOw== 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 z6si4362984edm.316.2019.10.18.10.27.39; Fri, 18 Oct 2019 10:27:39 -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 S2634503AbfJRR1g (ORCPT + 26 others); Fri, 18 Oct 2019 13:27:36 -0400 Received: from [217.140.110.172] ([217.140.110.172]:47182 "EHLO foss.arm.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S2505496AbfJRR1c (ORCPT ); Fri, 18 Oct 2019 13:27:32 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6EC4B143B; Fri, 18 Oct 2019 10:26:59 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A2CA73F718; Fri, 18 Oct 2019 10:26:56 -0700 (PDT) From: Dave Martin To: linux-kernel@vger.kernel.org Cc: Andrew Jones , Arnd Bergmann , Catalin Marinas , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Kees Cook , =?utf-8?q?Kristina_Mart=C5=A1enko?= , Marc Zyngier , Mark Brown , Paul Elliott , Peter Zijlstra , Richard Henderson , Sudakshina Das , Szabolcs Nagy , Thomas Gleixner , Will Deacon , Yu-cheng Yu , Amit Kachhap , Vincenzo Frascino , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 08/12] arm64: BTI: Decode BYTPE bits when printing PSTATE Date: Fri, 18 Oct 2019 18:25:41 +0100 Message-Id: <1571419545-20401-9-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1571419545-20401-1-git-send-email-Dave.Martin@arm.com> References: <1571419545-20401-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 notation, 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 --- Changes since v2: * Split out the PSR_BYTPE_* definitions that for merging into "arm64: Basic Branch Target Identification support". --- arch/arm64/kernel/process.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) -- 2.1.4 diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 4c78937..a2b555a 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -209,6 +209,15 @@ void machine_restart(char *cmd) while (1); } +#define bstr(suffix, str) [PSR_BTYPE_ ## suffix >> PSR_BTYPE_SHIFT] = str +static const char *const btypes[] = { + bstr(NONE, "--"), + bstr( JC, "jc"), + bstr( C, "-c"), + bstr( J , "j-") +}; +#undef bstr + static void print_pstate(struct pt_regs *regs) { u64 pstate = regs->pstate; @@ -227,7 +236,10 @@ 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", + 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', @@ -238,7 +250,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); } }