From patchwork Sun Oct 24 23:58:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Posen X-Patchwork-Id: 1545471 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=mdL8Vnr6; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HcwD05MYmz9s0r for ; Mon, 25 Oct 2021 11:04:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A8BA083536; Mon, 25 Oct 2021 02:03:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="mdL8Vnr6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E5A3E815CE; Mon, 25 Oct 2021 01:58:33 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3D35782DF6 for ; Mon, 25 Oct 2021 01:58:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jim.posen@gmail.com Received: by mail-qv1-xf36.google.com with SMTP id gh1so6131559qvb.8 for ; Sun, 24 Oct 2021 16:58:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qroMYwoqjgeNjbhAC+xM9XVsr20+fhcsylYCLtO3EpE=; b=mdL8Vnr6wSjGAA20K+mbgE/fNEjelZRRcgeK7eyRKkLUBqoj1k2BhPz+PFQE419LHq HJXMf5/gCcsVgfnvU5CR5/teFwG7cxw8agZUj1JTMDmfxib8h5yJLdgAsghMRBqinpNp WvKWZNMaV1Sx3djDhGb/sfmjwJIgcP4SizuYcNzFzQ55knoEgU+Wu0/evZV/Zv0YAqWx urk/uKqXjRyXgRfI4+rwS5mxqubvm610kT7NgVif6G+Jx51/lL739/9rrVbmvniNGkaQ 7E3eMGauo6RPv528htoYJm9A2E4FtIGlLmKL3ElBCGzSR8EonEUNOEM5HKwTOUHr8+OG geRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qroMYwoqjgeNjbhAC+xM9XVsr20+fhcsylYCLtO3EpE=; b=SL4xvKQwojSz/0tYGmVafJe4B6auDrZ8VhvQxLU03RUmA7K3NuocryqeOK3rLgOrJN Mupc8e0l4BqO2mLqjFAwlVL2isLdcafzvNL0GqPsvuw6wONWXhwYzrlWYyIqdYuUtvnd BSH3LnPs8K++B3LrmQFLqwqgefV9lBoyRJh2YdnJtcErYDhG6pRkL+8SDPFhF4EMl2Bn gjwWWGhaB9t1tsU2rA5fSu/4PAe9UwF9PFZtWa/Cne4iujPBDVcINsCJaC2/9RZPTs5d 2gzbt+Lm2RKWa7qJsdyFL3uNKp2rgmt0cLHDNkV3fw80La2aPAL84sSkqJ7qvkeMEjPz Lqeg== X-Gm-Message-State: AOAM5322C9iH6pbxxY5gqbO6tqzHtEJPVsF6kC/vzXnVFYqxQ5Hj5FNB c/UxfgkbVBp679zKTMquWO/1Xoq1VdU= X-Google-Smtp-Source: ABdhPJyaeDs/J7FktDo7FEGj2MpS2HmZmGX2j2MWaTH50fR6nt/DHAhJxNh7VxBy9aac4byShbsYow== X-Received: by 2002:a05:6214:2aa9:: with SMTP id js9mr8781711qvb.10.1635119906852; Sun, 24 Oct 2021 16:58:26 -0700 (PDT) Received: from phantom.myfiosgateway.com ([68.237.40.64]) by smtp.gmail.com with ESMTPSA id c9sm6848573qte.43.2021.10.24.16.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Oct 2021 16:58:26 -0700 (PDT) From: Jim Posen To: u-boot@lists.denx.de Cc: trini@konsulko.com, mbrugger@suse.com, Jim Posen , Harald Seiler , Simon Glass Subject: [RFC PATCH 5/5] Fix PC adjustment logic in exception handlers Date: Sun, 24 Oct 2021 19:58:08 -0400 Message-Id: <20211024235808.1926508-6-jim.posen@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211024235808.1926508-1-jim.posen@gmail.com> References: <20211024235808.1926508-1-jim.posen@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 25 Oct 2021 02:02:55 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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 The link register is at a different offset depending on processor mode, so ensure it applies the correct adjustment. Signed-off-by: Jim Posen --- arch/arm/include/asm/u-boot-arm.h | 14 +++++++------- arch/arm/lib/interrupts.c | 26 +++++++++++++------------- arch/arm/lib/vectors.S | 4 +++- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/arch/arm/include/asm/u-boot-arm.h b/arch/arm/include/asm/u-boot-arm.h index 0b93cc48c5..6ebefa7c86 100644 --- a/arch/arm/include/asm/u-boot-arm.h +++ b/arch/arm/include/asm/u-boot-arm.h @@ -41,17 +41,17 @@ int board_init(void); struct pt_regs; void bad_mode(void); -void do_undefined_instruction(struct pt_regs *pt_regs); -void do_software_interrupt(struct pt_regs *pt_regs); -void do_prefetch_abort(struct pt_regs *pt_regs); -void do_data_abort(struct pt_regs *pt_regs); -void do_not_used(struct pt_regs *pt_regs); +void do_undefined_instruction(struct pt_regs *pt_regs, bool hyp_mode); +void do_software_interrupt(struct pt_regs *pt_regs, bool hyp_mode); +void do_prefetch_abort(struct pt_regs *pt_regs, bool hyp_mode); +void do_data_abort(struct pt_regs *pt_regs, bool hyp_mode); +void do_not_used(struct pt_regs *pt_regs, bool hyp_mode); #ifdef CONFIG_ARM64 void do_fiq(struct pt_regs *pt_regs, unsigned int esr); void do_irq(struct pt_regs *pt_regs, unsigned int esr); #else -void do_fiq(struct pt_regs *pt_regs); -void do_irq(struct pt_regs *pt_regswq); +void do_fiq(struct pt_regs *pt_regs, bool hyp_mode); +void do_irq(struct pt_regs *pt_regswq, bool hyp_mode); #endif void reset_misc(void); diff --git a/arch/arm/lib/interrupts.c b/arch/arm/lib/interrupts.c index 6dc27d1d58..498401cdc5 100644 --- a/arch/arm/lib/interrupts.c +++ b/arch/arm/lib/interrupts.c @@ -135,17 +135,17 @@ static inline void fixup_pc(struct pt_regs *regs, int offset) regs->ARM_pc = pc | (regs->ARM_pc & PCMASK); } -void do_undefined_instruction (struct pt_regs *pt_regs) +void do_undefined_instruction(struct pt_regs *pt_regs, bool hyp_mode) { efi_restore_gd(); printf ("undefined instruction\n"); - fixup_pc(pt_regs, -4); + fixup_pc(pt_regs, hyp_mode ? 0 : thumb_mode(regs) ? -2 : -4); show_regs (pt_regs); show_efi_loaded_images(pt_regs); bad_mode (); } -void do_software_interrupt (struct pt_regs *pt_regs) +void do_software_interrupt(struct pt_regs *pt_regs, bool _hyp_mode) { efi_restore_gd(); printf ("software interrupt\n"); @@ -155,51 +155,51 @@ void do_software_interrupt (struct pt_regs *pt_regs) bad_mode (); } -void do_prefetch_abort (struct pt_regs *pt_regs) +void do_prefetch_abort(struct pt_regs *pt_regs, bool hyp_mode) { efi_restore_gd(); printf ("prefetch abort\n"); - fixup_pc(pt_regs, -8); + fixup_pc(pt_regs, hyp_mode ? 0 : -4); show_regs (pt_regs); show_efi_loaded_images(pt_regs); bad_mode (); } -void do_data_abort (struct pt_regs *pt_regs) +void do_data_abort(struct pt_regs *pt_regs, bool hyp_mode) { efi_restore_gd(); printf ("data abort\n"); - fixup_pc(pt_regs, -8); + fixup_pc(pt_regs, hyp_mode ? 0 : -8); show_regs (pt_regs); show_efi_loaded_images(pt_regs); bad_mode (); } -void do_not_used (struct pt_regs *pt_regs) +void do_not_used(struct pt_regs *pt_regs, bool hyp_mode) { efi_restore_gd(); printf ("not used\n"); - fixup_pc(pt_regs, -8); + fixup_pc(pt_regs, hyp_mode ? 0 : -8); show_regs (pt_regs); show_efi_loaded_images(pt_regs); bad_mode (); } -void do_fiq (struct pt_regs *pt_regs) +void do_fiq(struct pt_regs *pt_regs, bool hyp_mode) { efi_restore_gd(); printf ("fast interrupt request\n"); - fixup_pc(pt_regs, -8); + fixup_pc(pt_regs, hyp_mode ? 0 : -4); show_regs (pt_regs); show_efi_loaded_images(pt_regs); bad_mode (); } -void do_irq (struct pt_regs *pt_regs) +void do_irq(struct pt_regs *pt_regs, bool hyp_mode) { efi_restore_gd(); printf ("interrupt request\n"); - fixup_pc(pt_regs, -8); + fixup_pc(pt_regs, hyp_mode ? 0 : -4); show_regs (pt_regs); show_efi_loaded_images(pt_regs); bad_mode (); diff --git a/arch/arm/lib/vectors.S b/arch/arm/lib/vectors.S index a36e3b7a43..dff2155dad 100644 --- a/arch/arm/lib/vectors.S +++ b/arch/arm/lib/vectors.S @@ -239,6 +239,7 @@ IRQ_STACK_START_IN: mov r1, lr stmia r5, {r0 - r3} @ save sp_SVC, lr_SVC, pc, cpsr mov r0, sp @ save current stack into r0 (param register) + mov r1, #0 @ set r1 param to 0, not hypervisor mode .endm .macro get_bad_stack @@ -321,7 +322,8 @@ fiq: str r1, [sp, #S_PC] str r2, [sp, #S_PSR] str r0, [sp, #S_OLD_R0] - mov r0, sp + mov r0, sp @ set r0 param to struct pt_regs on stack + mov r1, #1 @ set r1 param to 1, hypervisor mode .endm hyp_undefined_instruction: