8d56e5c5a9
In the initial release of the ARM Architecture Reference Manual for ARMv8-A, the ESR_ELx registers were defined as 32-bit registers. This changed in 2018 with version D.a (ARM DDI 0487D.a) of the architecture, when they became 64-bit registers, with bits [63:32] defined as RES0. In version G.a, a new field was added to ESR_ELx, ISS2, which covers bits [36:32]. This field is used when the Armv8.7 extension FEAT_LS64 is implemented. As a result of the evolution of the register width, Linux stores it as both a 64-bit value and a 32-bit value, which hasn't affected correctness so far as Linux only uses the lower 32 bits of the register. Make the register type consistent and always treat it as 64-bit wide. The register is redefined as an "unsigned long", which is an unsigned double-word (64-bit quantity) for the LP64 machine (aapcs64 [1], Table 1, page 14). The type was chosen because "unsigned int" is the most frequent type for ESR_ELx and because FAR_ELx, which is used together with ESR_ELx in exception handling, is also declared as "unsigned long". The 64-bit type also makes adding support for architectural features that use fields above bit 31 easier in the future. The KVM hypervisor will receive a similar update in a subsequent patch. [1] https://github.com/ARM-software/abi-aa/releases/download/2021Q3/aapcs64.pdf Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Reviewed-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20220425114444.368693-4-alexandru.elisei@arm.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
104 lines
2.9 KiB
C
104 lines
2.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Based on arch/arm/include/asm/traps.h
|
|
*
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
*/
|
|
#ifndef __ASM_TRAP_H
|
|
#define __ASM_TRAP_H
|
|
|
|
#include <linux/list.h>
|
|
#include <asm/esr.h>
|
|
#include <asm/sections.h>
|
|
|
|
struct pt_regs;
|
|
|
|
struct undef_hook {
|
|
struct list_head node;
|
|
u32 instr_mask;
|
|
u32 instr_val;
|
|
u64 pstate_mask;
|
|
u64 pstate_val;
|
|
int (*fn)(struct pt_regs *regs, u32 instr);
|
|
};
|
|
|
|
void register_undef_hook(struct undef_hook *hook);
|
|
void unregister_undef_hook(struct undef_hook *hook);
|
|
void force_signal_inject(int signal, int code, unsigned long address, unsigned long err);
|
|
void arm64_notify_segfault(unsigned long addr);
|
|
void arm64_force_sig_fault(int signo, int code, unsigned long far, const char *str);
|
|
void arm64_force_sig_mceerr(int code, unsigned long far, short lsb, const char *str);
|
|
void arm64_force_sig_ptrace_errno_trap(int errno, unsigned long far, const char *str);
|
|
|
|
/*
|
|
* Move regs->pc to next instruction and do necessary setup before it
|
|
* is executed.
|
|
*/
|
|
void arm64_skip_faulting_instruction(struct pt_regs *regs, unsigned long size);
|
|
|
|
static inline int __in_irqentry_text(unsigned long ptr)
|
|
{
|
|
return ptr >= (unsigned long)&__irqentry_text_start &&
|
|
ptr < (unsigned long)&__irqentry_text_end;
|
|
}
|
|
|
|
static inline int in_entry_text(unsigned long ptr)
|
|
{
|
|
return ptr >= (unsigned long)&__entry_text_start &&
|
|
ptr < (unsigned long)&__entry_text_end;
|
|
}
|
|
|
|
/*
|
|
* CPUs with the RAS extensions have an Implementation-Defined-Syndrome bit
|
|
* to indicate whether this ESR has a RAS encoding. CPUs without this feature
|
|
* have a ISS-Valid bit in the same position.
|
|
* If this bit is set, we know its not a RAS SError.
|
|
* If its clear, we need to know if the CPU supports RAS. Uncategorized RAS
|
|
* errors share the same encoding as an all-zeros encoding from a CPU that
|
|
* doesn't support RAS.
|
|
*/
|
|
static inline bool arm64_is_ras_serror(unsigned long esr)
|
|
{
|
|
WARN_ON(preemptible());
|
|
|
|
if (esr & ESR_ELx_IDS)
|
|
return false;
|
|
|
|
if (this_cpu_has_cap(ARM64_HAS_RAS_EXTN))
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
* Return the AET bits from a RAS SError's ESR.
|
|
*
|
|
* It is implementation defined whether Uncategorized errors are containable.
|
|
* We treat them as Uncontainable.
|
|
* Non-RAS SError's are reported as Uncontained/Uncategorized.
|
|
*/
|
|
static inline unsigned long arm64_ras_serror_get_severity(unsigned long esr)
|
|
{
|
|
unsigned long aet = esr & ESR_ELx_AET;
|
|
|
|
if (!arm64_is_ras_serror(esr)) {
|
|
/* Not a RAS error, we can't interpret the ESR. */
|
|
return ESR_ELx_AET_UC;
|
|
}
|
|
|
|
/*
|
|
* AET is RES0 if 'the value returned in the DFSC field is not
|
|
* [ESR_ELx_FSC_SERROR]'
|
|
*/
|
|
if ((esr & ESR_ELx_FSC) != ESR_ELx_FSC_SERROR) {
|
|
/* No severity information : Uncategorized */
|
|
return ESR_ELx_AET_UC;
|
|
}
|
|
|
|
return aet;
|
|
}
|
|
|
|
bool arm64_is_fatal_ras_serror(struct pt_regs *regs, unsigned long esr);
|
|
void __noreturn arm64_serror_panic(struct pt_regs *regs, unsigned long esr);
|
|
#endif
|