Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2223522rdd; Fri, 12 Jan 2024 03:18:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IEO68jOo8NyN3huMrEbxpXFGHS8ST5ZfibSOzwkHJY1Nv0Bz0dmXBgyBjujWFgniA8r53iy X-Received: by 2002:aa7:d754:0:b0:558:1463:773d with SMTP id a20-20020aa7d754000000b005581463773dmr590760eds.75.1705058284849; Fri, 12 Jan 2024 03:18:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705058284; cv=none; d=google.com; s=arc-20160816; b=GkswdI3MSCtJhTFo8hH+MV1FxQ6aXpnFClvpNnZ9i6aIzYjUjLcDqKUraO9HdRho0t qWXFSlE+5FrY/QZBgk8JMlgqbhFr2TW62OP/wCnUq+7e+dVkGcjm/IhGkqHuec2Q4CEW TJMfqd+c7M6AEdn2wOnRNobbvIBPG9Xvyn6iDzxB4sxpCRnMiKs53Y4RW2cK9xEKKLiM KYcwh4T/6m+YSsTzN3r3sNpbBl3OG6U2USOP6X9ApRuWQs4HP5I3IyM/xsIHVbLMYTRm KtMh/jLMPqSTuAyhW5dfR5ngCJ/SsA6iLnXxL+KU+Unxkmjw4e7/bCzJJDd0eZ1Rjt2+ 7EeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BPz3Ba2qsBHXEcQ86Ca39sCiPs3HQbwo2qACoN41JeA=; fh=AdjJcfMlYbiYDdKKIz6ysPeqNYJJCfTBHWq2VWscBlk=; b=pKP7JRaq2ul9aJV4dLuPth0cm+WzZrT/tLERHN9/P0+SQ6KV9e4U+m98icLnDvqMvg nnV7rPUU//UdvHQkg0P7sA6ydTK48HwMaLODK66oqk46A/voA0OlToKS9+zkaDrvy2IB SzIcq684MiLqZdqP7+lAX1h9rQwSoCPBtbJmsSAIE5r4AWS8fG33JzPzPTaSLYtmgcZN Mid+F3biJT9O9c2gIebHr70U9fDKSWShK6G97liD2lUSoYLtOwbnSETaKKi3U8PjkuQh cb8IPc8BnNK3lf7ljMnqgLA4ZFLbZScUuhi695sUrGAfk8SDQE6+rEajxL9HLyw1hdbL wfNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=BOWCWzkc; spf=pass (google.com: domain of linux-kernel+bounces-24610-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24610-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g21-20020a056402091500b00558a633dd66si1182502edz.134.2024.01.12.03.18.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 03:18:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24610-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=BOWCWzkc; spf=pass (google.com: domain of linux-kernel+bounces-24610-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24610-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 972811F233A3 for ; Fri, 12 Jan 2024 11:18:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 16D0867E8B; Fri, 12 Jan 2024 11:17:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="BOWCWzkc" Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B50A63510 for ; Fri, 12 Jan 2024 11:17:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2866b15b013so1475105a91.0 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=vger.kernel.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=BOWCWzkcDobvb19D6MKirzVlhdsI7DTfKHE6ZAKYsqPLOBfn/R3AJbsRAsVSPmbhTs Ewyo2nh5Yc1Th9+XNRtl27D02DcHEDREMwWxxuApSYpHI0l+sh6huf10fIW7KR9sXj6c mt8WR47zY8dDMMi14qEUclB+wyMJljXcKeZYT8tvVgDzqgF49dcMP6th8R4ayKGBOLaQ 4nZ2vSEf8e4Fd33VKJ02Miul6cbojQmkthaZZNV0UX6B+e/QhU+i1ugUuuB8zRRZbiRD tcJwhyHlELwPvS7wJrfqGYCThnOfTLBvABDEca9GMPEl4zXE3yWOcJpn6XcEu7ojvMVb YfrQ== 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=polZ8f7jFxNImC/W23Dbdsu9ySAASZwINZ8dbPzkwnr1xd1H85iVs3zQBCDi9w2ELX ezi1MqJoa4862AdHWQQO/FBekaj07BS7hMSIsjren+t/4AEo/ZS2KwKLTp97bKS/U5up mJd0MOPQrRFqdX3w7Aavrdfn76mohII/b+bVdwkz2aNL4eLcrrH/+gjS4IIuQiPoSKD7 BChJCDQSECR/pu1iYg9RJtJkeIseieZEp2YWgs3y2aIEQB4t//8g02cJQVvlERmrbU51 dStrvDLD69YSFapotg2VHmZXk+qLLLyxVwRN8L1J+q0q1yshcoAfjgJflAMS+hBe87YL bjJQ== X-Gm-Message-State: AOJu0YxCijJ0+ER4gzmLTWCByYbYbuefbtQXPR8ygKceMqp66D3IN7cN c3MRUC9zv/wzn+6H5QjCTDRIIUnxrlHlYQ== 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?q?Cl=C3=A9ment=20L=C3=A9ger?= 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?q?Cl=C3=A9ment=20L=C3=A9ger?= , 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: -- 2.43.0