Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1685438pxb; Fri, 20 Nov 2020 16:35:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJzSBv02qdI26a0uCMkO6n0ecgr3tMO+TdZrZQWs3dMVbgg8dN5t7ScpFQXrDYH5tHrAev79 X-Received: by 2002:a17:907:162a:: with SMTP id hb42mr16400801ejc.251.1605918935139; Fri, 20 Nov 2020 16:35:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605918935; cv=none; d=google.com; s=arc-20160816; b=xTaU7bc3cTIFHgwdbpLLxrl3k0k3xJdWo0d2RDXwf49iqBh2iFpcWy5wHnxXrioStQ 6NqQhlZAogmAQXAmzV4bYoj6Toj6Yc1SB7JKPe39++VZB2YzcaHu5kcWNgwbY2bUiJID PTCSfJR11fOVz01L1ITI4PxH6j4E2LlWDgeR5bn8BrYVwISkgPtb+0ssHfOH2WPMdeVs 4rnyCOPk71ulMITdw8zPZSwBpP35b7YiMKYAuOJ/CDn3ZOiGFa66e1PoBO2tt5N3ZlHS VOt1jy30VWgP7YAs2v78mxc9n1ocdQFgeoqpdb+UPMf38yAmO3nOUgSLLYj1uTzoY5wx zaYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature:dkim-filter; bh=MebfIyhuSjtcItZhTeTBX3QIsCHrngY2XYQqTgXCPYQ=; b=p8e1Ci0Zb/u6I/n5cReqgrYwG2ejD4mgiCDrWwBSMWPZFhIZm7+Qt/hW9jHUapUgh2 xL3oh8yOPrHwy7TMpzEYqN3zvJYpc22VO7q1bTBDQ6k/Soih7KcKhZEduiLfyeHlbeBX KBHZW9M84LN6vgD4sX5QUQutXI0+C/FqmXS63JTNkEAfh3kCYcmSS6rG2+JZ4NhRS3FI ZnzMQsfysGPlWzmWvE6L+sP8qHR61PSOXMv2X9X2lX/EZ4WHPHB3QO/vc7HF3eMLm6UI UPtqf84vpzVPCKHKhvGUvmgmQQmkdWSTFhDqVorq2Rlq2n0OHuum5GfBh8aKlNQWa3ql Mg8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=XLgYOBre; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb34si2627079ejc.68.2020.11.20.16.35.12; Fri, 20 Nov 2020 16:35:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=XLgYOBre; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728802AbgKUAau (ORCPT + 99 others); Fri, 20 Nov 2020 19:30:50 -0500 Received: from linux.microsoft.com ([13.77.154.182]:51182 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728561AbgKUAau (ORCPT ); Fri, 20 Nov 2020 19:30:50 -0500 Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 82FD120B71D1; Fri, 20 Nov 2020 16:30:49 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 82FD120B71D1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1605918649; bh=MebfIyhuSjtcItZhTeTBX3QIsCHrngY2XYQqTgXCPYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XLgYOBresYxJgoxN0DlBM9yVv0ko+Ri+Z7wYyu0wJUzajy77ENNnwrsyy+zTU2UTN HofrVvFIyualY5DXVDLEEh50nU1J7ajNzq9ceFHdeJpTmqpK3JtthIREEhsMJbOg/a cclk3D31Gqx67uE+z+z2q4KlWyJdD+XAbsmFQpXM= From: Nuno Das Neves To: linux-hyperv@vger.kernel.org Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, mikelley@microsoft.com, viremana@linux.microsoft.com, sunilmut@microsoft.com, nunodasneves@linux.microsoft.com, wei.liu@kernel.org, ligrassi@microsoft.com, kys@microsoft.com Subject: [RFC PATCH 03/18] virt/mshv: minimal mshv module (/dev/mshv/) Date: Fri, 20 Nov 2020 16:30:22 -0800 Message-Id: <1605918637-12192-4-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1605918637-12192-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1605918637-12192-1-git-send-email-nunodasneves@linux.microsoft.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce a barebones module file for the mshv API. Introduce CONFIG_HYPERV_ROOT_API for controlling compilation of mshv. Co-developed-by: Lillian Grassin-Drake Signed-off-by: Lillian Grassin-Drake Signed-off-by: Nuno Das Neves --- arch/x86/Kconfig | 2 ++ arch/x86/hyperv/Kconfig | 22 +++++++++++++ arch/x86/hyperv/Makefile | 4 +++ virt/mshv/mshv_main.c | 70 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 arch/x86/hyperv/Kconfig create mode 100644 virt/mshv/mshv_main.c diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index f6946b81f74a..8d3848eea358 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2901,3 +2901,5 @@ source "drivers/firmware/Kconfig" source "arch/x86/kvm/Kconfig" source "arch/x86/Kconfig.assembler" + +source "arch/x86/hyperv/Kconfig" diff --git a/arch/x86/hyperv/Kconfig b/arch/x86/hyperv/Kconfig new file mode 100644 index 000000000000..81e783ab3514 --- /dev/null +++ b/arch/x86/hyperv/Kconfig @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# HYPERV_ROOT_API configuration +# + +config HYPERV_ROOT_API + tristate "Microsoft Hypervisor root partition interfaces: /dev/mshv" + depends on HYPERV + help + Provides access to interfaces for managing guest virtual machines + running under the Microsoft Hypervisor. + + These interfaces will only work when Linux is running as root + partition on the Microsoft Hypervisor. + + The interfaces are provided via a device named /dev/mshv. + + To compile this as a module, choose M here: the module + will be called mshv. + + If unsure, say N. + diff --git a/arch/x86/hyperv/Makefile b/arch/x86/hyperv/Makefile index 2ebcf3969121..86f6dc1c5118 100644 --- a/arch/x86/hyperv/Makefile +++ b/arch/x86/hyperv/Makefile @@ -5,3 +5,7 @@ obj-$(CONFIG_X86_64) += hv_apic.o hv_proc.o irqdomain.o ifdef CONFIG_X86_64 obj-$(CONFIG_PARAVIRT_SPINLOCKS) += hv_spinlock.o endif + +MSHV := ../../../virt/mshv +mshv-y += $(MSHV)/mshv_main.o +obj-$(CONFIG_HYPERV_ROOT_API) += mshv.o diff --git a/virt/mshv/mshv_main.c b/virt/mshv/mshv_main.c new file mode 100644 index 000000000000..ecb9089761fe --- /dev/null +++ b/virt/mshv/mshv_main.c @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2020, Microsoft Corporation. + * + * Authors: + * Nuno Das Neves + * Lillian Grassin-Drake + */ + +#include +#include +#include +#include + +MODULE_AUTHOR("Microsoft"); +MODULE_LICENSE("GPL"); + +static long +mshv_dev_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) +{ + return -ENOTTY; +} + +static int +mshv_dev_open(struct inode *inode, struct file *filp) +{ + return 0; +} + +static int +mshv_dev_release(struct inode *inode, struct file *filp) +{ + return 0; +} + +static const struct file_operations mshv_dev_fops = { + .owner = THIS_MODULE, + .open = mshv_dev_open, + .release = mshv_dev_release, + .unlocked_ioctl = mshv_dev_ioctl, + .llseek = noop_llseek, +}; + +static struct miscdevice mshv_dev = { + .minor = MISC_DYNAMIC_MINOR, + .name = "mshv", + .fops = &mshv_dev_fops, + .mode = 600, +}; + +static int +__init mshv_init(void) +{ + int r; + + r = misc_register(&mshv_dev); + if (r) + pr_err("%s: misc device register failed\n", __func__); + + return r; +} + +static void +__exit mshv_exit(void) +{ + misc_deregister(&mshv_dev); +} + +module_init(mshv_init); +module_exit(mshv_exit); -- 2.25.1