From patchwork Sun Oct 24 23:58:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Posen X-Patchwork-Id: 1545468 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=mZvfnTXq; 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 4HcwCM177jz9s0r for ; Mon, 25 Oct 2021 11:03:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 324A2834CD; Mon, 25 Oct 2021 02:03:05 +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="mZvfnTXq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B0E3B834AC; Mon, 25 Oct 2021 01:58:27 +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=ham autolearn_force=no version=3.4.2 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) (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 F2D16815CE for ; Mon, 25 Oct 2021 01:58:23 +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-qt1-x836.google.com with SMTP id t16so8834955qto.5 for ; Sun, 24 Oct 2021 16:58:23 -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=AZUYiaept162TEZzUcOjMKQYh/mQJsUN4JH5Au/jEGQ=; b=mZvfnTXqTHgAo5acqjMjaL1Zg4G9+u+z6fL4NG7gAxuc7iMEKAzECIHrDgfUnkmayY dki8o7A+oCo81P8ttBalauD7OepiSuJShv2DRCQBix+SvCXIZmPyyezBllecXt3AdCxb TF6SGHg9YJh2CngfB0QKTUkyyjQBXd2jQZe+/uD+X28IvivssCfaXjZBWFgIGIBzDrES 0SQg3A2in9Fv/eTHmZwdUGTGZmYGQ+G4a6qy47AugYKRWgffjnKLvG/E0DE0i+nhZGp4 V1DhxJE+6KCaK2lFi4+wcUF6/Y38nniC69m22Ruyr+ED/sPQC5V5EOLlFSisZoDQiErR Ck5w== 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=AZUYiaept162TEZzUcOjMKQYh/mQJsUN4JH5Au/jEGQ=; b=fCvIOX6HctaGCq2mEwaOXkt58mVtKKthEwXmtdWQhotNqQTRWf8tiJ8Ehs1h/kqqUN KItqmQYr8JQNuaKlAF6Teebdw9kNNl1SnfLBgetGGGrFDXJ7MozBj4ENCHKBgxIHj4uE sy7Wvy083kk099NVYAYf8c6Jb+zfuMfqTP4i1JscTpTF92RnIqOZ+MgH54TMmdUEh+dP ciJUnBFLn1kt7ghhXizT7/7qHLFhj7e8cuTLzhHbqXmEBQlO5X4hZ8CekpeII1vSvfLs lzbMhp5D9rYWberkCdfBU93IJnoevF/1ff2baQx4xA/TeGVWPNqIBw6IlO1oQJr6teUm pt6Q== X-Gm-Message-State: AOAM5321oJgfwVl9piD3KR8DW3ifqgsw0QpX9vagkXnhK9BkTzss2FJD 5DQbCmQHJH6aVxL6kWw0nbThEnp4XL4= X-Google-Smtp-Source: ABdhPJwMjRTttajemcrA4CTqscyCPhuxJlwA8HXgKef7CK/M4wNyoQpU9ys8DWgFWQ6XdK5dO4948Q== X-Received: by 2002:ac8:7fd5:: with SMTP id b21mr14573713qtk.101.1635119902434; Sun, 24 Oct 2021 16:58:22 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Oct 2021 16:58:22 -0700 (PDT) From: Jim Posen To: u-boot@lists.denx.de Cc: trini@konsulko.com, mbrugger@suse.com, Jim Posen Subject: [RFC PATCH 2/5] Hypervisor mode interrupt vector table Date: Sun, 24 Oct 2021 19:58:05 -0400 Message-Id: <20211024235808.1926508-3-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 Create separate vector table for exceptions taken to PL2, which happens when U-Boot is running in hypervisor mode. The handler logic is different enough that a separate vector table is the simplest way to handle it. Signed-off-by: Jim Posen --- arch/arm/lib/vectors.S | 95 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/arch/arm/lib/vectors.S b/arch/arm/lib/vectors.S index 56f3681558..89b91b27da 100644 --- a/arch/arm/lib/vectors.S +++ b/arch/arm/lib/vectors.S @@ -117,6 +117,39 @@ _not_used: .word not_used _irq: .word irq _fiq: .word fiq +#ifdef CONFIG_CPU_V7_HAS_VIRT +/* + ************************************************************************* + * + * Hypervisor mode interrupt vectors table + * + ************************************************************************* + */ + + .globl hyp_vector_table + + .align 5 +hyp_vector_table: + ldr pc, _hyp_reset + ldr pc, _hyp_undefined_instruction + ldr pc, _hyp_software_interrupt + ldr pc, _hyp_prefetch_abort + ldr pc, _hyp_data_abort + ldr pc, _hyp_not_used + ldr pc, _hyp_irq + ldr pc, _hyp_fiq + +_hyp_reset: .word reset +_hyp_undefined_instruction: .word hyp_undefined_instruction +_hyp_software_interrupt: .word hyp_software_interrupt +_hyp_prefetch_abort: .word hyp_prefetch_abort +_hyp_data_abort: .word hyp_data_abort +_hyp_not_used: .word hyp_not_used +_hyp_irq: .word hyp_irq +_hyp_fiq: .word hyp_fiq + +#endif /* CONFIG_CPU_V7_HAS_VIR + .balignl 16,0xdeadbeef /* @@ -139,6 +172,15 @@ data_abort: not_used: irq: fiq: +#ifdef CONFIG_CPU_V7_HAS_VIRT +hyp_undefined_instruction: +hyp_software_interrupt: +hyp_prefetch_abort: +hyp_data_abort: +hyp_not_used: +hyp_irq: +hyp_fiq: +#endif /* CONFIG_CPU_V7_HAS_VIRT 1: b 1b /* hang and never return */ @@ -289,4 +331,57 @@ fiq: bad_save_user_regs bl do_fiq +#ifdef CONFIG_CPU_V7_HAS_VIRT + +/** + * Hypervisor mode exception handlers + * + * If exception is taken to EL2, U-Boot must have been running in hypervisor + * mode. Use the existing stack to save register values onto because + * overwriting the stack pointer would leave no way to inspect its value. + */ + + .macro hyp_enter_exception + str sp, [sp, #(-S_FRAME_SIZE + S_SP)] + sub sp, sp, #S_FRAME_SIZE + stmia sp, {r0 - r12} + mrs r1, elr_hyp + mrs r2, spsr + str lr, [sp, #S_LR] + str r1, [sp, #S_PC] + str r2, [sp, #S_PSR] + str r0, [sp, #S_OLD_R0] + mov r0, sp + .endm + +hyp_undefined_instruction: + hyp_enter_exception + bl do_undefined_instruction + +hyp_software_interrupt: + hyp_enter_exception + bl do_software_interrupt + +hyp_prefetch_abort: + hyp_enter_exception + bl do_prefetch_abort + +hyp_data_abort: + hyp_enter_exception + bl do_data_abort + +hyp_not_used: + hyp_enter_exception + bl do_not_used + +hyp_irq: + hyp_enter_exception + bl do_irq + +hyp_fiq: + hyp_enter_exception + bl do_fiq + +#endif /* CONFIG_CPU_V7_HAS_VIRT */ + #endif /* CONFIG_SPL_BUILD */