From nobody Mon May 13 22:47:41 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=1691064358; cv=none; d=zohomail.com; s=zohoarc; b=MWEERUgo10lyIQnVfP9reS5i8qdB4bUaka3n+23jA64TYqCZkuClVfuIgfxgsiIt1BZUjtcD9edUtCoAcplo52OCMtfBzgi25rlR2bqrc8XgGb3CEMa9oRi0SdS0MSpaMUi9PoIBqyXUpDthyB7/C6b8DsnH0RuM5ovM5I9DF6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691064358; 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=xJtJCMw7fy83NnUSxcXJn4fOwoFlzc9n7K+NQt3JNLk=; b=X6Cj9JZ11hxTv49lhuPS+PqBreLe3uVVAmXqltJ2HRl3S29jxONMcFbAjovtPFZp0Oycu54eN717yAt+SGDWkOfswlfwCHwXrGlvt/VkFl4VSrBl9Kk6+QdSGeszN9+TU2jujMeS7Jv68y9E9xMmBUG7HB0zvZje96fOuNAkXZQ= 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 1691064358513287.0870057566691; Thu, 3 Aug 2023 05:05:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.576305.902284 (Exim 4.92) (envelope-from ) id 1qRX58-0003Bp-Q1; Thu, 03 Aug 2023 12:05:30 +0000 Received: by outflank-mailman (output) from mailman id 576305.902284; Thu, 03 Aug 2023 12:05:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRX58-0003B0-Kb; Thu, 03 Aug 2023 12:05:30 +0000 Received: by outflank-mailman (input) for mailman id 576305; Thu, 03 Aug 2023 12:05:29 +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 1qRX57-0002sc-36 for xen-devel@lists.xenproject.org; Thu, 03 Aug 2023 12:05:29 +0000 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [2a00:1450:4864:20::135]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 084ba611-31f6-11ee-8613-37d641c3527e; Thu, 03 Aug 2023 14:05:26 +0200 (CEST) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-4fe2de785e7so1579671e87.1 for ; Thu, 03 Aug 2023 05:05:26 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id e22-20020ac25476000000b004fdfefdf4acsm3304557lfn.39.2023.08.03.05.05.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 05:05:25 -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: 084ba611-31f6-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691064326; x=1691669126; 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=xJtJCMw7fy83NnUSxcXJn4fOwoFlzc9n7K+NQt3JNLk=; b=RNWNGd0waEqqsrrlGRF6VMWNTiCqywapKS5vo7BDm/+3b5nQYmkZLLkCFu+QhGUnCI A3mkbvy/dM7C31HgETx5n8dfAM2ieUsPJ75KPDq34gzwYkKpibRifIyqzKh9tbAcC2wb FzLAgrAq0BSwkJAGEgh/krJdAZ53EqRqQfki7kt9+MdkNdyy0jFqbzGJ4PNJPoDCioFV ZWvzf6YQxuqJ+A6s6+uDZFIlrFYSODlraxDAa7vJZGVNttm5r54eJMASsoCKj0uvtbFC 8TxuzXpx7a8n5/aUv94EYHpsxqQDES986incGMJPV9DnoPFDLIwflke/HNChmXsyeM8N know== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691064326; x=1691669126; 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=xJtJCMw7fy83NnUSxcXJn4fOwoFlzc9n7K+NQt3JNLk=; b=UXE2H3ruglHdDd2KB9wyZ54dxrHlikIDOBZR4VpyciFgzMaa/Q6cvTQTMJOtSZxiW8 rl0OLkrVGcHRyC05bXf40MWRa299S8/5VekpHIGfQ9Du6QxeFyJ/JKk94W4Dpd6pDagT 68kWtCqygGNRqqmo5m7I1yNHxdemlRjela4Woouy++lOqTfLI23jsHmU3RIAVW929uM5 Z8hBOhrCGwOCZqDxtRHnM/vloCSLDtJaOx9yXZzePNBoP9zAFp2ml/MLWuwHuP7sESGZ lUgfZEioTlmQBWOF4DIXyl02I7NNLjVpXxe0kJ+Oojvvz70Z4llJGXJ0uFi97CSD41gF hAyA== X-Gm-Message-State: ABy/qLa9TdQ2Zh+DrG5UaRgNCdd1+iLzcCbNLdBDctqikXx+15w5wXIT lsCjguoHr/3zVi/Do9f2rGYWZsCvW/I= X-Google-Smtp-Source: APBJJlHetGi4rKmwdsyTXvWMkMyAuaRKX7fJZoGlpHhx8H9/f9PpXxsZXR+gKwxg7MV/tlVe56k1+g== X-Received: by 2002:a05:6512:2009:b0:4f8:6560:6436 with SMTP id a9-20020a056512200900b004f865606436mr6501358lfb.9.1691064325827; Thu, 03 Aug 2023 05:05:25 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v7 1/6] xen/riscv: introduce temporary printk stuff Date: Thu, 3 Aug 2023 15:05:17 +0300 Message-ID: <4fbdbbb3bf2bf2ebee2709bbb52be02c89a4a55a.1691063432.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1691064360169100001 Content-Type: text/plain; charset="utf-8" The patch introdcuces printk related stuff which should be deleted after Xen common code will be available. Signed-off-by: Oleksii Kurochko --- Changes in V7: - only rebase was done. --- Changes in V6: - the patch was introduced in the current patch series (V6) --- xen/arch/riscv/early_printk.c | 168 ++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) diff --git a/xen/arch/riscv/early_printk.c b/xen/arch/riscv/early_printk.c index 610c814f54..60742a042d 100644 --- a/xen/arch/riscv/early_printk.c +++ b/xen/arch/riscv/early_printk.c @@ -40,3 +40,171 @@ void early_printk(const char *str) str++; } } + +/* + * The following #if 1 ... #endif should be removed after printk + * and related stuff are ready. + */ +#if 1 + +#include +#include + +/** + * strlen - Find the length of a string + * @s: The string to be sized + */ +size_t (strlen)(const char * s) +{ + const char *sc; + + for (sc =3D s; *sc !=3D '\0'; ++sc) + /* nothing */; + return sc - s; +} + +/** + * memcpy - Copy one area of memory to another + * @dest: Where to copy to + * @src: Where to copy from + * @count: The size of the area. + * + * You should not use this function to access IO space, use memcpy_toio() + * or memcpy_fromio() instead. + */ +void *(memcpy)(void *dest, const void *src, size_t count) +{ + char *tmp =3D (char *) dest, *s =3D (char *) src; + + while (count--) + *tmp++ =3D *s++; + + return dest; +} + +int vsnprintf(char* str, size_t size, const char* format, va_list args) +{ + size_t i =3D 0; /* Current position in the output string */ + size_t written =3D 0; /* Total number of characters written */ + char* dest =3D str; + + while ( format[i] !=3D '\0' && written < size - 1 ) + { + if ( format[i] =3D=3D '%' ) + { + i++; + + if ( format[i] =3D=3D '\0' ) + break; + + if ( format[i] =3D=3D '%' ) + { + if ( written < size - 1 ) + { + dest[written] =3D '%'; + written++; + } + i++; + continue; + } + + /* + * Handle format specifiers. + * For simplicity, only %s and %d are implemented here. + */ + + if ( format[i] =3D=3D 's' ) + { + char* arg =3D va_arg(args, char*); + size_t arglen =3D strlen(arg); + + size_t remaining =3D size - written - 1; + + if ( arglen > remaining ) + arglen =3D remaining; + + memcpy(dest + written, arg, arglen); + + written +=3D arglen; + i++; + } + else if ( format[i] =3D=3D 'd' ) + { + int arg =3D va_arg(args, int); + + /* Convert the integer to string representation */ + char numstr[32]; /* Assumes a maximum of 32 digits */ + int numlen =3D 0; + int num =3D arg; + size_t remaining; + + if ( arg < 0 ) + { + if ( written < size - 1 ) + { + dest[written] =3D '-'; + written++; + } + + num =3D -arg; + } + + do + { + numstr[numlen] =3D '0' + num % 10; + num =3D num / 10; + numlen++; + } while ( num > 0 ); + + /* Reverse the string */ + for (int j =3D 0; j < numlen / 2; j++) + { + char tmp =3D numstr[j]; + numstr[j] =3D numstr[numlen - 1 - j]; + numstr[numlen - 1 - j] =3D tmp; + } + + remaining =3D size - written - 1; + + if ( numlen > remaining ) + numlen =3D remaining; + + memcpy(dest + written, numstr, numlen); + + written +=3D numlen; + i++; + } + } + else + { + if ( written < size - 1 ) + { + dest[written] =3D format[i]; + written++; + } + i++; + } + } + + if ( size > 0 ) + dest[written] =3D '\0'; + + return written; +} + +void printk(const char *format, ...) +{ + static char buf[1024]; + + va_list args; + va_start(args, format); + + (void)vsnprintf(buf, sizeof(buf), format, args); + + early_printk(buf); + + va_end(args); +} + +#endif + --=20 2.41.0 From nobody Mon May 13 22:47:41 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=1691064355; cv=none; d=zohomail.com; s=zohoarc; b=Bwbvbwxlwr1+5HPEWOXGoJ6cbDrW7FC8/vUgCgd/GoZL4r94P3GFfTwzbw/P75YJnY8t/Q+q0uF0pHXDUId/qiDzK+wbFrBfHBF5LAOeVvjXeZvNlMI1lfFm4irD/c/pn3W/oiquxm6GGfTaU+ivCstbegc9D52zcQ2lJGAAT9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691064355; 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=Y+DU3kYIXVYlczgnjPIgAblT5y0PqecHU2rZnswjn2g=; b=T4vs2YFTXaksKb2FACPKdE+2dNHpc+XqkCiOdUz5e4pAdFG+jJpja9+1o1suGl0ieuZS/qFdlQlbCEfo3UHPhzQ022i4KdtuH1DZ6ZQjtRqokljTB5EvrVmq6FuU9A4cYphSbgGKMjJqGLquRZAdnhIAmn5ZvvwQhHQnHetzgm8= 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 1691064355841177.68613797941578; Thu, 3 Aug 2023 05:05:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.576303.902268 (Exim 4.92) (envelope-from ) id 1qRX57-0002sy-9x; Thu, 03 Aug 2023 12:05:29 +0000 Received: by outflank-mailman (output) from mailman id 576303.902268; Thu, 03 Aug 2023 12:05:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRX57-0002sr-5Q; Thu, 03 Aug 2023 12:05:29 +0000 Received: by outflank-mailman (input) for mailman id 576303; Thu, 03 Aug 2023 12:05:28 +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 1qRX56-0002sb-6b for xen-devel@lists.xenproject.org; Thu, 03 Aug 2023 12:05:28 +0000 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [2a00:1450:4864:20::136]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 08974c9d-31f6-11ee-b268-6b7b168915f2; Thu, 03 Aug 2023 14:05:27 +0200 (CEST) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4fe48d0ab0fso1506314e87.1 for ; Thu, 03 Aug 2023 05:05:27 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id e22-20020ac25476000000b004fdfefdf4acsm3304557lfn.39.2023.08.03.05.05.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 05:05:26 -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: 08974c9d-31f6-11ee-b268-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691064326; x=1691669126; 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=Y+DU3kYIXVYlczgnjPIgAblT5y0PqecHU2rZnswjn2g=; b=QpM/5DX/BO83ao1VktAURaEd5vCgzt+w0XxW1EJmZXBfkcFVuYv39XZXGen2V/W4T0 tGVUo5RgkpDe4TE2w+dlXerXCXb8ZTG60Rf1Xp4Oep2MG4X5l/PLahyMovcjcZlONjtk BqEQgZBg2fzjkK8GQ1QYllV7nixVPOpRM/MzlfMspE00SQIuskK9asiii0eAkBrluog6 Ohy+t7XsnC/3L0iDYVdEbl5hTNsTkbutZ5WMefoIPETJUFK73EMT9MzfACcvEsXFvv9P fgqhkZ3fYsPp2rwIeYJmEYhPShKTe507oRgPGCj+xKE6cJiQrLgvbsyi9ttpjOSMAT6F tNwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691064326; x=1691669126; 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=Y+DU3kYIXVYlczgnjPIgAblT5y0PqecHU2rZnswjn2g=; b=cnFHttdE7hRW8E9z7ofdcgBRw9I5oWfs+rFw9T+CQLoVL9s1IeZxK55EvihLDj69+L tV6ba2vusfsuJb1cmIIsNWUZEYvUBeoieRhVdXWgpn1MCoO7+l681xMBwzqoEk/3Zpm9 JuOTlmErvCFbrkHduP1Dk4U57QL3ZvLXTMVcLErBBqnXvU5Ijd5KCFUASjpNjW+aff7g uGiRIstWQB61k4/q7KjYj5PSzpd4q8HKAesaAMI2DSzzyWlDN0YiEfZxAwlKpFk0bpAK ie/bVpEnjVv5G6AFJxwXLFoBXC5K6lwp8jIjbSc+l+I8M/B791Jkoy8PBhhYqgVEgKkI ZU7Q== X-Gm-Message-State: ABy/qLYwxxTuKDyngEqXIYY1BhA2aZY1cNETapvA3vFlFOzw1PGdwvRj 1XWHwQR0L5BMb9as9M3e/7NvnsJ2Qds= X-Google-Smtp-Source: APBJJlEbonaD9/0BAPXd1RpRxUS7o9+LRSnGh1aH+kdhyaTHliEbakbUGPrbaDGLYJumlFmokTiuTQ== X-Received: by 2002:a05:6512:2253:b0:4fe:711:2931 with SMTP id i19-20020a056512225300b004fe07112931mr7480300lfu.22.1691064326389; Thu, 03 Aug 2023 05:05:26 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v7 2/6] xen/riscv: introduce dummy Date: Thu, 3 Aug 2023 15:05:18 +0300 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1691064357650100001 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 Acked-by: Alistair Francis --- Changes in V7: - Nothing changed. Only rebase. --- Changes in V6: - Nothing changed. Only rebase. --- 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.41.0 From nobody Mon May 13 22:47:41 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=1691064355; cv=none; d=zohomail.com; s=zohoarc; b=Yf0JQ2/j56l7KfAjSB/4xDL3z6+lrFOv01bwjmhlWKqHAp3gVJyRs94TAwbwerZ9DZgqVOYOHUR2yz1ozHOeIDxySU3BsKrkVdOwZjoe1yhynoPjZrck7hMe4Cyl4rSl+fsQQ504/+fwolDjDsYjtSh/md87pJADUPAn7k89A8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691064355; 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=STtKrHA1Sag04TDET++CsZtqnaGprv3A+LtpFHsKLZ0=; b=Ykn6xbbA9S1rOl02hXpPqX9fy9iALFsMqwzkfvRVDC63RKIoWwTW6PF+AP5QNhB8ywh5S89a4aAzmFKZ4Nl9TtXw9/VR1ATbZ7ZmvIoTubh0lBSW52vutYKJDcDHdVXwj4/+je+d0s9R0vpVn4P/fa/++23BNvlLWVUlw8iZork= 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 1691064355511787.7466640129182; Thu, 3 Aug 2023 05:05:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.576307.902299 (Exim 4.92) (envelope-from ) id 1qRX59-0003Vs-R0; Thu, 03 Aug 2023 12:05:31 +0000 Received: by outflank-mailman (output) from mailman id 576307.902299; Thu, 03 Aug 2023 12:05:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRX59-0003SP-HE; Thu, 03 Aug 2023 12:05:31 +0000 Received: by outflank-mailman (input) for mailman id 576307; Thu, 03 Aug 2023 12:05:29 +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 1qRX57-0002sb-Qy for xen-devel@lists.xenproject.org; Thu, 03 Aug 2023 12:05:29 +0000 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [2a00:1450:4864:20::129]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0976e245-31f6-11ee-b268-6b7b168915f2; Thu, 03 Aug 2023 14:05:29 +0200 (CEST) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4fe463420fbso1494136e87.3 for ; Thu, 03 Aug 2023 05:05:29 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id e22-20020ac25476000000b004fdfefdf4acsm3304557lfn.39.2023.08.03.05.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 05:05:26 -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: 0976e245-31f6-11ee-b268-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691064328; x=1691669128; 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=STtKrHA1Sag04TDET++CsZtqnaGprv3A+LtpFHsKLZ0=; b=Z0jMj2MbtzzeO2TkiK5IxBi2JLOcWaT3c8iXqSjMnwrOGXZUxChrwf3fJ6Njq9NcVg dRPhoo+l+mJa19wEcxQjU64qTTKCIR8LjyxLYOZpuGEcBwcxJzLogBH7tZhR+fBHizdW FmLkSwomBCgO9l7RqQcN9+WlhoMFMj5mHy7ib5Iit0e2JMzv+CF/muG6vYSt5ZE3ibcU 9spL5V5yElrnhTAlTr0VY2VWfPSYWwt4eke7C56tgnVY8AAAZGF7zM2wXeeQyI2JQu+F hOBIUvJQ8pJHT4KgzwFIu7+j7mGfJ99g2UPQXBYwfo2oRIuL53pJDx6g6jQbq/Yup80D Vv7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691064328; x=1691669128; 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=STtKrHA1Sag04TDET++CsZtqnaGprv3A+LtpFHsKLZ0=; b=FHhHILzsQ6yrf0ogRkFl8Z9kMFVZziWB08aFbDB6BZH5TXUyyCNiRIU+ChW2K1no6p fEEyT4ZZC2BGejUVujmMfuaS9u3x6rkeTagQ2QTsXP+yLi0WbigKdu+WJzgQ3npB4vgH CPt5NonHCBcZnfjWW9AJY1ZqFmIa7ygSqMX18X5nVxEFDlAyRcBmWMz36NE5tB57j5/L 4/wt6llg3wY9mOPyp+zGKARqCiWR3KWhHVAlAdcbREK7jQyIXOJEQZGw0bTIn4bbDi7L SstIhBHiZgRvfNmXL1WxVgJYyZJBRryH8Nbn7HwLGewA6ugEUNcttFScY83gQxObwY70 3c/g== X-Gm-Message-State: ABy/qLbY8Wz8RklVU0kExmBABzt4ZV5j+VPwZdtpa4tnVTOgzFrpCRL/ 92wbOolBDu6L3oycsO8sfT9Xo1dkfgA= X-Google-Smtp-Source: APBJJlHvs7TfwdJjxWn0f+qWGjUj7YUnxmhAGYG0gOXVrOItVzjirQEsu0ZTFkM/slG5jIGyujl5Gg== X-Received: by 2002:a05:6512:4003:b0:4f8:7055:6f7e with SMTP id br3-20020a056512400300b004f870556f7emr6298170lfb.44.1691064327475; Thu, 03 Aug 2023 05:05:27 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v7 3/6] xen/riscv: introduce decode_cause() stuff Date: Thu, 3 Aug 2023 15:05:19 +0300 Message-ID: <25e8e5c5826199ad6f91fb5106472917765d8260.1691063432.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1691064357834100005 Content-Type: text/plain; charset="utf-8" The patch introduces stuff needed to decode a reason of an exception. Signed-off-by: Oleksii Kurochko 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_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 | 84 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c index ccd3593f5a..ea1012e83e 100644 --- a/xen/arch/riscv/traps.c +++ b/xen/arch/riscv/traps.c @@ -4,10 +4,92 @@ * * RISC-V Trap handlers */ + +#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); + + printk("Unhandled exception: %s\n", decode_cause(cause)); + die(); } + +void do_trap(struct cpu_user_regs *cpu_regs) +{ + do_unexpected_trap(cpu_regs); +} --=20 2.41.0 From nobody Mon May 13 22:47:41 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=1691064350; cv=none; d=zohomail.com; s=zohoarc; b=h+BXLn6gkvQm+6OLLPAI41XBdZMA34rJULh08vma4hbmHmFWJ6qSFBf20JhBUJXzN+zV6hVOrAJI5Zs+UMnCmpo2MYtS3sLzb7SGI6tYZUcjwauf4At8tX7+0nDF6Y4ENRmnfN0jRqIafRINkaWRFXnU2ZHq24cS86pZC9n56Mw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691064350; 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=EXuF1AtcaFIuqh3RnuzjKGdWBJliPJb+moN2Ah/LYz8=; b=kJhcMh8gmFCMYbFrGCsFhKxtRn3806iVOPyn9TAZz/0GJcTIMgdmjjp9sWfSc1TnCWCu2bYzgZMIupv4W5rpwwmfXNHwtXBMH/f4pYq3UqQ9FNXhOPGddKyqXRSx/YrBozlWsE9PGPjNGQJb4WIyBEcwfPp5EB/9JD8DszjUpAM= 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 1691064350247387.36464736070025; Thu, 3 Aug 2023 05:05:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.576306.902290 (Exim 4.92) (envelope-from ) id 1qRX59-0003JY-5I; Thu, 03 Aug 2023 12:05:31 +0000 Received: by outflank-mailman (output) from mailman id 576306.902290; Thu, 03 Aug 2023 12:05:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRX58-0003I4-VK; Thu, 03 Aug 2023 12:05:30 +0000 Received: by outflank-mailman (input) for mailman id 576306; Thu, 03 Aug 2023 12:05:29 +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 1qRX57-0002sb-BB for xen-devel@lists.xenproject.org; Thu, 03 Aug 2023 12:05:29 +0000 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [2a00:1450:4864:20::12e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0996ed66-31f6-11ee-b268-6b7b168915f2; Thu, 03 Aug 2023 14:05:28 +0200 (CEST) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-4fe28e4671dso1586007e87.0 for ; Thu, 03 Aug 2023 05:05:28 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id e22-20020ac25476000000b004fdfefdf4acsm3304557lfn.39.2023.08.03.05.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 05:05:27 -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: 0996ed66-31f6-11ee-b268-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691064328; x=1691669128; 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=EXuF1AtcaFIuqh3RnuzjKGdWBJliPJb+moN2Ah/LYz8=; b=gRt8bvU/HD2PsiCRodzS3I+Wd6vdyLIiKQ6TVGm0bEIXxGG/YxYsgpadjNhjJFOHZc boEcOY8/NMbjRv9OB3eOWkZKhJqR745V4uG2e1gF/zcas7vS3B7rDMzjFgAxL3ZHte/A 7uquNO9uO4p6HiEwGAoCbd/W/vIPXgNn24ofvgvyIPCUrO1quJwWzv6DnjO5LhL9kJj8 TWN+jPlzEcQJjI/Pt9fDkR3m4By3xjDcD2TOExycv5qSsbU3jS2/UphfWu5Sg+pDaheV Y23fPNM55yuLmMC2PsUSd7Y8DRR/JJ/KLsQU3myo7bjQ6rv5j2EGOgvnxxz/L0VYGj/2 69TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691064328; x=1691669128; 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=EXuF1AtcaFIuqh3RnuzjKGdWBJliPJb+moN2Ah/LYz8=; b=XZDJotmPe95E1m7X177znlv36qoCeatTRWekwe4BUNxWpAuMRtv7ql9m0RFfPF03Re 2NmU7pJvVTIKjqZtDzUNvNShugsBUVcjN+gidYVkkyTbdaWtwPp83PE1bcvLTsRp0iVH Hc47DwRtbPPWo0Gys9Agj7KyRgFS4Y76unxmCgzzWkAIftucESg5PAmf1RL+vt+S9MuG XC4Z9KByepRD7KUIXgv0jM20B3MEFovMSIKRtAEoRCZUgpq8maID3WyDWeVt5DrV9Vfe VJ505zxuwxFIY5i6I+2REIPBWef1j77OLU9ZjY8dpRDYUQgWQRDhxTw0Z7JDOiOAym+B e0ZQ== X-Gm-Message-State: ABy/qLZwUEmlKa8t1lTfsv8R1eW2A6HCd6KRKptfDjbtfQnMahwKEjyh 727pqh01mYLI3wJFxepFo/QeMO6fpIk= X-Google-Smtp-Source: APBJJlEYKsvurp295A8fafMIlO/Ww5a4Tb9xWwALkTdp3vT1IkXrzdcwiuV8Q5VT2RegS9LqjAY/fQ== X-Received: by 2002:a19:ab09:0:b0:4fe:1ecf:8ab4 with SMTP id u9-20020a19ab09000000b004fe1ecf8ab4mr6014686lfe.18.1691064328125; Thu, 03 Aug 2023 05:05:28 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v7 4/6] xen/riscv: introduce trap_init() Date: Thu, 3 Aug 2023 15:05:20 +0300 Message-ID: <921ea81d2571ce3103336cd2bf6619b8a8a6751c.1691063432.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1691064352039100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Oleksii Kurochko Reviewed-by: Alistair Francis --- 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/as= m/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 @@ =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 6593f601c1..abdd1669c6 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -5,6 +5,7 @@ =20 #include #include +#include =20 /* Xen stack for bringing up the first CPU. */ unsigned char __initdata cpu0_boot_stack[STACK_SIZE] @@ -15,6 +16,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id, { remove_identity_mapping(); =20 + trap_init(); + early_printk("Hello from C env\n"); =20 early_printk("All set up\n"); diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c index ea1012e83e..3e08ec44f7 100644 --- a/xen/arch/riscv/traps.c +++ b/xen/arch/riscv/traps.c @@ -12,6 +12,18 @@ #include #include =20 +/* + * Initialize the trap handling. + * + * The function is called after MMU is enabled. + */ +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.41.0 From nobody Mon May 13 22:47:41 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=1691064356; cv=none; d=zohomail.com; s=zohoarc; b=YApDWO17W2+l/ckdS0ewVnJ+4Hj6dBrup6o6IepTS7uqvKq7xQK19h3jMToO4fDelGU+BZ3NicHRGufKY1iBKWwlJzhwVEf3oJyQEhN2aPh3+Bry1FyIEP0a6wR+tx9bIy+jAmoqIkfCwSyz/0BZbxKcMprT1nLGIX8FmVQDsRU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691064356; 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=n0T/c4H8PYV8a+tUf8bqa7kNmhfFOIl+4o24A/6F65Y=; b=jJVV+VU2plLNgznuc/uYNKmAlh6/E7NiqbQ1GHDSIPyW9CE0+TFRPluYVZhQx/uAZHB7n6KbRFL57Jbxm+tr1sTzWGe/z0ong+S4eg1jWHcXW+zlVG4v4+w0MbEfc/0WBAYt4j+XqL3ZQbFV1jxmu3/DFYDMbQt/TOE97g8WQlU= 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 1691064356965579.4478648206282; Thu, 3 Aug 2023 05:05:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.576309.902320 (Exim 4.92) (envelope-from ) id 1qRX5B-000461-Cx; Thu, 03 Aug 2023 12:05:33 +0000 Received: by outflank-mailman (output) from mailman id 576309.902320; Thu, 03 Aug 2023 12:05:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRX5B-000455-63; Thu, 03 Aug 2023 12:05:33 +0000 Received: by outflank-mailman (input) for mailman id 576309; Thu, 03 Aug 2023 12:05:31 +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 1qRX59-0002sc-P8 for xen-devel@lists.xenproject.org; Thu, 03 Aug 2023 12:05:31 +0000 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [2a00:1450:4864:20::12a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0a391522-31f6-11ee-8613-37d641c3527e; Thu, 03 Aug 2023 14:05:29 +0200 (CEST) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-4fe0e23a4b1so1554116e87.3 for ; Thu, 03 Aug 2023 05:05:29 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id e22-20020ac25476000000b004fdfefdf4acsm3304557lfn.39.2023.08.03.05.05.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 05:05:28 -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: 0a391522-31f6-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691064329; x=1691669129; 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=n0T/c4H8PYV8a+tUf8bqa7kNmhfFOIl+4o24A/6F65Y=; b=m802bzewGsdutyqXiwNNiqsYfn3M4z9y5xCanYDSAoA3f8ePVkg/q+T3QSz1krZJbW jjE8Xme9E05+k17DEBsRkiMxZZykmstizUoamdINVEJCYaIYmeHaHYC9ZVoVkasrusoA uf5rdFd9/O+WPvJhaFwBNPQs2EImt+HITbwLhyIKB2WpT/gVrGZpyDy/LQDO4RiHAiPz gov6/EsKwHHrHiJ03r9iFFaks7XPrryTi/ovEt/VWVMnw0jgF22Xz7tTfh9cI5elTtD2 5VfQWJx/V7Y2a1p0RNkqKmTGedc6bUl0Rh/szGEDOmkoLoM9ZDoxeEEKbtVLYPeUx8Ob O8xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691064329; x=1691669129; 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=n0T/c4H8PYV8a+tUf8bqa7kNmhfFOIl+4o24A/6F65Y=; b=iKYl6iSfjwVm7hBvMLRCItxmHJYRF9QbfVImBux0YncG32F06xsVe31eMDWjJ0+vie hXyyXCmiMKFBszlw9D7JtTFL74Gn6Ue2tAKRrX7bcktHsWx0R+FPu0kPMITQ19S+J8YZ 5vks78AEE4lWi+8mD6Y3+vOK2c7JUpddKeVNEpQvltD16Kkwi3IPbqxmk6ySrwVEbxfd IMc/tF4f8KqI+SM0jkAc18/UnVZ4xdAUoEpGX8M8WHWMrQhqXLKiuQzr8pnCDsr4zEkb vZHGjLoYWaFwhKfrP1BAtYLRLBd6R7HRh+fPIvmpAXIG7pN5/7rgtKMG1tWVA0JfeiJ0 EbGg== X-Gm-Message-State: ABy/qLY60VFWowZGvnfR/5SRbw1eD9uO5VITQs4c4IVhsXXyoYxpaUpx KUFFmj77MAhjFD7c+V9N0pZj4SWzuCk= X-Google-Smtp-Source: APBJJlFcG/cnXqx2b/EBsYl3rOroJ1/VDytVVW7Wh4XLH1gBRwg4iEuipD+1UxKgXe6vmMzf+NnUCA== X-Received: by 2002:ac2:5b4e:0:b0:4fe:1f1c:184f with SMTP id i14-20020ac25b4e000000b004fe1f1c184fmr7005761lfp.44.1691064329028; Thu, 03 Aug 2023 05:05:29 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v7 5/6] xen/riscv: introduce an implementation of macros from Date: Thu, 3 Aug 2023 15:05:21 +0300 Message-ID: <9fdda7716faf412f1e2cdf9a990c98e64c4b21f3.1691063432.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1691064357691100002 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 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.=20 --- 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=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 | 27 +++++++ xen/arch/riscv/traps.c | 128 +++++++++++++++++++++++++++++++ xen/arch/riscv/xen.lds.S | 10 +++ 3 files changed, 165 insertions(+) diff --git a/xen/arch/riscv/include/asm/bug.h b/xen/arch/riscv/include/asm/= bug.h index e8b1e40823..f5ff96140f 100644 --- a/xen/arch/riscv/include/asm/bug.h +++ b/xen/arch/riscv/include/asm/bug.h @@ -7,4 +7,31 @@ #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 ). + * + * 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/traps.c b/xen/arch/riscv/traps.c index 3e08ec44f7..439c098c22 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 @@ -12,6 +14,8 @@ #include #include =20 +#define cast_to_bug_frame(addr) ((const struct bug_frame *)(addr)) + /* * Initialize the trap handling. * @@ -101,7 +105,131 @@ static void do_unexpected_trap(const struct cpu_user_= regs *regs) die(); } =20 +void show_execution_state(const struct cpu_user_regs *regs) +{ + printk("implement show_execution_state(regs)\n"); +} + +/* + * TODO: generic do_bug_frame() should be used instead of current + * implementation 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: + printk("Xen WARN at %s:%d\n", filename, lineno); + + show_execution_state(regs); + + goto end; + + case BUGFRAME_bug: + printk("Xen BUG at %s:%d\n", filename, lineno); + + show_execution_state(regs); + + printk("change wait_for_interrupt to panic() when common is availa= ble\n"); + die(); + + case BUGFRAME_assert: + /* ASSERT: decode the predicate string pointer. */ + predicate =3D bug_msg(bug); + + printk("Assertion %s failed at %s:%d\n", predicate, filename, line= no); + + show_execution_state(regs); + + printk("change wait_for_interrupt to panic() when common is availa= ble\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; +} + +/* Should be used only in Xen code ? */ +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 3fa7db3bf9..a10e0ad87c 100644 --- a/xen/arch/riscv/xen.lds.S +++ b/xen/arch/riscv/xen.lds.S @@ -45,6 +45,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.41.0 From nobody Mon May 13 22:47:41 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=1691064352; cv=none; d=zohomail.com; s=zohoarc; b=WTgsA27BbSuueEhcE1y03HeDA6Py1cHob+zo4CGIHH879P1dEMWCMQTBSM9QVKFXMRUGjpzzLg/t0iOmTXXQan6YfKQJysdMy/aCawqHdVmU+tmxEl+XR3ejFo8C0j+6l8OPcO+Qotsi62N6e5uhsYyYobtHZi6p2ZXpsSYrhSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691064352; 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=VSibP5eTiQgTk20HjOHTiUPAjHnFr8NTK33Zlp/pEgM=; b=aKJqqquW4anbA9Du/zDTuwij3edSfx1xknhjf/B6fmUIIJmalKpF2QKxcpf/4dcn7RNbvdCAD50c+H+AhHHPieGPLs2pI3KIw1AzT0drXdNQlPx3UXuypiJpmp73w+IXFeHOK6HgDdonYHymqXV1MhZtll1ioHngRdWrDbT4Hvg= 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 1691064352552861.0119344639346; Thu, 3 Aug 2023 05:05:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.576308.902316 (Exim 4.92) (envelope-from ) id 1qRX5B-00042e-5d; Thu, 03 Aug 2023 12:05:33 +0000 Received: by outflank-mailman (output) from mailman id 576308.902316; Thu, 03 Aug 2023 12:05:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRX5A-000418-Rf; Thu, 03 Aug 2023 12:05:32 +0000 Received: by outflank-mailman (input) for mailman id 576308; Thu, 03 Aug 2023 12:05:31 +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 1qRX59-0002sb-M7 for xen-devel@lists.xenproject.org; Thu, 03 Aug 2023 12:05:31 +0000 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [2a00:1450:4864:20::12a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0af92a90-31f6-11ee-b268-6b7b168915f2; Thu, 03 Aug 2023 14:05:31 +0200 (CEST) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-4fe1c285690so1484750e87.3 for ; Thu, 03 Aug 2023 05:05:31 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id e22-20020ac25476000000b004fdfefdf4acsm3304557lfn.39.2023.08.03.05.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 05:05:29 -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: 0af92a90-31f6-11ee-b268-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691064330; x=1691669130; 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=VSibP5eTiQgTk20HjOHTiUPAjHnFr8NTK33Zlp/pEgM=; b=W6CAZlzPU+q9DyJ4PxnDSCSGu2OKImYbHfsVDqpgeVcB03n78aqZo+OJFUKhCPpqvA 3SGs0+aJjno9H1WyopozDLnhJxISIFMSaxf5NLJQGEzb1CHm3DRvfh91cn4q4EnPj/3q 3a8Ty1x2z0FR5T7q7R4eXyMRFrgt1P1V6BAZYkNWfIfMb00+HcdlcLNohfNaY8ftV67s 5f5FqWruN5SCnuRSge+9zxNRYLGgHQYSuE2wFv3eZOP/uzY3NBlO7s9B0QGBVll4u7mP NFqXGNaUDBqtsDocKl8aBME+k7rlfkieewXMxj3i5iq1bVXVPJulwavaLh5wgZhIicWm 0VXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691064330; x=1691669130; 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=VSibP5eTiQgTk20HjOHTiUPAjHnFr8NTK33Zlp/pEgM=; b=EOC2fxJzBMSbmepzTzArxx+7G03PXK0jH5oK5t2wuCoSqiBY/DSO1a+4rf+8zuFFuQ aA4ell+Ff7PmY5c63LVaPXCdhyocZsweivTg5Bud1cXJ4n9RFf5Uz8R/xvKa6tBidS50 roUiDXwt9lTA81oYvIWTB1XojQsRVGkWVV6VF4j6C54ATEQYrslA9eXR2oHOHhla1XJ7 h++MAQK5BwQDBLnO7DAG1RcrgHY/z++XEm34l+/pOSlJC8IFAe5gfwTOkk1HI/AV9dmH 4IBxlbkWCecZLEo+Jw77YAhplxlxBDPZjTC7ZSQHQMNHXb+UHrUZ4T2LEx9zOr96gPNo chHQ== X-Gm-Message-State: ABy/qLbKmrqzKWkCdOeR8AM/isJExFwj4ZqcEPwPo+PN37X6sJxQEMqx VAzKicEwdV2JJ7hehx2audqx4a88GWg= X-Google-Smtp-Source: APBJJlG4UqEUWpc3dVF03OxtTwW2iHbpqYjBVtCRroEIaKyZdZ+eNxE4rlulDSKQ0g3NphinHlIrvA== X-Received: by 2002:a05:6512:2521:b0:4f7:6775:2a66 with SMTP id be33-20020a056512252100b004f767752a66mr8694805lfb.53.1691064330433; Thu, 03 Aug 2023 05:05:30 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v7 6/6] xen/riscv: test basic handling stuff Date: Thu, 3 Aug 2023 15:05:22 +0300 Message-ID: <89553c7196a3e01294a17a0ae3946544b1b14e04.1691063432.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1691064354227100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Oleksii Kurochko Acked-by: Alistair Francis --- 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 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index abdd1669c6..ab83f84e67 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ =20 +#include #include #include =20 @@ -11,6 +12,20 @@ unsigned char __initdata cpu0_boot_stack[STACK_SIZE] __aligned(STACK_SIZE); =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, paddr_t dtb_addr) { @@ -18,6 +33,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id, =20 trap_init(); =20 + test_macros_from_bug_h(); + early_printk("Hello from C env\n"); =20 early_printk("All set up\n"); --=20 2.41.0