[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202002261341.D2BB57A@keescook>
Date: Wed, 26 Feb 2020 13:42:01 -0800
From: Kees Cook <keescook@...omium.org>
To: Mark Brown <broonie@...nel.org>
Cc: Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Paul Elliott <paul.elliott@....com>,
Peter Zijlstra <peterz@...radead.org>,
Yu-cheng Yu <yu-cheng.yu@...el.com>,
Amit Kachhap <amit.kachhap@....com>,
Vincenzo Frascino <vincenzo.frascino@....com>,
Marc Zyngier <maz@...nel.org>,
Eugene Syromiatnikov <esyr@...hat.com>,
Szabolcs Nagy <szabolcs.nagy@....com>,
"H . J . Lu " <hjl.tools@...il.com>,
Andrew Jones <drjones@...hat.com>,
Arnd Bergmann <arnd@...db.de>, Jann Horn <jannh@...gle.com>,
Richard Henderson <richard.henderson@...aro.org>,
Kristina Martšenko <kristina.martsenko@....com>,
Thomas Gleixner <tglx@...utronix.de>,
Florian Weimer <fweimer@...hat.com>,
Sudakshina Das <sudi.das@....com>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-arch@...r.kernel.org, linux-fsdevel@...r.kernel.org,
Dave Martin <Dave.Martin@....com>
Subject: Re: [PATCH v7 06/11] arm64: BTI: Decode BYTPE bits when printing
PSTATE
On Wed, Feb 26, 2020 at 03:57:09PM +0000, Mark Brown wrote:
> From: Dave Martin <Dave.Martin@....com>
>
> 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 <Dave.Martin@....com>
Reviewed-by: Kees Cook <keescook@...omium.org>
-Kees
> Signed-off-by: Mark Brown <broonie@...nel.org>
> ---
> 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
>
--
Kees Cook
Powered by blists - more mailing lists