From nobody Sat Apr 27 02:20:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678977600; cv=none; d=zohomail.com; s=zohoarc; b=W2m1cwMavMX3hJBB3nIbBMMfAnRaXgolXRkW2ho7hWDjH29n6os0SuxA+eusQGmjsvX/hvAP/qu5iKiIfGK7e4IkfLeYynvTMwaUlUoAK1YljZkXs7khmO+OOQ164QZ0JMetftZ0RjtteElehNfgLc8YHH3X4MGZ3eu01hCSMQ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678977600; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YQMyKbzQe0AjQ7eGyuvY7xOmw9XaxRLiNTI1dISB708=; b=KxUnNC5K3r1DSIMaY0qNnZeEM7zBD/TM4ONnqbSDSz4sthrlzc1wGTWGr3N5K6Wh5auzCsnM1i+jAFhFNcH9C2tmuqfN+qS4sAfLlIdW4UuNp5pfu0LbVHp5YrRHR8Lxh7qRSHzWx9oCa/fKIUfYVlNLf9/8+KpADKp+keW3jmg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1678977600487899.0435439856599; Thu, 16 Mar 2023 07:40:00 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.510649.788725 (Exim 4.92) (envelope-from ) id 1pcolX-0006nU-Nl; Thu, 16 Mar 2023 14:39:39 +0000 Received: by outflank-mailman (output) from mailman id 510649.788725; Thu, 16 Mar 2023 14:39:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pcolX-0006n1-HM; Thu, 16 Mar 2023 14:39:39 +0000 Received: by outflank-mailman (input) for mailman id 510649; Thu, 16 Mar 2023 14:39:38 +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 1pcolW-0006hg-2o for xen-devel@lists.xenproject.org; Thu, 16 Mar 2023 14:39:38 +0000 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [2a00:1450:4864:20::52e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5f6f605f-c408-11ed-b464-930f4c7d94ae; Thu, 16 Mar 2023 15:39:35 +0100 (CET) Received: by mail-ed1-x52e.google.com with SMTP id eh3so8492482edb.11 for ; Thu, 16 Mar 2023 07:39:35 -0700 (PDT) Received: from fedora.. (46.204.101.131.nat.umts.dynamic.t-mobile.pl. [46.204.101.131]) by smtp.gmail.com with ESMTPSA id q16-20020a1709060e5000b008b980c3e013sm3970187eji.179.2023.03.16.07.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 07:39:35 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 5f6f605f-c408-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678977575; 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=YQMyKbzQe0AjQ7eGyuvY7xOmw9XaxRLiNTI1dISB708=; b=X+Pp4vF+BjOTTI9+tC6SgbPvdbpLNSCWCd+ov2PsheNQQfqYRDWn0CPyBmaA3IwQXw 9C2oydfDIUVrFFcTlsPwlf25PK9ycRc6vnpbRZT/HLOH4d0B4iWX0W5WfT0djQDidnwE FiD0b0vFb7NRnSf/68IB+aD4wwAacgZqDf1+4sBntFcJhzc6ifXpHyGean0vCoc1MxeT nWuib/viRD7Pczj+eiD/7X2MykirIrDL7xjJWWviE1zi1V8V1fZxVr1invQGU2RYLgB+ qlqYtaz8Zaf+TGzdCXlEAQW+bpWTTr3gy3Hv8Q+axtz3sRJ8taTeVCJbMUMXg++rIxM2 kC2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678977575; 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=YQMyKbzQe0AjQ7eGyuvY7xOmw9XaxRLiNTI1dISB708=; b=1y49TxGzP5T5l+YE/Ki0BLYe/m9/SOItdYB8xXHJAGir+XsQcLqxod6JpvkNc60us1 IgFcCtE5uuNBgGUNlXLXuUpxflzwCjRca6o5csAEo1eu00p3yjs1P5sk2ipOr3GHfinh CucDzxibh0gsY2Pddl/lJU1UvVkhY2oPml4j5DGnpDwZxfWc4pYP26qbIIbREzd9OZFS 8Mpp93LuOxfv9L+6Exteg4cmNFHIPGpDPunNVgAxmuIeXHJjtokklzaeojpm2TOiIytw PmN375RdykJRnSgwC9fu84yCchpu5sQkDMzya6bHVWConks57Jwp1JD3mCRdBYFPgTd9 qOnw== X-Gm-Message-State: AO0yUKWeDbjTyjohgqX4MYWhT+wlSfPH9efcrL9Sy9nEOXjnPfzIRLGn bL1bS+m1ifI6KKslhZYOBBj4Z3cjUR3beg== X-Google-Smtp-Source: AK7set9qqBVMh2bkP/3GgL0gqjIw1GS6jOmy7mvO21s2qCJ8T8i+Mz1gDMGirsCe+afTiTHnvRpd8g== X-Received: by 2002:a17:906:fe4c:b0:931:b34:4172 with SMTP id wz12-20020a170906fe4c00b009310b344172mr1419801ejb.3.1678977575171; Thu, 16 Mar 2023 07:39:35 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Julien Grall , Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v5 1/7] xen/riscv: introduce boot information structure Date: Thu, 16 Mar 2023 16:39:23 +0200 Message-Id: <553b07e967f56b78eba2d27c9115cce707a45c08.1678976127.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678977601594100005 Content-Type: text/plain; charset="utf-8" The structure holds information about: 1. linker start/end address 2. load start/end address Also the patch introduces offsets for boot information structure members to access them in assembly code. Signed-off-by: Oleksii Kurochko --- Changes in V5: * the patch was introduced in the current patch series (V5) --- xen/arch/riscv/include/asm/boot-info.h | 15 +++++++++++++++ xen/arch/riscv/riscv64/asm-offsets.c | 3 +++ 2 files changed, 18 insertions(+) create mode 100644 xen/arch/riscv/include/asm/boot-info.h diff --git a/xen/arch/riscv/include/asm/boot-info.h b/xen/arch/riscv/includ= e/asm/boot-info.h new file mode 100644 index 0000000000..cda3d278f5 --- /dev/null +++ b/xen/arch/riscv/include/asm/boot-info.h @@ -0,0 +1,15 @@ +#ifndef _ASM_BOOT_INFO_H +#define _ASM_BOOT_INFO_H + +extern struct boot_info { + unsigned long linker_start; + unsigned long linker_end; + unsigned long load_start; + unsigned long load_end; +} boot_info; + +/* LINK_TO_LOAD() and LOAD_TO_LINK() works only when MMU isn't enabled. */ +#define LINK_TO_LOAD(addr) ((addr) - boot_info.linker_start + boot_info.lo= ad_start) +#define LOAD_TO_LINK(addr) ((addr) - boot_info.load_start + boot_info.link= er_start) + +#endif \ No newline at end of file diff --git a/xen/arch/riscv/riscv64/asm-offsets.c b/xen/arch/riscv/riscv64/= asm-offsets.c index d632b75c2a..6b89e9a91d 100644 --- a/xen/arch/riscv/riscv64/asm-offsets.c +++ b/xen/arch/riscv/riscv64/asm-offsets.c @@ -1,5 +1,6 @@ #define COMPILE_OFFSETS =20 +#include #include #include =20 @@ -50,4 +51,6 @@ void asm_offsets(void) OFFSET(CPU_USER_REGS_SEPC, struct cpu_user_regs, sepc); OFFSET(CPU_USER_REGS_SSTATUS, struct cpu_user_regs, sstatus); OFFSET(CPU_USER_REGS_PREGS, struct cpu_user_regs, pregs); + OFFSET(BI_LINKER_START, struct boot_info, linker_start); + OFFSET(BI_LOAD_START, struct boot_info, load_start); } --=20 2.39.2 From nobody Sat Apr 27 02:20:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678977598; cv=none; d=zohomail.com; s=zohoarc; b=Jee7V0/IDy3eNUzTVx+fzDRhx53dHgxz+ortqGS/2YMS9ygXGkIA/wP+FDgPq5DBmQ3VmxSpDmKK1C8mUybyRZPwpvLU2BBK6Pm6uwJnSUtYFDYpAl/kPWw4MsEJJnUrz4fIiErlST5BuUXaNa8KRHUF6HtGlHrxXpnjKARHmH0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678977598; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FKTp6dhD+4idMmK9ijuA9b238S46/VfGSoR4ri38brw=; b=ieXQTBkZL6JFswzjtXPyFuroLDpoHru6OhQ/B4SDlDkcj83M3ndQcULnaVMZ6U4CDlOE5VA+A9cS+rWniyuFY8T3jIlR8yA5i4tALu1gixSuTtqY+gtE+JYEUcVlFRHt41OXpHZIqIvbd3OGcm3kO+7Hh4Gidih2/v39mtl8qrI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1678977598448765.0873789585471; Thu, 16 Mar 2023 07:39:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.510648.788719 (Exim 4.92) (envelope-from ) id 1pcolX-0006lL-DW; Thu, 16 Mar 2023 14:39:39 +0000 Received: by outflank-mailman (output) from mailman id 510648.788719; Thu, 16 Mar 2023 14:39:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pcolX-0006lE-AM; Thu, 16 Mar 2023 14:39:39 +0000 Received: by outflank-mailman (input) for mailman id 510648; Thu, 16 Mar 2023 14:39:37 +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 1pcolV-0006WA-Qr for xen-devel@lists.xenproject.org; Thu, 16 Mar 2023 14:39:37 +0000 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [2a00:1450:4864:20::535]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 603c7922-c408-11ed-87f5-c1b5be75604c; Thu, 16 Mar 2023 15:39:37 +0100 (CET) Received: by mail-ed1-x535.google.com with SMTP id h8so8550623ede.8 for ; Thu, 16 Mar 2023 07:39:37 -0700 (PDT) Received: from fedora.. (46.204.101.131.nat.umts.dynamic.t-mobile.pl. [46.204.101.131]) by smtp.gmail.com with ESMTPSA id q16-20020a1709060e5000b008b980c3e013sm3970187eji.179.2023.03.16.07.39.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 07:39:36 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 603c7922-c408-11ed-87f5-c1b5be75604c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678977576; 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=FKTp6dhD+4idMmK9ijuA9b238S46/VfGSoR4ri38brw=; b=jy8u2YoDJFHvNcDmZHex1DeiAuyMUA3z9f6y9fA2TTiO9KjAHPufx9C23cUXZjkrmk /yQEKIVernI1kqs+IBjUWBMQ5VDfPuwZQb6/FscIeVv0jEjt4I9+N5LzZ5ShFGoHVo/P GImQvTVbwEBoT9Yk9R5O+LI3/x12adNWbmtIDoBhi/7cCjR1Rppv1t+1ObMZi5PsERGy Xpwye8I/yxvSBCBnAa21OcLLyU59FYhzCFXwkCigtDjTjPpjfspK/vemHi+v77g4Pq4f tm9fk0945NjhfOdOHkX6XXq1Xtr4OgPHWDL8zaDAyUzYiIC+PF3aGHmBkVyg6DiUGGkO zCfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678977576; 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=FKTp6dhD+4idMmK9ijuA9b238S46/VfGSoR4ri38brw=; b=3GQk6BdvCSVHQYZbulkzpemPs2WUzpl0V0Qrq3rZI36+XCMXdyCuOw//46QinwafOj v7UAogEFo4OEZPWmbA+Y1nNlOI3GfVDFgtpy9aVaCVZ1c7WXC26Fv1v1mMCNvnwLFDNw gqFnKf2ML0Jap/e0zxl7HkParzUPq8spGapinKSUhH+jh63lsCl+1HJFQ2Raao+ZeNMP HoZ9yeu3ORQgYZYOyg1cKPsIsRrwDd22BF6fEKRzMtOG57sXDrUBrO52fZlo+ZtvMKVn NvsDnzqAwiTt4Rqu5+4I4+qaVHxz+N8Ji6ytBWmlzLAlmGlS4Aiy06Ix2RKgzuqmMvbE Vx0Q== X-Gm-Message-State: AO0yUKVhyMaXvZRO9Wi9QKAGgBcIrCUQ3bh7E3g2767UNsIeT++Dij/L sez4GuMmOckmkKuOfGuy5hNSsA0I7JUdCg== X-Google-Smtp-Source: AK7set8HtsRIID8Vf/liy0Uj8Kik4uprAzIHvvNP/SBbta69oYn2IjTXTo18aEGrsHyRMbTmEiYBEg== X-Received: by 2002:a17:906:d0cc:b0:84d:3403:f4f2 with SMTP id bq12-20020a170906d0cc00b0084d3403f4f2mr10321182ejb.62.1678977576604; Thu, 16 Mar 2023 07:39:36 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Julien Grall , Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v5 2/7] xen/riscv: initialize boot_info structure Date: Thu, 16 Mar 2023 16:39:24 +0200 Message-Id: <1941d4ed64ff6edcc6354d09d6a40db4d6f63c44.1678976127.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678977599776100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Oleksii Kurochko --- Changes in V5: * the patch was introduced in the current patch series (V5) --- xen/arch/riscv/setup.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index 0908bdb9f9..36556eb779 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -1,12 +1,16 @@ #include #include +#include =20 +#include #include =20 /* Xen stack for bringing up the first CPU. */ unsigned char __initdata cpu0_boot_stack[STACK_SIZE] __aligned(STACK_SIZE); =20 +struct boot_info boot_info =3D { (unsigned long)&_start, (unsigned long)&_= end, 0UL, 0UL }; + /* =20 * To be sure that .bss isn't zero. It will simplify code of * .bss initialization. @@ -15,11 +19,19 @@ unsigned char __initdata cpu0_boot_stack[STACK_SIZE] */ int dummy_bss __attribute__((unused)); =20 +static void fill_boot_info(void) +{ + boot_info.load_start =3D (unsigned long)_start; + boot_info.load_end =3D (unsigned long)_end; +} + void __init noreturn start_xen(unsigned long bootcpu_id, unsigned long dtb_paddr) { early_printk("Hello from C env\n"); =20 + fill_boot_info(); + early_printk("All set up\n"); for ( ;; ) asm volatile ("wfi"); --=20 2.39.2 From nobody Sat Apr 27 02:20:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678977599; cv=none; d=zohomail.com; s=zohoarc; b=dBOj0RiHpu6Gw12GRJXRjzgT9LuONRcr2NQgnF6Gobp17o2DPRyZ8PCiMmN5Hs2iQa1lC7Q5DGCQS5b8Tp6OC5TvPrMjMCeHSZCXq6glxqahzDCJuadui6jwB8Zs+T7a905vgH1K7jgnRFwehK6j1g8fm4CxLOOd+xaKbm1VCv4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678977599; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uotKGM8ahFKgf3MT0pEjvm7HDKJnl+RTbHm3nOfbQEM=; b=nwKLi9O3pTypxFNdoDNhZ55N+synmolh8wmiddktM4vdjH1FtY1sVQwd9LZY/+Du6apc1E+88ESsxAf5xDKybZxs8FdPR3eFTABzszBVqvIAjZ9zdbym2s2pqPUyXefDzA8TubY5SJQ5YTP9rZ0z0eSsCMA66wbnOABWvJaCVxw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1678977599920411.5121823456501; Thu, 16 Mar 2023 07:39:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.510650.788739 (Exim 4.92) (envelope-from ) id 1pcolZ-0007H8-Ve; Thu, 16 Mar 2023 14:39:41 +0000 Received: by outflank-mailman (output) from mailman id 510650.788739; Thu, 16 Mar 2023 14:39:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pcolZ-0007H1-SU; Thu, 16 Mar 2023 14:39:41 +0000 Received: by outflank-mailman (input) for mailman id 510650; Thu, 16 Mar 2023 14:39:40 +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 1pcolY-0006hg-6Q for xen-devel@lists.xenproject.org; Thu, 16 Mar 2023 14:39:40 +0000 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [2a00:1450:4864:20::532]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6113a9ab-c408-11ed-b464-930f4c7d94ae; Thu, 16 Mar 2023 15:39:38 +0100 (CET) Received: by mail-ed1-x532.google.com with SMTP id z21so8615593edb.4 for ; Thu, 16 Mar 2023 07:39:38 -0700 (PDT) Received: from fedora.. (46.204.101.131.nat.umts.dynamic.t-mobile.pl. [46.204.101.131]) by smtp.gmail.com with ESMTPSA id q16-20020a1709060e5000b008b980c3e013sm3970187eji.179.2023.03.16.07.39.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 07:39:37 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 6113a9ab-c408-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678977578; 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=uotKGM8ahFKgf3MT0pEjvm7HDKJnl+RTbHm3nOfbQEM=; b=HSf9ESpnA/hZJ4sxBlL27WhTheR6Ct9DuyI+EoDvGqQ1XMVLg2MTokt1W2ys2HMH/m shZHveECFFwSIlwpmV2Ojk+52zEKf579YGJVqCSjtljsBd15B0NEz/9ikBkBXFEM2sJl asRzT266OAMg6Gw60MzBNBqaU/ZsXEKOehIthCkfMYY3g86MwmsMyTtAjb3y1W4p3meD h1MiBVB3cmXsaL5jwAwv807c1+ZDfPGb5NUZX8rN9RvCxtkYpaKoz5S5PosutMj53vNR CMPjhXF1EcQxUYQ2eHGY0aVl4oeLRpxgjX/XHG4w9YOMW1sCFUD/UW2z7H3hc9QDlm0f X4Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678977578; 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=uotKGM8ahFKgf3MT0pEjvm7HDKJnl+RTbHm3nOfbQEM=; b=z2ChNZEYkBlJVkS83Vu68V0smpvTSNm45yJmzLTk2LA9Urk3eOX0jeTyPzaYfk/LJt XZ+WWXLC13qkc4SYK0tdLvYAk44ELy44rT13JVOaGJDvQWFO92GRe66hTZajKHYXqNBF TZKGbLrohibFgHBVmLAt4JpzVbCkfMtwd7F0wWi9FRBTq8lskJHaQd9lCSl2ikLTrcKi Rt3HAiIiMpQ0Ud7LfW8jtWim03SNMcQh/0KCtBneMrQumjvGMw5i0CiBLoPDf/GjvdD9 G8Zndolzf3nZ40mNYFNQK2VDbBiCjH025nvVWLYakQNYp9aIezss/+mfb1sOF9VXigf4 orKA== X-Gm-Message-State: AO0yUKX438lc/ImYjtCYK1vX9figZ3Y+dXHOdy6oQJuRwtPqqgJEyiZ2 GRRXaTOBgM0pE6ILd4cT75opRXyGWkdWhg== X-Google-Smtp-Source: AK7set8Ru4rQtVOEgpLtDmbBvbuwUibac+vfcTcMMNJ7ATqF7bTay3xanj6Hf6gEvZuRhmnQg0a5pA== X-Received: by 2002:a17:906:d0cc:b0:84d:3403:f4f2 with SMTP id bq12-20020a170906d0cc00b0084d3403f4f2mr10321280ejb.62.1678977578043; Thu, 16 Mar 2023 07:39:38 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Julien Grall , Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v5 3/7] xen/riscv: introduce dummy Date: Thu, 16 Mar 2023 16:39:25 +0200 Message-Id: <82aa35ce27ca11076bbafbb565e9c85e1ce7624d.1678976127.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678977601682100007 Content-Type: text/plain; charset="utf-8" will be used in the patch "xen/riscv: introduce decode_cause() stuff" and requires Signed-off-by: Oleksii Kurochko --- Changes in V5: * the patch was introduced in the current patch series (V5) --- xen/arch/riscv/include/asm/bug.h | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 xen/arch/riscv/include/asm/bug.h diff --git a/xen/arch/riscv/include/asm/bug.h b/xen/arch/riscv/include/asm/= bug.h new file mode 100644 index 0000000000..e8b1e40823 --- /dev/null +++ b/xen/arch/riscv/include/asm/bug.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2012 Regents of the University of California + * Copyright (C) 2021-2023 Vates + * + */ +#ifndef _ASM_RISCV_BUG_H +#define _ASM_RISCV_BUG_H + +#endif /* _ASM_RISCV_BUG_H */ --=20 2.39.2 From nobody Sat Apr 27 02:20:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678977599; cv=none; d=zohomail.com; s=zohoarc; b=IWHoNs6FCDIt5lB1uubTrpNkxkltQEA9vF4WKRBt7UAyAlDsf0LKhGmxfDWZkApiSa0VR7XSiDciAm3wP2gpjJW7dreTeOm7xoI/tmM64/8Ie+eC8+vej/7XQVfsk1R+9Ow6lo1S/S5XWLHrW14Fkhv51MlegwJrjo8BWx3aEC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678977599; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QwhZUEDbU03FgtZvxsT8dmiRdPOC/MCr+LKArTSUuK0=; b=gIyVXEGVHlggRxSd1MfwSZsB3WgoWcyz/RJbBUUcyPD78KFxQDC/TCf3eNGuvwgRIwJk/grX2Fu2G7kIpQtcyNMhYefhpkZBmmjpyyUkmpTRIO8eK8puo1mtbxNYIOdnAZtjxghTfV4m5noeLVQS7+TcksI3x5zWO8F9StG+JqA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1678977599465918.788925927967; Thu, 16 Mar 2023 07:39:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.510651.788743 (Exim 4.92) (envelope-from ) id 1pcola-0007Ka-9W; Thu, 16 Mar 2023 14:39:42 +0000 Received: by outflank-mailman (output) from mailman id 510651.788743; Thu, 16 Mar 2023 14:39:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pcola-0007JL-4V; Thu, 16 Mar 2023 14:39:42 +0000 Received: by outflank-mailman (input) for mailman id 510651; Thu, 16 Mar 2023 14:39:40 +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 1pcolY-0006WA-H7 for xen-devel@lists.xenproject.org; Thu, 16 Mar 2023 14:39:40 +0000 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [2a00:1450:4864:20::534]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 61e69eac-c408-11ed-87f5-c1b5be75604c; Thu, 16 Mar 2023 15:39:39 +0100 (CET) Received: by mail-ed1-x534.google.com with SMTP id cy23so8471774edb.12 for ; Thu, 16 Mar 2023 07:39:40 -0700 (PDT) Received: from fedora.. (46.204.101.131.nat.umts.dynamic.t-mobile.pl. [46.204.101.131]) by smtp.gmail.com with ESMTPSA id q16-20020a1709060e5000b008b980c3e013sm3970187eji.179.2023.03.16.07.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 07:39:39 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 61e69eac-c408-11ed-87f5-c1b5be75604c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678977579; 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=QwhZUEDbU03FgtZvxsT8dmiRdPOC/MCr+LKArTSUuK0=; b=LfCilxI99YjO1HEPhb9/5Iip+mUoAlN/FaC4RdMQLB1L7MweN8Y0FYUIgEuTj8lQ9D A7LZThJfxU43bPO/EFOOzPXyNC8DpsiB/qIoGH4KmUy5PZE2aHZqyyVCM0suNpEscGq6 XYH1trmXu66/0Zh/dyZJYOUoZ/qEdbYpC/SmNY9yXp2Kj50K2gBSVXmYCFKI9++cOeCA oC+P6xoC/lFSoms266G4CvwNac21sXBfuEn2nyLnhy7ZzCJFt6acWBd87iqteL2ew+e7 dnALpvuSIiKmciecZrGsLb39wf8eZi5aAR7lDUfrmUV+b+DrZ8MTrzh7fRDoHKsjHzkz ApgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678977579; 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=QwhZUEDbU03FgtZvxsT8dmiRdPOC/MCr+LKArTSUuK0=; b=3TPWYrcyNRa4g0nME061OxNhAloKw3ZZ3zf75knKrEELncxhXRsl+rHS4omE1loqkn hOrAa0u6l6z2YzpG9UsGqipyxLKrWTuDZTQ3GLYeIf5epDDnmeOTRw6gbAzJscSmfxOy GJXa4vauTh+54rwmIrL0SXvKJa+jwubZVFI+iMvsbGr6845Zxl2V5+cPY7Fri9XbqR3f T3/a1H5VCm8Ql6bZy8kOSeBY8sqihMH5qXLk2P7jNpaWTr8yYp3nSZ+huAnsl/3qU0fH 9sYnP4/40fYfBg5oWOJCljUDcDeLTog0ERCcrJAdpfR+DwR/MlcuB28Kkl1rCsCS7oOK xp1A== X-Gm-Message-State: AO0yUKVr/JqygDLbHDaKCsdwtkwrf/B6NMcPUuZmJiA3Ut7/PoB98vWD ZTswymlpZoGpbXuWu/X9ZawoDGzVQJ5fgA== X-Google-Smtp-Source: AK7set+Vrw/c5buXIsbsEI62JvWFHhRvEkwkzgagKamP974RO2D+8gf004qYvaTQBzeTEN/ggAfbsw== X-Received: by 2002:a17:907:dab:b0:92f:b290:78c with SMTP id go43-20020a1709070dab00b0092fb290078cmr6091041ejc.21.1678977579482; Thu, 16 Mar 2023 07:39:39 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Julien Grall , Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v5 4/7] xen/riscv: introduce decode_cause() stuff Date: Thu, 16 Mar 2023 16:39:26 +0200 Message-Id: <8c7b4a5d328be8b1cd2aa99c8d9a7883e4969600.1678976127.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678977601507100003 Content-Type: text/plain; charset="utf-8" The patch introduces stuff needed to decode a reason of an exception. Signed-off-by: Oleksii Kurochko --- Changes in V5: - Remove from riscv/traps/c as nothing would require inclusion. - decode_reserved_interrupt_cause(), decode_interrupt_cause(), decode_cau= se, do_unexpected_trap() were made as static they are expected to be used only in traps.c - use LINK_TO_LOAD() for addresses which can be linker time relative. --- Changes in V4: - fix string in decode_reserved_interrupt_cause() --- Changes in V3: - Nothing changed --- Changes in V2: - Make decode_trap_cause() more optimization friendly. - Merge the pathc which introduces do_unexpected_trap() to the current on= e. --- xen/arch/riscv/traps.c | 87 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c index ccd3593f5a..8a1529e0c5 100644 --- a/xen/arch/riscv/traps.c +++ b/xen/arch/riscv/traps.c @@ -4,10 +4,95 @@ * * RISC-V Trap handlers */ + +#include + +#include +#include +#include #include #include =20 -void do_trap(struct cpu_user_regs *cpu_regs) +static const char *decode_trap_cause(unsigned long cause) +{ + static const char *const trap_causes[] =3D { + [CAUSE_MISALIGNED_FETCH] =3D "Instruction Address Misaligned", + [CAUSE_FETCH_ACCESS] =3D "Instruction Access Fault", + [CAUSE_ILLEGAL_INSTRUCTION] =3D "Illegal Instruction", + [CAUSE_BREAKPOINT] =3D "Breakpoint", + [CAUSE_MISALIGNED_LOAD] =3D "Load Address Misaligned", + [CAUSE_LOAD_ACCESS] =3D "Load Access Fault", + [CAUSE_MISALIGNED_STORE] =3D "Store/AMO Address Misaligned", + [CAUSE_STORE_ACCESS] =3D "Store/AMO Access Fault", + [CAUSE_USER_ECALL] =3D "Environment Call from U-Mode", + [CAUSE_SUPERVISOR_ECALL] =3D "Environment Call from S-Mode", + [CAUSE_MACHINE_ECALL] =3D "Environment Call from M-Mode", + [CAUSE_FETCH_PAGE_FAULT] =3D "Instruction Page Fault", + [CAUSE_LOAD_PAGE_FAULT] =3D "Load Page Fault", + [CAUSE_STORE_PAGE_FAULT] =3D "Store/AMO Page Fault", + [CAUSE_FETCH_GUEST_PAGE_FAULT] =3D "Instruction Guest Page Fault", + [CAUSE_LOAD_GUEST_PAGE_FAULT] =3D "Load Guest Page Fault", + [CAUSE_VIRTUAL_INST_FAULT] =3D "Virtualized Instruction Fault", + [CAUSE_STORE_GUEST_PAGE_FAULT] =3D "Guest Store/AMO Page Fault", + }; + + if ( cause < ARRAY_SIZE(trap_causes) && trap_causes[cause] ) + return trap_causes[cause]; + return "UNKNOWN"; +} + +static const char *decode_reserved_interrupt_cause(unsigned long irq_cause) +{ + switch ( irq_cause ) + { + case IRQ_M_SOFT: + return "M-mode Software Interrupt"; + case IRQ_M_TIMER: + return "M-mode TIMER Interrupt"; + case IRQ_M_EXT: + return "M-mode External Interrupt"; + default: + return "UNKNOWN IRQ type"; + } +} + +static const char *decode_interrupt_cause(unsigned long cause) +{ + unsigned long irq_cause =3D cause & ~CAUSE_IRQ_FLAG; + + switch ( irq_cause ) + { + case IRQ_S_SOFT: + return "Supervisor Software Interrupt"; + case IRQ_S_TIMER: + return "Supervisor Timer Interrupt"; + case IRQ_S_EXT: + return "Supervisor External Interrupt"; + default: + return decode_reserved_interrupt_cause(irq_cause); + } +} + +static const char *decode_cause(unsigned long cause) +{ + if ( cause & CAUSE_IRQ_FLAG ) + return decode_interrupt_cause(cause); + + return decode_trap_cause(cause); +} + +static void do_unexpected_trap(const struct cpu_user_regs *regs) { + unsigned long cause =3D csr_read(CSR_SCAUSE); + + early_printk("Unhandled exception: "); + early_printk(LINK_TO_LOAD(decode_cause(cause))); + early_printk("\n"); + die(); } + +void do_trap(struct cpu_user_regs *cpu_regs) +{ + do_unexpected_trap(cpu_regs); +} --=20 2.39.2 From nobody Sat Apr 27 02:20:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678977601; cv=none; d=zohomail.com; s=zohoarc; b=oHIMdWdxKu3AcRiNBFbupLdg5/FXWq+/EnnoUKGHTR8wix0mLZhKAgbaTE6VeVJVZghRSmR6Rr8yQC6ZPOKs0K0qdvrEAYg0bjWo0Fz7MWxxBDr6TXOwsXL574AlGsjBOyZWvxMI4ttr2sQAjgOZGAPHva7EQm1UQRvFXyBjfyE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678977601; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L+oNxTKcsx1V4FRFzCufKSsxTMBMI/DOdCYZTlMD0WU=; b=Eh39U3EkzsS9QmG8m1lOlxpXUfUGe6LNiqJGdCYNItAnjhWLSGR016xDYT/n7HNxzGYH83Z9GvzKmhAtOC65xQUgi9Il69jHkUTo1VCsab6iaeLyT0Wb1P/uyte3paTK8+gchdlUc6PPQMQca+Y4o3Te2rsRH+on9rv8ndG98mU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1678977601294452.651042544686; Thu, 16 Mar 2023 07:40:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.510652.788759 (Exim 4.92) (envelope-from ) id 1pcolc-0007qA-Hy; Thu, 16 Mar 2023 14:39:44 +0000 Received: by outflank-mailman (output) from mailman id 510652.788759; Thu, 16 Mar 2023 14:39:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pcolc-0007pz-D6; Thu, 16 Mar 2023 14:39:44 +0000 Received: by outflank-mailman (input) for mailman id 510652; Thu, 16 Mar 2023 14:39:43 +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 1pcolb-0006hg-7F for xen-devel@lists.xenproject.org; Thu, 16 Mar 2023 14:39:43 +0000 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [2a00:1450:4864:20::52f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 62d3d3dc-c408-11ed-b464-930f4c7d94ae; Thu, 16 Mar 2023 15:39:41 +0100 (CET) Received: by mail-ed1-x52f.google.com with SMTP id ek18so8572499edb.6 for ; Thu, 16 Mar 2023 07:39:41 -0700 (PDT) Received: from fedora.. (46.204.101.131.nat.umts.dynamic.t-mobile.pl. [46.204.101.131]) by smtp.gmail.com with ESMTPSA id q16-20020a1709060e5000b008b980c3e013sm3970187eji.179.2023.03.16.07.39.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 07:39:40 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 62d3d3dc-c408-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678977581; 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=L+oNxTKcsx1V4FRFzCufKSsxTMBMI/DOdCYZTlMD0WU=; b=OH3IkYV0idjDWqvJYDmmV43va+dtXqyIM4tpTxwUbU6gSX28jZMbjvEl7q2by1s49w Grg/qo/bi8/O2PhNxTBva3I2G9vqCDoi4UsPF7BFQLW5J4o68ZRR1lUGnzNIUWP0RS9N 4JDmQpOIIGWFVMKqLd0XITZBS0sT1UJhOEeN5eK15wdb4GpGk/LYzfAa6Q5BswX5sr0p KzOibXQLdAv1+yItdnXPj7jP7CmMC7GwnFB8XHyhdHrhdlP+Y9RgvOT+0GC3o5TZ75PC gajqhsqpyCoDv7japRrDgGU7Rf9cIkWCxM41qqaZsSKfSxxOfMCsVGlldcbAZPoQ/8iL pRlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678977581; 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=L+oNxTKcsx1V4FRFzCufKSsxTMBMI/DOdCYZTlMD0WU=; b=B6VX7xLuOZTEM1qDetAfuK9OXFTO4IIs/leOIR05VAg0PSURW2DDMsxm63+mDmtfVN qAvxHwLGE6/OgXm74fofHkNJ9irJKJ8UfsjyJ+pcx4ODcxYkf2nlmaBVKpbvsWLR8QEy 278+LLMGJho0mpgKprEc/rmdbRVLuuji6uOU5vlfhoLHKl1Jy7wPrhzK3cngfsrQifOo CZLLkq+kKdedYHPQSseBveR1vsjHS4thou/0NV5f71LONNhf6MJcNvqz5C+HEyLFAfUC sMYzv1m1beUO52WagJHivPUIKQARb9jdUtDr0EJCP/jehtoDjtflWtowYaUEjxevcb6f XTnQ== X-Gm-Message-State: AO0yUKX4SbXrmeK/ew6Ch3zDp2bAAtP7xyUS0RRkhyAwaHVO+Sq2p+R0 2YNMAc6nD3o/YJL+tpX/JQ0026C6XptNUg== X-Google-Smtp-Source: AK7set94yAmmz9NW6r6NpoX2YsE+xbesnwj+czE9vNO9NPnxwu0LyVkJ20ICj5GIYnHciAFmB7rY8A== X-Received: by 2002:a17:907:7283:b0:92f:e4c5:5a28 with SMTP id dt3-20020a170907728300b0092fe4c55a28mr5146754ejc.54.1678977581092; Thu, 16 Mar 2023 07:39:41 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Julien Grall , Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v5 5/7] xen/riscv: introduce trap_init() Date: Thu, 16 Mar 2023 16:39:27 +0200 Message-Id: <91b0284d20f530f2795a119ccb7436ee0b800256.1678976127.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678977601687100008 Content-Type: text/plain; charset="utf-8" Signed-off-by: Oleksii Kurochko Reviewed-by: Alistair Francis --- 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 | 5 +++++ xen/arch/riscv/traps.c | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/xen/arch/riscv/include/asm/traps.h b/xen/arch/riscv/include/as= m/traps.h index f3fb6b25d1..f1879294ef 100644 --- a/xen/arch/riscv/include/asm/traps.h +++ b/xen/arch/riscv/include/asm/traps.h @@ -7,6 +7,7 @@ =20 void do_trap(struct cpu_user_regs *cpu_regs); void handle_trap(void); +void trap_init(void); =20 #endif /* __ASSEMBLY__ */ =20 diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index 36556eb779..b44d105b5f 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -3,7 +3,9 @@ #include =20 #include +#include #include +#include =20 /* Xen stack for bringing up the first CPU. */ unsigned char __initdata cpu0_boot_stack[STACK_SIZE] @@ -32,7 +34,10 @@ void __init noreturn start_xen(unsigned long bootcpu_id, =20 fill_boot_info(); =20 + trap_init(); + early_printk("All set up\n"); + for ( ;; ) asm volatile ("wfi"); =20 diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c index 8a1529e0c5..581f34efbc 100644 --- a/xen/arch/riscv/traps.c +++ b/xen/arch/riscv/traps.c @@ -13,6 +13,13 @@ #include #include =20 +void trap_init(void) +{ + unsigned long addr =3D (unsigned long)&handle_trap; + + csr_write(CSR_STVEC, addr); +} + static const char *decode_trap_cause(unsigned long cause) { static const char *const trap_causes[] =3D { --=20 2.39.2 From nobody Sat Apr 27 02:20:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678977603; cv=none; d=zohomail.com; s=zohoarc; b=KJrLtpVsVN//vrH6AO5J9Y+1IFaT4Rmey/8GM79BtttsLio7ZhFrvAKynjIaDggPqZj4nJA3g2IuA0qpCfEaO8fkExLabeqBDKHQMGBXobb3bmP81vw1P2dKdBIzTsubluncGKabKMzlmJXgAv/KnEvHXcH8UY4GbnheoAq3/Is= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678977603; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X7oCfkecOQ2j8RepZ+CNQJX2PvriCtlq7k5FrgLtuck=; b=Oiqe6IAhHEXr91MdgTre4oeee+CXYzC0q+VaLhnzDWZwLW0mtM0VAJduqxgsfhVNrvgyJKAJYcaBslW8+g7pNdrBf364hV+seaqxG+u58A87WyZg20yNNs+VP9a3N2sSQQMP8mrQzsek73/bxVMQy3/QvZO5iDKKtH7VyHsYUA0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 167897760357344.1869863686569; Thu, 16 Mar 2023 07:40:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.510653.788769 (Exim 4.92) (envelope-from ) id 1pcold-00086X-Rt; Thu, 16 Mar 2023 14:39:45 +0000 Received: by outflank-mailman (output) from mailman id 510653.788769; Thu, 16 Mar 2023 14:39:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pcold-00085y-Le; Thu, 16 Mar 2023 14:39:45 +0000 Received: by outflank-mailman (input) for mailman id 510653; Thu, 16 Mar 2023 14:39:44 +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 1pcolc-0006WA-26 for xen-devel@lists.xenproject.org; Thu, 16 Mar 2023 14:39:44 +0000 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [2a00:1450:4864:20::536]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 63c912cb-c408-11ed-87f5-c1b5be75604c; Thu, 16 Mar 2023 15:39:43 +0100 (CET) Received: by mail-ed1-x536.google.com with SMTP id r11so8604768edd.5 for ; Thu, 16 Mar 2023 07:39:43 -0700 (PDT) Received: from fedora.. (46.204.101.131.nat.umts.dynamic.t-mobile.pl. [46.204.101.131]) by smtp.gmail.com with ESMTPSA id q16-20020a1709060e5000b008b980c3e013sm3970187eji.179.2023.03.16.07.39.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 07:39:42 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 63c912cb-c408-11ed-87f5-c1b5be75604c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678977582; 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=X7oCfkecOQ2j8RepZ+CNQJX2PvriCtlq7k5FrgLtuck=; b=ReeUJVL8vnLrnkGDEYCiEAvmh2/kVs6V6fBk3Cao+CH5kHEuDwfI1oiab9Px+Owjtn ipCS/XESu7EKCBflzL8xyII5DBsiQ8/9aMXyFCob+UrVT84rGzbebryKQB4Isty34Ym4 U4HClM8HwrvJBw1DzqYA9LbQoLocSItziAcEjK+Ad2nOQdMvnr1MkMPmN7ukAG37uyJO OBtT/9UTldewNl/nFSmgu4TQB5w/Ab4hrUCVDnDMKlbZ7eV4z6j2hIpziyhu9oI7LsEq OU/LGWI3uRHxc3h3K4RlOvLMUKFlXQn9GbejX6pTYUADiKI8KgHL+fsyYvRX3gfbt3XJ rcRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678977582; 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=X7oCfkecOQ2j8RepZ+CNQJX2PvriCtlq7k5FrgLtuck=; b=7KqNYB/SenSwcbQe3WM3+YGQbc5OnlWc3Bn5mIQRmZ5PmB1JoOmVZEpY6CokrLHD9H /AnJpEXN6fRfbPviJSfF5T+LA9hEhKE1/GRiY6pOhrVq8LqVdTsjgpMHQQEILgiwp2MP fPfdatl00SSxNo06dkfn/ZodthBb63wHNbUWAm3eqkV4df0XPY4fB/9Eppyuea79Ug3O 245QUmi/asWEC5CCIX1Zy/3GcLi9Ep5JjAzcB0evouy3//Acb/M9reTwwyMYnKzoGUuY Q6RY97YFNwBswAK0mFL7zisFyVBTSxiq3J4MY/rI2AS2YLF56NM7lZu+foxxBv8z1PP4 BLpQ== X-Gm-Message-State: AO0yUKX5+hC+IuXtX4Yit7i5Dw2T2hQ2Srg2sd8Yi60QXzaeDrM8TMKG vdAWWtWJJPbUGKgEm++74xchcW8WXGqHvw== X-Google-Smtp-Source: AK7set+q1LnSNVGK3HLixY3bvOEyRMc7E0nYtEaG8ouEXoSfiSM/qCUkTuNzaUhLt52K7viCbzpyRA== X-Received: by 2002:a17:906:5a95:b0:7e0:eed0:8beb with SMTP id l21-20020a1709065a9500b007e0eed08bebmr10305130ejq.41.1678977582626; Thu, 16 Mar 2023 07:39:42 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Julien Grall , Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v5 6/7] xen/riscv: introduce an implementation of macros from Date: Thu, 16 Mar 2023 16:39:28 +0200 Message-Id: <67807e242d3e12f1080956eea052285cb67a7dbf.1678976127.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678977605705100001 Content-Type: text/plain; charset="utf-8" The patch introduces macros: BUG(), WARN(), run_in_exception(), assert_failed. To be precise, the macros from generic bug implementation () will be used. The implementation uses "ebreak" instruction in combination with diffrent bug frame tables (for each type) which contains useful information. Signed-off-by: Oleksii Kurochko --- Changes in V5: - Remove "#include " from as there is no any nee= d in it anymore - Update macros GET_INSN_LENGTH: remove UL and 'unsigned int len;' from it - Remove " include " from risc/setup.c. it is not needed in th= e current version of the patch - change an argument type from vaddr_t to uint32_t for is_valid_bugaddr a= nd introduce read_instr() to read instruction properly as the length of qinstruction can be either 3= 2 or 16 bits. - Code style fixes - update the comments before do_bug_frame() in riscv/trap.c - Refactor is_valid_bugaddr() function. - introduce macros cast_to_bug_frame(addr) to hide casts. - use LINK_TO_LOAD() for addresses which are linker time relative. --- Changes in V4: - Updates in RISC-V's : * Add explanatory comment about why there is only defined for 32-bits l= ength instructions and 16/32-bits BUG_INSN_{16,32}. * Change 'unsigned long' to 'unsigned int' inside GET_INSN_LENGTH(). * Update declaration of is_valid_bugaddr(): switch return type from int= to bool and the argument from 'unsigned int' to 'vaddr'. - Updates in RISC-V's traps.c: * replace /xen and /asm includes=20 * update definition of is_valid_bugaddr():switch return type from int t= o bool and the argument from 'unsigned int' to 'vaddr'. Code style inside fu= nction was updated too. * do_bug_frame() refactoring: * local variables start and bug became 'const struct bug_frame' * bug_frames[] array became 'static const struct bug_frame[] =3D ...' * remove all casts * remove unneeded comments and add an explanatory comment that the do= _bug_frame() will be switched to a generic one. * do_trap() refactoring: * read 16-bits value instead of 32-bits as compressed instruction can be used and it might happen than only 16-bits may be accessible. * code style updates * re-use instr variable instead of re-reading instruction. - Updates in setup.c: * add blank line between xen/ and asm/ includes. --- Changes in V3: - Rebase the patch "xen/riscv: introduce an implementation of macros from " on top of patch series [introduce generic implementat= ion of macros from bug.h] --- Changes in V2: - Remove __ in define namings - Update run_in_exception_handler() with register void *fn_ asm(__stringify(BUG_FN_REG)) =3D (fn); - Remove bug_instr_t type and change it's usage to uint32_t --- xen/arch/riscv/include/asm/bug.h | 28 +++++ xen/arch/riscv/include/asm/processor.h | 2 + xen/arch/riscv/traps.c | 139 +++++++++++++++++++++++++ xen/arch/riscv/xen.lds.S | 10 ++ 4 files changed, 179 insertions(+) diff --git a/xen/arch/riscv/include/asm/bug.h b/xen/arch/riscv/include/asm/= bug.h index e8b1e40823..bf3194443f 100644 --- a/xen/arch/riscv/include/asm/bug.h +++ b/xen/arch/riscv/include/asm/bug.h @@ -7,4 +7,32 @@ #ifndef _ASM_RISCV_BUG_H #define _ASM_RISCV_BUG_H =20 +#ifndef __ASSEMBLY__ + +#define BUG_INSTR "ebreak" + +/* + * The base instruction set has a fixed length of 32-bit naturally aligned + * instructions. + * + * There are extensions of variable length ( where each instruction can be + * any number of 16-bit parcels in length ) but they aren't used in Xen + * and Linux kernel ( where these definitions were taken from ). + * + * Compressed ISA is used now where the instruction length is 16 bit and + * 'ebreak' instruction, in this case, can be either 16 or 32 bit ( + * depending on if compressed ISA is used or not ) + */ +#define INSN_LENGTH_MASK _UL(0x3) +#define INSN_LENGTH_32 _UL(0x3) + +#define BUG_INSN_32 _UL(0x00100073) /* ebreak */ +#define BUG_INSN_16 _UL(0x9002) /* c.ebreak */ +#define COMPRESSED_INSN_MASK _UL(0xffff) + +#define GET_INSN_LENGTH(insn) \ + (((insn) & INSN_LENGTH_MASK) =3D=3D INSN_LENGTH_32 ? 4 : 2) \ + +#endif /* !__ASSEMBLY__ */ + #endif /* _ASM_RISCV_BUG_H */ diff --git a/xen/arch/riscv/include/asm/processor.h b/xen/arch/riscv/includ= e/asm/processor.h index a71448e02e..ef23d9589e 100644 --- a/xen/arch/riscv/include/asm/processor.h +++ b/xen/arch/riscv/include/asm/processor.h @@ -69,6 +69,8 @@ static inline void die(void) wfi(); } =20 +void show_execution_state(const struct cpu_user_regs *regs); + #endif /* __ASSEMBLY__ */ =20 #endif /* _ASM_RISCV_PROCESSOR_H */ diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c index 581f34efbc..2afcabb912 100644 --- a/xen/arch/riscv/traps.c +++ b/xen/arch/riscv/traps.c @@ -5,6 +5,8 @@ * RISC-V Trap handlers */ =20 +#include +#include #include =20 #include @@ -13,6 +15,10 @@ #include #include =20 +#define cast_to_bug_frame(addr) \ + (const struct bug_frame *)(LINK_TO_LOAD((char *)addr)) + + void trap_init(void) { unsigned long addr =3D (unsigned long)&handle_trap; @@ -99,7 +105,140 @@ static void do_unexpected_trap(const struct cpu_user_r= egs *regs) die(); } =20 +void show_execution_state(const struct cpu_user_regs *regs) +{ + early_printk("implement show_execution_state(regs)\n"); +} + +/* + * TODO: change early_printk's function to early_printk with format + * when s(n)printf() will be added. + * + * Probably the TODO won't be needed as generic do_bug_frame() + * has been introduced and current implementation will be replaced + * with generic one when panic(), printk() and find_text_region() + * (virtual memory?) will be ready/merged + */ +int do_bug_frame(const struct cpu_user_regs *regs, vaddr_t pc) +{ + const struct bug_frame *start, *end; + const struct bug_frame *bug =3D NULL; + unsigned int id =3D 0; + const char *filename, *predicate; + int lineno; + + static const struct bug_frame* bug_frames[] =3D { + &__start_bug_frames[0], + &__stop_bug_frames_0[0], + &__stop_bug_frames_1[0], + &__stop_bug_frames_2[0], + &__stop_bug_frames_3[0], + }; + + for ( id =3D 0; id < BUGFRAME_NR; id++ ) + { + start =3D cast_to_bug_frame(bug_frames[id]); + end =3D cast_to_bug_frame(bug_frames[id + 1]); + + while ( start !=3D end ) + { + if ( (vaddr_t)bug_loc(start) =3D=3D pc ) + { + bug =3D start; + goto found; + } + + start++; + } + } + + found: + if ( bug =3D=3D NULL ) + return -ENOENT; + + if ( id =3D=3D BUGFRAME_run_fn ) + { + void (*fn)(const struct cpu_user_regs *) =3D bug_ptr(bug); + + fn(regs); + + goto end; + } + + /* WARN, BUG or ASSERT: decode the filename pointer and line number. */ + filename =3D bug_ptr(bug); + lineno =3D bug_line(bug); + + switch ( id ) + { + case BUGFRAME_warn: + early_printk("Xen WARN at "); + early_printk(filename); + early_printk("\n"); + + show_execution_state(regs); + + goto end; + + case BUGFRAME_bug: + early_printk("Xen BUG at "); + early_printk(filename); + early_printk("\n"); + + show_execution_state(regs); + early_printk("change wait_for_interrupt to panic() when common is = available\n"); + die(); + + case BUGFRAME_assert: + /* ASSERT: decode the predicate string pointer. */ + predicate =3D bug_msg(bug); + + early_printk("Assertion \'"); + early_printk(predicate); + early_printk("\' failed at "); + early_printk(filename); + early_printk("\n"); + + show_execution_state(regs); + early_printk("change wait_for_interrupt to panic() when common is = available\n"); + die(); + } + + return -EINVAL; + + end: + return 0; +} + +static bool is_valid_bugaddr(uint32_t insn) +{ + return insn =3D=3D BUG_INSN_32 || + (insn & COMPRESSED_INSN_MASK) =3D=3D BUG_INSN_16; +} + +static uint32_t read_instr(unsigned long pc) +{ + uint16_t instr16 =3D *(uint16_t *)pc; + + if ( GET_INSN_LENGTH(instr16) =3D=3D 2 ) + return (uint32_t)instr16; + else + return *(uint32_t *)pc; +} + void do_trap(struct cpu_user_regs *cpu_regs) { + register_t pc =3D cpu_regs->sepc; + uint32_t instr =3D read_instr(pc); + + if ( is_valid_bugaddr(instr) ) + { + if ( !do_bug_frame(cpu_regs, pc) ) + { + cpu_regs->sepc +=3D GET_INSN_LENGTH(instr); + return; + } + } + do_unexpected_trap(cpu_regs); } diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S index f299ea8422..eed457c492 100644 --- a/xen/arch/riscv/xen.lds.S +++ b/xen/arch/riscv/xen.lds.S @@ -40,6 +40,16 @@ SECTIONS . =3D ALIGN(PAGE_SIZE); .rodata : { _srodata =3D .; /* Read-only data */ + /* Bug frames table */ + __start_bug_frames =3D .; + *(.bug_frames.0) + __stop_bug_frames_0 =3D .; + *(.bug_frames.1) + __stop_bug_frames_1 =3D .; + *(.bug_frames.2) + __stop_bug_frames_2 =3D .; + *(.bug_frames.3) + __stop_bug_frames_3 =3D .; *(.rodata) *(.rodata.*) *(.data.rel.ro) --=20 2.39.2 From nobody Sat Apr 27 02:20:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678977607; cv=none; d=zohomail.com; s=zohoarc; b=VhVOQEAx5n3g1cFlBVMxH+PGRfi5Fk2GAfdE3f/43P59ihiEGtIv1wlNBwP4mxz2pDuRYSe0Sq6SRTTMncZXj6X1/vrK7Vm8/qCO0cNx9uaQH0k05uMP/YpWsppWc+osRUMTpCHPzJxa4wCbp/VjlOdSrCP/y6htiQVFD7Uf4kc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678977607; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KNIHclMhI5KuwmYwhjT6HcX6NDeB8oTP6k36A94QyFI=; b=ZBUVFFeYyrmVw41VNXptztXCXSoEjR72KsUqHptx9a/SzezdkSsTJB/mgvwJlEdmOTK8gAYJbdO3pABiGnJAXsHnGD/kFJZ1OD6zT9EDlkSp1jvMzUrMs0o3APgE6C6/2HPzCIMvMmjKB3zmSyItqjmx0s4PyT9UGndTaRQOqLE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1678977607005453.24078917346355; Thu, 16 Mar 2023 07:40:07 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.510654.788779 (Exim 4.92) (envelope-from ) id 1pcolf-0008QS-DN; Thu, 16 Mar 2023 14:39:47 +0000 Received: by outflank-mailman (output) from mailman id 510654.788779; Thu, 16 Mar 2023 14:39:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pcolf-0008QF-8z; Thu, 16 Mar 2023 14:39:47 +0000 Received: by outflank-mailman (input) for mailman id 510654; Thu, 16 Mar 2023 14:39:45 +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 1pcold-0006WA-2L for xen-devel@lists.xenproject.org; Thu, 16 Mar 2023 14:39:45 +0000 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [2a00:1450:4864:20::535]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 64934f96-c408-11ed-87f5-c1b5be75604c; Thu, 16 Mar 2023 15:39:44 +0100 (CET) Received: by mail-ed1-x535.google.com with SMTP id h8so8552102ede.8 for ; Thu, 16 Mar 2023 07:39:44 -0700 (PDT) Received: from fedora.. (46.204.101.131.nat.umts.dynamic.t-mobile.pl. [46.204.101.131]) by smtp.gmail.com with ESMTPSA id q16-20020a1709060e5000b008b980c3e013sm3970187eji.179.2023.03.16.07.39.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 07:39:43 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 64934f96-c408-11ed-87f5-c1b5be75604c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678977584; 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=KNIHclMhI5KuwmYwhjT6HcX6NDeB8oTP6k36A94QyFI=; b=keNi+Wzsq/txMnFyrCdFK4A4FXIN/Ea07piF1la+gIIHgFHXPCbI/gOJsicHBRlidY pXODQq5/RmI+X7VnsXohPg6shzJkHH+qPLPzZkblP7PlxY4RXREXi5UVVFgB13cgIRsk p6ayJgAxbszEC8NVwXfBBy4KbZx+8Xg70npQdGbI2afl0Rl5WbYgbwGZmDIcU+VrpTjR YreTiCbHymPHippLLc6nnTPsGMmkQjAiuak7qn1PmYxpxR2rBUkCcIG4BS03vtrlPGu6 FHNbkqastSn7QOFMbp/AdBrsHC+IFyld/SKq5o3RRflLQcyl7QN+vMWEKnv7Hc1f0tSj TNAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678977584; 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=KNIHclMhI5KuwmYwhjT6HcX6NDeB8oTP6k36A94QyFI=; b=as2RqKxeHfKQueCVqIEsvB8fYjM+MIKXQAJ8hYGyFIhHYZMzJHJm5kBz2u02DryCMQ pst3QD5KFVLuofWKoBgRQy5gejHKq+L8viJbUBFWpvVPxGdcK2B44fDcgHDFYQiaNcbE QMeTCibPSniO2KX57Gx8l3KAhoTdW4BRGDG7VuWRrUSqAabhqu3RAv05qsHYvWi2BXds U/7J1iLb3EdMbYN4lrqZ+mCKz1XlN+5MpVwbYG09gE2KCk0IkayLtn4i5Lo0ksEzyStL F75LiWxrq9Sk6AGNqWEGTm4tyDMBa533QDIAOyDcJr2TnAHh5VPlB6EuuHaXmiXdABja S0Zw== X-Gm-Message-State: AO0yUKUpv3I12ZnS1UWc/ZfTM9+30AxTbl38m5wr53BzXc3+dMVGBJCd 9iJUw+ujB/XUXsG95Oc+MdCs9op4SZOEUQ== X-Google-Smtp-Source: AK7set/q4NXUwR3SV1sseVDhD2AxPdVUBDFZ+lrU4KLqNb7ipT+JcRZrfX4irnegkux3kx3BQVRovQ== X-Received: by 2002:a17:906:702:b0:913:ff28:59bd with SMTP id y2-20020a170906070200b00913ff2859bdmr10540338ejb.52.1678977584126; Thu, 16 Mar 2023 07:39:44 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Julien Grall , Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v5 7/7] xen/riscv: test basic handling stuff Date: Thu, 16 Mar 2023 16:39:29 +0200 Message-Id: <7aaf322d5314688039212251f5202ef4cdb46f14.1678976127.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678977607545100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Oleksii Kurochko Acked-by: Alistair Francis --- Changes in V5: - Nothing changed --- Changes in V4: - Add Acked-by: Alistair Francis --- Changes in V3: - Nothing changed --- Changes in V2: - Nothing changed --- xen/arch/riscv/setup.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index b44d105b5f..b56c69a3dc 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -27,6 +28,20 @@ static void fill_boot_info(void) boot_info.load_end =3D (unsigned long)_end; } =20 +static void test_run_in_exception(struct cpu_user_regs *regs) +{ + early_printk("If you see this message, "); + early_printk("run_in_exception_handler is most likely working\n"); +} + +static void test_macros_from_bug_h(void) +{ + run_in_exception_handler(test_run_in_exception); + WARN(); + early_printk("If you see this message, "); + early_printk("WARN is most likely working\n"); +} + void __init noreturn start_xen(unsigned long bootcpu_id, unsigned long dtb_paddr) { @@ -36,6 +51,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id, =20 trap_init(); =20 + test_macros_from_bug_h(); + early_printk("All set up\n"); =20 for ( ;; ) --=20 2.39.2