From nobody Thu Sep 19 00:52:34 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=1722962297; cv=none; d=zohomail.com; s=zohoarc; b=jZn/KdKyxhkyzb0i8IndqL+BF2ASY/mXwdqdUhpv1sG2Ho1tN3r9Fhbhj4py6RRB4hJdlIEMu2QESYIz+slUG86RP3nMf94zbC0QeQSVdwEQWk2Lss3DI/nrzMAoyHVghp/MfEu7fJalMI1y4+LP5xCpgG3dUTyjYAuOE7B2rrs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722962297; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ti+mt/1uMMi7JLPjgJYKhqxaEaRYrTbLXwbihRv8QHU=; b=R14zUKOwqBCpqIFNyVCMQ7lMm4AM47U80/Rr9tLunEh4NGLUsS1IUGBUazAeeXCVMiR/emWtRH8RmCFXlDqgDmyZoTtpLqGqlZEpELZeHGZlo5Jf0mTnBmE0+TkKTq2q9Jkyh0qRlkZeEakUG3WY56O/9RkYf5i4gfRv0N0P/yw= 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 1722962297004864.0639105899809; Tue, 6 Aug 2024 09:38:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.772985.1183426 (Exim 4.92) (envelope-from ) id 1sbNC8-0000KI-OX; Tue, 06 Aug 2024 16:37:56 +0000 Received: by outflank-mailman (output) from mailman id 772985.1183426; Tue, 06 Aug 2024 16:37:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sbNC8-0000KB-M2; Tue, 06 Aug 2024 16:37:56 +0000 Received: by outflank-mailman (input) for mailman id 772985; Tue, 06 Aug 2024 16:37:55 +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 1sbNC7-0000Jt-IW for xen-devel@lists.xenproject.org; Tue, 06 Aug 2024 16:37:55 +0000 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [2a00:1450:4864:20::52a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3ae46a20-5412-11ef-bc04-fd08da9f4363; Tue, 06 Aug 2024 18:37:54 +0200 (CEST) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5b9d48d1456so30515a12.1 for ; Tue, 06 Aug 2024 09:37:54 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5b839708c56sm6130442a12.2.2024.08.06.09.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 09:37:53 -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: 3ae46a20-5412-11ef-bc04-fd08da9f4363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722962274; x=1723567074; 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=Ti+mt/1uMMi7JLPjgJYKhqxaEaRYrTbLXwbihRv8QHU=; b=j7Z8y0XrvsNnm2N0UU1h7AChPCkFD6MxSzzpxJyM6vHBPvMASusDkNfJzgM1x7YeZ0 Ifpe/kzaUt86g2UXEUQIJmEensaTvwukZto+QA5h20edxS5tFi8I2aPFkp7t+5dn14Cm S4RgNI2wxkHpTqpt+ZVhuVAgBMYRG0qKSPi53hv1fm2DhTMg4n9JkNnbQyjS+dMr3uAO oXNGdcmrwV/xuGQbvtDKkLBGkQNBmQuWorneSd/jLeba+qKVCwLr4M/JZ+vWeZeRlbXX rvyPdwNEZ6/yzP2pSVAcLwWHl8ryW4lGZmWshbt6h3kv/l4UYEywk+b09qkwWdYWYjAJ d5kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722962274; x=1723567074; 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=Ti+mt/1uMMi7JLPjgJYKhqxaEaRYrTbLXwbihRv8QHU=; b=CEmTrGJghFuUBG7r67lrLD0IXzORA8mvuiBpZdC06LyLk5IVIY8moBCv7yLrIfuFht qUYtxtn+myzTpZg23YePb+oFZ1l+98ZwkwcHAjkB8pSry5acxeQumO1uAWG4qlEq0H9x ol9SYkh9ttFgnEGddikGrUee6pX8N7Usngj4JienSsNSTpiLk0/XZ+PDKt6k73uEhke8 uxrW3TNZ8WubkxWXtJw8zdqrPYAvz5ciI6SjNXbRq7D0wCaF8q78yIJsBjsBZXXrLy7n mmPGXF7Jtbe8CL4yxM1N3yTeFvRQsDJN7WagyGG1ZBr1P9ufdNZdygg35/5MrpYACd7W 5dVw== X-Gm-Message-State: AOJu0Yy+ujwjGUI/VYCcUEeZT82nMXfRdVcvXAcB7k0WeL7I7j+RWr/s VLfBCtJS/ooz/aU7h3DLGW03FAe0ICM/cacIYyCKGSjV77hIl1s6v2ElRw== X-Google-Smtp-Source: AGHT+IEcW4ivBa9VJ4kM/q5GKqO4YlEqHsmmQQwXt92tS+p9N4/xfIcL5HvvjBzGc/ctDrexTJss6w== X-Received: by 2002:a05:6402:1913:b0:5ba:bf81:a971 with SMTP id 4fb4d7f45d1cf-5babf81ab6amr8722320a12.1.1722962273632; Tue, 06 Aug 2024 09:37:53 -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 v13 1/2] xen/riscv: enable GENERIC_BUG_FRAME Date: Tue, 6 Aug 2024 18:37:49 +0200 Message-ID: <516ada36487fd57f7a784f9fb3fe328f5365bd85.1722960083.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1722962298312116600 Content-Type: text/plain; charset="utf-8" Enable GENERIC_BUG_FRAME to support BUG(), WARN(), ASSERT, and run_in_exception_handler(). "UNIMP" is used for BUG_INSTR, which, when macros from are used, triggers an exception with the ILLEGAL_INSTRUCTION cause. This instruction is encoded as a 2-byte instruction when CONFIG_RISCV_ISA_C is enabled: ffffffffc0046ba0: 0000 unimp and is encoded as a 4-byte instruction when CONFIG_RISCV_ISA_C ins't enabled: ffffffffc005a460: c0001073 unimp Using 'ebreak' as BUG_INSTR does not guarantee proper handling of macros from . If a debugger inserts a breakpoint (using the 'ebreak' instruction) at a location where Xen already uses 'ebreak', it creates ambiguity. Xen cannot distinguish whether the 'ebreak' instruction is inserted by the debugger or is part of Xen's own code. Remove BUG_INSN_32 and BUG_INSN_16 macros as they encode the ebreak instruction, which is no longer used for BUG_INSN. Update the comment above the definition of INS_LENGTH_MASK as instead of 'ebreak' instruction 'unimp' instruction is used. is included for the reason that panic() and printk() are used in common/bug.c and RISC-V fails if it is not included. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in V13: - add fallthrough for " case CAUSE_ILLEGAL_INSTRUCTION" in do_trap(). - define BUG_INSTR as "UNIMP" to cover properly the cases when CONFIG_RISCV_ISA_C is enabled and not. - Update the comment above the definition of INS_LENGTH_MASK. - Update the commit message. --- Changes in V12: - Update the commit message - Use 0x0000 as BUG_INSTR instead of 'ebreak' to deal with cases when the debugger inserts 'ebreak' into the place where Xen has ebreak. - Remove BUG_INSN_32 and BUG_INSN_16 macros as they encode the ebreak instruction, which is no longer used for BUG_INSN. - Update the commit above the definition of INS_LENGTH_MASK. - Move break inside "if ( do_bug_frame(cpu_regs, pc) >=3D 0 )". --- Changes in V11: - update the commit message - change "%lx" to "%#x" for PC register printing. - drop +1 in argument of is_kernel_text(pc) and is_kernel_inittext(pc). - drop return for case CAUSE_BREAKPOINT. - add break to default and add a blank like above it. - add a comment CAUSE_BREAKPOINT is handled instead of illegal instructio= n. --- 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 t= rap 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 previo= us 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 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 * 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/Kconfig | 1 + xen/arch/riscv/include/asm/bug.h | 8 +++----- xen/arch/riscv/traps.c | 26 +++++++++++++++++++++++++- xen/common/bug.c | 1 + 4 files changed, 30 insertions(+), 6 deletions(-) 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 =20 config RISCV_64 def_bool y diff --git a/xen/arch/riscv/include/asm/bug.h b/xen/arch/riscv/include/asm/= bug.h index f5ff96140f..30941816de 100644 --- a/xen/arch/riscv/include/asm/bug.h +++ b/xen/arch/riscv/include/asm/bug.h @@ -9,7 +9,7 @@ =20 #ifndef __ASSEMBLY__ =20 -#define BUG_INSTR "ebreak" +#define BUG_INSTR "UNIMP" =20 /* * The base instruction set has a fixed length of 32-bit naturally aligned @@ -18,15 +18,13 @@ * There are extensions of variable length ( where each instruction can be * any number of 16-bit parcels in length ). * - * 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 ( + * Compressed ISA is used now where the instruction length is 16 bit and + * 'unimp' 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) =20 -#define BUG_INSN_32 _UL(0x00100073) /* ebreak */ -#define BUG_INSN_16 _UL(0x9002) /* c.ebreak */ #define COMPRESSED_INSN_MASK _UL(0xffff) =20 #define GET_INSN_LENGTH(insn) \ diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c index 7149504ebc..d55a4a827b 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 #include #include @@ -106,7 +108,29 @@ static void do_unexpected_trap(const struct cpu_user_r= egs *regs) =20 void do_trap(struct cpu_user_regs *cpu_regs) { - do_unexpected_trap(cpu_regs); + register_t pc =3D cpu_regs->sepc; + unsigned long cause =3D csr_read(CSR_SCAUSE); + + switch ( cause ) + { + case CAUSE_ILLEGAL_INSTRUCTION: + if ( do_bug_frame(cpu_regs, pc) >=3D 0 ) + { + if ( !(is_kernel_text(pc) || is_kernel_inittext(pc)) ) + { + printk("Something wrong with PC: %#lx\n", pc); + die(); + } + + cpu_regs->sepc +=3D GET_INSN_LENGTH(*(uint16_t *)pc); + + break; + } + fallthrough; + default: + do_unexpected_trap(cpu_regs); + break; + } } =20 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 --=20 2.45.2 From nobody Thu Sep 19 00:52:34 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=1722962292; cv=none; d=zohomail.com; s=zohoarc; b=QLHkOkvUCJ677mm6gBXseTNXJCH90G1Rz7QkNHXgYpHuG2KwXof4yaO+PTt18JsTew35zUCIBA25ZoZRPM7L1Lq8ZAlqMFJslP2uB7ECDWTuHhMO3SP49K/nELFGExHVZxGYkMxZKBdyN0D/YHkYL26/CeRceH1z0bHGQc+4KyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722962292; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=L/Zbn2a14GKs5tYnWS9wWhluQiN5HzX568Es6OXBxYc=; b=NGAuDEwqd/vDeT3PPSsLvY9Gj7n+cQBxhLQDCxu12H3MgYm2NFSWYExTJ8WJZZErBFVewt62uC2Dwqb75cUbtX4Chvl1h4gMaLBDOKrUM9dMQd/vo8UV8MzL7YaJfUuumAhX6Vq9iU2IgB3aaSdmxu0sDEbhmAGNUBmwxJ+T2Tk= 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 1722962292734202.98066005423516; Tue, 6 Aug 2024 09:38:12 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.772987.1183447 (Exim 4.92) (envelope-from ) id 1sbNCA-0000nB-CH; Tue, 06 Aug 2024 16:37:58 +0000 Received: by outflank-mailman (output) from mailman id 772987.1183447; Tue, 06 Aug 2024 16:37:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sbNCA-0000n2-7q; Tue, 06 Aug 2024 16:37:58 +0000 Received: by outflank-mailman (input) for mailman id 772987; Tue, 06 Aug 2024 16:37:57 +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 1sbNC8-0000K5-Uj for xen-devel@lists.xenproject.org; Tue, 06 Aug 2024 16:37:56 +0000 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [2a00:1450:4864:20::534]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3b4ba3c8-5412-11ef-8776-851b0ebba9a2; Tue, 06 Aug 2024 18:37:55 +0200 (CEST) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5a15692b6f6so1252416a12.0 for ; Tue, 06 Aug 2024 09:37:55 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5b839708c56sm6130442a12.2.2024.08.06.09.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 09:37:54 -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: 3b4ba3c8-5412-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722962274; x=1723567074; 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=L/Zbn2a14GKs5tYnWS9wWhluQiN5HzX568Es6OXBxYc=; b=JauJaSg0YE2usxOhzKLqHnmdiqeB3HrrvOtlMVG36qmJgZwDFgWuDXzYsvlPdk4aNO bDmAXtRH0ck8WDOM284KPcKhmivSUAMNznXMO+jActgavG0dWjtbQrJI87XbWwQn4Qd6 c1BtDZ5VgbY4rSLnMCQulVYlb0kvv2ichgv63ocO8mVsamHu4ZHedlIYXcgL0CCLN7Qw ALxtOY/D0zieUgODlFmXIB8m+/zW1109FOlrrTcDXwLpVtfyj0nU/di6/AqdRbNNXCVf Qs1wn4fQF2FszRMhS368nHA//pGpXYS4IuNN1agXTvgWneMxN0F7zrWBSHKk7M5bpSV6 LU9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722962274; x=1723567074; 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/Zbn2a14GKs5tYnWS9wWhluQiN5HzX568Es6OXBxYc=; b=HeJT7TtbT7ZSZQvyYZi8Zsc4q6d+1C31ipQavWknjoJ0+cnFtvzDJG8I+0HcLQ3Fx8 Cp2bHths0IN/gL32iMMz5QpOyzQVR9qdlUiTv4lTxHYlpRNXlqNWwfVC0w1P3Bg/q2WQ /JRTFVTcdNz2t5mOTFlMCO9PEtq+ZktECYwIlJYID2VMWD43fuvWPX3qEzIixRVUkpBo +8dxPQE+68QtpTC0ioLs7/kzn42dBfhX6sqNBBFhQvnxOkpU36HmgTpGreWHF7AYOjoF 0rJdCN2lTBO8e8KAtUiUa7ZbYCncCLD13v42hJzQcRFwOXU0lhXBBMerGT6scBOaMSTn GHJg== X-Gm-Message-State: AOJu0Yweuff049nLvQnOxNM1qgHqYFIiqZGdFdOycqHQApFP2ClaknDt 6dZPIJJmQ2QeFkYE57F9/rWXQLlA59O6Kv3tqucrrDrwyktmkR6h/JXusw== X-Google-Smtp-Source: AGHT+IFJNqSE4REWswtsQjnFc/RMGzrgjPXR54oSr80O8g7PxeOx279jo2TGDHO/Ag890La0nFFmaw== X-Received: by 2002:a05:6402:457:b0:59e:b95d:e769 with SMTP id 4fb4d7f45d1cf-5b7f36f3fdamr12422813a12.5.1722962274383; Tue, 06 Aug 2024 09:37:54 -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 v13 2/2] xen/riscv: test basic exception handling stuff Date: Tue, 6 Aug 2024 18:37:50 +0200 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1722962294103116600 Content-Type: text/plain; charset="utf-8" Introduce testing for macros in Wrap the testing in the SELF_TESTS configuration to avoid log noise related to functionality testing (specifically, macros from ) when CONFIG_SELF_TESTS is disabled. Signed-off-by: Oleksii Kurochko Acked-by: Alistair Francis --- Changes in V13: - update the commit message. --- Changes in V12: - Notrhing changed. Only rebase. --- Changes in V11: - update the commit message. --- 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 st= uff" --- Changes in V9: - s/early_printk/printk as common code is now available --- Changes in V5-V8: - Nothing changed. Only rebase. --- Changes in V4: - Add Acked-by: Alistair Francis --- Changes in V2-V3: - 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); =20 +#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, =20 trap_init(); =20 +#ifdef CONFIG_SELF_TESTS + test_macros_from_bug_h(); +#endif + printk("All set up\n"); =20 for ( ;; ) --=20 2.45.2