From nobody Sat Nov 2 12:17:25 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; dkim=fail spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1490043198316843.531747850214; Mon, 20 Mar 2017 13:53:18 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6CB4680471; Mon, 20 Mar 2017 13:53:16 -0700 (PDT) Received: from mail-wm0-x230.google.com (mail-wm0-x230.google.com [IPv6:2a00:1450:400c:c09::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B6A0C80470 for ; Mon, 20 Mar 2017 13:53:14 -0700 (PDT) Received: by mail-wm0-x230.google.com with SMTP id t189so74474427wmt.1 for ; Mon, 20 Mar 2017 13:53:14 -0700 (PDT) Received: from localhost.localdomain (189.17.90.92.rev.sfr.net. [92.90.17.189]) by smtp.gmail.com with ESMTPSA id q1sm12184651wra.65.2017.03.20.13.53.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Mar 2017 13:53:12 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pv2s+GUVohznZVg+HWKjAg3vFqo/fglhfv5rMGu8/V0=; b=XS7+qfF/YJPnU797Zsv0ZS5RsyQzfKAxkGeCQ+mHHN19nhUUbm3E6b3RUvCBoVNmcA EOLIoEz71w0MxxAIfRfpqTHgTQ6As5Uvc5uIw4izgubQ76+v7+SUYYZx/c4wdcXIIo06 m7SQ0osiqNn5mdRvBFXVIYAwzBMLc0SOrOLFk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pv2s+GUVohznZVg+HWKjAg3vFqo/fglhfv5rMGu8/V0=; b=AmvSt1NAbP8qrtRaRBPtvNgcieAjVuqsSdZhOiOTwrGek5fVxBOUVofXxobR4wArjg Y+DgWf6nKtomiJShW+xt2uEon68vjqBIWoyE4Z1yEtyB2zzzTpKsCKZ0AJjA89W/HLH8 IJ8EI2/aO0ytLGLwt2loBHtUdfzQDPrHWwIXgMzUKGAgHMSTXV+rM8cLEmOVRmQu3K/e 9zJgQx4APpbDdmcBqQpzc3SmhoNSuSzU4byYScc4NALHSwM2f88n7OT9wt7/2UKGK1n1 qkJCd7rGuauavn+WpGg4iTEy8EWrtVtBhdbXZC3hstoOxYSIBeOO85VoYHzpKmnNpmeJ LJYA== X-Gm-Message-State: AFeK/H1F+W2UY5WUklgyOx3/sAlNvkESUf1omrdbbcTUdEfIBnUqB9H/DyCoWPNbpAuTF5Gn X-Received: by 10.28.12.147 with SMTP id 141mr12699919wmm.8.1490043193383; Mon, 20 Mar 2017 13:53:13 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Mon, 20 Mar 2017 20:52:59 +0000 Message-Id: <1490043181-20031-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490043181-20031-1-git-send-email-ard.biesheuvel@linaro.org> References: <1490043181-20031-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 1/3] ArmPkg/DefaultExceptionHandlerLib: add missing GUID to .inf X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ryan.harkin@linaro.org, Ard Biesheuvel , eugene@hp.com MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add the gEfiDebugImageInfoTableGuid, which is referenced in the code, to both .INF files describing this module. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf = | 3 +++ ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.i= nf | 3 +++ 2 files changed, 6 insertions(+) diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHand= lerLib.inf b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHand= lerLib.inf index 5d3ce892ff3c..f5421b1240a1 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.= inf +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.= inf @@ -42,3 +42,6 @@ [LibraryClasses] PeCoffGetEntryPointLib ArmDisassemblerLib SerialPortLib + +[Guids] + gEfiDebugImageInfoTableGuid diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHand= lerLibBase.inf b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultException= HandlerLibBase.inf index 8f5b3e1010c8..b53a5e89f507 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibB= ase.inf +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibB= ase.inf @@ -40,3 +40,6 @@ [LibraryClasses] PeCoffGetEntryPointLib ArmDisassemblerLib SerialPortLib + +[Guids] + gEfiDebugImageInfoTableGuid --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sat Nov 2 12:17:25 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; dkim=fail spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1490043200015707.6760654796909; Mon, 20 Mar 2017 13:53:20 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9E82780470; Mon, 20 Mar 2017 13:53:18 -0700 (PDT) Received: from mail-wm0-x22d.google.com (mail-wm0-x22d.google.com [IPv6:2a00:1450:400c:c09::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A89788046A for ; Mon, 20 Mar 2017 13:53:17 -0700 (PDT) Received: by mail-wm0-x22d.google.com with SMTP id n11so73175448wma.1 for ; Mon, 20 Mar 2017 13:53:17 -0700 (PDT) Received: from localhost.localdomain (189.17.90.92.rev.sfr.net. [92.90.17.189]) by smtp.gmail.com with ESMTPSA id q1sm12184651wra.65.2017.03.20.13.53.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Mar 2017 13:53:15 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=w3g/teTrWkA+/88ey9WiqKKZKrTmsEvZpb8mYLDCyis=; b=W3O5nAn/2yQHnoDoRDD8wv1xxgkbyQaBz/wlOacQ4loB09Q/BXATVKEDgGHAH1HhiW a8ECBKgNZVJ82vc3VnF+uoQvZTf86KqWcABf1znzfjqOHS5QfAvSYzQvnFS25g8gqv7S Vdvmm1gqGXR1+la4zihM3D3VYF8qIKXgWfGLE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=w3g/teTrWkA+/88ey9WiqKKZKrTmsEvZpb8mYLDCyis=; b=VXSpuHTlaldF2ytZEqVSNhS1+euR23k7M3VFP7a1V/W7YjZzWy718nXpx2D9JVcIxn 5YuiyN672Ol437Ag5k6wVku0SuBrlNqpFc/EhguKdhPqh9fCkbtJ+V/aIl3OvcI9cvVQ 5inaVZxz+grfZM2yZhmVAHwLwyoHYiT/tIoDBhDL3EamNbB7H2xKbPj+3KqE8PTWLKDy liqTbpxPJ2JU1YlSr8G8eMvfFLmU/WybAUTIz0dvlZI5g6FtMtl3QqtZswWhQkjUQysH 5103pnL3x5jeS8LV/EHM0fBbFf4L6ke95XUp/DTs4WnXrCXhFeqshh3SueI0l6lNKh8P R2mw== X-Gm-Message-State: AFeK/H2CAlDutk+vDV16TrloZYLo20R6VyY0rs0Ws7vkO/IA+27u6cf725SjIF/UvBDpLZjW X-Received: by 10.28.7.13 with SMTP id 13mr11900176wmh.16.1490043196251; Mon, 20 Mar 2017 13:53:16 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Mon, 20 Mar 2017 20:53:00 +0000 Message-Id: <1490043181-20031-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490043181-20031-1-git-send-email-ard.biesheuvel@linaro.org> References: <1490043181-20031-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 2/3] ArmPkg/DefaultExceptionHandlerLib: walk call stack unconditionally X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ryan.harkin@linaro.org, Ard Biesheuvel , eugene@hp.com MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Currently, we only attempt to walk the call stack and print a backtrace if the program counter refers to a location covered by a PE/COFF image. However, regardless of the value of PC, the frame pointer may still have a meaningful value, and so we can still produce the remainder of the backtrace. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.= c | 56 +++++++++++--------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExcep= tionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultEx= ceptionHandler.c index 2f9c2ede37c1..1024bf48c63d 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHan= dler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHan= dler.c @@ -181,37 +181,43 @@ DefaultExceptionHandler ( DEBUG ((EFI_D_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [ 0] %a\n", SystemContext.SystemContextAArch64->ELR, ImageBase, SystemContext.SystemContextAArch64->ELR - ImageBase, BaseName (Pdb= ))); + } else { + DEBUG ((EFI_D_ERROR, "PC 0x%012lx\n", SystemContext.SystemContextAAr= ch64->ELR)); + } =20 - if ((UINT64 *)SystemContext.SystemContextAArch64->FP !=3D 0) { - Idx =3D 0; + if ((UINT64 *)SystemContext.SystemContextAArch64->FP !=3D 0) { + Idx =3D 0; =20 - RootFp[0] =3D ((UINT64 *)SystemContext.SystemContextAArch64->FP)[0= ]; - RootFp[1] =3D ((UINT64 *)SystemContext.SystemContextAArch64->FP)[1= ]; - if (RootFp[1] !=3D SystemContext.SystemContextAArch64->LR) { - RootFp[0] =3D SystemContext.SystemContextAArch64->FP; - RootFp[1] =3D SystemContext.SystemContextAArch64->LR; - } - for (Fp =3D RootFp; Fp[0] !=3D 0; Fp =3D (UINT64 *)Fp[0]) { - Pdb =3D GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader); - if (Pdb !=3D NULL) { - if (Pdb !=3D PrevPdb) { - Idx++; - PrevPdb =3D Pdb; - } - DEBUG ((EFI_D_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [% 2d] %a\= n", - Fp[1], ImageBase, Fp[1] - ImageBase, Idx, BaseName (Pdb))); + RootFp[0] =3D ((UINT64 *)SystemContext.SystemContextAArch64->FP)[0]; + RootFp[1] =3D ((UINT64 *)SystemContext.SystemContextAArch64->FP)[1]; + if (RootFp[1] !=3D SystemContext.SystemContextAArch64->LR) { + RootFp[0] =3D SystemContext.SystemContextAArch64->FP; + RootFp[1] =3D SystemContext.SystemContextAArch64->LR; + } + for (Fp =3D RootFp; Fp[0] !=3D 0; Fp =3D (UINT64 *)Fp[0]) { + Pdb =3D GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader); + if (Pdb !=3D NULL) { + if (Pdb !=3D PrevPdb) { + Idx++; + PrevPdb =3D Pdb; } + DEBUG ((EFI_D_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [% 2d] %a\n", + Fp[1], ImageBase, Fp[1] - ImageBase, Idx, BaseName (Pdb))); + } else { + DEBUG ((EFI_D_ERROR, "PC 0x%012lx\n", Fp[1])); } - PrevPdb =3D Pdb =3D GetImageName (SystemContext.SystemContextAArch= 64->ELR, &ImageBase, &PeCoffSizeOfHeader); + } + PrevPdb =3D Pdb =3D GetImageName (SystemContext.SystemContextAArch64= ->ELR, &ImageBase, &PeCoffSizeOfHeader); + if (Pdb !=3D NULL) { DEBUG ((EFI_D_ERROR, "\n[ 0] %a\n", Pdb)); + } =20 - Idx =3D 0; - for (Fp =3D RootFp; Fp[0] !=3D 0; Fp =3D (UINT64 *)Fp[0]) { - Pdb =3D GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader); - if (Pdb !=3D NULL && Pdb !=3D PrevPdb) { - DEBUG ((EFI_D_ERROR, "[% 2d] %a\n", ++Idx, Pdb)); - PrevPdb =3D Pdb; - } + Idx =3D 0; + for (Fp =3D RootFp; Fp[0] !=3D 0; Fp =3D (UINT64 *)Fp[0]) { + Pdb =3D GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader); + if (Pdb !=3D NULL && Pdb !=3D PrevPdb) { + DEBUG ((EFI_D_ERROR, "[% 2d] %a\n", ++Idx, Pdb)); + PrevPdb =3D Pdb; } } } --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sat Nov 2 12:17:25 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; dkim=fail spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 149004320299284.35834545768216; Mon, 20 Mar 2017 13:53:22 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D01D480476; Mon, 20 Mar 2017 13:53:21 -0700 (PDT) Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com [IPv6:2a00:1450:400c:c09::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0606180476 for ; Mon, 20 Mar 2017 13:53:20 -0700 (PDT) Received: by mail-wm0-x22f.google.com with SMTP id n11so74371083wma.0 for ; Mon, 20 Mar 2017 13:53:19 -0700 (PDT) Received: from localhost.localdomain (189.17.90.92.rev.sfr.net. [92.90.17.189]) by smtp.gmail.com with ESMTPSA id q1sm12184651wra.65.2017.03.20.13.53.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Mar 2017 13:53:17 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RKM9Svb6dp6GzoqAImw8mNxfjhi5cIgUmvImlhdzGJ0=; b=IZOz8cS/z7vC1pXLWmPq1/6b4khBf1hD7utId5S1FoB8F4VIsG2gKrxQFBcYknmPcl wixFvDuIUJbz4XZR27rRDXxs6599MbI9pMA91T3jzvva60q0bfj9vWd7v4H5eQAaRfCp dHiBt2up/88GM1FUvZLHlR6gqFal6eBbvrnT8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RKM9Svb6dp6GzoqAImw8mNxfjhi5cIgUmvImlhdzGJ0=; b=BbG9uhmxMJ2tv0qOPq1xFOIam89zn/df+sVFCLo+0cyByPFET9va3KCGFkFbiuUgmB x4468UkI11sdPmMOqxREJFI0RHc1zUOp9z88Qt8O5g94RY1+lULT1mEx5MycyEanertb ndBj0RMxHsR4qX/WRKM46wwzRbrZOOQgjKhdcQaOMA5g4V8P/qKOJxc9ZRw8MOnNGqH0 dspfY8iv5xj6JwaH0m+pfsIc3uYqZu4wuT5yMWjxTyr+EY/aqlVQROjbUducJtAjCAQ5 vYo+kB80V2nmOfUsgAFIQRy02/v0WXfyALnucjsKkP3b844VlD/v541lVhhtJh8wYxQf hH/A== X-Gm-Message-State: AFeK/H1twpicGWeOwPJr9QtGBRLzUYGAPhF7KHTFRQcWLGiXC96WqeLgXXqUJW8SVIF3dpdp X-Received: by 10.28.135.149 with SMTP id j143mr11704273wmd.19.1490043198560; Mon, 20 Mar 2017 13:53:18 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Mon, 20 Mar 2017 20:53:01 +0000 Message-Id: <1490043181-20031-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490043181-20031-1-git-send-email-ard.biesheuvel@linaro.org> References: <1490043181-20031-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 3/3] ArmPkg/ArmExceptionLib: use EL0 stack for synchronous exceptions X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ryan.harkin@linaro.org, Ard Biesheuvel , eugene@hp.com MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In order to be able to produce meaningful diagnostic output when taking synchronous exceptions that have been caused by corruption of the stack pointer, prepare the EL0 stack pointer and switch to it when handling the 'Sync exception using SPx' exception class. Other exception classes (of which we really only care about IrqSPx) are left functionally intact. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Note that some code has been moved around so that the macro doesn't grow too big to fit in a 128 byte slot, while keeping the code logically consistent. ArmPkg/Library/ArmExceptionLib/AArch64/AArch64Exception.c | 17 +++- ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S | 86 +++++++++++= +-------- ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf | 5 +- 3 files changed, 70 insertions(+), 38 deletions(-) diff --git a/ArmPkg/Library/ArmExceptionLib/AArch64/AArch64Exception.c b/Ar= mPkg/Library/ArmExceptionLib/AArch64/AArch64Exception.c index 3d6eb4974d74..bd307628af87 100644 --- a/ArmPkg/Library/ArmExceptionLib/AArch64/AArch64Exception.c +++ b/ArmPkg/Library/ArmExceptionLib/AArch64/AArch64Exception.c @@ -16,7 +16,7 @@ #include =20 #include - +#include #include // for MAX_AARCH64_EXCEPTION =20 UINTN gMaxExceptionNumber =3D MAX_AARCH64_EXCEPTION; @@ -25,11 +25,26 @@ EFI_EXCEPTION_CALLBACK gDebuggerExceptionHandlers[MAX_= AARCH64_EXCEPTION + 1] =3D PHYSICAL_ADDRESS gExceptionVectorAlignmentMask =3D ARM_VECTOR_TABLE= _ALIGNMENT; UINTN gDebuggerNoHandlerValue =3D 0; // todo: define for= AArch64 =20 +#define EL0_STACK_PAGES 2 + +VOID +RegisterEl0Stack ( + IN VOID *Stack + ); + RETURN_STATUS ArchVectorConfig( IN UINTN VectorBaseAddress ) { UINTN HcrReg; + UINT8 *Stack; + + Stack =3D AllocatePages (EL0_STACK_PAGES); + if (Stack =3D=3D NULL) { + return RETURN_OUT_OF_RESOURCES; + } + + RegisterEl0Stack ((UINT8 *)Stack + EFI_PAGES_TO_SIZE (EL0_STACK_PAGES)); =20 if (ArmReadCurrentEL() =3D=3D AARCH64_EL2) { HcrReg =3D ArmReadHcr(); diff --git a/ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S b/Ar= mPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S index ff1f5fc81316..ac426d72a150 100644 --- a/ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S +++ b/ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S @@ -100,6 +100,7 @@ =20 GCC_ASM_EXPORT(ExceptionHandlersEnd) GCC_ASM_EXPORT(CommonCExceptionHandler) +GCC_ASM_EXPORT(RegisterEl0Stack) =20 .text =20 @@ -122,35 +123,41 @@ ASM_PFX(ExceptionHandlersStart): VECTOR_BASE(ExceptionHandlersStart) #endif =20 - .macro ExceptionEntry, val + .macro ExceptionEntry, val, sp=3DSPx + .ifnc \sp, SPx + msr SPsel, xzr + .endif + // Move the stackpointer so we can reach our structure with the str inst= ruction. sub sp, sp, #(FP_CONTEXT_SIZE + SYS_CONTEXT_SIZE) =20 - // Push some GP registers so we can record the exception context + // Push the GP registers so we can record the exception context stp x0, x1, [sp, #-GP_CONTEXT_SIZE]! stp x2, x3, [sp, #0x10] stp x4, x5, [sp, #0x20] stp x6, x7, [sp, #0x30] + stp x8, x9, [sp, #0x40] + stp x10, x11, [sp, #0x50] + stp x12, x13, [sp, #0x60] + stp x14, x15, [sp, #0x70] + stp x16, x17, [sp, #0x80] + stp x18, x19, [sp, #0x90] + stp x20, x21, [sp, #0xa0] + stp x22, x23, [sp, #0xb0] + stp x24, x25, [sp, #0xc0] + stp x26, x27, [sp, #0xd0] + stp x28, x29, [sp, #0xe0] + add x28, sp, #(GP_CONTEXT_SIZE + FP_CONTEXT_SIZE + SYS_CONTEXT_SIZE) =20 - EL1_OR_EL2_OR_EL3(x1) -1:mrs x2, elr_el1 // Exception Link Register - mrs x3, spsr_el1 // Saved Processor Status Register 32bit - mrs x5, esr_el1 // EL1 Exception syndrome register 32bit - mrs x6, far_el1 // EL1 Fault Address Register - b 4f - -2:mrs x2, elr_el2 // Exception Link Register - mrs x3, spsr_el2 // Saved Processor Status Register 32bit - mrs x5, esr_el2 // EL2 Exception syndrome register 32bit - mrs x6, far_el2 // EL2 Fault Address Register - b 4f - -3:mrs x2, elr_el3 // Exception Link Register - mrs x3, spsr_el3 // Saved Processor Status Register 32bit - mrs x5, esr_el3 // EL3 Exception syndrome register 32bit - mrs x6, far_el3 // EL3 Fault Address Register + .ifnc \sp, SPx + msr SPsel, #1 // Switch back to read the SP value upon entry=20 + mov x7, sp + msr SPsel, xzr + .else + mov x7, x28 // x28 contains the SP value upon entry + .endif =20 -4:mrs x4, fpsr // Floating point Status Register 32bit + stp x30, x7, [sp, #0xf0] =20 // Record the type of exception that occurred. mov x0, #\val @@ -189,7 +196,7 @@ ASM_PFX(SErrorSP0): // VECTOR_ENTRY(ExceptionHandlersStart, ARM_VECTOR_CUR_SPx_SYNC) ASM_PFX(SynchronousExceptionSPx): - ExceptionEntry EXCEPT_AARCH64_SYNCHRONOUS_EXCEPTIONS + ExceptionEntry EXCEPT_AARCH64_SYNCHRONOUS_EXCEPTIONS, SP0 =20 VECTOR_ENTRY(ExceptionHandlersStart, ARM_VECTOR_CUR_SPx_IRQ) ASM_PFX(IrqSPx): @@ -248,20 +255,25 @@ ASM_PFX(ExceptionHandlersEnd): =20 ASM_PFX(CommonExceptionEntry): =20 - // Stack the remaining GP registers - stp x8, x9, [sp, #0x40] - stp x10, x11, [sp, #0x50] - stp x12, x13, [sp, #0x60] - stp x14, x15, [sp, #0x70] - stp x16, x17, [sp, #0x80] - stp x18, x19, [sp, #0x90] - stp x20, x21, [sp, #0xa0] - stp x22, x23, [sp, #0xb0] - stp x24, x25, [sp, #0xc0] - stp x26, x27, [sp, #0xd0] - stp x28, x29, [sp, #0xe0] - add x28, sp, #GP_CONTEXT_SIZE + FP_CONTEXT_SIZE + SYS_CONTEXT_SIZE - stp x30, x28, [sp, #0xf0] + EL1_OR_EL2_OR_EL3(x1) +1:mrs x2, elr_el1 // Exception Link Register + mrs x3, spsr_el1 // Saved Processor Status Register 32bit + mrs x5, esr_el1 // EL1 Exception syndrome register 32bit + mrs x6, far_el1 // EL1 Fault Address Register + b 4f + +2:mrs x2, elr_el2 // Exception Link Register + mrs x3, spsr_el2 // Saved Processor Status Register 32bit + mrs x5, esr_el2 // EL2 Exception syndrome register 32bit + mrs x6, far_el2 // EL2 Fault Address Register + b 4f + +3:mrs x2, elr_el3 // Exception Link Register + mrs x3, spsr_el3 // Saved Processor Status Register 32bit + mrs x5, esr_el3 // EL3 Exception syndrome register 32bit + mrs x6, far_el3 // EL3 Fault Address Register + +4:mrs x4, fpsr // Floating point Status Register 32bit =20 // Save the SYS regs stp x2, x3, [x28, #-SYS_CONTEXT_SIZE]! @@ -368,3 +380,7 @@ ASM_PFX(CommonExceptionEntry): add sp, sp, #FP_CONTEXT_SIZE + SYS_CONTEXT_SIZE =20 eret + +ASM_PFX(RegisterEl0Stack): + msr sp_el0, x0 + ret diff --git a/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf b/ArmPkg/Li= brary/ArmExceptionLib/ArmExceptionLib.inf index 10d9ae0f4afc..cd9149cf76c6 100644 --- a/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf +++ b/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf @@ -53,10 +53,11 @@ [Packages] =20 [LibraryClasses] ArmLib - DebugLib - DefaultExceptionHandlerLib BaseMemoryLib CacheMaintenanceLib + DebugLib + DefaultExceptionHandlerLib + MemoryAllocationLib =20 [Pcd] gArmTokenSpaceGuid.PcdDebuggerExceptionSupport --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel