From nobody Tue Oct 15 16:14:24 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=1691764407; cv=none; d=zohomail.com; s=zohoarc; b=FlQ5C68uUhlARWuWTrPJegz26QJxTZID1bypqNDARapQR+Vd34z9xyhnwySGDV38xxjtWBGP3vueUFs5VuACbk1CVDy36se5Lr58pkG70K90qA1K8IGCGtW0gLTD4Ibj1o2EKb43buoDa3EF/13zrPcil7COewZna4ImB6GSPJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691764407; 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=m8jHaMKqz0HfbXk2J9EkqrL9mGdPZo33L8RyKFfrtek=; b=O3v7FFzni7qfrpV954cqc9ca2eCzGtlqwHZBQgpnWqeJCr3wHtDi7035qaB1FFZTdi2ZDv0MeZWKFwwOpVHK3DHCS7pRLREhgN7khSnnZ2XF3X0lkr92onB0heejV2N9eQJwl0Y/rSUbk7GKGf2QoOIlNCXlj91puTVnmQdnU2g= 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 1691764407664567.476327177314; Fri, 11 Aug 2023 07:33:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.582503.912303 (Exim 4.92) (envelope-from ) id 1qUTCH-00050n-8U; Fri, 11 Aug 2023 14:33:01 +0000 Received: by outflank-mailman (output) from mailman id 582503.912303; Fri, 11 Aug 2023 14:33:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qUTCH-00050g-5t; Fri, 11 Aug 2023 14:33:01 +0000 Received: by outflank-mailman (input) for mailman id 582503; Fri, 11 Aug 2023 14:33:00 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qUTCF-00049h-V0 for xen-devel@lists.xenproject.org; Fri, 11 Aug 2023 14:33:00 +0000 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [2a00:1450:4864:20::132]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f8364630-3853-11ee-b284-6b7b168915f2; Fri, 11 Aug 2023 16:32:59 +0200 (CEST) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4fe28e4671dso3281410e87.0 for ; Fri, 11 Aug 2023 07:32:59 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id q2-20020ac25a02000000b004fe07f06337sm753453lfn.53.2023.08.11.07.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 07:32:58 -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: f8364630-3853-11ee-b284-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691764379; x=1692369179; 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=m8jHaMKqz0HfbXk2J9EkqrL9mGdPZo33L8RyKFfrtek=; b=fdlqZrbaH0gKi00KzPG9s/IrK3X7nR8PjPZvg2UWwNEUsT70z2RhysrSdXrWXwHzw+ zLVxLb9JY6UBPReG8thCEa7lNhoAy1cwBsWda5bT2ggPkTcttMeAY0bUfmxhdU70kMnt Y96CV9RZeCjJbjbbWxI96Oh5RYi5Z8kITenQUWJkWhnqTUZefiZ6C4InM/3plcDSns8H VkJzkTAW/k0PTT4hul0ACb3wmmAVQd9O6E8rF/w4JkrxOy+B9Y/jgUQyEg6gY9eO7SvH RniFpvyyR2p9g3jBiur901Woy5Vpm7YiomceKi3cCa3PvmjQKwGzrPQWl/vAd8WbBygc iprg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691764379; x=1692369179; 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=m8jHaMKqz0HfbXk2J9EkqrL9mGdPZo33L8RyKFfrtek=; b=W/Lt7dxdGCHvdjra5erdt07ycBdwHJZj3kQSDltbluWXH/Nbut6zgG+BGAwgx8M0I0 ZJdCxQfaSq4qRfgzpYLiEQc+0xMCt7mNcnbaAPrgOKdbbd4LKv1FfVBYkUDz4FIm/WpA KjEDf55hfrlmEjoWdiXrgNw+XRlEeU1Jslx7DLpfMY0V29bGzhLsmkA1QmrfEznHdNbN FWUsTcS5cGIIQ1tCv4iPQD7BfmH1OyOdxFAiZ+naEr2BPxO6vSf9+F5fuvNQNFw96ct8 63foEpPSaXSXOfhd6AujIJH7E2+dX3ThOOIA0AKwuNglyinkMrFnyTycWY0zKyACQlUd +pKg== X-Gm-Message-State: AOJu0YxTRPnVxaWv11B7V7NlOdJfW7kZclmNpxZwMn04PHLOuY7jRl5c sSqtBv08cHk4shmb2cwaZzifIsafKnU= X-Google-Smtp-Source: AGHT+IF1Q8q72UIc0xVO9V0e4F5v7jMaTT86mWd5rfbSM2zcPNlU9v2BoTXjhKKgMx9lbGjS/2wKeA== X-Received: by 2002:a19:9148:0:b0:4fb:978e:95b8 with SMTP id y8-20020a199148000000b004fb978e95b8mr1523531lfj.59.1691764378388; Fri, 11 Aug 2023 07:32:58 -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 v8 1/6] xen/riscv: introduce temporary printk stuff Date: Fri, 11 Aug 2023 17:32:50 +0300 Message-ID: <4d986a1083f35ab66eba6ffde964af3b4453b216.1691763757.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: 1691764409084100013 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 Acked-by: Alistair Francis --- Changes in V8: - only rebase was done. --- 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 Tue Oct 15 16:14:24 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=1691764410; cv=none; d=zohomail.com; s=zohoarc; b=ZMaPwH9zG0kMCSGWn+iJt/aPIqyRJWHfLnOMpWpgBynnUYx1R/TdGdZrJVPhs26k23GgUQry/ws2/gyAJTWJsTo4y41DNGc0yy0DgLn8f1A13Ev3dOPIdwCCUDC2zAvDaqaHOH83pJvFxQMgDeUA1XVusud92ANg8ulooCz7yNM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691764410; 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=2/OtmtgHs6hiIE3b0R04W2tm1wiLCCAEvdGukHjFIgw=; b=VbbDjQy8zzVhU5cTfZ45yEMc012qwGTwaW+EcYEKQNX7iChBZhGFYPw7x+MIucEFQ/+tUQsAXSu0jNclFVmkeDflc5/hw1uVtcDcc+XKE+L1h/JpDVr1LV8V6mhQrsBgHeet6/EafiYoRyT0nIuidM6JWr3z8KHVSBEilAidZis= 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 1691764410581867.9969922572567; Fri, 11 Aug 2023 07:33:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.582505.912318 (Exim 4.92) (envelope-from ) id 1qUTCI-0005J9-Qk; Fri, 11 Aug 2023 14:33:02 +0000 Received: by outflank-mailman (output) from mailman id 582505.912318; Fri, 11 Aug 2023 14:33:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qUTCI-0005IA-Lq; Fri, 11 Aug 2023 14:33:02 +0000 Received: by outflank-mailman (input) for mailman id 582505; Fri, 11 Aug 2023 14:33:01 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qUTCG-00049h-VG for xen-devel@lists.xenproject.org; Fri, 11 Aug 2023 14:33:00 +0000 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [2a00:1450:4864:20::132]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f884fb49-3853-11ee-b284-6b7b168915f2; Fri, 11 Aug 2023 16:32:59 +0200 (CEST) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4fe11652b64so3245174e87.0 for ; Fri, 11 Aug 2023 07:32:59 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id q2-20020ac25a02000000b004fe07f06337sm753453lfn.53.2023.08.11.07.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 07:32:58 -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: f884fb49-3853-11ee-b284-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691764379; x=1692369179; 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=2/OtmtgHs6hiIE3b0R04W2tm1wiLCCAEvdGukHjFIgw=; b=qlkroSIbIq8LkBTjrCWeTTE5BVIoP3g6BRTkQnk9Td3MXWG4pZGJTohu074BaP2cRT ybYxGeoiTBMQpnSGWZvoUS15M3TvKOoE47GQQbhu0QKrpsyGMie3c/lVZJNltAXrxRN/ xUfpm3RKgEEy5ggyTRu1FsEO6V+8ulen6DS0bWh11GOoKz0h7um9t9bJVSakxDybJhvH ws/rcXdTZb3wgro0mBX8h/jCIj9tFBLSoC4SJaqkCD8MXRQQ/jkwWnVeMuRim/enL2/y yXcxUeC5MVblYy+D8xEs8SXugGss18wdnBq9yIT5iE33BUi0onS7AAgbD+6Ei80hiC0O LseQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691764379; x=1692369179; 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=2/OtmtgHs6hiIE3b0R04W2tm1wiLCCAEvdGukHjFIgw=; b=TBoLXpnEIsPLpGWzG/kPJAh1EIpITErqA/cuksWMM8VknDKD6PYtDNJ3IvDNPtVuVM Dz+nBiIa1+GRLkBsu5V2QneKx6OV6Lkk6QyYsXlAQGO1U/s96hzuQdckgtHOzavb7sW+ nHdT/fkvom879vcMQXuFjtc2eXnyKpR9bXHejN7pGziTeAi8yp3nNBeQaZ49N/Sj5jkN sfdCGMtWENfLyeV2JlR+WNamn+nGqvy0GB6l1PIpoyUp82NkmEJ58n1anHNRjfa8Wagg RyByGoHy87o6fSaVq7nCBqmpDk5TiYUwm38JrJIeVSJPLiwxgberFthIYioP0xi9nrjU 651w== X-Gm-Message-State: AOJu0Yz2Po+wKeLh3FiYFOwSYmRNo1wwiJHxKUyHrsoGRa1a98MNzb2f 4aXnDXxViN9GhSBMR7jxDvQeeNCka3A= X-Google-Smtp-Source: AGHT+IHduLYw9QGKUkNhITZuwy+eFdqGXS19EtKxUmx23upKJLTfpHuFHdlLRkXfdeY3zs5nMz5wCA== X-Received: by 2002:a05:6512:695:b0:4fe:711:2931 with SMTP id t21-20020a056512069500b004fe07112931mr2288829lfe.22.1691764378985; Fri, 11 Aug 2023 07:32:58 -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 v8 2/6] xen/riscv: introduce Date: Fri, 11 Aug 2023 17:32:51 +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: 1691764411378100017 Content-Type: text/plain; charset="utf-8" Signed-off-by: Oleksii Kurochko Reviewed-by: Alistair Francis --- Changes in V8: - new patch. It was introduced instead of dummy asm/bug.h introduction. --- xen/arch/riscv/include/asm/bug.h | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 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..f5ff96140f --- /dev/null +++ b/xen/arch/riscv/include/asm/bug.h @@ -0,0 +1,37 @@ +/* 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 + +#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 */ --=20 2.41.0 From nobody Tue Oct 15 16:14:24 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=1691764404; cv=none; d=zohomail.com; s=zohoarc; b=lLTYJjCkK51YCKi2YvDipQ/8KtWZwK7JLjDsXd6wNzaDR+y8dt4c2lx/c0wBSJcnFaJzLDDWDi77lpcmBQkHMq246OifyHkHe9/AJcPY+JHJ3aGJdxFDAKqHJ05UTlmC4EsBMA59VW/xqqPv6uil8Q5rXUUHR9tkoPJDNog3aFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691764404; 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=yUcu2qxnQUPl60o9J+2YFJhCdL460tY2JEgoa99A+hs=; b=F/lxh5wamx0KpZp6wI0TkKCNVJOwoZ53k5EodtaqrQXTM/01cjy4awNlDBVs12FhWrTjz6sMG9Zm0LkBV22gmhkliRQJwQE/Bfhm/C6qzOSgWM4/tvRLOsAvya+4lWtk/5hDFbXusAUi2OO4M9/cuNgWCrsyt8BqQPZ7nRQDniY= 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 1691764404842141.04934199240904; Fri, 11 Aug 2023 07:33:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.582506.912325 (Exim 4.92) (envelope-from ) id 1qUTCJ-0005WI-CQ; Fri, 11 Aug 2023 14:33:03 +0000 Received: by outflank-mailman (output) from mailman id 582506.912325; Fri, 11 Aug 2023 14:33:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qUTCJ-0005Sz-5f; Fri, 11 Aug 2023 14:33:03 +0000 Received: by outflank-mailman (input) for mailman id 582506; Fri, 11 Aug 2023 14:33:02 +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 1qUTCI-0004v5-5k for xen-devel@lists.xenproject.org; Fri, 11 Aug 2023 14:33:02 +0000 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [2a00:1450:4864:20::12d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f88d3af2-3853-11ee-8613-37d641c3527e; Fri, 11 Aug 2023 16:32:59 +0200 (CEST) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4fe27849e6aso3261494e87.1 for ; Fri, 11 Aug 2023 07:33:00 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id q2-20020ac25a02000000b004fe07f06337sm753453lfn.53.2023.08.11.07.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 07:32:59 -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: f88d3af2-3853-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691764380; x=1692369180; 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=yUcu2qxnQUPl60o9J+2YFJhCdL460tY2JEgoa99A+hs=; b=kpmGNC0rGdvqjEnckQmthWRufVqIFbkXrlV1X8NxCthx0hq5FHxZabpthDdNBYljYB BE2b4op30+CS9s6+msN5L4Qs85H43tMFlRvdX5UQLrX3ABo9B8bKQJczO1phoEw+gH1G yupgxEROaEzYvhy84SMLfwOT9EBlu84M11LSFqq3c6sUDMqUOv+faXSXcHhrAcxMpftL CVdPVTdvKjIflbyCY2LRVGueomS7UjvHGpZdY+IS7k36s1fwqEY0h3XL1QKkkwkJ0b7Z YzMI8FBjed9DITZiNZ1wzFJI9dKDC20mlpAYoY9GenR0TzTuOymF+DF/vMRd9QJ0MdbU 9D0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691764380; x=1692369180; 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=yUcu2qxnQUPl60o9J+2YFJhCdL460tY2JEgoa99A+hs=; b=P24XaqRIDpVqe70esv2MgjtJQjkvl8joO3NUpVJQ/ihXF/CFWpQmDNCYiH/BBvjWXC KEAc4DPdoadtKHgPEjOBzRKhhLjLNFfFZjPd6/yxJ8BtnlIiIUSnVgMfNE87FVI3aZvz XoGdhU8Ml+2irn6IHcpz8qa2X7VUqvjSYx0qcdUNPvBT1bDbSn5bY5JyCuYVEYfce0mD BlDroRY6eI/FXrI/kbMTWS8hb493bp7M/Zq3w/FqAhlYr19XJQ5uHMSe9fO22xwdgYwu wOJSKuZC9bNQpJbk2jQTUQ4cTMJdJe0DLQ0a5swew5BWsCechGI/1jQo7MLIUpglneA8 chDw== X-Gm-Message-State: AOJu0YyV7qUVluFU13ezcSQCXWdL1UfDuLBu8JpP/w+eFjU2IL/LMgrb 7RiISImK2Ffte92fUNaQ/ZVJOnY6Q+o= X-Google-Smtp-Source: AGHT+IG3DDqQ/ltjvGgtw/Whl2OwvjMojKAXkZMmzPqYsbf0lTo9FGVz+/HNzm7xePWRhZRr93Tuig== X-Received: by 2002:ac2:5205:0:b0:4fe:e8f:e216 with SMTP id a5-20020ac25205000000b004fe0e8fe216mr1486152lfl.39.1691764379572; Fri, 11 Aug 2023 07:32:59 -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 v8 3/6] xen/riscv: introduce decode_cause() stuff Date: Fri, 11 Aug 2023 17:32:52 +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: 1691764407031100007 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 V8: - fix typo in return string from decode_reserved_interrupt_cause - add Acked-by: Alistair Francis --- Changes in V7: - Nothing changed. Only rebase. --- Changes in V6: - Remove usage of LINK_TO_LOAD() due to the MMU being enabled first. - Change early_printk() to printk() --- Changes in V5: - Remove from riscv/traps/c as nothing would require inclusion. - decode_reserved_interrupt_cause(), decode_interrupt_cause(), decode_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..a2b63d579b 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 Tue Oct 15 16:14:24 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=1691764672; cv=none; d=zohomail.com; s=zohoarc; b=YyxLNgGBMUmcw5/sJUdfBm3370WzxNdJlEqa2Pn4PQf0rxhklpgRDZvMedIIpamUkU4HzXs4SuZf2Lbxj94CjI60Ljnd3alcTo31MfYM7XNTv0JX8dLgXGMLFgkiODTUKlRl2a4KBwjigrKcxNVqFiht+VVgvSPdnujIIzTAKW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691764672; 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=Nt7soPoblldHqrs8iwJbMnbI3th3kHrjMiBeC6m3Zr4=; b=dmLw1qTS7JkwMKfDCnroS8yq05+wHWpEXXQQth41FtHuIX6OcsY1StQaQzrRHL+6TLU3rxBpcowgJS/LEVgbPmyDToo5h7spLnUYP/GcBHK0SscO2mfwz+1cFb7pmIqCwz/UpSQobZibaNA0ObeGxZv3qJXWnx+JCQsNgvuiivI= 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 1691764672787911.2926341559381; Fri, 11 Aug 2023 07:37:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.582538.912353 (Exim 4.92) (envelope-from ) id 1qUTGY-00086z-3Q; Fri, 11 Aug 2023 14:37:26 +0000 Received: by outflank-mailman (output) from mailman id 582538.912353; Fri, 11 Aug 2023 14:37:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qUTGY-00086s-0j; Fri, 11 Aug 2023 14:37:26 +0000 Received: by outflank-mailman (input) for mailman id 582538; Fri, 11 Aug 2023 14:37:23 +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 1qUTCH-00049h-VT for xen-devel@lists.xenproject.org; Fri, 11 Aug 2023 14:33:01 +0000 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [2a00:1450:4864:20::12c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f9208269-3853-11ee-b284-6b7b168915f2; Fri, 11 Aug 2023 16:33:00 +0200 (CEST) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-4fe1489ced6so3309330e87.0 for ; Fri, 11 Aug 2023 07:33:00 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id q2-20020ac25a02000000b004fe07f06337sm753453lfn.53.2023.08.11.07.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 07:32:59 -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: f9208269-3853-11ee-b284-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691764380; x=1692369180; 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=Nt7soPoblldHqrs8iwJbMnbI3th3kHrjMiBeC6m3Zr4=; b=cMPfu9KZPOhHwuYJe5Ic3ZCC/qBC+8k5RNGZzZ0LNtY1oFu0pi7gqF/m7Mfrt6UpOk 7rPXfc2BpnF7lwRF7OdnspLelDtF4YkDNBPRUY8zL78BhIjKNK1GHGg0B2zuesgCSojb EUEfWmlES0cKFY/W7HZU++baBk4b/PzDepRR/zTHVBQe6xicajFLpu/ZEUZhV6UY5vKT DbJP8BTX3k/Uti5DFwg432RKO+4CsBtiNQZaWNO5TN1nuj3hekiGB5jHn/ooXH2SWyUd 48IH54Ds7M1IZH/5MqsQdjDB79qhl/1lZntlgoYsxe8yB1kv8AnWRk/TpEPhpznadYpo G5jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691764380; x=1692369180; 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=Nt7soPoblldHqrs8iwJbMnbI3th3kHrjMiBeC6m3Zr4=; b=FZ/Y6Xs1jUoiZzI+EDymXfKQceLg5Y+meAW+IpTONUAap6G8g2VE8IFSEwUS56JHZ2 hsmUNfFpw3Z69yFaKXyDlnt+27JGSr4jrdSzculmAP1XJLESY54TGrUuwni48vnJNjsM +cOWS7BSAyiVOOENzK2MXBvmPWKrdUAkNGuzuRLWOshe1XMS18ntDTIDXulZBMFSSSlT 2nnf3jt2o4j1RZKDps499ZsJV/qiLJddgc8qBp/ynIItrw2J3dqZ5tbSR7b1MBYtfEiw gRIChDtovIBNNTnXtyw8RT8bN7s9Bn2QZcCDKqFSbD5tHKs7JL2RTfIqK3kF49V3kHBM oS4Q== X-Gm-Message-State: AOJu0Yw5QjeKnMVlIv8C2cr/0KfC6tDvma2UfjhryG1LO2F31u+fIF+P xMEfOTVCfKvOnF+nWUlUca2hrVt0sb0= X-Google-Smtp-Source: AGHT+IFLritZVFHFNIyx1qPpf3U57eldQaFfs/SVN+5U80NMv5bcu2V+pM3HV3sGy1NKrD/z2JjUyw== X-Received: by 2002:a05:6512:2249:b0:4fb:8eec:ce49 with SMTP id i9-20020a056512224900b004fb8eecce49mr1870456lfu.31.1691764380132; Fri, 11 Aug 2023 07:33:00 -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 v8 4/6] xen/riscv: introduce trap_init() Date: Fri, 11 Aug 2023 17:32:53 +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: 1691764673571100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Oleksii Kurochko Reviewed-by: Alistair Francis --- Changes in V8: - nothing changed. only rebase was done. --- Changes in V7: - #define cast_to_bug_frame(addr) ((const struct bug_frame *)(addr)). - remove unnecessary comments in trap_init() function. --- Changes in V6: - trap_init() is now called after enabling the MMU. - Add additional explanatory comments. --- Changes in V5: - Nothing changed --- Changes in V4: - Nothing changed --- Changes in V3: - Nothing changed --- Changes in V2: - Rename setup_trap_handler() to trap_init(). - Add Reviewed-by to the commit message. --- xen/arch/riscv/include/asm/traps.h | 1 + xen/arch/riscv/setup.c | 3 +++ xen/arch/riscv/traps.c | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/xen/arch/riscv/include/asm/traps.h b/xen/arch/riscv/include/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 a2b63d579b..c1175668b6 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 Tue Oct 15 16:14:24 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=1691764676; cv=none; d=zohomail.com; s=zohoarc; b=EpvLVQ1G9rIE75+Zp7IMwtQtJCLHVN15REKSOQpCT4dliHQhGzTXWr0rZ99DNm0QUqsVEdOFmzUunF1Q073kG1FvP46MQPG1HjQtYw+HTUbXhcxu+lP+einLl8tHxirVZgT+dectcex9rGy/Zh/QCx2d5UPLTVjXfaU++aLt5JY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691764676; 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=WxemZPSrKphIU1DOnZWltN7srrgDFj6wafS5aBn4TaY=; b=O0JnOz6i+SE+Tw4YM3x5S3MMTzmukfXboPof6ofM5n93dRnm/6bUImZGFAfiiXd68GbjYdfKHgtIjkIZhmck4z6bP3swtA6t7RHT54I5YYZtTqMGm4uEbPyZqwezteng5EtlCI0Y55ZQLLPHrBH7w+33NlJ+3qE1nSyLhoYONno= 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 1691764676653910.8641753169553; Fri, 11 Aug 2023 07:37:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.582539.912358 (Exim 4.92) (envelope-from ) id 1qUTGY-00089U-CS; Fri, 11 Aug 2023 14:37:26 +0000 Received: by outflank-mailman (output) from mailman id 582539.912358; Fri, 11 Aug 2023 14:37:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qUTGY-00088x-7G; Fri, 11 Aug 2023 14:37:26 +0000 Received: by outflank-mailman (input) for mailman id 582539; Fri, 11 Aug 2023 14:37:24 +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 1qUTCJ-00049h-WA for xen-devel@lists.xenproject.org; Fri, 11 Aug 2023 14:33:04 +0000 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [2a00:1450:4864:20::131]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f9ca3bd4-3853-11ee-b284-6b7b168915f2; Fri, 11 Aug 2023 16:33:02 +0200 (CEST) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4fe216edaf7so3719472e87.0 for ; Fri, 11 Aug 2023 07:33:01 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id q2-20020ac25a02000000b004fe07f06337sm753453lfn.53.2023.08.11.07.33.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 07:33:00 -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: f9ca3bd4-3853-11ee-b284-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691764381; x=1692369181; 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=WxemZPSrKphIU1DOnZWltN7srrgDFj6wafS5aBn4TaY=; b=RledqS7a4a44XsG7EKTMY24d/SDPhktwyck2xu6KGzJ7wyApw2dfUkQd7Kryd3TO1/ a5TgrjPSpWXNbIEhgiP1MnemhYvo/Lr102dhbYyr9A6jTFWPOHyuRdA584aSCTQeEO1S 1MQiQeqq0GFpRj/dpFRe7uVBzXr0aVrIQYwmpfMTu/quwxag+61u6TDRZXrmLEhLJ/4I n4hVXqoug9eVGd6w20vIrfK4eroSNCicM04l5OCxpWrUD+EamEGvlA0JrpZaTFHCcUc7 C9Kfnct8VHop8wCVc69ObTkBuNfHeafbAXIxFe6eFzyLKYAj3i5DaE399QspFyDppNnq qCfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691764381; x=1692369181; 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=WxemZPSrKphIU1DOnZWltN7srrgDFj6wafS5aBn4TaY=; b=ft+g4b0aH+l074sNllTs/DVG/2admK8Pt3eGu3PhEIsAblkj/wP5AWaZwFs3TI7xX0 RMxMeelta3TfHaU01FiRlTp34ZuB6DSTdOL6EQqXjRhwlFUI8YrVjAOHR+Y/hdlE5bLF uuuHUz5XCFqifj1crin61aviR04x/xEDkN6jKyACQOsRIz4rhGF4v/9MMKFEcuu3/3U4 shE2+8MMUip7Sv2ySkxAny2UGKgLlD92djRXA7/uVHLx9U7oDwXl/xvAs10m9s6ApRTy GX3KhcqlfTE2d/tWieNlb/mxz6E7CWZs+WR07AS6hT9LSse33EoGDmMgFmVBX47+ccT3 m7wg== X-Gm-Message-State: AOJu0Yy4GMyHxyPDIVPOt+uBiv9qJ8A1Q8LQVysvunc9dN50Csy4YVX9 oVKCEDa9k1zB7Bk1QlIr/rTq98zotSw= X-Google-Smtp-Source: AGHT+IFdYvM9CDX0s6tuokZtE3ADXkxDijqkkbycTjKUe2GpoqCgYMO++xnf4wBPtEU2jr/fZOk7aA== X-Received: by 2002:a05:6512:3d8b:b0:4fd:d226:adcc with SMTP id k11-20020a0565123d8b00b004fdd226adccmr2129948lfv.21.1691764380992; Fri, 11 Aug 2023 07:33:00 -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 v8 5/6] xen/riscv: implement do_bug_frame() Date: Fri, 11 Aug 2023 17:32:54 +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: 1691764677425100001 Content-Type: text/plain; charset="utf-8" The patch introduces the temporary implementation of do_bug_frame(). When common code is merged, CONFIG_GENERIC_BUG_FRAME should be used instead. Signed-off-by: Oleksii Kurochko --- Changes in V8: - remove Pointless initializer of id. - make bug_frames[] array constant. - remove cast_to_bug_frame(addr). - rename is_valig_bugaddr to is_valid_bug_insn(). - add check that read_instr is used only on xen code - update the commit message. --- Changes in V7: - move to this patch the definition of cast_to_bug_frame() from the previo= us patch. - update the comment in bug.h. - update the comment above do_bug_frame(). - fix code style. - add comment to read_instr func. - add space for bug_frames in lds.S.=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/traps.c | 138 +++++++++++++++++++++++++++++++++++++++ xen/arch/riscv/xen.lds.S | 10 +++ 2 files changed, 148 insertions(+) diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c index c1175668b6..b096dce6c7 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 @@ -101,7 +103,143 @@ 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; + const char *filename, *predicate; + int lineno; + + static const struct bug_frame * const 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 bug_frames[id]; + end =3D 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_bug_insn(uint32_t insn) +{ + return insn =3D=3D BUG_INSN_32 || + (insn & COMPRESSED_INSN_MASK) =3D=3D BUG_INSN_16; +} + +/* There are no guests for now so the func has to return alwasys false */ +static inline bool guest_mode(void) +{ + return false; +} + +/* Should be used only on Xen code */ +static uint32_t read_instr(unsigned long pc) +{ + uint16_t instr16 =3D *(uint16_t *)pc; + + if ( guest_mode() ) + { + printk("%s should be called only on Xen code\n", __func__); + die(); + } + + if ( GET_INSN_LENGTH(instr16) =3D=3D 2 ) + return 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_bug_insn(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 Tue Oct 15 16:14:24 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=1691764413; cv=none; d=zohomail.com; s=zohoarc; b=bMlvr94vz8QDCiyiRApTe4UGoOfIZRPUhTwzqLh0iHEQweef6E2a5QqJEsmzl9Dk+mWNqx0SKVNNvnx85Arc77BVZHMAfR/phw210O2r2dpnj5dANOKn2/ZCQoQ5xqBH/hbzHKVhSGpiqD+a/WvdLIFrKZYCd3IV4AOt1moNA2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691764413; 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=jFpMwQTvtWnzo8KwJdfRA9hSdfLNtSc3JC0W+s/e69Y=; b=IthSp65Cz9S6neYCbUEStmA5e7L3hMCxpENs9lIpH4htyURJp6dt7oD5BtMgc+KZpgE0Rjb3GL2UHRofs0TkhBwPlHMYiDRbPnClajXLjaBzQ9Uf74sXYjQK9UIWZXbZjntP0ZnQWM+FNFNnnbBvwP2z6GVm5YE17FrpiEf6Owk= 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 1691764413696578.3016588066124; Fri, 11 Aug 2023 07:33:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.582507.912343 (Exim 4.92) (envelope-from ) id 1qUTCL-000646-HI; Fri, 11 Aug 2023 14:33:05 +0000 Received: by outflank-mailman (output) from mailman id 582507.912343; Fri, 11 Aug 2023 14:33:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qUTCL-00063x-EN; Fri, 11 Aug 2023 14:33:05 +0000 Received: by outflank-mailman (input) for mailman id 582507; Fri, 11 Aug 2023 14:33:04 +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 1qUTCJ-0004v5-Us for xen-devel@lists.xenproject.org; Fri, 11 Aug 2023 14:33:03 +0000 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [2a00:1450:4864:20::12e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f9bcacf7-3853-11ee-8613-37d641c3527e; Fri, 11 Aug 2023 16:33:01 +0200 (CEST) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-4fe4f5290daso3197740e87.1 for ; Fri, 11 Aug 2023 07:33:02 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id q2-20020ac25a02000000b004fe07f06337sm753453lfn.53.2023.08.11.07.33.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 07:33:01 -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: f9bcacf7-3853-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691764382; x=1692369182; 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=jFpMwQTvtWnzo8KwJdfRA9hSdfLNtSc3JC0W+s/e69Y=; b=P5p5421NCrEG8Ee6OjVvEtTzJqh/gZr4I11F/MVRGw8mylTa77oLnjMUivSurxOrm8 kT0ZVuSdvBJwvF2rlVH5af9eQ6yYJqSeBkz+3Icxk9m3BjRV7TtlfpwK0UDA9dxw5yIc e1tFzdOx1oHhkmGSKU82xA1qfYNZxO+Tl0zsLAEI1sPphlXMout0wEXYInSp9p+T8Z27 7WyStY3dW05+tRPeHp4HOB4YHsrb+OKa8n0GE2Gjwx7Gt2q10l6FBruaSaX+lv7RYyZe wUOZ6Zo2VUI/yD2PjkmRGLiTxVw7D48tdFcNLX/tYSQmKSC/vmK6s8gCJdtEqI2bXW2y 4eXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691764382; x=1692369182; 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=jFpMwQTvtWnzo8KwJdfRA9hSdfLNtSc3JC0W+s/e69Y=; b=DcB+yDbDSF5/7i012olUijniCxstOR83N6qLsGp4/0ZAXykwRSsY4jopPfRvZPYOJS E6KYX99MKW83jm5ynfASoaizA7tJR7hmthRMQ4Yt2A32mQCa3dQRtlxet1IEnVF7RW6X BRm9uIz/N7saEZwIaSdP59Q2eic2ihFA1aTsVWnCRRQe/xqd1SbEVOI+37Sri57XHwyy he40WxapkySc/PQ+oBCE6buQyPmHB6M4kGYJvw9O/vjBcRd7Mg1iDqqqchxeMmVO2yWq RU4e9qodURbrs57Sc8O/5x5ZE8g6zB1FwJHfhw52VbzAhKgXuKKHaA5fZxe+zQY1EqWj jQQg== X-Gm-Message-State: AOJu0YwRwZTjdaELR0clmiZed3dXjOS86yrWXOROCxBYia/ydVWmLaNE 7/06096xX6g5RJlftUX7lmNJD6VkT/Q= X-Google-Smtp-Source: AGHT+IG6Q6Ixn2L8rvE0G3xiM07jPib5otv7nMk8wxhac8f6YUd0iuw91E+NK5WgQy510PAzqLGYqw== X-Received: by 2002:a05:6512:3d1d:b0:4f9:607a:6508 with SMTP id d29-20020a0565123d1d00b004f9607a6508mr1707605lfv.50.1691764381583; Fri, 11 Aug 2023 07:33:01 -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 v8 6/6] xen/riscv: test basic handling stuff Date: Fri, 11 Aug 2023 17:32:55 +0300 Message-ID: <557ee932891edcfd189dfee006317094a9144f10.1691763757.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: 1691764415456100029 Content-Type: text/plain; charset="utf-8" Signed-off-by: Oleksii Kurochko Acked-by: Alistair Francis --- Changes in V8: - Nothing changed. Only rebase. --- Changes in V6: - Nothing changed. Only rebase. --- Changes in V6: - Nothing changed --- Changes in V5: - Nothing changed --- Changes in V4: - Add Acked-by: Alistair Francis --- Changes in V3: - Nothing changed --- Changes in V2: - Nothing changed --- xen/arch/riscv/setup.c | 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