From patchwork Fri Jan 12 11:17:13 2024 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: 13518323 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 46B70C4706C for ; Fri, 12 Jan 2024 11:18:11 +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=A643H6trso9n/hb5pPogG1YM7JseQsZmoWG6ZNN0IZw=; b=Rnl3G+gZ/31ueI L5yv5rMtQYVphgoKr0o9BZIcIDRFYciUQbvdIGlH2Xdkj7vE+J6bf/mSXMgmwdr+mFjIjjygTWANq 3MjdhXNhsaCB1kiEXFuifLusEjKMQmo1pEPQz9qqCBGSyKBjzxjZUDF8vgUbTwefvxkta5Z41xwEN Kkc6STk8IhCBCNIPfaE8qo5frJ+SS9pdY9rZeH9a0xDNK1Tq22aC23VhfsHqrlrKS3p/iYtOfgKOt xzSUDP82iSVgttLlQlNoJkJCrXNlgoNtkfwScVIwFAujVNWwBOrtZqehAz60GCw7ZnA9sQiuFhYkj D9jdCsWCZjUc0A5M378A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rOFXl-002ZNb-0u; Fri, 12 Jan 2024 11:17:45 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rOFXi-002ZMH-1Q for linux-arm-kernel@lists.infradead.org; Fri, 12 Jan 2024 11:17:44 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-28d00f8ddbaso1481257a91.1 for ; Fri, 12 Jan 2024 03:17:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1705058262; x=1705663062; 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=BPz3Ba2qsBHXEcQ86Ca39sCiPs3HQbwo2qACoN41JeA=; b=T+DD9ud/GALQrxBqZI68vyYPvwLaF45SqEYzqtsD7RQvoV+adQ09QaY/1oBfUGv9q3 2+AeSo7+iFblol3GGZ+spKlWMr7J0qGPJWxw3horZwx0YB2BoRisOikWe46UzI+1PhpI 5da28zLYv21Rm9XbeM+X50I4mZId4DHEXSQONPC6xEXsNu1KqhvYjg+lL1VLf7EQ9bFD ALHe+bRTRffijOq9z814+dFClMyOYsiSWGyDe9bZaB6nQZ2fcYbLsJS6hr7yWTju5Hxg ZHBwnvCDbTgR+bRTSmGRHpDwhmYdYBYTEyDo2TwON7pHX5dRc9H18aV3WRzzNmuM/6uj kYpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705058262; x=1705663062; 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=BPz3Ba2qsBHXEcQ86Ca39sCiPs3HQbwo2qACoN41JeA=; b=Q6Wbn304F9HtK9xlarPfU32oOHq+izAMQz2oLv7LpAFMrGdDBxB5D3Vqpek76+QvJ7 g7rgX8zml7an7JJx4AXYrOTaLf5qAUxaoLrydNKHpsHr5w2pdu9JGZxAyPjRN5zDbzMW YqAhAuRRn2Re8DWA1I47EuEuu/84JkGdpD7nYTRQgf8ooKyT0EPfsmVhI3e3xieMK1Lm RTlG6pd/F24lIhwGDtcfRMJwSxutahgrOJ9XQjVxk5bqIloO1emJUREZOHl0/MDv7UzP ak3kpBuP+dOOSPWJooBnrw1AELJnYBNqWquz6h38B6lux/Zg9g/EMd1WTMudnx4TZX9M Dnzw== X-Gm-Message-State: AOJu0YxuAFIrJmurWG2W4M77tMBlni3gaG6WYF2RwbRh9UNFUkgMrlLi NQRmnWVffg5BThjuu7oPWrAzSjVUcofT9w== X-Google-Smtp-Source: AGHT+IFVJJimodUIGj6PoQdC5SEaQIRT46Bqli7WQ7LcyrkwR9voMH6TUpcHgpr8DRtDtz2TFWl/UQ== X-Received: by 2002:a17:90b:4c42:b0:28e:fa5:7afd with SMTP id np2-20020a17090b4c4200b0028e0fa57afdmr681589pjb.4.1705058261938; Fri, 12 Jan 2024 03:17:41 -0800 (PST) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:a276:8a4e:2aa1:5f09]) by smtp.gmail.com with ESMTPSA id sd12-20020a17090b514c00b0028cef021d45sm3794179pjb.17.2024.01.12.03.17.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 03:17:41 -0800 (PST) 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 v2 1/3] riscv: add SBI SSE extension definitions Date: Fri, 12 Jan 2024 12:17:13 +0100 Message-ID: <20240112111720.2975069-2-cleger@rivosinc.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240112111720.2975069-1-cleger@rivosinc.com> References: <20240112111720.2975069-1-cleger@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240112_031742_485032_5437299D X-CRM114-Status: GOOD ( 11.39 ) 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 | 47 ++++++++++++++++++++++++++++++++++++ arch/riscv/kernel/sbi.c | 4 +++ 2 files changed, 51 insertions(+) diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h index 0892f4421bc4..11cad3ec4a18 100644 --- a/arch/riscv/include/asm/sbi.h +++ b/arch/riscv/include/asm/sbi.h @@ -31,6 +31,7 @@ enum sbi_ext_id { SBI_EXT_SRST = 0x53525354, SBI_EXT_PMU = 0x504D55, SBI_EXT_DBCN = 0x4442434E, + SBI_EXT_SSE = 0x535345, /* Experimentals extensions must lie within this range */ SBI_EXT_EXPERIMENTAL_START = 0x08000000, @@ -243,6 +244,49 @@ enum sbi_ext_dbcn_fid { SBI_EXT_DBCN_CONSOLE_WRITE_BYTE = 2, }; +enum sbi_ext_sse_fid { + SBI_SSE_EVENT_ATTR_READ = 0, + SBI_SSE_EVENT_ATTR_WRITE, + SBI_SSE_EVENT_REGISTER, + SBI_SSE_EVENT_UNREGISTER, + SBI_SSE_EVENT_ENABLE, + SBI_SSE_EVENT_DISABLE, + SBI_SSE_EVENT_COMPLETE, + SBI_SSE_EVENT_SIGNAL, +}; + +enum sbi_sse_event_attr { + SBI_SSE_ATTR_STATUS = 0, + SBI_SSE_ATTR_PRIO, + SBI_SSE_ATTR_CONFIG, + SBI_SSE_ATTR_PREFERRED_HART, + SBI_SSE_ATTR_ENTRY_PC, + SBI_SSE_ATTR_ENTRY_A0, + SBI_SSE_ATTR_ENTRY_A6, + SBI_SSE_ATTR_ENTRY_A7, + SBI_SSE_ATTR_INTERRUPTED_MODE, + SBI_SSE_ATTR_INTERRUPTED_PC, + SBI_SSE_ATTR_INTERRUPTED_A0, + SBI_SSE_ATTR_INTERRUPTED_A6, + SBI_SSE_ATTR_INTERRUPTED_A7, +}; + +#define SBI_SSE_ATTR_STATUS_STATE_OFFSET 0 +#define SBI_SSE_ATTR_STATUS_STATE_MASK 0x3 +#define SBI_SSE_ATTR_STATUS_PENDING_OFFSET 2 +#define SBI_SSE_ATTR_STATUS_INJECT_OFFSET 3 + +#define SBI_SSE_ATTR_CONFIG_ONESHOT (1 << 0) + +#define SBI_SSE_EVENT_LOCAL_RAS 0x00000000 +#define SBI_SSE_EVENT_GLOBAL_RAS 0x00008000 +#define SBI_SSE_EVENT_LOCAL_PMU 0x00010000 +#define SBI_SSE_EVENT_LOCAL_SOFTWARE 0xffff0000 +#define SBI_SSE_EVENT_GLOBAL_SOFTWARE 0xffff8000 + +#define SBI_SSE_EVENT_GLOBAL (1 << 15) +#define SBI_SSE_EVENT_PLATFORM (1 << 14) + #define SBI_SPEC_VERSION_DEFAULT 0x1 #define SBI_SPEC_VERSION_MAJOR_SHIFT 24 #define SBI_SPEC_VERSION_MAJOR_MASK 0x7f @@ -258,6 +302,9 @@ enum sbi_ext_dbcn_fid { #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 5a62ed1da453..cfd8d51fa2a9 100644 --- a/arch/riscv/kernel/sbi.c +++ b/arch/riscv/kernel/sbi.c @@ -57,9 +57,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: