├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── diffs └── LIS4.0 │ ├── ln12Mar_lis40.patch │ ├── rhel6x_rhel5x.patch │ └── rhel7x_rhel6x.patch ├── hv-rhel5.x └── hv │ ├── CHANGELOG │ ├── Kconfig │ ├── Makefile │ ├── Module.markers │ ├── README │ ├── channel.c │ ├── channel_mgmt.c │ ├── connection.c │ ├── copy_files │ ├── git_add_files │ ├── hid-core.c │ ├── hid-debug.c │ ├── hid-hyperv.c │ ├── hid-ids.h │ ├── hid-input.c │ ├── hv.c │ ├── hv_balloon.c │ ├── hv_compat.c │ ├── hv_fcopy.c │ ├── hv_kvp.c │ ├── hv_snapshot.c │ ├── hv_timesource.c │ ├── hv_util.c │ ├── hv_utils_transport.c │ ├── hv_utils_transport.h │ ├── hyperv-keyboard.c │ ├── hyperv.conf │ ├── hyperv_fb.c │ ├── hyperv_net.h │ ├── hyperv_pvdrivers.conf │ ├── hyperv_vmbus.h │ ├── include │ ├── asm │ │ ├── hyperv.h │ │ ├── mshyperv.h │ │ └── sync_bitops.h │ ├── linux │ │ ├── atomic.h │ │ ├── export.h │ │ ├── hid-debug.h │ │ ├── hid.h │ │ ├── hidraw.h │ │ ├── hv_compat.h │ │ ├── hyperv.h │ │ ├── rndis.h │ │ ├── unaligned │ │ │ ├── access_ok.h │ │ │ ├── be_byteshift.h │ │ │ ├── be_memmove.h │ │ │ ├── be_struct.h │ │ │ ├── generic.h │ │ │ ├── le_byteshift.h │ │ │ ├── le_memmove.h │ │ │ ├── le_struct.h │ │ │ ├── memmove.h │ │ │ └── packed_struct.h │ │ └── uuid.h │ └── uapi │ │ └── linux │ │ ├── hyperv.h │ │ └── uuid.h │ ├── netvsc.c │ ├── netvsc_drv.c │ ├── overrides.mk │ ├── rhel5-hv-driver-install │ ├── rhel5-hv-driver-uninstall │ ├── ring_buffer.c │ ├── rndis_filter.c │ ├── storvsc_drv.c │ ├── tools │ ├── Makefile │ ├── hv_fcopy_daemon.c │ ├── hv_get_dhcp_info.sh │ ├── hv_get_dns_info.sh │ ├── hv_kvp_daemon.c │ ├── hv_set_ifconfig.sh │ ├── hv_vss_daemon.c │ └── lsvmbus │ ├── vmbus_drv.c │ └── xorg.conf ├── hv-rhel6.x └── hv │ ├── Kconfig │ ├── Makefile │ ├── README │ ├── arch │ └── x86 │ │ ├── hyperv │ │ ├── hv_init.c │ │ └── ms_hyperv_ext.c │ │ └── include │ │ ├── lis │ │ └── asm │ │ │ ├── mshyperv.h │ │ │ └── sync_bitops.h │ │ └── uapi │ │ └── lis │ │ └── asm │ │ └── hyperv.h │ ├── channel.c │ ├── channel_mgmt.c │ ├── connection.c │ ├── copy_files │ ├── git_add_files │ ├── hid-hyperv.c │ ├── hv.c │ ├── hv_balloon.c │ ├── hv_fcopy.c │ ├── hv_kvp.c │ ├── hv_snapshot.c │ ├── hv_trace.c │ ├── hv_trace.h │ ├── hv_trace_balloon.h │ ├── hv_util.c │ ├── hv_utils_transport.c │ ├── hv_utils_transport.h │ ├── hvnd_addr.c │ ├── hyperv-keyboard.c │ ├── hyperv.conf │ ├── hyperv_fb.c │ ├── hyperv_net.h │ ├── hyperv_pvdrivers.conf │ ├── hyperv_vmbus.h │ ├── include │ ├── linux │ │ ├── atomic.h │ │ ├── export.h │ │ ├── hv_compat.h │ │ ├── hyperv.h │ │ ├── rndis.h │ │ └── unaligned │ │ │ ├── access_ok.h │ │ │ ├── be_byteshift.h │ │ │ ├── be_memmove.h │ │ │ ├── be_struct.h │ │ │ ├── generic.h │ │ │ ├── le_byteshift.h │ │ │ ├── le_memmove.h │ │ │ ├── le_struct.h │ │ │ ├── memmove.h │ │ │ └── packed_struct.h │ └── uapi │ │ └── linux │ │ ├── hyperv.h │ │ └── uuid.h │ ├── mx_abi.h │ ├── netvsc.c │ ├── netvsc_drv.c │ ├── pci-hyperv.c │ ├── provider.c │ ├── rhel6-hv-driver-install │ ├── rhel6-hv-driver-uninstall │ ├── ring_buffer.c │ ├── rndis_filter.c │ ├── storvsc_drv.c │ ├── tools │ ├── Makefile │ ├── bondvf.sh │ ├── hv_fcopy_daemon.c │ ├── hv_get_dhcp_info.sh │ ├── hv_get_dns_info.sh │ ├── hv_kvp_daemon.c │ ├── hv_set_ifconfig.sh │ ├── hv_vss_daemon.c │ └── lsvmbus │ ├── uio_hv_generic.c │ ├── vmbus_drv.c │ ├── vmbus_rdma.c │ └── vmbus_rdma.h ├── hv-rhel7.x └── hv │ ├── CHANGELOG │ ├── Kconfig │ ├── Makefile │ ├── README │ ├── arch │ └── x86 │ │ ├── hyperv │ │ ├── hv_init.c │ │ └── ms_hyperv_ext.c │ │ └── include │ │ ├── lis │ │ └── asm │ │ │ ├── mshyperv.h │ │ │ └── sync_bitops.h │ │ └── uapi │ │ └── lis │ │ └── asm │ │ └── hyperv.h │ ├── channel.c │ ├── channel_mgmt.c │ ├── connection.c │ ├── copy_files │ ├── git_add_files │ ├── hid-core.c │ ├── hid-debug.c │ ├── hid-hyperv.c │ ├── hid-ids.h │ ├── hid-input.c │ ├── hv.c │ ├── hv_balloon.c │ ├── hv_compat.c │ ├── hv_fcopy.c │ ├── hv_kvp.c │ ├── hv_snapshot.c │ ├── hv_trace.c │ ├── hv_trace.h │ ├── hv_trace_balloon.h │ ├── hv_util.c │ ├── hv_utils_transport.c │ ├── hv_utils_transport.h │ ├── hvnd_addr.c │ ├── hyperv-keyboard.c │ ├── hyperv.conf │ ├── hyperv_fb.c │ ├── hyperv_mod_blacklist.conf │ ├── hyperv_net.h │ ├── hyperv_pvdrivers.conf │ ├── hyperv_transport.c │ ├── hyperv_vmbus.h │ ├── include │ ├── linux │ │ ├── atomic.h │ │ ├── export.h │ │ ├── hid-debug.h │ │ ├── hid.h │ │ ├── hidraw.h │ │ ├── hv_compat.h │ │ ├── hyperv.h │ │ ├── rndis.h │ │ ├── unaligned │ │ │ ├── access_ok.h │ │ │ ├── be_byteshift.h │ │ │ ├── be_memmove.h │ │ │ ├── be_struct.h │ │ │ ├── generic.h │ │ │ ├── le_byteshift.h │ │ │ ├── le_memmove.h │ │ │ ├── le_struct.h │ │ │ ├── memmove.h │ │ │ └── packed_struct.h │ │ └── uuid.h │ └── uapi │ │ └── linux │ │ ├── hyperv.h │ │ └── uuid.h │ ├── mlnx-ofa_kernel-4.5.tgz │ ├── mx_abi.h │ ├── netvsc.c │ ├── netvsc_compat.h │ ├── netvsc_drv.c │ ├── netvsc_trace.h │ ├── pci-hyperv.c │ ├── provider.c │ ├── rhel7-hv-driver-install │ ├── rhel7-hv-driver-uninstall │ ├── ring_buffer.c │ ├── rndis_filter.c │ ├── storvsc_drv.c │ ├── tools │ ├── 68-azure-sriov-nm-unmanaged.rules │ ├── Makefile │ ├── hv_fcopy_daemon.c │ ├── hv_get_dhcp_info │ ├── hv_get_dhcp_info.sh │ ├── hv_get_dns_info │ ├── hv_get_dns_info.sh │ ├── hv_kvp_daemon.c │ ├── hv_set_ifconfig │ ├── hv_set_ifconfig.sh │ ├── hv_vss_daemon.c │ ├── lsvmbus │ └── systemd │ │ ├── 70-hv_fcopy.rules │ │ ├── 70-hv_kvp.rules │ │ ├── 70-hv_vss.rules │ │ ├── hv_fcopy_daemon.service │ │ ├── hv_kvp_daemon.service │ │ └── hv_vss_daemon.service │ ├── uio_hv_generic.c │ ├── vmbus_drv.c │ ├── vmbus_rdma.c │ ├── vmbus_rdma.h │ └── xorg.conf ├── setup_travis_env.sh └── tools ├── hyperv_kdump_config.ps1 ├── kdump_configure.sh ├── port_upstream_patches.sh └── sriov ├── 60-hyperv-vf-name-run.rules ├── 60-hyperv-vf-name.rules ├── hv_vf_name └── ifcfg-vf1 /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | *.mod.c 7 | *.mod.o 8 | 9 | # Precompiled Headers 10 | *.gch 11 | *.pch 12 | 13 | # Temporary files 14 | .tmp_versions 15 | Module.symvers 16 | modules.order 17 | *.img 18 | *.unsigned 19 | *.code-workspace 20 | *.cmd 21 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # 2 | # travis-ci definition file 3 | # below matrix points to docker images 4 | # 5 | sudo: false 6 | dist: trusty 7 | 8 | env: 9 | matrix: 10 | - CENTOS=centos:7.5.1804 KERNEL=3.10.0-862 BUILD=7.5.1804 11 | - CENTOS=centos:7.4.1708 KERNEL=3.10.0-693.21.1 BUILD=7.4.1708 12 | - CENTOS=centos:7.4.1708 KERNEL=3.10.0-693 BUILD=7.4.1708 13 | - CENTOS=centos:7.3.1611 KERNEL=3.10.0-514 BUILD=7.3.1611 14 | - CENTOS=centos:7.2.1511 KERNEL=3.10.0-327 BUILD=7.2.1511 15 | - CENTOS=centos:7.1.1503 KERNEL=3.10.0-229 BUILD=7.1.1503 16 | - CENTOS=centos:7.0.1406 KERNEL=3.10.0-123 BUILD=7.0.1406 17 | - CENTOS=centos:6.9 KERNEL=2.6.32-696 BUILD=6.9 18 | - CENTOS=centos:6.8 KERNEL=2.6.32-642 BUILD=6.8 19 | - CENTOS=centos:6.7 KERNEL=2.6.32-573 BUILD=6.7 20 | - CENTOS=centos:6.6 KERNEL=2.6.32-504 BUILD=6.6 21 | 22 | services: 23 | - docker 24 | 25 | before_install: 26 | - sudo apt-get update 27 | - sudo apt-get install -o Dpkg::Options::="--force-confold" --force-yes -y docker-ce 28 | - sudo docker --version 29 | - sudo docker pull $CENTOS 30 | 31 | script: 32 | - bash setup_travis_env.sh 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | lis-next 2 | [![Build Status](https://travis-ci.org/LIS/lis-next.svg?branch=master)](https://travis-ci.org/LIS/lis-next) 3 | ======== 4 | This repository tracks the development effort to enhance downloadable LIS drivers for older distributions. While the best set of Hyper-V integration components are always available in the upstream Linux kernel, from time to time we will backport the features in most demand for older distributions. This repository will contain the source code for all such backports. 5 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/CHANGELOG: -------------------------------------------------------------------------------- 1 | July 18th, 2013: Got rid of the ifdef typo in kvp daemon.c. Fixed up a typo in hv_kvp.c for the SET case 2 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/Kconfig: -------------------------------------------------------------------------------- 1 | menu "Microsoft Hyper-V guest support" 2 | 3 | config HYPERV 4 | tristate "Microsoft Hyper-V client drivers" 5 | depends on X86 && ACPI && PCI && X86_LOCAL_APIC && HYPERVISOR_GUEST 6 | help 7 | Select this option to run Linux as a Hyper-V client operating 8 | system. 9 | 10 | config HYPERV_UTILS 11 | tristate "Microsoft Hyper-V Utilities driver" 12 | depends on HYPERV && CONNECTOR && NLS 13 | help 14 | Select this option to enable the Hyper-V Utilities. 15 | 16 | config HYPERV_BALLOON 17 | tristate "Microsoft Hyper-V Balloon driver" 18 | depends on HYPERV 19 | help 20 | Select this option to enable Hyper-V Balloon driver. 21 | 22 | endmenu 23 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/Makefile: -------------------------------------------------------------------------------- 1 | include $(M)/overrides.mk 2 | 3 | obj-m += hv_vmbus.o 4 | obj-m += hv_storvsc.o 5 | obj-m += hv_netvsc.o 6 | obj-m += hv_utils.o 7 | obj-m += hid-hyperv.o 8 | obj-m += hid-base.o 9 | 10 | obj-m += hyperv_fb.o 11 | obj-m += hv_balloon.o 12 | obj-m += hyperv-keyboard.o 13 | 14 | hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o hv_fcopy.o hv_utils_transport.o 15 | 16 | hv_vmbus-y := vmbus_drv.o \ 17 | hv.o connection.o channel.o \ 18 | channel_mgmt.o ring_buffer.o hv_compat.o 19 | 20 | hv_storvsc-y := storvsc_drv.o 21 | hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o 22 | hid-base-y := hid-core.o hid-input.o hid-debug.o 23 | hyperv_keyboard-y := hyperv-keyboard.o 24 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/Module.markers: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIS/lis-next/5f06e3f9530cc7c0dcece6f6d0fb1b0987ac17df/hv-rhel5.x/hv/Module.markers -------------------------------------------------------------------------------- /hv-rhel5.x/hv/README: -------------------------------------------------------------------------------- 1 | After unpacking the tar file; as root: 2 | 3 | Execute the script ./rhel5-hv-driver-install to build and install 4 | Hyper-V drivers on a rhel5.x installation. Once the script completes, 5 | reboot the machine to bringup RHEL5.X enlightened on Hyper-V. 6 | 7 | To uninstall the Hyper-V drivers, execute the script 8 | ./rhel5-hv-driver-uninstall. Once the script completes, reboot the machine 9 | to bringup RHEL5 in fully emulated mode. 10 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/copy_files: -------------------------------------------------------------------------------- 1 | echo "Copying Files" 2 | echo "Invoke this script from drivers/hv directory" 3 | 4 | rm -rf tools 5 | mkdir tools 6 | mkdir -p ./include/linux 7 | mkdir -p ./include/uapi/linux 8 | mkdir -p ./include/asm/linux 9 | 10 | cp ../scsi/storvsc_drv.c . 11 | cp ../video/fbdev/hyperv_fb.c . 12 | cp ../hid/hid-hyperv.c . 13 | cp ../input/serio/hyperv-keyboard.c . 14 | cp ../net/hyperv/*.[hc] . 15 | 16 | cp ../../tools/hv/*.c ./tools/ 17 | cp ../../tools/hv/*.sh ./tools/ 18 | 19 | cp ../../include/linux/hyperv.h ./include/linux/ 20 | cp ../../include/linux/uuid.h ./include/linux/ 21 | cp ../../include/uapi/linux/uuid.h ./include/uapi/linux/ 22 | cp ../../include/linux/rndis.h ./include/linux/ 23 | cp ../../include/linux/atomic.h ./include/linux/ 24 | cp ../../include/linux/hv_compat.h ./include/linux/ 25 | cp ../../include/uapi/linux/hyperv.h ./include/uapi/linux/ 26 | 27 | cp ../../arch/x86/include/uapi/asm/hyperv.h ./include/asm/ 28 | cp ../../arch/x86/include/asm/mshyperv.h ./include/asm/ 29 | 30 | cp -r ../../include/linux/unaligned ./include/linux/ 31 | cp ../../arch/x86/include/asm/sync_bitops.h ./include/asm/ 32 | cp ../../include/linux/export.h ./include/linux/ 33 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/git_add_files: -------------------------------------------------------------------------------- 1 | echo "Git adding Files" 2 | echo "Invoke this script from drivers/hv directory after applying the base patch" 3 | 4 | git add git_add_files 5 | git add overrides.mk 6 | git add copy_files 7 | git add remove_files 8 | git add README 9 | git add ../../include/linux/hv_compat.h 10 | 11 | git add rhel6-hv-driver-install 12 | git add rhel6-hv-driver-uninstall 13 | 14 | git add hyperv_pvdrivers.conf 15 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/hv_compat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if (RHEL_RELEASE_CODE < 1288) 5 | static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder) 6 | { 7 | union { 8 | u64 v64; 9 | u32 v32[2]; 10 | } d = { dividend }; 11 | u32 upper; 12 | 13 | upper = d.v32[1]; 14 | d.v32[1] = 0; 15 | if (upper >= divisor) { 16 | d.v32[1] = upper / divisor; 17 | upper %= divisor; 18 | } 19 | asm ("divl %2" : "=a" (d.v32[0]), "=d" (*remainder) : 20 | "rm" (divisor), "0" (d.v32[0]), "1" (upper)); 21 | return d.v64; 22 | } 23 | 24 | #ifndef div_s64_rem 25 | s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder) 26 | { 27 | u64 quotient; 28 | 29 | if (dividend < 0) { 30 | quotient = div_u64_rem(-dividend, abs(divisor), (u32 *)remainder); 31 | *remainder = -*remainder; 32 | if (divisor > 0) 33 | quotient = -quotient; 34 | } else { 35 | quotient = div_u64_rem(dividend, abs(divisor), (u32 *)remainder); 36 | if (divisor < 0) 37 | quotient = -quotient; 38 | } 39 | return quotient; 40 | } 41 | EXPORT_SYMBOL(div_s64_rem); 42 | #endif 43 | #endif 44 | 45 | #if RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(5, 9) 46 | struct timespec ns_to_timespec(const s64 nsec) 47 | { 48 | struct timespec ts; 49 | s32 rem; 50 | 51 | if (!nsec) 52 | return (struct timespec) {0, 0}; 53 | 54 | ts.tv_sec = div_s64_rem(nsec, NSEC_PER_SEC, &rem); 55 | if (unlikely(rem < 0)) { 56 | ts.tv_sec--; 57 | rem += NSEC_PER_SEC; 58 | } 59 | ts.tv_nsec = rem; 60 | 61 | return ts; 62 | } 63 | EXPORT_SYMBOL(ns_to_timespec); 64 | #endif 65 | 66 | struct shutdown_event { 67 | struct work_struct wq; 68 | char buf[64]; 69 | char *argv[4]; 70 | char *envp[6]; 71 | }; 72 | 73 | static void hv_usermodehelper(struct shutdown_event *s_event) 74 | { 75 | call_usermodehelper(s_event->argv[0], s_event->argv, s_event->envp, 1); 76 | } 77 | 78 | static struct shutdown_event s_event; 79 | 80 | void rhel_5_x_power_off(void) 81 | { 82 | int cnt = 0; 83 | s_event.argv[cnt++] = "/sbin/poweroff"; 84 | s_event.argv[cnt++] = 0; 85 | 86 | cnt = 0; 87 | 88 | s_event.envp[cnt++] = "HOME=/"; 89 | s_event.envp[cnt++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; 90 | s_event.envp[cnt++] = 0; 91 | INIT_WORK(&s_event.wq, (void *)(void *)hv_usermodehelper, &s_event); 92 | schedule_work(&s_event.wq); 93 | } 94 | EXPORT_SYMBOL(rhel_5_x_power_off); 95 | 96 | //KYS 97 | 98 | #ifndef netdev_err 99 | void netdev_err(struct net_device *net, const char *fmt, ...) //KYS 100 | { 101 | va_list args; 102 | 103 | va_start(args, fmt); 104 | vprintk(fmt, args); 105 | va_end(args); 106 | } 107 | EXPORT_SYMBOL(netdev_err); 108 | #endif 109 | 110 | 111 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/hv_timesource.c: -------------------------------------------------------------------------------- 1 | /* 2 | * A clocksource for Linux running on HyperV. 3 | * 4 | * 5 | * Copyright (C) 2010, Novell, Inc. 6 | * Author : K. Y. Srinivasan 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 15 | * NON INFRINGEMENT. See the GNU General Public License for more 16 | * details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | */ 23 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #define HV_CLOCK_SHIFT 22 34 | 35 | static cycle_t read_hv_clock(void) 36 | { 37 | cycle_t current_tick; 38 | /* 39 | * Read the partition counter to get the current tick count. This count 40 | * is set to 0 when the partition is created and is incremented in 41 | * 100 nanosecond units. 42 | */ 43 | rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick); 44 | return current_tick; 45 | } 46 | 47 | static struct clocksource hyperv_cs = { 48 | .name = "hyperv_clocksource", 49 | .rating = 499, /* use this when running on Hyperv*/ 50 | .read = read_hv_clock, 51 | .mask = CLOCKSOURCE_MASK(64), 52 | /* 53 | * The time ref counter in HyperV is in 100ns units. 54 | * The definition of mult is: 55 | * mult/2^shift = ns/cyc = 100 56 | * mult = (100 << shift) 57 | */ 58 | .mult = (100 << HV_CLOCK_SHIFT), 59 | .shift = HV_CLOCK_SHIFT, 60 | }; 61 | 62 | static struct dmi_system_id 63 | hv_timesource_dmi_table[] = { 64 | { 65 | .ident = "Hyper-V", 66 | .matches = { 67 | DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"), 68 | DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"), 69 | DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"), 70 | }, 71 | }, 72 | { }, 73 | }; 74 | MODULE_DEVICE_TABLE(dmi, hv_timesource_dmi_table); 75 | 76 | static const struct pci_device_id 77 | hv_timesource_pci_table[] = { 78 | { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */ 79 | { 0 } 80 | }; 81 | MODULE_DEVICE_TABLE(pci, hv_timesource_pci_table); 82 | 83 | 84 | static int __init init_hv_clocksource(void) 85 | { 86 | if ((x86_hyper != &x86_hyper_ms_hyperv) || 87 | !(ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)) 88 | return -ENODEV; 89 | 90 | if (!dmi_check_system(hv_timesource_dmi_table)) 91 | return -ENODEV; 92 | 93 | pr_info("Registering HyperV clock source\n"); 94 | return clocksource_register(&hyperv_cs); 95 | } 96 | 97 | module_init(init_hv_clocksource); 98 | MODULE_DESCRIPTION("HyperV based clocksource"); 99 | MODULE_AUTHOR("K. Y. Srinivasan "); 100 | MODULE_LICENSE("GPL"); 101 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/hv_utils_transport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kernel/userspace transport abstraction for Hyper-V util driver. 3 | * 4 | * Copyright (C) 2015, Vitaly Kuznetsov 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License version 2 as published 8 | * by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 13 | * NON INFRINGEMENT. See the GNU General Public License for more 14 | * details. 15 | * 16 | */ 17 | 18 | #ifndef _HV_UTILS_TRANSPORT_H 19 | #define _HV_UTILS_TRANSPORT_H 20 | 21 | #include 22 | #include 23 | 24 | enum hvutil_transport_mode { 25 | HVUTIL_TRANSPORT_INIT = 0, 26 | HVUTIL_TRANSPORT_NETLINK, 27 | HVUTIL_TRANSPORT_CHARDEV, 28 | }; 29 | 30 | struct hvutil_transport { 31 | int mode; /* hvutil_transport_mode */ 32 | struct file_operations fops; /* file operations */ 33 | struct miscdevice mdev; /* misc device */ 34 | struct cb_id cn_id; /* CN_*_IDX/CN_*_VAL */ 35 | struct list_head list; /* hvt_list */ 36 | int (*on_msg)(void *, int); /* callback on new user message */ 37 | void (*on_reset)(void); /* callback when userspace drops */ 38 | u8 *outmsg; /* message to the userspace */ 39 | int outmsg_len; /* its length */ 40 | wait_queue_head_t outmsg_q; /* poll/read wait queue */ 41 | struct mutex outmsg_lock; /* protects outmsg */ 42 | }; 43 | 44 | struct hvutil_transport *hvutil_transport_init(char *name, 45 | u32 cn_idx, u32 cn_val, 46 | int (*on_msg)(void *, int), 47 | void (*on_reset)(void)); 48 | int hvutil_transport_send(struct hvutil_transport *hvt, void *msg, int len); 49 | void hvutil_transport_destroy(struct hvutil_transport *hvt); 50 | 51 | #endif /* _HV_UTILS_TRANSPORT_H */ 52 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/hyperv.conf: -------------------------------------------------------------------------------- 1 | # this is hyperv conf file to override inbuilt hyper-v kernel driver. 2 | 3 | override hv_vmbus * weak-updates/microsoft-hyper-v 4 | override hid-hyperv * weak-updates/microsoft-hyper-v 5 | override hv_netvsc * weak-updates/microsoft-hyper-v 6 | override hv_utils * weak-updates/microsoft-hyper-v 7 | override hyperv_fb * weak-updates/microsoft-hyper-v 8 | override hv_balloon * weak-updates/microsoft-hyper-v 9 | override hv_storvsc * weak-updates/microsoft-hyper-v 10 | override hyperv-keyboard * weak-updates/microsoft-hyper-v 11 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/hyperv_pvdrivers.conf: -------------------------------------------------------------------------------- 1 | # Install HyperV paravirtualized drivers 2 | 3 | install ata_piix { /sbin/modprobe hv_storvsc 2>&1 || /sbin/modprobe --ignore-install ata_piix; } 4 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/asm/mshyperv.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASM_X86_MSHYPER_H 2 | #define _ASM_X86_MSHYPER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | struct ms_hyperv_info { 9 | u32 features; 10 | u32 misc_features; 11 | u32 hints; 12 | }; 13 | 14 | extern struct ms_hyperv_info ms_hyperv; 15 | 16 | void hyperv_callback_vector(void); 17 | #ifdef CONFIG_TRACING 18 | #define trace_hyperv_callback_vector hyperv_callback_vector 19 | #endif 20 | void hv_register_vmbus_handler(int irq, irq_handler_t handler); 21 | 22 | void hyperv_vector_handler(struct pt_regs *regs); 23 | void hv_setup_vmbus_irq(void (*handler)(void)); 24 | void hv_remove_vmbus_irq(void); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/asm/sync_bitops.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASM_X86_SYNC_BITOPS_H 2 | #define _ASM_X86_SYNC_BITOPS_H 3 | 4 | /* 5 | * Copyright 1992, Linus Torvalds. 6 | */ 7 | 8 | /* 9 | * These have to be done with inline assembly: that way the bit-setting 10 | * is guaranteed to be atomic. All bit operations return 0 if the bit 11 | * was cleared before the operation and != 0 if it was not. 12 | * 13 | * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). 14 | */ 15 | 16 | #define ADDR (*(volatile long *)addr) 17 | 18 | /** 19 | * sync_set_bit - Atomically set a bit in memory 20 | * @nr: the bit to set 21 | * @addr: the address to start counting from 22 | * 23 | * This function is atomic and may not be reordered. See __set_bit() 24 | * if you do not require the atomic guarantees. 25 | * 26 | * Note that @nr may be almost arbitrarily large; this function is not 27 | * restricted to acting on a single-word quantity. 28 | */ 29 | static inline void sync_set_bit(long nr, volatile unsigned long *addr) 30 | { 31 | asm volatile("lock; bts %1,%0" 32 | : "+m" (ADDR) 33 | : "Ir" (nr) 34 | : "memory"); 35 | } 36 | 37 | /** 38 | * sync_clear_bit - Clears a bit in memory 39 | * @nr: Bit to clear 40 | * @addr: Address to start counting from 41 | * 42 | * sync_clear_bit() is atomic and may not be reordered. However, it does 43 | * not contain a memory barrier, so if it is used for locking purposes, 44 | * you should call smp_mb__before_atomic() and/or smp_mb__after_atomic() 45 | * in order to ensure changes are visible on other processors. 46 | */ 47 | static inline void sync_clear_bit(long nr, volatile unsigned long *addr) 48 | { 49 | asm volatile("lock; btr %1,%0" 50 | : "+m" (ADDR) 51 | : "Ir" (nr) 52 | : "memory"); 53 | } 54 | 55 | /** 56 | * sync_change_bit - Toggle a bit in memory 57 | * @nr: Bit to change 58 | * @addr: Address to start counting from 59 | * 60 | * sync_change_bit() is atomic and may not be reordered. 61 | * Note that @nr may be almost arbitrarily large; this function is not 62 | * restricted to acting on a single-word quantity. 63 | */ 64 | static inline void sync_change_bit(long nr, volatile unsigned long *addr) 65 | { 66 | asm volatile("lock; btc %1,%0" 67 | : "+m" (ADDR) 68 | : "Ir" (nr) 69 | : "memory"); 70 | } 71 | 72 | /** 73 | * sync_test_and_set_bit - Set a bit and return its old value 74 | * @nr: Bit to set 75 | * @addr: Address to count from 76 | * 77 | * This operation is atomic and cannot be reordered. 78 | * It also implies a memory barrier. 79 | */ 80 | static inline int sync_test_and_set_bit(long nr, volatile unsigned long *addr) 81 | { 82 | int oldbit; 83 | 84 | asm volatile("lock; bts %2,%1\n\tsbbl %0,%0" 85 | : "=r" (oldbit), "+m" (ADDR) 86 | : "Ir" (nr) : "memory"); 87 | return oldbit; 88 | } 89 | 90 | /** 91 | * sync_test_and_clear_bit - Clear a bit and return its old value 92 | * @nr: Bit to clear 93 | * @addr: Address to count from 94 | * 95 | * This operation is atomic and cannot be reordered. 96 | * It also implies a memory barrier. 97 | */ 98 | static inline int sync_test_and_clear_bit(long nr, volatile unsigned long *addr) 99 | { 100 | int oldbit; 101 | 102 | asm volatile("lock; btr %2,%1\n\tsbbl %0,%0" 103 | : "=r" (oldbit), "+m" (ADDR) 104 | : "Ir" (nr) : "memory"); 105 | return oldbit; 106 | } 107 | 108 | /** 109 | * sync_test_and_change_bit - Change a bit and return its old value 110 | * @nr: Bit to change 111 | * @addr: Address to count from 112 | * 113 | * This operation is atomic and cannot be reordered. 114 | * It also implies a memory barrier. 115 | */ 116 | static inline int sync_test_and_change_bit(long nr, volatile unsigned long *addr) 117 | { 118 | int oldbit; 119 | 120 | asm volatile("lock; btc %2,%1\n\tsbbl %0,%0" 121 | : "=r" (oldbit), "+m" (ADDR) 122 | : "Ir" (nr) : "memory"); 123 | return oldbit; 124 | } 125 | 126 | #define sync_test_bit(nr, addr) test_bit(nr, addr) 127 | 128 | #undef ADDR 129 | 130 | #endif /* _ASM_X86_SYNC_BITOPS_H */ 131 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/linux/atomic.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_ATOMIC_H 2 | #define _LINUX_ATOMIC_H 3 | #include 4 | 5 | #endif 6 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/linux/export.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_EXPORT_H 2 | #define _LINUX_EXPORT_H 3 | /* 4 | * Export symbols from the kernel to modules. Forked from module.h 5 | * to reduce the amount of pointless cruft we feed to gcc when only 6 | * exporting a simple symbol or two. 7 | * 8 | * Try not to add #includes here. It slows compilation and makes kernel 9 | * hackers place grumpy comments in header files. 10 | */ 11 | 12 | /* Some toolchains use a `_' prefix for all user symbols. */ 13 | #ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX 14 | #define __VMLINUX_SYMBOL(x) _##x 15 | #define __VMLINUX_SYMBOL_STR(x) "_" #x 16 | #else 17 | #define __VMLINUX_SYMBOL(x) x 18 | #define __VMLINUX_SYMBOL_STR(x) #x 19 | #endif 20 | 21 | /* Indirect, so macros are expanded before pasting. */ 22 | #define VMLINUX_SYMBOL(x) __VMLINUX_SYMBOL(x) 23 | #define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x) 24 | 25 | #ifndef __ASSEMBLY__ 26 | struct kernel_symbol 27 | { 28 | unsigned long value; 29 | const char *name; 30 | }; 31 | 32 | #ifdef MODULE 33 | extern struct module __this_module; 34 | #define THIS_MODULE (&__this_module) 35 | #else 36 | #define THIS_MODULE ((struct module *)0) 37 | #endif 38 | 39 | #ifdef CONFIG_MODULES 40 | 41 | #ifndef __GENKSYMS__ 42 | #ifdef CONFIG_MODVERSIONS 43 | /* Mark the CRC weak since genksyms apparently decides not to 44 | * generate a checksums for some symbols */ 45 | #define __CRC_SYMBOL(sym, sec) \ 46 | extern __visible void *__crc_##sym __attribute__((weak)); \ 47 | static const unsigned long __kcrctab_##sym \ 48 | __used \ 49 | __attribute__((section("___kcrctab" sec "+" #sym), unused)) \ 50 | = (unsigned long) &__crc_##sym; 51 | #else 52 | #define __CRC_SYMBOL(sym, sec) 53 | #endif 54 | 55 | /* For every exported symbol, place a struct in the __ksymtab section */ 56 | #define __EXPORT_SYMBOL(sym, sec) \ 57 | extern typeof(sym) sym; \ 58 | __CRC_SYMBOL(sym, sec) \ 59 | static const char __kstrtab_##sym[] \ 60 | __attribute__((section("__ksymtab_strings"), aligned(1))) \ 61 | = VMLINUX_SYMBOL_STR(sym); \ 62 | extern const struct kernel_symbol __ksymtab_##sym; \ 63 | __visible const struct kernel_symbol __ksymtab_##sym \ 64 | __used \ 65 | __attribute__((section("___ksymtab" sec "+" #sym), unused)) \ 66 | = { (unsigned long)&sym, __kstrtab_##sym } 67 | 68 | #define EXPORT_SYMBOL(sym) \ 69 | __EXPORT_SYMBOL(sym, "") 70 | 71 | #define EXPORT_SYMBOL_GPL(sym) \ 72 | __EXPORT_SYMBOL(sym, "_gpl") 73 | 74 | #define EXPORT_SYMBOL_GPL_FUTURE(sym) \ 75 | __EXPORT_SYMBOL(sym, "_gpl_future") 76 | 77 | #ifdef CONFIG_UNUSED_SYMBOLS 78 | #define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused") 79 | #define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl") 80 | #else 81 | #define EXPORT_UNUSED_SYMBOL(sym) 82 | #define EXPORT_UNUSED_SYMBOL_GPL(sym) 83 | #endif 84 | 85 | #endif /* __GENKSYMS__ */ 86 | 87 | #else /* !CONFIG_MODULES... */ 88 | 89 | #define EXPORT_SYMBOL(sym) 90 | #define EXPORT_SYMBOL_GPL(sym) 91 | #define EXPORT_SYMBOL_GPL_FUTURE(sym) 92 | #define EXPORT_UNUSED_SYMBOL(sym) 93 | #define EXPORT_UNUSED_SYMBOL_GPL(sym) 94 | 95 | #endif /* CONFIG_MODULES */ 96 | #endif /* !__ASSEMBLY__ */ 97 | 98 | #endif /* _LINUX_EXPORT_H */ 99 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/linux/hid-debug.h: -------------------------------------------------------------------------------- 1 | #ifndef __HID_DEBUG_H 2 | #define __HID_DEBUG_H 3 | 4 | /* 5 | * Copyright (c) 2007-2009 Jiri Kosina 6 | */ 7 | 8 | /* 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | */ 24 | 25 | #define HID_DEBUG_BUFSIZE 512 26 | 27 | #ifdef CONFIG_DEBUG_FS 28 | 29 | void hid_dump_input(struct hid_device *, struct hid_usage *, __s32); 30 | void hid_dump_device(struct hid_device *, struct seq_file *); 31 | void hid_dump_field(struct hid_field *, int, struct seq_file *); 32 | char *hid_resolv_usage(unsigned, struct seq_file *); 33 | void hid_debug_register(struct hid_device *, const char *); 34 | void hid_debug_unregister(struct hid_device *); 35 | void hid_debug_init(void); 36 | void hid_debug_exit(void); 37 | void hid_debug_event(struct hid_device *, char *); 38 | 39 | 40 | struct hid_debug_list { 41 | char *hid_debug_buf; 42 | int head; 43 | int tail; 44 | struct fasync_struct *fasync; 45 | struct hid_device *hdev; 46 | struct list_head node; 47 | struct mutex read_mutex; 48 | }; 49 | 50 | #else 51 | 52 | #define hid_dump_input(a,b,c) do { } while (0) 53 | #define hid_dump_device(a,b) do { } while (0) 54 | #define hid_dump_field(a,b,c) do { } while (0) 55 | #define hid_resolv_usage(a,b) do { } while (0) 56 | #define hid_debug_register(a, b) do { } while (0) 57 | #define hid_debug_unregister(a) do { } while (0) 58 | #define hid_debug_init() do { } while (0) 59 | #define hid_debug_exit() do { } while (0) 60 | #define hid_debug_event(a,b) do { } while (0) 61 | 62 | #endif 63 | 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/linux/hidraw.h: -------------------------------------------------------------------------------- 1 | #ifndef _HIDRAW_H 2 | #define _HIDRAW_H 3 | 4 | /* 5 | * Copyright (c) 2007 Jiri Kosina 6 | */ 7 | 8 | /* 9 | * This program is free software; you can redistribute it and/or modify it 10 | * under the terms and conditions of the GNU General Public License, 11 | * version 2, as published by the Free Software Foundation. 12 | * 13 | * You should have received a copy of the GNU General Public License along with 14 | * this program; if not, write to the Free Software Foundation, Inc., 15 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | struct hidraw_report_descriptor { 22 | __u32 size; 23 | __u8 value[HID_MAX_DESCRIPTOR_SIZE]; 24 | }; 25 | 26 | struct hidraw_devinfo { 27 | __u32 bustype; 28 | __s16 vendor; 29 | __s16 product; 30 | }; 31 | 32 | /* ioctl interface */ 33 | #define HIDIOCGRDESCSIZE _IOR('H', 0x01, int) 34 | #define HIDIOCGRDESC _IOR('H', 0x02, struct hidraw_report_descriptor) 35 | #define HIDIOCGRAWINFO _IOR('H', 0x03, struct hidraw_devinfo) 36 | #define HIDIOCGRAWNAME(len) _IOC(_IOC_READ, 'H', 0x04, len) 37 | #define HIDIOCGRAWPHYS(len) _IOC(_IOC_READ, 'H', 0x05, len) 38 | /* The first byte of SFEATURE and GFEATURE is the report number */ 39 | #define HIDIOCSFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len) 40 | #define HIDIOCGFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len) 41 | 42 | #define HIDRAW_FIRST_MINOR 0 43 | #define HIDRAW_MAX_DEVICES 64 44 | /* number of reports to buffer */ 45 | #define HIDRAW_BUFFER_SIZE 64 46 | 47 | 48 | /* kernel-only API declarations */ 49 | #ifdef __KERNEL__ 50 | 51 | struct hidraw { 52 | unsigned int minor; 53 | int exist; 54 | int open; 55 | wait_queue_head_t wait; 56 | struct hid_device *hid; 57 | struct device *dev; 58 | struct list_head list; 59 | }; 60 | 61 | struct hidraw_report { 62 | __u8 *value; 63 | int len; 64 | }; 65 | 66 | struct hidraw_list { 67 | struct hidraw_report buffer[HIDRAW_BUFFER_SIZE]; 68 | int head; 69 | int tail; 70 | struct fasync_struct *fasync; 71 | struct hidraw *hidraw; 72 | struct list_head node; 73 | struct mutex read_mutex; 74 | }; 75 | 76 | #ifdef CONFIG_HIDRAW 77 | int hidraw_init(void); 78 | void hidraw_exit(void); 79 | int hidraw_report_event(struct hid_device *, u8 *, int); 80 | int hidraw_connect(struct hid_device *); 81 | void hidraw_disconnect(struct hid_device *); 82 | #else 83 | static inline int hidraw_init(void) { return 0; } 84 | static inline void hidraw_exit(void) { } 85 | static inline int hidraw_report_event(struct hid_device *hid, u8 *data, int len) { return 0; } 86 | static inline int hidraw_connect(struct hid_device *hid) { return -1; } 87 | static inline void hidraw_disconnect(struct hid_device *hid) { } 88 | #endif 89 | 90 | #endif 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/linux/unaligned/access_ok.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_ACCESS_OK_H 2 | #define _LINUX_UNALIGNED_ACCESS_OK_H 3 | 4 | #include 5 | #include 6 | 7 | static inline u16 get_unaligned_le16(const void *p) 8 | { 9 | return le16_to_cpup((__le16 *)p); 10 | } 11 | 12 | static inline u32 get_unaligned_le32(const void *p) 13 | { 14 | return le32_to_cpup((__le32 *)p); 15 | } 16 | 17 | static inline u64 get_unaligned_le64(const void *p) 18 | { 19 | return le64_to_cpup((__le64 *)p); 20 | } 21 | 22 | static inline u16 get_unaligned_be16(const void *p) 23 | { 24 | return be16_to_cpup((__be16 *)p); 25 | } 26 | 27 | static inline u32 get_unaligned_be32(const void *p) 28 | { 29 | return be32_to_cpup((__be32 *)p); 30 | } 31 | 32 | static inline u64 get_unaligned_be64(const void *p) 33 | { 34 | return be64_to_cpup((__be64 *)p); 35 | } 36 | 37 | static inline void put_unaligned_le16(u16 val, void *p) 38 | { 39 | *((__le16 *)p) = cpu_to_le16(val); 40 | } 41 | 42 | static inline void put_unaligned_le32(u32 val, void *p) 43 | { 44 | *((__le32 *)p) = cpu_to_le32(val); 45 | } 46 | 47 | static inline void put_unaligned_le64(u64 val, void *p) 48 | { 49 | *((__le64 *)p) = cpu_to_le64(val); 50 | } 51 | 52 | static inline void put_unaligned_be16(u16 val, void *p) 53 | { 54 | *((__be16 *)p) = cpu_to_be16(val); 55 | } 56 | 57 | static inline void put_unaligned_be32(u32 val, void *p) 58 | { 59 | *((__be32 *)p) = cpu_to_be32(val); 60 | } 61 | 62 | static inline void put_unaligned_be64(u64 val, void *p) 63 | { 64 | *((__be64 *)p) = cpu_to_be64(val); 65 | } 66 | 67 | #endif /* _LINUX_UNALIGNED_ACCESS_OK_H */ 68 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/linux/unaligned/be_byteshift.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_BE_BYTESHIFT_H 2 | #define _LINUX_UNALIGNED_BE_BYTESHIFT_H 3 | 4 | #include 5 | 6 | static inline u16 __get_unaligned_be16(const u8 *p) 7 | { 8 | return p[0] << 8 | p[1]; 9 | } 10 | 11 | static inline u32 __get_unaligned_be32(const u8 *p) 12 | { 13 | return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]; 14 | } 15 | 16 | static inline u64 __get_unaligned_be64(const u8 *p) 17 | { 18 | return (u64)__get_unaligned_be32(p) << 32 | 19 | __get_unaligned_be32(p + 4); 20 | } 21 | 22 | static inline void __put_unaligned_be16(u16 val, u8 *p) 23 | { 24 | *p++ = val >> 8; 25 | *p++ = val; 26 | } 27 | 28 | static inline void __put_unaligned_be32(u32 val, u8 *p) 29 | { 30 | __put_unaligned_be16(val >> 16, p); 31 | __put_unaligned_be16(val, p + 2); 32 | } 33 | 34 | static inline void __put_unaligned_be64(u64 val, u8 *p) 35 | { 36 | __put_unaligned_be32(val >> 32, p); 37 | __put_unaligned_be32(val, p + 4); 38 | } 39 | 40 | static inline u16 get_unaligned_be16(const void *p) 41 | { 42 | return __get_unaligned_be16((const u8 *)p); 43 | } 44 | 45 | static inline u32 get_unaligned_be32(const void *p) 46 | { 47 | return __get_unaligned_be32((const u8 *)p); 48 | } 49 | 50 | static inline u64 get_unaligned_be64(const void *p) 51 | { 52 | return __get_unaligned_be64((const u8 *)p); 53 | } 54 | 55 | static inline void put_unaligned_be16(u16 val, void *p) 56 | { 57 | __put_unaligned_be16(val, p); 58 | } 59 | 60 | static inline void put_unaligned_be32(u32 val, void *p) 61 | { 62 | __put_unaligned_be32(val, p); 63 | } 64 | 65 | static inline void put_unaligned_be64(u64 val, void *p) 66 | { 67 | __put_unaligned_be64(val, p); 68 | } 69 | 70 | #endif /* _LINUX_UNALIGNED_BE_BYTESHIFT_H */ 71 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/linux/unaligned/be_memmove.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_BE_MEMMOVE_H 2 | #define _LINUX_UNALIGNED_BE_MEMMOVE_H 3 | 4 | #include 5 | 6 | static inline u16 get_unaligned_be16(const void *p) 7 | { 8 | return __get_unaligned_memmove16((const u8 *)p); 9 | } 10 | 11 | static inline u32 get_unaligned_be32(const void *p) 12 | { 13 | return __get_unaligned_memmove32((const u8 *)p); 14 | } 15 | 16 | static inline u64 get_unaligned_be64(const void *p) 17 | { 18 | return __get_unaligned_memmove64((const u8 *)p); 19 | } 20 | 21 | static inline void put_unaligned_be16(u16 val, void *p) 22 | { 23 | __put_unaligned_memmove16(val, p); 24 | } 25 | 26 | static inline void put_unaligned_be32(u32 val, void *p) 27 | { 28 | __put_unaligned_memmove32(val, p); 29 | } 30 | 31 | static inline void put_unaligned_be64(u64 val, void *p) 32 | { 33 | __put_unaligned_memmove64(val, p); 34 | } 35 | 36 | #endif /* _LINUX_UNALIGNED_LE_MEMMOVE_H */ 37 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/linux/unaligned/be_struct.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_BE_STRUCT_H 2 | #define _LINUX_UNALIGNED_BE_STRUCT_H 3 | 4 | #include 5 | 6 | static inline u16 get_unaligned_be16(const void *p) 7 | { 8 | return __get_unaligned_cpu16((const u8 *)p); 9 | } 10 | 11 | static inline u32 get_unaligned_be32(const void *p) 12 | { 13 | return __get_unaligned_cpu32((const u8 *)p); 14 | } 15 | 16 | static inline u64 get_unaligned_be64(const void *p) 17 | { 18 | return __get_unaligned_cpu64((const u8 *)p); 19 | } 20 | 21 | static inline void put_unaligned_be16(u16 val, void *p) 22 | { 23 | __put_unaligned_cpu16(val, p); 24 | } 25 | 26 | static inline void put_unaligned_be32(u32 val, void *p) 27 | { 28 | __put_unaligned_cpu32(val, p); 29 | } 30 | 31 | static inline void put_unaligned_be64(u64 val, void *p) 32 | { 33 | __put_unaligned_cpu64(val, p); 34 | } 35 | 36 | #endif /* _LINUX_UNALIGNED_BE_STRUCT_H */ 37 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/linux/unaligned/generic.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_GENERIC_H 2 | #define _LINUX_UNALIGNED_GENERIC_H 3 | 4 | /* 5 | * Cause a link-time error if we try an unaligned access other than 6 | * 1,2,4 or 8 bytes long 7 | */ 8 | extern void __bad_unaligned_access_size(void); 9 | 10 | #define __get_unaligned_le(ptr) ((__force typeof(*(ptr)))({ \ 11 | __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \ 12 | __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_le16((ptr)), \ 13 | __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_le32((ptr)), \ 14 | __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_le64((ptr)), \ 15 | __bad_unaligned_access_size())))); \ 16 | })) 17 | 18 | #define __get_unaligned_be(ptr) ((__force typeof(*(ptr)))({ \ 19 | __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \ 20 | __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_be16((ptr)), \ 21 | __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_be32((ptr)), \ 22 | __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_be64((ptr)), \ 23 | __bad_unaligned_access_size())))); \ 24 | })) 25 | 26 | #define __put_unaligned_le(val, ptr) ({ \ 27 | void *__gu_p = (ptr); \ 28 | switch (sizeof(*(ptr))) { \ 29 | case 1: \ 30 | *(u8 *)__gu_p = (__force u8)(val); \ 31 | break; \ 32 | case 2: \ 33 | put_unaligned_le16((__force u16)(val), __gu_p); \ 34 | break; \ 35 | case 4: \ 36 | put_unaligned_le32((__force u32)(val), __gu_p); \ 37 | break; \ 38 | case 8: \ 39 | put_unaligned_le64((__force u64)(val), __gu_p); \ 40 | break; \ 41 | default: \ 42 | __bad_unaligned_access_size(); \ 43 | break; \ 44 | } \ 45 | (void)0; }) 46 | 47 | #define __put_unaligned_be(val, ptr) ({ \ 48 | void *__gu_p = (ptr); \ 49 | switch (sizeof(*(ptr))) { \ 50 | case 1: \ 51 | *(u8 *)__gu_p = (__force u8)(val); \ 52 | break; \ 53 | case 2: \ 54 | put_unaligned_be16((__force u16)(val), __gu_p); \ 55 | break; \ 56 | case 4: \ 57 | put_unaligned_be32((__force u32)(val), __gu_p); \ 58 | break; \ 59 | case 8: \ 60 | put_unaligned_be64((__force u64)(val), __gu_p); \ 61 | break; \ 62 | default: \ 63 | __bad_unaligned_access_size(); \ 64 | break; \ 65 | } \ 66 | (void)0; }) 67 | 68 | #endif /* _LINUX_UNALIGNED_GENERIC_H */ 69 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/linux/unaligned/le_byteshift.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_LE_BYTESHIFT_H 2 | #define _LINUX_UNALIGNED_LE_BYTESHIFT_H 3 | 4 | #include 5 | 6 | static inline u16 __get_unaligned_le16(const u8 *p) 7 | { 8 | return p[0] | p[1] << 8; 9 | } 10 | 11 | static inline u32 __get_unaligned_le32(const u8 *p) 12 | { 13 | return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; 14 | } 15 | 16 | static inline u64 __get_unaligned_le64(const u8 *p) 17 | { 18 | return (u64)__get_unaligned_le32(p + 4) << 32 | 19 | __get_unaligned_le32(p); 20 | } 21 | 22 | static inline void __put_unaligned_le16(u16 val, u8 *p) 23 | { 24 | *p++ = val; 25 | *p++ = val >> 8; 26 | } 27 | 28 | static inline void __put_unaligned_le32(u32 val, u8 *p) 29 | { 30 | __put_unaligned_le16(val >> 16, p + 2); 31 | __put_unaligned_le16(val, p); 32 | } 33 | 34 | static inline void __put_unaligned_le64(u64 val, u8 *p) 35 | { 36 | __put_unaligned_le32(val >> 32, p + 4); 37 | __put_unaligned_le32(val, p); 38 | } 39 | 40 | static inline u16 get_unaligned_le16(const void *p) 41 | { 42 | return __get_unaligned_le16((const u8 *)p); 43 | } 44 | 45 | static inline u32 get_unaligned_le32(const void *p) 46 | { 47 | return __get_unaligned_le32((const u8 *)p); 48 | } 49 | 50 | static inline u64 get_unaligned_le64(const void *p) 51 | { 52 | return __get_unaligned_le64((const u8 *)p); 53 | } 54 | 55 | static inline void put_unaligned_le16(u16 val, void *p) 56 | { 57 | __put_unaligned_le16(val, p); 58 | } 59 | 60 | static inline void put_unaligned_le32(u32 val, void *p) 61 | { 62 | __put_unaligned_le32(val, p); 63 | } 64 | 65 | static inline void put_unaligned_le64(u64 val, void *p) 66 | { 67 | __put_unaligned_le64(val, p); 68 | } 69 | 70 | #endif /* _LINUX_UNALIGNED_LE_BYTESHIFT_H */ 71 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/linux/unaligned/le_memmove.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_LE_MEMMOVE_H 2 | #define _LINUX_UNALIGNED_LE_MEMMOVE_H 3 | 4 | #include 5 | 6 | static inline u16 get_unaligned_le16(const void *p) 7 | { 8 | return __get_unaligned_memmove16((const u8 *)p); 9 | } 10 | 11 | static inline u32 get_unaligned_le32(const void *p) 12 | { 13 | return __get_unaligned_memmove32((const u8 *)p); 14 | } 15 | 16 | static inline u64 get_unaligned_le64(const void *p) 17 | { 18 | return __get_unaligned_memmove64((const u8 *)p); 19 | } 20 | 21 | static inline void put_unaligned_le16(u16 val, void *p) 22 | { 23 | __put_unaligned_memmove16(val, p); 24 | } 25 | 26 | static inline void put_unaligned_le32(u32 val, void *p) 27 | { 28 | __put_unaligned_memmove32(val, p); 29 | } 30 | 31 | static inline void put_unaligned_le64(u64 val, void *p) 32 | { 33 | __put_unaligned_memmove64(val, p); 34 | } 35 | 36 | #endif /* _LINUX_UNALIGNED_LE_MEMMOVE_H */ 37 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/linux/unaligned/le_struct.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_LE_STRUCT_H 2 | #define _LINUX_UNALIGNED_LE_STRUCT_H 3 | 4 | #include 5 | 6 | static inline u16 get_unaligned_le16(const void *p) 7 | { 8 | return __get_unaligned_cpu16((const u8 *)p); 9 | } 10 | 11 | static inline u32 get_unaligned_le32(const void *p) 12 | { 13 | return __get_unaligned_cpu32((const u8 *)p); 14 | } 15 | 16 | static inline u64 get_unaligned_le64(const void *p) 17 | { 18 | return __get_unaligned_cpu64((const u8 *)p); 19 | } 20 | 21 | static inline void put_unaligned_le16(u16 val, void *p) 22 | { 23 | __put_unaligned_cpu16(val, p); 24 | } 25 | 26 | static inline void put_unaligned_le32(u32 val, void *p) 27 | { 28 | __put_unaligned_cpu32(val, p); 29 | } 30 | 31 | static inline void put_unaligned_le64(u64 val, void *p) 32 | { 33 | __put_unaligned_cpu64(val, p); 34 | } 35 | 36 | #endif /* _LINUX_UNALIGNED_LE_STRUCT_H */ 37 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/linux/unaligned/memmove.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_MEMMOVE_H 2 | #define _LINUX_UNALIGNED_MEMMOVE_H 3 | 4 | #include 5 | #include 6 | 7 | /* Use memmove here, so gcc does not insert a __builtin_memcpy. */ 8 | 9 | static inline u16 __get_unaligned_memmove16(const void *p) 10 | { 11 | u16 tmp; 12 | memmove(&tmp, p, 2); 13 | return tmp; 14 | } 15 | 16 | static inline u32 __get_unaligned_memmove32(const void *p) 17 | { 18 | u32 tmp; 19 | memmove(&tmp, p, 4); 20 | return tmp; 21 | } 22 | 23 | static inline u64 __get_unaligned_memmove64(const void *p) 24 | { 25 | u64 tmp; 26 | memmove(&tmp, p, 8); 27 | return tmp; 28 | } 29 | 30 | static inline void __put_unaligned_memmove16(u16 val, void *p) 31 | { 32 | memmove(p, &val, 2); 33 | } 34 | 35 | static inline void __put_unaligned_memmove32(u32 val, void *p) 36 | { 37 | memmove(p, &val, 4); 38 | } 39 | 40 | static inline void __put_unaligned_memmove64(u64 val, void *p) 41 | { 42 | memmove(p, &val, 8); 43 | } 44 | 45 | #endif /* _LINUX_UNALIGNED_MEMMOVE_H */ 46 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/linux/unaligned/packed_struct.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_PACKED_STRUCT_H 2 | #define _LINUX_UNALIGNED_PACKED_STRUCT_H 3 | 4 | #include 5 | 6 | struct __una_u16 { u16 x; } __packed; 7 | struct __una_u32 { u32 x; } __packed; 8 | struct __una_u64 { u64 x; } __packed; 9 | 10 | static inline u16 __get_unaligned_cpu16(const void *p) 11 | { 12 | const struct __una_u16 *ptr = (const struct __una_u16 *)p; 13 | return ptr->x; 14 | } 15 | 16 | static inline u32 __get_unaligned_cpu32(const void *p) 17 | { 18 | const struct __una_u32 *ptr = (const struct __una_u32 *)p; 19 | return ptr->x; 20 | } 21 | 22 | static inline u64 __get_unaligned_cpu64(const void *p) 23 | { 24 | const struct __una_u64 *ptr = (const struct __una_u64 *)p; 25 | return ptr->x; 26 | } 27 | 28 | static inline void __put_unaligned_cpu16(u16 val, void *p) 29 | { 30 | struct __una_u16 *ptr = (struct __una_u16 *)p; 31 | ptr->x = val; 32 | } 33 | 34 | static inline void __put_unaligned_cpu32(u32 val, void *p) 35 | { 36 | struct __una_u32 *ptr = (struct __una_u32 *)p; 37 | ptr->x = val; 38 | } 39 | 40 | static inline void __put_unaligned_cpu64(u64 val, void *p) 41 | { 42 | struct __una_u64 *ptr = (struct __una_u64 *)p; 43 | ptr->x = val; 44 | } 45 | 46 | #endif /* _LINUX_UNALIGNED_PACKED_STRUCT_H */ 47 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/linux/uuid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UUID/GUID definition 3 | * 4 | * Copyright (C) 2010, Intel Corp. 5 | * Huang Ying 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License version 9 | * 2 as published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | #ifndef _LINUX_UUID_H_ 21 | #define _LINUX_UUID_H_ 22 | 23 | #include "../uapi/linux/uuid.h" 24 | 25 | 26 | static inline int uuid_le_cmp(const uuid_le u1, const uuid_le u2) 27 | { 28 | return memcmp(&u1, &u2, sizeof(uuid_le)); 29 | } 30 | 31 | static inline int uuid_be_cmp(const uuid_be u1, const uuid_be u2) 32 | { 33 | return memcmp(&u1, &u2, sizeof(uuid_be)); 34 | } 35 | 36 | extern void uuid_le_gen(uuid_le *u); 37 | extern void uuid_be_gen(uuid_be *u); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/include/uapi/linux/uuid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UUID/GUID definition 3 | * 4 | * Copyright (C) 2010, Intel Corp. 5 | * Huang Ying 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License version 9 | * 2 as published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef _UAPI_LINUX_UUID_H_ 22 | #define _UAPI_LINUX_UUID_H_ 23 | 24 | #include 25 | #ifdef __KERNEL__ 26 | #include 27 | #else 28 | #include 29 | #endif 30 | 31 | typedef struct { 32 | __u8 b[16]; 33 | } uuid_le; 34 | 35 | typedef struct { 36 | __u8 b[16]; 37 | } uuid_be; 38 | 39 | #define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ 40 | ((uuid_le) \ 41 | {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ 42 | (b) & 0xff, ((b) >> 8) & 0xff, \ 43 | (c) & 0xff, ((c) >> 8) & 0xff, \ 44 | (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) 45 | 46 | #define UUID_BE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ 47 | ((uuid_be) \ 48 | {{ ((a) >> 24) & 0xff, ((a) >> 16) & 0xff, ((a) >> 8) & 0xff, (a) & 0xff, \ 49 | ((b) >> 8) & 0xff, (b) & 0xff, \ 50 | ((c) >> 8) & 0xff, (c) & 0xff, \ 51 | (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) 52 | 53 | #define NULL_UUID_LE \ 54 | UUID_LE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, \ 55 | 0x00, 0x00, 0x00, 0x00) 56 | 57 | #define NULL_UUID_BE \ 58 | UUID_BE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, \ 59 | 0x00, 0x00, 0x00, 0x00) 60 | 61 | 62 | #endif /* _UAPI_LINUX_UUID_H_ */ 63 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/overrides.mk: -------------------------------------------------------------------------------- 1 | _HV_CPPFLAGS += -I$(M)/include 2 | 3 | EXTRA_CFLAGS += $(_HV_CPPFLAGS) 4 | CPPFLAGS := -I$(M)/include $(CPPFLAGS) 5 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/rhel5-hv-driver-install: -------------------------------------------------------------------------------- 1 | echo "Building Modules" 2 | if [ "$KERNEL_VERSION" == "" ] 3 | then 4 | KERNEL_VERSION=$(uname -r) 5 | fi 6 | 7 | make -C /lib/modules/$KERNEL_VERSION/build M=`pwd` clean 8 | [ $? -eq 0 ] || exit 1 9 | 10 | make -C /lib/modules/$KERNEL_VERSION/build M=`pwd` modules 11 | [ $? -eq 0 ] || exit 1 12 | 13 | echo "Installing Modules" 14 | cp -f ./*.ko /lib/modules/$KERNEL_VERSION/extra/ 15 | [ $? -eq 0 ] || exit 1 16 | 17 | echo "Generating Module dependencies" 18 | depmod 19 | [ $? -eq 0 ] || exit 1 20 | 21 | echo "Installing Modprobe Rules" 22 | 23 | echo "Saving old initramfs" 24 | if [ ! -e /boot/"initrd-$KERNEL_VERSION.img-old" ] 25 | then 26 | cp -f /boot/"initrd-$KERNEL_VERSION.img" /boot/"initrd-$KERNEL_VERSION.img-old" 27 | fi 28 | 29 | echo "Generating initramfs" 30 | mkinitrd --preload=hv_storvsc "initrd-$KERNEL_VERSION.img" "$KERNEL_VERSION" 31 | [ $? -eq 0 ] || exit 1 32 | 33 | echo "Installing new initramfs" 34 | mv -f "initrd-$KERNEL_VERSION.img" /boot/"initrd-$KERNEL_VERSION.img" 35 | [ $? -eq 0 ] || exit 1 36 | 37 | echo "Config X-Window" 38 | cp -f ./xorg.conf /etc/X11/ 39 | 40 | echo "Completed" 41 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/rhel5-hv-driver-uninstall: -------------------------------------------------------------------------------- 1 | echo "Get rid of the Hyper-V drivers and modprobe rules" 2 | if [ "$KERNEL_VERSION" == "" ] 3 | then 4 | KERNEL_VERSION=$(uname -r) 5 | fi 6 | 7 | rm -f /etc/X11/xorg.conf 8 | 9 | rm -rf /lib/modules/$KERNEL_VERSION/extra/hv_*.ko 10 | rm -rf /lib/modules/$KERNEL_VERSION/extra/hid*.ko 11 | 12 | 13 | echo "Create and install initramfs without Hyper-V drivers" 14 | 15 | rm -f "initrd-$KERNEL_VERSION.img" 16 | 17 | mkinitrd "initrd-$KERNEL_VERSION.img" "$KERNEL_VERSION" 18 | 19 | mv -f "initrd-$KERNEL_VERSION.img" /boot/"initrd-$KERNEL_VERSION.img" 20 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/tools/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Hyper-V tools 2 | 3 | CC = $(CROSS_COMPILE)gcc 4 | PTHREAD_LIBS = -lpthread 5 | WARNINGS = -Wall -Wextra 6 | CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) $(shell getconf LFS_CFLAGS) 7 | 8 | CFLAGS += -D__EXPORTED_HEADERS__ -I../include/uapi -I ../include 9 | 10 | # Get RHEL/CentOS version information 11 | rhel_major=$(shell grep -Eoh [0-9]+\.[0-9]+ /etc/{issue,*release} | head -1 | awk -F'.' '{ print $$1 }') 12 | rhel_minor=$(shell grep -Eoh [0-9]+\.[0-9]+ /etc/{issue,*release} | head -1 | awk -F'.' '{ print $$2 }') 13 | rhel_release_code=$(shell echo $$(($(rhel_major) << 8 | $(rhel_minor)))) 14 | 15 | # hv_vss_daemon will be compiled only on RHEL5.4 and higher. 16 | buildsnapshot=$(shell test $(rhel_release_code) -lt 1284; echo $$?) 17 | ifeq ($(buildsnapshot),0) 18 | all: hv_kvp_daemon hv_fcopy_daemon 19 | %: %.c 20 | $(CC) $(CFLAGS) -o $@ $^ 21 | clean: 22 | $(RM) hv_kvp_daemon hv_fcopy_daemon 23 | 24 | else 25 | all: hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon 26 | %: %.c 27 | $(CC) $(CFLAGS) -o $@ $^ 28 | clean: 29 | $(RM) hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon 30 | endif 31 | 32 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/tools/hv_get_dhcp_info.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This example script retrieves the DHCP state of a given interface. 4 | # In the interest of keeping the KVP daemon code free of distro specific 5 | # information; the kvp daemon code invokes this external script to gather 6 | # DHCP setting for the specific interface. 7 | # 8 | # Input: Name of the interface 9 | # 10 | # Output: The script prints the string "Enabled" to stdout to indicate 11 | # that DHCP is enabled on the interface. If DHCP is not enabled, 12 | # the script prints the string "Disabled" to stdout. 13 | # 14 | # Each Distro is expected to implement this script in a distro specific 15 | # fashion. For instance on Distros that ship with Network Manager enabled, 16 | # this script can be based on the Network Manager APIs for retrieving DHCP 17 | # information. 18 | 19 | if_file="/etc/sysconfig/network-scripts/ifcfg-"$1 20 | 21 | dhcp=$(grep "dhcp" $if_file 2>/dev/null) 22 | 23 | if [ "$dhcp" != "" ]; 24 | then 25 | echo "Enabled" 26 | else 27 | echo "Disabled" 28 | fi 29 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/tools/hv_get_dns_info.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This example script parses /etc/resolv.conf to retrive DNS information. 4 | # In the interest of keeping the KVP daemon code free of distro specific 5 | # information; the kvp daemon code invokes this external script to gather 6 | # DNS information. 7 | # This script is expected to print the nameserver values to stdout. 8 | # Each Distro is expected to implement this script in a distro specific 9 | # fashion. For instance on Distros that ship with Network Manager enabled, 10 | # this script can be based on the Network Manager APIs for retrieving DNS 11 | # entries. 12 | 13 | cat /etc/resolv.conf 2>/dev/null | awk '/^nameserver/ { print $2 }' 14 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/tools/hv_set_ifconfig.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This example script activates an interface based on the specified 4 | # configuration. 5 | # 6 | # In the interest of keeping the KVP daemon code free of distro specific 7 | # information; the kvp daemon code invokes this external script to configure 8 | # the interface. 9 | # 10 | # The only argument to this script is the configuration file that is to 11 | # be used to configure the interface. 12 | # 13 | # Each Distro is expected to implement this script in a distro specific 14 | # fashion. For instance on Distros that ship with Network Manager enabled, 15 | # this script can be based on the Network Manager APIs for configuring the 16 | # interface. 17 | # 18 | # This example script is based on a RHEL environment. 19 | # 20 | # Here is the format of the ip configuration file: 21 | # 22 | # HWADDR=macaddr 23 | # DEVICE=interface name 24 | # BOOTPROTO= (where is "dhcp" if DHCP is configured 25 | # or "none" if no boot-time protocol should be used) 26 | # 27 | # IPADDR0=ipaddr1 28 | # IPADDR1=ipaddr2 29 | # IPADDRx=ipaddry (where y = x + 1) 30 | # 31 | # NETMASK0=netmask1 32 | # NETMASKx=netmasky (where y = x + 1) 33 | # 34 | # GATEWAY=ipaddr1 35 | # GATEWAYx=ipaddry (where y = x + 1) 36 | # 37 | # DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) 38 | # 39 | # IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be 40 | # tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as 41 | # IPV6NETMASK. 42 | # 43 | # The host can specify multiple ipv4 and ipv6 addresses to be 44 | # configured for the interface. Furthermore, the configuration 45 | # needs to be persistent. A subsequent GET call on the interface 46 | # is expected to return the configuration that is set via the SET 47 | # call. 48 | # 49 | 50 | 51 | 52 | echo "IPV6INIT=yes" >> $1 53 | echo "NM_CONTROLLED=no" >> $1 54 | echo "PEERDNS=yes" >> $1 55 | echo "ONBOOT=yes" >> $1 56 | 57 | sed -i 's/IPADDR0/IPADDR/g' $1 58 | sed -i 's/NETMASK0/NETMASK/g' $1 59 | 60 | cp $1 /etc/sysconfig/network-scripts/ 61 | 62 | 63 | interface=$(echo $1 | awk -F - '{ print $2 }') 64 | 65 | /sbin/ifdown $interface 2>/dev/null 66 | /sbin/ifup $interface 2>/dev/null 67 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/tools/lsvmbus: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | from optparse import OptionParser 5 | 6 | parser = OptionParser() 7 | parser.add_option("-v", "--verbose", dest="verbose", 8 | help="print verbose messages. Try -vv, -vvv for \ 9 | more verbose messages", action="count") 10 | 11 | (options, args) = parser.parse_args() 12 | 13 | verbose = 0 14 | if options.verbose is not None: 15 | verbose = options.verbose 16 | 17 | vmbus_sys_path = '/sys/bus/vmbus/devices' 18 | if not os.path.isdir(vmbus_sys_path): 19 | print "%s doesn't exist: exiting..." % vmbus_sys_path 20 | exit(-1) 21 | 22 | vmbus_dev_dict = { 23 | '{0e0b6031-5213-4934-818b-38d90ced39db}' : '[Operating system shutdown]', 24 | '{9527e630-d0ae-497b-adce-e80ab0175caf}' : '[Time Synchronization]', 25 | '{57164f39-9115-4e78-ab55-382f3bd5422d}' : '[Heartbeat]', 26 | '{a9a0f4e7-5a45-4d96-b827-8a841e8c03e6}' : '[Data Exchange]', 27 | '{35fa2e29-ea23-4236-96ae-3a6ebacba440}' : '[Backup (volume checkpoint)]', 28 | '{34d14be3-dee4-41c8-9ae7-6b174977c192}' : '[Guest services]', 29 | '{525074dc-8985-46e2-8057-a307dc18a502}' : '[Dynamic Memory]', 30 | '{cfa8b69e-5b4a-4cc0-b98b-8ba1a1f3f95a}' : 'Synthetic mouse', 31 | '{f912ad6d-2b17-48ea-bd65-f927a61c7684}' : 'Synthetic keyboard', 32 | '{da0a7802-e377-4aac-8e77-0558eb1073f8}' : 'Synthetic framebuffer adapter', 33 | '{f8615163-df3e-46c5-913f-f2d2f965ed0e}' : 'Synthetic network adapter', 34 | '{32412632-86cb-44a2-9b5c-50d1417354f5}' : 'Synthetic IDE Controller', 35 | '{ba6163d9-04a1-4d29-b605-72e2ffb1dc7f}' : 'Synthetic SCSI Controller', 36 | '{2f9bcc4a-0069-4af3-b76b-6fd0be528cda}' : 'Synthetic fiber channel adapter', 37 | '{8c2eaf3d-32a7-4b09-ab99-bd1f1c86b501}' : 'Synthetic RDMA adapter', 38 | '{276aacf4-ac15-426c-98dd-7521ad3f01fe}' : '[Reserved system device]', 39 | '{f8e65716-3cb3-4a06-9a60-1889c5cccab5}' : '[Reserved system device]', 40 | '{3375baf4-9e15-4b30-b765-67acb10d607b}' : '[Reserved system device]', 41 | } 42 | 43 | def get_vmbus_dev_attr(dev_name, attr): 44 | try: 45 | f = open('%s/%s/%s' % (vmbus_sys_path, dev_name, attr), 'r') 46 | lines = f.readlines() 47 | f.close() 48 | except IOError: 49 | lines = [] 50 | 51 | return lines 52 | 53 | class VMBus_Dev: 54 | pass 55 | 56 | 57 | vmbus_dev_list = [] 58 | 59 | for f in os.listdir(vmbus_sys_path): 60 | vmbus_id = get_vmbus_dev_attr(f, 'id')[0].strip() 61 | class_id = get_vmbus_dev_attr(f, 'class_id')[0].strip() 62 | device_id = get_vmbus_dev_attr(f, 'device_id')[0].strip() 63 | dev_desc = vmbus_dev_dict.get(class_id, 'Unknown') 64 | 65 | chn_vp_mapping = get_vmbus_dev_attr(f, 'channel_vp_mapping') 66 | chn_vp_mapping = [c.strip() for c in chn_vp_mapping] 67 | chn_vp_mapping = sorted(chn_vp_mapping, 68 | key = lambda c : int(c.split(':')[0])) 69 | 70 | chn_vp_mapping = ['\tRel_ID=%s, target_cpu=%s' % 71 | (c.split(':')[0], c.split(':')[1]) 72 | for c in chn_vp_mapping] 73 | d = VMBus_Dev() 74 | d.sysfs_path = '%s/%s' % (vmbus_sys_path, f) 75 | d.vmbus_id = vmbus_id 76 | d.class_id = class_id 77 | d.device_id = device_id 78 | d.dev_desc = dev_desc 79 | d.chn_vp_mapping = '\n'.join(chn_vp_mapping) 80 | if d.chn_vp_mapping: 81 | d.chn_vp_mapping += '\n' 82 | 83 | vmbus_dev_list.append(d) 84 | 85 | 86 | vmbus_dev_list = sorted(vmbus_dev_list, key = lambda d : int(d.vmbus_id)) 87 | 88 | format0 = '%2s: %s' 89 | format1 = '%2s: Class_ID = %s - %s\n%s' 90 | format2 = '%2s: Class_ID = %s - %s\n\tDevice_ID = %s\n\tSysfs path: %s\n%s' 91 | 92 | for d in vmbus_dev_list: 93 | if verbose == 0: 94 | print ('VMBUS ID ' + format0) % (d.vmbus_id, d.dev_desc) 95 | elif verbose == 1: 96 | print ('VMBUS ID ' + format1) % \ 97 | (d.vmbus_id, d.class_id, d.dev_desc, d.chn_vp_mapping) 98 | else: 99 | print ('VMBUS ID ' + format2) % \ 100 | (d.vmbus_id, d.class_id, d.dev_desc, \ 101 | d.device_id, d.sysfs_path, d.chn_vp_mapping) 102 | -------------------------------------------------------------------------------- /hv-rhel5.x/hv/xorg.conf: -------------------------------------------------------------------------------- 1 | # Xorg configuration created by pyxf86config 2 | 3 | Section "ServerLayout" 4 | Identifier "Default Layout" 5 | Screen 0 "Screen0" 0 0 6 | InputDevice "Keyboard0" "CoreKeyboard" 7 | EndSection 8 | 9 | Section "ServerFlags" 10 | Option "AllowMouseOpenFail" "yes" 11 | EndSection 12 | 13 | Section "InputDevice" 14 | Identifier "Keyboard0" 15 | Driver "kbd" 16 | Option "XkbModel" "pc105" 17 | Option "XkbLayout" "us" 18 | EndSection 19 | 20 | Section "Device" 21 | Identifier "Videocard0" 22 | Driver "fbdev" 23 | EndSection 24 | 25 | Section "Screen" 26 | Identifier "Screen0" 27 | Device "Videocard0" 28 | EndSection 29 | 30 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/Kconfig: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | 3 | menu "Microsoft Hyper-V guest support" 4 | 5 | config HYPERV 6 | tristate "Microsoft Hyper-V client drivers" 7 | depends on X86 && ACPI && PCI && X86_LOCAL_APIC && HYPERVISOR_GUEST 8 | help 9 | Select this option to run Linux as a Hyper-V client operating 10 | system. 11 | 12 | config HYPERV_UTILS 13 | tristate "Microsoft Hyper-V Utilities driver" 14 | depends on HYPERV && CONNECTOR && NLS 15 | help 16 | Select this option to enable the Hyper-V Utilities. 17 | 18 | config HYPERV_BALLOON 19 | tristate "Microsoft Hyper-V Balloon driver" 20 | depends on HYPERV 21 | help 22 | Select this option to enable Hyper-V Balloon driver. 23 | 24 | endmenu 25 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/Makefile: -------------------------------------------------------------------------------- 1 | obj-m += hv_vmbus.o 2 | obj-m += hv_storvsc.o 3 | obj-m += hv_netvsc.o 4 | obj-m += hv_utils.o 5 | obj-m += hid-hyperv.o 6 | obj-m += hyperv_fb.o 7 | obj-m += hv_balloon.o 8 | obj-m += hyperv-keyboard.o 9 | 10 | # Get RHEL/CentOS version information 11 | rhel_major=$(shell grep -Eoh [0-9]+\.[0-9]+ /etc/{issue,*release} | head -1 | awk -F'.' '{ print $$1 }') 12 | rhel_minor=$(shell grep -Eoh [0-9]+\.[0-9]+ /etc/{issue,*release} | head -1 | awk -F'.' '{ print $$2 }') 13 | rhel_release_code=$(shell echo $$(($(rhel_major) << 8 | $(rhel_minor)))) 14 | 15 | # Get machine bit length 16 | arch=$(shell getconf LONG_BIT) 17 | 18 | # RDMA should only build on RHEL/CentOS 6.5 or later, and on 64 bits arch 19 | buildrdma=$(shell test $(rhel_release_code) -ge 1541; echo $$?) 20 | ifeq ($(buildrdma),0) 21 | ifeq ($(arch), 64) 22 | obj-m += hv_network_direct.o 23 | endif 24 | endif 25 | 26 | # UIO underlying function are not yet in rhel6.x so make it conditional for future release 27 | buildrdma=$(shell test $(rhel_release_code) -ge 1545; echo $$?) 28 | ifeq ($(buildrdma),0) 29 | ifeq ($(arch), 64) 30 | obj-m += uio_hv_generic.o 31 | endif 32 | endif 33 | 34 | #Make it conditional for PCI driver to build 6.7 and above. 35 | build_pci=$(shell test $(rhel_release_code) -ge 1543; echo $$?) 36 | ifeq ($(build_pci),0) 37 | obj-m += pci-hyperv.o 38 | endif 39 | 40 | ccflags-y += -I$(M)/include/ -I$(M)/arch/$(SRCARCH)/include -I$(M)/arch/$(SRCARCH)/include/uapi 41 | 42 | # Get extra kernel version information beyond LINUX_VERSION_CODE or RHEL_RELEASE_CODE. 43 | # This is used to identify RHEL/CentOS kernel update versions. 44 | extraversioninfo = $(shell uname -r | awk -F'-' '{print $$2}') 45 | ifdef KERNEL_VERSION 46 | extraversioninfo = $(shell echo $(KERNEL_VERSION) | awk -F'-' '{print $$2}' ) 47 | endif 48 | extraversion1 = $(shell echo $(extraversioninfo) | awk -F'.' '{print $$1}' | grep -E '^[0-9]+$$') 49 | ifneq ($(extraversion1),) 50 | ccflags-y += -DEXTRAVERSION1=$(extraversion1) 51 | else 52 | ccflags-y += -DEXTRAVERSION1=0 53 | endif 54 | 55 | extraversion2 = $(shell echo $(extraversioninfo) | awk -F'.' '{print $$2}' | grep -E '^[0-9]+$$') 56 | ifneq ($(extraversion2),) 57 | ccflags-y += -DEXTRAVERSION2=$(extraversion2) 58 | else 59 | ccflags-y += -DEXTRAVERSION2=0 60 | endif 61 | 62 | CFLAGS_hv_trace.o = -I$(src) 63 | CFLAGS_hv_balloon.o = -I$(src) 64 | 65 | hv_vmbus-y := vmbus_drv.o \ 66 | hv.o connection.o channel.o hv_trace.o \ 67 | channel_mgmt.o ring_buffer.o \ 68 | arch/$(SRCARCH)/hyperv/hv_init.o \ 69 | arch/$(SRCARCH)/hyperv/ms_hyperv_ext.o 70 | 71 | hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o hv_fcopy.o hv_utils_transport.o 72 | hv_storvsc-y := storvsc_drv.o 73 | hv_uio_generic-y := uio_hv_generic.o 74 | hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o 75 | hyperv_keyboard-y := hyperv-keyboard.o 76 | hv_network_direct-y := provider.o vmbus_rdma.o hvnd_addr.o 77 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/README: -------------------------------------------------------------------------------- 1 | After unpacking the tar file; as root: 2 | 3 | Execute the script ./rhel6-hv-driver-install to build and install 4 | Hyper-V drivers on a rhel6 installation. Once the script completes, 5 | reboot the machine to bringup RHEL6 enlightened on Hyper-V. 6 | 7 | To uninstall the Hyper-V drivers, execute the script 8 | ./rhel6-hv-driver-uninstall. Once the script completes, reboot the machine 9 | to bringup RHEL6 in fully emulated mode. 10 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/arch/x86/hyperv/ms_hyperv_ext.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2018, Microsoft, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 as published 7 | * by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 12 | * NON INFRINGEMENT. See the GNU General Public License for more 13 | * details. 14 | * 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | /* See the comment near the struct definition to know why we need this */ 22 | struct ms_hyperv_info_external ms_hyperv_ext; 23 | 24 | 25 | /* Copied from the upstream's ms_hyperv_init_platform() */ 26 | void init_ms_hyperv_ext(void) 27 | { 28 | /* 29 | * Extract the features and hints 30 | */ 31 | 32 | ms_hyperv_ext.features = cpuid_eax(HYPERV_CPUID_FEATURES); 33 | ms_hyperv_ext.misc_features = cpuid_edx(HYPERV_CPUID_FEATURES); 34 | ms_hyperv_ext.hints = cpuid_eax(HYPERV_CPUID_ENLIGHTMENT_INFO); 35 | 36 | pr_info("Hyper-V: detected features 0x%x, hints 0x%x\n", 37 | ms_hyperv_ext.features, ms_hyperv_ext.hints); 38 | } 39 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/arch/x86/include/lis/asm/sync_bitops.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASM_X86_SYNC_BITOPS_H 2 | #define _ASM_X86_SYNC_BITOPS_H 3 | 4 | /* 5 | * Copyright 1992, Linus Torvalds. 6 | */ 7 | 8 | /* 9 | * These have to be done with inline assembly: that way the bit-setting 10 | * is guaranteed to be atomic. All bit operations return 0 if the bit 11 | * was cleared before the operation and != 0 if it was not. 12 | * 13 | * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). 14 | */ 15 | 16 | #define ADDR (*(volatile long *)addr) 17 | 18 | /** 19 | * sync_set_bit - Atomically set a bit in memory 20 | * @nr: the bit to set 21 | * @addr: the address to start counting from 22 | * 23 | * This function is atomic and may not be reordered. See __set_bit() 24 | * if you do not require the atomic guarantees. 25 | * 26 | * Note that @nr may be almost arbitrarily large; this function is not 27 | * restricted to acting on a single-word quantity. 28 | */ 29 | static inline void sync_set_bit(long nr, volatile unsigned long *addr) 30 | { 31 | asm volatile("lock; bts %1,%0" 32 | : "+m" (ADDR) 33 | : "Ir" (nr) 34 | : "memory"); 35 | } 36 | 37 | /** 38 | * sync_clear_bit - Clears a bit in memory 39 | * @nr: Bit to clear 40 | * @addr: Address to start counting from 41 | * 42 | * sync_clear_bit() is atomic and may not be reordered. However, it does 43 | * not contain a memory barrier, so if it is used for locking purposes, 44 | * you should call smp_mb__before_atomic() and/or smp_mb__after_atomic() 45 | * in order to ensure changes are visible on other processors. 46 | */ 47 | static inline void sync_clear_bit(long nr, volatile unsigned long *addr) 48 | { 49 | asm volatile("lock; btr %1,%0" 50 | : "+m" (ADDR) 51 | : "Ir" (nr) 52 | : "memory"); 53 | } 54 | 55 | /** 56 | * sync_change_bit - Toggle a bit in memory 57 | * @nr: Bit to change 58 | * @addr: Address to start counting from 59 | * 60 | * sync_change_bit() is atomic and may not be reordered. 61 | * Note that @nr may be almost arbitrarily large; this function is not 62 | * restricted to acting on a single-word quantity. 63 | */ 64 | static inline void sync_change_bit(long nr, volatile unsigned long *addr) 65 | { 66 | asm volatile("lock; btc %1,%0" 67 | : "+m" (ADDR) 68 | : "Ir" (nr) 69 | : "memory"); 70 | } 71 | 72 | /** 73 | * sync_test_and_set_bit - Set a bit and return its old value 74 | * @nr: Bit to set 75 | * @addr: Address to count from 76 | * 77 | * This operation is atomic and cannot be reordered. 78 | * It also implies a memory barrier. 79 | */ 80 | static inline int sync_test_and_set_bit(long nr, volatile unsigned long *addr) 81 | { 82 | int oldbit; 83 | 84 | asm volatile("lock; bts %2,%1\n\tsbbl %0,%0" 85 | : "=r" (oldbit), "+m" (ADDR) 86 | : "Ir" (nr) : "memory"); 87 | return oldbit; 88 | } 89 | 90 | /** 91 | * sync_test_and_clear_bit - Clear a bit and return its old value 92 | * @nr: Bit to clear 93 | * @addr: Address to count from 94 | * 95 | * This operation is atomic and cannot be reordered. 96 | * It also implies a memory barrier. 97 | */ 98 | static inline int sync_test_and_clear_bit(long nr, volatile unsigned long *addr) 99 | { 100 | int oldbit; 101 | 102 | asm volatile("lock; btr %2,%1\n\tsbbl %0,%0" 103 | : "=r" (oldbit), "+m" (ADDR) 104 | : "Ir" (nr) : "memory"); 105 | return oldbit; 106 | } 107 | 108 | /** 109 | * sync_test_and_change_bit - Change a bit and return its old value 110 | * @nr: Bit to change 111 | * @addr: Address to count from 112 | * 113 | * This operation is atomic and cannot be reordered. 114 | * It also implies a memory barrier. 115 | */ 116 | static inline int sync_test_and_change_bit(long nr, volatile unsigned long *addr) 117 | { 118 | int oldbit; 119 | 120 | asm volatile("lock; btc %2,%1\n\tsbbl %0,%0" 121 | : "=r" (oldbit), "+m" (ADDR) 122 | : "Ir" (nr) : "memory"); 123 | return oldbit; 124 | } 125 | 126 | #define sync_test_bit(nr, addr) test_bit(nr, addr) 127 | 128 | #undef ADDR 129 | 130 | #endif /* _ASM_X86_SYNC_BITOPS_H */ 131 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/copy_files: -------------------------------------------------------------------------------- 1 | echo "Copying Files" 2 | echo "Invoke this script from drivers/hv directory" 3 | 4 | rm -rf tools 5 | mkdir tools 6 | mkdir -p ./include/linux 7 | mkdir -p ./include/uapi/linux 8 | mkdir -p ./include/asm/linux 9 | 10 | cp ../scsi/storvsc_drv.c . 11 | cp ../video/fbdev/hyperv_fb.c . 12 | cp ../hid/hid-hyperv.c . 13 | cp ../input/serio/hyperv-keyboard.c . 14 | cp ../net/hyperv/*.[hc] . 15 | 16 | cp ../../tools/hv/*.c ./tools/ 17 | cp ../../tools/hv/*.sh ./tools/ 18 | 19 | cp ../../include/linux/hyperv.h ./include/linux/ 20 | cp ../../include/linux/uuid.h ./include/linux/ 21 | cp ../../include/uapi/linux/uuid.h ./include/uapi/linux/ 22 | cp ../../include/linux/rndis.h ./include/linux/ 23 | cp ../../include/linux/atomic.h ./include/linux/ 24 | cp ../../include/linux/hv_compat.h ./include/linux/ 25 | cp ../../include/uapi/linux/hyperv.h ./include/uapi/linux/ 26 | 27 | cp ../../arch/x86/include/uapi/asm/hyperv.h ./include/asm/ 28 | cp ../../arch/x86/include/asm/mshyperv.h ./include/asm/ 29 | 30 | cp -r ../../include/linux/unaligned ./include/linux/ 31 | cp ../../arch/x86/include/asm/sync_bitops.h ./include/asm/ 32 | cp ../../include/linux/export.h ./include/linux/ 33 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/git_add_files: -------------------------------------------------------------------------------- 1 | echo "Git adding Files" 2 | echo "Invoke this script from drivers/hv directory after applying the base patch" 3 | 4 | git add git_add_files 5 | git add overrides.mk 6 | git add copy_files 7 | git add remove_files 8 | git add README 9 | git add ../../include/linux/hv_compat.h 10 | 11 | git add rhel6-hv-driver-install 12 | git add rhel6-hv-driver-uninstall 13 | 14 | git add hyperv_pvdrivers.conf 15 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/hv_trace.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | 3 | #include "hyperv_vmbus.h" 4 | 5 | #define CREATE_TRACE_POINTS 6 | #include "hv_trace.h" 7 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/hv_trace_balloon.h: -------------------------------------------------------------------------------- 1 | #undef TRACE_SYSTEM 2 | #define TRACE_SYSTEM hyperv 3 | 4 | #if !defined(_HV_TRACE_BALLOON_H) || defined(TRACE_HEADER_MULTI_READ) 5 | #define _HV_TRACE_BALLOON_H 6 | 7 | #include 8 | 9 | TRACE_EVENT(balloon_status, 10 | TP_PROTO(u64 available, u64 committed, 11 | unsigned long vm_memory_committed, 12 | unsigned long pages_ballooned, 13 | unsigned long pages_added, 14 | unsigned long pages_onlined), 15 | TP_ARGS(available, committed, vm_memory_committed, 16 | pages_ballooned, pages_added, pages_onlined), 17 | TP_STRUCT__entry( 18 | __field(u64, available) 19 | __field(u64, committed) 20 | __field(unsigned long, vm_memory_committed) 21 | __field(unsigned long, pages_ballooned) 22 | __field(unsigned long, pages_added) 23 | __field(unsigned long, pages_onlined) 24 | ), 25 | TP_fast_assign( 26 | __entry->available = available; 27 | __entry->committed = committed; 28 | __entry->vm_memory_committed = vm_memory_committed; 29 | __entry->pages_ballooned = pages_ballooned; 30 | __entry->pages_added = pages_added; 31 | __entry->pages_onlined = pages_onlined; 32 | ), 33 | TP_printk("available %lld, committed %lld; vm_memory_committed %ld;" 34 | " pages_ballooned %ld, pages_added %ld, pages_onlined %ld", 35 | __entry->available, __entry->committed, 36 | __entry->vm_memory_committed, __entry->pages_ballooned, 37 | __entry->pages_added, __entry->pages_onlined 38 | ) 39 | ); 40 | 41 | #undef TRACE_INCLUDE_PATH 42 | #define TRACE_INCLUDE_PATH . 43 | #undef TRACE_INCLUDE_FILE 44 | #define TRACE_INCLUDE_FILE hv_trace_balloon 45 | #endif /* _HV_TRACE_BALLOON_H */ 46 | 47 | /* This part must be outside protection */ 48 | #include 49 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/hv_utils_transport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kernel/userspace transport abstraction for Hyper-V util driver. 3 | * 4 | * Copyright (C) 2015, Vitaly Kuznetsov 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License version 2 as published 8 | * by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 13 | * NON INFRINGEMENT. See the GNU General Public License for more 14 | * details. 15 | * 16 | */ 17 | 18 | #ifndef _HV_UTILS_TRANSPORT_H 19 | #define _HV_UTILS_TRANSPORT_H 20 | 21 | #include 22 | #include 23 | 24 | enum hvutil_transport_mode { 25 | HVUTIL_TRANSPORT_INIT = 0, 26 | HVUTIL_TRANSPORT_NETLINK, 27 | HVUTIL_TRANSPORT_CHARDEV, 28 | HVUTIL_TRANSPORT_DESTROY, 29 | }; 30 | 31 | struct hvutil_transport { 32 | int mode; /* hvutil_transport_mode */ 33 | struct file_operations fops; /* file operations */ 34 | struct miscdevice mdev; /* misc device */ 35 | struct cb_id cn_id; /* CN_*_IDX/CN_*_VAL */ 36 | struct list_head list; /* hvt_list */ 37 | int (*on_msg)(void *, int); /* callback on new user message */ 38 | void (*on_reset)(void); /* callback when userspace drops */ 39 | void (*on_read)(void); /* callback on message read */ 40 | u8 *outmsg; /* message to the userspace */ 41 | int outmsg_len; /* its length */ 42 | wait_queue_head_t outmsg_q; /* poll/read wait queue */ 43 | struct mutex lock; /* protects struct members */ 44 | struct completion release; /* synchronize with fd release */ 45 | }; 46 | 47 | struct hvutil_transport *hvutil_transport_init(char *name, 48 | u32 cn_idx, u32 cn_val, 49 | int (*on_msg)(void *, int), 50 | void (*on_reset)(void)); 51 | int hvutil_transport_send(struct hvutil_transport *hvt, void *msg, int len, 52 | void (*on_read_cb)(void)); 53 | void hvutil_transport_destroy(struct hvutil_transport *hvt); 54 | 55 | #endif /* _HV_UTILS_TRANSPORT_H */ 56 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/hvnd_addr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Microsoft Corporation. 3 | * 4 | * Author: 5 | * K. Y. Srinivasan 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 as published 9 | * by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 14 | * NON INFRINGEMENT. See the GNU General Public License for more 15 | * details. 16 | * 17 | * Bug fixes/enhancements: Long Li 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include "vmbus_rdma.h" 35 | 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | 49 | int hvnd_get_outgoing_rdma_addr(struct hvnd_dev *nd_dev, struct hvnd_ucontext *uctx, 50 | union nd_sockaddr_inet *og_addr) 51 | { 52 | int ret; 53 | /* 54 | * Query the host and select the first address. 55 | */ 56 | struct pkt_query_addr_list pkt; 57 | 58 | memset(&pkt, 0, sizeof(pkt)); //KYS try to avoid having to zero everything 59 | 60 | hvnd_init_hdr(&pkt.hdr, 61 | (sizeof(pkt) - 62 | sizeof(struct ndv_packet_hdr_control_1)), 63 | uctx->create_pkt.handle.local, 64 | uctx->create_pkt.handle.remote, 65 | IOCTL_ND_ADAPTER_QUERY_ADDRESS_LIST, 0, 0, 0); 66 | 67 | pkt.ioctl.in.version = ND_VERSION_1; 68 | pkt.ioctl.in.reserved = 0; 69 | pkt.ioctl.in.handle = uctx->adaptor_hdl; 70 | 71 | ret = hvnd_send_ioctl_pkt(nd_dev, &pkt.hdr, 72 | sizeof(pkt), (u64)&pkt); 73 | 74 | if (ret) 75 | return ret; 76 | 77 | /* 78 | * Copy the address out. 79 | */ 80 | 81 | memcpy(og_addr, &pkt.ioctl.out[0], sizeof(*og_addr)); 82 | return 0; 83 | 84 | } 85 | 86 | static struct rdma_addr_client self; 87 | 88 | struct resolve_cb_context { 89 | struct rdma_dev_addr *addr; 90 | struct completion comp; 91 | }; 92 | 93 | void hvnd_addr_init(void) 94 | { 95 | rdma_addr_register_client(&self); 96 | return; 97 | } 98 | 99 | void hvnd_addr_deinit(void) 100 | { 101 | rdma_addr_unregister_client(&self); 102 | return; 103 | } 104 | 105 | static void resolve_cb(int status, struct sockaddr *src_addr, 106 | struct rdma_dev_addr *addr, void *context) 107 | { 108 | memcpy(((struct resolve_cb_context *)context)->addr, addr, sizeof(struct 109 | rdma_dev_addr)); 110 | complete(&((struct resolve_cb_context *)context)->comp); 111 | } 112 | 113 | int hvnd_get_neigh_mac_addr(struct sockaddr *local, struct sockaddr *remote, char *mac_addr) 114 | { 115 | struct rdma_dev_addr dev_addr; 116 | struct resolve_cb_context ctx; 117 | int ret; 118 | 119 | memset(&dev_addr, 0, sizeof(dev_addr)); 120 | ctx.addr = &dev_addr; 121 | init_completion(&ctx.comp); 122 | 123 | ret = rdma_resolve_ip(&self, local, remote, &dev_addr, 1000, resolve_cb, &ctx); 124 | 125 | if (ret) { 126 | hvnd_error("rdma_resolve_ip failed ret=%d\n", ret); 127 | return ret; 128 | } 129 | 130 | wait_for_completion(&ctx.comp); 131 | memcpy(mac_addr, dev_addr.dst_dev_addr, ETH_ALEN); 132 | return ret; 133 | } 134 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/hyperv.conf: -------------------------------------------------------------------------------- 1 | # this is hyperv conf file to override inbuilt hyper-v kernel driver. 2 | 3 | override hv_vmbus * weak-updates/microsoft-hyper-v 4 | override hid-hyperv * weak-updates/microsoft-hyper-v 5 | override hv_netvsc * weak-updates/microsoft-hyper-v 6 | override hv_utils * weak-updates/microsoft-hyper-v 7 | override hyperv_fb * weak-updates/microsoft-hyper-v 8 | override hv_balloon * weak-updates/microsoft-hyper-v 9 | override hv_storvsc * weak-updates/microsoft-hyper-v 10 | override hyperv-keyboard * weak-updates/microsoft-hyper-v 11 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/hyperv_pvdrivers.conf: -------------------------------------------------------------------------------- 1 | # Install HyperV paravirtualized drivers 2 | # 3 | # Only load the ata_piix driver on versions that support prefer_ms_hyperv. Otherwise 4 | # loading the ata_piix will result in IDE drives being detected twice. Supported 5 | # versions are from RHEL/CentOS 6.4 and newer. 6 | # 7 | 8 | install ata_piix { /sbin/modprobe hv_storvsc 2>&1; grep -q -E "6.0|6.1 |6.2|6.3" /etc/*-release || /sbin/modprobe --ignore-install ata_piix; } 9 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/include/linux/atomic.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_ATOMIC_H 2 | #define _LINUX_ATOMIC_H 3 | 4 | #include 5 | 6 | #endif /* _LINUX_ATOMIC_H */ 7 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/include/linux/export.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_EXPORT_H 2 | #define _LINUX_EXPORT_H 3 | /* 4 | * Export symbols from the kernel to modules. Forked from module.h 5 | * to reduce the amount of pointless cruft we feed to gcc when only 6 | * exporting a simple symbol or two. 7 | * 8 | * Try not to add #includes here. It slows compilation and makes kernel 9 | * hackers place grumpy comments in header files. 10 | */ 11 | 12 | /* Some toolchains use a `_' prefix for all user symbols. */ 13 | #ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX 14 | #define __VMLINUX_SYMBOL(x) _##x 15 | #define __VMLINUX_SYMBOL_STR(x) "_" #x 16 | #else 17 | #define __VMLINUX_SYMBOL(x) x 18 | #define __VMLINUX_SYMBOL_STR(x) #x 19 | #endif 20 | 21 | /* Indirect, so macros are expanded before pasting. */ 22 | #define VMLINUX_SYMBOL(x) __VMLINUX_SYMBOL(x) 23 | #define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x) 24 | 25 | #ifndef __ASSEMBLY__ 26 | struct kernel_symbol 27 | { 28 | unsigned long value; 29 | const char *name; 30 | }; 31 | 32 | #ifdef MODULE 33 | extern struct module __this_module; 34 | #define THIS_MODULE (&__this_module) 35 | #else 36 | #define THIS_MODULE ((struct module *)0) 37 | #endif 38 | 39 | #ifdef CONFIG_MODULES 40 | 41 | #ifndef __GENKSYMS__ 42 | #ifdef CONFIG_MODVERSIONS 43 | /* Mark the CRC weak since genksyms apparently decides not to 44 | * generate a checksums for some symbols */ 45 | #define __CRC_SYMBOL(sym, sec) \ 46 | extern __visible void *__crc_##sym __attribute__((weak)); \ 47 | static const unsigned long __kcrctab_##sym \ 48 | __used \ 49 | __attribute__((section("___kcrctab" sec "+" #sym), unused)) \ 50 | = (unsigned long) &__crc_##sym; 51 | #else 52 | #define __CRC_SYMBOL(sym, sec) 53 | #endif 54 | 55 | /* For every exported symbol, place a struct in the __ksymtab section */ 56 | #define __EXPORT_SYMBOL(sym, sec) \ 57 | extern typeof(sym) sym; \ 58 | __CRC_SYMBOL(sym, sec) \ 59 | static const char __kstrtab_##sym[] \ 60 | __attribute__((section("__ksymtab_strings"), aligned(1))) \ 61 | = VMLINUX_SYMBOL_STR(sym); \ 62 | extern const struct kernel_symbol __ksymtab_##sym; \ 63 | __visible const struct kernel_symbol __ksymtab_##sym \ 64 | __used \ 65 | __attribute__((section("___ksymtab" sec "+" #sym), unused)) \ 66 | = { (unsigned long)&sym, __kstrtab_##sym } 67 | 68 | #define EXPORT_SYMBOL(sym) \ 69 | __EXPORT_SYMBOL(sym, "") 70 | 71 | #define EXPORT_SYMBOL_GPL(sym) \ 72 | __EXPORT_SYMBOL(sym, "_gpl") 73 | 74 | #define EXPORT_SYMBOL_GPL_FUTURE(sym) \ 75 | __EXPORT_SYMBOL(sym, "_gpl_future") 76 | 77 | #ifdef CONFIG_UNUSED_SYMBOLS 78 | #define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused") 79 | #define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl") 80 | #else 81 | #define EXPORT_UNUSED_SYMBOL(sym) 82 | #define EXPORT_UNUSED_SYMBOL_GPL(sym) 83 | #endif 84 | 85 | #endif /* __GENKSYMS__ */ 86 | 87 | #else /* !CONFIG_MODULES... */ 88 | 89 | #define EXPORT_SYMBOL(sym) 90 | #define EXPORT_SYMBOL_GPL(sym) 91 | #define EXPORT_SYMBOL_GPL_FUTURE(sym) 92 | #define EXPORT_UNUSED_SYMBOL(sym) 93 | #define EXPORT_UNUSED_SYMBOL_GPL(sym) 94 | 95 | #endif /* CONFIG_MODULES */ 96 | #endif /* !__ASSEMBLY__ */ 97 | 98 | #endif /* _LINUX_EXPORT_H */ 99 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/include/linux/unaligned/access_ok.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_ACCESS_OK_H 2 | #define _LINUX_UNALIGNED_ACCESS_OK_H 3 | 4 | #include 5 | #include 6 | 7 | static inline u16 get_unaligned_le16(const void *p) 8 | { 9 | return le16_to_cpup((__le16 *)p); 10 | } 11 | 12 | static inline u32 get_unaligned_le32(const void *p) 13 | { 14 | return le32_to_cpup((__le32 *)p); 15 | } 16 | 17 | static inline u64 get_unaligned_le64(const void *p) 18 | { 19 | return le64_to_cpup((__le64 *)p); 20 | } 21 | 22 | static inline u16 get_unaligned_be16(const void *p) 23 | { 24 | return be16_to_cpup((__be16 *)p); 25 | } 26 | 27 | static inline u32 get_unaligned_be32(const void *p) 28 | { 29 | return be32_to_cpup((__be32 *)p); 30 | } 31 | 32 | static inline u64 get_unaligned_be64(const void *p) 33 | { 34 | return be64_to_cpup((__be64 *)p); 35 | } 36 | 37 | static inline void put_unaligned_le16(u16 val, void *p) 38 | { 39 | *((__le16 *)p) = cpu_to_le16(val); 40 | } 41 | 42 | static inline void put_unaligned_le32(u32 val, void *p) 43 | { 44 | *((__le32 *)p) = cpu_to_le32(val); 45 | } 46 | 47 | static inline void put_unaligned_le64(u64 val, void *p) 48 | { 49 | *((__le64 *)p) = cpu_to_le64(val); 50 | } 51 | 52 | static inline void put_unaligned_be16(u16 val, void *p) 53 | { 54 | *((__be16 *)p) = cpu_to_be16(val); 55 | } 56 | 57 | static inline void put_unaligned_be32(u32 val, void *p) 58 | { 59 | *((__be32 *)p) = cpu_to_be32(val); 60 | } 61 | 62 | static inline void put_unaligned_be64(u64 val, void *p) 63 | { 64 | *((__be64 *)p) = cpu_to_be64(val); 65 | } 66 | 67 | #endif /* _LINUX_UNALIGNED_ACCESS_OK_H */ 68 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/include/linux/unaligned/be_byteshift.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_BE_BYTESHIFT_H 2 | #define _LINUX_UNALIGNED_BE_BYTESHIFT_H 3 | 4 | #include 5 | 6 | static inline u16 __get_unaligned_be16(const u8 *p) 7 | { 8 | return p[0] << 8 | p[1]; 9 | } 10 | 11 | static inline u32 __get_unaligned_be32(const u8 *p) 12 | { 13 | return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]; 14 | } 15 | 16 | static inline u64 __get_unaligned_be64(const u8 *p) 17 | { 18 | return (u64)__get_unaligned_be32(p) << 32 | 19 | __get_unaligned_be32(p + 4); 20 | } 21 | 22 | static inline void __put_unaligned_be16(u16 val, u8 *p) 23 | { 24 | *p++ = val >> 8; 25 | *p++ = val; 26 | } 27 | 28 | static inline void __put_unaligned_be32(u32 val, u8 *p) 29 | { 30 | __put_unaligned_be16(val >> 16, p); 31 | __put_unaligned_be16(val, p + 2); 32 | } 33 | 34 | static inline void __put_unaligned_be64(u64 val, u8 *p) 35 | { 36 | __put_unaligned_be32(val >> 32, p); 37 | __put_unaligned_be32(val, p + 4); 38 | } 39 | 40 | static inline u16 get_unaligned_be16(const void *p) 41 | { 42 | return __get_unaligned_be16((const u8 *)p); 43 | } 44 | 45 | static inline u32 get_unaligned_be32(const void *p) 46 | { 47 | return __get_unaligned_be32((const u8 *)p); 48 | } 49 | 50 | static inline u64 get_unaligned_be64(const void *p) 51 | { 52 | return __get_unaligned_be64((const u8 *)p); 53 | } 54 | 55 | static inline void put_unaligned_be16(u16 val, void *p) 56 | { 57 | __put_unaligned_be16(val, p); 58 | } 59 | 60 | static inline void put_unaligned_be32(u32 val, void *p) 61 | { 62 | __put_unaligned_be32(val, p); 63 | } 64 | 65 | static inline void put_unaligned_be64(u64 val, void *p) 66 | { 67 | __put_unaligned_be64(val, p); 68 | } 69 | 70 | #endif /* _LINUX_UNALIGNED_BE_BYTESHIFT_H */ 71 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/include/linux/unaligned/be_memmove.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_BE_MEMMOVE_H 2 | #define _LINUX_UNALIGNED_BE_MEMMOVE_H 3 | 4 | #include 5 | 6 | static inline u16 get_unaligned_be16(const void *p) 7 | { 8 | return __get_unaligned_memmove16((const u8 *)p); 9 | } 10 | 11 | static inline u32 get_unaligned_be32(const void *p) 12 | { 13 | return __get_unaligned_memmove32((const u8 *)p); 14 | } 15 | 16 | static inline u64 get_unaligned_be64(const void *p) 17 | { 18 | return __get_unaligned_memmove64((const u8 *)p); 19 | } 20 | 21 | static inline void put_unaligned_be16(u16 val, void *p) 22 | { 23 | __put_unaligned_memmove16(val, p); 24 | } 25 | 26 | static inline void put_unaligned_be32(u32 val, void *p) 27 | { 28 | __put_unaligned_memmove32(val, p); 29 | } 30 | 31 | static inline void put_unaligned_be64(u64 val, void *p) 32 | { 33 | __put_unaligned_memmove64(val, p); 34 | } 35 | 36 | #endif /* _LINUX_UNALIGNED_LE_MEMMOVE_H */ 37 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/include/linux/unaligned/be_struct.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_BE_STRUCT_H 2 | #define _LINUX_UNALIGNED_BE_STRUCT_H 3 | 4 | #include 5 | 6 | static inline u16 get_unaligned_be16(const void *p) 7 | { 8 | return __get_unaligned_cpu16((const u8 *)p); 9 | } 10 | 11 | static inline u32 get_unaligned_be32(const void *p) 12 | { 13 | return __get_unaligned_cpu32((const u8 *)p); 14 | } 15 | 16 | static inline u64 get_unaligned_be64(const void *p) 17 | { 18 | return __get_unaligned_cpu64((const u8 *)p); 19 | } 20 | 21 | static inline void put_unaligned_be16(u16 val, void *p) 22 | { 23 | __put_unaligned_cpu16(val, p); 24 | } 25 | 26 | static inline void put_unaligned_be32(u32 val, void *p) 27 | { 28 | __put_unaligned_cpu32(val, p); 29 | } 30 | 31 | static inline void put_unaligned_be64(u64 val, void *p) 32 | { 33 | __put_unaligned_cpu64(val, p); 34 | } 35 | 36 | #endif /* _LINUX_UNALIGNED_BE_STRUCT_H */ 37 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/include/linux/unaligned/generic.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_GENERIC_H 2 | #define _LINUX_UNALIGNED_GENERIC_H 3 | 4 | /* 5 | * Cause a link-time error if we try an unaligned access other than 6 | * 1,2,4 or 8 bytes long 7 | */ 8 | extern void __bad_unaligned_access_size(void); 9 | 10 | #define __get_unaligned_le(ptr) ((__force typeof(*(ptr)))({ \ 11 | __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \ 12 | __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_le16((ptr)), \ 13 | __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_le32((ptr)), \ 14 | __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_le64((ptr)), \ 15 | __bad_unaligned_access_size())))); \ 16 | })) 17 | 18 | #define __get_unaligned_be(ptr) ((__force typeof(*(ptr)))({ \ 19 | __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \ 20 | __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_be16((ptr)), \ 21 | __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_be32((ptr)), \ 22 | __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_be64((ptr)), \ 23 | __bad_unaligned_access_size())))); \ 24 | })) 25 | 26 | #define __put_unaligned_le(val, ptr) ({ \ 27 | void *__gu_p = (ptr); \ 28 | switch (sizeof(*(ptr))) { \ 29 | case 1: \ 30 | *(u8 *)__gu_p = (__force u8)(val); \ 31 | break; \ 32 | case 2: \ 33 | put_unaligned_le16((__force u16)(val), __gu_p); \ 34 | break; \ 35 | case 4: \ 36 | put_unaligned_le32((__force u32)(val), __gu_p); \ 37 | break; \ 38 | case 8: \ 39 | put_unaligned_le64((__force u64)(val), __gu_p); \ 40 | break; \ 41 | default: \ 42 | __bad_unaligned_access_size(); \ 43 | break; \ 44 | } \ 45 | (void)0; }) 46 | 47 | #define __put_unaligned_be(val, ptr) ({ \ 48 | void *__gu_p = (ptr); \ 49 | switch (sizeof(*(ptr))) { \ 50 | case 1: \ 51 | *(u8 *)__gu_p = (__force u8)(val); \ 52 | break; \ 53 | case 2: \ 54 | put_unaligned_be16((__force u16)(val), __gu_p); \ 55 | break; \ 56 | case 4: \ 57 | put_unaligned_be32((__force u32)(val), __gu_p); \ 58 | break; \ 59 | case 8: \ 60 | put_unaligned_be64((__force u64)(val), __gu_p); \ 61 | break; \ 62 | default: \ 63 | __bad_unaligned_access_size(); \ 64 | break; \ 65 | } \ 66 | (void)0; }) 67 | 68 | #endif /* _LINUX_UNALIGNED_GENERIC_H */ 69 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/include/linux/unaligned/le_byteshift.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_LE_BYTESHIFT_H 2 | #define _LINUX_UNALIGNED_LE_BYTESHIFT_H 3 | 4 | #include 5 | 6 | static inline u16 __get_unaligned_le16(const u8 *p) 7 | { 8 | return p[0] | p[1] << 8; 9 | } 10 | 11 | static inline u32 __get_unaligned_le32(const u8 *p) 12 | { 13 | return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; 14 | } 15 | 16 | static inline u64 __get_unaligned_le64(const u8 *p) 17 | { 18 | return (u64)__get_unaligned_le32(p + 4) << 32 | 19 | __get_unaligned_le32(p); 20 | } 21 | 22 | static inline void __put_unaligned_le16(u16 val, u8 *p) 23 | { 24 | *p++ = val; 25 | *p++ = val >> 8; 26 | } 27 | 28 | static inline void __put_unaligned_le32(u32 val, u8 *p) 29 | { 30 | __put_unaligned_le16(val >> 16, p + 2); 31 | __put_unaligned_le16(val, p); 32 | } 33 | 34 | static inline void __put_unaligned_le64(u64 val, u8 *p) 35 | { 36 | __put_unaligned_le32(val >> 32, p + 4); 37 | __put_unaligned_le32(val, p); 38 | } 39 | 40 | static inline u16 get_unaligned_le16(const void *p) 41 | { 42 | return __get_unaligned_le16((const u8 *)p); 43 | } 44 | 45 | static inline u32 get_unaligned_le32(const void *p) 46 | { 47 | return __get_unaligned_le32((const u8 *)p); 48 | } 49 | 50 | static inline u64 get_unaligned_le64(const void *p) 51 | { 52 | return __get_unaligned_le64((const u8 *)p); 53 | } 54 | 55 | static inline void put_unaligned_le16(u16 val, void *p) 56 | { 57 | __put_unaligned_le16(val, p); 58 | } 59 | 60 | static inline void put_unaligned_le32(u32 val, void *p) 61 | { 62 | __put_unaligned_le32(val, p); 63 | } 64 | 65 | static inline void put_unaligned_le64(u64 val, void *p) 66 | { 67 | __put_unaligned_le64(val, p); 68 | } 69 | 70 | #endif /* _LINUX_UNALIGNED_LE_BYTESHIFT_H */ 71 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/include/linux/unaligned/le_memmove.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_LE_MEMMOVE_H 2 | #define _LINUX_UNALIGNED_LE_MEMMOVE_H 3 | 4 | #include 5 | 6 | static inline u16 get_unaligned_le16(const void *p) 7 | { 8 | return __get_unaligned_memmove16((const u8 *)p); 9 | } 10 | 11 | static inline u32 get_unaligned_le32(const void *p) 12 | { 13 | return __get_unaligned_memmove32((const u8 *)p); 14 | } 15 | 16 | static inline u64 get_unaligned_le64(const void *p) 17 | { 18 | return __get_unaligned_memmove64((const u8 *)p); 19 | } 20 | 21 | static inline void put_unaligned_le16(u16 val, void *p) 22 | { 23 | __put_unaligned_memmove16(val, p); 24 | } 25 | 26 | static inline void put_unaligned_le32(u32 val, void *p) 27 | { 28 | __put_unaligned_memmove32(val, p); 29 | } 30 | 31 | static inline void put_unaligned_le64(u64 val, void *p) 32 | { 33 | __put_unaligned_memmove64(val, p); 34 | } 35 | 36 | #endif /* _LINUX_UNALIGNED_LE_MEMMOVE_H */ 37 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/include/linux/unaligned/le_struct.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_LE_STRUCT_H 2 | #define _LINUX_UNALIGNED_LE_STRUCT_H 3 | 4 | #include 5 | 6 | static inline u16 get_unaligned_le16(const void *p) 7 | { 8 | return __get_unaligned_cpu16((const u8 *)p); 9 | } 10 | 11 | static inline u32 get_unaligned_le32(const void *p) 12 | { 13 | return __get_unaligned_cpu32((const u8 *)p); 14 | } 15 | 16 | static inline u64 get_unaligned_le64(const void *p) 17 | { 18 | return __get_unaligned_cpu64((const u8 *)p); 19 | } 20 | 21 | static inline void put_unaligned_le16(u16 val, void *p) 22 | { 23 | __put_unaligned_cpu16(val, p); 24 | } 25 | 26 | static inline void put_unaligned_le32(u32 val, void *p) 27 | { 28 | __put_unaligned_cpu32(val, p); 29 | } 30 | 31 | static inline void put_unaligned_le64(u64 val, void *p) 32 | { 33 | __put_unaligned_cpu64(val, p); 34 | } 35 | 36 | #endif /* _LINUX_UNALIGNED_LE_STRUCT_H */ 37 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/include/linux/unaligned/memmove.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_MEMMOVE_H 2 | #define _LINUX_UNALIGNED_MEMMOVE_H 3 | 4 | #include 5 | #include 6 | 7 | /* Use memmove here, so gcc does not insert a __builtin_memcpy. */ 8 | 9 | static inline u16 __get_unaligned_memmove16(const void *p) 10 | { 11 | u16 tmp; 12 | memmove(&tmp, p, 2); 13 | return tmp; 14 | } 15 | 16 | static inline u32 __get_unaligned_memmove32(const void *p) 17 | { 18 | u32 tmp; 19 | memmove(&tmp, p, 4); 20 | return tmp; 21 | } 22 | 23 | static inline u64 __get_unaligned_memmove64(const void *p) 24 | { 25 | u64 tmp; 26 | memmove(&tmp, p, 8); 27 | return tmp; 28 | } 29 | 30 | static inline void __put_unaligned_memmove16(u16 val, void *p) 31 | { 32 | memmove(p, &val, 2); 33 | } 34 | 35 | static inline void __put_unaligned_memmove32(u32 val, void *p) 36 | { 37 | memmove(p, &val, 4); 38 | } 39 | 40 | static inline void __put_unaligned_memmove64(u64 val, void *p) 41 | { 42 | memmove(p, &val, 8); 43 | } 44 | 45 | #endif /* _LINUX_UNALIGNED_MEMMOVE_H */ 46 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/include/linux/unaligned/packed_struct.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_PACKED_STRUCT_H 2 | #define _LINUX_UNALIGNED_PACKED_STRUCT_H 3 | 4 | #include 5 | 6 | struct __una_u16 { u16 x; } __packed; 7 | struct __una_u32 { u32 x; } __packed; 8 | struct __una_u64 { u64 x; } __packed; 9 | 10 | static inline u16 __get_unaligned_cpu16(const void *p) 11 | { 12 | const struct __una_u16 *ptr = (const struct __una_u16 *)p; 13 | return ptr->x; 14 | } 15 | 16 | static inline u32 __get_unaligned_cpu32(const void *p) 17 | { 18 | const struct __una_u32 *ptr = (const struct __una_u32 *)p; 19 | return ptr->x; 20 | } 21 | 22 | static inline u64 __get_unaligned_cpu64(const void *p) 23 | { 24 | const struct __una_u64 *ptr = (const struct __una_u64 *)p; 25 | return ptr->x; 26 | } 27 | 28 | static inline void __put_unaligned_cpu16(u16 val, void *p) 29 | { 30 | struct __una_u16 *ptr = (struct __una_u16 *)p; 31 | ptr->x = val; 32 | } 33 | 34 | static inline void __put_unaligned_cpu32(u32 val, void *p) 35 | { 36 | struct __una_u32 *ptr = (struct __una_u32 *)p; 37 | ptr->x = val; 38 | } 39 | 40 | static inline void __put_unaligned_cpu64(u64 val, void *p) 41 | { 42 | struct __una_u64 *ptr = (struct __una_u64 *)p; 43 | ptr->x = val; 44 | } 45 | 46 | #endif /* _LINUX_UNALIGNED_PACKED_STRUCT_H */ 47 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/include/uapi/linux/uuid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UUID/GUID definition 3 | * 4 | * Copyright (C) 2010, Intel Corp. 5 | * Huang Ying 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License version 9 | * 2 as published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef _LINUX_UUID_H_ 22 | #define _LINUX_UUID_H_ 23 | 24 | #include 25 | #include 26 | 27 | typedef struct { 28 | __u8 b[16]; 29 | } uuid_le; 30 | 31 | typedef struct { 32 | __u8 b[16]; 33 | } uuid_be; 34 | 35 | #define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ 36 | ((uuid_le) \ 37 | {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ 38 | (b) & 0xff, ((b) >> 8) & 0xff, \ 39 | (c) & 0xff, ((c) >> 8) & 0xff, \ 40 | (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) 41 | 42 | #define UUID_BE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ 43 | ((uuid_be) \ 44 | {{ ((a) >> 24) & 0xff, ((a) >> 16) & 0xff, ((a) >> 8) & 0xff, (a) & 0xff, \ 45 | ((b) >> 8) & 0xff, (b) & 0xff, \ 46 | ((c) >> 8) & 0xff, (c) & 0xff, \ 47 | (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) 48 | 49 | #define NULL_UUID_LE \ 50 | UUID_LE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, \ 51 | 0x00, 0x00, 0x00, 0x00) 52 | 53 | #define NULL_UUID_BE \ 54 | UUID_BE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, \ 55 | 0x00, 0x00, 0x00, 0x00) 56 | 57 | #ifdef __KERNEL__ 58 | 59 | static inline int uuid_le_cmp(const uuid_le u1, const uuid_le u2) 60 | { 61 | return memcmp(&u1, &u2, sizeof(uuid_le)); 62 | } 63 | 64 | static inline int uuid_be_cmp(const uuid_be u1, const uuid_be u2) 65 | { 66 | return memcmp(&u1, &u2, sizeof(uuid_be)); 67 | } 68 | 69 | #endif /* __KERNEL__ */ 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/mx_abi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 Topspin Communications. All rights reserved. 3 | * Copyright (c) 2005 Cisco Systems. All rights reserved. 4 | * Copyright (c) 2005 PathScale, Inc. All rights reserved. 5 | * 6 | * This software is available to you under a choice of one of two 7 | * licenses. You may choose to be licensed under the terms of the GNU 8 | * General Public License (GPL) Version 2, available from the file 9 | * COPYING in the main directory of this source tree, or the 10 | * OpenIB.org BSD license below: 11 | * 12 | * Redistribution and use in source and binary forms, with or 13 | * without modification, are permitted provided that the following 14 | * conditions are met: 15 | * 16 | * - Redistributions of source code must retain the above 17 | * copyright notice, this list of conditions and the following 18 | * disclaimer. 19 | * 20 | * - Redistributions in binary form must reproduce the above 21 | * copyright notice, this list of conditions and the following 22 | * disclaimer in the documentation and/or other materials 23 | * provided with the distribution. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 | * SOFTWARE. 33 | * 34 | * KYS: made some modifications. 35 | */ 36 | 37 | #ifndef MX_ABI_H 38 | #define MX_ABI_H 39 | 40 | 41 | 42 | /* 43 | * Make sure that all structs defined in this file remain laid out so 44 | * that they pack the same way on 32-bit and 64-bit architectures (to 45 | * avoid incompatibility between 32-bit userspace and 64-bit kernels). 46 | * Specifically: 47 | * - Do not use pointer types -- pass pointers in UINT64 instead. 48 | * - Make sure that any structure larger than 4 bytes is padded to a 49 | * multiple of 8 bytes. Otherwise the structure size will be 50 | * different between 32-bit and 64-bit architectures. 51 | */ 52 | 53 | enum ibv_get_context_mappings { 54 | IBV_GET_CONTEXT_UAR, 55 | IBV_GET_CONTEXT_BF, 56 | IBV_GET_CONTEXT_MAPPING_MAX 57 | }; 58 | 59 | struct ibv_get_context_req { 60 | 61 | union nd_mapping mappings[IBV_GET_CONTEXT_MAPPING_MAX]; 62 | }; 63 | 64 | struct ibv_get_context_resp { 65 | 66 | // mmap UAR and BF 67 | struct nd_mapping_result mapping_results[IBV_GET_CONTEXT_MAPPING_MAX]; 68 | 69 | // mmap Blue Flame 70 | int bf_buf_size; 71 | int bf_offset; 72 | 73 | // mlx4_query_device result 74 | int max_qp_wr; 75 | int max_sge; 76 | int max_cqe; 77 | 78 | // general parameters 79 | u32 cqe_size; 80 | u32 vend_id; 81 | u16 dev_id; 82 | u16 bf_reg_size; 83 | u16 bf_regs_per_page; 84 | u16 reserved1; 85 | 86 | // ibv_cmd_get_context result 87 | u32 qp_tab_size; 88 | 89 | u32 reserved2; 90 | }; 91 | 92 | struct ibv_alloc_pd_resp { 93 | u64 pd_handle; 94 | u32 pdn; 95 | u32 reserved; 96 | }; 97 | 98 | struct ibv_reg_mr { 99 | u64 start; 100 | u64 length; 101 | u64 hca_va; 102 | u32 access_flags; 103 | u32 pdn; 104 | u64 pd_handle; 105 | }; 106 | 107 | struct ibv_reg_mr_resp { 108 | u64 mr_handle; 109 | u32 lkey; 110 | u32 rkey; 111 | }; 112 | 113 | 114 | enum mlx4_ib_create_cq_mapping { 115 | MLX4_IB_CREATE_CQ_BUF, 116 | MLX4_IB_CREATE_CQ_DB, 117 | MLX4_IB_CREATE_CQ_ARM_SN, // Windows specific 118 | MLX4_IB_CREATE_CQ_MAPPING_MAX 119 | }; 120 | 121 | #define MLX4_CQ_FLAGS_ARM_IN_KERNEL 1 122 | 123 | struct ibv_create_cq { 124 | union nd_mapping mappings[MLX4_IB_CREATE_CQ_MAPPING_MAX]; 125 | u32 flags; 126 | }; 127 | 128 | struct ibv_create_cq_resp { 129 | struct nd_mapping_result mapping_results[MLX4_IB_CREATE_CQ_MAPPING_MAX]; 130 | u32 cqn; 131 | u32 cqe; 132 | }; 133 | 134 | enum mlx4_ib_create_srq_mappings { 135 | MLX4_IB_CREATE_SRQ_BUF, 136 | MLX4_IB_CREATE_SRQ_DB, 137 | MLX4_IB_CREATE_SRQ_MAPPINGS_MAX 138 | }; 139 | 140 | struct ibv_create_srq { 141 | union nd_mapping mappings[MLX4_IB_CREATE_SRQ_MAPPINGS_MAX]; 142 | }; 143 | 144 | struct ibv_create_srq_resp { 145 | struct nd_mapping_result mapping_results[MLX4_IB_CREATE_SRQ_MAPPINGS_MAX]; 146 | }; 147 | 148 | enum mlx4_ib_create_qp_mappings { 149 | MLX4_IB_CREATE_QP_BUF, 150 | MLX4_IB_CREATE_QP_DB, 151 | MLX4_IB_CREATE_QP_MAPPINGS_MAX 152 | }; 153 | 154 | struct ibv_create_qp { 155 | union nd_mapping mappings[MLX4_IB_CREATE_QP_MAPPINGS_MAX]; 156 | u8 log_sq_bb_count; 157 | u8 log_sq_stride; 158 | u8 sq_no_prefetch; 159 | u8 reserved; 160 | }; 161 | 162 | struct ibv_create_qp_resp { 163 | struct nd_mapping_result mapping_results[MLX4_IB_CREATE_QP_MAPPINGS_MAX]; 164 | // struct ib_uverbs_create_qp_resp 165 | u64 qp_handle; 166 | u32 qpn; 167 | u32 max_send_wr; 168 | u32 max_recv_wr; 169 | u32 max_send_sge; 170 | u32 max_recv_sge; 171 | u32 max_inline_data; 172 | }; 173 | 174 | enum ibv_qp_attr_mask { 175 | IBV_QP_STATE = 1 << 0, 176 | IBV_QP_CUR_STATE = 1 << 1, 177 | IBV_QP_EN_SQD_ASYNC_NOTIFY = 1 << 2, 178 | IBV_QP_ACCESS_FLAGS = 1 << 3, 179 | IBV_QP_PKEY_INDEX = 1 << 4, 180 | IBV_QP_PORT = 1 << 5, 181 | IBV_QP_QKEY = 1 << 6, 182 | IBV_QP_AV = 1 << 7, 183 | IBV_QP_PATH_MTU = 1 << 8, 184 | IBV_QP_TIMEOUT = 1 << 9, 185 | IBV_QP_RETRY_CNT = 1 << 10, 186 | IBV_QP_RNR_RETRY = 1 << 11, 187 | IBV_QP_RQ_PSN = 1 << 12, 188 | IBV_QP_MAX_QP_RD_ATOMIC = 1 << 13, 189 | IBV_QP_ALT_PATH = 1 << 14, 190 | IBV_QP_MIN_RNR_TIMER = 1 << 15, 191 | IBV_QP_SQ_PSN = 1 << 16, 192 | IBV_QP_MAX_DEST_RD_ATOMIC = 1 << 17, 193 | IBV_QP_PATH_MIG_STATE = 1 << 18, 194 | IBV_QP_CAP = 1 << 19, 195 | IBV_QP_DEST_QPN = 1 << 20 196 | }; 197 | 198 | enum ibv_qp_state { 199 | IBV_QPS_RESET, 200 | IBV_QPS_INIT, 201 | IBV_QPS_RTR, 202 | IBV_QPS_RTS, 203 | IBV_QPS_SQD, 204 | IBV_QPS_SQE, 205 | IBV_QPS_ERR 206 | }; 207 | 208 | 209 | struct ibv_modify_qp_resp { 210 | enum ibv_qp_attr_mask attr_mask; 211 | u8 qp_state; 212 | u8 reserved[3]; 213 | }; 214 | 215 | struct ibv_create_ah_resp { 216 | u64 start; 217 | }; 218 | 219 | /* 220 | * Some mlx4 specific kernel definitions. Perhaps could be in 221 | * separate file. 222 | */ 223 | 224 | struct mlx4_ib_user_db_page { 225 | struct list_head list; 226 | struct ib_umem *umem; 227 | unsigned long user_virt; 228 | int refcnt; 229 | }; 230 | 231 | 232 | #endif /* MX_ABI_H */ 233 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/rhel6-hv-driver-install: -------------------------------------------------------------------------------- 1 | echo "Building Modules" 2 | if [ "$KERNEL_VERSION" == "" ] 3 | then 4 | KERNEL_VERSION=$(uname -r) 5 | fi 6 | 7 | make -C /lib/modules/$KERNEL_VERSION/build M=`pwd` clean 8 | [ $? -eq 0 ] || exit 1 9 | 10 | make -C /lib/modules/$KERNEL_VERSION/build M=`pwd` modules -j$(nproc) 11 | [ $? -eq 0 ] || exit 1 12 | 13 | echo "Installing Modules" 14 | 15 | cp -f ./*.ko /lib/modules/$KERNEL_VERSION/extra/ 16 | [ $? -eq 0 ] || exit 1 17 | 18 | echo "Generating Module dependencies" 19 | 20 | depmod 21 | [ $? -eq 0 ] || exit 1 22 | 23 | echo "Installing Modprobe Rules" 24 | 25 | cp -f ./hyperv_pvdrivers.conf /etc/modprobe.d/ 26 | [ $? -eq 0 ] || exit 1 27 | 28 | echo "Copying scripts for IP injection" 29 | 30 | mkdir -p /usr/libexec/hypervkvpd/ 31 | 32 | \cp -f ./tools/hv_get_dns_info.sh /usr/libexec/hypervkvpd/hv_get_dns_info 33 | [ $? -eq 0 ] || exit 1 34 | 35 | \cp -f ./tools/hv_get_dhcp_info.sh /usr/libexec/hypervkvpd/hv_get_dhcp_info 36 | [ $? -eq 0 ] || exit 1 37 | 38 | \cp -f ./tools/hv_set_ifconfig.sh /usr/libexec/hypervkvpd/hv_set_ifconfig 39 | [ $? -eq 0 ] || exit 1 40 | 41 | echo "Copying lsvmbus tool" 42 | 43 | \cp -f ./tools/lsvmbus /usr/sbin/ 44 | [ $? -eq 0 ] || exit 1 45 | chmod +x /usr/sbin/lsvmbus 46 | 47 | echo "Generating initramfs" 48 | 49 | dracut --force "initramfs-$KERNEL_VERSION.img" $KERNEL_VERSION 50 | [ $? -eq 0 ] || exit 1 51 | 52 | echo "Saving old initramfs" 53 | 54 | if [ ! -e /boot/"initramfs-$KERNEL_VERSION.img-old" ] 55 | then 56 | cp -f /boot/"initramfs-$KERNEL_VERSION.img" /boot/"initramfs-$KERNEL_VERSION.img-old" 57 | fi 58 | 59 | echo "Installing new initramfs" 60 | 61 | cp -f "initramfs-$KERNEL_VERSION.img" /boot/"initramfs-$KERNEL_VERSION.img" 62 | [ $? -eq 0 ] || exit 1 63 | 64 | echo "Update kernel commandline" 65 | grubby --update-kernel "/boot/vmlinuz-$KERNEL_VERSION" --args=disable_mtrr_trim 66 | [ $? -eq 0 ] || exit 1 67 | 68 | echo "Completed!" 69 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/rhel6-hv-driver-uninstall: -------------------------------------------------------------------------------- 1 | echo "Get rid of the Hyper-V drivers and modprobe rules" 2 | if [ "$KERNEL_VERSION" == "" ] 3 | then 4 | KERNEL_VERSION=$(uname -r) 5 | fi 6 | 7 | rm -rf /lib/modules/$KERNEL_VERSION/extra/hv_*.ko 8 | rm -f /lib/modules/$KERNEL_VERSION/extra/hyperv_fb.ko 9 | rm -f /lib/modules/$KERNEL_VERSION/extra/hid-hyperv.ko 10 | rm -f /lib/modules/$KERNEL_VERSION/extra/hyperv-keyboard.ko 11 | rm -f /lib/modules/$KERNEL_VERSION/extra/uio_hv_generic.ko 12 | 13 | rm -rf /lib/modules/$KERNEL_VERSION/extra/microsoft-hyper-v/hv_*.ko 14 | rm -rf /etc/modprobe.d/hyperv_pvdrivers.conf 15 | 16 | echo "Get rid of ip injection scripts" 17 | rm -rf /usr/sbin/hv_get_dns_info 18 | rm -rf /usr/sbin/hv_get_dhcp_info 19 | rm -rf /usr/sbin/hv_set_ifconfig 20 | 21 | echo "Removing lsvmbus tool" 22 | rm -rf /usr/sbin/lsvmbus 23 | 24 | depmod 25 | 26 | echo "Create and install initramfs without Hyper-V drivers" 27 | dracut --force "initramfs-$KERNEL_VERSION.img" $KERNEL_VERSION 28 | cp -f "initramfs-$KERNEL_VERSION.img" /boot/"initramfs-$KERNEL_VERSION.img" 29 | 30 | echo "Remove updates to kernel commandline" 31 | grubby --update-kernel "/boot/vmlinuz-$KERNEL_VERSION" --remove-args=disable_mtrr_trim 32 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/tools/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Hyper-V tools 2 | 3 | CC = $(CROSS_COMPILE)gcc 4 | WARNINGS = -Wall -Wextra 5 | CFLAGS = $(WARNINGS) -g $(shell getconf LFS_CFLAGS) 6 | 7 | CFLAGS += -D__EXPORTED_HEADERS__ -I../include/uapi -I../include 8 | 9 | all: hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon 10 | %: %.c 11 | $(CC) $(CFLAGS) -o $@ $^ 12 | 13 | clean: 14 | $(RM) hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon 15 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/tools/bondvf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This example script creates bonding network devices based on synthetic NIC 4 | # (the virtual network adapter usually provided by Hyper-V) and the matching 5 | # VF NIC (SRIOV virtual function). So the synthetic NIC and VF NIC can 6 | # function as one network device, and fail over to the synthetic NIC if VF is 7 | # down. 8 | # 9 | # Usage: 10 | # - After configured vSwitch and vNIC with SRIOV, start Linux virtual 11 | # machine (VM) 12 | # - Run this scripts on the VM. It will create configuration files in 13 | # distro specific directory. 14 | # - Reboot the VM, so that the bonding config are enabled. 15 | # 16 | # The config files are DHCP by default. You may edit them if you need to change 17 | # to Static IP or change other settings. 18 | # 19 | 20 | sysdir=/sys/class/net 21 | netvsc_cls={f8615163-df3e-46c5-913f-f2d2f965ed0e} 22 | bondcnt=0 23 | 24 | # Detect Distro 25 | if [ -f /etc/redhat-release ]; 26 | then 27 | cfgdir=/etc/sysconfig/network-scripts 28 | distro=redhat 29 | elif grep -q 'Ubuntu' /etc/issue 30 | then 31 | cfgdir=/etc/network 32 | distro=ubuntu 33 | elif grep -q 'SUSE' /etc/issue 34 | then 35 | cfgdir=/etc/sysconfig/network 36 | distro=suse 37 | else 38 | echo "Unsupported Distro" 39 | exit 1 40 | fi 41 | 42 | echo Detected Distro: $distro, or compatible 43 | 44 | # Get a list of ethernet names 45 | list_eth=(`cd $sysdir && ls -d */ | cut -d/ -f1 | grep -v bond`) 46 | eth_cnt=${#list_eth[@]} 47 | 48 | echo List of net devices: 49 | 50 | # Get the MAC addresses 51 | for (( i=0; i < $eth_cnt; i++ )) 52 | do 53 | list_mac[$i]=`cat $sysdir/${list_eth[$i]}/address` 54 | echo ${list_eth[$i]}, ${list_mac[$i]} 55 | done 56 | 57 | # Find NIC with matching MAC 58 | for (( i=0; i < $eth_cnt-1; i++ )) 59 | do 60 | for (( j=i+1; j < $eth_cnt; j++ )) 61 | do 62 | if [ "${list_mac[$i]}" = "${list_mac[$j]}" ] 63 | then 64 | list_match[$i]=${list_eth[$j]} 65 | break 66 | fi 67 | done 68 | done 69 | 70 | function create_eth_cfg_redhat { 71 | local fn=$cfgdir/ifcfg-$1 72 | 73 | rm -f $fn 74 | echo DEVICE=$1 >>$fn 75 | echo TYPE=Ethernet >>$fn 76 | echo BOOTPROTO=none >>$fn 77 | echo UUID=`uuidgen` >>$fn 78 | echo ONBOOT=yes >>$fn 79 | echo PEERDNS=yes >>$fn 80 | echo IPV6INIT=yes >>$fn 81 | echo MASTER=$2 >>$fn 82 | echo SLAVE=yes >>$fn 83 | } 84 | 85 | function create_eth_cfg_pri_redhat { 86 | create_eth_cfg_redhat $1 $2 87 | } 88 | 89 | function create_bond_cfg_redhat { 90 | local fn=$cfgdir/ifcfg-$1 91 | 92 | rm -f $fn 93 | echo DEVICE=$1 >>$fn 94 | echo TYPE=Bond >>$fn 95 | echo BOOTPROTO=dhcp >>$fn 96 | echo UUID=`uuidgen` >>$fn 97 | echo ONBOOT=yes >>$fn 98 | echo PEERDNS=yes >>$fn 99 | echo IPV6INIT=yes >>$fn 100 | echo BONDING_MASTER=yes >>$fn 101 | echo BONDING_OPTS=\"mode=active-backup miimon=100 primary=$2\" >>$fn 102 | } 103 | 104 | function del_eth_cfg_ubuntu { 105 | local fn=$cfgdir/interfaces 106 | local tmpfl=$(mktemp) 107 | 108 | local nic_start='^[ \t]*(auto|iface|mapping|allow-.*)[ \t]+'$1 109 | local nic_end='^[ \t]*(auto|iface|mapping|allow-.*|source)' 110 | 111 | awk "/$nic_end/{x=0} x{next} /$nic_start/{x=1;next} 1" $fn >$tmpfl 112 | 113 | cp $tmpfl $fn 114 | 115 | rm $tmpfl 116 | } 117 | 118 | 119 | function create_eth_cfg_ubuntu { 120 | local fn=$cfgdir/interfaces 121 | 122 | del_eth_cfg_ubuntu $1 123 | echo $'\n'auto $1 >>$fn 124 | echo iface $1 inet manual >>$fn 125 | echo bond-master $2 >>$fn 126 | } 127 | 128 | function create_eth_cfg_pri_ubuntu { 129 | local fn=$cfgdir/interfaces 130 | 131 | del_eth_cfg_ubuntu $1 132 | echo $'\n'allow-hotplug $1 >>$fn 133 | echo iface $1 inet manual >>$fn 134 | echo bond-master $2 >>$fn 135 | echo bond-primary $1 >>$fn 136 | } 137 | 138 | function create_bond_cfg_ubuntu { 139 | local fn=$cfgdir/interfaces 140 | 141 | echo $'\n'auto $1 >>$fn 142 | echo iface $1 inet dhcp >>$fn 143 | echo bond-mode active-backup >>$fn 144 | echo bond-miimon 100 >>$fn 145 | echo bond-slaves none >>$fn 146 | } 147 | 148 | function create_eth_cfg_suse { 149 | local fn=$cfgdir/ifcfg-$1 150 | 151 | rm -f $fn 152 | echo BOOTPROTO=none >>$fn 153 | echo STARTMODE=auto >>$fn 154 | } 155 | 156 | function create_eth_cfg_pri_suse { 157 | local fn=$cfgdir/ifcfg-$1 158 | 159 | rm -f $fn 160 | echo BOOTPROTO=none >>$fn 161 | echo STARTMODE=hotplug >>$fn 162 | } 163 | 164 | function create_bond_cfg_suse { 165 | local fn=$cfgdir/ifcfg-$1 166 | 167 | rm -f $fn 168 | echo BOOTPROTO=dhcp >>$fn 169 | echo STARTMODE=auto >>$fn 170 | echo BONDING_MASTER=yes >>$fn 171 | echo BONDING_SLAVE_0=$2 >>$fn 172 | echo BONDING_SLAVE_1=$3 >>$fn 173 | echo BONDING_MODULE_OPTS=\'mode=active-backup miimon=100 primary=$2\' >>$fn 174 | } 175 | 176 | function create_bond { 177 | local bondname=bond$bondcnt 178 | local primary 179 | local secondary 180 | 181 | local class_id1=`cat $sysdir/$1/device/class_id 2>/dev/null` 182 | local class_id2=`cat $sysdir/$2/device/class_id 2>/dev/null` 183 | 184 | if [ "$class_id1" = "$netvsc_cls" ] 185 | then 186 | primary=$2 187 | secondary=$1 188 | elif [ "$class_id2" = "$netvsc_cls" ] 189 | then 190 | primary=$1 191 | secondary=$2 192 | else 193 | return 0 194 | fi 195 | 196 | echo $'\nBond name:' $bondname 197 | 198 | if [ $distro == ubuntu ] 199 | then 200 | local mainfn=$cfgdir/interfaces 201 | local s="^[ \t]*(auto|iface|mapping|allow-.*)[ \t]+${bondname}" 202 | 203 | grep -E "$s" $mainfn 204 | if [ $? -eq 0 ] 205 | then 206 | echo "WARNING: ${bondname} has been configured already" 207 | return 208 | fi 209 | elif [ $distro == redhat ] || [ $distro == suse ] 210 | then 211 | local fn=$cfgdir/ifcfg-$bondname 212 | if [ -f $fn ] 213 | then 214 | echo "WARNING: ${bondname} has been configured already" 215 | return 216 | fi 217 | else 218 | echo "Unsupported Distro: ${distro}" 219 | return 220 | fi 221 | 222 | echo configuring $primary 223 | create_eth_cfg_pri_$distro $primary $bondname 224 | 225 | echo configuring $secondary 226 | create_eth_cfg_$distro $secondary $bondname 227 | 228 | echo creating: $bondname with primary slave: $primary 229 | create_bond_cfg_$distro $bondname $primary $secondary 230 | } 231 | 232 | for (( i=0; i < $eth_cnt-1; i++ )) 233 | do 234 | if [ -n "${list_match[$i]}" ] 235 | then 236 | create_bond ${list_eth[$i]} ${list_match[$i]} 237 | let bondcnt=bondcnt+1 238 | fi 239 | done 240 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/tools/hv_get_dhcp_info.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This example script retrieves the DHCP state of a given interface. 4 | # In the interest of keeping the KVP daemon code free of distro specific 5 | # information; the kvp daemon code invokes this external script to gather 6 | # DHCP setting for the specific interface. 7 | # 8 | # Input: Name of the interface 9 | # 10 | # Output: The script prints the string "Enabled" to stdout to indicate 11 | # that DHCP is enabled on the interface. If DHCP is not enabled, 12 | # the script prints the string "Disabled" to stdout. 13 | # 14 | # Each Distro is expected to implement this script in a distro specific 15 | # fashion. For instance on Distros that ship with Network Manager enabled, 16 | # this script can be based on the Network Manager APIs for retrieving DHCP 17 | # information. 18 | 19 | if_file="/etc/sysconfig/network-scripts/ifcfg-"$1 20 | 21 | dhcp=$(grep "dhcp" $if_file 2>/dev/null) 22 | 23 | if [ "$dhcp" != "" ]; 24 | then 25 | echo "Enabled" 26 | else 27 | echo "Disabled" 28 | fi 29 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/tools/hv_get_dns_info.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This example script parses /etc/resolv.conf to retrive DNS information. 4 | # In the interest of keeping the KVP daemon code free of distro specific 5 | # information; the kvp daemon code invokes this external script to gather 6 | # DNS information. 7 | # This script is expected to print the nameserver values to stdout. 8 | # Each Distro is expected to implement this script in a distro specific 9 | # fashion. For instance on Distros that ship with Network Manager enabled, 10 | # this script can be based on the Network Manager APIs for retrieving DNS 11 | # entries. 12 | 13 | cat /etc/resolv.conf 2>/dev/null | awk '/^nameserver/ { print $2 }' 14 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/tools/hv_set_ifconfig.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This example script activates an interface based on the specified 4 | # configuration. 5 | # 6 | # In the interest of keeping the KVP daemon code free of distro specific 7 | # information; the kvp daemon code invokes this external script to configure 8 | # the interface. 9 | # 10 | # The only argument to this script is the configuration file that is to 11 | # be used to configure the interface. 12 | # 13 | # Each Distro is expected to implement this script in a distro specific 14 | # fashion. For instance on Distros that ship with Network Manager enabled, 15 | # this script can be based on the Network Manager APIs for configuring the 16 | # interface. 17 | # 18 | # This example script is based on a RHEL environment. 19 | # 20 | # Here is the format of the ip configuration file: 21 | # 22 | # HWADDR=macaddr 23 | # DEVICE=interface name 24 | # BOOTPROTO= (where is "dhcp" if DHCP is configured 25 | # or "none" if no boot-time protocol should be used) 26 | # 27 | # IPADDR0=ipaddr1 28 | # IPADDR1=ipaddr2 29 | # IPADDRx=ipaddry (where y = x + 1) 30 | # 31 | # NETMASK0=netmask1 32 | # NETMASKx=netmasky (where y = x + 1) 33 | # 34 | # GATEWAY=ipaddr1 35 | # GATEWAYx=ipaddry (where y = x + 1) 36 | # 37 | # DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) 38 | # 39 | # IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be 40 | # tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as 41 | # IPV6NETMASK. 42 | # 43 | # The host can specify multiple ipv4 and ipv6 addresses to be 44 | # configured for the interface. Furthermore, the configuration 45 | # needs to be persistent. A subsequent GET call on the interface 46 | # is expected to return the configuration that is set via the SET 47 | # call. 48 | # 49 | 50 | 51 | 52 | echo "IPV6INIT=yes" >> $1 53 | echo "NM_CONTROLLED=no" >> $1 54 | echo "PEERDNS=yes" >> $1 55 | echo "ONBOOT=yes" >> $1 56 | 57 | sed -i 's/IPADDR0/IPADDR/g' $1 58 | sed -i 's/NETMASK0/NETMASK/g' $1 59 | 60 | cp $1 /etc/sysconfig/network-scripts/ 61 | 62 | 63 | interface=$(echo $1 | awk -F - '{ print $2 }') 64 | 65 | /sbin/ifdown $interface 2>/dev/null 66 | /sbin/ifup $interface 2>/dev/null 67 | -------------------------------------------------------------------------------- /hv-rhel6.x/hv/tools/lsvmbus: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | from optparse import OptionParser 5 | 6 | parser = OptionParser() 7 | parser.add_option("-v", "--verbose", dest="verbose", 8 | help="print verbose messages. Try -vv, -vvv for \ 9 | more verbose messages", action="count") 10 | 11 | (options, args) = parser.parse_args() 12 | 13 | verbose = 0 14 | if options.verbose is not None: 15 | verbose = options.verbose 16 | 17 | vmbus_sys_path = '/sys/bus/vmbus/devices' 18 | if not os.path.isdir(vmbus_sys_path): 19 | print("%s doesn't exist: exiting..." % vmbus_sys_path) 20 | exit(-1) 21 | 22 | vmbus_dev_dict = { 23 | '{0e0b6031-5213-4934-818b-38d90ced39db}' : '[Operating system shutdown]', 24 | '{9527e630-d0ae-497b-adce-e80ab0175caf}' : '[Time Synchronization]', 25 | '{57164f39-9115-4e78-ab55-382f3bd5422d}' : '[Heartbeat]', 26 | '{a9a0f4e7-5a45-4d96-b827-8a841e8c03e6}' : '[Data Exchange]', 27 | '{35fa2e29-ea23-4236-96ae-3a6ebacba440}' : '[Backup (volume checkpoint)]', 28 | '{34d14be3-dee4-41c8-9ae7-6b174977c192}' : '[Guest services]', 29 | '{525074dc-8985-46e2-8057-a307dc18a502}' : '[Dynamic Memory]', 30 | '{cfa8b69e-5b4a-4cc0-b98b-8ba1a1f3f95a}' : 'Synthetic mouse', 31 | '{f912ad6d-2b17-48ea-bd65-f927a61c7684}' : 'Synthetic keyboard', 32 | '{da0a7802-e377-4aac-8e77-0558eb1073f8}' : 'Synthetic framebuffer adapter', 33 | '{f8615163-df3e-46c5-913f-f2d2f965ed0e}' : 'Synthetic network adapter', 34 | '{32412632-86cb-44a2-9b5c-50d1417354f5}' : 'Synthetic IDE Controller', 35 | '{ba6163d9-04a1-4d29-b605-72e2ffb1dc7f}' : 'Synthetic SCSI Controller', 36 | '{2f9bcc4a-0069-4af3-b76b-6fd0be528cda}' : 'Synthetic fiber channel adapter', 37 | '{8c2eaf3d-32a7-4b09-ab99-bd1f1c86b501}' : 'Synthetic RDMA adapter', 38 | '{44c4f61d-4444-4400-9d52-802e27ede19f}' : 'PCI Express pass-through', 39 | '{276aacf4-ac15-426c-98dd-7521ad3f01fe}' : '[Reserved system device]', 40 | '{f8e65716-3cb3-4a06-9a60-1889c5cccab5}' : '[Reserved system device]', 41 | '{3375baf4-9e15-4b30-b765-67acb10d607b}' : '[Reserved system device]', 42 | } 43 | 44 | def get_vmbus_dev_attr(dev_name, attr): 45 | try: 46 | f = open('%s/%s/%s' % (vmbus_sys_path, dev_name, attr), 'r') 47 | lines = f.readlines() 48 | f.close() 49 | except IOError: 50 | lines = [] 51 | 52 | return lines 53 | 54 | class VMBus_Dev: 55 | pass 56 | 57 | 58 | vmbus_dev_list = [] 59 | 60 | for f in os.listdir(vmbus_sys_path): 61 | vmbus_id = get_vmbus_dev_attr(f, 'id')[0].strip() 62 | class_id = get_vmbus_dev_attr(f, 'class_id')[0].strip() 63 | device_id = get_vmbus_dev_attr(f, 'device_id')[0].strip() 64 | dev_desc = vmbus_dev_dict.get(class_id, 'Unknown') 65 | 66 | chn_vp_mapping = get_vmbus_dev_attr(f, 'channel_vp_mapping') 67 | chn_vp_mapping = [c.strip() for c in chn_vp_mapping] 68 | chn_vp_mapping = sorted(chn_vp_mapping, 69 | key = lambda c : int(c.split(':')[0])) 70 | 71 | chn_vp_mapping = ['\tRel_ID=%s, target_cpu=%s' % 72 | (c.split(':')[0], c.split(':')[1]) 73 | for c in chn_vp_mapping] 74 | d = VMBus_Dev() 75 | d.sysfs_path = '%s/%s' % (vmbus_sys_path, f) 76 | d.vmbus_id = vmbus_id 77 | d.class_id = class_id 78 | d.device_id = device_id 79 | d.dev_desc = dev_desc 80 | d.chn_vp_mapping = '\n'.join(chn_vp_mapping) 81 | if d.chn_vp_mapping: 82 | d.chn_vp_mapping += '\n' 83 | 84 | vmbus_dev_list.append(d) 85 | 86 | 87 | vmbus_dev_list = sorted(vmbus_dev_list, key = lambda d : int(d.vmbus_id)) 88 | 89 | format0 = '%2s: %s' 90 | format1 = '%2s: Class_ID = %s - %s\n%s' 91 | format2 = '%2s: Class_ID = %s - %s\n\tDevice_ID = %s\n\tSysfs path: %s\n%s' 92 | 93 | for d in vmbus_dev_list: 94 | if verbose == 0: 95 | print(('VMBUS ID ' + format0) % (d.vmbus_id, d.dev_desc)) 96 | elif verbose == 1: 97 | print (('VMBUS ID ' + format1) % \ 98 | (d.vmbus_id, d.class_id, d.dev_desc, d.chn_vp_mapping)) 99 | else: 100 | print (('VMBUS ID ' + format2) % \ 101 | (d.vmbus_id, d.class_id, d.dev_desc, \ 102 | d.device_id, d.sysfs_path, d.chn_vp_mapping)) 103 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/CHANGELOG: -------------------------------------------------------------------------------- 1 | Tracking Linux-Next Commit 2 | Date: 2015-11-10 00:29:42 (GMT) 3 | Commit-ID: 3209f9d780d137cdb54c85e0a776cb19e723a170 4 | 5 | scsi: storvsc: Fix a bug in the handling of SRB status flags 6 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/Kconfig: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | 3 | menu "Microsoft Hyper-V guest support" 4 | 5 | config HYPERV 6 | tristate "Microsoft Hyper-V client drivers" 7 | depends on X86 && ACPI && PCI && X86_LOCAL_APIC && HYPERVISOR_GUEST 8 | help 9 | Select this option to run Linux as a Hyper-V client operating 10 | system. 11 | 12 | config HYPERV_UTILS 13 | tristate "Microsoft Hyper-V Utilities driver" 14 | depends on HYPERV && CONNECTOR && NLS 15 | help 16 | Select this option to enable the Hyper-V Utilities. 17 | 18 | config HYPERV_BALLOON 19 | tristate "Microsoft Hyper-V Balloon driver" 20 | depends on HYPERV 21 | help 22 | Select this option to enable Hyper-V Balloon driver. 23 | 24 | endmenu 25 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/Makefile: -------------------------------------------------------------------------------- 1 | obj-m += hv_vmbus.o 2 | obj-m += hv_storvsc.o 3 | obj-m += hv_netvsc.o 4 | obj-m += hv_utils.o 5 | obj-m += hid-hyperv.o 6 | obj-m += hyperv_fb.o 7 | obj-m += hv_balloon.o 8 | obj-m += hyperv-keyboard.o 9 | 10 | # Get machine bit length 11 | arch=$(shell getconf LONG_BIT) 12 | 13 | # Get RHEL/CentOS version information 14 | rhel_major=$(shell grep -Eoh [0-9]+\.[0-9]+ /etc/{issue,*release} | head -1 | awk -F'.' '{ print $$1 }') 15 | rhel_minor=$(shell grep -Eoh [0-9]+\.[0-9]+ /etc/{issue,*release} | head -1 | awk -F'.' '{ print $$2 }') 16 | rhel_release_code=$(shell echo $$(($(rhel_major) << 8 | $(rhel_minor)))) 17 | 18 | # RDMA should only build on 64 bits arch 19 | ifeq ($(arch), 64) 20 | # Network direct driver in LIS is supported for RHEL/CentOS <= 7.6 21 | build_hv_network_direct=$(shell test $(rhel_release_code) -lt 1799; echo $$?) 22 | ifeq ($(build_hv_network_direct),0) 23 | obj-m += hv_network_direct.o 24 | endif 25 | endif 26 | 27 | # Kernel support for Hyper-V Sockets driver was introduced in RHEL/CentOS 7.4 28 | # Only build the hv_sock driver on RHEL 7.4 and newer. 29 | # The RHEL_RELEASE_CODE for RHEL/CentOS 7.3 = 1795. 30 | 31 | build_hvsock=$(shell test $(rhel_release_code) -gt 1795; echo $$?) 32 | ifeq ($(build_hvsock),0) 33 | obj-m += hv_sock.o 34 | endif 35 | 36 | # Kernel support for the Hyper-V PCI driver was introduced in RHEL/CentOS 7.3 37 | # Only build the pci-hyperv driver on RHEL 7.3 and newer. 38 | # The RHEL_RELEASE_CODE for RHEL/CentOS 7.2 = 1794. 39 | 40 | build_pci=$(shell test $(rhel_release_code) -gt 1794; echo $$?) 41 | ifeq ($(build_pci),0) 42 | obj-m += pci-hyperv.o 43 | endif 44 | 45 | 46 | # UIO underlying function are not yet in rhel6.x so make it conditional for future release 47 | buildrdma=$(shell test $(rhel_release_code) -gt 1795; echo $$?) 48 | ifeq ($(buildrdma),0) 49 | ifeq ($(arch), 64) 50 | obj-m += uio_hv_generic.o 51 | endif 52 | endif 53 | 54 | # Get extra kernel version information beyond LINUX_VERSION_CODE or RHEL_RELEASE_CODE. 55 | # This is used to identify RHEL/CentOS kernel update versions. 56 | extraversioninfo = $(shell uname -r | awk -F'-' '{print $$2}') 57 | ifdef KERNEL_VERSION 58 | extraversioninfo = $(shell echo $(KERNEL_VERSION) | awk -F'-' '{print $$2}' ) 59 | endif 60 | extraversion1 = $(shell echo $(extraversioninfo) | awk -F'.' '{print $$1}' | grep -E '^[0-9]+$$') 61 | ifneq ($(extraversion1),) 62 | ccflags-y += -DEXTRAVERSION1=$(extraversion1) 63 | else 64 | ccflags-y += -DEXTRAVERSION1=0 65 | endif 66 | 67 | extraversion2 = $(shell echo $(extraversioninfo) | awk -F'.' '{print $$2}' | grep -E '^[0-9]+$$') 68 | ifneq ($(extraversion2),) 69 | ccflags-y += -DEXTRAVERSION2=$(extraversion2) 70 | else 71 | ccflags-y += -DEXTRAVERSION2=0 72 | endif 73 | 74 | ccflags-y += -I$(M)/include/ -I$(M)/arch/$(ARCH)/include -I$(M)/arch/$(ARCH)/include/uapi 75 | 76 | CFLAGS_hv_trace.o = -I$(src) 77 | CFLAGS_hv_balloon.o = -I$(src) 78 | 79 | hv_vmbus-y := vmbus_drv.o \ 80 | hv.o connection.o channel.o hv_trace.o \ 81 | channel_mgmt.o ring_buffer.o \ 82 | arch/$(ARCH)/hyperv/hv_init.o \ 83 | arch/$(ARCH)/hyperv/ms_hyperv_ext.o 84 | hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o hv_fcopy.o hv_utils_transport.o 85 | 86 | hv_storvsc-y := storvsc_drv.o 87 | hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o 88 | hyperv_keyboard-y := hyperv-keyboard.o 89 | hv_network_direct-y := provider.o vmbus_rdma.o hvnd_addr.o 90 | hv_sock-y := hyperv_transport.o 91 | hv_uio_generic-y := uio_hv_generic.o 92 | 93 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/README: -------------------------------------------------------------------------------- 1 | After unpacking the tar file; as root: 2 | 3 | Execute the script ./rhel7-hv-driver-install to build and install 4 | Hyper-V drivers on a rhel7.x installation. Once the script completes, 5 | reboot the machine to bringup RHEL7.X enlightened on Hyper-V. 6 | 7 | To uninstall the Hyper-V drivers, execute the script 8 | ./rhel7-hv-driver-uninstall. Once the script completes, reboot the machine 9 | to bringup RHEL7 in fully emulated mode. 10 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/arch/x86/hyperv/ms_hyperv_ext.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2017, Microsoft, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 as published 7 | * by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 12 | * NON INFRINGEMENT. See the GNU General Public License for more 13 | * details. 14 | * 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | /* See the comment near the struct definition to know why we need this */ 22 | struct ms_hyperv_info_external ms_hyperv_ext; 23 | 24 | 25 | /* Copied from the upstream's ms_hyperv_init_platform() */ 26 | void init_ms_hyperv_ext(void) 27 | { 28 | /* 29 | * Extract the features and hints 30 | */ 31 | 32 | ms_hyperv_ext.features = cpuid_eax(HYPERV_CPUID_FEATURES); 33 | ms_hyperv_ext.misc_features = cpuid_edx(HYPERV_CPUID_FEATURES); 34 | ms_hyperv_ext.hints = cpuid_eax(HYPERV_CPUID_ENLIGHTMENT_INFO); 35 | 36 | pr_info("Hyper-V: detected features 0x%x, hints 0x%x\n", 37 | ms_hyperv_ext.features, ms_hyperv_ext.hints); 38 | } 39 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/arch/x86/include/lis/asm/sync_bitops.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASM_X86_SYNC_BITOPS_H 2 | #define _ASM_X86_SYNC_BITOPS_H 3 | 4 | /* 5 | * Copyright 1992, Linus Torvalds. 6 | */ 7 | 8 | /* 9 | * These have to be done with inline assembly: that way the bit-setting 10 | * is guaranteed to be atomic. All bit operations return 0 if the bit 11 | * was cleared before the operation and != 0 if it was not. 12 | * 13 | * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). 14 | */ 15 | 16 | #define ADDR (*(volatile long *)addr) 17 | 18 | /** 19 | * sync_set_bit - Atomically set a bit in memory 20 | * @nr: the bit to set 21 | * @addr: the address to start counting from 22 | * 23 | * This function is atomic and may not be reordered. See __set_bit() 24 | * if you do not require the atomic guarantees. 25 | * 26 | * Note that @nr may be almost arbitrarily large; this function is not 27 | * restricted to acting on a single-word quantity. 28 | */ 29 | static inline void sync_set_bit(long nr, volatile unsigned long *addr) 30 | { 31 | asm volatile("lock; bts %1,%0" 32 | : "+m" (ADDR) 33 | : "Ir" (nr) 34 | : "memory"); 35 | } 36 | 37 | /** 38 | * sync_clear_bit - Clears a bit in memory 39 | * @nr: Bit to clear 40 | * @addr: Address to start counting from 41 | * 42 | * sync_clear_bit() is atomic and may not be reordered. However, it does 43 | * not contain a memory barrier, so if it is used for locking purposes, 44 | * you should call smp_mb__before_atomic() and/or smp_mb__after_atomic() 45 | * in order to ensure changes are visible on other processors. 46 | */ 47 | static inline void sync_clear_bit(long nr, volatile unsigned long *addr) 48 | { 49 | asm volatile("lock; btr %1,%0" 50 | : "+m" (ADDR) 51 | : "Ir" (nr) 52 | : "memory"); 53 | } 54 | 55 | /** 56 | * sync_change_bit - Toggle a bit in memory 57 | * @nr: Bit to change 58 | * @addr: Address to start counting from 59 | * 60 | * sync_change_bit() is atomic and may not be reordered. 61 | * Note that @nr may be almost arbitrarily large; this function is not 62 | * restricted to acting on a single-word quantity. 63 | */ 64 | static inline void sync_change_bit(long nr, volatile unsigned long *addr) 65 | { 66 | asm volatile("lock; btc %1,%0" 67 | : "+m" (ADDR) 68 | : "Ir" (nr) 69 | : "memory"); 70 | } 71 | 72 | /** 73 | * sync_test_and_set_bit - Set a bit and return its old value 74 | * @nr: Bit to set 75 | * @addr: Address to count from 76 | * 77 | * This operation is atomic and cannot be reordered. 78 | * It also implies a memory barrier. 79 | */ 80 | static inline int sync_test_and_set_bit(long nr, volatile unsigned long *addr) 81 | { 82 | int oldbit; 83 | 84 | asm volatile("lock; bts %2,%1\n\tsbbl %0,%0" 85 | : "=r" (oldbit), "+m" (ADDR) 86 | : "Ir" (nr) : "memory"); 87 | return oldbit; 88 | } 89 | 90 | /** 91 | * sync_test_and_clear_bit - Clear a bit and return its old value 92 | * @nr: Bit to clear 93 | * @addr: Address to count from 94 | * 95 | * This operation is atomic and cannot be reordered. 96 | * It also implies a memory barrier. 97 | */ 98 | static inline int sync_test_and_clear_bit(long nr, volatile unsigned long *addr) 99 | { 100 | int oldbit; 101 | 102 | asm volatile("lock; btr %2,%1\n\tsbbl %0,%0" 103 | : "=r" (oldbit), "+m" (ADDR) 104 | : "Ir" (nr) : "memory"); 105 | return oldbit; 106 | } 107 | 108 | /** 109 | * sync_test_and_change_bit - Change a bit and return its old value 110 | * @nr: Bit to change 111 | * @addr: Address to count from 112 | * 113 | * This operation is atomic and cannot be reordered. 114 | * It also implies a memory barrier. 115 | */ 116 | static inline int sync_test_and_change_bit(long nr, volatile unsigned long *addr) 117 | { 118 | int oldbit; 119 | 120 | asm volatile("lock; btc %2,%1\n\tsbbl %0,%0" 121 | : "=r" (oldbit), "+m" (ADDR) 122 | : "Ir" (nr) : "memory"); 123 | return oldbit; 124 | } 125 | 126 | #define sync_test_bit(nr, addr) test_bit(nr, addr) 127 | 128 | #undef ADDR 129 | 130 | #endif /* _ASM_X86_SYNC_BITOPS_H */ 131 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/copy_files: -------------------------------------------------------------------------------- 1 | echo "Copying Files" 2 | echo "Invoke this script from drivers/hv directory" 3 | 4 | rm -rf tools 5 | mkdir tools 6 | mkdir -p ./include/linux 7 | mkdir -p ./include/uapi/linux 8 | mkdir -p ./include/asm/linux 9 | 10 | cp ../scsi/storvsc_drv.c . 11 | cp ../video/fbdev/hyperv_fb.c . 12 | cp ../hid/hid-hyperv.c . 13 | cp ../input/serio/hyperv-keyboard.c . 14 | cp ../net/hyperv/*.[hc] . 15 | 16 | cp ../../tools/hv/*.c ./tools/ 17 | cp ../../tools/hv/*.sh ./tools/ 18 | 19 | cp ../../include/linux/hyperv.h ./include/linux/ 20 | cp ../../include/linux/uuid.h ./include/linux/ 21 | cp ../../include/uapi/linux/uuid.h ./include/uapi/linux/ 22 | cp ../../include/linux/rndis.h ./include/linux/ 23 | cp ../../include/linux/atomic.h ./include/linux/ 24 | cp ../../include/linux/hv_compat.h ./include/linux/ 25 | cp ../../include/uapi/linux/hyperv.h ./include/uapi/linux/ 26 | 27 | cp ../../arch/x86/include/uapi/asm/hyperv.h ./include/asm/ 28 | cp ../../arch/x86/include/asm/mshyperv.h ./include/asm/ 29 | 30 | cp -r ../../include/linux/unaligned ./include/linux/ 31 | cp ../../arch/x86/include/asm/sync_bitops.h ./include/asm/ 32 | cp ../../include/linux/export.h ./include/linux/ 33 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/git_add_files: -------------------------------------------------------------------------------- 1 | echo "Git adding Files" 2 | echo "Invoke this script from drivers/hv directory after applying the base patch" 3 | 4 | git add git_add_files 5 | git add overrides.mk 6 | git add copy_files 7 | git add remove_files 8 | git add README 9 | git add ../../include/linux/hv_compat.h 10 | 11 | git add rhel6-hv-driver-install 12 | git add rhel6-hv-driver-uninstall 13 | 14 | git add hyperv_pvdrivers.conf 15 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/hv_compat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(5,8)) 5 | static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder) 6 | { 7 | union { 8 | u64 v64; 9 | u32 v32[2]; 10 | } d = { dividend }; 11 | u32 upper; 12 | 13 | upper = d.v32[1]; 14 | d.v32[1] = 0; 15 | if (upper >= divisor) { 16 | d.v32[1] = upper / divisor; 17 | upper %= divisor; 18 | } 19 | asm ("divl %2" : "=a" (d.v32[0]), "=d" (*remainder) : 20 | "rm" (divisor), "0" (d.v32[0]), "1" (upper)); 21 | return d.v64; 22 | } 23 | 24 | #ifndef div_s64_rem 25 | s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder) 26 | { 27 | u64 quotient; 28 | 29 | if (dividend < 0) { 30 | quotient = div_u64_rem(-dividend, abs(divisor), (u32 *)remainder); 31 | *remainder = -*remainder; 32 | if (divisor > 0) 33 | quotient = -quotient; 34 | } else { 35 | quotient = div_u64_rem(dividend, abs(divisor), (u32 *)remainder); 36 | if (divisor < 0) 37 | quotient = -quotient; 38 | } 39 | return quotient; 40 | } 41 | EXPORT_SYMBOL(div_s64_rem); 42 | #endif 43 | #endif 44 | 45 | #if RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(5, 9) 46 | struct timespec ns_to_timespec(const s64 nsec) 47 | { 48 | struct timespec ts; 49 | s32 rem; 50 | 51 | if (!nsec) 52 | return (struct timespec) {0, 0}; 53 | 54 | ts.tv_sec = div_s64_rem(nsec, NSEC_PER_SEC, &rem); 55 | if (unlikely(rem < 0)) { 56 | ts.tv_sec--; 57 | rem += NSEC_PER_SEC; 58 | } 59 | ts.tv_nsec = rem; 60 | 61 | return ts; 62 | } 63 | EXPORT_SYMBOL(ns_to_timespec); 64 | #endif 65 | 66 | struct shutdown_event { 67 | struct work_struct wq; 68 | char buf[64]; 69 | char *argv[4]; 70 | char *envp[6]; 71 | }; 72 | 73 | static void hv_usermodehelper(struct shutdown_event *s_event) 74 | { 75 | call_usermodehelper(s_event->argv[0], s_event->argv, s_event->envp, 1); 76 | } 77 | 78 | static struct shutdown_event s_event; 79 | 80 | void rhel_5_x_power_off(void) 81 | { 82 | int cnt = 0; 83 | s_event.argv[cnt++] = "/sbin/poweroff"; 84 | s_event.argv[cnt++] = 0; 85 | 86 | cnt = 0; 87 | 88 | s_event.envp[cnt++] = "HOME=/"; 89 | s_event.envp[cnt++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; 90 | s_event.envp[cnt++] = 0; 91 | INIT_WORK(&s_event.wq, (void *)(void *)hv_usermodehelper, &s_event); 92 | schedule_work(&s_event.wq); 93 | } 94 | EXPORT_SYMBOL(rhel_5_x_power_off); 95 | 96 | //KYS 97 | 98 | #ifndef netdev_err 99 | void netdev_err(struct net_device *net, const char *fmt, ...) //KYS 100 | { 101 | va_list args; 102 | 103 | va_start(args, fmt); 104 | vprintk(fmt, args); 105 | va_end(args); 106 | } 107 | EXPORT_SYMBOL(netdev_err); 108 | #endif 109 | 110 | 111 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/hv_trace.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | 3 | #include "hyperv_vmbus.h" 4 | 5 | #define CREATE_TRACE_POINTS 6 | #include "hv_trace.h" 7 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/hv_trace_balloon.h: -------------------------------------------------------------------------------- 1 | #undef TRACE_SYSTEM 2 | #define TRACE_SYSTEM hyperv 3 | 4 | #if !defined(_HV_TRACE_BALLOON_H) || defined(TRACE_HEADER_MULTI_READ) 5 | #define _HV_TRACE_BALLOON_H 6 | 7 | #include 8 | 9 | TRACE_EVENT(balloon_status, 10 | TP_PROTO(u64 available, u64 committed, 11 | unsigned long vm_memory_committed, 12 | unsigned long pages_ballooned, 13 | unsigned long pages_added, 14 | unsigned long pages_onlined), 15 | TP_ARGS(available, committed, vm_memory_committed, 16 | pages_ballooned, pages_added, pages_onlined), 17 | TP_STRUCT__entry( 18 | __field(u64, available) 19 | __field(u64, committed) 20 | __field(unsigned long, vm_memory_committed) 21 | __field(unsigned long, pages_ballooned) 22 | __field(unsigned long, pages_added) 23 | __field(unsigned long, pages_onlined) 24 | ), 25 | TP_fast_assign( 26 | __entry->available = available; 27 | __entry->committed = committed; 28 | __entry->vm_memory_committed = vm_memory_committed; 29 | __entry->pages_ballooned = pages_ballooned; 30 | __entry->pages_added = pages_added; 31 | __entry->pages_onlined = pages_onlined; 32 | ), 33 | TP_printk("available %lld, committed %lld; vm_memory_committed %ld;" 34 | " pages_ballooned %ld, pages_added %ld, pages_onlined %ld", 35 | __entry->available, __entry->committed, 36 | __entry->vm_memory_committed, __entry->pages_ballooned, 37 | __entry->pages_added, __entry->pages_onlined 38 | ) 39 | ); 40 | 41 | #undef TRACE_INCLUDE_PATH 42 | #define TRACE_INCLUDE_PATH . 43 | #undef TRACE_INCLUDE_FILE 44 | #define TRACE_INCLUDE_FILE hv_trace_balloon 45 | #endif /* _HV_TRACE_BALLOON_H */ 46 | 47 | /* This part must be outside protection */ 48 | #include 49 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/hv_utils_transport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Kernel/userspace transport abstraction for Hyper-V util driver. 3 | * 4 | * Copyright (C) 2015, Vitaly Kuznetsov 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License version 2 as published 8 | * by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 13 | * NON INFRINGEMENT. See the GNU General Public License for more 14 | * details. 15 | * 16 | */ 17 | 18 | #ifndef _HV_UTILS_TRANSPORT_H 19 | #define _HV_UTILS_TRANSPORT_H 20 | 21 | #include 22 | #include 23 | 24 | enum hvutil_transport_mode { 25 | HVUTIL_TRANSPORT_INIT = 0, 26 | HVUTIL_TRANSPORT_NETLINK, 27 | HVUTIL_TRANSPORT_CHARDEV, 28 | HVUTIL_TRANSPORT_DESTROY, 29 | }; 30 | 31 | struct hvutil_transport { 32 | int mode; /* hvutil_transport_mode */ 33 | struct file_operations fops; /* file operations */ 34 | struct miscdevice mdev; /* misc device */ 35 | struct cb_id cn_id; /* CN_*_IDX/CN_*_VAL */ 36 | struct list_head list; /* hvt_list */ 37 | int (*on_msg)(void *, int); /* callback on new user message */ 38 | void (*on_reset)(void); /* callback when userspace drops */ 39 | void (*on_read)(void); /* callback on message read */ 40 | u8 *outmsg; /* message to the userspace */ 41 | int outmsg_len; /* its length */ 42 | wait_queue_head_t outmsg_q; /* poll/read wait queue */ 43 | struct mutex lock; /* protects struct members */ 44 | struct completion release; /* synchronize with fd release */ 45 | }; 46 | 47 | struct hvutil_transport *hvutil_transport_init(const char *name, 48 | u32 cn_idx, u32 cn_val, 49 | int (*on_msg)(void *, int), 50 | void (*on_reset)(void)); 51 | int hvutil_transport_send(struct hvutil_transport *hvt, void *msg, int len, 52 | void (*on_read_cb)(void)); 53 | void hvutil_transport_destroy(struct hvutil_transport *hvt); 54 | 55 | #endif /* _HV_UTILS_TRANSPORT_H */ 56 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/hvnd_addr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Microsoft Corporation. 3 | * 4 | * Author: 5 | * K. Y. Srinivasan 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 as published 9 | * by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 14 | * NON INFRINGEMENT. See the GNU General Public License for more 15 | * details. 16 | * 17 | * Bug fixes/enhancements: Long Li 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include "vmbus_rdma.h" 36 | 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | 50 | int hvnd_get_outgoing_rdma_addr(struct hvnd_dev *nd_dev, struct hvnd_ucontext *uctx, 51 | union nd_sockaddr_inet *og_addr) 52 | { 53 | int ret; 54 | /* 55 | * Query the host and select the first address. 56 | */ 57 | struct pkt_query_addr_list pkt; 58 | 59 | memset(&pkt, 0, sizeof(pkt)); //KYS try to avoid having to zero everything 60 | 61 | hvnd_init_hdr(&pkt.hdr, 62 | (sizeof(pkt) - 63 | sizeof(struct ndv_packet_hdr_control_1)), 64 | uctx->create_pkt.handle.local, 65 | uctx->create_pkt.handle.remote, 66 | IOCTL_ND_ADAPTER_QUERY_ADDRESS_LIST, 0, 0, 0); 67 | 68 | pkt.ioctl.in.version = ND_VERSION_1; 69 | pkt.ioctl.in.reserved = 0; 70 | pkt.ioctl.in.handle = uctx->adaptor_hdl; 71 | 72 | ret = hvnd_send_ioctl_pkt(nd_dev, &pkt.hdr, 73 | sizeof(pkt), (u64)&pkt); 74 | 75 | if (ret) 76 | return ret; 77 | 78 | /* 79 | * Copy the address out. 80 | */ 81 | 82 | memcpy(og_addr, &pkt.ioctl.out[0], sizeof(*og_addr)); 83 | return 0; 84 | 85 | } 86 | 87 | static struct rdma_addr_client self; 88 | 89 | struct resolve_cb_context { 90 | struct rdma_dev_addr *addr; 91 | struct completion comp; 92 | }; 93 | 94 | void hvnd_addr_init(void) 95 | { 96 | rdma_addr_register_client(&self); 97 | return; 98 | } 99 | 100 | void hvnd_addr_deinit(void) 101 | { 102 | rdma_addr_unregister_client(&self); 103 | return; 104 | } 105 | 106 | static void resolve_cb(int status, struct sockaddr *src_addr, 107 | struct rdma_dev_addr *addr, void *context) 108 | { 109 | memcpy(((struct resolve_cb_context *)context)->addr, addr, sizeof(struct 110 | rdma_dev_addr)); 111 | complete(&((struct resolve_cb_context *)context)->comp); 112 | } 113 | 114 | int hvnd_get_neigh_mac_addr(struct sockaddr *local, struct sockaddr *remote, char *mac_addr) 115 | { 116 | struct rdma_dev_addr dev_addr; 117 | struct resolve_cb_context ctx; 118 | int ret; 119 | 120 | memset(&dev_addr, 0, sizeof(dev_addr)); 121 | #if (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,3)) 122 | dev_addr.net = &init_net; 123 | #endif 124 | ctx.addr = &dev_addr; 125 | init_completion(&ctx.comp); 126 | 127 | ret = rdma_resolve_ip(&self, local, remote, &dev_addr, 1000, resolve_cb, &ctx); 128 | 129 | if (ret) { 130 | hvnd_error("rdma_resolve_ip failed ret=%d\n", ret); 131 | return ret; 132 | } 133 | 134 | wait_for_completion(&ctx.comp); 135 | memcpy(mac_addr, dev_addr.dst_dev_addr, ETH_ALEN); 136 | return ret; 137 | } 138 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/hyperv.conf: -------------------------------------------------------------------------------- 1 | # this is hyperv conf file to override inbuilt hyper-v kernel driver. 2 | 3 | override hv_vmbus * weak-updates/microsoft-hyper-v 4 | override hid-hyperv * weak-updates/microsoft-hyper-v 5 | override hv_netvsc * weak-updates/microsoft-hyper-v 6 | override hv_utils * weak-updates/microsoft-hyper-v 7 | override hyperv_fb * weak-updates/microsoft-hyper-v 8 | override hv_balloon * weak-updates/microsoft-hyper-v 9 | override hv_storvsc * weak-updates/microsoft-hyper-v 10 | override hyperv-keyboard * weak-updates/microsoft-hyper-v 11 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/hyperv_mod_blacklist.conf: -------------------------------------------------------------------------------- 1 | # Do not load the 'mlx ib' drivers 2 | install mlx5_ib /bin/false 3 | install mlx4_ib /bin/false 4 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/hyperv_pvdrivers.conf: -------------------------------------------------------------------------------- 1 | # Install HyperV paravirtualized drivers 2 | 3 | install ata_piix { /sbin/modprobe hv_storvsc 2>&1; /sbin/modprobe --ignore-install ata_piix; } 4 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/linux/atomic.h: -------------------------------------------------------------------------------- 1 | /* Atomic operations usable in machine independent code */ 2 | #ifndef _LINUX_ATOMIC_H 3 | #define _LINUX_ATOMIC_H 4 | #include 5 | 6 | /** 7 | * atomic_add_unless - add unless the number is already a given value 8 | * @v: pointer of type atomic_t 9 | * @a: the amount to add to v... 10 | * @u: ...unless v is equal to u. 11 | * 12 | * Atomically adds @a to @v, so long as @v was not already @u. 13 | * Returns non-zero if @v was not @u, and zero otherwise. 14 | */ 15 | static inline int atomic_add_unless(atomic_t *v, int a, int u) 16 | { 17 | return __atomic_add_unless(v, a, u) != u; 18 | } 19 | 20 | /** 21 | * atomic_inc_not_zero - increment unless the number is zero 22 | * @v: pointer of type atomic_t 23 | * 24 | * Atomically increments @v by 1, so long as @v is non-zero. 25 | * Returns non-zero if @v was non-zero, and zero otherwise. 26 | */ 27 | #ifndef atomic_inc_not_zero 28 | #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 29 | #endif 30 | 31 | /** 32 | * atomic_inc_not_zero_hint - increment if not null 33 | * @v: pointer of type atomic_t 34 | * @hint: probable value of the atomic before the increment 35 | * 36 | * This version of atomic_inc_not_zero() gives a hint of probable 37 | * value of the atomic. This helps processor to not read the memory 38 | * before doing the atomic read/modify/write cycle, lowering 39 | * number of bus transactions on some arches. 40 | * 41 | * Returns: 0 if increment was not done, 1 otherwise. 42 | */ 43 | #ifndef atomic_inc_not_zero_hint 44 | static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint) 45 | { 46 | int val, c = hint; 47 | 48 | /* sanity test, should be removed by compiler if hint is a constant */ 49 | if (!hint) 50 | return atomic_inc_not_zero(v); 51 | 52 | do { 53 | val = atomic_cmpxchg(v, c, c + 1); 54 | if (val == c) 55 | return 1; 56 | c = val; 57 | } while (c); 58 | 59 | return 0; 60 | } 61 | #endif 62 | 63 | #ifndef atomic_inc_unless_negative 64 | static inline int atomic_inc_unless_negative(atomic_t *p) 65 | { 66 | int v, v1; 67 | for (v = 0; v >= 0; v = v1) { 68 | v1 = atomic_cmpxchg(p, v, v + 1); 69 | if (likely(v1 == v)) 70 | return 1; 71 | } 72 | return 0; 73 | } 74 | #endif 75 | 76 | #ifndef atomic_dec_unless_positive 77 | static inline int atomic_dec_unless_positive(atomic_t *p) 78 | { 79 | int v, v1; 80 | for (v = 0; v <= 0; v = v1) { 81 | v1 = atomic_cmpxchg(p, v, v - 1); 82 | if (likely(v1 == v)) 83 | return 1; 84 | } 85 | return 0; 86 | } 87 | #endif 88 | 89 | /* 90 | * atomic_dec_if_positive - decrement by 1 if old value positive 91 | * @v: pointer of type atomic_t 92 | * 93 | * The function returns the old value of *v minus 1, even if 94 | * the atomic variable, v, was not decremented. 95 | */ 96 | #ifndef atomic_dec_if_positive 97 | static inline int atomic_dec_if_positive(atomic_t *v) 98 | { 99 | int c, old, dec; 100 | c = atomic_read(v); 101 | for (;;) { 102 | dec = c - 1; 103 | if (unlikely(dec < 0)) 104 | break; 105 | old = atomic_cmpxchg((v), c, dec); 106 | if (likely(old == c)) 107 | break; 108 | c = old; 109 | } 110 | return dec; 111 | } 112 | #endif 113 | 114 | #ifndef CONFIG_ARCH_HAS_ATOMIC_OR 115 | static inline void atomic_or(int i, atomic_t *v) 116 | { 117 | int old; 118 | int new; 119 | 120 | do { 121 | old = atomic_read(v); 122 | new = old | i; 123 | } while (atomic_cmpxchg(v, old, new) != old); 124 | } 125 | #endif /* #ifndef CONFIG_ARCH_HAS_ATOMIC_OR */ 126 | 127 | #include 128 | #ifdef CONFIG_GENERIC_ATOMIC64 129 | #include 130 | #endif 131 | #endif /* _LINUX_ATOMIC_H */ 132 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/linux/export.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_EXPORT_H 2 | #define _LINUX_EXPORT_H 3 | /* 4 | * Export symbols from the kernel to modules. Forked from module.h 5 | * to reduce the amount of pointless cruft we feed to gcc when only 6 | * exporting a simple symbol or two. 7 | * 8 | * Try not to add #includes here. It slows compilation and makes kernel 9 | * hackers place grumpy comments in header files. 10 | */ 11 | 12 | /* Some toolchains use a `_' prefix for all user symbols. */ 13 | #ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX 14 | #define __VMLINUX_SYMBOL(x) _##x 15 | #define __VMLINUX_SYMBOL_STR(x) "_" #x 16 | #else 17 | #define __VMLINUX_SYMBOL(x) x 18 | #define __VMLINUX_SYMBOL_STR(x) #x 19 | #endif 20 | 21 | /* Indirect, so macros are expanded before pasting. */ 22 | #define VMLINUX_SYMBOL(x) __VMLINUX_SYMBOL(x) 23 | #define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x) 24 | 25 | #ifndef __ASSEMBLY__ 26 | struct kernel_symbol 27 | { 28 | unsigned long value; 29 | const char *name; 30 | }; 31 | 32 | #ifdef MODULE 33 | extern struct module __this_module; 34 | #define THIS_MODULE (&__this_module) 35 | #else 36 | #define THIS_MODULE ((struct module *)0) 37 | #endif 38 | 39 | #ifdef CONFIG_MODULES 40 | 41 | #ifndef __GENKSYMS__ 42 | #ifdef CONFIG_MODVERSIONS 43 | /* Mark the CRC weak since genksyms apparently decides not to 44 | * generate a checksums for some symbols */ 45 | #define __CRC_SYMBOL(sym, sec) \ 46 | extern __visible void *__crc_##sym __attribute__((weak)); \ 47 | static const unsigned long __kcrctab_##sym \ 48 | __used \ 49 | __attribute__((section("___kcrctab" sec "+" #sym), unused)) \ 50 | = (unsigned long) &__crc_##sym; 51 | #else 52 | #define __CRC_SYMBOL(sym, sec) 53 | #endif 54 | 55 | /* For every exported symbol, place a struct in the __ksymtab section */ 56 | #define __EXPORT_SYMBOL(sym, sec) \ 57 | extern typeof(sym) sym; \ 58 | __CRC_SYMBOL(sym, sec) \ 59 | static const char __kstrtab_##sym[] \ 60 | __attribute__((section("__ksymtab_strings"), aligned(1))) \ 61 | = VMLINUX_SYMBOL_STR(sym); \ 62 | extern const struct kernel_symbol __ksymtab_##sym; \ 63 | __visible const struct kernel_symbol __ksymtab_##sym \ 64 | __used \ 65 | __attribute__((section("___ksymtab" sec "+" #sym), unused)) \ 66 | = { (unsigned long)&sym, __kstrtab_##sym } 67 | 68 | #define EXPORT_SYMBOL(sym) \ 69 | __EXPORT_SYMBOL(sym, "") 70 | 71 | #define EXPORT_SYMBOL_GPL(sym) \ 72 | __EXPORT_SYMBOL(sym, "_gpl") 73 | 74 | #define EXPORT_SYMBOL_GPL_FUTURE(sym) \ 75 | __EXPORT_SYMBOL(sym, "_gpl_future") 76 | 77 | #ifdef CONFIG_UNUSED_SYMBOLS 78 | #define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused") 79 | #define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl") 80 | #else 81 | #define EXPORT_UNUSED_SYMBOL(sym) 82 | #define EXPORT_UNUSED_SYMBOL_GPL(sym) 83 | #endif 84 | 85 | #endif /* __GENKSYMS__ */ 86 | 87 | #else /* !CONFIG_MODULES... */ 88 | 89 | #define EXPORT_SYMBOL(sym) 90 | #define EXPORT_SYMBOL_GPL(sym) 91 | #define EXPORT_SYMBOL_GPL_FUTURE(sym) 92 | #define EXPORT_UNUSED_SYMBOL(sym) 93 | #define EXPORT_UNUSED_SYMBOL_GPL(sym) 94 | 95 | #endif /* CONFIG_MODULES */ 96 | #endif /* !__ASSEMBLY__ */ 97 | 98 | #endif /* _LINUX_EXPORT_H */ 99 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/linux/hid-debug.h: -------------------------------------------------------------------------------- 1 | #ifndef __HID_DEBUG_H 2 | #define __HID_DEBUG_H 3 | 4 | /* 5 | * Copyright (c) 2007-2009 Jiri Kosina 6 | */ 7 | 8 | /* 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | */ 24 | 25 | #define HID_DEBUG_BUFSIZE 512 26 | 27 | #ifdef CONFIG_DEBUG_FS 28 | 29 | void hid_dump_input(struct hid_device *, struct hid_usage *, __s32); 30 | void hid_dump_device(struct hid_device *, struct seq_file *); 31 | void hid_dump_field(struct hid_field *, int, struct seq_file *); 32 | char *hid_resolv_usage(unsigned, struct seq_file *); 33 | void hid_debug_register(struct hid_device *, const char *); 34 | void hid_debug_unregister(struct hid_device *); 35 | void hid_debug_init(void); 36 | void hid_debug_exit(void); 37 | void hid_debug_event(struct hid_device *, char *); 38 | 39 | 40 | struct hid_debug_list { 41 | char *hid_debug_buf; 42 | int head; 43 | int tail; 44 | struct fasync_struct *fasync; 45 | struct hid_device *hdev; 46 | struct list_head node; 47 | struct mutex read_mutex; 48 | }; 49 | 50 | #else 51 | 52 | #define hid_dump_input(a,b,c) do { } while (0) 53 | #define hid_dump_device(a,b) do { } while (0) 54 | #define hid_dump_field(a,b,c) do { } while (0) 55 | #define hid_resolv_usage(a,b) do { } while (0) 56 | #define hid_debug_register(a, b) do { } while (0) 57 | #define hid_debug_unregister(a) do { } while (0) 58 | #define hid_debug_init() do { } while (0) 59 | #define hid_debug_exit() do { } while (0) 60 | #define hid_debug_event(a,b) do { } while (0) 61 | 62 | #endif 63 | 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/linux/hidraw.h: -------------------------------------------------------------------------------- 1 | #ifndef _HIDRAW_H 2 | #define _HIDRAW_H 3 | 4 | /* 5 | * Copyright (c) 2007 Jiri Kosina 6 | */ 7 | 8 | /* 9 | * This program is free software; you can redistribute it and/or modify it 10 | * under the terms and conditions of the GNU General Public License, 11 | * version 2, as published by the Free Software Foundation. 12 | * 13 | * You should have received a copy of the GNU General Public License along with 14 | * this program; if not, write to the Free Software Foundation, Inc., 15 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | struct hidraw_report_descriptor { 22 | __u32 size; 23 | __u8 value[HID_MAX_DESCRIPTOR_SIZE]; 24 | }; 25 | 26 | struct hidraw_devinfo { 27 | __u32 bustype; 28 | __s16 vendor; 29 | __s16 product; 30 | }; 31 | 32 | /* ioctl interface */ 33 | #define HIDIOCGRDESCSIZE _IOR('H', 0x01, int) 34 | #define HIDIOCGRDESC _IOR('H', 0x02, struct hidraw_report_descriptor) 35 | #define HIDIOCGRAWINFO _IOR('H', 0x03, struct hidraw_devinfo) 36 | #define HIDIOCGRAWNAME(len) _IOC(_IOC_READ, 'H', 0x04, len) 37 | #define HIDIOCGRAWPHYS(len) _IOC(_IOC_READ, 'H', 0x05, len) 38 | /* The first byte of SFEATURE and GFEATURE is the report number */ 39 | #define HIDIOCSFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len) 40 | #define HIDIOCGFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len) 41 | 42 | #define HIDRAW_FIRST_MINOR 0 43 | #define HIDRAW_MAX_DEVICES 64 44 | /* number of reports to buffer */ 45 | #define HIDRAW_BUFFER_SIZE 64 46 | 47 | 48 | /* kernel-only API declarations */ 49 | #ifdef __KERNEL__ 50 | 51 | struct hidraw { 52 | unsigned int minor; 53 | int exist; 54 | int open; 55 | wait_queue_head_t wait; 56 | struct hid_device *hid; 57 | struct device *dev; 58 | struct list_head list; 59 | }; 60 | 61 | struct hidraw_report { 62 | __u8 *value; 63 | int len; 64 | }; 65 | 66 | struct hidraw_list { 67 | struct hidraw_report buffer[HIDRAW_BUFFER_SIZE]; 68 | int head; 69 | int tail; 70 | struct fasync_struct *fasync; 71 | struct hidraw *hidraw; 72 | struct list_head node; 73 | struct mutex read_mutex; 74 | }; 75 | 76 | #ifdef CONFIG_HIDRAW 77 | int hidraw_init(void); 78 | void hidraw_exit(void); 79 | int hidraw_report_event(struct hid_device *, u8 *, int); 80 | int hidraw_connect(struct hid_device *); 81 | void hidraw_disconnect(struct hid_device *); 82 | #else 83 | static inline int hidraw_init(void) { return 0; } 84 | static inline void hidraw_exit(void) { } 85 | static inline int hidraw_report_event(struct hid_device *hid, u8 *data, int len) { return 0; } 86 | static inline int hidraw_connect(struct hid_device *hid) { return -1; } 87 | static inline void hidraw_disconnect(struct hid_device *hid) { } 88 | #endif 89 | 90 | #endif 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/linux/unaligned/access_ok.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_ACCESS_OK_H 2 | #define _LINUX_UNALIGNED_ACCESS_OK_H 3 | 4 | #include 5 | #include 6 | 7 | static inline u16 get_unaligned_le16(const void *p) 8 | { 9 | return le16_to_cpup((__le16 *)p); 10 | } 11 | 12 | static inline u32 get_unaligned_le32(const void *p) 13 | { 14 | return le32_to_cpup((__le32 *)p); 15 | } 16 | 17 | static inline u64 get_unaligned_le64(const void *p) 18 | { 19 | return le64_to_cpup((__le64 *)p); 20 | } 21 | 22 | static inline u16 get_unaligned_be16(const void *p) 23 | { 24 | return be16_to_cpup((__be16 *)p); 25 | } 26 | 27 | static inline u32 get_unaligned_be32(const void *p) 28 | { 29 | return be32_to_cpup((__be32 *)p); 30 | } 31 | 32 | static inline u64 get_unaligned_be64(const void *p) 33 | { 34 | return be64_to_cpup((__be64 *)p); 35 | } 36 | 37 | static inline void put_unaligned_le16(u16 val, void *p) 38 | { 39 | *((__le16 *)p) = cpu_to_le16(val); 40 | } 41 | 42 | static inline void put_unaligned_le32(u32 val, void *p) 43 | { 44 | *((__le32 *)p) = cpu_to_le32(val); 45 | } 46 | 47 | static inline void put_unaligned_le64(u64 val, void *p) 48 | { 49 | *((__le64 *)p) = cpu_to_le64(val); 50 | } 51 | 52 | static inline void put_unaligned_be16(u16 val, void *p) 53 | { 54 | *((__be16 *)p) = cpu_to_be16(val); 55 | } 56 | 57 | static inline void put_unaligned_be32(u32 val, void *p) 58 | { 59 | *((__be32 *)p) = cpu_to_be32(val); 60 | } 61 | 62 | static inline void put_unaligned_be64(u64 val, void *p) 63 | { 64 | *((__be64 *)p) = cpu_to_be64(val); 65 | } 66 | 67 | #endif /* _LINUX_UNALIGNED_ACCESS_OK_H */ 68 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/linux/unaligned/be_byteshift.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_BE_BYTESHIFT_H 2 | #define _LINUX_UNALIGNED_BE_BYTESHIFT_H 3 | 4 | #include 5 | 6 | static inline u16 __get_unaligned_be16(const u8 *p) 7 | { 8 | return p[0] << 8 | p[1]; 9 | } 10 | 11 | static inline u32 __get_unaligned_be32(const u8 *p) 12 | { 13 | return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]; 14 | } 15 | 16 | static inline u64 __get_unaligned_be64(const u8 *p) 17 | { 18 | return (u64)__get_unaligned_be32(p) << 32 | 19 | __get_unaligned_be32(p + 4); 20 | } 21 | 22 | static inline void __put_unaligned_be16(u16 val, u8 *p) 23 | { 24 | *p++ = val >> 8; 25 | *p++ = val; 26 | } 27 | 28 | static inline void __put_unaligned_be32(u32 val, u8 *p) 29 | { 30 | __put_unaligned_be16(val >> 16, p); 31 | __put_unaligned_be16(val, p + 2); 32 | } 33 | 34 | static inline void __put_unaligned_be64(u64 val, u8 *p) 35 | { 36 | __put_unaligned_be32(val >> 32, p); 37 | __put_unaligned_be32(val, p + 4); 38 | } 39 | 40 | static inline u16 get_unaligned_be16(const void *p) 41 | { 42 | return __get_unaligned_be16((const u8 *)p); 43 | } 44 | 45 | static inline u32 get_unaligned_be32(const void *p) 46 | { 47 | return __get_unaligned_be32((const u8 *)p); 48 | } 49 | 50 | static inline u64 get_unaligned_be64(const void *p) 51 | { 52 | return __get_unaligned_be64((const u8 *)p); 53 | } 54 | 55 | static inline void put_unaligned_be16(u16 val, void *p) 56 | { 57 | __put_unaligned_be16(val, p); 58 | } 59 | 60 | static inline void put_unaligned_be32(u32 val, void *p) 61 | { 62 | __put_unaligned_be32(val, p); 63 | } 64 | 65 | static inline void put_unaligned_be64(u64 val, void *p) 66 | { 67 | __put_unaligned_be64(val, p); 68 | } 69 | 70 | #endif /* _LINUX_UNALIGNED_BE_BYTESHIFT_H */ 71 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/linux/unaligned/be_memmove.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_BE_MEMMOVE_H 2 | #define _LINUX_UNALIGNED_BE_MEMMOVE_H 3 | 4 | #include 5 | 6 | static inline u16 get_unaligned_be16(const void *p) 7 | { 8 | return __get_unaligned_memmove16((const u8 *)p); 9 | } 10 | 11 | static inline u32 get_unaligned_be32(const void *p) 12 | { 13 | return __get_unaligned_memmove32((const u8 *)p); 14 | } 15 | 16 | static inline u64 get_unaligned_be64(const void *p) 17 | { 18 | return __get_unaligned_memmove64((const u8 *)p); 19 | } 20 | 21 | static inline void put_unaligned_be16(u16 val, void *p) 22 | { 23 | __put_unaligned_memmove16(val, p); 24 | } 25 | 26 | static inline void put_unaligned_be32(u32 val, void *p) 27 | { 28 | __put_unaligned_memmove32(val, p); 29 | } 30 | 31 | static inline void put_unaligned_be64(u64 val, void *p) 32 | { 33 | __put_unaligned_memmove64(val, p); 34 | } 35 | 36 | #endif /* _LINUX_UNALIGNED_LE_MEMMOVE_H */ 37 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/linux/unaligned/be_struct.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_BE_STRUCT_H 2 | #define _LINUX_UNALIGNED_BE_STRUCT_H 3 | 4 | #include 5 | 6 | static inline u16 get_unaligned_be16(const void *p) 7 | { 8 | return __get_unaligned_cpu16((const u8 *)p); 9 | } 10 | 11 | static inline u32 get_unaligned_be32(const void *p) 12 | { 13 | return __get_unaligned_cpu32((const u8 *)p); 14 | } 15 | 16 | static inline u64 get_unaligned_be64(const void *p) 17 | { 18 | return __get_unaligned_cpu64((const u8 *)p); 19 | } 20 | 21 | static inline void put_unaligned_be16(u16 val, void *p) 22 | { 23 | __put_unaligned_cpu16(val, p); 24 | } 25 | 26 | static inline void put_unaligned_be32(u32 val, void *p) 27 | { 28 | __put_unaligned_cpu32(val, p); 29 | } 30 | 31 | static inline void put_unaligned_be64(u64 val, void *p) 32 | { 33 | __put_unaligned_cpu64(val, p); 34 | } 35 | 36 | #endif /* _LINUX_UNALIGNED_BE_STRUCT_H */ 37 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/linux/unaligned/generic.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_GENERIC_H 2 | #define _LINUX_UNALIGNED_GENERIC_H 3 | 4 | /* 5 | * Cause a link-time error if we try an unaligned access other than 6 | * 1,2,4 or 8 bytes long 7 | */ 8 | extern void __bad_unaligned_access_size(void); 9 | 10 | #define __get_unaligned_le(ptr) ((__force typeof(*(ptr)))({ \ 11 | __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \ 12 | __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_le16((ptr)), \ 13 | __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_le32((ptr)), \ 14 | __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_le64((ptr)), \ 15 | __bad_unaligned_access_size())))); \ 16 | })) 17 | 18 | #define __get_unaligned_be(ptr) ((__force typeof(*(ptr)))({ \ 19 | __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \ 20 | __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_be16((ptr)), \ 21 | __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_be32((ptr)), \ 22 | __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_be64((ptr)), \ 23 | __bad_unaligned_access_size())))); \ 24 | })) 25 | 26 | #define __put_unaligned_le(val, ptr) ({ \ 27 | void *__gu_p = (ptr); \ 28 | switch (sizeof(*(ptr))) { \ 29 | case 1: \ 30 | *(u8 *)__gu_p = (__force u8)(val); \ 31 | break; \ 32 | case 2: \ 33 | put_unaligned_le16((__force u16)(val), __gu_p); \ 34 | break; \ 35 | case 4: \ 36 | put_unaligned_le32((__force u32)(val), __gu_p); \ 37 | break; \ 38 | case 8: \ 39 | put_unaligned_le64((__force u64)(val), __gu_p); \ 40 | break; \ 41 | default: \ 42 | __bad_unaligned_access_size(); \ 43 | break; \ 44 | } \ 45 | (void)0; }) 46 | 47 | #define __put_unaligned_be(val, ptr) ({ \ 48 | void *__gu_p = (ptr); \ 49 | switch (sizeof(*(ptr))) { \ 50 | case 1: \ 51 | *(u8 *)__gu_p = (__force u8)(val); \ 52 | break; \ 53 | case 2: \ 54 | put_unaligned_be16((__force u16)(val), __gu_p); \ 55 | break; \ 56 | case 4: \ 57 | put_unaligned_be32((__force u32)(val), __gu_p); \ 58 | break; \ 59 | case 8: \ 60 | put_unaligned_be64((__force u64)(val), __gu_p); \ 61 | break; \ 62 | default: \ 63 | __bad_unaligned_access_size(); \ 64 | break; \ 65 | } \ 66 | (void)0; }) 67 | 68 | #endif /* _LINUX_UNALIGNED_GENERIC_H */ 69 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/linux/unaligned/le_byteshift.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_LE_BYTESHIFT_H 2 | #define _LINUX_UNALIGNED_LE_BYTESHIFT_H 3 | 4 | #include 5 | 6 | static inline u16 __get_unaligned_le16(const u8 *p) 7 | { 8 | return p[0] | p[1] << 8; 9 | } 10 | 11 | static inline u32 __get_unaligned_le32(const u8 *p) 12 | { 13 | return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; 14 | } 15 | 16 | static inline u64 __get_unaligned_le64(const u8 *p) 17 | { 18 | return (u64)__get_unaligned_le32(p + 4) << 32 | 19 | __get_unaligned_le32(p); 20 | } 21 | 22 | static inline void __put_unaligned_le16(u16 val, u8 *p) 23 | { 24 | *p++ = val; 25 | *p++ = val >> 8; 26 | } 27 | 28 | static inline void __put_unaligned_le32(u32 val, u8 *p) 29 | { 30 | __put_unaligned_le16(val >> 16, p + 2); 31 | __put_unaligned_le16(val, p); 32 | } 33 | 34 | static inline void __put_unaligned_le64(u64 val, u8 *p) 35 | { 36 | __put_unaligned_le32(val >> 32, p + 4); 37 | __put_unaligned_le32(val, p); 38 | } 39 | 40 | static inline u16 get_unaligned_le16(const void *p) 41 | { 42 | return __get_unaligned_le16((const u8 *)p); 43 | } 44 | 45 | static inline u32 get_unaligned_le32(const void *p) 46 | { 47 | return __get_unaligned_le32((const u8 *)p); 48 | } 49 | 50 | static inline u64 get_unaligned_le64(const void *p) 51 | { 52 | return __get_unaligned_le64((const u8 *)p); 53 | } 54 | 55 | static inline void put_unaligned_le16(u16 val, void *p) 56 | { 57 | __put_unaligned_le16(val, p); 58 | } 59 | 60 | static inline void put_unaligned_le32(u32 val, void *p) 61 | { 62 | __put_unaligned_le32(val, p); 63 | } 64 | 65 | static inline void put_unaligned_le64(u64 val, void *p) 66 | { 67 | __put_unaligned_le64(val, p); 68 | } 69 | 70 | #endif /* _LINUX_UNALIGNED_LE_BYTESHIFT_H */ 71 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/linux/unaligned/le_memmove.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_LE_MEMMOVE_H 2 | #define _LINUX_UNALIGNED_LE_MEMMOVE_H 3 | 4 | #include 5 | 6 | static inline u16 get_unaligned_le16(const void *p) 7 | { 8 | return __get_unaligned_memmove16((const u8 *)p); 9 | } 10 | 11 | static inline u32 get_unaligned_le32(const void *p) 12 | { 13 | return __get_unaligned_memmove32((const u8 *)p); 14 | } 15 | 16 | static inline u64 get_unaligned_le64(const void *p) 17 | { 18 | return __get_unaligned_memmove64((const u8 *)p); 19 | } 20 | 21 | static inline void put_unaligned_le16(u16 val, void *p) 22 | { 23 | __put_unaligned_memmove16(val, p); 24 | } 25 | 26 | static inline void put_unaligned_le32(u32 val, void *p) 27 | { 28 | __put_unaligned_memmove32(val, p); 29 | } 30 | 31 | static inline void put_unaligned_le64(u64 val, void *p) 32 | { 33 | __put_unaligned_memmove64(val, p); 34 | } 35 | 36 | #endif /* _LINUX_UNALIGNED_LE_MEMMOVE_H */ 37 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/linux/unaligned/le_struct.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_LE_STRUCT_H 2 | #define _LINUX_UNALIGNED_LE_STRUCT_H 3 | 4 | #include 5 | 6 | static inline u16 get_unaligned_le16(const void *p) 7 | { 8 | return __get_unaligned_cpu16((const u8 *)p); 9 | } 10 | 11 | static inline u32 get_unaligned_le32(const void *p) 12 | { 13 | return __get_unaligned_cpu32((const u8 *)p); 14 | } 15 | 16 | static inline u64 get_unaligned_le64(const void *p) 17 | { 18 | return __get_unaligned_cpu64((const u8 *)p); 19 | } 20 | 21 | static inline void put_unaligned_le16(u16 val, void *p) 22 | { 23 | __put_unaligned_cpu16(val, p); 24 | } 25 | 26 | static inline void put_unaligned_le32(u32 val, void *p) 27 | { 28 | __put_unaligned_cpu32(val, p); 29 | } 30 | 31 | static inline void put_unaligned_le64(u64 val, void *p) 32 | { 33 | __put_unaligned_cpu64(val, p); 34 | } 35 | 36 | #endif /* _LINUX_UNALIGNED_LE_STRUCT_H */ 37 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/linux/unaligned/memmove.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_MEMMOVE_H 2 | #define _LINUX_UNALIGNED_MEMMOVE_H 3 | 4 | #include 5 | #include 6 | 7 | /* Use memmove here, so gcc does not insert a __builtin_memcpy. */ 8 | 9 | static inline u16 __get_unaligned_memmove16(const void *p) 10 | { 11 | u16 tmp; 12 | memmove(&tmp, p, 2); 13 | return tmp; 14 | } 15 | 16 | static inline u32 __get_unaligned_memmove32(const void *p) 17 | { 18 | u32 tmp; 19 | memmove(&tmp, p, 4); 20 | return tmp; 21 | } 22 | 23 | static inline u64 __get_unaligned_memmove64(const void *p) 24 | { 25 | u64 tmp; 26 | memmove(&tmp, p, 8); 27 | return tmp; 28 | } 29 | 30 | static inline void __put_unaligned_memmove16(u16 val, void *p) 31 | { 32 | memmove(p, &val, 2); 33 | } 34 | 35 | static inline void __put_unaligned_memmove32(u32 val, void *p) 36 | { 37 | memmove(p, &val, 4); 38 | } 39 | 40 | static inline void __put_unaligned_memmove64(u64 val, void *p) 41 | { 42 | memmove(p, &val, 8); 43 | } 44 | 45 | #endif /* _LINUX_UNALIGNED_MEMMOVE_H */ 46 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/linux/unaligned/packed_struct.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_UNALIGNED_PACKED_STRUCT_H 2 | #define _LINUX_UNALIGNED_PACKED_STRUCT_H 3 | 4 | #include 5 | 6 | struct __una_u16 { u16 x; } __packed; 7 | struct __una_u32 { u32 x; } __packed; 8 | struct __una_u64 { u64 x; } __packed; 9 | 10 | static inline u16 __get_unaligned_cpu16(const void *p) 11 | { 12 | const struct __una_u16 *ptr = (const struct __una_u16 *)p; 13 | return ptr->x; 14 | } 15 | 16 | static inline u32 __get_unaligned_cpu32(const void *p) 17 | { 18 | const struct __una_u32 *ptr = (const struct __una_u32 *)p; 19 | return ptr->x; 20 | } 21 | 22 | static inline u64 __get_unaligned_cpu64(const void *p) 23 | { 24 | const struct __una_u64 *ptr = (const struct __una_u64 *)p; 25 | return ptr->x; 26 | } 27 | 28 | static inline void __put_unaligned_cpu16(u16 val, void *p) 29 | { 30 | struct __una_u16 *ptr = (struct __una_u16 *)p; 31 | ptr->x = val; 32 | } 33 | 34 | static inline void __put_unaligned_cpu32(u32 val, void *p) 35 | { 36 | struct __una_u32 *ptr = (struct __una_u32 *)p; 37 | ptr->x = val; 38 | } 39 | 40 | static inline void __put_unaligned_cpu64(u64 val, void *p) 41 | { 42 | struct __una_u64 *ptr = (struct __una_u64 *)p; 43 | ptr->x = val; 44 | } 45 | 46 | #endif /* _LINUX_UNALIGNED_PACKED_STRUCT_H */ 47 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/linux/uuid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UUID/GUID definition 3 | * 4 | * Copyright (C) 2010, Intel Corp. 5 | * Huang Ying 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License version 9 | * 2 as published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | #ifndef _LINUX_UUID_H_ 21 | #define _LINUX_UUID_H_ 22 | 23 | #include "../uapi/linux/uuid.h" 24 | 25 | 26 | static inline int uuid_le_cmp(const uuid_le u1, const uuid_le u2) 27 | { 28 | return memcmp(&u1, &u2, sizeof(uuid_le)); 29 | } 30 | 31 | static inline int uuid_be_cmp(const uuid_be u1, const uuid_be u2) 32 | { 33 | return memcmp(&u1, &u2, sizeof(uuid_be)); 34 | } 35 | 36 | extern void uuid_le_gen(uuid_le *u); 37 | extern void uuid_be_gen(uuid_be *u); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/include/uapi/linux/uuid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UUID/GUID definition 3 | * 4 | * Copyright (C) 2010, Intel Corp. 5 | * Huang Ying 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License version 9 | * 2 as published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef _UAPI_LINUX_UUID_H_ 22 | #define _UAPI_LINUX_UUID_H_ 23 | 24 | #include 25 | #include 26 | 27 | typedef struct { 28 | __u8 b[16]; 29 | } uuid_le; 30 | 31 | typedef struct { 32 | __u8 b[16]; 33 | } uuid_be; 34 | 35 | #define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ 36 | ((uuid_le) \ 37 | {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ 38 | (b) & 0xff, ((b) >> 8) & 0xff, \ 39 | (c) & 0xff, ((c) >> 8) & 0xff, \ 40 | (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) 41 | 42 | #define UUID_BE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ 43 | ((uuid_be) \ 44 | {{ ((a) >> 24) & 0xff, ((a) >> 16) & 0xff, ((a) >> 8) & 0xff, (a) & 0xff, \ 45 | ((b) >> 8) & 0xff, (b) & 0xff, \ 46 | ((c) >> 8) & 0xff, (c) & 0xff, \ 47 | (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) 48 | 49 | #define NULL_UUID_LE \ 50 | UUID_LE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, \ 51 | 0x00, 0x00, 0x00, 0x00) 52 | 53 | #define NULL_UUID_BE \ 54 | UUID_BE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, \ 55 | 0x00, 0x00, 0x00, 0x00) 56 | 57 | 58 | #endif /* _UAPI_LINUX_UUID_H_ */ 59 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/mlnx-ofa_kernel-4.5.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIS/lis-next/5f06e3f9530cc7c0dcece6f6d0fb1b0987ac17df/hv-rhel7.x/hv/mlnx-ofa_kernel-4.5.tgz -------------------------------------------------------------------------------- /hv-rhel7.x/hv/mx_abi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 Topspin Communications. All rights reserved. 3 | * Copyright (c) 2005 Cisco Systems. All rights reserved. 4 | * Copyright (c) 2005 PathScale, Inc. All rights reserved. 5 | * 6 | * This software is available to you under a choice of one of two 7 | * licenses. You may choose to be licensed under the terms of the GNU 8 | * General Public License (GPL) Version 2, available from the file 9 | * COPYING in the main directory of this source tree, or the 10 | * OpenIB.org BSD license below: 11 | * 12 | * Redistribution and use in source and binary forms, with or 13 | * without modification, are permitted provided that the following 14 | * conditions are met: 15 | * 16 | * - Redistributions of source code must retain the above 17 | * copyright notice, this list of conditions and the following 18 | * disclaimer. 19 | * 20 | * - Redistributions in binary form must reproduce the above 21 | * copyright notice, this list of conditions and the following 22 | * disclaimer in the documentation and/or other materials 23 | * provided with the distribution. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 | * SOFTWARE. 33 | * 34 | * KYS: made some modifications. 35 | */ 36 | 37 | #ifndef MX_ABI_H 38 | #define MX_ABI_H 39 | 40 | 41 | 42 | /* 43 | * Make sure that all structs defined in this file remain laid out so 44 | * that they pack the same way on 32-bit and 64-bit architectures (to 45 | * avoid incompatibility between 32-bit userspace and 64-bit kernels). 46 | * Specifically: 47 | * - Do not use pointer types -- pass pointers in UINT64 instead. 48 | * - Make sure that any structure larger than 4 bytes is padded to a 49 | * multiple of 8 bytes. Otherwise the structure size will be 50 | * different between 32-bit and 64-bit architectures. 51 | */ 52 | 53 | enum ibv_get_context_mappings { 54 | IBV_GET_CONTEXT_UAR, 55 | IBV_GET_CONTEXT_BF, 56 | IBV_GET_CONTEXT_MAPPING_MAX 57 | }; 58 | 59 | struct ibv_get_context_req { 60 | 61 | union nd_mapping mappings[IBV_GET_CONTEXT_MAPPING_MAX]; 62 | }; 63 | 64 | struct ibv_get_context_resp { 65 | 66 | // mmap UAR and BF 67 | struct nd_mapping_result mapping_results[IBV_GET_CONTEXT_MAPPING_MAX]; 68 | 69 | // mmap Blue Flame 70 | int bf_buf_size; 71 | int bf_offset; 72 | 73 | // mlx4_query_device result 74 | int max_qp_wr; 75 | int max_sge; 76 | int max_cqe; 77 | 78 | // general parameters 79 | u32 cqe_size; 80 | u32 vend_id; 81 | u16 dev_id; 82 | u16 bf_reg_size; 83 | u16 bf_regs_per_page; 84 | u16 reserved1; 85 | 86 | // ibv_cmd_get_context result 87 | u32 qp_tab_size; 88 | 89 | u32 reserved2; 90 | }; 91 | 92 | struct ibv_alloc_pd_resp { 93 | u64 pd_handle; 94 | u32 pdn; 95 | u32 reserved; 96 | }; 97 | 98 | struct ibv_reg_mr { 99 | u64 start; 100 | u64 length; 101 | u64 hca_va; 102 | u32 access_flags; 103 | u32 pdn; 104 | u64 pd_handle; 105 | }; 106 | 107 | struct ibv_reg_mr_resp { 108 | u64 mr_handle; 109 | u32 lkey; 110 | u32 rkey; 111 | }; 112 | 113 | 114 | enum mlx4_ib_create_cq_mapping { 115 | MLX4_IB_CREATE_CQ_BUF, 116 | MLX4_IB_CREATE_CQ_DB, 117 | MLX4_IB_CREATE_CQ_ARM_SN, // Windows specific 118 | MLX4_IB_CREATE_CQ_MAPPING_MAX 119 | }; 120 | 121 | #define MLX4_CQ_FLAGS_ARM_IN_KERNEL 1 122 | 123 | struct ibv_create_cq { 124 | union nd_mapping mappings[MLX4_IB_CREATE_CQ_MAPPING_MAX]; 125 | u32 flags; 126 | }; 127 | 128 | struct ibv_create_cq_resp { 129 | struct nd_mapping_result mapping_results[MLX4_IB_CREATE_CQ_MAPPING_MAX]; 130 | u32 cqn; 131 | u32 cqe; 132 | }; 133 | 134 | enum mlx4_ib_create_srq_mappings { 135 | MLX4_IB_CREATE_SRQ_BUF, 136 | MLX4_IB_CREATE_SRQ_DB, 137 | MLX4_IB_CREATE_SRQ_MAPPINGS_MAX 138 | }; 139 | 140 | struct ibv_create_srq { 141 | union nd_mapping mappings[MLX4_IB_CREATE_SRQ_MAPPINGS_MAX]; 142 | }; 143 | 144 | struct ibv_create_srq_resp { 145 | struct nd_mapping_result mapping_results[MLX4_IB_CREATE_SRQ_MAPPINGS_MAX]; 146 | }; 147 | 148 | enum mlx4_ib_create_qp_mappings { 149 | MLX4_IB_CREATE_QP_BUF, 150 | MLX4_IB_CREATE_QP_DB, 151 | MLX4_IB_CREATE_QP_MAPPINGS_MAX 152 | }; 153 | 154 | struct ibv_create_qp { 155 | union nd_mapping mappings[MLX4_IB_CREATE_QP_MAPPINGS_MAX]; 156 | u8 log_sq_bb_count; 157 | u8 log_sq_stride; 158 | u8 sq_no_prefetch; 159 | u8 reserved; 160 | }; 161 | 162 | struct ibv_create_qp_resp { 163 | struct nd_mapping_result mapping_results[MLX4_IB_CREATE_QP_MAPPINGS_MAX]; 164 | // struct ib_uverbs_create_qp_resp 165 | u64 qp_handle; 166 | u32 qpn; 167 | u32 max_send_wr; 168 | u32 max_recv_wr; 169 | u32 max_send_sge; 170 | u32 max_recv_sge; 171 | u32 max_inline_data; 172 | }; 173 | 174 | enum ibv_qp_attr_mask { 175 | IBV_QP_STATE = 1 << 0, 176 | IBV_QP_CUR_STATE = 1 << 1, 177 | IBV_QP_EN_SQD_ASYNC_NOTIFY = 1 << 2, 178 | IBV_QP_ACCESS_FLAGS = 1 << 3, 179 | IBV_QP_PKEY_INDEX = 1 << 4, 180 | IBV_QP_PORT = 1 << 5, 181 | IBV_QP_QKEY = 1 << 6, 182 | IBV_QP_AV = 1 << 7, 183 | IBV_QP_PATH_MTU = 1 << 8, 184 | IBV_QP_TIMEOUT = 1 << 9, 185 | IBV_QP_RETRY_CNT = 1 << 10, 186 | IBV_QP_RNR_RETRY = 1 << 11, 187 | IBV_QP_RQ_PSN = 1 << 12, 188 | IBV_QP_MAX_QP_RD_ATOMIC = 1 << 13, 189 | IBV_QP_ALT_PATH = 1 << 14, 190 | IBV_QP_MIN_RNR_TIMER = 1 << 15, 191 | IBV_QP_SQ_PSN = 1 << 16, 192 | IBV_QP_MAX_DEST_RD_ATOMIC = 1 << 17, 193 | IBV_QP_PATH_MIG_STATE = 1 << 18, 194 | IBV_QP_CAP = 1 << 19, 195 | IBV_QP_DEST_QPN = 1 << 20 196 | }; 197 | 198 | enum ibv_qp_state { 199 | IBV_QPS_RESET, 200 | IBV_QPS_INIT, 201 | IBV_QPS_RTR, 202 | IBV_QPS_RTS, 203 | IBV_QPS_SQD, 204 | IBV_QPS_SQE, 205 | IBV_QPS_ERR 206 | }; 207 | 208 | 209 | struct ibv_modify_qp_resp { 210 | enum ibv_qp_attr_mask attr_mask; 211 | u8 qp_state; 212 | u8 reserved[3]; 213 | }; 214 | 215 | struct ibv_create_ah_resp { 216 | u64 start; 217 | }; 218 | 219 | /* 220 | * Some mlx4 specific kernel definitions. Perhaps could be in 221 | * separate file. 222 | */ 223 | 224 | struct mlx4_ib_user_db_page { 225 | struct list_head list; 226 | struct ib_umem *umem; 227 | unsigned long user_virt; 228 | int refcnt; 229 | }; 230 | 231 | 232 | #endif /* MX_ABI_H */ 233 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/netvsc_compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Compatiability macros to adapt to older kernel versions 3 | */ 4 | 5 | static inline bool compat_napi_complete_done(struct napi_struct *n, int work_done) 6 | { 7 | #if (RHEL_RELEASE_CODE <= RHEL_RELEASE_VERSION(7,3)) 8 | napi_complete(n); 9 | #else 10 | napi_complete_done(n, work_done); 11 | #endif 12 | return true; 13 | } 14 | 15 | #define napi_complete_done compat_napi_complete_done 16 | 17 | #if (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(7,2)) 18 | static inline void __napi_schedule_irqoff(struct napi_struct *n) 19 | { 20 | __napi_schedule(n); 21 | } 22 | #endif 23 | 24 | 25 | 26 | static inline void *compat_kvmalloc_array(size_t n, size_t size, gfp_t flags) 27 | { 28 | void *ptr = NULL; 29 | #if (RHEL_RELEASE_CODE <= RHEL_RELEASE_VERSION(7,4)) 30 | ptr = vzalloc(n*size); 31 | #else 32 | ptr = kvmalloc_array(n, size, flags); 33 | #endif 34 | return ptr; 35 | } 36 | 37 | 38 | #define kvmalloc_array compat_kvmalloc_array 39 | 40 | static inline void compat_kvfree(const void *addr) 41 | { 42 | #if (RHEL_RELEASE_CODE <= RHEL_RELEASE_VERSION(7,4)) 43 | vfree(addr); 44 | #else 45 | kvfree(addr); 46 | #endif 47 | } 48 | 49 | #define kvfree compat_kvfree 50 | 51 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/netvsc_trace.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | 3 | #if !defined(_NETVSC_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) 4 | #define _NETVSC_TRACE_H 5 | 6 | /* This is purely a stub since older kernels do not have tracing. */ 7 | 8 | #define trace_rndis_send(ndev, q, msg) 9 | #define trace_rndis_recv(ndev, q, msg) 10 | #define trace_nvsp_send(ndev, msg) 11 | #define trace_nvsp_send_pkt(ndev, chan, rpkt) 12 | #define trace_nvsp_recv(ndev, chan, msg) 13 | 14 | #endif /* _NETVSC_TRACE_H */ 15 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/rhel7-hv-driver-install: -------------------------------------------------------------------------------- 1 | echo "Building Modules" 2 | if [ "$KERNEL_VERSION" == "" ] 3 | then 4 | KERNEL_VERSION=$(uname -r) 5 | fi 6 | 7 | rhel_major=$(grep -Eoh [0-9]+\.[0-9]+ /etc/{issue,*release} | head -1 | awk -F'.' '{ print $1 }') 8 | rhel_minor=$(grep -Eoh [0-9]+\.[0-9]+ /etc/{issue,*release} | head -1 | awk -F'.' '{ print $2 }') 9 | rhel_release_code=$((rhel_major << 8 | rhel_minor)) 10 | if [ $rhel_release_code -ge 1795 ] && [ $rhel_release_code -lt 1797 ]; then 11 | echo "Building & installing MLX OFED ..." 12 | rm -rf mlnx-ofa_kernel-4.5 13 | tar zxf mlnx-ofa_kernel-4.5.tgz 14 | cd mlnx-ofa_kernel-4.5 15 | ./configure --with-mlx5-core-and-en-mod --with-mlx4_en-mod -j$(nproc) 16 | make -j$(nproc) 17 | mkdir -p /lib/modules/$KERNEL_VERSION/extra/lis-mlx 18 | find . -name *.ko -exec cp {} /lib/modules/$KERNEL_VERSION/extra/lis-mlx \; 19 | cd .. 20 | echo "Installing modprobe blacklist conf" 21 | cp -f ./hyperv_mod_blacklist.conf /etc/modprobe.d/ 22 | fi 23 | 24 | echo "Cleaning up from any previous builds" 25 | make -C /lib/modules/$KERNEL_VERSION/build M=`pwd` clean 26 | [ $? -eq 0 ] || exit 1 27 | 28 | echo "Creating LIS modules" 29 | make -C /lib/modules/$KERNEL_VERSION/build M=`pwd` modules -j$(nproc) 30 | [ $? -eq 0 ] || exit 1 31 | 32 | echo "Installing Modules" 33 | cp -f ./*.ko /lib/modules/$KERNEL_VERSION/extra/ 34 | [ $? -eq 0 ] || exit 1 35 | 36 | echo "Generating Module dependencies" 37 | depmod 38 | [ $? -eq 0 ] || exit 1 39 | 40 | echo "Installing Modprobe Rules" 41 | cp -f ./hyperv_pvdrivers.conf /etc/modprobe.d/ 42 | [ $? -eq 0 ] || exit 1 43 | 44 | echo "Copying scripts for IP injection" 45 | \cp -f ./tools/hv_get_dns_info.sh /usr/sbin/hv_get_dns_info 46 | [ $? -eq 0 ] || exit 1 47 | 48 | \cp -f ./tools/hv_get_dhcp_info.sh /usr/sbin/hv_get_dhcp_info 49 | [ $? -eq 0 ] || exit 1 50 | 51 | \cp -f ./tools/hv_set_ifconfig.sh /usr/sbin/hv_set_ifconfig 52 | [ $? -eq 0 ] || exit 1 53 | 54 | echo "Copying lsvmbus tool" 55 | \cp -f ./tools/lsvmbus /usr/sbin/ 56 | [ $? -eq 0 ] || exit 1 57 | chmod +x /usr/sbin/lsvmbus 58 | 59 | echo "Generating initramfs" 60 | dracut --force "initramfs-$KERNEL_VERSION.img" $KERNEL_VERSION 61 | [ $? -eq 0 ] || exit 1 62 | 63 | echo "Saving old initramfs" 64 | if [ ! -e "/boot/initramfs-$KERNEL_VERSION.img-old" ] 65 | then 66 | cp -f "/boot/initramfs-$KERNEL_VERSION.img" "/boot/initramfs-$KERNEL_VERSION.img-old" 67 | [ $? -eq 0 ] || exit 1 68 | fi 69 | 70 | echo "Installing new initramfs" 71 | cp -f "initramfs-$KERNEL_VERSION.img" "/boot/initramfs-$KERNEL_VERSION.img" 72 | [ $? -eq 0 ] || exit 1 73 | 74 | # Remove the local copy of the initramfs image file 75 | rm -f "./initramfs-$KERNEL_VERSION.img" 76 | 77 | echo "Completed" 78 | exit 0 79 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/rhel7-hv-driver-uninstall: -------------------------------------------------------------------------------- 1 | echo "Get rid of the Hyper-V drivers and modprobe rules" 2 | if [ "$KERNEL_VERSION" == "" ] 3 | then 4 | KERNEL_VERSION=$(uname -r) 5 | fi 6 | 7 | rm -rf /lib/modules/$KERNEL_VERSION/extra/lis-mlx 8 | rm -rf /lib/modules/$KERNEL_VERSION/extra/hv_*.ko 9 | rm -rf /lib/modules/$KERNEL_VERSION/extra/hid-hyperv.ko 10 | rm -rf /lib/modules/$KERNEL_VERSION/extra/hyperv_fb.ko 11 | rm -rf /lib/modules/$KERNEL_VERSION/extra/hyperv-keyboard.ko 12 | rm -rf /lib/modules/$KERNEL_VERSION/extra/pci-hyperv.ko 13 | rm -rf /lib/modules/$KERNEL_VERSION/extra/uio_hv_generic.ko 14 | 15 | rm -rf /lib/modules/$KERNEL_VERSION/extra/microsoft-hyper-v/hv_*.ko 16 | rm -rf /etc/modprobe.d/hyperv_pvdrivers.conf 17 | rm -f /etc/modprobe.d/hyperv_mod_blacklist.conf 18 | 19 | echo "Get rid of ip injection scripts" 20 | rm -rf /usr/sbin/hv_get_dns_info 21 | rm -rf /usr/sbin/hv_get_dhcp_info 22 | rm -rf /usr/sbin/hv_set_ifconfig 23 | 24 | echo "Removing lsvmbus tool" 25 | rm -rf /usr/sbin/lsvmbus 26 | 27 | depmod 28 | 29 | echo "Create and install initramfs without Hyper-V drivers" 30 | dracut --force "initramfs-$KERNEL_VERSION.img" $KERNEL_VERSION 31 | cp -f "initramfs-$KERNEL_VERSION.img" /boot/"initramfs-$KERNEL_VERSION.img" 32 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/tools/68-azure-sriov-nm-unmanaged.rules: -------------------------------------------------------------------------------- 1 | # Accelerated Networking on Azure exposes a new SRIOV interface to the VM. 2 | # This interface is transparently bonded to the synthetic interface, 3 | # so NetworkManager should just ignore any SRIOV interfaces. 4 | SUBSYSTEM=="net", DRIVERS=="hv_pci", ACTION=="add", ENV{NM_UNMANAGED}="1" 5 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/tools/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Hyper-V tools 2 | 3 | CC = $(CROSS_COMPILE)gcc 4 | WARNINGS = -Wall -Wextra 5 | CFLAGS = $(WARNINGS) -g $(shell getconf LFS_CFLAGS) 6 | 7 | CFLAGS += -D__EXPORTED_HEADERS__ -I../include/uapi -I../include 8 | 9 | all: hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon 10 | %: %.c 11 | $(CC) $(CFLAGS) -o $@ $^ 12 | 13 | clean: 14 | $(RM) hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon 15 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/tools/hv_get_dhcp_info: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This example script retrieves the DHCP state of a given interface. 4 | # In the interest of keeping the KVP daemon code free of distro specific 5 | # information; the kvp daemon code invokes this external script to gather 6 | # DHCP setting for the specific interface. 7 | # 8 | # Input: Name of the interface 9 | # 10 | # Output: The script prints the string "Enabled" to stdout to indicate 11 | # that DHCP is enabled on the interface. If DHCP is not enabled, 12 | # the script prints the string "Disabled" to stdout. 13 | # 14 | # Each Distro is expected to implement this script in a distro specific 15 | # fashion. For instance on Distros that ship with Network Manager enabled, 16 | # this script can be based on the Network Manager APIs for retrieving DHCP 17 | # information. 18 | 19 | if_file="/etc/sysconfig/network-scripts/ifcfg-"$1 20 | 21 | dhcp=$(grep "dhcp" $if_file 2>/dev/null) 22 | 23 | if [ "$dhcp" != "" ]; 24 | then 25 | echo "Enabled" 26 | else 27 | echo "Disabled" 28 | fi 29 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/tools/hv_get_dhcp_info.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This example script retrieves the DHCP state of a given interface. 4 | # In the interest of keeping the KVP daemon code free of distro specific 5 | # information; the kvp daemon code invokes this external script to gather 6 | # DHCP setting for the specific interface. 7 | # 8 | # Input: Name of the interface 9 | # 10 | # Output: The script prints the string "Enabled" to stdout to indicate 11 | # that DHCP is enabled on the interface. If DHCP is not enabled, 12 | # the script prints the string "Disabled" to stdout. 13 | # 14 | # Each Distro is expected to implement this script in a distro specific 15 | # fashion. For instance on Distros that ship with Network Manager enabled, 16 | # this script can be based on the Network Manager APIs for retrieving DHCP 17 | # information. 18 | 19 | if_file="/etc/sysconfig/network-scripts/ifcfg-"$1 20 | 21 | dhcp=$(grep "dhcp" $if_file 2>/dev/null) 22 | 23 | if [ "$dhcp" != "" ]; 24 | then 25 | echo "Enabled" 26 | else 27 | echo "Disabled" 28 | fi 29 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/tools/hv_get_dns_info: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This example script parses /etc/resolv.conf to retrive DNS information. 4 | # In the interest of keeping the KVP daemon code free of distro specific 5 | # information; the kvp daemon code invokes this external script to gather 6 | # DNS information. 7 | # This script is expected to print the nameserver values to stdout. 8 | # Each Distro is expected to implement this script in a distro specific 9 | # fashion. For instance on Distros that ship with Network Manager enabled, 10 | # this script can be based on the Network Manager APIs for retrieving DNS 11 | # entries. 12 | 13 | cat /etc/resolv.conf 2>/dev/null | awk '/^nameserver/ { print $2 }' 14 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/tools/hv_get_dns_info.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This example script parses /etc/resolv.conf to retrive DNS information. 4 | # In the interest of keeping the KVP daemon code free of distro specific 5 | # information; the kvp daemon code invokes this external script to gather 6 | # DNS information. 7 | # This script is expected to print the nameserver values to stdout. 8 | # Each Distro is expected to implement this script in a distro specific 9 | # fashion. For instance on Distros that ship with Network Manager enabled, 10 | # this script can be based on the Network Manager APIs for retrieving DNS 11 | # entries. 12 | 13 | cat /etc/resolv.conf 2>/dev/null | awk '/^nameserver/ { print $2 }' 14 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/tools/hv_set_ifconfig: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This example script activates an interface based on the specified 4 | # configuration. 5 | # 6 | # In the interest of keeping the KVP daemon code free of distro specific 7 | # information; the kvp daemon code invokes this external script to configure 8 | # the interface. 9 | # 10 | # The only argument to this script is the configuration file that is to 11 | # be used to configure the interface. 12 | # 13 | # Each Distro is expected to implement this script in a distro specific 14 | # fashion. For instance on Distros that ship with Network Manager enabled, 15 | # this script can be based on the Network Manager APIs for configuring the 16 | # interface. 17 | # 18 | # This example script is based on a RHEL environment. 19 | # 20 | # Here is the format of the ip configuration file: 21 | # 22 | # HWADDR=macaddr 23 | # DEVICE=interface name 24 | # BOOTPROTO= (where is "dhcp" if DHCP is configured 25 | # or "none" if no boot-time protocol should be used) 26 | # 27 | # IPADDR0=ipaddr1 28 | # IPADDR1=ipaddr2 29 | # IPADDRx=ipaddry (where y = x + 1) 30 | # 31 | # NETMASK0=netmask1 32 | # NETMASKx=netmasky (where y = x + 1) 33 | # 34 | # GATEWAY=ipaddr1 35 | # GATEWAYx=ipaddry (where y = x + 1) 36 | # 37 | # DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) 38 | # 39 | # IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be 40 | # tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as 41 | # IPV6NETMASK. 42 | # 43 | # The host can specify multiple ipv4 and ipv6 addresses to be 44 | # configured for the interface. Furthermore, the configuration 45 | # needs to be persistent. A subsequent GET call on the interface 46 | # is expected to return the configuration that is set via the SET 47 | # call. 48 | # 49 | 50 | 51 | 52 | echo "IPV6INIT=yes" >> $1 53 | echo "NM_CONTROLLED=no" >> $1 54 | echo "PEERDNS=yes" >> $1 55 | echo "ONBOOT=yes" >> $1 56 | 57 | 58 | cp $1 /etc/sysconfig/network-scripts/ 59 | 60 | 61 | interface=$(echo $1 | awk -F - '{ print $2 }') 62 | 63 | /sbin/ifdown $interface 2>/dev/null 64 | /sbin/ifup $interface 2>/dev/null 65 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/tools/hv_set_ifconfig.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This example script activates an interface based on the specified 4 | # configuration. 5 | # 6 | # In the interest of keeping the KVP daemon code free of distro specific 7 | # information; the kvp daemon code invokes this external script to configure 8 | # the interface. 9 | # 10 | # The only argument to this script is the configuration file that is to 11 | # be used to configure the interface. 12 | # 13 | # Each Distro is expected to implement this script in a distro specific 14 | # fashion. For instance on Distros that ship with Network Manager enabled, 15 | # this script can be based on the Network Manager APIs for configuring the 16 | # interface. 17 | # 18 | # This example script is based on a RHEL environment. 19 | # 20 | # Here is the format of the ip configuration file: 21 | # 22 | # HWADDR=macaddr 23 | # DEVICE=interface name 24 | # BOOTPROTO= (where is "dhcp" if DHCP is configured 25 | # or "none" if no boot-time protocol should be used) 26 | # 27 | # IPADDR0=ipaddr1 28 | # IPADDR1=ipaddr2 29 | # IPADDRx=ipaddry (where y = x + 1) 30 | # 31 | # NETMASK0=netmask1 32 | # NETMASKx=netmasky (where y = x + 1) 33 | # 34 | # GATEWAY=ipaddr1 35 | # GATEWAYx=ipaddry (where y = x + 1) 36 | # 37 | # DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) 38 | # 39 | # IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be 40 | # tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as 41 | # IPV6NETMASK. 42 | # 43 | # The host can specify multiple ipv4 and ipv6 addresses to be 44 | # configured for the interface. Furthermore, the configuration 45 | # needs to be persistent. A subsequent GET call on the interface 46 | # is expected to return the configuration that is set via the SET 47 | # call. 48 | # 49 | 50 | 51 | 52 | echo "IPV6INIT=yes" >> $1 53 | echo "NM_CONTROLLED=no" >> $1 54 | echo "PEERDNS=yes" >> $1 55 | echo "ONBOOT=yes" >> $1 56 | 57 | sed -i 's/IPADDR0/IPADDR/g' $1 58 | sed -i 's/NETMASK0/NETMASK/g' $1 59 | 60 | cp $1 /etc/sysconfig/network-scripts/ 61 | 62 | 63 | interface=$(echo $1 | awk -F - '{ print $2 }') 64 | 65 | /sbin/ifdown $interface 2>/dev/null 66 | /sbin/ifup $interface 2>/dev/null 67 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/tools/lsvmbus: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | from optparse import OptionParser 5 | 6 | parser = OptionParser() 7 | parser.add_option("-v", "--verbose", dest="verbose", 8 | help="print verbose messages. Try -vv, -vvv for \ 9 | more verbose messages", action="count") 10 | 11 | (options, args) = parser.parse_args() 12 | 13 | verbose = 0 14 | if options.verbose is not None: 15 | verbose = options.verbose 16 | 17 | vmbus_sys_path = '/sys/bus/vmbus/devices' 18 | if not os.path.isdir(vmbus_sys_path): 19 | print("%s doesn't exist: exiting..." % vmbus_sys_path) 20 | exit(-1) 21 | 22 | vmbus_dev_dict = { 23 | '{0e0b6031-5213-4934-818b-38d90ced39db}' : '[Operating system shutdown]', 24 | '{9527e630-d0ae-497b-adce-e80ab0175caf}' : '[Time Synchronization]', 25 | '{57164f39-9115-4e78-ab55-382f3bd5422d}' : '[Heartbeat]', 26 | '{a9a0f4e7-5a45-4d96-b827-8a841e8c03e6}' : '[Data Exchange]', 27 | '{35fa2e29-ea23-4236-96ae-3a6ebacba440}' : '[Backup (volume checkpoint)]', 28 | '{34d14be3-dee4-41c8-9ae7-6b174977c192}' : '[Guest services]', 29 | '{525074dc-8985-46e2-8057-a307dc18a502}' : '[Dynamic Memory]', 30 | '{cfa8b69e-5b4a-4cc0-b98b-8ba1a1f3f95a}' : 'Synthetic mouse', 31 | '{f912ad6d-2b17-48ea-bd65-f927a61c7684}' : 'Synthetic keyboard', 32 | '{da0a7802-e377-4aac-8e77-0558eb1073f8}' : 'Synthetic framebuffer adapter', 33 | '{f8615163-df3e-46c5-913f-f2d2f965ed0e}' : 'Synthetic network adapter', 34 | '{32412632-86cb-44a2-9b5c-50d1417354f5}' : 'Synthetic IDE Controller', 35 | '{ba6163d9-04a1-4d29-b605-72e2ffb1dc7f}' : 'Synthetic SCSI Controller', 36 | '{2f9bcc4a-0069-4af3-b76b-6fd0be528cda}' : 'Synthetic fiber channel adapter', 37 | '{8c2eaf3d-32a7-4b09-ab99-bd1f1c86b501}' : 'Synthetic RDMA adapter', 38 | '{44c4f61d-4444-4400-9d52-802e27ede19f}' : 'PCI Express pass-through', 39 | '{276aacf4-ac15-426c-98dd-7521ad3f01fe}' : '[Reserved system device]', 40 | '{f8e65716-3cb3-4a06-9a60-1889c5cccab5}' : '[Reserved system device]', 41 | '{3375baf4-9e15-4b30-b765-67acb10d607b}' : '[Reserved system device]', 42 | } 43 | 44 | def get_vmbus_dev_attr(dev_name, attr): 45 | try: 46 | f = open('%s/%s/%s' % (vmbus_sys_path, dev_name, attr), 'r') 47 | lines = f.readlines() 48 | f.close() 49 | except IOError: 50 | lines = [] 51 | 52 | return lines 53 | 54 | class VMBus_Dev: 55 | pass 56 | 57 | 58 | vmbus_dev_list = [] 59 | 60 | for f in os.listdir(vmbus_sys_path): 61 | vmbus_id = get_vmbus_dev_attr(f, 'id')[0].strip() 62 | class_id = get_vmbus_dev_attr(f, 'class_id')[0].strip() 63 | device_id = get_vmbus_dev_attr(f, 'device_id')[0].strip() 64 | dev_desc = vmbus_dev_dict.get(class_id, 'Unknown') 65 | 66 | chn_vp_mapping = get_vmbus_dev_attr(f, 'channel_vp_mapping') 67 | chn_vp_mapping = [c.strip() for c in chn_vp_mapping] 68 | chn_vp_mapping = sorted(chn_vp_mapping, 69 | key = lambda c : int(c.split(':')[0])) 70 | 71 | chn_vp_mapping = ['\tRel_ID=%s, target_cpu=%s' % 72 | (c.split(':')[0], c.split(':')[1]) 73 | for c in chn_vp_mapping] 74 | d = VMBus_Dev() 75 | d.sysfs_path = '%s/%s' % (vmbus_sys_path, f) 76 | d.vmbus_id = vmbus_id 77 | d.class_id = class_id 78 | d.device_id = device_id 79 | d.dev_desc = dev_desc 80 | d.chn_vp_mapping = '\n'.join(chn_vp_mapping) 81 | if d.chn_vp_mapping: 82 | d.chn_vp_mapping += '\n' 83 | 84 | vmbus_dev_list.append(d) 85 | 86 | 87 | vmbus_dev_list = sorted(vmbus_dev_list, key = lambda d : int(d.vmbus_id)) 88 | 89 | format0 = '%2s: %s' 90 | format1 = '%2s: Class_ID = %s - %s\n%s' 91 | format2 = '%2s: Class_ID = %s - %s\n\tDevice_ID = %s\n\tSysfs path: %s\n%s' 92 | 93 | for d in vmbus_dev_list: 94 | if verbose == 0: 95 | print(('VMBUS ID ' + format0) % (d.vmbus_id, d.dev_desc)) 96 | elif verbose == 1: 97 | print (('VMBUS ID ' + format1) % \ 98 | (d.vmbus_id, d.class_id, d.dev_desc, d.chn_vp_mapping)) 99 | else: 100 | print (('VMBUS ID ' + format2) % \ 101 | (d.vmbus_id, d.class_id, d.dev_desc, \ 102 | d.device_id, d.sysfs_path, d.chn_vp_mapping)) 103 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/tools/systemd/70-hv_fcopy.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEM=="misc", KERNEL=="vmbus/hv_fcopy", TAG+="systemd", ENV{SYSTEMD_WANTS}+="hv_fcopy_daemon.service" 2 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/tools/systemd/70-hv_kvp.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEM=="misc", KERNEL=="vmbus/hv_kvp", TAG+="systemd", ENV{SYSTEMD_WANTS}+="hv_kvp_daemon.service" 2 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/tools/systemd/70-hv_vss.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEM=="misc", KERNEL=="vmbus/hv_vss", TAG+="systemd", ENV{SYSTEMD_WANTS}+="hv_vss_daemon.service" 2 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/tools/systemd/hv_fcopy_daemon.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Hyper-V FCOPY daemon 3 | BindsTo=sys-devices-virtual-misc-vmbus\x21hv_fcopy.device 4 | ConditionPathExists=/dev/vmbus/hv_fcopy 5 | 6 | [Service] 7 | ExecStart=/usr/sbin/hv_fcopy_daemon -n 8 | 9 | [Install] 10 | WantedBy=multi-user.target 11 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/tools/systemd/hv_kvp_daemon.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Hyper-V KVP daemon 3 | BindsTo=sys-devices-virtual-misc-vmbus\x21hv_kvp.device 4 | 5 | [Service] 6 | Type=simple 7 | ExecStart=/usr/sbin/hv_kvp_daemon -n 8 | 9 | [Install] 10 | WantedBy=multi-user.target 11 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/tools/systemd/hv_vss_daemon.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Hyper-V VSS daemon 3 | BindsTo=sys-devices-virtual-misc-vmbus\x21hv_vss.device 4 | 5 | [Service] 6 | ExecStart=/usr/sbin/hv_vss_daemon -n 7 | 8 | [Install] 9 | WantedBy=multi-user.target 10 | -------------------------------------------------------------------------------- /hv-rhel7.x/hv/xorg.conf: -------------------------------------------------------------------------------- 1 | # Xorg configuration created by pyxf86config 2 | 3 | Section "ServerLayout" 4 | Identifier "Default Layout" 5 | Screen 0 "Screen0" 0 0 6 | InputDevice "Keyboard0" "CoreKeyboard" 7 | EndSection 8 | 9 | Section "ServerFlags" 10 | Option "AllowMouseOpenFail" "yes" 11 | EndSection 12 | 13 | Section "InputDevice" 14 | Identifier "Keyboard0" 15 | Driver "kbd" 16 | Option "XkbModel" "pc105" 17 | Option "XkbLayout" "us" 18 | EndSection 19 | 20 | Section "Device" 21 | Identifier "Videocard0" 22 | Driver "fbdev" 23 | EndSection 24 | 25 | Section "Screen" 26 | Identifier "Screen0" 27 | Device "Videocard0" 28 | EndSection 29 | 30 | -------------------------------------------------------------------------------- /setup_travis_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -xe 2 | 3 | # we need to start a process in foreground in order to keep the container running 4 | docker run --privileged -d -t -e "container=docker" -v /sys/fs/cgroup:/sys/fs/cgroup -v `pwd`:/home/travis/build/chvalean/lis-next:rw ${CENTOS} /bin/bash 5 | 6 | # get container ID for further use 7 | DOCKER_CONTAINER_ID=$(sudo docker ps | grep centos | awk '{print $1}') 8 | docker logs $DOCKER_CONTAINER_ID 9 | 10 | # install a few dependencies 11 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "cat /etc/centos-release" 12 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "yum -y -q install automake make gcc wget" 13 | 14 | # current centos release must be kept updated here, 15 | # only the latest GA is in main repo, all previous releases go to vault 16 | if [[ "$BUILD" == "7.5.1804" ]]; then 17 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "wget http://mirror.centos.org/centos/7/os/x86_64/Packages/kernel-devel-${KERNEL}.el7.x86_64.rpm" 18 | # To be used for a future minor kernel update for 7.5 19 | # if [[ "$KERNEL" == "3.10.0-xxx.y.z" ]]; then 20 | # docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "wget http://mirror.centos.org/centos/7/updates/x86_64/Packages/kernel-devel-${KERNEL}.el7.x86_64.rpm" 21 | # fi 22 | elif [[ "$BUILD" == "7."* ]]; then 23 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "wget http://vault.centos.org/${BUILD}/os/x86_64/Packages/kernel-devel-${KERNEL}.el7.x86_64.rpm" 24 | if [[ "$KERNEL" == "3.10.0-693.21.1" ]]; then 25 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "wget http://vault.centos.org/${BUILD}/updates/x86_64/Packages/kernel-devel-${KERNEL}.el7.x86_64.rpm" 26 | fi 27 | fi 28 | 29 | # current centos release must be kept updated here, 30 | # only the latest GA is in main repo, all previous releases go to vault 31 | if [[ "$BUILD" == "6.9" ]]; then 32 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "wget http://mirror.centos.org/centos/${BUILD}/os/x86_64/Packages/kernel-devel-${KERNEL}.el6.x86_64.rpm" 33 | elif [[ "$BUILD" == "6."* ]]; then 34 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "wget http://vault.centos.org/${BUILD}/os/x86_64/Packages/kernel-devel-${KERNEL}.el6.x86_64.rpm" 35 | fi 36 | 37 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "rpm -ivh kernel-devel-${KERNEL}*" 38 | 39 | # work-around to skip warning during install, we won't boot the new kernel 40 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "mkdir -p /lib/modules/$(uname -r)/extra" 41 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "touch /lib/modules/$(uname -r)/modules.order" 42 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "touch /lib/modules/$(uname -r)/modules.builtin" 43 | if [[ "$KERNEL" == "3.10."* ]]; then 44 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "ln -s /usr/src/kernels/${KERNEL}.el7.x86_64 /lib/modules/$(uname -r)/build" 45 | elif [[ "$BUILD" == "6."* ]]; then 46 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "ln -s /usr/src/kernels/${KERNEL}.el6.x86_64 /lib/modules/$(uname -r)/build" 47 | fi 48 | 49 | # installing lis-next 50 | if [[ "$BUILD" == "7"* ]]; then 51 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "cd /home/travis/build/chvalean/lis-next/hv-rhel7.x/hv/tools ; make" 52 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "cd /home/travis/build/chvalean/lis-next/hv-rhel7.x/hv/ ; bash -e rhel7-hv-driver-install" 53 | elif [[ "$BUILD" == "6."* ]]; then 54 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "cd /home/travis/build/chvalean/lis-next/hv-rhel6.x/hv/tools ; make" 55 | docker exec -t $DOCKER_CONTAINER_ID /bin/bash -xec "cd /home/travis/build/chvalean/lis-next/hv-rhel6.x/hv/ ; bash -e rhel6-hv-driver-install" 56 | fi 57 | 58 | # clean-up container 59 | docker stop $DOCKER_CONTAINER_ID 60 | docker rm -v $DOCKER_CONTAINER_ID 61 | -------------------------------------------------------------------------------- /tools/hyperv_kdump_config.ps1: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # 3 | # Linux on Hyper-V and Azure Test Code, ver. 1.0.0 4 | # Copyright (c) Microsoft Corporation 5 | # 6 | # All rights reserved. 7 | # Licensed under the Apache License, Version 2.0 (the ""License""); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS 13 | # OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 14 | # ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR 15 | # PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. 16 | # 17 | # See the Apache Version 2.0 License for specific language governing 18 | # permissions and limitations under the License. 19 | # 20 | ######################################################################## 21 | 22 | <# 23 | .Synopsis 24 | Configured Kdump on Linux VMs running on Hyper-V. 25 | 26 | .Description 27 | 28 | Test parameters 29 | 30 | .Parameter vmName 31 | Name of the VM to test. 32 | 33 | .Parameter hvServer 34 | Name of the Hyper-V server hosting the VM. 35 | 36 | .Parameter vmIP 37 | IP address of the VM. 38 | 39 | .Parameter vmRootPasswd 40 | Root password of the VM. 41 | 42 | Please keep plink.exe, pscp.exe in bin\ folder where script is. 43 | #> 44 | 45 | #param ([String] $vmName, [String] $hvServer, [String] $vmRootPasswd) 46 | 47 | param( 48 | [Parameter(Mandatory=$true)][String] $vmName, 49 | [Parameter(Mandatory=$true)][String] $hvServer, 50 | [Parameter(Mandatory=$true)][String] $vmRootPasswd, 51 | [String] $vmIP 52 | ) 53 | 54 | ####################################################################### 55 | # 56 | # GetIPv4ViaHyperV() 57 | # 58 | # Description: 59 | # Looks at the IP address of each NIC. IPv4 addresses are 60 | # tested with a ping to check the connectivity then returns the 61 | # working IPV4 address 62 | # 63 | ####################################################################### 64 | 65 | function GetIPv4ViaHyperV([String] $vmName, [String] $server) 66 | { 67 | <# 68 | .Synopsis 69 | Use the Hyper-V network cmdlets to retrieve a VMs IPv4 address. 70 | .Description 71 | Look at the IP addresses on each NIC the VM has. For each 72 | address, see if it in IPv4 address and then see if it is 73 | reachable via a ping. 74 | .Parameter vmName 75 | Name of the VM to retrieve the IP address from. 76 | .Parameter server 77 | Name of the server hosting the VM 78 | .Example 79 | GetIpv4ViaHyperV $testVMName $serverName 80 | #> 81 | 82 | $vm = Get-VM -Name $vmName -ComputerName $server -ErrorAction SilentlyContinue 83 | if (-not $vm) 84 | { 85 | Write-Error -Message "GetIPv4ViaHyperV: Unable to create VM object for VM ${vmName}" -Category ObjectNotFound -ErrorAction SilentlyContinue 86 | return $null 87 | } 88 | 89 | $networkAdapters = $vm.NetworkAdapters 90 | if (-not $networkAdapters) 91 | { 92 | Write-Error -Message "GetIPv4ViaHyperV: No network adapters found on VM ${vmName}" -Category ObjectNotFound -ErrorAction SilentlyContinue 93 | return $null 94 | } 95 | 96 | foreach ($nic in $networkAdapters) 97 | { 98 | $ipAddresses = $nic.IPAddresses 99 | if (-not $ipAddresses) 100 | { 101 | Continue 102 | } 103 | 104 | foreach ($address in $ipAddresses) 105 | { 106 | # Ignore address if it is not an IPv4 address 107 | $addr = [IPAddress] $address 108 | if ($addr.AddressFamily -ne [System.Net.Sockets.AddressFamily]::InterNetwork) 109 | { 110 | Continue 111 | } 112 | 113 | # Ignore address if it a loopback address 114 | if ($address.StartsWith("127.")) 115 | { 116 | Continue 117 | } 118 | 119 | # See if it is an address we can access 120 | $ping = New-Object System.Net.NetworkInformation.Ping 121 | $sts = $ping.Send($address) 122 | if ($sts -and $sts.Status -eq [System.Net.NetworkInformation.IPStatus]::Success) 123 | { 124 | return $address 125 | } 126 | } 127 | } 128 | 129 | Write-Error -Message "GetIPv4ViaHyperV: No IPv4 address found on any NICs for VM ${vmName}" -Category ObjectNotFound -ErrorAction SilentlyContinue 130 | return $null 131 | } 132 | 133 | if (-not $vmIP) 134 | { 135 | $vmIP=GetIPv4ViaHyperV $vmName $hvServer 136 | 137 | if (-not $vmIP) 138 | { 139 | "Error: Unable to find IP address for vm ${vmName}" 140 | return $False 141 | } 142 | } 143 | 144 | $kdump_configure="kdump_configure.sh" 145 | $bash_kdump_verify="kdump_verify.sh" 146 | 147 | $OSDetails =Get-WmiObject -class Win32_OperatingSystem -computername $hvServer 148 | $hvServerOsVersion=($OSDetails.version -split "\.")[0]+"."+($OSDetails.version -split "\.")[1] 149 | 150 | "${vmName} IP address: ${vmIP}, hvServerOsVersion: $hvServerOsVersion" 151 | "Copying files to VM..." 152 | 153 | echo "y" | bin\pscp -pw ${vmRootPasswd} $kdump_configure root@${vmIP}:/root/ 154 | 155 | $cmd="dos2unix *.sh" 156 | echo y | bin\plink.exe root@${vmIP} -pw ${vmRootPasswd} $cmd 157 | 158 | $cmd="bash /root/$kdump_configure $hvServerOsVersion" 159 | $cmd 160 | echo y | bin\plink.exe root@${vmIP} -pw ${vmRootPasswd} $cmd 161 | 162 | $status=echo y | bin\plink.exe root@${vmIP} -pw ${vmRootPasswd} "cat /root/summary.log" 163 | 164 | if($status -match "KDUMP_CONFIGURED") { 165 | "Kdump configued succesfullly" 166 | }else{ 167 | "Error: Kdump configuration failed!!" 168 | } 169 | 170 | "Downloading log files.." 171 | echo "y" | bin\pscp -pw ${vmRootPasswd} root@${vmIP}:/root/kdump_config.log . 172 | if ($LASTEXITCODE -ne 0){ 173 | "Failed to download file: kdump_config.log" 174 | }else{ 175 | "Succesfully downloaded file: kdump_config.log" 176 | } 177 | echo "y" | bin\pscp -pw ${vmRootPasswd} root@${vmIP}:/root/summary.log . 178 | if ($LASTEXITCODE -ne 0){ 179 | "Failed to download file: summary.log" 180 | }else{ 181 | "Succesfully downloaded file: summary.log" 182 | } 183 | 184 | -------------------------------------------------------------------------------- /tools/port_upstream_patches.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ######################################################################## 4 | # 5 | # Linux on Hyper-V and Azure Test Code, ver. 1.0.0 6 | # Copyright (c) Microsoft Corporation 7 | # 8 | # All rights reserved. 9 | # Licensed under the Apache License, Version 2.0 (the ""License""); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS 15 | # OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 16 | # ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR 17 | # PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. 18 | # 19 | # See the Apache Version 2.0 License for specific language governing 20 | # permissions and limitations under the License. 21 | # 22 | ######################################################################## 23 | 24 | ######################################################################## 25 | # 26 | # This is a script to help port LIS driver patches from upstream (e.g. 27 | # linux-next, net-next) into the LIS-Next repository. 28 | # 29 | # How to use this: 30 | # 1) Place the set of patches (e.g. from kernel.org) to a directory and 31 | # name them in some order (01.patch, 02.patch, etc…) 32 | # 33 | # 2) Run 'cd ~/lis-next/hv-rhel7.x/hv' 34 | # You can change to whichever target OS you are working on. 35 | # 36 | # 3) Run 'port_usptream_patches.sh ' 37 | # 38 | ######################################################################## 39 | 40 | 41 | 42 | PATCHDIR=$1 43 | RHELVERSION=$2 44 | #DEPTH=$3 45 | 46 | result=0 47 | 48 | if [ -z $RHELVERSION ]; then 49 | RHELVERSION=$(pwd | grep -oP '(?<=hv-rhel)[0-9]+') 50 | fi 51 | 52 | if [ -z $PATCHDIR ]; then 53 | echo "Usage: port_upstream_patches " 54 | exit 1 55 | fi 56 | 57 | echo "=== Porting to RHEL Version $RHELVERSION" 58 | 59 | for patchfile in ${PATCHDIR}/*.patch; do 60 | commit_desc=$(grep Subject $patchfile -m1 | cut -d ":" -f2-) 61 | commit_id=$(grep From $patchfile -m1 | cut -d " " -f2) 62 | 63 | echo "=== Working on $patchfile..." 64 | echo "=== Title: $commit_desc" 65 | echo "=== ID: $commit_id" 66 | 67 | echo "Normalizing the paths in the patch..." 68 | sed -i 's/--- a\/drivers\/hv/--- a/g' $patchfile 69 | sed -i 's/+++ b\/drivers\/hv/+++ b/g' $patchfile 70 | sed -i 's/--- a\/drivers\/scsi/--- a/g' $patchfile 71 | sed -i 's/+++ b\/drivers\/scsi/+++ b/g' $patchfile 72 | sed -i 's/--- a\/tools\/hv\//--- a\/tools\//g' $patchfile 73 | sed -i 's/+++ b\/tools\/hv\//+++ b\/tools\//g' $patchfile 74 | sed -i 's/--- a\/drivers\/net\/hyperv/ --- a/g' $patchfile 75 | sed -i 's/+++ b\/drivers\/net\/hyperv/ +++ b/g' $patchfile 76 | sed -i 's/--- a\/arch\/x86\/include\/asm/ --- a\/arch\/x86\/include\/lis\/asm/g' $patchfile 77 | sed -i 's/+++ b\/arch\/x86\/include\/asm/ +++ b\/arch\/x86\/include\/lis\/asm/g' $patchfile 78 | sed -i 's/--- a\/arch\/x86\/include\/uapi\/asm/ --- a\/arch\/x86\/include\/uapi\/lis\/asm/g' $patchfile 79 | sed -i 's/+++ b\/arch\/x86\/include\/uapi\/asm/ +++ b\/arch\/x86\/include\/uapi\/lis\/asm/g' $patchfile 80 | sed -i 's/--- a\/drivers\/pci\/host/--- a/g' $patchfile 81 | sed -i 's/+++ b\/drivers\/pci\/host/+++ b/g' $patchfile 82 | 83 | echo "Applying patch in DRY RUN..." 84 | #depth=$DEPTH 85 | #if [ -z $DEPTH ]; then 86 | # depth=$(grep "\-\-\- a" $patchfile -m1 | grep -o "\/" | wc -l) 87 | #fi 88 | 89 | echo "patch --dry-run --ignore-whitespace -p1 -F1 -f < $patchfile" 90 | patch --dry-run --ignore-whitespace -p1 -F1 -f < $patchfile 91 | result=$? 92 | if [ $result -ne 0 ]; then 93 | echo "Failed to apply patch in dry run. Please manually port it." 94 | break 95 | fi 96 | 97 | echo "Applying patch for real this time..." 98 | patch --ignore-whitespace -p1 -F1 -f < $patchfile 99 | result=$? 100 | if [ $result -ne 0 ]; then 101 | echo "Failed to apply patch. Please manually port it." 102 | break 103 | fi 104 | 105 | echo "Building LIS drivers..." 106 | make -C /lib/modules/$(uname -r)/build M=`pwd` clean 107 | make -C /lib/modules/$(uname -r)/build M=`pwd` modules 108 | result=$? 109 | if [ $result -ne 0 ]; then 110 | echo "Failed to build LIS drivers." 111 | break 112 | fi 113 | 114 | echo "Building LIS daemons..." 115 | make -C ./tools clean 116 | make -C ./tools 117 | result=$? 118 | if [ $result -ne 0 ]; then 119 | echo "Failed to build LIS daemons." 120 | break 121 | fi 122 | 123 | echo "Committing ported patch..." 124 | make -C ./tools clean 125 | make -C /lib/modules/$(uname -r)/build M=`pwd` clean 126 | git add -u . 127 | git add ./\*.c 128 | git add ./\*.h 129 | git commit -m "RH${RHELVERSION}:$commit_desc " 130 | result=$? 131 | if [ $result -ne 0 ]; then 132 | echo "Failed to commit patch." 133 | break 134 | fi 135 | 136 | echo "Marking patch as ported..." 137 | mv $patchfile ${patchfile}.done 138 | done 139 | 140 | exit $result 141 | -------------------------------------------------------------------------------- /tools/sriov/60-hyperv-vf-name-run.rules: -------------------------------------------------------------------------------- 1 | # Assign Hyper-V VF NICs to stable names 2 | SUBSYSTEM=="net", DRIVERS=="hv_pci", ACTION=="add", PROGRAM="/usr/sbin/hv_vf_name", NAME:="vf%c", RUN+="/usr/sbin/bondvf_lock" -------------------------------------------------------------------------------- /tools/sriov/60-hyperv-vf-name.rules: -------------------------------------------------------------------------------- 1 | # Assign Hyper-V VF NICs to stable names 2 | SUBSYSTEM=="net", DRIVERS=="hv_pci", ACTION=="add", PROGRAM="/usr/sbin/hv_vf_name", NAME:="vf%c" -------------------------------------------------------------------------------- /tools/sriov/hv_vf_name: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # On HyperV/Azure VMs, we use VF serial number as the PCI domain. This number 3 | # is used as part of VF nic names for persistency. 4 | 5 | echo $DEVPATH | awk -F"/pci" '{print $2}' | cut -d: -f1 | sed 's/^0*//' 6 | -------------------------------------------------------------------------------- /tools/sriov/ifcfg-vf1: -------------------------------------------------------------------------------- 1 | DEVICE=vf1 2 | TYPE=Ethernet 3 | BOOTPROTO=none 4 | ONBOOT=no 5 | NM_CONTROLLED=no 6 | PEERDNS=yes 7 | IPV6INIT=yes --------------------------------------------------------------------------------