From nobody Mon May 6 05:10:59 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=1685362439; cv=none; d=zohomail.com; s=zohoarc; b=S0rVbgmCA4scUBoBc8p0sqr50n6nV+78xhaETJE4Q2VIUmSy6d36JycIyFW/RfDYNNJdrPROBGhoknhb5ni9icS6vFOMA7EYTB2aV7vFXbRmZT4P7E/hxAm49SzYof4KqWRrPEJu1faKKZQa6+TYXy1tcCaIv1ptMLkMKF4bJUo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685362439; 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=/C052OVgKf2/+kQyjQaALA5nb1G75JwZbX4aVlgaqOA=; b=dtFla0J6fFPAVzsROth12UVu6gfInUd0J2BcUS5NiHz6xTeJXszpaTO3Bf/cxProFN8J4XcBwo9IoTOp0E0Bb0jD9pfGNTg9cp9QArSarVjPmRM0Cv6T04XHhbJXKvynyybuvvScmM31+1N/BLV7AZuQ35R1pfyXTH+ELahUXvk= 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 1685362439369208.48158708559686; Mon, 29 May 2023 05:13:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.540605.842466 (Exim 4.92) (envelope-from ) id 1q3bkf-0005Vz-Fx; Mon, 29 May 2023 12:13:29 +0000 Received: by outflank-mailman (output) from mailman id 540605.842466; Mon, 29 May 2023 12:13: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 1q3bkf-0005VS-9Y; Mon, 29 May 2023 12:13:29 +0000 Received: by outflank-mailman (input) for mailman id 540605; Mon, 29 May 2023 12:13:28 +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 1q3bke-0005DI-5h for xen-devel@lists.xenproject.org; Mon, 29 May 2023 12:13:28 +0000 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [2a00:1450:4864:20::230]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 35be092a-fe1a-11ed-8611-37d641c3527e; Mon, 29 May 2023 14:13:24 +0200 (CEST) Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2af189d323fso48962231fa.1 for ; Mon, 29 May 2023 05:13:24 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id z14-20020a2e964e000000b002ac87c15fd4sm2427762ljh.95.2023.05.29.05.13.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 05:13:23 -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: 35be092a-fe1a-11ed-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685362403; x=1687954403; 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=/C052OVgKf2/+kQyjQaALA5nb1G75JwZbX4aVlgaqOA=; b=VNtgcoWpnSU3L62BC1zjb8x+g1k92ZREVQ2sFWV0gKoTLZkqrSmvRezX6zNPMdy89n P/KxOIkgrwgdu606XaKgCeDWNNHro4WpxMJsPOH+nw0DLFxOiBSgK4MME7eafqAtubYF LIu4ySxhet2MWQrU8I9DpuRQuDM66qgl4WrYR1w8ajBnYP6dNp1ZZhlkbkL40pGBoIKa oiwIx/dYzIdA/p9rDDAJMvH48rlhZ0wMpqQeVY/cl1HA4dPEc8PAQDtCpxpTZXrfNfYk fS0tYDLDOfD9fCIdl6T2FGhybdO6eVoF4cgHCfkl7NpoqvTMz32KbN5Yi86Sb4wrPOY+ jCPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685362403; x=1687954403; 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=/C052OVgKf2/+kQyjQaALA5nb1G75JwZbX4aVlgaqOA=; b=aHtuGAUjwJWGy95Q7u3juqRWBFfqYz1YNAsIdwysYlXwS69NiccELaTwSxYtc2lWf1 IUzxKsPcOGB2v/rRyU6cC6IfgwEYKC3yj0vjrifoc2x+Hk+XwypwDo2BXuL133rIr3Hn 1CGMEZkKgXMAfyBjwmY3F3L6OOGbsQ9pbvnspx2v3J2nFuLh/MoYvGcLAPV8wGaOamsC EA8c3NJwGXzDW2oqxrcRWQg2b5RBlTeD1f9xvUXcrvxJw3C8w2Ep3M1nObUEZ1FERU3t KSS2AcNUpidtVQB17Xm9flN5iwoDbTTe+xZXUnan8asHUh/lX5YySEZuwx5obY9ITx4C nzWQ== X-Gm-Message-State: AC+VfDzU38Vd0Lg/m9oUfStx2GxDUSFPpAIl8zaRWTlcqLdNn9tBAJf2 g9ybcKbe/lBV5LzfrioInLXZAgU6wJo= X-Google-Smtp-Source: ACHHUZ4KpIiE+T3YC+yLia9p7gQBArv3+/5DXIUwucKoZGsfb2YMWCRkXG+rsinXEzmUEgPso8B6ug== X-Received: by 2002:a05:6512:10cc:b0:4f2:47ea:2f32 with SMTP id k12-20020a05651210cc00b004f247ea2f32mr2439587lfg.23.1685362403464; Mon, 29 May 2023 05:13:23 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Julien Grall , Andrew Cooper , Stefano Stabellini , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v6 1/6] xen/riscv: introduce temporary printk stuff Date: Mon, 29 May 2023 15:13:14 +0300 Message-Id: <2a43fd49b34ff2e3e8e3c35e9cf0bdd72ad63f91.1685359848.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1685362440816100002 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 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..7d24932a35 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.40.1 From nobody Mon May 6 05:10:59 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=1685362436; cv=none; d=zohomail.com; s=zohoarc; b=ROALpAxcLNRJBCL08g5NV5g/wrB/NcA60l0IGFOpQZp074EiI4Ae1lTHRz8crlJNGNk4k3knul0kwbUuSWKCDjQflT+7EiaY8Nwme06SeAHHzAFkH04rHH2zlo8ByMvAW5Gu5y70E95yqE4gaUZBgs3s9gBFsalJ5eftBFiQNCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685362436; 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=HHQHWourHZby5JiDzW3SkVKPGSqK79/gkhN0T0QJ+Ak=; b=X4VbZzN6OJ5SfkOHIEz0h+hhzpe6DFzZR+hoQ3U58yirgz1vsATzvcnlgyByZAtvSYMiCKwRcHaEP2xceFMfU06bf+yE1dVKmr3yfZc2h+tsR5VP2+06LyGm3sXDMSR4GCP2JhmjYGbCPxcREWUKTDA/GgyuJ9Tui6cByoVO0SI= 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 1685362436016451.6889754471688; Mon, 29 May 2023 05:13:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.540606.842472 (Exim 4.92) (envelope-from ) id 1q3bkf-0005d4-Nz; Mon, 29 May 2023 12:13:29 +0000 Received: by outflank-mailman (output) from mailman id 540606.842472; Mon, 29 May 2023 12:13: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 1q3bkf-0005cG-Kh; Mon, 29 May 2023 12:13:29 +0000 Received: by outflank-mailman (input) for mailman id 540606; Mon, 29 May 2023 12:13:28 +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 1q3bke-0005DI-Ci for xen-devel@lists.xenproject.org; Mon, 29 May 2023 12:13:28 +0000 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [2a00:1450:4864:20::235]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 363edad5-fe1a-11ed-8611-37d641c3527e; Mon, 29 May 2023 14:13:25 +0200 (CEST) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2af1c884b08so39784941fa.1 for ; Mon, 29 May 2023 05:13:25 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id z14-20020a2e964e000000b002ac87c15fd4sm2427762ljh.95.2023.05.29.05.13.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 05:13:23 -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: 363edad5-fe1a-11ed-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685362404; x=1687954404; 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=HHQHWourHZby5JiDzW3SkVKPGSqK79/gkhN0T0QJ+Ak=; b=oR7cLdVsdieoIpYv82dgRiF9/zLzzAid/pFmpbkcUioNpbkh3/qHGt1TYm/rVl5DJx soBQV7eVkPDC0RIPuDv5yucnEkEcnYfnRudMEh+t68+EuLv+mttGoX1YiqDjHUsHrhEH lZ3sVbDL7CVDCrCl9dkg9P4qewvgQSaEh3q7feQ15eHAH3lhz/MAmDWqpl5MstytXF+J 4TDFF2YLMwYSt4MQIeQZko4sCdaOIfmFXNa0HodxhDc48UdutIvupJGlIGz45tGNjFi5 +iQnR4E2Fc3RAkjutsdeAKvcIUAdApps6M+YGBJlGLaYrRbNbsVKvoO6/ymWvaAxb/L+ 2OsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685362404; x=1687954404; 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=HHQHWourHZby5JiDzW3SkVKPGSqK79/gkhN0T0QJ+Ak=; b=YHxJV0JNnM7jSoKAd6xXe0fSkENQ8GrbSLUeVHXDYRW6W74GTmPTajuc09MS/siQFf GMJv5cIksu2mwJWhE8MsgzzRNUMam6PL+butp29skEvxrP0/W0XbtCmzjbWNhdfRDIzn wdRguiiZwnu3gC1EumeLmK6shD7lmBR7U2khR6D1svF1RQ48vCbEzvOK/H0TL5umiPWN J0AbjT+7WveMyFNwnxEw6NhjlsVUR4OsItffS/1IBiVFXUelTU82c/yDibFbNF6ELGG2 KvzTdAxRwA2ZaTXLDYnv3mluFGoLV15bKTGgT6pGTXtZLsvWvAbe0dRR/nSrzH4ERSld gR9A== X-Gm-Message-State: AC+VfDxrdW2ObdctrgE7LVoBoTIU8nsLkKB9T5ML+/+sdEsHxS0MDf43 +4PX1CBoZ9Z7TI9bZFQrySC4yG03FYw= X-Google-Smtp-Source: ACHHUZ43cpZFa9TVNywdOJd3rfXwSv/GypAR6BFC3btMjVEMX79QTrjh+aBZWQaeBunLSyl/B6FQUA== X-Received: by 2002:a2e:9b0d:0:b0:2b0:248c:bc4e with SMTP id u13-20020a2e9b0d000000b002b0248cbc4emr2678913lji.19.1685362404357; Mon, 29 May 2023 05:13:24 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Julien Grall , Andrew Cooper , Stefano Stabellini , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v6 2/6] xen/riscv: introduce dummy Date: Mon, 29 May 2023 15:13:15 +0300 Message-Id: <268eb55c4f6ff4eb9e1a2524eae7645ffc79568c.1685359848.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1685362436938100004 Content-Type: text/plain; charset="utf-8" will be used in the patch "xen/riscv: introduce decode_cause() stuff" and requires Signed-off-by: Oleksii Kurochko --- Changes in 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.40.1 From nobody Mon May 6 05:10:59 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=1685362441; cv=none; d=zohomail.com; s=zohoarc; b=RqaOhoBdzHewnqBO0f9kJVHvMj0eg9Uyt8Wv1ZEuRy6pznPo0jqbmnLOov2LQGo0FzjvbQZwdIF9WXH7Vq9Fv/9iJi2zibwAkQ16lbCTcPtwZgbtdnvwiGBBTn+jXCPNyGPV1jWjmBTLoMYmvneBX1LMBiUpHRBOv2qTYYv/73w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685362441; 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=wkQ4zHDkTr4O9GodmGbD3ibtCyQrQEbN6NGk6h/UX0A=; b=LYcm9nXYGZ3bciiZ+aopWUohh8RY3eCdzI+N/1jLMgr9/RsApeFoEilFEH8zGBgDjVcsKypAQ6x0zOwEYsfnwRN+upSTzYU4/JmyO+1DNvrC0VyT4fZSlBHKtHNncZKRYeKD6B7hAAm5cHCG5N4IFmgNZyXVYz+Gcv8FbB41Jfo= 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 1685362441736832.4749403888355; Mon, 29 May 2023 05:14:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.540603.842450 (Exim 4.92) (envelope-from ) id 1q3bkd-0005DX-Sm; Mon, 29 May 2023 12:13:27 +0000 Received: by outflank-mailman (output) from mailman id 540603.842450; Mon, 29 May 2023 12:13:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q3bkd-0005DQ-Pw; Mon, 29 May 2023 12:13:27 +0000 Received: by outflank-mailman (input) for mailman id 540603; Mon, 29 May 2023 12:13:27 +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 1q3bkd-0005DK-2F for xen-devel@lists.xenproject.org; Mon, 29 May 2023 12:13:27 +0000 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [2a00:1450:4864:20::234]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 36b8513a-fe1a-11ed-b231-6b7b168915f2; Mon, 29 May 2023 14:13:25 +0200 (CEST) Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2af7081c9ebso33984231fa.1 for ; Mon, 29 May 2023 05:13:26 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id z14-20020a2e964e000000b002ac87c15fd4sm2427762ljh.95.2023.05.29.05.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 05:13:24 -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: 36b8513a-fe1a-11ed-b231-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685362405; x=1687954405; 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=wkQ4zHDkTr4O9GodmGbD3ibtCyQrQEbN6NGk6h/UX0A=; b=d58sQl2RjRtSnDVfLMcJjRKVv1upnmb9HuOWNe/xYJmPy3KUgpdZOWqOGyHyY1UiN1 c1qldE4Id8rQqM/qwM/Y6+tMhWjabRmrOBH/TzzsaYqTZ1FKuB6lBQpJmBCQL5tejuzz uxc6QNunuKRvGTS2RMV3KuXMQAfbkQR9sJpV+Nzly3CskFCeMDq1/ZH1dkEJAI3fUsr2 lvyo8oseMqvIsh0TVDdNBasMESmZzrJOwg4NLM1u8wx7wcwahPcQ35WLShm4+fqQmyDN 5OYTKGZI/CEwikX5y/LyhTX9AsqngumqHBM8ii6vekCz9IMHnKJtkE4afavoiJSrrUnn vfbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685362405; x=1687954405; 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=wkQ4zHDkTr4O9GodmGbD3ibtCyQrQEbN6NGk6h/UX0A=; b=N3LseP5VmksNXALGPd6BW08UaoPk1MgfGeJEfmE13gc3I0W9wZ870aN8ZQXJQkeIWH tHskXeggc1FCTQXelAXm0C71T1igC5Mk3Ld9ww4sMvoYEVUWgCNxy2QmxjK28bJGK3dm gtYN0QYDCqNxu59Af1lgFsyJKEiNZAFaqnUxgryGwGIt5GBhUpEyHpxiK8P9bCzfaf64 DzHLp9+LceyeiDXvtUEZ4++nT8tbPoP5lWNUivO9Rd+zgvYPQe4lbT5sWwMURVCqM4eR yIW5cC2LxoxcaQCS2rIdg4qm7jYSMfKfhEEa43QzEqZaYMOLs5VFAtcqiDPfoATEHqQy zvRg== X-Gm-Message-State: AC+VfDzIuMWbtG70ZGYW5UOrRCstG1M6+Zwo757PAXHQLujr4fXKBa80 HXISeD7qmUMKHLRa2caIcAlVGgFZnNg= X-Google-Smtp-Source: ACHHUZ4Ha9S4qBbRlL0G/+/O2i7GhUTN8dMSJOG9tXm+dMCi/JovQUoEALmoa6jvQUrT/H5v3za5aw== X-Received: by 2002:a2e:9417:0:b0:2ad:8a4b:6a9e with SMTP id i23-20020a2e9417000000b002ad8a4b6a9emr3593392ljh.26.1685362405214; Mon, 29 May 2023 05:13:25 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Julien Grall , Andrew Cooper , Stefano Stabellini , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v6 3/6] xen/riscv: introduce decode_cause() stuff Date: Mon, 29 May 2023 15:13:16 +0300 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1685362442517100005 Content-Type: text/plain; charset="utf-8" The patch introduces stuff needed to decode a reason of an exception. Signed-off-by: Oleksii Kurochko --- Changes in 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.40.1 From nobody Mon May 6 05:10:59 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=1685362441; cv=none; d=zohomail.com; s=zohoarc; b=NPS0+P8HSuuLMwP9MoJxMh//ILzbTxgOMUDINCWUxw2QJtw+LvBG7cSFrmSKmcTzbjXc/IniXlVKnDt1Qs83gjyVaSQlbtescxLRfjOvSc8MN2XLD++8dW3sgeTiryNDi6UJmFwvA3kq+4gTYupR0zp4lnH+mTKeeDY2Wswbjh8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685362441; 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=GfEaiOQUBCZEc9m9TcpbthmlviGr6gh0qCBn/DEmm+4=; b=NrSSo1QQjgs9xwGbZOQkGHQrwloRhoyWHOJX8IzSihwwj3eTQ4fABzX5I4QyvYEaaMLFau3PXj9qImAg+E76ptePISlJKsg7CKsYvexKjit3B1pm206pH6Idb4x+KOf8OlM3kB+7Of3/0jMB82NiUnXTSP1F4d4lgK7N0x7whW4= 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 16853624416951001.6597219598362; Mon, 29 May 2023 05:14:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.540607.842480 (Exim 4.92) (envelope-from ) id 1q3bkg-0005oO-8T; Mon, 29 May 2023 12:13:30 +0000 Received: by outflank-mailman (output) from mailman id 540607.842480; Mon, 29 May 2023 12:13: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 1q3bkg-0005n0-3U; Mon, 29 May 2023 12:13:30 +0000 Received: by outflank-mailman (input) for mailman id 540607; Mon, 29 May 2023 12:13: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 1q3bkf-0005DI-5h for xen-devel@lists.xenproject.org; Mon, 29 May 2023 12:13:29 +0000 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [2a00:1450:4864:20::22e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 373c73be-fe1a-11ed-8611-37d641c3527e; Mon, 29 May 2023 14:13:26 +0200 (CEST) Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2af2b74d258so33764371fa.3 for ; Mon, 29 May 2023 05:13:26 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id z14-20020a2e964e000000b002ac87c15fd4sm2427762ljh.95.2023.05.29.05.13.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 05:13: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: 373c73be-fe1a-11ed-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685362406; x=1687954406; 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=GfEaiOQUBCZEc9m9TcpbthmlviGr6gh0qCBn/DEmm+4=; b=T2UzzMCjI4y6qWUGyeniQt8VMvQpgboaSIZdZw0x1K5eOf1UZLucx1O6DAJg2vRMVd 3+MH40pASrruXzh+CDny1F81oCfKe/f9L8HzA9tL5jJl1ODC6DwGNL79QXiTjpyhCSAj 38wnNLObZ4aVUvQMuY5JytvfKRl0FqanO2nvTRZf4D/21Qcvg9R+T8IRyQSjlb2oTA8K hx7CWP1xtHp4AhT6FDVcxyrKqrljjCIot8geRQk6L8Ykl+dpHmcF1+oGAunc09D6BxWR OAGTscoHZTDmOnLcCLMtUO6VL5gBDu+aHhC/P1uZh8wUx32fCOKIFMT6dW8/UJbv+xPJ d7sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685362406; x=1687954406; 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=GfEaiOQUBCZEc9m9TcpbthmlviGr6gh0qCBn/DEmm+4=; b=h4KtRcyFTiTZqT6a7I554or4cIcJIfwsP+Ny+9iPKDx7SnnnVThZcpG4gnmVjTwUs3 +jXC6PPRzQaamX1G8zJsex5o9hVqYBnS2p8XluN6mZ7M6GUUiRlq9LOy7fyeuRFx4Nq6 ry441QoVoO0eKYlNnU+g/3T8ziOeGLdzLylqGf4lO+gu69ViLgpVZ6J0OBA1KsL+nYOx UvkdM8wq6MA2mR3CJW0dgtPNsaxSindNpaQT31mBw8TK3RTks1uQlWd2nV7gXnAWLllw WC1P1I07pOnexJta+KRGxmcw46hv+CcXRMBEEm4MKLTu4obea01z6l9sl7dk/UnGDSHq Ea5Q== X-Gm-Message-State: AC+VfDy/Nf65NALe3gPSVIEUCdyWPrnyxoD7lrJoIAvYyCesrao3sN7d eKZrev/1hc9ZcOI6RZw6MO/bK6qEBNA= X-Google-Smtp-Source: ACHHUZ64pZrBI6bynejBHjG+p4XjvJ1GwyCqiLiS7raB5U4Qd6ZRbytGgFAO1fA2A6GAzNeTb1SnEQ== X-Received: by 2002:a2e:b706:0:b0:2b0:497a:2029 with SMTP id j6-20020a2eb706000000b002b0497a2029mr4504061ljo.23.1685362406101; Mon, 29 May 2023 05:13:26 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Julien Grall , Andrew Cooper , Stefano Stabellini , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v6 4/6] xen/riscv: introduce trap_init() Date: Mon, 29 May 2023 15:13:17 +0300 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1685362443008100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Oleksii Kurochko Reviewed-by: Alistair Francis --- 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 | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/xen/arch/riscv/include/asm/traps.h b/xen/arch/riscv/include/as= m/traps.h index f3fb6b25d1..f1879294ef 100644 --- a/xen/arch/riscv/include/asm/traps.h +++ b/xen/arch/riscv/include/asm/traps.h @@ -7,6 +7,7 @@ =20 void do_trap(struct cpu_user_regs *cpu_regs); void handle_trap(void); +void trap_init(void); =20 #endif /* __ASSEMBLY__ */ =20 diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index 845d18d86f..1cae0e5ccc 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -3,6 +3,7 @@ =20 #include #include +#include =20 /* Xen stack for bringing up the first CPU. */ unsigned char __initdata cpu0_boot_stack[STACK_SIZE] @@ -25,6 +26,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id, =20 void __init noreturn cont_after_mmu_is_enabled(void) { + trap_init(); + early_printk("All set up\n"); =20 for ( ;; ) diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c index ea1012e83e..48c1059954 100644 --- a/xen/arch/riscv/traps.c +++ b/xen/arch/riscv/traps.c @@ -12,6 +12,31 @@ #include #include =20 +#define cast_to_bug_frame(addr) \ + (const struct bug_frame *)(addr) + +/* + * Initialize the trap handling. + * + * The function is called after MMU is enabled. + */ +void trap_init(void) +{ + /* + * When the MMU is off, addr varialbe will be a physical address other= wise + * it would be a virtual address. + * + * It will work fine as: + * - access to addr is PC-relative. + * - -nopie is used. -nopie really suppresses the compiler emitting + * code going through .got (which then indeed would mean using abso= lute + * addresses). + */ + 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.40.1 From nobody Mon May 6 05:10:59 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=1685362435; cv=none; d=zohomail.com; s=zohoarc; b=aUufVhFnsy6ABQMi6XfIWaU9Rk9tW4YkdR//9S55rnQHGqRH+OADmRuZOgxxCak3itRjTp36S10zJePwlOnJ6e8MhgHSuMushlWXvA6tkGcAJ0fCYsyP8381twEcTvAzSqQWHlD72er3rfraCJi9DIuQHVnsVVEZZ64YPSxqBOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685362435; 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=IGRAwgV1/X9tXgdqrBZ2V9h6YU+/IZLXtXO6lnBKNgc=; b=buzvwiiPpn+iQuzlKXfZYqcsgWreu2ITVjg/1EO7o1q6i1XBa/3RRg+JH6GO5ulJRLIOAsbcCt+RulZKzux3VQxZsXAVkVdOShM9OSQz5MSzfwIJOnpVkHZCWuIf92v0SCzAzOtow8yPp8WWLAce2j7aHvhZbciIXxBti38RmjI= 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 1685362435076898.4070230268451; Mon, 29 May 2023 05:13:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.540608.842498 (Exim 4.92) (envelope-from ) id 1q3bkh-0006L2-Hp; Mon, 29 May 2023 12:13:31 +0000 Received: by outflank-mailman (output) from mailman id 540608.842498; Mon, 29 May 2023 12:13: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 1q3bkh-0006Ju-CV; Mon, 29 May 2023 12:13:31 +0000 Received: by outflank-mailman (input) for mailman id 540608; Mon, 29 May 2023 12:13:30 +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 1q3bkg-0005DI-95 for xen-devel@lists.xenproject.org; Mon, 29 May 2023 12:13:30 +0000 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [2a00:1450:4864:20::22a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 38235dff-fe1a-11ed-8611-37d641c3527e; Mon, 29 May 2023 14:13:28 +0200 (CEST) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2af2e1725bdso39959611fa.0 for ; Mon, 29 May 2023 05:13:28 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id z14-20020a2e964e000000b002ac87c15fd4sm2427762ljh.95.2023.05.29.05.13.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 05:13: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: 38235dff-fe1a-11ed-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685362407; x=1687954407; 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=IGRAwgV1/X9tXgdqrBZ2V9h6YU+/IZLXtXO6lnBKNgc=; b=BhOu4Ae/aJWmaV/4Fkq+tg/eZ+FemcZMvELH4qD4sK+/f2TTmCvN+iKQoyDYXyn7Z4 2CVo8KZNghTDITtZePCZfONohTwxFzo11Q2I/samt/c/WRbwcAptcFfVSXSam50/Po16 Svt0qtGXhcq9zh0FxML00zdW2vQ5AewvqrQmLNmiud9J5ASW6G619kng2eI1FtP7+qhh fO5nHeGpy5o/q7sXMANx+1jLrLPONUyKTcItWAfItQwDX4z9gsMnlBHLyR1C6lfgyPi8 T+BWqcIFb3RziKoFTyaTn/+C/t9DXdTq5ccyqMIPLtztxGzUBXEkYJdxToCbj7A62L9u XVaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685362407; x=1687954407; 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=IGRAwgV1/X9tXgdqrBZ2V9h6YU+/IZLXtXO6lnBKNgc=; b=GKHTaygzvNhYjm85Lhoocl2Od8LptQObhkboTrBsmXPjaZ/pa4z/Y/p9dz2fKwPQMw 3HzjSM/WKxgyKHNgXe4DqF703KrTqqd0GdAoazbRNRIgdUTSBNZuXd8ktlN58xafNQNo M7kY+ZaSs+1inkSflMOxmgh7Y4e/s2LLZOjzwmYWo8F688zAss5XtKMf0DqePFZVqX/i v6C/8XSOC76/H5n/TK1MrAiFYq9RU70UUpbTucHUHt2wMDLlTCeIW9pBJzZHxIiwgWSb FCywEzjnwy9Kmnm5wNjO3TXETuhKm5hIzaUlVVbn2Na/1zL6/DsJcTvdOEMnb8fKys7e d0mw== X-Gm-Message-State: AC+VfDwqySRO2SEyl8z630gNRiazV+H/50SF3dxe0LhFFHMPiyhsfI4R OxdqN3JhphU//Bw5fMZvjBMcP/FTqjQ= X-Google-Smtp-Source: ACHHUZ4X24KzltwWEPBY4ezedLUOWadfqfw7Wb+VGCa/0rc3MsIxgXlvFdTfbAFC+17nv9jiuAbTFw== X-Received: by 2002:a05:651c:c2:b0:2a7:7493:9966 with SMTP id 2-20020a05651c00c200b002a774939966mr3195466ljr.24.1685362407086; Mon, 29 May 2023 05:13:27 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Julien Grall , Andrew Cooper , Stefano Stabellini , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v6 5/6] xen/riscv: introduce an implementation of macros from Date: Mon, 29 May 2023 15:13:18 +0300 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1685362436894100002 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 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 | 28 +++++++ xen/arch/riscv/traps.c | 129 +++++++++++++++++++++++++++++++ xen/arch/riscv/xen.lds.S | 10 +++ 3 files changed, 167 insertions(+) diff --git a/xen/arch/riscv/include/asm/bug.h b/xen/arch/riscv/include/asm/= bug.h index e8b1e40823..bf3194443f 100644 --- a/xen/arch/riscv/include/asm/bug.h +++ b/xen/arch/riscv/include/asm/bug.h @@ -7,4 +7,32 @@ #ifndef _ASM_RISCV_BUG_H #define _ASM_RISCV_BUG_H =20 +#ifndef __ASSEMBLY__ + +#define BUG_INSTR "ebreak" + +/* + * The base instruction set has a fixed length of 32-bit naturally aligned + * instructions. + * + * There are extensions of variable length ( where each instruction can be + * any number of 16-bit parcels in length ) but they aren't used in Xen + * and Linux kernel ( where these definitions were taken from ). + * + * Compressed ISA is used now where the instruction length is 16 bit and + * 'ebreak' instruction, in this case, can be either 16 or 32 bit ( + * depending on if compressed ISA is used or not ) + */ +#define INSN_LENGTH_MASK _UL(0x3) +#define INSN_LENGTH_32 _UL(0x3) + +#define BUG_INSN_32 _UL(0x00100073) /* ebreak */ +#define BUG_INSN_16 _UL(0x9002) /* c.ebreak */ +#define COMPRESSED_INSN_MASK _UL(0xffff) + +#define GET_INSN_LENGTH(insn) \ + (((insn) & INSN_LENGTH_MASK) =3D=3D INSN_LENGTH_32 ? 4 : 2) \ + +#endif /* !__ASSEMBLY__ */ + #endif /* _ASM_RISCV_BUG_H */ diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c index 48c1059954..535fb058e1 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 @@ -114,7 +116,134 @@ 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: change early_printk's function to early_printk with format + * when s(n)printf() will be added. + * + * Probably the TODO won't be needed as generic do_bug_frame() + * has been introduced and current implementation will be replaced + * with generic one when panic(), printk() and find_text_region() + * (virtual memory?) will be ready/merged + */ +int do_bug_frame(const struct cpu_user_regs *regs, vaddr_t pc) +{ + const struct bug_frame *start, *end; + const struct bug_frame *bug =3D NULL; + unsigned int id =3D 0; + const char *filename, *predicate; + int lineno; + + static const struct bug_frame* bug_frames[] =3D { + &__start_bug_frames[0], + &__stop_bug_frames_0[0], + &__stop_bug_frames_1[0], + &__stop_bug_frames_2[0], + &__stop_bug_frames_3[0], + }; + + for ( id =3D 0; id < BUGFRAME_NR; id++ ) + { + start =3D cast_to_bug_frame(bug_frames[id]); + end =3D cast_to_bug_frame(bug_frames[id + 1]); + + while ( start !=3D end ) + { + if ( (vaddr_t)bug_loc(start) =3D=3D pc ) + { + bug =3D start; + goto found; + } + + start++; + } + } + + found: + if ( bug =3D=3D NULL ) + return -ENOENT; + + if ( id =3D=3D BUGFRAME_run_fn ) + { + void (*fn)(const struct cpu_user_regs *) =3D bug_ptr(bug); + + fn(regs); + + goto end; + } + + /* WARN, BUG or ASSERT: decode the filename pointer and line number. */ + filename =3D bug_ptr(bug); + lineno =3D bug_line(bug); + + switch ( id ) + { + case BUGFRAME_warn: + 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; +} + +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 df71d31e17..0412493911 100644 --- a/xen/arch/riscv/xen.lds.S +++ b/xen/arch/riscv/xen.lds.S @@ -40,6 +40,16 @@ SECTIONS . =3D ALIGN(PAGE_SIZE); .rodata : { _srodata =3D .; /* Read-only data */ + /* Bug frames table */ + __start_bug_frames =3D .; + *(.bug_frames.0) + __stop_bug_frames_0 =3D .; + *(.bug_frames.1) + __stop_bug_frames_1 =3D .; + *(.bug_frames.2) + __stop_bug_frames_2 =3D .; + *(.bug_frames.3) + __stop_bug_frames_3 =3D .; *(.rodata) *(.rodata.*) *(.data.rel.ro) --=20 2.40.1 From nobody Mon May 6 05:10:59 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=1685362439; cv=none; d=zohomail.com; s=zohoarc; b=HHsSz7eNK9p8h0Fm60qqT65y1EUQTk6Sic5sTJi1aH5uf58jZrdZm3WB2T6hiunklePpcTqgsT94s3RWzSkhCGSlTxuTNN2vlg8hIut/JagEgTSPphSal5bzGwUOFmsYH0NmepUuDCeOaTf0K2olhO5FC9G47lTxGHj40r8pv2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685362439; 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=0YD5229mDIwkWy00dCe850+V9AEq/Mk9/bgvE344cjU=; b=dgPYhSMX1663ryMrTPAer5feqJLqcSNAIY/aH3l2KKJqwCi2s9i8SGt35t2PLjX3iYrzoc5LQUm4fhFxIu6GjZG40eAThi056h9ZYGkJRDioTNeoH//0nl1rwYp6aqYHtTbq+BW0riaRIqch2ZegFhhosSsn38BFd7jMoMBRIWo= 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 1685362439232398.5549894024699; Mon, 29 May 2023 05:13:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.540609.842510 (Exim 4.92) (envelope-from ) id 1q3bki-0006iB-S0; Mon, 29 May 2023 12:13:32 +0000 Received: by outflank-mailman (output) from mailman id 540609.842510; Mon, 29 May 2023 12:13:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q3bki-0006hQ-Mi; Mon, 29 May 2023 12:13:32 +0000 Received: by outflank-mailman (input) for mailman id 540609; Mon, 29 May 2023 12:13: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 1q3bkh-0005DI-6A for xen-devel@lists.xenproject.org; Mon, 29 May 2023 12:13:31 +0000 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [2a00:1450:4864:20::236]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 388e07b9-fe1a-11ed-8611-37d641c3527e; Mon, 29 May 2023 14:13:29 +0200 (CEST) Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2af2451b3f1so33742581fa.2 for ; Mon, 29 May 2023 05:13:29 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id z14-20020a2e964e000000b002ac87c15fd4sm2427762ljh.95.2023.05.29.05.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 05:13: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: 388e07b9-fe1a-11ed-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685362408; x=1687954408; 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=0YD5229mDIwkWy00dCe850+V9AEq/Mk9/bgvE344cjU=; b=TpzCdOknut6VDyJFWFVTwZjazt6GcrLBoZXZ77wvjfK4aVJ5kE1OhaT/+bJRKu25lt bdw4Nb3uqgPY83iObryh3p/gGP4Os9mAGLnnl5ervnCbr6/qJRUG1t/N4yc8itMRwU4Q Lj7wRdGPYIG1TBcvsjxpiZz1Z5WZ/SLmVfiiBtgEls4/1P3+aMC3fTp9bRw28egIj0Jz 9V5iEcUY8G1zFevbcjIOqg98oPWPndMJwFpb0wNe+Mchw1ozKddBN4xW+3T25DkjaWkT s7C3vlqEE3n5b9YpR85vs4yrfFLXk39ReBBckDHC51g05h3khQjs6sB1mrr9BFhte+Ut PIgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685362408; x=1687954408; 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=0YD5229mDIwkWy00dCe850+V9AEq/Mk9/bgvE344cjU=; b=dm7sjlYwyF25vm7D/+SlDze8+NkcSGpZNNwZXxlWnx5USuA7gaDfS9dCrxHzArw4CJ 3qlbz4rCNoPbibzaRRyOswgnzr9VomVzj1Ft/qAB6cnBO25nUNzq4NEmLSnd1RALu8aW gBvmSMLPb5xYqRo2Kpfu4r1+vLppb62WB51W/ZWRGWfyeGYxW4gOP3RWHgQDcU/+2o9k kiyB60B7Aq7cf/bHjN6l+0wzzkOQ9b6qJtQUKdBbAO2CUxB2QLi19RsrMkh0lgkVinor 2qQJsRA8DCtD+CGSRmHvNVpTjn2C88sda37bHFCiHZ8q+b3zu7Yg2HAsjHlbj7aVQbd6 h3Kg== X-Gm-Message-State: AC+VfDyocQaQ8DLuFWSIusjSK0PjD6XUQ8pyZllhC0lfTAlvx9bYkua7 hYOL/S40GvPbBeqlF3/q1jqqT2KdIhE= X-Google-Smtp-Source: ACHHUZ7qWlQ0izumLBrxWGN4a1dMw2W/W9ZTX1VBQsZPtZd6SyEXM+BC9wFxToGEYSGFFfxny5MvVA== X-Received: by 2002:a2e:2416:0:b0:2a8:ad36:f8ca with SMTP id k22-20020a2e2416000000b002a8ad36f8camr4249022ljk.14.1685362408351; Mon, 29 May 2023 05:13:28 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Julien Grall , Andrew Cooper , Stefano Stabellini , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v6 6/6] xen/riscv: test basic handling stuff Date: Mon, 29 May 2023 15:13:19 +0300 Message-Id: <90e4f333ded1a18e5c0e0b389580ed5d25e0272a.1685359848.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1685362440804100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Oleksii Kurochko Acked-by: Alistair Francis --- 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 1cae0e5ccc..481d88249d 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -1,3 +1,4 @@ +#include #include #include =20 @@ -9,6 +10,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) { @@ -28,6 +43,8 @@ void __init noreturn cont_after_mmu_is_enabled(void) { trap_init(); =20 + test_macros_from_bug_h(); + early_printk("All set up\n"); =20 for ( ;; ) --=20 2.40.1