Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E51ACC433F5 for ; Sun, 9 Jan 2022 19:08:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 631B481761; Sun, 9 Jan 2022 20:08:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.b="pfZTL29Q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D2E97830B3; Sun, 9 Jan 2022 20:08:47 +0100 (CET) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A5E3C804C8 for ; Sun, 9 Jan 2022 20:08:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 054E0402EA for ; Sun, 9 Jan 2022 19:08:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1641755324; bh=MzZL6RB2Uig0A3MauuFFnEPfBwIiULVtrlXDI6FItlo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=pfZTL29QX4gvdgHWSBSzEBZUgPKooxS5V/qc/lky3EzWFFmBjRqkM0d1ZgjRN6ZjR pSzV/UwSTNMDWB1xF0/w5OVY8+x3vtXBZ9TmejczyqZJEz0s73mGZmWvvakVLjLpzq /4Gu6LWtOCsUY14llIEh4NrTm0a0kewdrOHr2IJN52SGatUficwrlFrlJC+5Nq1NOi W259bWHM6b4mejE6UpxMfpHrewFO7Ub/UhCC5quVPTfd36EZGEwdYtcCb2Rsx5xdBJ FKjBJcAkJNkeTlwm0yIp7AWFsqrx0xgvxqAFdeXGQ5dhhvYHSwTO+4kapCXV6aWGj6 UuFP9WVgZgpYw== Received: by mail-wm1-f71.google.com with SMTP id n25-20020a05600c3b9900b00348b83fbd0dso502191wms.0 for ; Sun, 09 Jan 2022 11:08:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=MzZL6RB2Uig0A3MauuFFnEPfBwIiULVtrlXDI6FItlo=; b=UN+cKA784zPg4qVPzZxi1o0Z1GAP6JloX2S3UB/FTXqAHUoGbc+O26fpLjodAK8s8o k/Pj0XhsFad4YMcTj96TtH+2KJuAodw9Cu/3/1NbbThr1o0BK5ognGlZ8/1Fk4Ltt8OU VQIHn4rB34CX+EgtjmtakvTwRDRa4ZhRoRAwzhqqHWiV3UazA5tRbekyw/XPWGvo5Icb 6n7Y86jrOUeujul8neU6ZUKrCqPoXcf2kuSC3yx24nwyv1lpiD9PfhljX0OqFf1s2yuq koHKgSnrOJAskRK5iZSrX3Uj98ftZ5NJM2USMfwLHZ3ucAm//YyKFwqmt7wrFv2OsraC gPcw== X-Gm-Message-State: AOAM532aXcptX85vGGhr60AylFzskYwqDw9hQTauD9PN3a4LMx0eNTyN jC/wLetENfc4MdVY0ce2yyvEBXTaTFx8cJrcnSr2/fWMRQ6rxskaofBpZ9XeRGG1F67ugyPX76o 3cmAEhAd3x/SoW8fWD7UEIZ20yA8Ed9s= X-Received: by 2002:a05:6000:1184:: with SMTP id g4mr522838wrx.278.1641755323562; Sun, 09 Jan 2022 11:08:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwtKTHeSQ33D0Y2c8hMj22TitJXl+Rp98lB7vfXBF5/95IoXu5fn4WQ7Mqzmh3Wox0eTt11aA== X-Received: by 2002:a05:6000:1184:: with SMTP id g4mr522825wrx.278.1641755323375; Sun, 09 Jan 2022 11:08:43 -0800 (PST) Received: from [192.168.123.94] (ip-88-152-144-157.hsi03.unitymediagroup.de. [88.152.144.157]) by smtp.gmail.com with ESMTPSA id e13sm4836894wmq.10.2022.01.09.11.08.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 09 Jan 2022 11:08:42 -0800 (PST) Message-ID: <7fd24059-c47a-b7ec-3ecb-7066e33fcdc1@canonical.com> Date: Sun, 9 Jan 2022 20:08:41 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH 1/6] cmd: exception: arm64: fix undefined, add faults Content-Language: en-US To: Andre Przywara , Tom Rini Cc: Simon Glass , Alison Wang , Michael Walle , Nishanth Menon , Priyanka Singh , Peter Hoyes , Marek Vasut , u-boot@lists.denx.de References: <20220109173009.25522-1-andre.przywara@arm.com> <20220109173009.25522-2-andre.przywara@arm.com> From: Heinrich Schuchardt In-Reply-To: <20220109173009.25522-2-andre.przywara@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean 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 > --- > 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") > */ > - 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") According to DI0487G_b_armv8_arm.pdf available at https://developer.arm.com/documentation/ddi0487/latest the generation of an alignment fault for ldar depends on FEAT_LSE2 (Large System Extensions v2) which is mandatory for ARMv8.4. See p. B2-161. Best regards Heinrich > + */ > + 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[] = > "\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