From patchwork Fri Jul 12 16:18:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 13731947 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 1A3B6C3DA4D for ; Fri, 12 Jul 2024 16:19:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.758145.1167460 (Exim 4.92) (envelope-from ) id 1sSIz7-000412-6R; Fri, 12 Jul 2024 16:19:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 758145.1167460; Fri, 12 Jul 2024 16:19:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sSIz7-00040v-3M; Fri, 12 Jul 2024 16:19:01 +0000 Received: by outflank-mailman (input) for mailman id 758145; Fri, 12 Jul 2024 16:18:59 +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 1sSIz5-00040f-RE for xen-devel@lists.xenproject.org; Fri, 12 Jul 2024 16:18:59 +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 7158473a-406a-11ef-bbfb-fd08da9f4363; Fri, 12 Jul 2024 18:18:58 +0200 (CEST) Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-58b966b41fbso2742376a12.1 for ; Fri, 12 Jul 2024 09:18:58 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-594bb9604f7sm4669169a12.15.2024.07.12.09.18.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 09:18:57 -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: 7158473a-406a-11ef-bbfb-fd08da9f4363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720801138; x=1721405938; 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=i1ipnza5ajE4GRPCrSoMhjiWbzjCCaJILPUyqeHpgvk=; b=XPfyBv00bCGx4p1Yw1dtijDFsl8AN16o/+RMqi3VKprk54WkLVX/EWtkTu2LpIzhD+ OPuBZHttUYJM6c4dSRzSXzPBoupN5qcOz3mf5KkxgLbIiVgfmwc4kEKBHYvBzz0i6+rq 9Y2LFVIGpMJEIm86PVw60ywokrwLGJEJ7XvwpbK0PTh99uxpU4SdvNTAOEt6G+GV0lqY w8d9kul02eTXR6BHIGRP0z9jhvs+ERJDQtCy21xnrv97/otIu3GhLuTl0jxF2Gy23d54 U+WIGy5xCqdMGlndCVX76TpgsTiXm8NCzd6El6bioanXlECZ3Owg4Vz30/6XiHvc0ho7 MycA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801138; x=1721405938; 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=i1ipnza5ajE4GRPCrSoMhjiWbzjCCaJILPUyqeHpgvk=; b=LHOslbc9y0ZQUnglp7SxbsajTU+JOKw287LYiMKP+B8miI6GBYpstw0LdKdR6Ip1AB vBiXoc7B45mnMTGDkkOHogOl7u2r8rfb7YWf3RftMt3D1zVXQ3qgi6DlXdS3ssi/b6ul nZUs861j/12OZYL+79Xl7ZJ5X1y69tWp4IN65PvTNU4PZQINkTXJkQ5yCC05i7dTWEz4 DUXfOWivEPr3fxEYSOqpboqEv4p7UoL6yFF92sMwzcZMDuDwV/P/xcZ8kGVUKuKQ69oT AFBsvsPjUe2cNYbbrSPJU/mfpkMNucflwgc7iDiTQt7k6X6bsXpANdzl2MztNop9YJ5s Gqpg== X-Gm-Message-State: AOJu0YzdlNnXYdGl6a77oJJ1ZgUe2mX0P+ZSdS0i9Fv0GWrU/W7m5ENo fI/aFgAl4zHh4YyZVov7JliYD7EiZXhT8tC3PBDobmbU5FKSOVHnCNHWXSFZ X-Google-Smtp-Source: AGHT+IF8vH7b+Z1sUrUYZuYyXAWCTAVtL76GPrTswXrnEy5mYpV+Qpyt/1xnLDBaDtwh7XWDCParxg== X-Received: by 2002:a50:a457:0:b0:572:9962:7f0 with SMTP id 4fb4d7f45d1cf-594bc7c802bmr7069998a12.34.1720801137759; Fri, 12 Jul 2024 09:18:57 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH v10 1/5] xen/riscv: use printk() instead of early_printk() Date: Fri, 12 Jul 2024 18:18:50 +0200 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 As common code is available it is better to use printk() instead of early_printk(). Also the printing of "Hello from RISC-V world" is dropped as it is useless and "All set up is enough". Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in V10: - add Acked-by: Jan Beulich --- Changes in V9: - new patch --- xen/arch/riscv/setup.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index 8bb5bdb2ae..e3cb0866d5 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -23,9 +23,7 @@ void __init noreturn start_xen(unsigned long bootcpu_id, { remove_identity_mapping(); - early_printk("Hello from C env\n"); - - early_printk("All set up\n"); + printk("All set up\n"); for ( ;; ) asm volatile ("wfi"); From patchwork Fri Jul 12 16:18:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 13731945 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 3B745C3DA50 for ; Fri, 12 Jul 2024 16:19:15 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.758148.1167487 (Exim 4.92) (envelope-from ) id 1sSIz8-0004Wo-UL; Fri, 12 Jul 2024 16:19:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 758148.1167487; Fri, 12 Jul 2024 16:19:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sSIz8-0004WI-NQ; Fri, 12 Jul 2024 16:19:02 +0000 Received: by outflank-mailman (input) for mailman id 758148; Fri, 12 Jul 2024 16:19:01 +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 1sSIz7-00040X-IQ for xen-devel@lists.xenproject.org; Fri, 12 Jul 2024 16:19:01 +0000 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [2a00:1450:4864:20::536]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7209ec4a-406a-11ef-8776-851b0ebba9a2; Fri, 12 Jul 2024 18:18:59 +0200 (CEST) Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-5854ac817afso2829789a12.2 for ; Fri, 12 Jul 2024 09:18:59 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-594bb9604f7sm4669169a12.15.2024.07.12.09.18.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 09:18:58 -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: 7209ec4a-406a-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720801139; x=1721405939; 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=wnR0lQfCiZrZB2pYI/iZQqNx4LzjeoRWt1LANtUWrVY=; b=lSCp4Cc/PTWxq/7qRzPBu6lXm80ywlWCafTDm4hGd2XpeB51S/XEdKPYzaYiqngM7u BWVxoPZoriLXjLC+JGoWvhbgYvF6G1Bx2VaISOQRjL3Tt2B4qhQrE8Fi/M0EgFYMBNy6 RG6O1xmGu7cgTE+btpGn/ZsLLZUMPVIZK7kn4SwfDP/QBmNPE36NyPcvsZWpumL+WQkq sWc42IraLHshVD12HEgN9jenoMgU0CamsE5476n5xIKM/x6dQIajLDap598f/Dden+16 GADa+TbUdkWc3ATN3xI/vo0wMqUJ9MrpaXGNxuZUqjE42e0/4iSajG9gTmORuiBHewx3 WIdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801139; x=1721405939; 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=wnR0lQfCiZrZB2pYI/iZQqNx4LzjeoRWt1LANtUWrVY=; b=aue5wtDYOyTNt77KCBkHq5RHqfX8LbNbLmy/hj3fEXVXYXwA87eN/T0VmT/3R4B6Ja xm/TP8ehAIv+KEH3RHizo+JbVDGqYAT4B+HXsDfc/5Og2t35PhJAMLNCuLXPNG0jHJAn cLe6NHsfSY68YgC3eUmyBv9cAKJNZg8NAs+3R4JKHOPR/K8bHpGpz+kzv0XNPlmKwgHl YdacDnEWUm15sBox96ndPrAminkpUfMyK/aintwGmuEMmG8TGcXyUCG+bHTsODwVDqhc 4GyeChQhsBxzyBYXNJEJO1cTdBeP2fIjZyJ8Bp3ThpRkb1Yc1PFrjOmPCD+tm3p4DEvA u9Vg== X-Gm-Message-State: AOJu0YzsLYrZVzbkETfomQ+DT3KKKvWo5eeFcSHH1po1s3cO3q9ORGMs X8nn0VRUDLO5NR0A6z2EYnBv1sZbkV30Zlx6vygzRcsK283GWWuUmtLy2C2o X-Google-Smtp-Source: AGHT+IElo5yBxcnuOD1tObFjCmJxahwTzdOmlQV86IIWtIO8gilmED3rdM9dA0bKJmDVSjjZmP5iXg== X-Received: by 2002:a50:d518:0:b0:585:437c:d7fc with SMTP id 4fb4d7f45d1cf-594bc7c7e61mr7402934a12.32.1720801138545; Fri, 12 Jul 2024 09:18:58 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH v10 2/5] xen/riscv: introduce decode_cause() stuff Date: Fri, 12 Jul 2024 18:18:51 +0200 Message-ID: <335b0b49720b3524b6c89c5ce62d3377a4bb1fb8.1720799487.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 The patch introduces stuff needed to decode a reason of an exception. Signed-off-by: Oleksii Kurochko Acked-by: Alistair Francis Acked-by: Jan Beulich --- Changes in V10: - add Acked-by: Jan Beulich --- Changes in V9: - This patch was reverted as breaks both release and randconfig builds. I don't see the failures now. ( probably it was because of printk usage which was not ready at that moment ). - drop inclusion of and - add for CAUSE_* in decode_trap_cause(). --- Changes in V8: - fix typo in return string from decode_reserved_interrupt_cause - add Acked-by: Alistair Francis --- Changes in V7: - Nothing changed. Only rebase. --- Changes in V6: - Remove usage of LINK_TO_LOAD() due to the MMU being enabled first. - Change early_printk() to printk() --- Changes in V5: - Remove from riscv/traps/c as nothing would require inclusion. - decode_reserved_interrupt_cause(), decode_interrupt_cause(), decode_cause, 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 one. --- xen/arch/riscv/traps.c | 80 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c index 5415cf8d90..37cec40dfa 100644 --- a/xen/arch/riscv/traps.c +++ b/xen/arch/riscv/traps.c @@ -9,13 +9,91 @@ #include #include +#include #include -void do_trap(struct cpu_user_regs *cpu_regs) +static const char *decode_trap_cause(unsigned long cause) +{ + static const char *const trap_causes[] = { + [CAUSE_MISALIGNED_FETCH] = "Instruction Address Misaligned", + [CAUSE_FETCH_ACCESS] = "Instruction Access Fault", + [CAUSE_ILLEGAL_INSTRUCTION] = "Illegal Instruction", + [CAUSE_BREAKPOINT] = "Breakpoint", + [CAUSE_MISALIGNED_LOAD] = "Load Address Misaligned", + [CAUSE_LOAD_ACCESS] = "Load Access Fault", + [CAUSE_MISALIGNED_STORE] = "Store/AMO Address Misaligned", + [CAUSE_STORE_ACCESS] = "Store/AMO Access Fault", + [CAUSE_USER_ECALL] = "Environment Call from U-Mode", + [CAUSE_SUPERVISOR_ECALL] = "Environment Call from S-Mode", + [CAUSE_MACHINE_ECALL] = "Environment Call from M-Mode", + [CAUSE_FETCH_PAGE_FAULT] = "Instruction Page Fault", + [CAUSE_LOAD_PAGE_FAULT] = "Load Page Fault", + [CAUSE_STORE_PAGE_FAULT] = "Store/AMO Page Fault", + [CAUSE_FETCH_GUEST_PAGE_FAULT] = "Instruction Guest Page Fault", + [CAUSE_LOAD_GUEST_PAGE_FAULT] = "Load Guest Page Fault", + [CAUSE_VIRTUAL_INST_FAULT] = "Virtualized Instruction Fault", + [CAUSE_STORE_GUEST_PAGE_FAULT] = "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 = 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 = csr_read(CSR_SCAUSE); + + printk("Unhandled exception: %s\n", decode_cause(cause)); + die(); } +void do_trap(struct cpu_user_regs *cpu_regs) +{ + do_unexpected_trap(cpu_regs); +} + void vcpu_show_execution_state(struct vcpu *v) { BUG_ON("unimplemented"); From patchwork Fri Jul 12 16:18:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 13731942 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 EA068C2BD09 for ; Fri, 12 Jul 2024 16:19:11 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.758147.1167481 (Exim 4.92) (envelope-from ) id 1sSIz8-0004TW-IV; Fri, 12 Jul 2024 16:19:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 758147.1167481; Fri, 12 Jul 2024 16:19:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sSIz8-0004TP-FW; Fri, 12 Jul 2024 16:19:02 +0000 Received: by outflank-mailman (input) for mailman id 758147; Fri, 12 Jul 2024 16:19:00 +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 1sSIz6-00040f-RP for xen-devel@lists.xenproject.org; Fri, 12 Jul 2024 16:19:00 +0000 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [2a00:1450:4864:20::530]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 725cc52d-406a-11ef-bbfb-fd08da9f4363; Fri, 12 Jul 2024 18:19:00 +0200 (CEST) Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-58bac81f40bso2957343a12.1 for ; Fri, 12 Jul 2024 09:19:00 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-594bb9604f7sm4669169a12.15.2024.07.12.09.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 09:18:59 -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: 725cc52d-406a-11ef-bbfb-fd08da9f4363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720801139; x=1721405939; 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=BY3OUb5w0oTrYR4mV0gprlP5xV2m84WlodPsogn9Pjs=; b=lyKrcixoE2JbL8aCfalV6m8iFZeZq+epl8czRQsC9RP6XgqfKX10VPOxxs9ukqxVHO ItrJ6vmpFY/PftN7zpHQv5uQWVUHSVuUVscqMT3TtrGmel95h2sYq62oMR/eWuBFHug4 I+uddAJKWICaK4jMjlVyvIVFu6ysOIdtKqM8W5KS+5rFr2PTRzu4vv8UzOG62GThGlv+ NqlEcVSBhwArEef5ib+Fodq3/+yGSye6EjvT3VPaJC00eV/M5E+WhzHIYdV9gmEuI+N0 ajQsEjY0zKT5yDup2rHfwFqQXdaPWZUZW6eTPb2ESgkHlsahmqJzYZY8/mqcfMWp3zKL xgUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801139; x=1721405939; 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=BY3OUb5w0oTrYR4mV0gprlP5xV2m84WlodPsogn9Pjs=; b=JI85Pbc7+cWqC0uMHpKHTvccGGlz+l3C2HBhcRhwI+3X/J//WN0hpuvilo8IBKgHSE TkTZhZv9Vz4v3X2XJ4fjgb+AP4yDjS15/IzkkMsajhUbKIiiugcRNwpPOxWsgjBnprnq wcmlhjTM5W3u6ozWoNeEtC/58YgCL1mX/YpTr5JD8YcJuqjWbBkNrnjnRf9ziWzUeoPH y3hlgyr3zbREGOGIMffTcoigECD9DtIAGy0MorqShArOZzzMzy5P5s1GnJ3XHn+grjbY q4u4sh2bQtvJ6m37uQqLegX+Rw/ITeWjrBps1AklG4eC0nfibJ7w5eWknnJVS7x3VrGg v4Pw== X-Gm-Message-State: AOJu0Yzz5x/WSmoLCpWC8KA0d8YDJz3oTVnOyNpL8uqJze0pM3BNNGre NVxfbz2ljhbwd8K4fVc60lC2ZPRIGMfKGZv83ApLANIkfCQM6cE6l0vDHAj0 X-Google-Smtp-Source: AGHT+IHL4FpM9BdrB3G+J7mKN1NNcS9yF2cOvmTTRegbZwowIZgJUdW3gdEkQ0GTVm3AiEdwiU2g1w== X-Received: by 2002:aa7:c35a:0:b0:57a:858d:20ca with SMTP id 4fb4d7f45d1cf-594bc7c7e77mr7398976a12.28.1720801139348; Fri, 12 Jul 2024 09:18:59 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH v10 3/5] xen/riscv: introduce trap_init() Date: Fri, 12 Jul 2024 18:18:52 +0200 Message-ID: <80c02f1215d74e42fd9bc7f0d6e27d043a11b0e9.1720799487.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 trap_init() wasn'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 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[] = { From patchwork Fri Jul 12 16:18:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 13731946 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 374B8C2BD09 for ; Fri, 12 Jul 2024 16:19:15 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.758149.1167494 (Exim 4.92) (envelope-from ) id 1sSIz9-0004hF-E0; Fri, 12 Jul 2024 16:19:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 758149.1167494; Fri, 12 Jul 2024 16:19:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sSIz9-0004fO-6k; Fri, 12 Jul 2024 16:19:03 +0000 Received: by outflank-mailman (input) for mailman id 758149; Fri, 12 Jul 2024 16:19:01 +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 1sSIz7-00040f-OL for xen-devel@lists.xenproject.org; Fri, 12 Jul 2024 16:19:01 +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 72e22411-406a-11ef-bbfb-fd08da9f4363; Fri, 12 Jul 2024 18:19:01 +0200 (CEST) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-57d05e0017aso2943721a12.1 for ; Fri, 12 Jul 2024 09:19:01 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-594bb9604f7sm4669169a12.15.2024.07.12.09.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 09:18:59 -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: 72e22411-406a-11ef-bbfb-fd08da9f4363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720801140; x=1721405940; 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=g0C/9rghoKuThfbYBBAzL0tAO029l075q93CgDcGue8=; b=fZEo7Jgt02lk/DQ8uvhYOevUnfq9AF0WeUAlTjNUT6eQEKQsFqe2N2q39mvnRyZS5e XO/7nojXV5rKNo8ex845O3NPEJgJ+WyXWVB69waaXqrOA/AqMO73Qm4yaSkzCxAeXBtE tlsvCn87ZQ9P/m8CHZ9cEJQBudT9Tj2cD+OmdZEHCQKAHqd+6r7w+x/Gx0Nb6DXPEjmt FesAcRcHWGjLWfWoDeW2C61TC1d9C+MqcsWhagTMdImiK6Uyg97rmCkz0E2LoeCuBBsS sElIZLQBk7yoX8eNpBGaG+ft405LJlQPrIg3oSIdc1/eRDY2m4OBshMh7crf9MhjicUw 1xZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801140; x=1721405940; 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=g0C/9rghoKuThfbYBBAzL0tAO029l075q93CgDcGue8=; b=jJXlFuL6XYEOGhjhZUQ8amz9TkLXHdOdeptqYFhrjWWA4zfJNqZ76uHPVkqV1ccONs zw5mW4MdW9FEMZaXV4bG55Chl+kuu/dEXkYeDPslFpxsSyI0XF3R2E28PUPCtnWfbTmK NOCzuBcmfYcyLCvFSCVDqDcLcONhCJbXT7809DXIj2GsLuGicic6m3HI0gmBm4VjYR4v FsDsReUfI0cvfcrTn/MUnUe8JSRqDIfwNgGsXzJDrOJ0DvTzlWp2V1lR3Ub1jLFUpBr0 uO0fHz0Wz0iEpwzeADWHRrdyRcZWaNsx8Ify+/cl4MpY3JC2pjjlgFqXXeGQK6/a+J0r WYiw== X-Gm-Message-State: AOJu0YycLmLMkIx9tqRyHs4iSs0t+rslRQf7OfUwbEDM9wB5DsjK1+s1 KOX84Q7dmRKJf5Qh6y2+1BmXKbXQyM8MSJWQlbr6jf3bGoQ8NtjhuAYLTbqH X-Google-Smtp-Source: AGHT+IHMCmazHpXLAa9xShPyez/uzRL10FRAkizhRobVMY2criCmK6BPZE5sZVwUOXOYsN/owRJ9zw== X-Received: by 2002:a05:6402:1911:b0:57c:5b7a:87e7 with SMTP id 4fb4d7f45d1cf-594ba0cbecemr9569042a12.14.1720801140259; Fri, 12 Jul 2024 09:19:00 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH v10 4/5] xen/riscv: enable GENERIC_BUG_FRAME Date: Fri, 12 Jul 2024 18:18:53 +0200 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 To have working BUG(), WARN(), ASSERT, run_in_exception_handler() it is needed to enable GENERIC_BUG_FRAME. Also, is needed to be included for the reason that panic() and printk() are used in common/bug.c and RISC-V fails if it is not included with the following errors: common/bug.c:69:9: error: implicit declaration of function 'printk' [-Werror=implicit-function-declaration] 69 | printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno); | ^~~~~~ common/bug.c:77:9: error: implicit declaration of function 'panic' [-Werror=implicit-function-declaration] 77 | panic("Xen BUG at %s%s:%d\n", prefix, filename, lineno); Signed-off-by: Oleksii Kurochko --- Changes in V10: - put 'select GENERIC_BUG_FRAME' in "Config RISCV". - rework do_trap() to not fetch an instruction in case when the cause of trap is BUG_insn. - drop read_instr() and is_valid_bug_insn(). - update the commit message. --- Changes in V9: - Rebase on the top of current staging. - use GENERIC_BUG_FRAME as now we have common code available. - add xen/lib.h to bug.c to fix a compilation error around printk. - update the commit message. - update the code of read_instr() in traps.c - fold two-s if into 1 in do_trap. --- Changes in V8: - remove Pointless initializer of id. - make bug_frames[] array constant. - remove cast_to_bug_frame(addr). - rename is_valig_bugaddr to is_valid_bug_insn(). - add check that read_instr is used only on xen code - update the commit message. --- Changes in V7: - move to this patch the definition of cast_to_bug_frame() from the previous patch. - update the comment in bug.h. - update the comment above do_bug_frame(). - fix code style. - add comment to read_instr func. - add space for bug_frames in lds.S. --- Changes in V6: - Avoid LINK_TO_LOAD() as bug.h functionality expected to be used after MMU is enabled. - Change early_printk() to printk() --- Changes in V5: - Remove "#include " from as there is no any need 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 the current version of the patch - change an argument type from vaddr_t to uint32_t for is_valid_bugaddr and introduce read_instr() to read instruction properly as the length of qinstruction can be either 32 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 length 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 * update definition of is_valid_bugaddr():switch return type from int to bool and the argument from 'unsigned int' to 'vaddr'. Code style inside function 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[] = ...' * 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 implementation 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)) = (fn); - Remove bug_instr_t type and change it's usage to uint32_t --- xen/arch/riscv/Kconfig | 1 + xen/arch/riscv/traps.c | 25 ++++++++++++++++++++++++- xen/common/bug.c | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/xen/arch/riscv/Kconfig b/xen/arch/riscv/Kconfig index b4b354a778..f531e96657 100644 --- a/xen/arch/riscv/Kconfig +++ b/xen/arch/riscv/Kconfig @@ -1,6 +1,7 @@ config RISCV def_bool y select FUNCTION_ALIGNMENT_16B + select GENERIC_BUG_FRAME config RISCV_64 def_bool y diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c index cb18b30ff2..e39603dc95 100644 --- a/xen/arch/riscv/traps.c +++ b/xen/arch/riscv/traps.c @@ -5,6 +5,7 @@ * RISC-V Trap handlers */ +#include #include #include @@ -103,7 +104,29 @@ static void do_unexpected_trap(const struct cpu_user_regs *regs) void do_trap(struct cpu_user_regs *cpu_regs) { - do_unexpected_trap(cpu_regs); + register_t pc = cpu_regs->sepc; + unsigned long cause = csr_read(CSR_SCAUSE); + + switch ( cause ) + { + case CAUSE_BREAKPOINT: + if ( do_bug_frame(cpu_regs, pc) >= 0 ) + { + if ( !pc || + !(is_kernel_text(pc + 1) || is_kernel_inittext(pc + 1)) ) + { + printk("Something wrong with PC: 0x%lx\n", pc); + die(); + } + + cpu_regs->sepc += GET_INSN_LENGTH(*(uint16_t *)pc); + return; + } + + break; + default: + do_unexpected_trap(cpu_regs); + } } void vcpu_show_execution_state(struct vcpu *v) diff --git a/xen/common/bug.c b/xen/common/bug.c index b7c5d8fd4d..75cb35fcfa 100644 --- a/xen/common/bug.c +++ b/xen/common/bug.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include From patchwork Fri Jul 12 16:18:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 13731943 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 EC17BC3DA4D for ; Fri, 12 Jul 2024 16:19:12 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.758150.1167510 (Exim 4.92) (envelope-from ) id 1sSIzA-0005AG-IZ; Fri, 12 Jul 2024 16:19:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 758150.1167510; Fri, 12 Jul 2024 16:19:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sSIzA-00059M-E5; Fri, 12 Jul 2024 16:19:04 +0000 Received: by outflank-mailman (input) for mailman id 758150; Fri, 12 Jul 2024 16:19:03 +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 1sSIz9-00040X-Cw for xen-devel@lists.xenproject.org; Fri, 12 Jul 2024 16:19:03 +0000 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [2a00:1450:4864:20::52b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 735fa3bc-406a-11ef-8776-851b0ebba9a2; Fri, 12 Jul 2024 18:19:01 +0200 (CEST) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-57cf8880f95so2742624a12.3 for ; Fri, 12 Jul 2024 09:19:01 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-594bb9604f7sm4669169a12.15.2024.07.12.09.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 09:19:00 -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: 735fa3bc-406a-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720801141; x=1721405941; 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=tzcJTvhB72zFgLJxMtKt5ug3KrGpNPrgBrt3gVVkNwk=; b=UhqBj/IRC72ZvK1Ztt8doi9NeFNUeYS98PlZ8Hf6Poo+QZ9ctfk83AGU8J+8Gn88uV 0+rqfjnI9gqKwL+wlqCTUR/dn0laMLBNuoqAHRbIENBK4X5aTBB/zWti6TBN19CGEckt igyaHVTkvuGN3QFfPo6Y7x2PBBAyuCL0U6uGoUD1tRQfxJKkY66RloD1PTUg0dh0e1ap sUcnesfWoGYiVZQUpq02f24bnYMP9dl6pJPJi5+FGeMw4c7T6Ow34kVqU1Po75QhxadN Baph5uH1bVQjThqjci7R/LRG+05+IRuk+oXu/GpgivtGZlG5e+YK5McyJS0HCmZDCwUV sYug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801141; x=1721405941; 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=tzcJTvhB72zFgLJxMtKt5ug3KrGpNPrgBrt3gVVkNwk=; b=o/vS0Tvnrz0sBeTEgy8XoyoOSYcyfq0OEDqPW/umqZvxODqUEG3+sr7mAYgu6yBL94 5PTLHkkOoSBWjjUFxPLpX9hipGAEnAxY3RvVJcLF0MpHsxJG4623qVe6BrG/cODTzYL3 gFXcOy4dNH7fXgrZjtUP3qyy49IHTL6GQB85m5sktoeLwtGgBJ7ol9l1rcBPuWzzpXlC ZFFl2ab7VrfzJKXugj8eFQ4OsJEANDGfvolTCj4VjXXnWoxRMrJZPYp7s9vg27gBDkB+ 6OrHOiVx3SEoOXREWLaeGQRljTVlbLwIColc5X3C8vZnNl991T0fVBZGBUtC9bb64Xus QmiA== X-Gm-Message-State: AOJu0YzLd9uF/d6iYZlLVyEOw6t6aG+yqU4n5wiIVFoTOwhd8/ahT/Ux E3NstFmXRL1uZOiRFADXgRRpo6vymTdrz2kwOva7O2Yl7sikA42TT2btmMWc X-Google-Smtp-Source: AGHT+IGPk9Dj8IhkgQmwNMU228dzBkvUapztG9fYL4a5yBBNhHL8kZxeHuVtgxzxK5Q9AvEqbtZSlA== X-Received: by 2002:a05:6402:33d5:b0:57d:3ea:3862 with SMTP id 4fb4d7f45d1cf-594bc7c9133mr7535849a12.27.1720801141130; Fri, 12 Jul 2024 09:19:01 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH v10 5/5] xen/riscv: test basic exception handling stuff Date: Fri, 12 Jul 2024 18:18:54 +0200 Message-ID: <17ee34d97af4bebc87facf8576cee519ca26bf12.1720799487.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 Signed-off-by: Oleksii Kurochko Acked-by: Alistair Francis --- Changes in V10: - wrap test_macros_from_bug_h() under "#ifdef CONFIG_SELF_TESTS" - update the commit title to: "xen/riscv: test basic exception handling stuff" --- Changes in V9: - s/early_printk/printk as common code is now available --- Changes in V8: - Nothing changed. Only rebase. --- Changes in V6: - Nothing changed. Only rebase. --- Changes in V6: - Nothing changed --- 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 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index a6a29a1508..4defad68f4 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -19,6 +19,22 @@ void arch_get_xen_caps(xen_capabilities_info_t *info) unsigned char __initdata cpu0_boot_stack[STACK_SIZE] __aligned(STACK_SIZE); +#ifdef CONFIG_SELF_TESTS +static void test_run_in_exception(const struct cpu_user_regs *regs) +{ + printk("If you see this message, "); + 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(); + printk("If you see this message, "); + printk("WARN is most likely working\n"); +} +#endif + void __init noreturn start_xen(unsigned long bootcpu_id, paddr_t dtb_addr) { @@ -26,6 +42,10 @@ void __init noreturn start_xen(unsigned long bootcpu_id, trap_init(); +#ifdef CONFIG_SELF_TESTS + test_macros_from_bug_h(); +#endif + printk("All set up\n"); for ( ;; )