Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp776192pxj; Fri, 28 May 2021 15:44:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwimUhtN6wqG99j9GJwc8dwHoBKc13q+2o7+HlaizfvFRsneCX6EFV6BTxDSYrchKUxzVo X-Received: by 2002:a05:6638:597:: with SMTP id a23mr10446237jar.27.1622241874649; Fri, 28 May 2021 15:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622241874; cv=none; d=google.com; s=arc-20160816; b=dPwPiaIxGOSejIkeqGsjc1c266BY/36sX2rDSmDNAxxP4VbWJj8auQMMDLWUdgLlkQ WzpanoRRRMde5onQhsZOowY9qebk7k7u/GCoysBp8Jk61z4IBKg09dHEfHiVqZj4vBlL E4rfEP44BviN+VCknKIRFr1j+Q89IHu8WS1CE9cdyGYZXuk56AKtTyR5ybDGU7dbVWv2 h+Gs3JjnI33ukhMi0UQcG+K06Z/2Tjt121MygxCR9FMGWDOMpjYrexibcsUvbaXMh+hG alrr2G/XfRulo9ZfTWd5o2q9NqAQqSFbDOJjmnoDXkiyyP8fD8/zag7fvprpGSLD21FT UJiQ== 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=HxgM6fAkNsD9pKalX66nNs4AG10Z2Op4z9nCDbFTpV0=; b=vI3oTwkJxvHcUxeNp+08xsu3DNwTpMjEyMy3DgsJtlMAKTJUYyMFPHhdDn5juvLFOY Hxu38ub1vKi/D1UbrI9Dd2hQ8ctr8lS8leFHFvGjfHDoi9+n6Tn51jt0dgB5AOj7SYWG CNbwKoRRAbzOP4CrdeB95xdTcmzs13s9G+u7AvJ7ZtGN5lPKYOLEx7TJDdevB5QVbcOL Mwc8fGB0Puf4FsQ0U/QaniX19e98gPidfyUjMqXZR9IGCFmMR203pgSLQjVPOsBZUAKG 7gCSwd5EQTwg0AiEgi1RSUx9NexsdMjzh7M0krdT9M5EotLfpkcPP6KX3SLNbePFNwOO 1S+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=LCFkwFlt; 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 r10si7447646ill.70.2021.05.28.15.44.21; Fri, 28 May 2021 15:44:34 -0700 (PDT) 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=LCFkwFlt; 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 S229792AbhE1WpW (ORCPT + 99 others); Fri, 28 May 2021 18:45:22 -0400 Received: from linux.microsoft.com ([13.77.154.182]:55826 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229679AbhE1WpR (ORCPT ); Fri, 28 May 2021 18:45:17 -0400 Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 6649A20B800A; Fri, 28 May 2021 15:43:42 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6649A20B800A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1622241822; bh=HxgM6fAkNsD9pKalX66nNs4AG10Z2Op4z9nCDbFTpV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LCFkwFlt70JK+bm8ubijNvjeulUaTDGZYLNUCwiOCSdNN0kjC3HJNrCTcPXC4vz9b vpeoHbDLAogL/dKeI+YX73io6lMKXWQIrMUimms8LDMjgsEcGfI1pzvYFChrTJaPlY YvB90xeji3YN1uICx9UnZYyDDgES37kn+LdQCxt4= From: Nuno Das Neves 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 03/19] drivers/hv: minimal mshv module (/dev/mshv/) Date: Fri, 28 May 2021 15:43:23 -0700 Message-Id: <1622241819-21155-4-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1622241819-21155-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1622241819-21155-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/hyperv/Makefile | 1 + drivers/hv/Kconfig | 18 ++++++++++ drivers/hv/Makefile | 3 ++ drivers/hv/mshv_main.c | 74 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 drivers/hv/mshv_main.c diff --git a/arch/x86/hyperv/Makefile b/arch/x86/hyperv/Makefile index 48e2c51464e8..4b5a8a96ba01 100644 --- a/arch/x86/hyperv/Makefile +++ b/arch/x86/hyperv/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_X86_64) += hv_apic.o hv_proc.o ifdef CONFIG_X86_64 obj-$(CONFIG_PARAVIRT_SPINLOCKS) += hv_spinlock.o endif + diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig index 66c794d92391..d618b1fab2bb 100644 --- a/drivers/hv/Kconfig +++ b/drivers/hv/Kconfig @@ -27,4 +27,22 @@ config HYPERV_BALLOON help Select this option to enable Hyper-V Balloon driver. +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 is named mshv. + + If unsure, say N. + + endmenu diff --git a/drivers/hv/Makefile b/drivers/hv/Makefile index 94daf8240c95..c943fbeb70e7 100644 --- a/drivers/hv/Makefile +++ b/drivers/hv/Makefile @@ -2,6 +2,7 @@ obj-$(CONFIG_HYPERV) += hv_vmbus.o obj-$(CONFIG_HYPERV_UTILS) += hv_utils.o obj-$(CONFIG_HYPERV_BALLOON) += hv_balloon.o +obj-$(CONFIG_HYPERV_ROOT_API) += mshv.o CFLAGS_hv_trace.o = -I$(src) CFLAGS_hv_balloon.o = -I$(src) @@ -11,3 +12,5 @@ hv_vmbus-y := vmbus_drv.o \ channel_mgmt.o ring_buffer.o hv_trace.o hv_vmbus-$(CONFIG_HYPERV_TESTING) += hv_debugfs.o hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o hv_fcopy.o hv_utils_transport.o + +mshv-y += mshv_main.o diff --git a/drivers/hv/mshv_main.c b/drivers/hv/mshv_main.c new file mode 100644 index 000000000000..c68cc84fb983 --- /dev/null +++ b/drivers/hv/mshv_main.c @@ -0,0 +1,74 @@ +// 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 int mshv_dev_open(struct inode *inode, struct file *filp); +static int mshv_dev_release(struct inode *inode, struct file *filp); +static long mshv_dev_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg); + +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 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 int +__init mshv_init(void) +{ + int ret; + + ret = misc_register(&mshv_dev); + if (ret) + pr_err("%s: misc device register failed\n", __func__); + + return ret; +} + +static void +__exit mshv_exit(void) +{ + misc_deregister(&mshv_dev); +} + +module_init(mshv_init); +module_exit(mshv_exit); -- 2.25.1