From: Nuno Das Neves <nunodasneves@linux.microsoft.com>
To: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org,
mikelley@microsoft.com, viremana@linux.microsoft.com,
sunilmut@microsoft.com, wei.liu@kernel.org, vkuznets@redhat.com,
ligrassi@microsoft.com, kys@microsoft.com
Subject: [PATCH 04/19] drivers/hv: check extension ioctl
Date: Fri, 28 May 2021 15:43:24 -0700 [thread overview]
Message-ID: <1622241819-21155-5-git-send-email-nunodasneves@linux.microsoft.com> (raw)
In-Reply-To: <1622241819-21155-1-git-send-email-nunodasneves@linux.microsoft.com>
Reserve ioctl number in userpsace-api/ioctl/ioctl-number.rst
Introduce MSHV_CHECK_EXTENSION ioctl.
Introduce documentation for /dev/mshv in Documentation/virt/mshv
Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
---
.../userspace-api/ioctl/ioctl-number.rst | 2 +
Documentation/virt/mshv/api.rst | 60 +++++++++++++++++++
drivers/hv/mshv_main.c | 23 +++++++
include/linux/mshv.h | 11 ++++
include/uapi/linux/mshv.h | 20 +++++++
5 files changed, 116 insertions(+)
create mode 100644 Documentation/virt/mshv/api.rst
create mode 100644 include/linux/mshv.h
create mode 100644 include/uapi/linux/mshv.h
diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst b/Documentation/userspace-api/ioctl/ioctl-number.rst
index 9bfc2b510c64..585d9cc42a5a 100644
--- a/Documentation/userspace-api/ioctl/ioctl-number.rst
+++ b/Documentation/userspace-api/ioctl/ioctl-number.rst
@@ -350,6 +350,8 @@ Code Seq# Include File Comments
0xB6 all linux/fpga-dfl.h
0xB7 all uapi/linux/remoteproc_cdev.h <mailto:linux-remoteproc@vger.kernel.org>
0xB7 all uapi/linux/nsfs.h <mailto:Andrei Vagin <avagin@openvz.org>>
+0xB8 all uapi/linux/mshv.h Microsoft Hypervisor root partition APIs
+ <mailto:linux-hyperv@vger.kernel.org>
0xC0 00-0F linux/usb/iowarrior.h
0xCA 00-0F uapi/misc/cxl.h
0xCA 10-2F uapi/misc/ocxl.h
diff --git a/Documentation/virt/mshv/api.rst b/Documentation/virt/mshv/api.rst
new file mode 100644
index 000000000000..75c5e073ecc0
--- /dev/null
+++ b/Documentation/virt/mshv/api.rst
@@ -0,0 +1,60 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+=====================================================
+Microsoft Hypervisor Root Partition API Documentation
+=====================================================
+
+1. Overview
+===========
+
+This document describes APIs for creating and managing guest virtual machines
+when running Linux as the root partition on the Microsoft Hypervisor.
+
+Note that this API is not yet stable!
+
+2. Glossary/Terms
+=================
+
+hv
+--
+Short for Hyper-V. This name is used in the kernel to describe interfaces to
+the Microsoft Hypervisor.
+
+mshv
+----
+Short for Microsoft Hypervisor. This is the name of the userland API module
+described in this document.
+
+Partition
+---------
+A virtual machine running on the Microsoft Hypervisor.
+
+Root Partition
+--------------
+The partition that is created and assumes control when the machine boots. The
+root partition can use mshv APIs to create guest partitions.
+
+3. API description
+==================
+
+The module is named mshv and can be configured with CONFIG_HYPERV_ROOT_API.
+
+Mshv is file descriptor-based, following a similar pattern to KVM.
+
+To get a handle to the mshv driver, use open("/dev/mshv").
+
+3.1 MSHV_CHECK_EXTENSION
+------------------------
+:Type: /dev/mshv ioctl
+:Parameters: pointer to a u32
+:Returns: 0 if extension unsupported, positive number if supported
+
+This ioctl takes a single argument corresponding to an API extension to check
+support for.
+
+If the extension is supported, MSHV_CHECK_EXTENSION will return a positive
+number. If not, it will return 0.
+
+The first extension that can be checked is MSHV_CAP_CORE_API_STABLE. This
+will be supported when the core API is stable.
+
diff --git a/drivers/hv/mshv_main.c b/drivers/hv/mshv_main.c
index c68cc84fb983..3342ea5bbd1d 100644
--- a/drivers/hv/mshv_main.c
+++ b/drivers/hv/mshv_main.c
@@ -11,6 +11,8 @@
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/miscdevice.h>
+#include <linux/slab.h>
+#include <linux/mshv.h>
MODULE_AUTHOR("Microsoft");
MODULE_LICENSE("GPL");
@@ -34,9 +36,30 @@ static struct miscdevice mshv_dev = {
.mode = 600,
};
+static long
+mshv_ioctl_check_extension(void __user *user_arg)
+{
+ u32 arg;
+
+ if (copy_from_user(&arg, user_arg, sizeof(arg)))
+ return -EFAULT;
+
+ switch (arg) {
+ case MSHV_CAP_CORE_API_STABLE:
+ return 0;
+ }
+
+ return -ENOTSUPP;
+}
+
static long
mshv_dev_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
{
+ switch (ioctl) {
+ case MSHV_CHECK_EXTENSION:
+ return mshv_ioctl_check_extension((void __user *)arg);
+ }
+
return -ENOTTY;
}
diff --git a/include/linux/mshv.h b/include/linux/mshv.h
new file mode 100644
index 000000000000..a0982fe2c0b8
--- /dev/null
+++ b/include/linux/mshv.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _LINUX_MSHV_H
+#define _LINUX_MSHV_H
+
+/*
+ * Microsoft Hypervisor root partition driver for /dev/mshv
+ */
+
+#include <uapi/linux/mshv.h>
+
+#endif
diff --git a/include/uapi/linux/mshv.h b/include/uapi/linux/mshv.h
new file mode 100644
index 000000000000..3b84e3ea97be
--- /dev/null
+++ b/include/uapi/linux/mshv.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _UAPI_LINUX_MSHV_H
+#define _UAPI_LINUX_MSHV_H
+
+/*
+ * Userspace interface for /dev/mshv
+ * Microsoft Hypervisor root partition APIs
+ * NOTE: This API is not yet stable!
+ */
+
+#include <linux/types.h>
+
+#define MSHV_CAP_CORE_API_STABLE 0x0
+
+#define MSHV_IOCTL 0xB8
+
+/* mshv device */
+#define MSHV_CHECK_EXTENSION _IOW(MSHV_IOCTL, 0x00, __u32)
+
+#endif
--
2.25.1
next prev parent reply other threads:[~2021-05-28 22:43 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-28 22:43 [PATCH 00/19] Microsoft Hypervisor root partition ioctl interface Nuno Das Neves
2021-05-28 22:43 ` [PATCH 01/19] x86/hyperv: convert hyperv statuses to linux error codes Nuno Das Neves
2021-06-10 18:22 ` Sunil Muthuswamy
2021-05-28 22:43 ` [PATCH 02/19] asm-generic/hyperv: convert hyperv statuses to strings Nuno Das Neves
2021-06-10 18:42 ` Sunil Muthuswamy
2021-06-23 22:15 ` Nuno Das Neves
2021-05-28 22:43 ` [PATCH 03/19] drivers/hv: minimal mshv module (/dev/mshv/) Nuno Das Neves
2021-05-29 0:01 ` Randy Dunlap
2021-06-01 19:45 ` Nuno Das Neves
2021-06-03 1:28 ` Sunil Muthuswamy
2021-06-23 22:05 ` Nuno Das Neves
2021-06-27 12:00 ` Wei Liu
2021-07-06 15:41 ` Nuno Das Neves
2021-05-28 22:43 ` Nuno Das Neves [this message]
2021-05-28 22:43 ` [PATCH 05/19] drivers/hv: create partition ioctl Nuno Das Neves
2021-05-28 22:43 ` [PATCH 06/19] drivers/hv: create, initialize, finalize, delete partition hypercalls Nuno Das Neves
2021-06-01 7:59 ` Wei Liu
2021-06-01 19:52 ` Nuno Das Neves
2021-05-28 22:43 ` [PATCH 07/19] drivers/hv: withdraw memory hypercall Nuno Das Neves
2021-05-28 22:43 ` [PATCH 08/19] drivers/hv: map and unmap guest memory Nuno Das Neves
2021-05-28 22:43 ` [PATCH 09/19] drivers/hv: create vcpu ioctl Nuno Das Neves
2021-05-28 22:43 ` [PATCH 10/19] drivers/hv: get and set vcpu registers ioctls Nuno Das Neves
2021-05-29 4:28 ` kernel test robot
2021-05-28 22:43 ` [PATCH 11/19] drivers/hv: set up synic pages for intercept messages Nuno Das Neves
2021-05-29 5:44 ` kernel test robot
2021-05-28 22:43 ` [PATCH 12/19] drivers/hv: run vp ioctl and isr Nuno Das Neves
2021-05-29 21:55 ` Wei Liu
2021-06-01 19:49 ` Nuno Das Neves
2021-05-28 22:43 ` [PATCH 13/19] drivers/hv: install intercept ioctl Nuno Das Neves
2021-05-28 22:43 ` [PATCH 14/19] drivers/hv: assert interrupt ioctl Nuno Das Neves
2021-05-28 22:43 ` [PATCH 15/19] drivers/hv: get and set vp state ioctls Nuno Das Neves
2021-05-28 22:43 ` [PATCH 16/19] drivers/hv: mmap vp register page Nuno Das Neves
2021-05-28 22:43 ` [PATCH 17/19] drivers/hv: get and set partition property ioctls Nuno Das Neves
2021-05-28 22:43 ` [PATCH 18/19] drivers/hv: Add enlightenment bits to create partition ioctl Nuno Das Neves
2021-05-28 22:43 ` [PATCH 19/19] drivers/hv: Translate GVA to GPA Nuno Das Neves
2021-06-10 9:22 ` [PATCH 00/19] Microsoft Hypervisor root partition ioctl interface Vitaly Kuznetsov
2021-06-23 22:18 ` Nuno Das Neves
2021-08-05 21:23 [PATCH v2 " Nuno Das Neves
2021-08-05 21:23 ` [PATCH 04/19] drivers/hv: check extension ioctl Nuno Das Neves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1622241819-21155-5-git-send-email-nunodasneves@linux.microsoft.com \
--to=nunodasneves@linux.microsoft.com \
--cc=kys@microsoft.com \
--cc=ligrassi@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikelley@microsoft.com \
--cc=sunilmut@microsoft.com \
--cc=viremana@linux.microsoft.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=vkuznets@redhat.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).