From patchwork Thu Oct 26 14:31:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= X-Patchwork-Id: 13437615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D58AC25B48 for ; Thu, 26 Oct 2023 14:32:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JvbCqQWc6jUJlYhZ378fhMrJyHxJRQ4tJvCmfqO1BUI=; b=VXpUez1WNxO5dl 9NXdxg1n79R+IetlhR1dwkIcC4TyuKQGvipEeAAfWPUQMOfs1feWSbTvCgBbBNAZ9Pe+jZyBUq+6Z WAbIf9lXXJAixnC0nFDYw79Jfamxk2/r67wnHvZUrILw2yph/2y4HAHBWbQ84HboMYv4jKOcDBED1 Jyy+jP0TAjwO5IcXYE6CkiSCjGlcuzLkhmx5XJSsFVvzRPkbBZjgPsh4SP+d2+SaO/PyZqLUbZhjb eT//HiEbUK9ONrf0LAqYEQ1n+zGMVXB3968bkAngtVJ6LGa87XTm/NVt4kEsk+rVjF4/Y8tDSgziZ 6ZXnk8QZGxQ/e2ZPnFjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qw1Oh-00Ega1-0Q; Thu, 26 Oct 2023 14:31:43 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qw1OV-00EgRr-2T for linux-arm-kernel@lists.infradead.org; Thu, 26 Oct 2023 14:31:33 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-50819c4ad6fso316699e87.0 for ; Thu, 26 Oct 2023 07:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1698330688; x=1698935488; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S1dcX0dIRRrObAnF5frYkpK4OuCll9+8enWqXlC/Z8E=; b=1cPdyat9CPAhqNShKboqkMXKImKCGkSEuIKH/TW72JsKEwZsbuVrGoXzit8JkvkJOZ ll4g5O4g7+d8XZSh8KdOx6OEvnRxBuLAl8Ht5AeSUrJ0oH2eoJ7rf1FSkMKn7BEF1yAO urQcJbbf3r3WL1vYSx1+5AB84nR9L8Kq9IH4xY2M86/aq5mKNmK4Z/nGzOM3/pzXmrt0 rBFwg4Ym77iyLTlRDoH27UbbQGuYCFE1O3LEuWr9u/+kE6Z12zDiMBQKCPaBvL6PU317 NAPoi3HTql15rxciYqo/0EVEncZarZ1Hkcmq0fkg9FzI6nPncqfMhXyzVpfrITpwFdnW nmbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698330688; x=1698935488; 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=S1dcX0dIRRrObAnF5frYkpK4OuCll9+8enWqXlC/Z8E=; b=T5x818sCJnKytqD5ZWl2uQNuLUp1ZL/Ja0HchI80vjZi8HANkRCYNQEbLkn0GqWOmn CtzcbJITbsvnR+TlM3sT8gPQkj1tLgatBqDqcmgJb84n2XGq2Sqjsrt3TlD60vAiZF7d HL0yeHkFObNAwYQP0U1EaY4P/1r8lUCcrq3UC2XjoIZzPsH8fEQ6MFAnY/NjegYwC6mN JKTT9Q4DSxtKJGux0BnNj6PkXowWKrHk2Sbolo0ul87DKVVIyDRorUs2w4LzJ0i16Z3g va0o5jUvpK7lCARGDg7k0g5OZRcaTW+sDuaZVBYSMNpbHkKuB+GWmW0+KjBtOy/jCOdK NlnQ== X-Gm-Message-State: AOJu0YzgAdHcsUOLFFel9FjmUHP6ZlFR3JIxFUV4I+8DqEqYN5gv0lqL HwlLUTAYZ5jKPMHZXi47bz0LeQ== X-Google-Smtp-Source: AGHT+IFmVffviYe4SnJWF87coMF05M74cu5j7URH/064z6PBGryKofvqvntRSm7MdXJtr+wPs+ZT7Q== X-Received: by 2002:a05:6512:3c8f:b0:507:94be:adcf with SMTP id h15-20020a0565123c8f00b0050794beadcfmr13384462lfv.2.1698330687613; Thu, 26 Oct 2023 07:31:27 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:b380:32be:257:5381]) by smtp.gmail.com with ESMTPSA id r9-20020a056000014900b003232f167df5sm14316589wrx.108.2023.10.26.07.31.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 07:31:27 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Atish Patra , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Himanshu Chauhan , Xu Lu Subject: [RFC PATCH 1/3] riscv: add SBI SSE extension definitions Date: Thu, 26 Oct 2023 16:31:20 +0200 Message-ID: <20231026143122.279437-2-cleger@rivosinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231026143122.279437-1-cleger@rivosinc.com> References: <20231026143122.279437-1-cleger@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231026_073131_806018_C4B9C6A1 X-CRM114-Status: GOOD ( 11.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add needed definitions for SBI Supervisor Software Events extension [1]. This extension enables the SBI to inject events into supervisor software much like ARM SDEI. [1] https://lists.riscv.org/g/tech-prs/message/515 Signed-off-by: Clément Léger --- arch/riscv/include/asm/sbi.h | 38 ++++++++++++++++++++++++++++++++++++ arch/riscv/kernel/sbi.c | 4 ++++ 2 files changed, 42 insertions(+) diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h index 5b4a1bf5f439..2e99cafe7fed 100644 --- a/arch/riscv/include/asm/sbi.h +++ b/arch/riscv/include/asm/sbi.h @@ -30,6 +30,7 @@ enum sbi_ext_id { SBI_EXT_HSM = 0x48534D, SBI_EXT_SRST = 0x53525354, SBI_EXT_PMU = 0x504D55, + SBI_EXT_SSE = 0x535345, /* Experimentals extensions must lie within this range */ SBI_EXT_EXPERIMENTAL_START = 0x08000000, @@ -236,6 +237,40 @@ enum sbi_pmu_ctr_type { /* Flags defined for counter stop function */ #define SBI_PMU_STOP_FLAG_RESET (1 << 0) +enum sbi_ext_sse_fid { + SBI_SSE_EVENT_ATTR_GET = 0, + SBI_SSE_EVENT_ATTR_SET, + SBI_SSE_EVENT_REGISTER, + SBI_SSE_EVENT_UNREGISTER, + SBI_SSE_EVENT_ENABLE, + SBI_SSE_EVENT_DISABLE, + SBI_SSE_EVENT_COMPLETE, + SBI_SSE_EVENT_SIGNAL, +}; + +#define SBI_SSE_EVENT_LOCAL_RAS 0x00000000 +#define SBI_SSE_EVENT_GLOBAL_RAS 0x00008000 +#define SBI_SSE_EVENT_LOCAL_ASYNC_PF 0x00010000 +#define SBI_SSE_EVENT_LOCAL_PMU 0x00010001 +#define SBI_SSE_EVENT_LOCAL_DEBUG 0xffff3fff +#define SBI_SSE_EVENT_GLOBAL_DEBUG 0xffffbfff + +#define SBI_SSE_EVENT_GLOBAL (1 << 15) +#define SBI_SSE_EVENT_PLATFORM (1 << 14) + +enum sbi_sse_event_attr { + SBI_SSE_EVENT_ATTR_STATE = 0, + SBI_SSE_EVENT_ATTR_PRIORITY, + SBI_SSE_EVENT_ATTR_INJECTION, + SBI_SSE_EVENT_ATTR_HART_ID, + SBI_SSE_EVENT_ATTR_RAW_PENDING_STATUS, +}; + +enum sbi_sse_event_handler_sts { + SBI_SSE_HANDLER_SUCCESS = 0, + SBI_SSE_HANDLER_FAILED, +}; + #define SBI_SPEC_VERSION_DEFAULT 0x1 #define SBI_SPEC_VERSION_MAJOR_SHIFT 24 #define SBI_SPEC_VERSION_MAJOR_MASK 0x7f @@ -251,6 +286,9 @@ enum sbi_pmu_ctr_type { #define SBI_ERR_ALREADY_AVAILABLE -6 #define SBI_ERR_ALREADY_STARTED -7 #define SBI_ERR_ALREADY_STOPPED -8 +#define SBI_ERR_INVALID_STATE -10 +#define SBI_ERR_BAD_RANGE -11 +#define SBI_ERR_BUSY -12 extern unsigned long sbi_spec_version; struct sbiret { diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c index c672c8ba9a2a..13b63b383d4e 100644 --- a/arch/riscv/kernel/sbi.c +++ b/arch/riscv/kernel/sbi.c @@ -56,9 +56,13 @@ int sbi_err_map_linux_errno(int err) case SBI_ERR_DENIED: return -EPERM; case SBI_ERR_INVALID_PARAM: + case SBI_ERR_BAD_RANGE: + case SBI_ERR_INVALID_STATE: return -EINVAL; case SBI_ERR_INVALID_ADDRESS: return -EFAULT; + case SBI_ERR_BUSY: + return -EBUSY; case SBI_ERR_NOT_SUPPORTED: case SBI_ERR_FAILURE: default: