Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp2748117ybn; Thu, 26 Sep 2019 17:12:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcvvcZ957pknBxgHIxd2xaNvPt/Gk6coUWkJrr3SiqkthxhooPK8iUIbXQUhJTC8Ek/5Go X-Received: by 2002:a05:6402:782:: with SMTP id d2mr1648289edy.296.1569543171980; Thu, 26 Sep 2019 17:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569543171; cv=none; d=google.com; s=arc-20160816; b=ZBC5ZUOsEDomseLbP6D1gBXLxTMIBrr5IQBr/Ty21oD/5N+f3Y6hkUW3/ytPxeTbxv KhalLRAmunupKnshB+GhXj5cV+G9Jej7CBMq8P3ZwkOwXwN5UT3t/ntSLiVJjys50Qzu ZxQTXGJ9BCPlKA4oud5AG+SFqPCX0QQOA9Q9Zdj+dhtG+/rDBzPA6mEtLRTkW8Jm9lAd 4XDHZcJD6EheskVkda/uTDg74l2Rx/dPcfvd7tySFFBbfI75/Xext7KMMz3UKpaPsqcO a+VqNBbOpSNOoB+q/k/UqZQidQnlKqb+tlF3sn+elzXgFPT6+gGI+7/0VpMF4qXYxb2L QjsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :wdcironportexception:ironport-sdr:ironport-sdr:ironport-sdr :dkim-signature; bh=ajGLR7fgyvr4dWlzdzPDfLT6SWUidHzjpntRunFM9EM=; b=yrC24tAr22wT2TARw8aZkm7cNSmN7Zlj3756ispTHkCI1iU7XM3pmMcOzwVWMxwHwV JEbR9tPq/2RtHcVCHecAaRcaq6ysPyuSjktr1jv29Fu/zR56D3AVLMOhq1qldsnybuiF 0XILL3gYAKUXh1g+6iRVlyK5dF7I8ePb1nRg4Fcj94je7fLS5fTTvWZqeFaebaJ2Lymu WwiUYsV6B/tsGY7hnU4TKNYqXjKMCwpHXirSF2ngI5D23zY+nBdhKKHfd1v5YLzjQvt+ 3vvD8hg8D6QIk/mV+mVEpsOAvW7pk4+K9xM7SWkrFWiqOlavDdew+Jj6sKfoYIDU73It ZPMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=RxfmoXcV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t49si533316edd.198.2019.09.26.17.12.13; Thu, 26 Sep 2019 17:12:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=RxfmoXcV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727463AbfI0AJ2 (ORCPT + 99 others); Thu, 26 Sep 2019 20:09:28 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:38047 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725842AbfI0AJ1 (ORCPT ); Thu, 26 Sep 2019 20:09:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1569542988; x=1601078988; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bDArMe9M2L91Z/CR0UnsmHQJUCaE4qjpImR1YxVjjj4=; b=RxfmoXcVp5X59seu8/+gzlhry+yCeTh9tLfLTUpuZvZgUgWk6oATZttU dtW/YvDj/GNYrlxWfBvchSOdOhORtsBeMfBtqJoxoZY3hNK9yFPwwcLLu cVFthIYQql1QzCJwJFGho7CcITlFAIY+j2XBzdiH+tyDTYEiYeNAyoUSU 4U4N+LWdYS7wA3YTq+kh96+CEh7D1eSBunU9QGIwo/kf3SvsDQo6LfWEl HC2LcoLYoYowJbywwouMxhfEYP8u09v3QY1se+KeURKPjrvdo9UQJIpjw ri7XSmMEA7YkMEBTZIZzcYCxsy996UL0dgCKEL43PalXI6Hl5tMWFFHA8 w==; IronPort-SDR: oZdufVvqyR0WHwkTjv/vKcEmZMMnS1vhH14ThAuG3oPHcY1yTfIDwvkFiU9UnTwLu6RKYJk1+5 E2AfXxDVrDkx95u0npMSPXFMsSKXNKpZkrkPMcrByW1Lia4DZ3If8WxcMB8Wxye94WO55d9vGR zIfEUA4OiQsREuqbF71FsWyuqIRXkuGfo20XX1vxSYVfx20gGJQcpLvPzttrh3hvffNRwivH5+ 5cSN6IQG4KbFz8sSviQZcPtzxA9jJXGlkbpZ2558hYLUI2dKHuJNQGtJ14RyKP8YazbWc5OGMZ SQo= X-IronPort-AV: E=Sophos;i="5.64,553,1559491200"; d="scan'208";a="220096745" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 27 Sep 2019 08:09:46 +0800 IronPort-SDR: f+n4acBEkBoHo1LCgHYsXt9sbBCMmGwpQcCz0cBJOR4F6JPSzmvFfuBvKgYf9kko1H3jnxJocJ OkzAZ7IWKI+3GTc6KZr6DfvsSrxxYL9fAFtyu3T0w4Os3W4QTFOA8sUcc53Iv3v0YFd9Oy6Rtj YVoklQrHPzkURiIyS7OxHNlsay4LlpHfGbVjJSaRvtE44+upRFHru9G1LNiLWhou8ptF2B7fta iusbn0EklYg/5BBb9Pu0HQGujG8D1bXpbBvTOSFlann2tYkgSGDzlRql9Sfb4J43CNJbSOHhNp dpjcKNuuPe+MX2CXDBBUhSp/ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2019 17:05:45 -0700 IronPort-SDR: 5iiWTZJZcFIZLgZ/ptOBpHjaDkMGM/HJC4HUB7QiJCVOBj24JiCl63mi+A1hxuRHQRcx+bMRQQ p14dA785reRfFMxu8TZcc+xegP3+vhPgoECX0jWMVV0WJPpbwu5PdGQ6dGl0Z1EE0DbCKGr3L6 tkBOE6j73OupEAxlVGMmtiwTOq7QMEWjue+yy2K2CQmXW10u4xtolQAZHZVceak+vb0xQ4nOdT wxISFKSoh9JSA+91eQGSybK3Ktqblh1HKv/WqpLSMmOm2IdYZ+AWmLeDYGwdEscdoQ25TcR6qx wSo= WDCIronportException: Internal Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip01.wdc.com with ESMTP; 26 Sep 2019 17:09:25 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Alan Kao , Albert Ou , Allison Randal , Anup Patel , Gary Guo , Greg Kroah-Hartman , linux-riscv@lists.infradead.org, Mike Rapoport , Palmer Dabbelt , Paul Walmsley , Thomas Gleixner Subject: [PATCH v2 3/3] RISC-V: Move SBI related macros under uapi. Date: Thu, 26 Sep 2019 17:09:15 -0700 Message-Id: <20190927000915.31781-4-atish.patra@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190927000915.31781-1-atish.patra@wdc.com> References: <20190927000915.31781-1-atish.patra@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All SBI related macros can be reused by KVM RISC-V and userspace tools such as kvmtool, qemu-kvm. SBI calls can also be emulated by userspace if required. Any future vendor extensions can leverage this to emulate the specific extension in userspace instead of kernel. Signed-off-by: Atish Patra --- arch/riscv/include/asm/sbi.h | 37 +----------------------- arch/riscv/include/uapi/asm/sbi.h | 48 +++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 36 deletions(-) create mode 100644 arch/riscv/include/uapi/asm/sbi.h diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h index 279b7f10b3c2..902b83041111 100644 --- a/arch/riscv/include/asm/sbi.h +++ b/arch/riscv/include/asm/sbi.h @@ -7,42 +7,7 @@ #define _ASM_RISCV_SBI_H #include - -enum sbi_ext_id { - SBI_EXT_0_1_SET_TIMER = 0x0, - SBI_EXT_0_1_CONSOLE_PUTCHAR = 0x1, - SBI_EXT_0_1_CONSOLE_GETCHAR = 0x2, - SBI_EXT_0_1_CLEAR_IPI = 0x3, - SBI_EXT_0_1_SEND_IPI = 0x4, - SBI_EXT_0_1_REMOTE_FENCE_I = 0x5, - SBI_EXT_0_1_REMOTE_SFENCE_VMA = 0x6, - SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID = 0x7, - SBI_EXT_0_1_SHUTDOWN = 0x8, - SBI_EXT_BASE = 0x10, -}; - -enum sbi_ext_base_fid { - SBI_BASE_GET_SPEC_VERSION = 0, - SBI_BASE_GET_IMP_ID, - SBI_BASE_GET_IMP_VERSION, - SBI_BASE_PROBE_EXT, - SBI_BASE_GET_MVENDORID, - SBI_BASE_GET_MARCHID, - SBI_BASE_GET_MIMPID, -}; - -#define SBI_SPEC_VERSION_DEFAULT 0x1 -#define SBI_SPEC_VERSION_MAJOR_OFFSET 24 -#define SBI_SPEC_VERSION_MAJOR_MASK 0x7f -#define SBI_SPEC_VERSION_MINOR_MASK 0xffffff - -/* SBI return error codes */ -#define SBI_SUCCESS 0 -#define SBI_ERR_FAILURE -1 -#define SBI_ERR_NOT_SUPPORTED -2 -#define SBI_ERR_INVALID_PARAM -3 -#define SBI_ERR_DENIED -4 -#define SBI_ERR_INVALID_ADDRESS -5 +#include extern unsigned long sbi_spec_version; struct sbiret { diff --git a/arch/riscv/include/uapi/asm/sbi.h b/arch/riscv/include/uapi/asm/sbi.h new file mode 100644 index 000000000000..2e09ee52c346 --- /dev/null +++ b/arch/riscv/include/uapi/asm/sbi.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Common SBI related defines and macros to be used by RISC-V kernel, + * RISC-V KVM and userspace. + * + * Copyright (c) 2019 Western Digital Corporation or its affiliates. + */ + +#ifndef _UAPI_ASM_RISCV_SBI_H +#define _UAPI_ASM_RISCV_SBI_H + +enum sbi_ext_id { + SBI_EXT_0_1_SET_TIMER = 0x0, + SBI_EXT_0_1_CONSOLE_PUTCHAR = 0x1, + SBI_EXT_0_1_CONSOLE_GETCHAR = 0x2, + SBI_EXT_0_1_CLEAR_IPI = 0x3, + SBI_EXT_0_1_SEND_IPI = 0x4, + SBI_EXT_0_1_REMOTE_FENCE_I = 0x5, + SBI_EXT_0_1_REMOTE_SFENCE_VMA = 0x6, + SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID = 0x7, + SBI_EXT_0_1_SHUTDOWN = 0x8, + SBI_EXT_BASE = 0x10, +}; + +enum sbi_ext_base_fid { + SBI_BASE_GET_SPEC_VERSION = 0, + SBI_BASE_GET_IMP_ID, + SBI_BASE_GET_IMP_VERSION, + SBI_BASE_PROBE_EXT, + SBI_BASE_GET_MVENDORID, + SBI_BASE_GET_MARCHID, + SBI_BASE_GET_MIMPID, +}; + +#define SBI_SPEC_VERSION_DEFAULT 0x1 +#define SBI_SPEC_VERSION_MAJOR_OFFSET 24 +#define SBI_SPEC_VERSION_MAJOR_MASK 0x7f +#define SBI_SPEC_VERSION_MINOR_MASK 0xffffff + +/* SBI return error codes */ +#define SBI_SUCCESS 0 +#define SBI_ERR_FAILURE -1 +#define SBI_ERR_NOT_SUPPORTED -2 +#define SBI_ERR_INVALID_PARAM -3 +#define SBI_ERR_DENIED -4 +#define SBI_ERR_INVALID_ADDRESS -5 + +#endif -- 2.21.0