Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp12074ybf; Wed, 26 Feb 2020 07:59:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwRWc3mBTki8ZMyAp00xhek/rvxPHQLkXxyMDShGBa+sRQ1U/rvvGi4k/nMVbgqrGEZ+rG0 X-Received: by 2002:a9d:6a53:: with SMTP id h19mr3813228otn.120.1582732767123; Wed, 26 Feb 2020 07:59:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582732767; cv=none; d=google.com; s=arc-20160816; b=dFKEryj3IJJASLXk4cnnUNCgVjCBTZauJksHMW3/2UgCvRVb1m0lcx4zXIC9C9BNba CfsWbxvBh4EsSCXr+igWGTGzvkYWCwON5M1+ulY+Y1e9+H883jcC15M4dJbgzH4rwj2x i8cTOcCEeD7W+D4r0VOx5r/+W1j2xxYhDw1/XVuhAn3w9dqIKl3BUyt3tlnwL9ovI2r4 UPW5wYOSwaLi6A8gE1mfNdTOLCXIRLtWPgtn0o3Kf+EW36IpJOggtEYxz/FIhw1rA3fc 2yuPKTQgQXV2GNscpdUbXypozKdLpq3N66dFZkKskQPjC+3JfWTuHY4FKDcrAbGB3VtL PJwg== 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=++DkJ8IwJfOyNmVhXC8+qhEoqR5blkiu1Egz01cM/j4=; b=0NRrmm3PDVh30CCrhPJHUsIXqoY7YFxe2k0DvOPafLoDuzWitT8wjOhMVOzgnBsXYX vB6coq9Hyafs1dvMnYacc8qaeukpGove29cpuStCLN1u5zap/ePMieP9ZHsxMzPSTZex C80FwLD8n57cClh3TKHOgwYukUjSmQOJjjH5mqeYswiLq21taFeLzCA29lLYaVSqLcgq mtyBUzFNgcMu0C4ElGf4dKWj6+SZRmax+VFGrwN/ijNcKAKNAeW97ffYkiH3cuGAIakX 37kR2G8O0x2VC0HxQTmU1ewFPIeQejtxJeo1cxHQ3leSZXHfbKWAV6yyC3Vd/biUV8/k lCWw== 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 t130si1333932oib.202.2020.02.26.07.59.15; Wed, 26 Feb 2020 07:59:27 -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 S1728945AbgBZP6C (ORCPT + 99 others); Wed, 26 Feb 2020 10:58:02 -0500 Received: from foss.arm.com ([217.140.110.172]:38080 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728681AbgBZP5g (ORCPT ); Wed, 26 Feb 2020 10:57:36 -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 3A5204B2; Wed, 26 Feb 2020 07:57:36 -0800 (PST) Received: from localhost (unknown [10.37.6.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 791673F819; Wed, 26 Feb 2020 07:57:35 -0800 (PST) From: Mark Brown To: Catalin Marinas , Will Deacon Cc: Alexander Viro , 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=20Mart=C5=A1enko?= , Thomas Gleixner , Florian Weimer , Sudakshina Das , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, Dave Martin , Mark Brown Subject: [PATCH v7 06/11] arm64: BTI: Decode BYTPE bits when printing PSTATE Date: Wed, 26 Feb 2020 15:57:09 +0000 Message-Id: <20200226155714.43937-7-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200226155714.43937-1-broonie@kernel.org> References: <20200226155714.43937-1-broonie@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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(-) diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index b8e3faa8d406..24af13d7bde6 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); } } -- 2.20.1