From patchwork Fri Nov 26 15:40:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 12641013 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 B09C3C433F5 for ; Fri, 26 Nov 2021 15:41:16 +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=JxnQ4R7k14rFVmAQ6kbgLC3oxs1dp5PQwug8DjJq3qI=; b=PRUKHKLpsnM6yG kmAlPezLh+xmBY9b1xXoCpb3eKlvHp1e/rWH8vvtsYnjcgxKU5jCav3VxfNgpWgcB8UdpzyrTrVLN o0JJfaYzEIW4Us+/50Vd5Ya6a8kn6L8L0koPRuaMwV81NU6VlBg0LfHLDXvxNrudJdeuhtETFVXoX u2Ec9SFZrGTxPxLFiNh3QYRJd2Iw4eg7RCWbr+SSU/zj00tTz0mpHGKIkvx6i8JJLDchZiBEx32jG CvvCE+Muh0/9j1UavXodLEDlZtjxlI88HLsHaTfdmHVVIuXyV1uvmGZE4tkaehrGi62JhuWEF4D7a cjHVcBhfaebrTWHnAFNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqdLN-00Axub-2t; Fri, 26 Nov 2021 15:40:57 +0000 Received: from esa3.hgst.iphmx.com ([216.71.153.141]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqdLK-00AxtA-C5; Fri, 26 Nov 2021 15:40:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1637941253; x=1669477253; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=Tjwhc9vT9WwipkcblO9vU5OVOm5KngnEVoNyzcLRv7Q=; b=AES9DsQr9zw1KjxdrVbvv/20tZZyBgwwVAc39klhyhTjSU0AkaKgmYht gpIYfc0ugx5sua0rL/OdhkDeHI+/n4SOg8kmPADelCPMg0A2qJQsbtj5q xHNyzYagkchgd8+uPFZw+ZJiOuq/l6Ksg/cEZRtLRAo67Q6Q+02Uz7BxD lWDZ4lTcOB4Jz1dDj7Oi2SUZnfdxIqTxEgh99FW3ZN3wBr2ZLGxMa+IQD TnSQGCnaOw5DAYguNcmozSmS+qK6aC0ZZGxQwtaNzK4OIgqLBqMhnoxZ6 kHTyGC5CVRsWyePyMJmW3fqFwuyRR3KsXdewFOpJ+QyIW5QsYv2+a/VRK w==; X-IronPort-AV: E=Sophos;i="5.87,266,1631548800"; d="scan'208";a="191541491" Received: from mail-co1nam11lp2171.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.171]) by ob1.hgst.iphmx.com with ESMTP; 26 Nov 2021 23:40:52 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LL31VKvtjRRCjN7coymTCBuNZNU3Y0LOd5NZa67IX+vHwQbHl/L8iZsMxZQEufyhIuVM+gOgkYiuHduy4cYKtQyPG13H4G5UjboZaZU924MloLqIphYLu/otqUHWacrR3Prknaf+YBCfrJxfk/SR8vg9BOtiFyI11ie87uYaO4sf6Npa5IIBmzKhxN/72v1BTTHYlpdiyJrfN170qGyi0yZcbKPmvdaG4NKMsFcEDHxivy93o+8tBITFWduQKvSw0/p9hf77L1qLm47lqKLJFOg6RzGJl083AJ2syg8USsErZtxyEhvBAQMZFVdiySTc3NsfBmDKjSf6+FUj/UTYBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Jd9LQ6X6JNI7eUzbXun1o5KucUYoZhcWgu5E0Vf4qJI=; b=ADvcDtYVA4LtpzAO/fHmN/KKK6GOilyIWotg5H9Up4QsnWrF6r2jKD1ZQYJS04wutSX/sCghW9RJ22nnvGf9r+DxcELlNlM+NXpM0DanIseN8Odv3BhcdzhlWDKl3pNCNKNTfE299PxHSQ+MYbF/KPZsf35MoFAQGFH9y2kdUAUJM5v4fSm1I9OjQp96GwQQy10imfJ2vQFgB2PAUhdd1MGAsxg9w3eSTIhUpqFGJRu505o/Mmrwy7jA3TvjJnzg5dv9kUhLyOroV+Zj3iXzbW0I2rXUo3IpzEdWwoxoLg6GHWHrnXXEEI/oFWbYr4jnKtgNe3K0jOCpvUuBhMQELA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Jd9LQ6X6JNI7eUzbXun1o5KucUYoZhcWgu5E0Vf4qJI=; b=oeHrddYFkRoVgHVwBZN2DlqBNKLg7TjGp0mKJVFYaSxxHwKl1+4udTTHrWu4PIr9Cm27rbp70C1HS+zDu6rxx2uuIt25VtgpP90vbgRICb3o70g9BKhtl0ga2q+zfPj7Rc6HJBWxH7FSzmDz4QgUzHrTnSXkBC/0aCmreSmXl3M= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB8330.namprd04.prod.outlook.com (2603:10b6:303:135::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.19; Fri, 26 Nov 2021 15:40:53 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97%9]) with mapi id 15.20.4734.023; Fri, 26 Nov 2021 15:40:52 +0000 From: Anup Patel To: Paolo Bonzini , Shuah Khan , Atish Patra Cc: Palmer Dabbelt , Paul Walmsley , Albert Ou , Alistair Francis , Anup Patel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Anup Patel Subject: [PATCH 1/4] RISC-V: KVM: Forward SBI experimental and vendor extensions Date: Fri, 26 Nov 2021 21:10:17 +0530 Message-Id: <20211126154020.342924-2-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211126154020.342924-1-anup.patel@wdc.com> References: <20211126154020.342924-1-anup.patel@wdc.com> X-ClientProxiedBy: MAXPR01CA0107.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::25) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 Received: from wdc.com (122.179.118.153) by MAXPR01CA0107.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20 via Frontend Transport; Fri, 26 Nov 2021 15:40:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dd523a92-3274-4070-64b6-08d9b0f320c3 X-MS-TrafficTypeDiagnostic: CO6PR04MB8330: X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dY+pjsUR7o1dbDgZtIvPy+0O0Bj16wH9BdvG3B+2mnv1hcPZm6WZiAJZwJPF1w2YIjLnH/DHa7P+n+Mv/vnwmt/l33UUznv0MUWY++0Eqf4sajJeljO3ejCYyKXnhVm2mLWVhsHuM70xWWa4LIG4fUPtdUBvqSrwzw7g+Qineetv1Uuf/9dBolVR3b/uBLH8WNXXfkp4bDv8RbU7+O6suz96OzbDJVYV9e+cJlR4I/iOJQzJTktvuoxPS+craliTf4qUV/s7Sf03g9xBZRLvBiWdIwZhDU3zUxyng2LT57hhuTaxB524JpjzzvazYqn/FRubPKleMlnotOJo4ARB7QHMiKiwgi8bNDAtfaYKCCuWzdcYxWweFigYVyyandXPSatmw4Um01SuhGi6+6AUm3/amQoFOLs+523eI8OCg9cgodYvt6d1AJBrHjpvbQ/NobnwI6AQtDd7sqr80S6fGZdYp0LWE0o4NHIQh9QgK+nQC0N5faMVG3UMh304/y1WqlwWYdZdCh0u/yW6sIgvt+yVTmC/aOdiQwbQRTDdyVqk7VgGmzeZCMfyUOHFR2qm9VBKqiFS9vM6GK/DFdQFykxHs7yyMfeYHFUq69Ogc9CLXMY0BwLECCOKzWIARuKznsFb/mJeCzSZK2att31h0GLkpPD3iosmB43BUo+VvCI16fnx1SclWjx3adywsQoJo4V/as67qXi+k3A1K3OAVA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8936002)(1076003)(54906003)(66946007)(110136005)(38350700002)(82960400001)(26005)(66556008)(186003)(44832011)(316002)(6666004)(86362001)(7696005)(956004)(2616005)(7416002)(52116002)(508600001)(2906002)(5660300002)(36756003)(55016003)(8886007)(38100700002)(66476007)(4326008)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4wYXltuhYpUL6ZAYGznhd6K4MDYnbBAbJX6xoOQSJfgCF9zx5DjiN9YVxWtfoBOG3EHAsy57RJq+wqQyOae/k8tDEdXfvX0/F74DBDBWyXiBrNUGzQIcN4FeL2NcFZu/qVALusxbxT+Osy/XJcUN6Oj81QBFkcv49OPStrFFP2Vl+Xj2pedHacL3w8rMPRdppnJSXwQUpe0A9wRgBuCAcFFvY1Y5fKrPfcTU7D66nYnjX4VuVwcPXKMBeM6Mln8GCM5e5gkEa0tTHn4R6K8zaMN/dtMEXT3a99HYhohdtxt4m0K5hD9NBXojXVvhV9AtlJE27gL2/sjifAYky1w8rRljiqzyPzFVz1Be8+eOE21ONkX7hUTePPxQb05qVCDf/7pUwswEYhho/xzB1yVcwJs0b7traEcjYP4p2zER3fCptJLUBQUudGscoRWY8m6TXiR8CChTFuZRkeXUtvysNoHzwotzC2667LrdSN++dBtoNeHeiwONQh4163Ms7zlYZ/VQO8KdoQ4Hckbr9hTxnR1w3lneuLofU86VQA/FJyy5JY00O8xpe9smgXMKmDV6Y4F0ZLCHBGbqCSETRYgArcQEY09Zd8qq/76WB02+IE+UjWwJxHrpJbWmK00NDBzQQ75KA19qeR5IUSdig8BTA6nW25CL9gh2UE0jvV78qGcyiOXnJ+EE+H1aQIJbfQcKgSJuowTy7BbnPZ6HSJIbL2tlCmurPKGsleqJeAWZVXpXUqYrIcafLS5/+LRCgo6B008YdPrBDUK4JezMbcr/g0sKgysjFzohcRVHswXtIHw1Mkml83h2XS90qO/Uag2QeSYbFInYOn9p7jzWMT7QRDlNWyv/cQ0MYm+xq9mUnQBxrJxu0LvyQoCDE0MnQAw9Wggrn3kLpxg7u+IaIrk4ubCjPFQrZuGqDKFEKvkcMK5isRP4rsmsH7oH9seeBgpf6I/O7rq3BJA8rtQ8/swhsH8D5novvZQxSa++cr2bbhlMrNO6+HC2/r37jInaazuF3jI5QqQksesjuXHvbdBUPKi3TjWIBPl0npy9CqMXCFaadx79VQmbxbRnfhpt5GqdtYuVYIl9NihVPGXMrjZbbbwW49LHWfNF96DZ1sTMWGVoux9EhXdPElFAAhztaLJYZbwuPZs29PNqsFoPQwLkivnrwF/dl65Gx9cd6HCggj+9N9sr8PQK0x1uDndy9U9sf8YC1wXZgwNCr3voNDyOHA5MZI3XcfGBpisbnvTOkD4dmeH1Gnwx8nI8piCnxP76N9/4xG8+BqfQjHsPJ4K7WNWVbCtzQDv/kPVvLPVO9OUyrzy95IVDn7fplrQlIpkGjEHVGBhOZhyQQzIKiwzFM4nq+7nEYphapITbHsVHZfYBd96hFaehntMYPSL0+FFvwVRX3y873dlt8d/ijwTaVmroGPL7oGhHcS1KSPZ9VkeejSonnjnl7kV7iSDDhYcBxoHNGPN6/FtpnNdlZGfWxLDw2w8P2zC5CwI8S3TF76XtdzBtZXx/bzdd3G1JwrH8u7lsgWt8u9N9yHjQCrDxYbWHZuPRsMG5cJFIa1Vv9HBb5sVJOzTuWho/3dnbf4WCFuzpmdAlY+4Skxw3z6X+JrCRwgR/AxOuJEgvqwYd4uA= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd523a92-3274-4070-64b6-08d9b0f320c3 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2021 15:40:52.7244 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pOEDVfuwnbwwDjBuapZT1Qh8DMcGm7XGub2+ydbM+fJbFQvwop2e9M0JEDlfBl/XGR4BKXJU6K3N9oJiDaq3Kw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB8330 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_074054_450096_3038D3D5 X-CRM114-Status: GOOD ( 13.32 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The SBI experimental extension space is for temporary (or experimental) stuff whereas SBI vendor extension space is for hardware vendor specific stuff. Both these SBI extension spaces won't be standardized by the SBI specification so let's blindly forward such SBI calls to the userspace. Signed-off-by: Anup Patel --- arch/riscv/kvm/vcpu_sbi.c | 4 ++++ arch/riscv/kvm/vcpu_sbi_base.c | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/arch/riscv/kvm/vcpu_sbi.c b/arch/riscv/kvm/vcpu_sbi.c index f62d25bc9733..78aa3db76225 100644 --- a/arch/riscv/kvm/vcpu_sbi.c +++ b/arch/riscv/kvm/vcpu_sbi.c @@ -46,6 +46,8 @@ extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_time; extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_ipi; extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_rfence; extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_hsm; +extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_experimental; +extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_vendor; static const struct kvm_vcpu_sbi_extension *sbi_ext[] = { &vcpu_sbi_ext_v01, @@ -54,6 +56,8 @@ static const struct kvm_vcpu_sbi_extension *sbi_ext[] = { &vcpu_sbi_ext_ipi, &vcpu_sbi_ext_rfence, &vcpu_sbi_ext_hsm, + &vcpu_sbi_ext_experimental, + &vcpu_sbi_ext_vendor, }; void kvm_riscv_vcpu_sbi_forward(struct kvm_vcpu *vcpu, struct kvm_run *run) diff --git a/arch/riscv/kvm/vcpu_sbi_base.c b/arch/riscv/kvm/vcpu_sbi_base.c index 641015549d12..2819c325f471 100644 --- a/arch/riscv/kvm/vcpu_sbi_base.c +++ b/arch/riscv/kvm/vcpu_sbi_base.c @@ -68,3 +68,30 @@ const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_base = { .extid_end = SBI_EXT_BASE, .handler = kvm_sbi_ext_base_handler, }; + +static int kvm_sbi_ext_expevend_handler(struct kvm_vcpu *vcpu, + struct kvm_run *run, + unsigned long *out_val, + struct kvm_cpu_trap *utrap, + bool *exit) +{ + /* + * Both SBI experimental and vendor extensions are + * unconditionally forwarded to userspace. + */ + kvm_riscv_vcpu_sbi_forward(vcpu, run); + *exit = true; + return 0; +} + +const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_experimental = { + .extid_start = SBI_EXT_EXPERIMENTAL_START, + .extid_end = SBI_EXT_EXPERIMENTAL_END, + .handler = kvm_sbi_ext_expevend_handler, +}; + +const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_vendor = { + .extid_start = SBI_EXT_VENDOR_START, + .extid_end = SBI_EXT_VENDOR_END, + .handler = kvm_sbi_ext_expevend_handler, +};