diff --git a/docs/kernels.md b/docs/kernels.md index b945b1b1b..659fc9b9c 100644 --- a/docs/kernels.md +++ b/docs/kernels.md @@ -18,7 +18,10 @@ is also available under a shorthand tag, e.g. `linuxkit/kernel:4.9.x` for the latest `4.9` kernel. For selected kernels (mostly the LTS kernels and latest stable kernels) we also compile/push kernels with additional debugging enabled. The hub images for these kernels have -the `_dbg` suffix in the tag. +the `_dbg` suffix in the tag. For some kernels, we also provide +matching packages containing the `perf` utility for debugging and +performance tracing. The perf package is called `kernel-perf` and is +tagged the same way as the kernel packages. In addition to the official kernel images, LinuxKit offers the ability to build bootable Linux images with kernels from various @@ -198,3 +201,20 @@ git format-patch -o $KITSRC/kernel/patches-4.9.x v4.9.15..HEAD ``` Then, create a PR for LinuxKit. + + +## Using `perf` + +The `kernel-perf` package contains a statically linked `perf` binary +under `/usr/bin` which is matched with the kernel of the same tag. +The simplest way to use the `perf` utility is to add the package to +the `init` section in the YAML file. This adds the binary to the root +filesystem. + +To use the binary, you can either bind mount it into the `getty` or `ssh` service container or you can access the root filesystem from the `getty` container via `nsenter`: +``` +nsenter -m/proc/1/ns/mnt ash +``` + +Alternatively, you can add the `kernel-perf` package as stage in a +multi-stage build to add it to a custom package. diff --git a/kernel/Dockerfile b/kernel/Dockerfile index 40c36ca8b..aa19b7e76 100644 --- a/kernel/Dockerfile +++ b/kernel/Dockerfile @@ -1,4 +1,32 @@ -FROM linuxkit/kernel-compile:1b396c221af673757703258159ddc8539843b02b@sha256:6b32d205bfc6407568324337b707d195d027328dbfec554428ea93e7b0a8299b AS kernel-build +FROM linuxkit/alpine:4f0ddee221c46f142e5a190dd43d2e07256ef98d AS kernel-build +RUN apk add \ + argp-standalone \ + automake \ + bash \ + bc \ + binutils-dev \ + bison \ + build-base \ + curl \ + diffutils \ + elfutils-dev \ + flex \ + git \ + gmp-dev \ + installkernel \ + kmod \ + libelf-dev \ + libressl-dev \ + libunwind-dev \ + linux-headers \ + ncurses-dev \ + sed \ + squashfs-tools \ + tar \ + xz \ + xz-dev \ + zlib-dev \ + || true ARG KERNEL_VERSION ARG KERNEL_SERIES @@ -65,6 +93,13 @@ RUN DVER=$(basename $(find /tmp/kernel-modules/lib/modules/ -mindepth 1 -maxdept RUN printf "KERNEL_SOURCE=${KERNEL_SOURCE}\n" > /out/kernel-source-info +# perf (Don't compile for 4.4.x, it's broken and tedious to fix) +RUN if [ "${KERNEL_SERIES}" != "4.4.x" ]; then \ + mkdir -p /build/perf && \ + make -C tools/perf LDFLAGS=-static O=/build/perf && \ + strip /build/perf/perf && \ + cp /build/perf/perf /out; \ + fi FROM scratch ENTRYPOINT [] diff --git a/kernel/Dockerfile.perf b/kernel/Dockerfile.perf new file mode 100644 index 000000000..5f08e7a97 --- /dev/null +++ b/kernel/Dockerfile.perf @@ -0,0 +1,10 @@ +# This Dockerfile extracts the perf utility from a kernel package and +# places it into a scratch image +ARG IMAGE +FROM ${IMAGE} AS kernel + +FROM scratch +ENTRYPOINT [] +CMD [] +WORKDIR / +COPY --from=kernel /perf /usr/bin/perf diff --git a/kernel/Makefile b/kernel/Makefile index e86dee2b0..98c8ad04f 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,18 +1,23 @@ # This builds the supported LinuxKit kernels. Kernels are wrapped up -# in a minimal toybox container, which contains the bzImage, a tar -# ball with modules and the kernel source. +# in a scratch container, which contains the bzImage, a tar +# ball with modules, the kernel sourcs, and in some case, the perf binary. # # Each kernel is pushed to hub twice, once as # linuxkit/kernel:..- and once as # inuxkit/kernel:..x. The is the git tree hash # of the current directory. The build will only rebuild the kernel # image if the git tree hash changed. +# +# For some kernels we also build a separate package containing the perf utility +# which is specific to a given kernel. perf packages are tagged the same way +# kernel packages. # Git tree hash of this directory. Override to force build HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}') # Name and Org on Hub ORG?=linuxkit IMAGE:=kernel +IMAGE_PERF:=kernel-perf .PHONY: check tag push sign # Targets: @@ -57,6 +62,31 @@ sign_$(2)$(3): build_$(2)$(3) build: build_$(2)$(3) push: push_$(2)$(3) sign: sign_$(2)$(3) + +ifneq ($(2), 4.4.x) +build_perf_$(2)$(3): build_$(2)$(3) + docker pull $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) || \ + docker build -f Dockerfile.perf \ + --build-arg IMAGE=$(ORG)/$(IMAGE):$(1)$(3)-$(HASH) \ + --no-cache --network=none -t $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) . + +push_perf_$(2)$(3): build_perf_$(2)$(3) + docker pull $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) || \ + (docker push $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) && \ + docker tag $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) $(ORG)/$(IMAGE_PERF):$(2)$(3) && \ + docker push $(ORG)/$(IMAGE_PERF):$(2)$(3)) + +sign_perf_$(2)$(3): build_perf_$(2)$(3) + DOCKER_CONTENT_TRUST=1 docker pull $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) || \ + (DOCKER_CONTENT_TRUST=1 docker push $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) && \ + docker tag $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) $(ORG)/$(IMAGE_PERF):$(2)$(3) && \ + DOCKER_CONTENT_TRUST=1 docker push $(ORG)/$(IMAGE_PERF):$(2)$(3)) + +build: build_perf_$(2)$(3) +push: push_perf_$(2)$(3) +sign: sign_perf_$(2)$(3) +endif + endef # diff --git a/kernel/patches-4.11.x/0001-tools-build-Add-test-for-sched_getcpu.patch b/kernel/patches-4.11.x/0001-tools-build-Add-test-for-sched_getcpu.patch new file mode 100644 index 000000000..9103c601a --- /dev/null +++ b/kernel/patches-4.11.x/0001-tools-build-Add-test-for-sched_getcpu.patch @@ -0,0 +1,149 @@ +From 500dc604f95708446c0a074d84716dfa5d3c55d8 Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Thu, 2 Mar 2017 12:55:49 -0300 +Subject: [PATCH 01/14] tools build: Add test for sched_getcpu() + +Instead of trying to go on adding more ifdef conditions, do a feature +test and define HAVE_SCHED_GETCPU_SUPPORT instead, then use it to +provide the prototype. No need to change the stub, as it is already a +__weak symbol. + +Cc: Adrian Hunter +Cc: David Ahern +Cc: Jiri Olsa +Cc: Namhyung Kim +Cc: Wang Nan +Link: http://lkml.kernel.org/n/tip-yge89er9g90sc0v6k0a0r5tr@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +(cherry picked from commit 120010cb1eea151d38a3e66f5ffc79a0c3110292) +--- + tools/build/Makefile.feature | 1 + + tools/build/feature/Makefile | 6 +++++- + tools/build/feature/test-all.c | 5 +++++ + tools/build/feature/test-sched_getcpu.c | 7 +++++++ + tools/perf/Makefile.config | 4 ++++ + tools/perf/util/cloexec.h | 6 ------ + tools/perf/util/util.h | 4 ++-- + 7 files changed, 24 insertions(+), 9 deletions(-) + create mode 100644 tools/build/feature/test-sched_getcpu.c + +diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature +index e3fb5ecbdcb6..523911f316ce 100644 +--- a/tools/build/Makefile.feature ++++ b/tools/build/Makefile.feature +@@ -63,6 +63,7 @@ FEATURE_TESTS_BASIC := \ + lzma \ + get_cpuid \ + bpf \ ++ sched_getcpu \ + sdt + + # FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list +diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile +index b564a2eea039..ab1e2bbc2e96 100644 +--- a/tools/build/feature/Makefile ++++ b/tools/build/feature/Makefile +@@ -48,7 +48,8 @@ FILES= \ + test-get_cpuid.bin \ + test-sdt.bin \ + test-cxx.bin \ +- test-jvmti.bin ++ test-jvmti.bin \ ++ test-sched_getcpu.bin + + FILES := $(addprefix $(OUTPUT),$(FILES)) + +@@ -91,6 +92,9 @@ $(OUTPUT)test-libelf.bin: + $(OUTPUT)test-glibc.bin: + $(BUILD) + ++$(OUTPUT)test-sched_getcpu.bin: ++ $(BUILD) ++ + DWARFLIBS := -ldw + ifeq ($(findstring -static,${LDFLAGS}),-static) + DWARFLIBS += -lelf -lebl -lz -llzma -lbz2 +diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c +index 699e43627397..cc6c7c01f4ca 100644 +--- a/tools/build/feature/test-all.c ++++ b/tools/build/feature/test-all.c +@@ -117,6 +117,10 @@ + # include "test-pthread-attr-setaffinity-np.c" + #undef main + ++#define main main_test_sched_getcpu ++# include "test-sched_getcpu.c" ++#undef main ++ + # if 0 + /* + * Disable libbabeltrace check for test-all, because the requested +@@ -182,6 +186,7 @@ int main(int argc, char *argv[]) + main_test_get_cpuid(); + main_test_bpf(); + main_test_libcrypto(); ++ main_test_sched_getcpu(); + main_test_sdt(); + + return 0; +diff --git a/tools/build/feature/test-sched_getcpu.c b/tools/build/feature/test-sched_getcpu.c +new file mode 100644 +index 000000000000..c4a148dd7104 +--- /dev/null ++++ b/tools/build/feature/test-sched_getcpu.c +@@ -0,0 +1,7 @@ ++#define _GNU_SOURCE ++#include ++ ++int main(void) ++{ ++ return sched_getcpu(); ++} +diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config +index 27c9fbca7bd9..2b656de99495 100644 +--- a/tools/perf/Makefile.config ++++ b/tools/perf/Makefile.config +@@ -317,6 +317,10 @@ ifdef NO_DWARF + NO_LIBDW_DWARF_UNWIND := 1 + endif + ++ifeq ($(feature-sched_getcpu), 1) ++ CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT ++endif ++ + ifndef NO_LIBELF + CFLAGS += -DHAVE_LIBELF_SUPPORT + EXTLIBS += -lelf +diff --git a/tools/perf/util/cloexec.h b/tools/perf/util/cloexec.h +index d0d465953d36..94a5a7d829d5 100644 +--- a/tools/perf/util/cloexec.h ++++ b/tools/perf/util/cloexec.h +@@ -3,10 +3,4 @@ + + unsigned long perf_event_open_cloexec_flag(void); + +-#ifdef __GLIBC_PREREQ +-#if !__GLIBC_PREREQ(2, 6) && !defined(__UCLIBC__) +-int sched_getcpu(void) __THROW; +-#endif +-#endif +- + #endif /* __PERF_CLOEXEC_H */ +diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h +index c74708da8571..b2cfa47990dc 100644 +--- a/tools/perf/util/util.h ++++ b/tools/perf/util/util.h +@@ -355,8 +355,8 @@ void print_binary(unsigned char *data, size_t len, + size_t bytes_per_line, print_binary_t printer, + void *extra); + +-#if !defined(__GLIBC__) && !defined(__ANDROID__) +-extern int sched_getcpu(void); ++#ifndef HAVE_SCHED_GETCPU_SUPPORT ++int sched_getcpu(void); + #endif + + int is_printable_array(char *p, unsigned int len); +-- +2.13.0 + diff --git a/kernel/patches-4.11.x/0001-vmbus-introduce-in-place-packet-iterator.patch b/kernel/patches-4.11.x/0002-vmbus-introduce-in-place-packet-iterator.patch similarity index 98% rename from kernel/patches-4.11.x/0001-vmbus-introduce-in-place-packet-iterator.patch rename to kernel/patches-4.11.x/0002-vmbus-introduce-in-place-packet-iterator.patch index f0055476c..ce93fcd18 100644 --- a/kernel/patches-4.11.x/0001-vmbus-introduce-in-place-packet-iterator.patch +++ b/kernel/patches-4.11.x/0002-vmbus-introduce-in-place-packet-iterator.patch @@ -1,7 +1,7 @@ -From f1d0fa353d3a960377c30c02583cae0ab4d2a065 Mon Sep 17 00:00:00 2001 +From 7fc081c8a985556a4bef220fc6fd8fd20639f226 Mon Sep 17 00:00:00 2001 From: stephen hemminger Date: Mon, 27 Feb 2017 10:26:48 -0800 -Subject: [PATCH 1/9] vmbus: introduce in-place packet iterator +Subject: [PATCH 02/14] vmbus: introduce in-place packet iterator This is mostly just a refactoring of previous functions (get_pkt_next_raw, put_pkt_raw and commit_rd_index) to make it easier @@ -365,5 +365,5 @@ index 970771a5f739..0c170a3f0d8b 100644 #endif /* _HYPERV_H */ -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.11.x/0002-vmbus-vmbus_open-reset-onchannel_callback-on-error.patch b/kernel/patches-4.11.x/0003-vmbus-vmbus_open-reset-onchannel_callback-on-error.patch similarity index 86% rename from kernel/patches-4.11.x/0002-vmbus-vmbus_open-reset-onchannel_callback-on-error.patch rename to kernel/patches-4.11.x/0003-vmbus-vmbus_open-reset-onchannel_callback-on-error.patch index dee51b6f6..064228f04 100644 --- a/kernel/patches-4.11.x/0002-vmbus-vmbus_open-reset-onchannel_callback-on-error.patch +++ b/kernel/patches-4.11.x/0003-vmbus-vmbus_open-reset-onchannel_callback-on-error.patch @@ -1,7 +1,7 @@ -From 9559fa150a71ecea0cd2583e46c66accf90e0616 Mon Sep 17 00:00:00 2001 +From 1d63d56461390883f4818f701c374a54379d7d21 Mon Sep 17 00:00:00 2001 From: Dexuan Cui Date: Fri, 5 May 2017 16:57:12 -0600 -Subject: [PATCH 2/9] vmbus: vmbus_open(): reset onchannel_callback on error +Subject: [PATCH 03/14] vmbus: vmbus_open(): reset onchannel_callback on error No real issue is observed without the patch, but let's add this just in case. @@ -10,7 +10,7 @@ Signed-off-by: Dexuan Cui Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Stephen Hemminger -Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511 +Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511-debug-0605 (cherry picked from commit c248b14174e1337c1461f9b13a573ad90a136e1c) --- drivers/hv/channel.c | 2 ++ @@ -30,5 +30,5 @@ index 321b8833fa6f..628d6fde1887 100644 } EXPORT_SYMBOL_GPL(vmbus_open); -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.11.x/0003-vmbus-add-the-matching-tasklet_enable-in-vmbus_close.patch b/kernel/patches-4.11.x/0004-vmbus-add-the-matching-tasklet_enable-in-vmbus_close.patch similarity index 89% rename from kernel/patches-4.11.x/0003-vmbus-add-the-matching-tasklet_enable-in-vmbus_close.patch rename to kernel/patches-4.11.x/0004-vmbus-add-the-matching-tasklet_enable-in-vmbus_close.patch index 60b86307c..d4fbb98ba 100644 --- a/kernel/patches-4.11.x/0003-vmbus-add-the-matching-tasklet_enable-in-vmbus_close.patch +++ b/kernel/patches-4.11.x/0004-vmbus-add-the-matching-tasklet_enable-in-vmbus_close.patch @@ -1,7 +1,7 @@ -From 3d3836f4b41e3932cbee6a8f8ac40536d6c4f320 Mon Sep 17 00:00:00 2001 +From f5f0b3c2685ff47d3e7a019801819a20dd04f971 Mon Sep 17 00:00:00 2001 From: Dexuan Cui Date: Fri, 5 May 2017 16:57:15 -0600 -Subject: [PATCH 3/9] vmbus: add the matching tasklet_enable() in +Subject: [PATCH 04/14] vmbus: add the matching tasklet_enable() in vmbus_close_internal() If we disable a tasklet that is scheduled but hasn't started to run, @@ -19,7 +19,7 @@ Signed-off-by: Dexuan Cui Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Stephen Hemminger -Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511 +Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511-debug-0605 (cherry picked from commit 008d8d8bc0c86473a8549a365bee9a479243e412) --- drivers/hv/channel.c | 1 + @@ -38,5 +38,5 @@ index 628d6fde1887..7cd2bd9fd1f1 100644 } -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.11.x/0004-vmbus-remove-goto-error_clean_msglist-in-vmbus_open.patch b/kernel/patches-4.11.x/0005-vmbus-remove-goto-error_clean_msglist-in-vmbus_open.patch similarity index 92% rename from kernel/patches-4.11.x/0004-vmbus-remove-goto-error_clean_msglist-in-vmbus_open.patch rename to kernel/patches-4.11.x/0005-vmbus-remove-goto-error_clean_msglist-in-vmbus_open.patch index bea52d423..93e06120a 100644 --- a/kernel/patches-4.11.x/0004-vmbus-remove-goto-error_clean_msglist-in-vmbus_open.patch +++ b/kernel/patches-4.11.x/0005-vmbus-remove-goto-error_clean_msglist-in-vmbus_open.patch @@ -1,7 +1,8 @@ -From 0dd911a6752477245598e32b63dc341b4efa7460 Mon Sep 17 00:00:00 2001 +From ecf3df3b127a9537d155f8542adba266c3c71aae Mon Sep 17 00:00:00 2001 From: Dexuan Cui Date: Fri, 5 May 2017 16:57:20 -0600 -Subject: [PATCH 4/9] vmbus: remove "goto error_clean_msglist" in vmbus_open() +Subject: [PATCH 05/14] vmbus: remove "goto error_clean_msglist" in + vmbus_open() This is just a cleanup patch to simplify the code a little. No semantic change. @@ -10,7 +11,7 @@ Signed-off-by: Dexuan Cui Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Stephen Hemminger -Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511 +Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511-debug-0605 (cherry picked from commit 4713066c11b2396eafd2873cbed7bdd72d1571eb) --- drivers/hv/channel.c | 18 +++++++----------- @@ -58,5 +59,5 @@ index 7cd2bd9fd1f1..db5e6f8730d2 100644 vmbus_teardown_gpadl(newchannel, newchannel->ringbuffer_gpadlhandle); kfree(open_info); -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.11.x/0005-vmbus-dynamically-enqueue-dequeue-a-channel-on-vmbus.patch b/kernel/patches-4.11.x/0006-vmbus-dynamically-enqueue-dequeue-a-channel-on-vmbus.patch similarity index 97% rename from kernel/patches-4.11.x/0005-vmbus-dynamically-enqueue-dequeue-a-channel-on-vmbus.patch rename to kernel/patches-4.11.x/0006-vmbus-dynamically-enqueue-dequeue-a-channel-on-vmbus.patch index 3a9773349..69ec89b03 100644 --- a/kernel/patches-4.11.x/0005-vmbus-dynamically-enqueue-dequeue-a-channel-on-vmbus.patch +++ b/kernel/patches-4.11.x/0006-vmbus-dynamically-enqueue-dequeue-a-channel-on-vmbus.patch @@ -1,7 +1,7 @@ -From 10daf5dad0b5b282c8070f3e828e03b2fa6622d4 Mon Sep 17 00:00:00 2001 +From 60a7f882c6ba48ee48c91d79d85eb14365444348 Mon Sep 17 00:00:00 2001 From: Dexuan Cui Date: Fri, 5 May 2017 16:57:23 -0600 -Subject: [PATCH 5/9] vmbus: dynamically enqueue/dequeue a channel on +Subject: [PATCH 06/14] vmbus: dynamically enqueue/dequeue a channel on vmbus_open/close MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 @@ -22,7 +22,7 @@ Tested-by: Rolf Neugebauer Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Stephen Hemminger -Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511 +Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511-debug-0605 (cherry picked from commit 1df677b35ff010d0def33f5420773015815cf843) --- drivers/hv/channel.c | 12 +++++++++--- @@ -185,5 +185,5 @@ index 0c170a3f0d8b..ba93b7e4a972 100644 void vmbus_setevent(struct vmbus_channel *channel); -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.11.x/0006-hv_sock-implements-Hyper-V-transport-for-Virtual-Soc.patch b/kernel/patches-4.11.x/0007-hv_sock-implements-Hyper-V-transport-for-Virtual-Soc.patch similarity index 99% rename from kernel/patches-4.11.x/0006-hv_sock-implements-Hyper-V-transport-for-Virtual-Soc.patch rename to kernel/patches-4.11.x/0007-hv_sock-implements-Hyper-V-transport-for-Virtual-Soc.patch index aee309fb4..b7a1cb25b 100644 --- a/kernel/patches-4.11.x/0006-hv_sock-implements-Hyper-V-transport-for-Virtual-Soc.patch +++ b/kernel/patches-4.11.x/0007-hv_sock-implements-Hyper-V-transport-for-Virtual-Soc.patch @@ -1,8 +1,8 @@ -From 8eb0473cb513e25b2379c5e700f6fb6df80d287d Mon Sep 17 00:00:00 2001 +From 00887e3d98575897e80881f462a2a4d56157135e Mon Sep 17 00:00:00 2001 From: Dexuan Cui Date: Fri, 5 May 2017 16:57:26 -0600 -Subject: [PATCH 6/9] hv_sock: implements Hyper-V transport for Virtual Sockets - (AF_VSOCK) +Subject: [PATCH 07/14] hv_sock: implements Hyper-V transport for Virtual + Sockets (AF_VSOCK) Hyper-V Sockets (hv_sock) supplies a byte-stream based communication mechanism between the host and the guest. It uses VMBus ringbuffer as the @@ -34,7 +34,7 @@ Cc: Stefan Hajnoczi Cc: Vitaly Kuznetsov Cc: Cathy Avery Cc: Rolf Neugebauer -Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511 +Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511-debug-0605 (cherry picked from commit 3476be340d2ff777609fca3e763da0292acbfc45) --- MAINTAINERS | 1 + @@ -930,5 +930,5 @@ index 000000000000..fd89bf357617 +MODULE_VERSION("1.0.0"); +MODULE_LICENSE("GPL"); -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.11.x/0007-VMCI-only-try-to-load-on-VMware-hypervisor.patch b/kernel/patches-4.11.x/0008-VMCI-only-try-to-load-on-VMware-hypervisor.patch similarity index 93% rename from kernel/patches-4.11.x/0007-VMCI-only-try-to-load-on-VMware-hypervisor.patch rename to kernel/patches-4.11.x/0008-VMCI-only-try-to-load-on-VMware-hypervisor.patch index decc7d75f..a732b78b3 100644 --- a/kernel/patches-4.11.x/0007-VMCI-only-try-to-load-on-VMware-hypervisor.patch +++ b/kernel/patches-4.11.x/0008-VMCI-only-try-to-load-on-VMware-hypervisor.patch @@ -1,7 +1,7 @@ -From 4a4ecfc0c7bd062dcba1e4dbc487e27ebcf0f8ba Mon Sep 17 00:00:00 2001 +From e4ad24e6481887b2419306ddea61298645f14e2f Mon Sep 17 00:00:00 2001 From: Dexuan Cui Date: Fri, 5 May 2017 16:57:29 -0600 -Subject: [PATCH 7/9] VMCI: only try to load on VMware hypervisor +Subject: [PATCH 08/14] VMCI: only try to load on VMware hypervisor Without the patch, vmw_vsock_vmci_transport.ko and vmw_vmci.ko can automatically load when an application creates an AF_VSOCK socket. @@ -27,7 +27,7 @@ Cc: Jorgen Hansen Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Stephen Hemminger -Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511 +Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511-debug-0605 (cherry picked from commit b5566b1b6e5cb19b381590587f841f950caabe4d) --- drivers/misc/vmw_vmci/vmci_driver.c | 8 ++++++++ @@ -60,5 +60,5 @@ index d7eaf1eb11e7..1789ea71ff5d 100644 if (vmci_err < VMCI_SUCCESS) { pr_err("Failed to initialize VMCIEvent (result=%d)\n", -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.11.x/0008-hv_sock-add-the-support-of-auto-loading.patch b/kernel/patches-4.11.x/0009-hv_sock-add-the-support-of-auto-loading.patch similarity index 85% rename from kernel/patches-4.11.x/0008-hv_sock-add-the-support-of-auto-loading.patch rename to kernel/patches-4.11.x/0009-hv_sock-add-the-support-of-auto-loading.patch index 698f83edb..4667dd65d 100644 --- a/kernel/patches-4.11.x/0008-hv_sock-add-the-support-of-auto-loading.patch +++ b/kernel/patches-4.11.x/0009-hv_sock-add-the-support-of-auto-loading.patch @@ -1,7 +1,7 @@ -From cf272990facec39bd5f42ef82a65f1a00c37ab73 Mon Sep 17 00:00:00 2001 +From 2782da00ad2d3f24b9ba4c5418ebd50dff0fa00c Mon Sep 17 00:00:00 2001 From: Dexuan Cui Date: Fri, 5 May 2017 16:57:35 -0600 -Subject: [PATCH 8/9] hv_sock: add the support of auto-loading +Subject: [PATCH 09/14] hv_sock: add the support of auto-loading After we disable VMWare virtual sockets driver's auto-loading on Hyper-V, we can enable hv_sock's auto-loading now. @@ -10,7 +10,7 @@ Signed-off-by: Dexuan Cui Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Stephen Hemminger -Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511 +Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511-debug-0605 (cherry picked from commit 6f1aa69011356ff95ed6c57400095e5f2d9eb900) --- net/vmw_vsock/hyperv_transport.c | 1 + @@ -26,5 +26,5 @@ index fd89bf357617..f465b0b662df 100644 MODULE_LICENSE("GPL"); +MODULE_ALIAS_NETPROTO(PF_VSOCK); -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.11.x/0009-hvsock-fix-a-race-in-hvs_stream_dequeue.patch b/kernel/patches-4.11.x/0010-hvsock-fix-a-race-in-hvs_stream_dequeue.patch similarity index 95% rename from kernel/patches-4.11.x/0009-hvsock-fix-a-race-in-hvs_stream_dequeue.patch rename to kernel/patches-4.11.x/0010-hvsock-fix-a-race-in-hvs_stream_dequeue.patch index 9a6c803a1..57dcc7cf4 100644 --- a/kernel/patches-4.11.x/0009-hvsock-fix-a-race-in-hvs_stream_dequeue.patch +++ b/kernel/patches-4.11.x/0010-hvsock-fix-a-race-in-hvs_stream_dequeue.patch @@ -1,7 +1,7 @@ -From b9bf375c542c1d2eec22f599dc1cc897ba0b3d66 Mon Sep 17 00:00:00 2001 +From a1fb69445672e790cb4c1b9c105af09eec69cd64 Mon Sep 17 00:00:00 2001 From: Dexuan Cui Date: Tue, 16 May 2017 22:14:03 +0800 -Subject: [PATCH 9/9] hvsock: fix a race in hvs_stream_dequeue() +Subject: [PATCH 10/14] hvsock: fix a race in hvs_stream_dequeue() If hv_pkt_iter_next() returns a non-NULL pointer, we must update the recv_data_len/data_off info, otherwise the received data will @@ -11,7 +11,7 @@ Thank Rolf for finding this! Reported-by: Rolf Neugebauer Signed-off-by: Dexuan Cui -Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511 +Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511-debug-0605 (cherry picked from commit 83c8635b893bbc0b5b329c632cea0382d5479763) --- net/vmw_vsock/hyperv_transport.c | 50 +++++++++++++++++++++++++++++----------- @@ -109,5 +109,5 @@ index f465b0b662df..30154836acd0 100644 case 1: ret = 1; -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.11.x/0011-hvsock-fix-vsock_dequeue-enqueue_accept-race.patch b/kernel/patches-4.11.x/0011-hvsock-fix-vsock_dequeue-enqueue_accept-race.patch new file mode 100644 index 000000000..7a83ba0b6 --- /dev/null +++ b/kernel/patches-4.11.x/0011-hvsock-fix-vsock_dequeue-enqueue_accept-race.patch @@ -0,0 +1,48 @@ +From 80782b837e261c1b8c56c919a8a2f9e750ea4a03 Mon Sep 17 00:00:00 2001 +From: Dexuan Cui +Date: Fri, 19 May 2017 21:49:59 +0800 +Subject: [PATCH 11/14] hvsock: fix vsock_dequeue/enqueue_accept race + +Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511-debug-0605 +(cherry picked from commit 29e6c6204845176c78c7840377a72389d188563c) +--- + net/vmw_vsock/af_vsock.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c +index 6f7f6757ceef..717db396f59e 100644 +--- a/net/vmw_vsock/af_vsock.c ++++ b/net/vmw_vsock/af_vsock.c +@@ -126,6 +126,7 @@ static struct proto vsock_proto = { + + static const struct vsock_transport *transport; + static DEFINE_MUTEX(vsock_register_mutex); ++static DEFINE_SPINLOCK(vsock_accept_queue_lock); + + /**** EXPORTS ****/ + +@@ -406,7 +407,10 @@ void vsock_enqueue_accept(struct sock *listener, struct sock *connected) + + sock_hold(connected); + sock_hold(listener); ++ ++ spin_lock(&vsock_accept_queue_lock); + list_add_tail(&vconnected->accept_queue, &vlistener->accept_queue); ++ spin_unlock(&vsock_accept_queue_lock); + } + EXPORT_SYMBOL_GPL(vsock_enqueue_accept); + +@@ -423,7 +427,10 @@ static struct sock *vsock_dequeue_accept(struct sock *listener) + vconnected = list_entry(vlistener->accept_queue.next, + struct vsock_sock, accept_queue); + ++ spin_lock(&vsock_accept_queue_lock); + list_del_init(&vconnected->accept_queue); ++ spin_unlock(&vsock_accept_queue_lock); ++ + sock_put(listener); + /* The caller will need a reference on the connected socket so we let + * it call sock_put(). +-- +2.13.0 + diff --git a/kernel/patches-4.11.x/0012-Drivers-hv-vmbus-Fix-rescind-handling.patch b/kernel/patches-4.11.x/0012-Drivers-hv-vmbus-Fix-rescind-handling.patch new file mode 100644 index 000000000..f83dcd21b --- /dev/null +++ b/kernel/patches-4.11.x/0012-Drivers-hv-vmbus-Fix-rescind-handling.patch @@ -0,0 +1,290 @@ +From 50fe52376c8d8bd905b45697fc7fe91f5da9c34e Mon Sep 17 00:00:00 2001 +From: "K. Y. Srinivasan" +Date: Sun, 30 Apr 2017 16:21:18 -0700 +Subject: [PATCH 12/14] Drivers: hv: vmbus: Fix rescind handling + +Fix the rescind handling. This patch addresses the following rescind +scenario that is currently not handled correctly: + +If a rescind were to be received while the offer is still being +peocessed, we will be blocked indefinitely since the rescind message +is handled on the same work element as the offer message. Fix this +issue. + +I would like to thank Dexuan Cui and +Long Li for working with me on this patch. + +Signed-off-by: K. Y. Srinivasan +Signed-off-by: Greg Kroah-Hartman +Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511-debug-0605 +(cherry picked from commit 6172aa1bbfb66a9e0b0da0f162f0e91c129e3c94) +--- + drivers/hv/channel.c | 8 ++++-- + drivers/hv/channel_mgmt.c | 69 ++++++++++++++++++++++++++++++++++++----------- + drivers/hv/connection.c | 7 +++-- + drivers/hv/hyperv_vmbus.h | 7 +++++ + drivers/hv/vmbus_drv.c | 29 +++++++++++++++++++- + 5 files changed, 99 insertions(+), 21 deletions(-) + +diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c +index f288e506fba0..2dab00019933 100644 +--- a/drivers/hv/channel.c ++++ b/drivers/hv/channel.c +@@ -635,9 +635,13 @@ void vmbus_close(struct vmbus_channel *channel) + */ + list_for_each_safe(cur, tmp, &channel->sc_list) { + cur_channel = list_entry(cur, struct vmbus_channel, sc_list); +- if (cur_channel->state != CHANNEL_OPENED_STATE) +- continue; + vmbus_close_internal(cur_channel); ++ if (cur_channel->rescind) { ++ mutex_lock(&vmbus_connection.channel_mutex); ++ hv_process_channel_removal(cur_channel, ++ cur_channel->offermsg.child_relid); ++ mutex_unlock(&vmbus_connection.channel_mutex); ++ } + } + /* + * Now close the primary. +diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c +index c5a01a4d589e..292717d922e0 100644 +--- a/drivers/hv/channel_mgmt.c ++++ b/drivers/hv/channel_mgmt.c +@@ -441,7 +441,6 @@ void vmbus_free_channels(void) + { + struct vmbus_channel *channel, *tmp; + +- mutex_lock(&vmbus_connection.channel_mutex); + list_for_each_entry_safe(channel, tmp, &vmbus_connection.chn_list, + listentry) { + /* hv_process_channel_removal() needs this */ +@@ -449,7 +448,6 @@ void vmbus_free_channels(void) + + vmbus_device_unregister(channel->device_obj); + } +- mutex_unlock(&vmbus_connection.channel_mutex); + } + + /* +@@ -496,8 +494,10 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel) + list_add_tail(&newchannel->sc_list, &channel->sc_list); + channel->num_sc++; + spin_unlock_irqrestore(&channel->lock, flags); +- } else ++ } else { ++ atomic_dec(&vmbus_connection.offer_in_progress); + goto err_free_chan; ++ } + } + + dev_type = hv_get_dev_type(newchannel); +@@ -514,6 +514,7 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel) + if (!fnew) { + if (channel->sc_creation_callback != NULL) + channel->sc_creation_callback(newchannel); ++ atomic_dec(&vmbus_connection.offer_in_progress); + return; + } + +@@ -535,9 +536,7 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel) + * binding which eventually invokes the device driver's AddDevice() + * method. + */ +- mutex_lock(&vmbus_connection.channel_mutex); + ret = vmbus_device_register(newchannel->device_obj); +- mutex_unlock(&vmbus_connection.channel_mutex); + + if (ret != 0) { + pr_err("unable to add child device object (relid %d)\n", +@@ -545,6 +544,8 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel) + kfree(newchannel->device_obj); + goto err_deq_chan; + } ++ ++ atomic_dec(&vmbus_connection.offer_in_progress); + return; + + err_deq_chan: +@@ -791,6 +792,7 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr) + newchannel = alloc_channel(); + if (!newchannel) { + vmbus_release_relid(offer->child_relid); ++ atomic_dec(&vmbus_connection.offer_in_progress); + pr_err("Unable to allocate channel object\n"); + return; + } +@@ -837,16 +839,38 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) + + rescind = (struct vmbus_channel_rescind_offer *)hdr; + ++ /* ++ * The offer msg and the corresponding rescind msg ++ * from the host are guranteed to be ordered - ++ * offer comes in first and then the rescind. ++ * Since we process these events in work elements, ++ * and with preemption, we may end up processing ++ * the events out of order. Given that we handle these ++ * work elements on the same CPU, this is possible only ++ * in the case of preemption. In any case wait here ++ * until the offer processing has moved beyond the ++ * point where the channel is discoverable. ++ */ ++ ++ while (atomic_read(&vmbus_connection.offer_in_progress) != 0) { ++ /* ++ * We wait here until any channel offer is currently ++ * being processed. ++ */ ++ msleep(1); ++ } ++ + mutex_lock(&vmbus_connection.channel_mutex); + channel = relid2channel(rescind->child_relid); ++ mutex_unlock(&vmbus_connection.channel_mutex); + + if (channel == NULL) { + /* +- * This is very impossible, because in +- * vmbus_process_offer(), we have already invoked +- * vmbus_release_relid() on error. ++ * We failed in processing the offer message; ++ * we would have cleaned up the relid in that ++ * failure path. + */ +- goto out; ++ return; + } + + spin_lock_irqsave(&channel->lock, flags); +@@ -858,7 +882,7 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) + if (channel->device_obj) { + if (channel->chn_rescind_callback) { + channel->chn_rescind_callback(channel); +- goto out; ++ return; + } + /* + * We will have to unregister this device from the +@@ -869,13 +893,26 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) + vmbus_device_unregister(channel->device_obj); + put_device(dev); + } +- } else { +- hv_process_channel_removal(channel, +- channel->offermsg.child_relid); + } +- +-out: +- mutex_unlock(&vmbus_connection.channel_mutex); ++ if (channel->primary_channel != NULL) { ++ /* ++ * Sub-channel is being rescinded. Following is the channel ++ * close sequence when initiated from the driveri (refer to ++ * vmbus_close() for details): ++ * 1. Close all sub-channels first ++ * 2. Then close the primary channel. ++ */ ++ if (channel->state == CHANNEL_OPEN_STATE) { ++ /* ++ * The channel is currently not open; ++ * it is safe for us to cleanup the channel. ++ */ ++ mutex_lock(&vmbus_connection.channel_mutex); ++ hv_process_channel_removal(channel, ++ channel->offermsg.child_relid); ++ mutex_unlock(&vmbus_connection.channel_mutex); ++ } ++ } + } + + void vmbus_hvsock_device_unregister(struct vmbus_channel *channel) +diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c +index a8366fec1458..13e2e148067b 100644 +--- a/drivers/hv/connection.c ++++ b/drivers/hv/connection.c +@@ -93,10 +93,13 @@ static int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, + * all the CPUs. This is needed for kexec to work correctly where + * the CPU attempting to connect may not be CPU 0. + */ +- if (version >= VERSION_WIN8_1) ++ if (version >= VERSION_WIN8_1) { + msg->target_vcpu = hv_context.vp_index[smp_processor_id()]; +- else ++ vmbus_connection.connect_cpu = smp_processor_id(); ++ } else { + msg->target_vcpu = 0; ++ vmbus_connection.connect_cpu = 0; ++ } + + /* + * Add to list before we send the request since we may +diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h +index 884f83bba1ab..f37921517650 100644 +--- a/drivers/hv/hyperv_vmbus.h ++++ b/drivers/hv/hyperv_vmbus.h +@@ -314,6 +314,13 @@ enum vmbus_connect_state { + #define MAX_SIZE_CHANNEL_MESSAGE HV_MESSAGE_PAYLOAD_BYTE_COUNT + + struct vmbus_connection { ++ /* ++ * CPU on which the initial host contact was made. ++ */ ++ int connect_cpu; ++ ++ atomic_t offer_in_progress; ++ + enum vmbus_connect_state conn_state; + + atomic_t next_gpadl_handle; +diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c +index 8370b9dc6037..1024000af956 100644 +--- a/drivers/hv/vmbus_drv.c ++++ b/drivers/hv/vmbus_drv.c +@@ -800,8 +800,10 @@ static void vmbus_device_release(struct device *device) + struct hv_device *hv_dev = device_to_hv_device(device); + struct vmbus_channel *channel = hv_dev->channel; + ++ mutex_lock(&vmbus_connection.channel_mutex); + hv_process_channel_removal(channel, + channel->offermsg.child_relid); ++ mutex_unlock(&vmbus_connection.channel_mutex); + kfree(hv_dev); + + } +@@ -879,7 +881,32 @@ void vmbus_on_msg_dpc(unsigned long data) + INIT_WORK(&ctx->work, vmbus_onmessage_work); + memcpy(&ctx->msg, msg, sizeof(*msg)); + +- queue_work(vmbus_connection.work_queue, &ctx->work); ++ /* ++ * The host can generate a rescind message while we ++ * may still be handling the original offer. We deal with ++ * this condition by ensuring the processing is done on the ++ * same CPU. ++ */ ++ switch (hdr->msgtype) { ++ case CHANNELMSG_RESCIND_CHANNELOFFER: ++ /* ++ * If we are handling the rescind message; ++ * schedule the work on the global work queue. ++ */ ++ schedule_work_on(vmbus_connection.connect_cpu, ++ &ctx->work); ++ break; ++ ++ case CHANNELMSG_OFFERCHANNEL: ++ atomic_inc(&vmbus_connection.offer_in_progress); ++ queue_work_on(vmbus_connection.connect_cpu, ++ vmbus_connection.work_queue, ++ &ctx->work); ++ break; ++ ++ default: ++ queue_work(vmbus_connection.work_queue, &ctx->work); ++ } + } else + entry->message_handler(hdr); + +-- +2.13.0 + diff --git a/kernel/patches-4.11.x/0013-vmbus-fix-hv_percpu_channel_deq-enq-race.patch b/kernel/patches-4.11.x/0013-vmbus-fix-hv_percpu_channel_deq-enq-race.patch new file mode 100644 index 000000000..c5da5ec39 --- /dev/null +++ b/kernel/patches-4.11.x/0013-vmbus-fix-hv_percpu_channel_deq-enq-race.patch @@ -0,0 +1,246 @@ +From 30cda9241fff7666faf2e0f0427df2c5fba2019d Mon Sep 17 00:00:00 2001 +From: Dexuan Cui +Date: Mon, 5 Jun 2017 16:13:18 +0800 +Subject: [PATCH 13/14] vmbus: fix hv_percpu_channel_deq/enq race + +Signed-off-by: Dexuan Cui +Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511-debug-0605 +(cherry picked from commit 24ff598cdf98290b25805219eff78336bc08e5ab) +--- + drivers/hv/channel_mgmt.c | 32 +++++++++++++++++++++---- + drivers/hv/connection.c | 11 +++++++++ + drivers/hv/hyperv_vmbus.h | 1 + + drivers/hv/vmbus_drv.c | 59 ++++++++++++++++++++++++++++++++++++++++++++--- + 4 files changed, 95 insertions(+), 8 deletions(-) + +diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c +index 292717d922e0..b9a5a15370c9 100644 +--- a/drivers/hv/channel_mgmt.c ++++ b/drivers/hv/channel_mgmt.c +@@ -365,11 +365,16 @@ static void percpu_channel_enq(void *arg) + + void hv_percpu_channel_enq(struct vmbus_channel *channel) + { ++ unsigned long flags; ++ + if (channel->target_cpu != get_cpu()) + smp_call_function_single(channel->target_cpu, + percpu_channel_enq, channel, true); +- else ++ else { ++ local_irq_save(flags); + percpu_channel_enq(channel); ++ local_irq_restore(flags); ++ } + + put_cpu(); + } +@@ -383,11 +388,16 @@ static void percpu_channel_deq(void *arg) + + void hv_percpu_channel_deq(struct vmbus_channel *channel) + { ++ unsigned long flags; ++ + if (channel->target_cpu != get_cpu()) + smp_call_function_single(channel->target_cpu, + percpu_channel_deq, channel, true); +- else ++ else { ++ local_irq_save(flags); + percpu_channel_deq(channel); ++ local_irq_restore(flags); ++ } + + put_cpu(); + } +@@ -495,7 +505,6 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel) + channel->num_sc++; + spin_unlock_irqrestore(&channel->lock, flags); + } else { +- atomic_dec(&vmbus_connection.offer_in_progress); + goto err_free_chan; + } + } +@@ -549,6 +558,7 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel) + return; + + err_deq_chan: ++ atomic_dec(&vmbus_connection.offer_in_progress); + mutex_lock(&vmbus_connection.channel_mutex); + list_del(&newchannel->listentry); + mutex_unlock(&vmbus_connection.channel_mutex); +@@ -915,16 +925,28 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) + } + } + ++static void vmbus_stop_rescind_handling_work(struct work_struct *work) ++{ ++ atomic_inc(&vmbus_connection.offer_in_progress); ++} ++ + void vmbus_hvsock_device_unregister(struct vmbus_channel *channel) + { +- mutex_lock(&vmbus_connection.channel_mutex); ++ struct work_struct work; + + BUG_ON(!is_hvsock_channel(channel)); + ++ /* Prevent chn_rescind_callback from running in the rescind path */ ++ INIT_WORK(&work, vmbus_stop_rescind_handling_work); ++ queue_work_on(vmbus_connection.connect_cpu, ++ vmbus_connection.work_queue_rescind, &work); ++ flush_work(&work); ++ + channel->rescind = true; + vmbus_device_unregister(channel->device_obj); + +- mutex_unlock(&vmbus_connection.channel_mutex); ++ /* Unblock the rescind handling */ ++ atomic_dec(&vmbus_connection.offer_in_progress); + } + EXPORT_SYMBOL_GPL(vmbus_hvsock_device_unregister); + +diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c +index 13e2e148067b..9e4a3d099836 100644 +--- a/drivers/hv/connection.c ++++ b/drivers/hv/connection.c +@@ -156,6 +156,12 @@ int vmbus_connect(void) + goto cleanup; + } + ++ vmbus_connection.work_queue_rescind = create_workqueue("hv_vmbus_rsd"); ++ if (!vmbus_connection.work_queue_rescind) { ++ ret = -ENOMEM; ++ goto cleanup; ++ } ++ + INIT_LIST_HEAD(&vmbus_connection.chn_msg_list); + spin_lock_init(&vmbus_connection.channelmsg_lock); + +@@ -246,6 +252,11 @@ void vmbus_disconnect(void) + */ + vmbus_initiate_unload(false); + ++ if (vmbus_connection.work_queue_rescind) { ++ drain_workqueue(vmbus_connection.work_queue_rescind); ++ destroy_workqueue(vmbus_connection.work_queue_rescind); ++ } ++ + if (vmbus_connection.work_queue) { + drain_workqueue(vmbus_connection.work_queue); + destroy_workqueue(vmbus_connection.work_queue); +diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h +index f37921517650..23b2bcbd174a 100644 +--- a/drivers/hv/hyperv_vmbus.h ++++ b/drivers/hv/hyperv_vmbus.h +@@ -350,6 +350,7 @@ struct vmbus_connection { + struct mutex channel_mutex; + + struct workqueue_struct *work_queue; ++ struct workqueue_struct *work_queue_rescind; + }; + + +diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c +index 1024000af956..be43e22ecd66 100644 +--- a/drivers/hv/vmbus_drv.c ++++ b/drivers/hv/vmbus_drv.c +@@ -839,6 +839,52 @@ static void vmbus_onmessage_work(struct work_struct *work) + kfree(ctx); + } + ++static void vmbus_dispatch_msg_work(struct work_struct *work) ++{ ++ struct vmbus_channel_message_header *hdr; ++ struct onmessage_work_context *ctx, *context; ++ ++ ctx = container_of(work, struct onmessage_work_context, work); ++ hdr = (struct vmbus_channel_message_header *)ctx->msg.u.payload; ++ ++ context = kmalloc(sizeof(*context), GFP_KERNEL | __GFP_NOFAIL); ++ INIT_WORK(&context->work, vmbus_onmessage_work); ++ memcpy(&context->msg, &ctx->msg, sizeof(struct hv_message)); ++ ++ /* ++ * The host can generate a rescind message while we ++ * may still be handling the original offer. We deal with ++ * this condition by ensuring the processing is done on the ++ * same CPU. ++ */ ++ switch (hdr->msgtype) { ++ case CHANNELMSG_RESCIND_CHANNELOFFER: ++ /* ++ * If we are handling the rescind message; ++ * schedule the work on the global work queue. ++ */ ++ queue_work_on(vmbus_connection.connect_cpu, ++ vmbus_connection.work_queue_rescind, ++ &context->work); ++ break; ++ ++ case CHANNELMSG_OFFERCHANNEL: ++ /* XXX */ ++ flush_workqueue(vmbus_connection.work_queue_rescind); ++ ++ atomic_inc(&vmbus_connection.offer_in_progress); ++ queue_work_on(vmbus_connection.connect_cpu, ++ vmbus_connection.work_queue, ++ &context->work); ++ break; ++ ++ default: ++ queue_work(vmbus_connection.work_queue, &context->work); ++ } ++ ++ kfree(ctx); ++} ++ + static void hv_process_timer_expiration(struct hv_message *msg, + struct hv_per_cpu_context *hv_cpu) + { +@@ -878,9 +924,10 @@ void vmbus_on_msg_dpc(unsigned long data) + if (ctx == NULL) + return; + +- INIT_WORK(&ctx->work, vmbus_onmessage_work); ++ INIT_WORK(&ctx->work, vmbus_dispatch_msg_work); + memcpy(&ctx->msg, msg, sizeof(*msg)); + ++#if 0 + /* + * The host can generate a rescind message while we + * may still be handling the original offer. We deal with +@@ -893,8 +940,9 @@ void vmbus_on_msg_dpc(unsigned long data) + * If we are handling the rescind message; + * schedule the work on the global work queue. + */ +- schedule_work_on(vmbus_connection.connect_cpu, +- &ctx->work); ++ queue_work_on(vmbus_connection.connect_cpu, ++ vmbus_connection.work_queue_rescind, ++ &ctx->work); + break; + + case CHANNELMSG_OFFERCHANNEL: +@@ -907,6 +955,9 @@ void vmbus_on_msg_dpc(unsigned long data) + default: + queue_work(vmbus_connection.work_queue, &ctx->work); + } ++#else ++ schedule_work(&ctx->work); ++#endif + } else + entry->message_handler(hdr); + +@@ -1204,6 +1255,8 @@ int vmbus_device_register(struct hv_device *child_device_obj) + child_device_obj->device.parent = &hv_acpi_dev->dev; + child_device_obj->device.release = vmbus_device_release; + ++ if (is_hvsock_channel(child_device_obj->channel)) ++ dev_set_uevent_suppress(&child_device_obj->device, 1); + /* + * Register with the LDM. This will kick off the driver/device + * binding...which will eventually call vmbus_match() and vmbus_probe() +-- +2.13.0 + diff --git a/kernel/patches-4.11.x/0014-vmbus-add-vmbus-onoffer-onoffer_rescind-sync.patch b/kernel/patches-4.11.x/0014-vmbus-add-vmbus-onoffer-onoffer_rescind-sync.patch new file mode 100644 index 000000000..8fe4112f8 --- /dev/null +++ b/kernel/patches-4.11.x/0014-vmbus-add-vmbus-onoffer-onoffer_rescind-sync.patch @@ -0,0 +1,119 @@ +From a51f61d1b7a12097545cb23508faef7d3a4384f2 Mon Sep 17 00:00:00 2001 +From: Dexuan Cui +Date: Mon, 5 Jun 2017 21:32:00 +0800 +Subject: [PATCH 14/14] vmbus: add vmbus onoffer/onoffer_rescind sync. + +Signed-off-by: Dexuan Cui +Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511-debug-0605 +(cherry picked from commit 9a00fd7c4ad9c5d1da39c3c44328145fe063ceed) +--- + drivers/hv/channel_mgmt.c | 25 +++++++++++++++++++------ + drivers/hv/hyperv_vmbus.h | 1 + + drivers/hv/vmbus_drv.c | 1 + + 3 files changed, 21 insertions(+), 6 deletions(-) + +diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c +index b9a5a15370c9..52c7e811738f 100644 +--- a/drivers/hv/channel_mgmt.c ++++ b/drivers/hv/channel_mgmt.c +@@ -467,6 +467,7 @@ void vmbus_free_channels(void) + static void vmbus_process_offer(struct vmbus_channel *newchannel) + { + struct vmbus_channel *channel; ++ struct hv_device *device_obj; + bool fnew = true; + unsigned long flags; + u16 dev_type; +@@ -524,6 +525,7 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel) + if (channel->sc_creation_callback != NULL) + channel->sc_creation_callback(newchannel); + atomic_dec(&vmbus_connection.offer_in_progress); ++ atomic_dec(&vmbus_connection.register_in_progress); + return; + } + +@@ -532,33 +534,36 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel) + * We need to set the DeviceObject field before calling + * vmbus_child_dev_add() + */ +- newchannel->device_obj = vmbus_device_create( ++ device_obj = vmbus_device_create( + &newchannel->offermsg.offer.if_type, + &newchannel->offermsg.offer.if_instance, + newchannel); +- if (!newchannel->device_obj) ++ if (!device_obj) + goto err_deq_chan; + +- newchannel->device_obj->device_id = dev_type; ++ device_obj->device_id = dev_type; + /* + * Add the new device to the bus. This will kick off device-driver + * binding which eventually invokes the device driver's AddDevice() + * method. + */ +- ret = vmbus_device_register(newchannel->device_obj); ++ atomic_dec(&vmbus_connection.offer_in_progress); ++ ret = vmbus_device_register(device_obj); + + if (ret != 0) { + pr_err("unable to add child device object (relid %d)\n", + newchannel->offermsg.child_relid); +- kfree(newchannel->device_obj); ++ kfree(device_obj); + goto err_deq_chan; + } ++ newchannel->device_obj = device_obj; ++ atomic_dec(&vmbus_connection.register_in_progress); + +- atomic_dec(&vmbus_connection.offer_in_progress); + return; + + err_deq_chan: + atomic_dec(&vmbus_connection.offer_in_progress); ++ atomic_dec(&vmbus_connection.register_in_progress); + mutex_lock(&vmbus_connection.channel_mutex); + list_del(&newchannel->listentry); + mutex_unlock(&vmbus_connection.channel_mutex); +@@ -889,6 +894,14 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) + + vmbus_rescind_cleanup(channel); + ++ while (atomic_read(&vmbus_connection.register_in_progress) != 0) { ++ /* ++ * We wait here until any channel offer is currently ++ * being processed. ++ */ ++ msleep(1); ++ } ++ + if (channel->device_obj) { + if (channel->chn_rescind_callback) { + channel->chn_rescind_callback(channel); +diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h +index 23b2bcbd174a..0d22b842a469 100644 +--- a/drivers/hv/hyperv_vmbus.h ++++ b/drivers/hv/hyperv_vmbus.h +@@ -320,6 +320,7 @@ struct vmbus_connection { + int connect_cpu; + + atomic_t offer_in_progress; ++ atomic_t register_in_progress; + + enum vmbus_connect_state conn_state; + +diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c +index be43e22ecd66..822daa0936c2 100644 +--- a/drivers/hv/vmbus_drv.c ++++ b/drivers/hv/vmbus_drv.c +@@ -873,6 +873,7 @@ static void vmbus_dispatch_msg_work(struct work_struct *work) + flush_workqueue(vmbus_connection.work_queue_rescind); + + atomic_inc(&vmbus_connection.offer_in_progress); ++ atomic_inc(&vmbus_connection.register_in_progress); + queue_work_on(vmbus_connection.connect_cpu, + vmbus_connection.work_queue, + &context->work); +-- +2.13.0 + diff --git a/kernel/patches-4.9.x/0001-tools-build-Add-test-for-sched_getcpu.patch b/kernel/patches-4.9.x/0001-tools-build-Add-test-for-sched_getcpu.patch new file mode 100644 index 000000000..061f2a074 --- /dev/null +++ b/kernel/patches-4.9.x/0001-tools-build-Add-test-for-sched_getcpu.patch @@ -0,0 +1,150 @@ +From f362cabb29dbdba34de667cf1bcbc011fed7e784 Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Thu, 2 Mar 2017 12:55:49 -0300 +Subject: [PATCH 01/12] tools build: Add test for sched_getcpu() + +Instead of trying to go on adding more ifdef conditions, do a feature +test and define HAVE_SCHED_GETCPU_SUPPORT instead, then use it to +provide the prototype. No need to change the stub, as it is already a +__weak symbol. + +Cc: Adrian Hunter +Cc: David Ahern +Cc: Jiri Olsa +Cc: Namhyung Kim +Cc: Wang Nan +Link: http://lkml.kernel.org/n/tip-yge89er9g90sc0v6k0a0r5tr@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +(cherry picked from commit 120010cb1eea151d38a3e66f5ffc79a0c3110292) +Signed-off-by: Rolf Neugebauer +--- + tools/build/Makefile.feature | 1 + + tools/build/feature/Makefile | 6 +++++- + tools/build/feature/test-all.c | 5 +++++ + tools/build/feature/test-sched_getcpu.c | 7 +++++++ + tools/perf/Makefile.config | 4 ++++ + tools/perf/util/cloexec.h | 6 ------ + tools/perf/util/util.h | 4 ++-- + 7 files changed, 24 insertions(+), 9 deletions(-) + create mode 100644 tools/build/feature/test-sched_getcpu.c + +diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature +index ae52e029dd22..ea0a46b4f65f 100644 +--- a/tools/build/Makefile.feature ++++ b/tools/build/Makefile.feature +@@ -63,6 +63,7 @@ FEATURE_TESTS_BASIC := \ + lzma \ + get_cpuid \ + bpf \ ++ sched_getcpu \ + sdt + + # FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list +diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile +index ac9c477a2a48..5d5f093b85a1 100644 +--- a/tools/build/feature/Makefile ++++ b/tools/build/feature/Makefile +@@ -47,7 +47,8 @@ FILES= \ + test-bpf.bin \ + test-get_cpuid.bin \ + test-sdt.bin \ +- test-cxx.bin ++ test-cxx.bin \ ++ test-sched_getcpu.bin + + FILES := $(addprefix $(OUTPUT),$(FILES)) + +@@ -89,6 +90,9 @@ $(OUTPUT)test-libelf.bin: + $(OUTPUT)test-glibc.bin: + $(BUILD) + ++$(OUTPUT)test-sched_getcpu.bin: ++ $(BUILD) ++ + DWARFLIBS := -ldw + ifeq ($(findstring -static,${LDFLAGS}),-static) + DWARFLIBS += -lelf -lebl -lz -llzma -lbz2 +diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c +index 699e43627397..cc6c7c01f4ca 100644 +--- a/tools/build/feature/test-all.c ++++ b/tools/build/feature/test-all.c +@@ -117,6 +117,10 @@ + # include "test-pthread-attr-setaffinity-np.c" + #undef main + ++#define main main_test_sched_getcpu ++# include "test-sched_getcpu.c" ++#undef main ++ + # if 0 + /* + * Disable libbabeltrace check for test-all, because the requested +@@ -182,6 +186,7 @@ int main(int argc, char *argv[]) + main_test_get_cpuid(); + main_test_bpf(); + main_test_libcrypto(); ++ main_test_sched_getcpu(); + main_test_sdt(); + + return 0; +diff --git a/tools/build/feature/test-sched_getcpu.c b/tools/build/feature/test-sched_getcpu.c +new file mode 100644 +index 000000000000..c4a148dd7104 +--- /dev/null ++++ b/tools/build/feature/test-sched_getcpu.c +@@ -0,0 +1,7 @@ ++#define _GNU_SOURCE ++#include ++ ++int main(void) ++{ ++ return sched_getcpu(); ++} +diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config +index cffdd9cf3ebf..a33f737329ae 100644 +--- a/tools/perf/Makefile.config ++++ b/tools/perf/Makefile.config +@@ -296,6 +296,10 @@ ifdef NO_DWARF + NO_LIBDW_DWARF_UNWIND := 1 + endif + ++ifeq ($(feature-sched_getcpu), 1) ++ CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT ++endif ++ + ifndef NO_LIBELF + CFLAGS += -DHAVE_LIBELF_SUPPORT + EXTLIBS += -lelf +diff --git a/tools/perf/util/cloexec.h b/tools/perf/util/cloexec.h +index d0d465953d36..94a5a7d829d5 100644 +--- a/tools/perf/util/cloexec.h ++++ b/tools/perf/util/cloexec.h +@@ -3,10 +3,4 @@ + + unsigned long perf_event_open_cloexec_flag(void); + +-#ifdef __GLIBC_PREREQ +-#if !__GLIBC_PREREQ(2, 6) && !defined(__UCLIBC__) +-int sched_getcpu(void) __THROW; +-#endif +-#endif +- + #endif /* __PERF_CLOEXEC_H */ +diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h +index 43899e0d6fa1..c3b180254f91 100644 +--- a/tools/perf/util/util.h ++++ b/tools/perf/util/util.h +@@ -356,8 +356,8 @@ void print_binary(unsigned char *data, size_t len, + size_t bytes_per_line, print_binary_t printer, + void *extra); + +-#if !defined(__GLIBC__) && !defined(__ANDROID__) +-extern int sched_getcpu(void); ++#ifndef HAVE_SCHED_GETCPU_SUPPORT ++int sched_getcpu(void); + #endif + + int is_printable_array(char *p, unsigned int len); +-- +2.13.0 + diff --git a/kernel/patches-4.9.x/0002-perf-jit-Avoid-returning-garbage-for-a-ret-variable.patch b/kernel/patches-4.9.x/0002-perf-jit-Avoid-returning-garbage-for-a-ret-variable.patch new file mode 100644 index 000000000..e0265d95b --- /dev/null +++ b/kernel/patches-4.9.x/0002-perf-jit-Avoid-returning-garbage-for-a-ret-variable.patch @@ -0,0 +1,70 @@ +From 20a8ecb884aaae0e43d2ce631d799b73f7825828 Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Thu, 13 Oct 2016 17:12:35 -0300 +Subject: [PATCH 02/12] perf jit: Avoid returning garbage for a ret variable + +When the loop body isn't executed at all, then the 'ret' local variable, +that is uninitialized will be used as the return value. + +This triggers this error on Alpine Linux: + + CC /tmp/build/perf/util/demangle-java.o + CC /tmp/build/perf/util/demangle-rust.o + CC /tmp/build/perf/util/jitdump.o + CC /tmp/build/perf/util/genelf.o + util/jitdump.c: In function 'jit_process': + util/jitdump.c:622:3: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized] + fprintf(stderr, "injected: %s (%d)\n", path, ret); + ^ + util/jitdump.c:584:6: note: 'ret' was declared here + int ret; + ^ + FLEX /tmp/build/perf/util/parse-events-flex.c + + / $ gcc -v + Using built-in specs. + COLLECT_GCC=gcc + COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/5.3.0/lto-wrapper + Target: x86_64-alpine-linux-musl + Configured with: /home/buildozer/aports/main/gcc/src/gcc-5.3.0/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info + +--build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 5.3.0' --enable-checking=release + +--disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-esp + +--enable-cloog-backend --enable-languages=c,c++,objc,java,fortran,ada --disable-libssp --disable-libmudflap --disable-libsanitizer --enable-shared + +--enable-threads --enable-tls --with-system-zlib + Thread model: posix + gcc version 5.3.0 (Alpine 5.3.0) + +But this so far got under the radar, not causing any build problem, till the +"perf jit: enable jitdump support without dwarf" gets applied, when the above +problem takes place, some combination of inlining or whatever, the problem +is real, so fix it by initializing the variable to zero. + +Cc: Anton Blanchard +Cc: Jiri Olsa +Cc: Maciej Debski +Cc: Namhyung Kim +Cc: Peter Zijlstra +Cc: Stephane Eranian +Link: https://lkml.kernel.org/r/20161013200437.GA12815@kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +(cherry picked from commit ef2c3e76d98dfb69a46d870b47656e8e5bac6e2b) +--- + tools/perf/util/jitdump.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c +index 95f0884aae02..f3ed3c963c71 100644 +--- a/tools/perf/util/jitdump.c ++++ b/tools/perf/util/jitdump.c +@@ -581,7 +581,7 @@ static int + jit_process_dump(struct jit_buf_desc *jd) + { + union jr_entry *jr; +- int ret; ++ int ret = 0; + + while ((jr = jit_get_next_entry(jd))) { + switch(jr->prefix.id) { +-- +2.13.0 + diff --git a/kernel/patches-4.9.x/0001-hv_sock-introduce-Hyper-V-Sockets.patch b/kernel/patches-4.9.x/0003-hv_sock-introduce-Hyper-V-Sockets.patch similarity index 99% rename from kernel/patches-4.9.x/0001-hv_sock-introduce-Hyper-V-Sockets.patch rename to kernel/patches-4.9.x/0003-hv_sock-introduce-Hyper-V-Sockets.patch index bc94e9752..2492fc7c1 100644 --- a/kernel/patches-4.9.x/0001-hv_sock-introduce-Hyper-V-Sockets.patch +++ b/kernel/patches-4.9.x/0003-hv_sock-introduce-Hyper-V-Sockets.patch @@ -1,7 +1,7 @@ -From b3ab7614ecd7602494567af7443aaba1332558db Mon Sep 17 00:00:00 2001 +From 345e0d8b616922b8c7efb9bf3132f6d706d9c050 Mon Sep 17 00:00:00 2001 From: Dexuan Cui Date: Sat, 23 Jul 2016 01:35:51 +0000 -Subject: [PATCH 01/10] hv_sock: introduce Hyper-V Sockets +Subject: [PATCH 03/12] hv_sock: introduce Hyper-V Sockets Hyper-V Sockets (hv_sock) supplies a byte-stream based communication mechanism between the host and the guest. It's somewhat like TCP over @@ -1787,5 +1787,5 @@ index 000000000000..331d3759f5cb +MODULE_DESCRIPTION("Hyper-V Sockets"); +MODULE_LICENSE("Dual BSD/GPL"); -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.9.x/0002-vmbus-Don-t-spam-the-logs-with-unknown-GUIDs.patch b/kernel/patches-4.9.x/0004-vmbus-Don-t-spam-the-logs-with-unknown-GUIDs.patch similarity index 86% rename from kernel/patches-4.9.x/0002-vmbus-Don-t-spam-the-logs-with-unknown-GUIDs.patch rename to kernel/patches-4.9.x/0004-vmbus-Don-t-spam-the-logs-with-unknown-GUIDs.patch index 131ca71b9..0d67733fc 100644 --- a/kernel/patches-4.9.x/0002-vmbus-Don-t-spam-the-logs-with-unknown-GUIDs.patch +++ b/kernel/patches-4.9.x/0004-vmbus-Don-t-spam-the-logs-with-unknown-GUIDs.patch @@ -1,7 +1,7 @@ -From 012f922a413f62dd3714e7a5267c5054c5925783 Mon Sep 17 00:00:00 2001 +From 70d9b4de7ab8d510f1370b81901a29e51485bb17 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Mon, 23 May 2016 18:55:45 +0100 -Subject: [PATCH 02/10] vmbus: Don't spam the logs with unknown GUIDs +Subject: [PATCH 04/12] vmbus: Don't spam the logs with unknown GUIDs With Hyper-V sockets device types are introduced on the fly. The pr_info() then prints a message on every connection, which is way too verbose. Since @@ -26,5 +26,5 @@ index d8bc4b910192..8df02f3ca0b2 100644 } -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.9.x/0003-Drivers-hv-utils-Fix-the-mapping-between-host-versio.patch b/kernel/patches-4.9.x/0005-Drivers-hv-utils-Fix-the-mapping-between-host-versio.patch similarity index 91% rename from kernel/patches-4.9.x/0003-Drivers-hv-utils-Fix-the-mapping-between-host-versio.patch rename to kernel/patches-4.9.x/0005-Drivers-hv-utils-Fix-the-mapping-between-host-versio.patch index e0b3bbbbf..5a82e2207 100644 --- a/kernel/patches-4.9.x/0003-Drivers-hv-utils-Fix-the-mapping-between-host-versio.patch +++ b/kernel/patches-4.9.x/0005-Drivers-hv-utils-Fix-the-mapping-between-host-versio.patch @@ -1,7 +1,7 @@ -From c04811a761d6df8dc7be550a646c16c2125bad38 Mon Sep 17 00:00:00 2001 +From dbd801cfa0ca1bd8a218b63547e755fd93b10303 Mon Sep 17 00:00:00 2001 From: Alex Ng Date: Sun, 6 Nov 2016 13:14:07 -0800 -Subject: [PATCH 03/10] Drivers: hv: utils: Fix the mapping between host +Subject: [PATCH 05/12] Drivers: hv: utils: Fix the mapping between host version and protocol to use We should intentionally declare the protocols to use for every known host @@ -44,5 +44,5 @@ index bcd06306f3e8..e7707747f56d 100644 } -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.9.x/0004-Drivers-hv-vss-Improve-log-messages.patch b/kernel/patches-4.9.x/0006-Drivers-hv-vss-Improve-log-messages.patch similarity index 96% rename from kernel/patches-4.9.x/0004-Drivers-hv-vss-Improve-log-messages.patch rename to kernel/patches-4.9.x/0006-Drivers-hv-vss-Improve-log-messages.patch index fc66c1b6e..de4844fa1 100644 --- a/kernel/patches-4.9.x/0004-Drivers-hv-vss-Improve-log-messages.patch +++ b/kernel/patches-4.9.x/0006-Drivers-hv-vss-Improve-log-messages.patch @@ -1,7 +1,7 @@ -From 854ddd4b4fdaefc292b09d4f4b250a5fee889114 Mon Sep 17 00:00:00 2001 +From b005bf4a7605ae77dbb6547be58a2a00c1a204ed Mon Sep 17 00:00:00 2001 From: Alex Ng Date: Sun, 6 Nov 2016 13:14:10 -0800 -Subject: [PATCH 04/10] Drivers: hv: vss: Improve log messages. +Subject: [PATCH 06/12] Drivers: hv: vss: Improve log messages. Adding log messages to help troubleshoot error cases and transaction handling. @@ -101,5 +101,5 @@ index a76e3db0d01f..b1446d51ef45 100644 return 0; } -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.9.x/0005-Drivers-hv-vss-Operation-timeouts-should-match-host-.patch b/kernel/patches-4.9.x/0007-Drivers-hv-vss-Operation-timeouts-should-match-host-.patch similarity index 92% rename from kernel/patches-4.9.x/0005-Drivers-hv-vss-Operation-timeouts-should-match-host-.patch rename to kernel/patches-4.9.x/0007-Drivers-hv-vss-Operation-timeouts-should-match-host-.patch index 79569e03f..c8ad59e40 100644 --- a/kernel/patches-4.9.x/0005-Drivers-hv-vss-Operation-timeouts-should-match-host-.patch +++ b/kernel/patches-4.9.x/0007-Drivers-hv-vss-Operation-timeouts-should-match-host-.patch @@ -1,7 +1,7 @@ -From 2174dbb9313a539f86857a8919225b5409022dba Mon Sep 17 00:00:00 2001 +From e90c65ae67af6caf6dcdc6737b7fedcbefba1f5e Mon Sep 17 00:00:00 2001 From: Alex Ng Date: Sun, 6 Nov 2016 13:14:11 -0800 -Subject: [PATCH 05/10] Drivers: hv: vss: Operation timeouts should match host +Subject: [PATCH 07/12] Drivers: hv: vss: Operation timeouts should match host expectation Increase the timeout of backup operations. When system is under I/O load, @@ -44,5 +44,5 @@ index b1446d51ef45..4e543dbb731a 100644 rc = hvutil_transport_send(hvt, vss_msg, sizeof(*vss_msg), NULL); if (rc) { -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.9.x/0006-Drivers-hv-vmbus-Use-all-supported-IC-versions-to-ne.patch b/kernel/patches-4.9.x/0008-Drivers-hv-vmbus-Use-all-supported-IC-versions-to-ne.patch similarity index 99% rename from kernel/patches-4.9.x/0006-Drivers-hv-vmbus-Use-all-supported-IC-versions-to-ne.patch rename to kernel/patches-4.9.x/0008-Drivers-hv-vmbus-Use-all-supported-IC-versions-to-ne.patch index 92bc67361..e8f9b90b2 100644 --- a/kernel/patches-4.9.x/0006-Drivers-hv-vmbus-Use-all-supported-IC-versions-to-ne.patch +++ b/kernel/patches-4.9.x/0008-Drivers-hv-vmbus-Use-all-supported-IC-versions-to-ne.patch @@ -1,7 +1,7 @@ -From 97e7a019f9f4bafcabb1689ad33b27fb60c3606c Mon Sep 17 00:00:00 2001 +From c3effb92348cc1e120705f16ad134ce059c2a2d2 Mon Sep 17 00:00:00 2001 From: Alex Ng Date: Sat, 28 Jan 2017 12:37:17 -0700 -Subject: [PATCH 06/10] Drivers: hv: vmbus: Use all supported IC versions to +Subject: [PATCH 08/12] Drivers: hv: vmbus: Use all supported IC versions to negotiate Previously, we were assuming that each IC protocol version was tied to a @@ -488,5 +488,5 @@ index 489ad74c1e6e..956acfc93487 100644 void hv_event_tasklet_disable(struct vmbus_channel *channel); void hv_event_tasklet_enable(struct vmbus_channel *channel); -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.9.x/0007-Drivers-hv-Log-the-negotiated-IC-versions.patch b/kernel/patches-4.9.x/0009-Drivers-hv-Log-the-negotiated-IC-versions.patch similarity index 96% rename from kernel/patches-4.9.x/0007-Drivers-hv-Log-the-negotiated-IC-versions.patch rename to kernel/patches-4.9.x/0009-Drivers-hv-Log-the-negotiated-IC-versions.patch index c9c8c849a..f6b848a35 100644 --- a/kernel/patches-4.9.x/0007-Drivers-hv-Log-the-negotiated-IC-versions.patch +++ b/kernel/patches-4.9.x/0009-Drivers-hv-Log-the-negotiated-IC-versions.patch @@ -1,7 +1,7 @@ -From 869354ebd5dc2ad10446b7bd041715ddd181e82b Mon Sep 17 00:00:00 2001 +From b140005685c86b44df788ade32cc887c2954a180 Mon Sep 17 00:00:00 2001 From: Alex Ng Date: Sat, 28 Jan 2017 12:37:18 -0700 -Subject: [PATCH 07/10] Drivers: hv: Log the negotiated IC versions. +Subject: [PATCH 09/12] Drivers: hv: Log the negotiated IC versions. Log the negotiated IC versions. @@ -114,5 +114,5 @@ index f3797c07be10..89440c2eb346 100644 hb_srv_version & 0xFFFF); } -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.9.x/0008-vmbus-fix-missed-ring-events-on-boot.patch b/kernel/patches-4.9.x/0010-vmbus-fix-missed-ring-events-on-boot.patch similarity index 93% rename from kernel/patches-4.9.x/0008-vmbus-fix-missed-ring-events-on-boot.patch rename to kernel/patches-4.9.x/0010-vmbus-fix-missed-ring-events-on-boot.patch index fb18f3023..8fb6fd717 100644 --- a/kernel/patches-4.9.x/0008-vmbus-fix-missed-ring-events-on-boot.patch +++ b/kernel/patches-4.9.x/0010-vmbus-fix-missed-ring-events-on-boot.patch @@ -1,7 +1,7 @@ -From c6d35f59897111836c99ac496fc19185ad5b2d14 Mon Sep 17 00:00:00 2001 +From 6d6402672f5f6ff6940653f0d0e1534ed44648d2 Mon Sep 17 00:00:00 2001 From: Dexuan Cui Date: Sun, 26 Mar 2017 16:42:20 +0800 -Subject: [PATCH 08/10] vmbus: fix missed ring events on boot +Subject: [PATCH 10/12] vmbus: fix missed ring events on boot During initialization, the channel initialization code schedules the tasklet to scan the VMBUS receive event page (i.e. simulates an @@ -52,5 +52,5 @@ index e7949b64bfbc..2fe024e86209 100644 void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid) -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.9.x/0009-vmbus-remove-goto-error_clean_msglist-in-vmbus_open.patch b/kernel/patches-4.9.x/0011-vmbus-remove-goto-error_clean_msglist-in-vmbus_open.patch similarity index 92% rename from kernel/patches-4.9.x/0009-vmbus-remove-goto-error_clean_msglist-in-vmbus_open.patch rename to kernel/patches-4.9.x/0011-vmbus-remove-goto-error_clean_msglist-in-vmbus_open.patch index 5ec62cd9b..3a62ad53d 100644 --- a/kernel/patches-4.9.x/0009-vmbus-remove-goto-error_clean_msglist-in-vmbus_open.patch +++ b/kernel/patches-4.9.x/0011-vmbus-remove-goto-error_clean_msglist-in-vmbus_open.patch @@ -1,7 +1,7 @@ -From 84ebcb68437336010f9ca728cf127f949d534054 Mon Sep 17 00:00:00 2001 +From bd98313228b6ec9018c83f02586fa7a07fafac36 Mon Sep 17 00:00:00 2001 From: Dexuan Cui Date: Wed, 29 Mar 2017 18:37:10 +0800 -Subject: [PATCH 09/10] vmbus: remove "goto error_clean_msglist" in +Subject: [PATCH 11/12] vmbus: remove "goto error_clean_msglist" in vmbus_open() This is just a cleanup patch to simplify the code a little. @@ -56,5 +56,5 @@ index 1606e7f08f4b..1caed01954f6 100644 vmbus_teardown_gpadl(newchannel, newchannel->ringbuffer_gpadlhandle); kfree(open_info); -- -2.11.1 +2.13.0 diff --git a/kernel/patches-4.9.x/0010-vmbus-dynamically-enqueue-dequeue-the-channel-on-vmb.patch b/kernel/patches-4.9.x/0012-vmbus-dynamically-enqueue-dequeue-the-channel-on-vmb.patch similarity index 97% rename from kernel/patches-4.9.x/0010-vmbus-dynamically-enqueue-dequeue-the-channel-on-vmb.patch rename to kernel/patches-4.9.x/0012-vmbus-dynamically-enqueue-dequeue-the-channel-on-vmb.patch index c74c1306d..67ead0ac5 100644 --- a/kernel/patches-4.9.x/0010-vmbus-dynamically-enqueue-dequeue-the-channel-on-vmb.patch +++ b/kernel/patches-4.9.x/0012-vmbus-dynamically-enqueue-dequeue-the-channel-on-vmb.patch @@ -1,7 +1,7 @@ -From 4ca791e8f598c5bab9cbc2c2d7f35d8c3c6328a3 Mon Sep 17 00:00:00 2001 +From 0656da868b410cfd818b9551411c40ac9c8c42ef Mon Sep 17 00:00:00 2001 From: Dexuan Cui Date: Fri, 24 Mar 2017 20:53:18 +0800 -Subject: [PATCH 10/10] vmbus: dynamically enqueue/dequeue the channel on +Subject: [PATCH 12/12] vmbus: dynamically enqueue/dequeue the channel on vmbus_open/close Signed-off-by: Dexuan Cui @@ -173,5 +173,5 @@ index 956acfc93487..9ee292b28e41 100644 void vmbus_setevent(struct vmbus_channel *channel); -- -2.11.1 +2.13.0 diff --git a/tools/alpine/packages b/tools/alpine/packages index a354bc93d..b14ec7021 100644 --- a/tools/alpine/packages +++ b/tools/alpine/packages @@ -18,9 +18,11 @@ cmake cryptsetup curl dhcpcd +diffutils dosfstools e2fsprogs e2fsprogs-extra +elfutils-dev flex gcc git @@ -36,7 +38,9 @@ libarchive-tools libc-dev libc-utils libelf-dev +libressl-dev libseccomp-dev +libunwind-dev linux-headers make mtools @@ -56,6 +60,7 @@ qemu-system-arm qemu-system-x86_64 sed sfdisk +slang-dev squashfs-tools strace syslinux @@ -67,3 +72,5 @@ vim xfsprogs xorriso xz +xz-dev +zlib-dev diff --git a/tools/alpine/versions b/tools/alpine/versions index 69f673337..9d1b14d08 100644 --- a/tools/alpine/versions +++ b/tools/alpine/versions @@ -17,22 +17,25 @@ btrfs-progs-4.10.2-r0 btrfs-progs-dev-4.10.2-r0 btrfs-progs-libs-4.10.2-r0 build-base-0.5-r0 -busybox-1.26.2-r4 +busybox-1.26.2-r5 bzip2-1.0.6-r5 ca-certificates-20161130-r2 cdrkit-1.1.11-r2 celt051-0.5.1.3-r0 -cmake-3.8.0-r0 +cmake-3.8.1-r0 cryptsetup-1.7.5-r0 cryptsetup-libs-1.7.5-r0 curl-7.54.0-r0 db-5.3.28-r0 device-mapper-libs-2.02.168-r3 dhcpcd-6.11.5-r1 +diffutils-3.5-r0 dosfstools-4.1-r1 e2fsprogs-1.43.4-r0 e2fsprogs-extra-1.43.4-r0 e2fsprogs-libs-1.43.4-r0 +elfutils-dev-0.168-r1 +elfutils-libelf-0.168-r1 expat-2.2.0-r0 file-5.30-r0 findmnt-2.28.2-r2 @@ -45,7 +48,7 @@ git-2.13.0-r0 glib-2.52.1-r0 gmp-6.1.2-r0 gmp-dev-6.1.2-r0 -gnutls-3.5.12-r0 +gnutls-3.5.13-r0 go-1.8.1-r0 gummiboot-48.1-r0 hvtools-4.4.15-r0 @@ -80,6 +83,8 @@ libedit-20170329.3.1-r2 libelf-0.8.13-r2 libelf-dev-0.8.13-r2 libepoxy-1.4.1-r0 +libexecinfo-1.1-r0 +libexecinfo-dev-1.1-r0 libfdisk-2.28.2-r2 libffi-3.2.1-r3 libgcc-6.3.0-r4 @@ -99,6 +104,7 @@ libogg-1.3.2-r1 libpciaccess-0.13.4-r1 libpng-1.6.29-r1 libressl-2.5.4-r0 +libressl-dev-2.5.4-r0 libressl2.5-libcrypto-2.5.4-r0 libressl2.5-libssl-2.5.4-r0 libressl2.5-libtls-2.5.4-r0 @@ -111,6 +117,8 @@ libstdc++-6.3.0-r4 libtasn1-4.10-r1 libtirpc-1.0.1-r1 libunistring-0.9.7-r0 +libunwind-1.2-r2 +libunwind-dev-1.2-r2 libusb-1.0.21-r0 libuuid-2.28.2-r2 libuv-1.11.0-r1 @@ -160,6 +168,8 @@ readline-6.3.008-r5 scanelf-1.2.2-r0 sed-4.4-r0 sfdisk-2.28.2-r2 +slang-2.3.1-r0 +slang-dev-2.3.1-r0 snappy-1.1.4-r1 spice-server-0.13.3-r1 squashfs-tools-4.3-r3 @@ -176,5 +186,7 @@ wayland-1.13.0-r0 xfsprogs-4.5.0-r0 xorriso-1.4.6-r0 xz-5.2.3-r0 +xz-dev-5.2.3-r0 xz-libs-5.2.3-r0 zlib-1.2.11-r0 +zlib-dev-1.2.11-r0 diff --git a/tools/kernel-compile/Dockerfile b/tools/kernel-compile/Dockerfile deleted file mode 100644 index 45d01e8fd..000000000 --- a/tools/kernel-compile/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM alpine:3.5 -RUN \ - apk update && apk upgrade && \ - apk add \ - build-base \ - argp-standalone \ - automake \ - bash \ - bc \ - binutils-dev \ - curl \ - git \ - gmp-dev \ - installkernel \ - kmod \ - libelf-dev \ - linux-headers \ - ncurses-dev \ - sed \ - squashfs-tools \ - tar \ - xz \ - && true diff --git a/tools/kernel-compile/Makefile b/tools/kernel-compile/Makefile deleted file mode 100644 index eede7f35e..000000000 --- a/tools/kernel-compile/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -.PHONY: tag push - -BASE=alpine:3.5 -IMAGE=kernel-compile - -default: push - -hash: - DOCKER_CONTENT_TRUST=1 docker pull $(BASE) - tar cf - Dockerfile | docker build --no-cache -t $(IMAGE):build - - docker run --rm $(IMAGE):build sha1sum /lib/apk/db/installed | sed 's/ .*//' > hash - -push: hash - docker pull linuxkit/$(IMAGE):$(shell cat hash) || \ - (docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash) && \ - docker push linuxkit/$(IMAGE):$(shell cat hash)) - docker rmi $(IMAGE):build - rm -f hash - -tag: hash - docker pull linuxkit/$(IMAGE):$(shell cat hash) || \ - docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash) - docker rmi $(IMAGE):build - rm -f hash - -clean: - rm -f hash - -.DELETE_ON_ERROR: diff --git a/tools/perf/.gitignore b/tools/perf/.gitignore deleted file mode 100644 index 7447f89a5..000000000 --- a/tools/perf/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin \ No newline at end of file diff --git a/tools/perf/Dockerfile b/tools/perf/Dockerfile deleted file mode 100644 index 90bceb6b7..000000000 --- a/tools/perf/Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -FROM alpine:3.4 - -RUN \ - apk update && apk upgrade && \ - apk add \ - argp-standalone \ - automake \ - bc \ - binutils-dev \ - bison \ - build-base \ - curl \ - flex \ - libelf-dev \ - linux-headers \ - sed \ - tar \ - util-linux-dev \ - xz \ - && true - -ARG KERNEL_VERSION=4.9.3 - -# get kernel source and extract it under /linux -ENV KERNEL_SOURCE=https://www.kernel.org/pub/linux/kernel/v4.x/linux-${KERNEL_VERSION}.tar.xz -RUN curl -fsSL -o linux-${KERNEL_VERSION}.tar.xz ${KERNEL_SOURCE} -RUN cat linux-${KERNEL_VERSION}.tar.xz | tar --absolute-names -xJ && mv /linux-${KERNEL_VERSION} /linux - -RUN mkdir -p /build/perf && \ - make -C /linux/tools/perf O=/build/perf LDFLAGS=-static - -WORKDIR /build/perf -CMD ["tar", "cf", "-", "perf"] - - diff --git a/tools/perf/Makefile b/tools/perf/Makefile deleted file mode 100644 index 517492e20..000000000 --- a/tools/perf/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -BASE=alpine:3.4 - -DEPS=Dockerfile - -bin/perf: $(DEPS) - DOCKER_CONTENT_TRUST=1 docker pull $(BASE) - mkdir -p $(dir $@) - BUILD=$$( docker build -q . ) && \ - docker run --rm --net=none $$BUILD | tar xf - -C bin - -clean: - rm -rf bin diff --git a/tools/perf/README.md b/tools/perf/README.md deleted file mode 100644 index d1fa03a92..000000000 --- a/tools/perf/README.md +++ /dev/null @@ -1 +0,0 @@ -Builds a statically linked version of the Linux kernel `perf` utility. You may want to/need to adjust the kernel version in the `Dockerfile` to match your kernel.