Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp5148465pxb; Tue, 28 Sep 2021 11:32:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPJCYU9da4+vVpfoJLwX5fN7sv+WiaCemvwL2HWOKdLtx70Se1Z+y/VgvK3Nxl1MZcXBpc X-Received: by 2002:aa7:9aee:0:b0:440:cd9d:405e with SMTP id y14-20020aa79aee000000b00440cd9d405emr6711503pfp.47.1632853950320; Tue, 28 Sep 2021 11:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632853950; cv=none; d=google.com; s=arc-20160816; b=xD5zQNEDtlTWlLtdhfdy2EvXkMiXuqeVqQ10TuLmv6iYblTaZyzKh984vsBIZqFDHE hRPeVEmsj6PBqk0DQRBb7vwqUGI4s+SIClnbO9FBs+ohoi5y/O9dCwKbK/RMrbJk97Sd OpJD/AYPASritbfwAgcF8yfjVtM6nqCc92e0dpHJQJQMrEOqrNwuxvEY/uCxE9aLatSo lCwDiDOPQUgAKzTXL/a4uM9muPLHrBlSPsZC0EKCHA4dACmgMm35Ci6N0jbgbzpvYcoW Fm0sIY0ZEkSFrp4xb3xjLD/ZkoL7IJBzWcbKyjdAlTBCkwDxaFnFa/MngEkRPQavXY8W CYMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=i+KeqlIfct1LzvCFtI2ZObmOtDqCo4ZA/x0Y5+bwmP8=; b=LuTWJWyY6zU0e7WhEFCSUHod4lnZNKsS5RlsyECWfUshnxF9Hvpz1QocrQGXrF3WT+ rAU2lMexUlZr5SfICCJ3yBm2mMP/HneqNlQ3VO7K+w5HQQ0V6S/9g23mvva+vpzKfLwk 6sZaNOaeJVg1gXwhIj+ltzovnV8Fw560diPkU9flGz4gp4e0abb5IwOx/uPzBfHqWH11 QH3trlMlOen67kOuPMJfPh6tGbiWTNCRraoIHCfABoN1GWt8nQbelzjJLD6qzjdjzNM7 MaiPnh/n6fIyf3YxDRoXa+F3zAv4veQ4/bt08a1KmLllJTCaevSGFYU5RCZ5vWUCUZNu WUxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=dlP+jG2j; 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 z18si24334315pgj.8.2021.09.28.11.32.17; Tue, 28 Sep 2021 11:32:30 -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=dlP+jG2j; 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 S242196AbhI1SdB (ORCPT + 99 others); Tue, 28 Sep 2021 14:33:01 -0400 Received: from linux.microsoft.com ([13.77.154.182]:50840 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241724AbhI1SdA (ORCPT ); Tue, 28 Sep 2021 14:33:00 -0400 Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id B53B720B8008; Tue, 28 Sep 2021 11:31:20 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B53B720B8008 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1632853880; bh=i+KeqlIfct1LzvCFtI2ZObmOtDqCo4ZA/x0Y5+bwmP8=; h=From:To:Cc:Subject:Date:From; b=dlP+jG2jDrJ94ZD1sOWln2wid9wPkAAEySXx0rb+kuO9TtSf0TQgnM3PxIBo8IeFQ TlBkykpb97F9CgRp/w6KNlHckjR1uFuHylMt1ezCwGACfFoh+RGLSPiTi7DKy3e8Uc W5zxqT/VtIh/3ZSmCgY85Gb1pZ1DbLC0rGJClWHg= 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, sthemmin@microsoft.com, anbelski@linux.microsoft.com Subject: [PATCH v3 00/19] Microsoft Hypervisor root partition ioctl interface Date: Tue, 28 Sep 2021 11:30:56 -0700 Message-Id: <1632853875-20261-1-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch series provides a userspace interface for creating and running guest virtual machines while running on the Microsoft Hypervisor [0]. Since managing guest machines can only be done when Linux is the root partition, this series depends on Wei Liu's patch series merged in 5.12: https://lore.kernel.org/linux-hyperv/20210203150435.27941-1-wei.liu@kernel.org/ The first two patches provide some helpers for converting hypervisor status codes to linux error codes, and printing hypervisor status codes to dmesg for debugging. Hyper-V related headers asm-generic/hyperv-tlfs.h and x86/asm/hyperv-tlfs.h are split into uapi and non-uapi. The uapi versions contain structures used in both the ioctl interface and the kernel. The mshv API is introduced in drivers/hv/mshv_main.c. As each interface is introduced, documentation is added in Documentation/virt/mshv/api.rst. The API is file-desciptor based, like KVM. The entry point is /dev/mshv. /dev/mshv ioctls: MSHV_CHECK_EXTENSION MSHV_CREATE_PARTITION Partition (vm) ioctls: MSHV_MAP_GUEST_MEMORY, MSHV_UNMAP_GUEST_MEMORY MSHV_INSTALL_INTERCEPT MSHV_ASSERT_INTERRUPT MSHV_GET_PARTITION_PROPERTY, MSHV_SET_PARTITION_PROPERTY MSHV_CREATE_VP Vp (vcpu) ioctls: MSHV_GET_VP_REGISTERS, MSHV_SET_VP_REGISTERS MSHV_RUN_VP MSHV_GET_VP_STATE, MSHV_SET_VP_STATE MSHV_VP_TRANSLATE_GVA mmap() (register page) [0] Hyper-V is more well-known, but it really refers to the whole stack including the hypervisor and other components that run in Windows kernel and userspace. Changes since v2: 1. Fix kernel test robot issues 2. Bugfix in GVA to GPA patch provided by Anatol Belski Changes since v1: 1. Correct mshv_dev mode to octal 0600 2. Fix bug in mshv_vp_iotcl_run - correctly set suspend registers on early exit 3. Address comments from Wei Liu, Sunil Muthuswamy, and Vitaly Kuznetsov 4. Run checkpatch.pl - fix whitespace and other style issues Changes since RFC: 1. Moved code from virt/mshv to drivers/hv 2. Split hypercall helper functions and synic code to hv_call.c and hv_synic.c 3. MSHV_REQUEST_VERSION ioctl replaced with MSHV_CHECK_EXTENSION 3. Numerous suggestions, fixes, style changes, etc from Michael Kelley, Vitaly Kuznetsov, Wei Liu, and Vineeth Pillai 4. Added patch to enable hypervisor enlightenments on partition creation 5. Added Wei Liu's patch for GVA to GPA translation Nuno Das Neves (18): x86/hyperv: convert hyperv statuses to linux error codes x86/hyperv: convert hyperv statuses to strings drivers/hv: minimal mshv module (/dev/mshv/) drivers/hv: check extension ioctl drivers/hv: create partition ioctl drivers/hv: create, initialize, finalize, delete partition hypercalls drivers/hv: withdraw memory hypercall drivers/hv: map and unmap guest memory drivers/hv: create vcpu ioctl drivers/hv: get and set vcpu registers ioctls drivers/hv: set up synic pages for intercept messages drivers/hv: run vp ioctl and isr drivers/hv: install intercept ioctl drivers/hv: assert interrupt ioctl drivers/hv: get and set vp state ioctls drivers/hv: mmap vp register page drivers/hv: get and set partition property ioctls drivers/hv: Add enlightenment bits to create partition ioctl Wei Liu (1): drivers/hv: Translate GVA to GPA .../userspace-api/ioctl/ioctl-number.rst | 2 + Documentation/virt/mshv/api.rst | 173 +++ arch/x86/hyperv/Makefile | 1 + arch/x86/hyperv/hv_init.c | 2 +- arch/x86/hyperv/hv_proc.c | 51 +- arch/x86/include/asm/hyperv-tlfs.h | 15 +- arch/x86/include/asm/mshyperv.h | 1 + arch/x86/include/uapi/asm/hyperv-tlfs.h | 1274 +++++++++++++++++ arch/x86/kernel/cpu/mshyperv.c | 16 + drivers/hv/Kconfig | 18 + drivers/hv/Makefile | 4 + drivers/hv/hv_call.c | 742 ++++++++++ drivers/hv/hv_synic.c | 181 +++ drivers/hv/mshv.h | 120 ++ drivers/hv/mshv_main.c | 1166 +++++++++++++++ include/asm-generic/hyperv-tlfs.h | 354 +++-- include/asm-generic/mshyperv.h | 4 + include/linux/mshv.h | 61 + include/uapi/asm-generic/hyperv-tlfs.h | 242 ++++ include/uapi/linux/mshv.h | 117 ++ 20 files changed, 4399 insertions(+), 145 deletions(-) create mode 100644 Documentation/virt/mshv/api.rst create mode 100644 arch/x86/include/uapi/asm/hyperv-tlfs.h create mode 100644 drivers/hv/hv_call.c create mode 100644 drivers/hv/hv_synic.c create mode 100644 drivers/hv/mshv.h create mode 100644 drivers/hv/mshv_main.c create mode 100644 include/linux/mshv.h create mode 100644 include/uapi/asm-generic/hyperv-tlfs.h create mode 100644 include/uapi/linux/mshv.h -- 2.23.4