Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3009022ybn; Thu, 26 Sep 2019 22:53:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGf1cntYS0QG0fadKqzUirCFai5zcyQQ8I/9q4dLRHw4dlTYEfCm9t3uq/BRxX9121Xcuj X-Received: by 2002:a17:906:960d:: with SMTP id s13mr6380033ejx.166.1569563634381; Thu, 26 Sep 2019 22:53:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569563634; cv=none; d=google.com; s=arc-20160816; b=w+g0pBV0UtVHzHHxHAIRM0fJyU1F6t29qQxtSoyWPAmLRsZU8VPKrIUNZdpWejyiz5 GAjUbIlMtAMIduxHye/qngLQGaIOXp4Z8HjYGiPXZw5TFHdi4ksAh1SDSRnl/oyhER0c LS29fYVxPySZnOEXdsLHk2HqbGXbyXeTcZTJkYMlX7RpzYmzClQvKS0CKqRcthRKpKEi JBjZwqg7Sq56pWVSSzU5l0F95qBpmpLp7dRYuWstQX/fDIAIhVZ+yTk6QkFfTYd9UM1f lGFE1rsB22Q+N/IhIya9jW7xNYe6WiuZ6CxlVHfaoe8Ktqw6I9SI1RcLfG1W+/tkxZDY r2fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=UboR/3YoY3uTd5/yIfcblxD1BtRwPtrq5UhbmXqOZRE=; b=PN2i4r//t45wNt9r8c1Q0DGGmWE/JU0atbMhoZYAuuobm3yTlomxKaVkBru42/L5g1 hb3YzrSmR7BFzQrSmYA2Q3/iumsq2yfdIH0NDxrUujzmtQj076jyOMd+rDmU0ehkcGqG +ZX81c2ShwP7CrYGDvgJUHi/Us08a7RQSo+zLR4ZbVbEP7X5CaMyVfON1YRBPf36XCtB 3ydOzsoDx6so/LTVvwlJWPivPhFBCukIZbwn5ccIqUV5OKPOmLE7l/PVIe0ljn/z+SCh snagByomrL8Ox5pZbwy5oZDRrIcrdeqvNjtFpQEX0s1ykoB+EKePht1kmP5uDOTE89sG RDEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=yYUj7D4P; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1si306090ejo.82.2019.09.26.22.53.30; Thu, 26 Sep 2019 22:53:54 -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=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=yYUj7D4P; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726075AbfI0FtG (ORCPT + 99 others); Fri, 27 Sep 2019 01:49:06 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:51060 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbfI0FtG (ORCPT ); Fri, 27 Sep 2019 01:49:06 -0400 Received: by mail-wm1-f67.google.com with SMTP id 5so5127973wmg.0 for ; Thu, 26 Sep 2019 22:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UboR/3YoY3uTd5/yIfcblxD1BtRwPtrq5UhbmXqOZRE=; b=yYUj7D4PSMFA1n+LtIatN5JEcAhdVXpZv8gEi6XuagNF1rAWPeLPjX7zE3JOzv+asu wX0oPV5zu8J5L/m2/HMwGsz63ARQtjxB5sjqcmAmlkUCLeIvSngTIRjn3PS5BtGvcxha 9cUmW4n7owYW1KZY4R5SlD7rkqrtoHyp72KMXpO2lkvjcpnqdYyQkbvp4r0cMtk3I9bB NiRfU90eGTTMro/NLsCPfoncmhrg/fBG522aQO6Ms1hHd6JaC3tpOJ2SE775hERPK3Iz 8MDMB57p8gLH/Es8dWfv18J5m1iRTNcvVj7onrb5KYYGnEuSiPGGfSYh4jUIkwmIf6F5 /cxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UboR/3YoY3uTd5/yIfcblxD1BtRwPtrq5UhbmXqOZRE=; b=tqiyKphkgx634QfY9oEEJtrC0CPyesVTDpNAZ09lyPup6lNuikrrZsF9rI1GWOv/6x kwoKnWFGS0fbjWEJO6mCDVtQRkKlpMDmhL3ADsfg4kiwjvJAvzVLpvUWcagskhBm3Apk JeOpc5vj5eLSSWiEiTUNaDn9Ukq+fosUDj8/1/ikfAImn3JqUc/gUGSXZl3lXvDsvTY4 QqKmo747Td4h86+hFNikTFh4XlWfdIYM1s0c7oMb9WECIAYkWfdpOSExYexwhQTG9EQ5 IS+cikiP51lRCn/QfNYOaXRZv3AJUssh7oHxbBquX8NNQr0V6XEnCKViINsbXRHYFbIT hDxA== X-Gm-Message-State: APjAAAWOSrbpzMZXRjCimKxuSVWd11RK/LqHSsiUwoK0VE6oCC4FOuxB cbWytIPkFDe0Gb9YB3cbg8HgKpR+GbjXyhcZlRD6G0ap X-Received: by 2002:a7b:c84f:: with SMTP id c15mr5891041wml.52.1569563343446; Thu, 26 Sep 2019 22:49:03 -0700 (PDT) MIME-Version: 1.0 References: <20190927000915.31781-1-atish.patra@wdc.com> <20190927000915.31781-4-atish.patra@wdc.com> In-Reply-To: <20190927000915.31781-4-atish.patra@wdc.com> From: Anup Patel Date: Fri, 27 Sep 2019 11:18:52 +0530 Message-ID: Subject: Re: [PATCH v2 3/3] RISC-V: Move SBI related macros under uapi. To: Atish Patra Cc: "linux-kernel@vger.kernel.org List" , Alan Kao , Albert Ou , Allison Randal , Gary Guo , Greg Kroah-Hartman , linux-riscv , Mike Rapoport , Palmer Dabbelt , Paul Walmsley , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 27, 2019 at 5:39 AM Atish Patra wrote: > > 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 > Thanks for considering KVM user-space SBI emulation. Reviewed-by: Anup Patel Regards, Anup