From patchwork Wed Dec 11 15:42:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 181256 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp700753ile; Wed, 11 Dec 2019 07:43:10 -0800 (PST) X-Google-Smtp-Source: APXvYqwCdcDcPpqApeDl+HuLbaSh4Q2+cOZyT+7aMSRea1xjWKWuVGNvGs0cuCqtWPHaNh1bunCK X-Received: by 2002:a9d:58c9:: with SMTP id s9mr2566817oth.121.1576078990734; Wed, 11 Dec 2019 07:43:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576078990; cv=none; d=google.com; s=arc-20160816; b=KRg4pkH9ULzQtcMKjpt0gtrOPm3ohQoHfyeMNF5Ph6/4BI1sUOekkqJKLVqzrtjBdZ xwMmBnBUSADNryvDDZ9/XWV0q7aZ/WLDsGHdJ+ua9jOrucKroB1jkr5ZviO2qoP5JULW GTWPerfdlKEEh6/Xew5Gf1NygluhDuL6w9bhQS+x2Mnza5nZMxQz9jThzzoyMHCTZy/6 Q94mIckzbluDxOhZlYsGpfzqh1j4hPivh9D4fwySLd9tJTutU1zNzjcnPLRzpphM+JwL qB0EMSzvhYERY+SWkVMzFq+Q/nssaVMObbJFydIr8sVpV575pbi67EpLIQL8+y/naKwU FlEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=S1SnB9EaiC7baDFTFO7cCuMYBobNtYsX6n3JZVtRjjM=; b=BoLp/BaTYlClWgUFC1a6n8USd6DC+0MKq1KYG58hHjvnI1HPUZ/oPEKRpCzBIWaUNi 142hBDzt0ZrS6YkTZ79Zw97/HczcaF5OVsFPmj4Bn/KIyg1gMo1CkKxxD+1+fW1glnzo 7JJ58Q4kqTGxU8eJ4PXhbMKID3R5GlibkQMlnNhxShc/qEvQIsM+b3c9rYbu3XUHCOGF pVEx8rw60G0ui4+SWDFnGVoT4jVAeHNxM1skDhRnDBEsEOjFtMsdcpHzO45vGnupAVn0 VEWzbBfeZN0WpspsDoqeK8QfiW7438XMK8/sxDcS2HclEBzYgIgIzuK9jBL263j00Ao9 sL3g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 185si1340581oie.52.2019.12.11.07.43.10; Wed, 11 Dec 2019 07:43:10 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729315AbfLKPnI (ORCPT + 27 others); Wed, 11 Dec 2019 10:43:08 -0500 Received: from foss.arm.com ([217.140.110.172]:35524 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387912AbfLKPnG (ORCPT ); Wed, 11 Dec 2019 10:43:06 -0500 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 D0D8CDA7; Wed, 11 Dec 2019 07:43:05 -0800 (PST) Received: from localhost (unknown [10.37.6.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2962D3F52E; Wed, 11 Dec 2019 07:43:05 -0800 (PST) From: Mark Brown To: Catalin Marinas , Will Deacon Cc: Paul Elliott , Peter Zijlstra , Yu-cheng Yu , Amit Kachhap , Vincenzo Frascino , Marc Zyngier , Eugene Syromiatnikov , Szabolcs Nagy , "H.J. Lu" , Andrew Jones , Kees Cook , Arnd Bergmann , Jann Horn , Richard Henderson , =?utf-8?q?Kristina_Mart=C5=A1enko?= , Thomas Gleixner , Florian Weimer , Sudakshina Das , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Dave Martin , Mark Brown Subject: [PATCH v4 07/12] arm64: BTI: Decode BYTPE bits when printing PSTATE Date: Wed, 11 Dec 2019 15:42:01 +0000 Message-Id: <20191211154206.46260-8-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191211154206.46260-1-broonie@kernel.org> References: <20191211154206.46260-1-broonie@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Martin 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 Signed-off-by: Mark Brown --- arch/arm64/kernel/process.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 37c508f409ac..e8eb70cd3fa0 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -211,6 +211,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; @@ -229,7 +238,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', @@ -240,7 +252,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); } }