From patchwork Wed Jul 24 15:31:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 13741090 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5298FC3DA7E for ; Wed, 24 Jul 2024 15:31:43 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.764284.1174658 (Exim 4.92) (envelope-from ) id 1sWdxf-0005Uq-NW; Wed, 24 Jul 2024 15:31:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 764284.1174658; Wed, 24 Jul 2024 15:31:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sWdxf-0005TO-GC; Wed, 24 Jul 2024 15:31:27 +0000 Received: by outflank-mailman (input) for mailman id 764284; Wed, 24 Jul 2024 15:31:26 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sWdxe-0005Oj-Ab for xen-devel@lists.xenproject.org; Wed, 24 Jul 2024 15:31:26 +0000 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [2a00:1450:4864:20::22e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c94115f3-49d1-11ef-bbfe-fd08da9f4363; Wed, 24 Jul 2024 17:31:24 +0200 (CEST) Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2f035ae1083so7913341fa.3 for ; Wed, 24 Jul 2024 08:31:24 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ef26f1bc4asm14240491fa.40.2024.07.24.08.31.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 08:31:23 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: c94115f3-49d1-11ef-bbfe-fd08da9f4363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721835084; x=1722439884; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mVzv7Lf3WsrGUV8320pTvF4jrk7P38KxVVOYJq9PCXU=; b=jdnpYO8/Sl3NXW61FqfANxGv8Xk8Lt+Ba6u9PyyYbos8FMlEE/CjlyVK2a/PF9Ahg7 eSQSIqDt0hJUfB2BrlNkxBq9q4YGfod4Ahfr4fxYZWF2u0KzfFsQDW/dzvTxEKkXlm80 Bxrk8p/u3uk5CF6PKFoRkT80mQWTVpYbuBhQ9TJXKxMioec86yOZc3f0iZBhqbF2UIXO GuKY12WDFENnwJ67tj9LgLUXe9FGfJgNlbsO8fAM6zcjyN//7H8j9SZX7SexFaF10RZ3 C2RXtmonO2UK1NsJiaHJ3S4hk59EyhEDq1pAknxieFgkPNn7x/DI6PkGDk8/+zF5biGc OvtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721835084; x=1722439884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mVzv7Lf3WsrGUV8320pTvF4jrk7P38KxVVOYJq9PCXU=; b=NANxyPIVhHdt8coLIeDKkStZe5+9UDwdv/4k9w0UnUynNja0jRovaBlbek1/qLplkJ 3+hXyTIdbe7O3hhVgPcIb68ytsKWZmZgJuhe1inHp0kEYlddeFEcLELSwoq4Qc6Ag4/5 5rBpa8DW33ajF/Oy27DP0ZCd11rh5t/Ox/HIdgbfXORxyvOWwz6ndOyoc4td2S/OhCXD 3NFCh5Nw3si6b5QHwGADKXGHB3/6OnmLp4vw1D92gq2J3BerJkwy3XRbhDxF2KfH8CqP rmsUZELmGnS+vh4gwgXLguZLc0zr3e2uokjn/I3aFZRcY5gA/i6BAYOIwFqA0QjI3dsx e88Q== X-Gm-Message-State: AOJu0Yy2mVE8XzvNB7oVQ2H7FAj7ByoGBXBlMwH2agdAdJ1AIvSv8ttG 22DQpk2QFryvkDDVrJzEhybVoUgStZ/Y1EnSD0RZj3yGkWQHhu7vhjdim462 X-Google-Smtp-Source: AGHT+IFTfVE2OSbKfPeAzMl0JaPOdVB8BEcT/RiMeGKr+zDRJDb13/LT83G1YiwAl8BTH0zdipBXBQ== X-Received: by 2002:a2e:a4a3:0:b0:2ef:2e3f:35da with SMTP id 38308e7fff4ca-2f039dbfbf0mr1225811fa.45.1721835083784; Wed, 24 Jul 2024 08:31:23 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Jan Beulich Subject: [PATCH v11 3/5] xen/riscv: introduce trap_init() Date: Wed, 24 Jul 2024 17:31:17 +0200 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 Note that trap_init() isn't declared with the __init attribute to avoid removing __init when multi-CPU support for Xen is added. Signed-off-by: Oleksii Kurochko Reviewed-by: Alistair Francis Acked-by: Jan Beulich --- Changes in V11: - update the commit message - add Acked-by: Jan Beulich --- Changes in V10: - update the commit message --- Changes in V9: - drop inclusion of in setup.c - drop #include - ... - introduce stub for void arch_get_xen_caps(xen_capabilities_info_t *info); - resolve rebase conflicts. --- Changes in V8: - nothing changed. only rebase was done. --- Changes in V7: - #define cast_to_bug_frame(addr) ((const struct bug_frame *)(addr)). - remove unnecessary comments in trap_init() function. --- Changes in V6: - trap_init() is now called after enabling the MMU. - Add additional explanatory comments. --- Changes in V5: - Nothing changed --- Changes in V4: - Nothing changed --- Changes in V3: - Nothing changed --- Changes in V2: - Rename setup_trap_handler() to trap_init(). - Add Reviewed-by to the commit message. --- xen/arch/riscv/include/asm/traps.h | 1 + xen/arch/riscv/setup.c | 3 +++ xen/arch/riscv/traps.c | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/xen/arch/riscv/include/asm/traps.h b/xen/arch/riscv/include/asm/traps.h index 3fef318478..c30118e095 100644 --- a/xen/arch/riscv/include/asm/traps.h +++ b/xen/arch/riscv/include/asm/traps.h @@ -9,6 +9,7 @@ void do_trap(struct cpu_user_regs *cpu_regs); void handle_trap(void); +void trap_init(void); #endif /* __ASSEMBLY__ */ diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index e3cb0866d5..a6a29a1508 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -8,6 +8,7 @@ #include #include +#include void arch_get_xen_caps(xen_capabilities_info_t *info) { @@ -23,6 +24,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id, { remove_identity_mapping(); + trap_init(); + printk("All set up\n"); for ( ;; ) diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c index 37cec40dfa..cb18b30ff2 100644 --- a/xen/arch/riscv/traps.c +++ b/xen/arch/riscv/traps.c @@ -12,6 +12,18 @@ #include #include +/* + * Initialize the trap handling. + * + * The function is called after MMU is enabled. + */ +void trap_init(void) +{ + unsigned long addr = (unsigned long)&handle_trap; + + csr_write(CSR_STVEC, addr); +} + static const char *decode_trap_cause(unsigned long cause) { static const char *const trap_causes[] = {