From patchwork Tue Mar 25 17:36:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 14029316 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 9A35FC3600D for ; Tue, 25 Mar 2025 17:37:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.926816.1329651 (Exim 4.92) (envelope-from ) id 1tx8D6-0000Ui-EW; Tue, 25 Mar 2025 17:37:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 926816.1329651; Tue, 25 Mar 2025 17:37:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tx8D6-0000TF-9B; Tue, 25 Mar 2025 17:37:08 +0000 Received: by outflank-mailman (input) for mailman id 926816; Tue, 25 Mar 2025 17:37:06 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tx8D4-0000Qy-Jv for xen-devel@lists.xenproject.org; Tue, 25 Mar 2025 17:37:06 +0000 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [2a00:1450:4864:20::635]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c437c017-099f-11f0-9ffa-bf95429c2676; Tue, 25 Mar 2025 18:37:04 +0100 (CET) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-ab78e6edb99so827638466b.2 for ; Tue, 25 Mar 2025 10:37:04 -0700 (PDT) Received: from fedora.. (user-109-243-64-225.play-internet.pl. [109.243.64.225]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac3efb65871sm897012066b.96.2025.03.25.10.37.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 10:37:03 -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: c437c017-099f-11f0-9ffa-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742924224; x=1743529024; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QR7+GAKTCGt2cIHaB5tu0WA4vzMonRrbNIvlE9oHS8Q=; b=Gp6vH+P1idT6uIc2E/6+6PzWW5hRizHcMJ3I2iDUJ7RlonTJ5MINh2qbzkkK13pNDa 8Y76BJHIc8BRo1mxeun7IOHeTzKj/wMxN0XN7S+ie4qD7tSCh5BAnNuk0/YceWv7Uzit 8pEwirSyEyV/fdK5daAQ4eKzaSxauojH1NVwZaQVnuUdxwTImN5yY7/t6WrA7T3YctlJ haz5RFy6u5QP8spQd3oxWxhwNMWpgX+TtL6sUpOsHuHVkariRGdYwAVydlI/RP+xuXM8 mjhx7qZMBVOYtMF8svRNMZPvUwDUcrfBN4T2P4qBNT5mmvJFvtSM4M5xO9kCbcR7G3QJ G6lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742924224; x=1743529024; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QR7+GAKTCGt2cIHaB5tu0WA4vzMonRrbNIvlE9oHS8Q=; b=oofa2FOzGZxq/xWSySzQ2aRVL//s9Rw0YN4SZLeIX90YcP/usv3V0W/hNjc41YZuCH U0HU3Ke7S8ADI6OLNQnv2JaIUyQNLJh7nIU02GMa085guxKhMKdCOlMBUanaXiHu+n2c ABkrtA3T1Agwisvei2RTIqwNiH8mx1ZXwHuS6NYsmrzehkyLkykwsY0ej2sYyndkmAWL x9QY5kCYD59Urgx+kgsEnj/ULgoioNtBh+FZpTPIjuifznQTdeySP9Vcsb/TO69QZfp+ r4Wz7M8pTKWKcKWBpyCdswzsQ3bhuR22vi4B5hNgQeGOG/VBFHk63PeD66vS0LSIUjKe MLbw== X-Gm-Message-State: AOJu0YxKUAG2CL4U4anRQ9v6EH69XUVbIfOkzP8iF49sKfqGHR/BVxKX WQJCRSCEuamFBpdR9HN8MZZrVeqtt7lUwxQ5Wsb/Gs861EJ9PoL0kAEYdA== X-Gm-Gg: ASbGncvWNqt/+O4Z2tWjzJLXWvdszdDLu39C9MQC5BVLtZP313W2/+bJdy4nz9brAyO WZGclrQEXhlAUUaGF7LS7RcoN1qHaYSNRCr3aFp8+/aFvVJ7T0UaPAbSdVYM2g5EJHCtc3m22LP iFzISWWwGeodsseeuEStawUGNQR636oKGwJz48738QPrtL13XmfyqBeGw9QHCTbzYHOjxtNtn8Q 2CHBB8b+UYZNfVc19kei+42G6mXPJ0WDIHQKtTRZUrvaCgG4Iot+eQwTtnLASbKcD7CX4bver2s M0lfH57dCboHsVOoy+5Nh03MUJ1Lw/kpKJ9Kps2DuhugpYm9r25fNCrpi/64Z0lPu84AxdMDSTz jXey5pzYv1a5JpA== X-Google-Smtp-Source: AGHT+IFrWi2J62SBU4NhjXKaVMyZEbFAZF4IjReGH1PkjB08zPaGIyFznpofCfAziu3+uuf3ln3qgg== X-Received: by 2002:a17:907:6e87:b0:abf:4708:8644 with SMTP id a640c23a62f3a-ac3f2458dc1mr1637252466b.43.1742924223535; Tue, 25 Mar 2025 10:37:03 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v2 1/4] xen/riscv: introduce preinit_xen_time() Date: Tue, 25 Mar 2025 18:36:57 +0100 Message-ID: <1a04711f46a1c0a7cdf709abc37f143747215495.1742918184.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 preinit_xen_time() does two things: 1. Parse timebase-frequency properpy of /cpus node to initialize cpu_khz variable. 2. Initialize xen_start_clock_cycles with the current time counter value. Signed-off-by: Oleksii Kurochko --- Changes in v2: - Update SPDX tag for time.c - s/read_mostly/__ro_after_init for boot_count variable. - Add declaration of boot_count to asm/time.h. - Rename boot_count to xen_start_clock_cycles. - Stray double blank in the defintion of timer_ids. - s/u32/uint32_t. - Drop full stop. - Update the commit message. - s/__initconst/__initconstrel for timer_ids[]. --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/include/asm/time.h | 5 ++++ xen/arch/riscv/setup.c | 2 ++ xen/arch/riscv/stubs.c | 2 -- xen/arch/riscv/time.c | 39 +++++++++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 xen/arch/riscv/time.c diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index b0c8270a99..82016a957a 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -9,6 +9,7 @@ obj-y += setup.o obj-y += shutdown.o obj-y += smp.o obj-y += stubs.o +obj-y += time.o obj-y += traps.o obj-y += vm_event.o diff --git a/xen/arch/riscv/include/asm/time.h b/xen/arch/riscv/include/asm/time.h index fc1572e9b4..c24745508b 100644 --- a/xen/arch/riscv/include/asm/time.h +++ b/xen/arch/riscv/include/asm/time.h @@ -5,6 +5,9 @@ #include #include +/* Clock cycles count at Xen startup */ +extern unsigned long xen_start_clock_cycles; + struct vcpu; static inline void force_update_vcpu_system_time(struct vcpu *v) @@ -19,6 +22,8 @@ static inline cycles_t get_cycles(void) return csr_read(CSR_TIME); } +void preinit_xen_time(void); + #endif /* ASM__RISCV__TIME_H */ /* diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index b0e587678e..836ad16fed 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -126,6 +126,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id, riscv_fill_hwcap(); + preinit_xen_time(); + printk("All set up\n"); machine_halt(); diff --git a/xen/arch/riscv/stubs.c b/xen/arch/riscv/stubs.c index 5951b0ce91..caa133de84 100644 --- a/xen/arch/riscv/stubs.c +++ b/xen/arch/riscv/stubs.c @@ -27,8 +27,6 @@ nodemask_t __read_mostly node_online_map = { { [0] = 1UL } }; /* time.c */ -unsigned long __ro_after_init cpu_khz; /* CPU clock frequency in kHz. */ - s_time_t get_s_time(void) { BUG_ON("unimplemented"); diff --git a/xen/arch/riscv/time.c b/xen/arch/riscv/time.c new file mode 100644 index 0000000000..ae8efa3c59 --- /dev/null +++ b/xen/arch/riscv/time.c @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#include +#include +#include +#include + +unsigned long __ro_after_init cpu_khz; /* CPU clock frequency in kHz. */ +unsigned long __ro_after_init xen_start_clock_cycles; + +static __initdata struct dt_device_node *timer; + +/* Set up the timer on the boot CPU (early init function) */ +static void __init preinit_dt_xen_time(void) +{ + static const struct dt_device_match __initconstrel timer_ids[] = + { + DT_MATCH_PATH("/cpus"), + { /* sentinel */ }, + }; + uint32_t rate; + + timer = dt_find_matching_node(NULL, timer_ids); + if ( !timer ) + panic("Unable to find a compatible timer in the device tree\n"); + + dt_device_set_used_by(timer, DOMID_XEN); + + if ( !dt_property_read_u32(timer, "timebase-frequency", &rate) ) + panic("Unable to find clock frequency\n"); + + cpu_khz = rate / 1000; +} + +void __init preinit_xen_time(void) +{ + preinit_dt_xen_time(); + + xen_start_clock_cycles = get_cycles(); +} From patchwork Tue Mar 25 17:36:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 14029318 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 8DC1BC36008 for ; Tue, 25 Mar 2025 17:37:22 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.926815.1329646 (Exim 4.92) (envelope-from ) id 1tx8D6-0000RN-5q; Tue, 25 Mar 2025 17:37:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 926815.1329646; Tue, 25 Mar 2025 17:37:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tx8D6-0000RG-28; Tue, 25 Mar 2025 17:37:08 +0000 Received: by outflank-mailman (input) for mailman id 926815; Tue, 25 Mar 2025 17:37:06 +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 1tx8D4-0000Qx-8u for xen-devel@lists.xenproject.org; Tue, 25 Mar 2025 17:37:06 +0000 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [2a00:1450:4864:20::62c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c4a6873d-099f-11f0-9ea3-5ba50f476ded; Tue, 25 Mar 2025 18:37:05 +0100 (CET) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-ab771575040so11426666b.1 for ; Tue, 25 Mar 2025 10:37:05 -0700 (PDT) Received: from fedora.. (user-109-243-64-225.play-internet.pl. [109.243.64.225]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac3efb65871sm897012066b.96.2025.03.25.10.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 10:37:03 -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: c4a6873d-099f-11f0-9ea3-5ba50f476ded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742924224; x=1743529024; 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=3gOQ8U3cpa7RAOGnJUwoO2nwCYBfxpYAKHyGklE8Ip4=; b=aLiWBSLnrsHISMhIq0osqsP7U6f8A5Cmf/Ady0QGf25GRa6e9oF7zEmoEbZzoBRRza sjTkBLaWCFdDA5mgGdHNvUxswEXrE1K36PglrcHFK2KxPZHKMRG3HW7HPThAijrwkPR4 RoeNiiXq3e7pxt5zbP4nODUb5ej5uyo3cwBP2kXEXg35eoQCV5RkqBepDwrwSydzt9bt 8WQdY1YjLEneWrkMLqEzc63oLwR5LVbWWcHoK1FrFTrVWg0F3gk3PS+1IdHCstnk9UH3 Pfv9MUblV1o3OpdQCIdtpJQvxfYoK14sfBF33WsgYwdhoer1wEunrgVKilspYbHcRRu1 JYww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742924224; x=1743529024; 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=3gOQ8U3cpa7RAOGnJUwoO2nwCYBfxpYAKHyGklE8Ip4=; b=sBswTeHSjwotxKfticvhBN+9OchwV1TVlWrIXpgW73qsE9G7qm+9/BL7XHnzVrM4f/ nfM012ClmvK/GML+/Qn4xFWBRUgaUWCNd8cDnfjr1QPI8n0kqqZ/diiA61d1q7Yp+Wbw bFTTkV+ESqXaqf2trqg3xPmxXoX6GOfen9mgThhT0lfA6rZBsUqR9K4PRYjj09cHVj0W +ZGmtI8Lf5x/qpY8kgtn/t6l6xc6pPDeY+MSAKolPdo+HySoTCggNY5wR9oaK1sTE0XB HgUlugHb6vIMWGj82hKNOPwubx06CMRA2j8dTT+brOBaX1YKirRb+iv23MRd+hyim3rr guFw== X-Gm-Message-State: AOJu0YwTAS7gGAt0ToiS6GNbL2hGsq9w2TmV2WWfa1wl9iT4S1SbeaQL JH7oWRGU9vfww+xXtLMh1/SBpS/8g/7gWqlkUN9MMTHkeKyYWcrwLSxYXA== X-Gm-Gg: ASbGncsEqlas/zX8pf83KkIS7u9mL6k6msDwQr3/DObNcn/VQG+u6tgno8Ai3pb7EDb 9LJoYyN2Gf37SYn48+yGK+ws6mas8HYmhgR49r1jW/vR7u8N+3RrWd3jx7rqOe6gjymS4vGxIhK CmG0sSXx0RhbklfzUvUBU0j7iUAgcV0ISJFM4jbVcW2Og6D3l5lRPHmZjz+MQP3J+JNt+97SO5h JpQBnjxB0dKlghg1gtV8Xf9I/ma1HQdZyqCCjXDHRdvlPE8HrEefQMU6ONS5uYIx0HnswiCgBbO Cqr6VVnsWkp8WnVdVVEgWSGUnhz14f3xK1NxicvyNGSuxMWBbwK6IzoQ+WqyulXZ0CM789nLPHl FtqIsC0Nj/BKDBQ== X-Google-Smtp-Source: AGHT+IGSNMLfyWyHsdvuXtC0d/YEBZrwaj+iwhePtkAh3ElgyY76m3+nDlVpHDJic/oA99k50+JABg== X-Received: by 2002:a17:907:724a:b0:ac6:b80b:2331 with SMTP id a640c23a62f3a-ac6e08f984cmr59383866b.4.1742924224234; Tue, 25 Mar 2025 10:37:04 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Doug Goldstein , Stefano Stabellini , Andrew Cooper Subject: [PATCH v2 2/4] automation: select APLIC and IMSIC to handle both wired interrupts and MSIs Date: Tue, 25 Mar 2025 18:36:58 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: <1a04711f46a1c0a7cdf709abc37f143747215495.1742918184.git.oleksii.kurochko@gmail.com> References: <1a04711f46a1c0a7cdf709abc37f143747215495.1742918184.git.oleksii.kurochko@gmail.com> MIME-Version: 1.0 By default, the `aia` option is set to "none" which selects the SiFive PLIC for handling wired interrupts. However, since PLIC is now considered obsolete and will not be supported by Xen now, APLIC and IMSIC are selected instead to manage both wired interrupts and MSIs. Signed-off-by: Oleksii Kurochko Acked-by: Andrew Cooper --- Tests results: https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/1734636979 Based on the source code of Qemu the support of AIA should be present from 7.0.0: 28d8c281200f ("hw/riscv: virt: Add optional AIA IMSIC support to virt machine") ``` $ git tag --contains 28d8c281200f20a060c456c81fd1564f3d119fda staging-mjt-test trivial-patches-pull-request v7.0.0 v7.0.0-rc0 v7.0.0-rc1 v7.0.0-rc2 v7.0.0-rc3 v7.0.0-rc4 v7.1.0 ... ``` And in Xen's GitLab CI it is used 7.2.11: ``` $ CONTAINER_NO_PULL=1 CONTAINER=bookworm-riscv64 ./automation/scripts/containerize *** Launching container ... user@6a1d1f0077fe:/build$ qemu-system-riscv64 --version QEMU emulator version 7.2.11 (Debian 1:7.2+dfsg-7+deb12u6) Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers ``` --- Changes in v2: - Acked-by: Andrew Cooper --- automation/scripts/qemu-smoke-riscv64.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/scripts/qemu-smoke-riscv64.sh b/automation/scripts/qemu-smoke-riscv64.sh index 8f755d0a6a..b2e112c942 100755 --- a/automation/scripts/qemu-smoke-riscv64.sh +++ b/automation/scripts/qemu-smoke-riscv64.sh @@ -6,7 +6,7 @@ set -ex -o pipefail rm -f smoke.serial export TEST_CMD="qemu-system-riscv64 \ - -M virt \ + -M virt,aia=aplic-imsic \ -smp 1 \ -nographic \ -m 2g \ From patchwork Tue Mar 25 17:36:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 14029317 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 E22E4C3600B for ; Tue, 25 Mar 2025 17:37:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.926818.1329676 (Exim 4.92) (envelope-from ) id 1tx8D8-00017f-2d; Tue, 25 Mar 2025 17:37:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 926818.1329676; Tue, 25 Mar 2025 17:37:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tx8D7-00016Z-VD; Tue, 25 Mar 2025 17:37:09 +0000 Received: by outflank-mailman (input) for mailman id 926818; Tue, 25 Mar 2025 17:37:08 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tx8D6-0000Qy-4n for xen-devel@lists.xenproject.org; Tue, 25 Mar 2025 17:37:08 +0000 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [2a00:1450:4864:20::62b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c543f8cf-099f-11f0-9ffa-bf95429c2676; Tue, 25 Mar 2025 18:37:06 +0100 (CET) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-ac345bd8e13so1042391766b.0 for ; Tue, 25 Mar 2025 10:37:06 -0700 (PDT) Received: from fedora.. (user-109-243-64-225.play-internet.pl. [109.243.64.225]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac3efb65871sm897012066b.96.2025.03.25.10.37.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 10:37:04 -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: c543f8cf-099f-11f0-9ffa-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742924225; x=1743529025; 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=krQovhxk411eqTxcXA3IPuwT9zjyGSDPwZ17OUSlKYo=; b=TVOpIaJeQgbbWL6MxNh1norLaVU3+ThQ9ZTsOXCstfGqOC0e6y9tJ6jZCB+adro5HU nHLj71OHXPLcGxUYiLh+UuW2Wtg+eekE2LQd19a/6dh4vEkg+fOYRE4Mz+ibmpAKKGCB fuhXAbOkwSQzRbWqjSC2HGfGuCq+Fgb3UlPnXvquk7z8y2piiEvRGT0BlsbJMuBlfsQP kbE78T8hT3gRjXyiOPFuIeov6TBjmpxtdkDUTISZ0UV/IhRIk4B9LkVDY3LjQcFDr30d XQ1up2576vrMTgxk4M4y/Iv83fJAVOmPpFJCHk3/1PlrAXiA9BOp3p8AaR0qDZS/vl/p oUCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742924225; x=1743529025; 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=krQovhxk411eqTxcXA3IPuwT9zjyGSDPwZ17OUSlKYo=; b=ofXG1ADJLjUg/bLvMHiSZNKg8gZvpCKAUliCf5IeykYB7fgG9ssJmH/m08sSfqHVrz qoABji8XPk1bTGLV7gZ5fWkk7AbleCjy3Ps5RwHSOPFGbNTRiQExGs4yBKiDuP5++9p2 +yNQM/c5CgIMF84VTxs1XPHpRv8p9vndk9krGKFrFjM9jvbmXeHUxC22MaFykJjvPcr7 DRldESR9fP51XYnANzUjJSNFVN4o8zd1dBI+0MLbrmhoGvMru0jjZbgJw6VjLMPN2jKf l/q8EMkTkbFYuFaCAjOt0eYvJppxyZiY7B0JPbNrNvkDGeYv7RTBtWP21RWoAqWJK1if MR1Q== X-Gm-Message-State: AOJu0YwJfcJ6lTK64JrrHIHwrCDKOqMmOyDxb/8R8Qb5Hee1XMCUp2Qs zrnOYSm/hMJysFvF8GsINPFcRN6WyCxhD4bK7dp4k+G0fOr9u2CV+OKjZQ== X-Gm-Gg: ASbGncsJ6WcplYXs+7sowgW6iVp85KrJUlJ+TXk09A99f3hO3fJytfLMEzy1nCbYicc dLdFz9oLPjg9CrzqruuEDBbDc0pFjW/WPX9F8K7j6LKyjxc7SkBxAuP8S0QsKI7ZyqMp+EV4ETP CM/d+wj1eWbxMELpWQx3W7C3Sznr3CDzX0s2Xr5s/Bazgs9YTB97o1qOPLT6IWRpoXKki7n8frK MIbUqiUa8ZkbDiKeTBsYU953JQlXqLpE0YdcUMVMZkqEWDbQ5asQq5znShbAuZQvRyDJ4desyKx uUVY6Xgu2j5qXB5GkzgOF8Ky+nWnOBCoX8ROj8EpDBySeji39cMZx0VSBwX+2htBjaa55QhX4+z IX6CeYxqeZXZj5Q== X-Google-Smtp-Source: AGHT+IFvY8ECpKVlMbxJC1uQh7F4bkUnqiFXj1VbwutSi04A4e2o9fxEnR68dPJMhyESxK8tLIWJtw== X-Received: by 2002:a17:907:e84c:b0:ac4:751:5f16 with SMTP id a640c23a62f3a-ac407515fefmr1489853266b.30.1742924225373; Tue, 25 Mar 2025 10:37:05 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , Romain Caritey Subject: [PATCH v2 3/4] xen/riscv: implement basic aplic_preinit() Date: Tue, 25 Mar 2025 18:36:59 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: <1a04711f46a1c0a7cdf709abc37f143747215495.1742918184.git.oleksii.kurochko@gmail.com> References: <1a04711f46a1c0a7cdf709abc37f143747215495.1742918184.git.oleksii.kurochko@gmail.com> MIME-Version: 1.0 Introduce preinitialization stuff for the RISC-V Advanced Platform-Level Interrupt Controller (APLIC) in Xen: - Implementing the APLIC pre-initialization function (`aplic_preinit()`), ensuring that only one APLIC instance is supported in S mode. - Initialize APLIC's correspoinding DT node. - Declaring the DT device match table for APLIC. - Setting `aplic_info.hw_version` during its declaration. - Declaring an APLIC device. Since Microchip originally developed aplic.c [1], an internal discussion with them led to the decision to use the MIT license instead of the default GPL-2.0-only. [1] https://gitlab.com/xen-project/people/olkur/xen/-/commit/7cfb4bd4748ca268142497ac5c327d2766fb342d Signed-off-by: Romain Caritey Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v2: - drop initialization of .node member to NULL of aplic_info. - s/initcont/initconstrel for aplic_dt_match and put initconstrel between type and identifier. - Update identation for DT_DEVICE_START(aplic, ...). - Update the commit message. --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/aplic.c | 49 +++++++++++++++++++++++++++++++ xen/arch/riscv/include/asm/intc.h | 20 +++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 xen/arch/riscv/aplic.c create mode 100644 xen/arch/riscv/include/asm/intc.h diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index 82016a957a..dd5fd25c7d 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -1,3 +1,4 @@ +obj-y += aplic.o obj-y += cpufeature.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-y += entry.o diff --git a/xen/arch/riscv/aplic.c b/xen/arch/riscv/aplic.c new file mode 100644 index 0000000000..856b3bf84f --- /dev/null +++ b/xen/arch/riscv/aplic.c @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: MIT */ + +/* + * xen/arch/riscv/aplic.c + * + * RISC-V Advanced Platform-Level Interrupt Controller support + * + * Copyright (c) 2023-2024 Microchip. + * Copyright (c) 2024-2025 Vates + */ + +#include +#include +#include + +#include +#include + +static struct intc_info aplic_info = { + .hw_version = INTC_APLIC +}; + +static int __init aplic_preinit(struct dt_device_node *node, const void *dat) +{ + if ( aplic_info.node ) + { + printk("XEN doesn't support more than one S mode APLIC\n"); + return -ENODEV; + } + + /* don't process if APLIC node is not for S mode */ + if ( dt_get_property(node, "riscv,children", NULL) ) + return -ENODEV; + + aplic_info.node = node; + + return 0; +} + +static const struct dt_device_match __initconstrel aplic_dt_match[] = +{ + DT_MATCH_COMPATIBLE("riscv,aplic"), + { /* sentinel */ }, +}; + +DT_DEVICE_START(aplic, "APLIC", DEVICE_INTERRUPT_CONTROLLER) + .dt_match = aplic_dt_match, + .init = aplic_preinit, +DT_DEVICE_END diff --git a/xen/arch/riscv/include/asm/intc.h b/xen/arch/riscv/include/asm/intc.h new file mode 100644 index 0000000000..ff9bb33896 --- /dev/null +++ b/xen/arch/riscv/include/asm/intc.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: MIT */ + +/* + * (c) 2023-2024 Microchip Technology Inc. + * (c) 2024 Vates + */ + +#ifndef ASM__RISCV__INTERRUPT_CONTOLLER_H +#define ASM__RISCV__INTERRUPT_CONTOLLER_H + +enum intc_version { + INTC_APLIC, +}; + +struct intc_info { + enum intc_version hw_version; + const struct dt_device_node *node; +}; + +#endif /* ASM__RISCV__INTERRUPT_CONTOLLER_H */ From patchwork Tue Mar 25 17:37:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 14029315 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 85BE1C36008 for ; Tue, 25 Mar 2025 17:37:19 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.926817.1329658 (Exim 4.92) (envelope-from ) id 1tx8D6-0000ew-RL; Tue, 25 Mar 2025 17:37:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 926817.1329658; Tue, 25 Mar 2025 17:37:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tx8D6-0000dh-NV; Tue, 25 Mar 2025 17:37:08 +0000 Received: by outflank-mailman (input) for mailman id 926817; Tue, 25 Mar 2025 17:37:08 +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 1tx8D5-0000Qx-VR for xen-devel@lists.xenproject.org; Tue, 25 Mar 2025 17:37:07 +0000 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [2a00:1450:4864:20::62f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c5ea9d0c-099f-11f0-9ea3-5ba50f476ded; Tue, 25 Mar 2025 18:37:07 +0100 (CET) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-ac297cbe017so13710766b.0 for ; Tue, 25 Mar 2025 10:37:07 -0700 (PDT) Received: from fedora.. (user-109-243-64-225.play-internet.pl. [109.243.64.225]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac3efb65871sm897012066b.96.2025.03.25.10.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 10:37:05 -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: c5ea9d0c-099f-11f0-9ea3-5ba50f476ded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742924227; x=1743529027; 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=rULmv9ycnH1A0yzpu+OMW8L+kKFgN+RXzTeCgFhTv8U=; b=WvC4DrTM9zG+2N7j0bQPadYTLtvfSIEZ21tNvVt346bqY50ZZjSVmc/I2Ywu2mNm7c dQ+KGz5/b7mbbo7IPmq1Le5OkCJ4BcsAvIc3TBv+LTh6cLSiSH2aW6oTjWXip5SE1bwK EBHpWkzDXO4rAu7ecILWSLmQ1GUCj0+5dzGInBedZJ99DSYjmHKsBuf8FdCQ2pWE8HCa uosScMl5Sgta8yuDq7lB76q0TJjH46zUKZ17+qSbyHVnf/4TWoKPhAZpLVq549EOq/mB 5FhQ0KM5mvUg1fBZcX6M2xeshFPRJPjNuF7SH7HQnKQdb5RmL/P+IFchBYz3JyyKan2y 72cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742924227; x=1743529027; 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=rULmv9ycnH1A0yzpu+OMW8L+kKFgN+RXzTeCgFhTv8U=; b=CyX4wWckX89kDI3K7gqomkPoWRUvWMyBJJDtHqVW9UwNDUyE3kbExWVDuZA3gOrKce ljAMdNsndB3s3zTOUQ031D1YiSS7onysVLOCevBoglc+aS6K1T0h7gdAs/qcSJNg44v4 HEk2aW4sNZnGp1wMXG5JD0K/6M3rXQqFY0HJnSqvwz3zfnbStE3ymvZ3m4aDH7DWlk3U A65HB/XL9BsHAG792db4zretwCZGfQAQJcxd2sMCx2PtrdMk7mWn95A3z/C9uS7cmBbR qonbcd5jtUeJ+SWDyU66qahZJumTR66uAfuVCuGCoNpFnnz3O/X3rJeJNFMpfz8H4tSC oyYQ== X-Gm-Message-State: AOJu0YxxKFJNrRpw07vlto6gOKSe6J8NecwrliHIdE1nW9dgqr7cP7Eo o38gokAtE9FuCz9aCBt35AV1guOmSdW4i1vacOKCxVQflfPuIsuOadHQ6A== X-Gm-Gg: ASbGncuOf6KMkWlu0tgqZiX5IIODuLb7Z86xITIkPLlXgFxvhVvkaee/XPSbPZEnpM/ SjO3DFYOSv/QRJHkU1QxxggNW0Qeb0Iz5pB2wi+3+W3ffoFl0UWPm8Xy2o4WaD5FmrA9pEHt3Eh J5zoJKzbDLnG1NOVQFknqsu75BRI0vAJRZ2UD33Jur2CJZSUTqAbJzF5vIhFWTrnKnuJ/RCq2H4 s89lOD+SzmBMKqRTOjyLMTSKGybp9D9Apvml3mQtCbU9MOqfE83tBvxcyrfVHJGwJxDNue75akD NQiY94zj8yw58F4kGZjX4v5mSlb3VUqW18CIUeOInb2XJIKdO10PNJRFtXO+1LEXJjKRkRDvfcX wEcQlF2/Ndw2bCA== X-Google-Smtp-Source: AGHT+IGzfaRCnzLnTAgLUcqXTkYf64vr0phicvjXgIyFK6kSvdSKl4A48jO+rc6JsIs9JfGEkXrmaQ== X-Received: by 2002:a17:907:7212:b0:ac2:d5d3:2b77 with SMTP id a640c23a62f3a-ac6e0a25ad2mr68355266b.8.1742924226447; Tue, 25 Mar 2025 10:37:06 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v2 4/4] xen/riscv: introduce intc_preinit() Date: Tue, 25 Mar 2025 18:37:00 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: <1a04711f46a1c0a7cdf709abc37f143747215495.1742918184.git.oleksii.kurochko@gmail.com> References: <1a04711f46a1c0a7cdf709abc37f143747215495.1742918184.git.oleksii.kurochko@gmail.com> MIME-Version: 1.0 Currently, only the device tree method is available to locate and perform pre-initialization steps for the interrupt controller (at the moment, only one interrupt controller is going to be supported). When `acpi_disabled` is true, the system will scan for a node with the "interrupt-controller" property and then call `device_init()` to validate if it is an expected interrupt controller and if yes then save this node for further usage. If `acpi_disabled` is false, the system will panic, as ACPI support is not yet implemented for RISC-V. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v2: - Update the commit message. --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/include/asm/intc.h | 2 ++ xen/arch/riscv/intc.c | 14 ++++++++++++++ xen/arch/riscv/setup.c | 3 +++ 4 files changed, 20 insertions(+) create mode 100644 xen/arch/riscv/intc.c diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index dd5fd25c7d..0c6c4a38a3 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -2,6 +2,7 @@ obj-y += aplic.o obj-y += cpufeature.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-y += entry.o +obj-y += intc.o obj-y += mm.o obj-y += pt.o obj-$(CONFIG_RISCV_64) += riscv64/ diff --git a/xen/arch/riscv/include/asm/intc.h b/xen/arch/riscv/include/asm/intc.h index ff9bb33896..52ba196d87 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -17,4 +17,6 @@ struct intc_info { const struct dt_device_node *node; }; +void intc_preinit(void); + #endif /* ASM__RISCV__INTERRUPT_CONTOLLER_H */ diff --git a/xen/arch/riscv/intc.c b/xen/arch/riscv/intc.c new file mode 100644 index 0000000000..4061a3c457 --- /dev/null +++ b/xen/arch/riscv/intc.c @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include + +void __init intc_preinit(void) +{ + if ( acpi_disabled ) + intc_dt_preinit(); + else + panic("ACPI interrupt controller preinit() isn't implemented\n"); +} diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index 836ad16fed..4e416f6e44 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -128,6 +129,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id, preinit_xen_time(); + intc_preinit(); + printk("All set up\n"); machine_halt();