[PATCH 1/6] cmd: exception: arm64: fix undefined, add faults
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Sun Jan 9 19:43:29 CET 2022
On 1/9/22 18:30, Andre Przywara wrote:
> The arm64 version of the exception command was just defining the
> undefined exception, but actually copied the AArch32 instruction.
>
> Replace that with an encoding that is guaranteed to be and stay
> undefined. Also add instructions to trigger unaligned access faults and
> a breakpoint.
> This brings ARM64 on par with ARM(32) for the exception command.
>
> Signed-off-by: Andre Przywara <andre.przywara at arm.com>
> ---
> cmd/arm/exception64.c | 42 ++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 38 insertions(+), 4 deletions(-)
>
> diff --git a/cmd/arm/exception64.c b/cmd/arm/exception64.c
> index d5de50a0803..1a9730e6aec 100644
> --- a/cmd/arm/exception64.c
> +++ b/cmd/arm/exception64.c
> @@ -12,14 +12,46 @@ static int do_undefined(struct cmd_tbl *cmdtp, int flag, int argc,
> char *const argv[])
> {
> /*
> - * 0xe7f...f. is undefined in ARM mode
> - * 0xde.. is undefined in Thumb mode
> + * Instructions starting with the upper 16 bits all 0 are permanently
> + * undefined. The lower 16 bits can be used for some kind of immediate.
> + * --- ARMv8 ARM (ARM DDI 0487G.a C6.2.339: "UDF")
What is the title and URL of the document? I could not find it. It would
be good to add this information in the comments.
Best regards
Heinrich
> */
> - asm volatile (".word 0xe7f7defb\n");
> + asm volatile (".word 0x00001234\n");
> +
> + return CMD_RET_FAILURE;
> +}
> +
> +static int do_unaligned(struct cmd_tbl *cmdtp, int flag, int argc,
> + char *const argv[])
> +{
> + /*
> + * The load acquire instruction requires the data source to be
> + * naturally aligned, and will fault even if strict alignment fault
> + * checking is disabled.
> + * --- ARMv8 ARM (ARM DDI 0487G.a B2.5.2: "Alignment of data accesses")
> + */
> + asm volatile (
> + "mov x1, sp\n\t"
> + "orr x1, x1, #3\n\t"
> + "ldar x0, [x1]\n"
> + ::: "x0", "x1" );
> +
> + return CMD_RET_FAILURE;
> +}
> +
> +static int do_breakpoint(struct cmd_tbl *cmdtp, int flag, int argc,
> + char *const argv[])
> +{
> + asm volatile ("brk #123\n");
> +
> return CMD_RET_FAILURE;
> }
>
> static struct cmd_tbl cmd_sub[] = {
> + U_BOOT_CMD_MKENT(breakpoint, CONFIG_SYS_MAXARGS, 1, do_breakpoint,
> + "", ""),
> + U_BOOT_CMD_MKENT(unaligned, CONFIG_SYS_MAXARGS, 1, do_unaligned,
> + "", ""),
> U_BOOT_CMD_MKENT(undefined, CONFIG_SYS_MAXARGS, 1, do_undefined,
> "", ""),
> };
> @@ -27,7 +59,9 @@ static struct cmd_tbl cmd_sub[] = {
> static char exception_help_text[] =
> "<ex>\n"
> " The following exceptions are available:\n"
> - " undefined - undefined instruction\n"
> + " breakpoint - breakpoint instruction exception\n"
> + " unaligned - unaligned LDAR data abort\n"
> + " undefined - undefined instruction exception\n"
> ;
>
> #include <exception.h>
More information about the U-Boot
mailing list