kvmtool: add patch to fix build with musl
PATCH 1/3 kvmtool: add patch to fix build with musl
This commit backports an upstream patch that fixes the build of kvmtool with musl:
In file included from builtin-balloon.c:9:0:include/kvm/kvm.h:22:0: warning: "PAGE_SIZE" redefined
#define PAGE_SIZE (sysconf(_SC_PAGE_SIZE))
Fixes one part of:
http://autobuild.buildroot.net/results/4459a909e735343d1cf768d30466bc3c57eca19e/
--- .../kvmtool/0001-avoid-redefining-PAGE_SIZE.patch | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 package/kvmtool/0001-avoid-redefining-PAGE_SIZE.patch
package/kvmtool/0001-avoid-redefining-PAGE_SIZE.patch new file +42 -0
@@ -0,0 +1,42 @@ +From bec1b0ced72dc0d49825d6b69d09296d13fd0af3 Mon Sep 17 00:00:00 2001 +From: Andre Przywara <[email protected]> +Date: Tue, 21 Jul 2015 10:58:46 +0100 +Subject: [PATCH] avoid redefining PAGE_SIZE + +PAGE_SIZE may have been defined by the C libary (musl-libc does that). +So avoid redefining it here unconditionally, instead only use our +definition if none has been provided by the libc. + +Signed-off-by: Andre Przywara <[email protected]> +Signed-off-by: Will Deacon <[email protected]> +[backport from upstream commit 4095fac878f618ae5e7384a1dc65ee34b6e05217.] +Signed-off-by: Thomas Petazzoni <[email protected]> +--- + include/kvm/kvm.h | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/include/kvm/kvm.h b/include/kvm/kvm.h +index 754e029..37155db 100644 +--- a/include/kvm/kvm.h ++++ b/include/kvm/kvm.h +@@ -11,6 +11,7 @@ + #include <time.h> + #include <signal.h> + #include <sys/prctl.h> ++#include <limits.h> + + #define SIGKVMEXIT (SIGRTMIN + 0) + #define SIGKVMPAUSE (SIGRTMIN + 1) +@@ -19,7 +20,9 @@ + #define HOME_DIR getenv("HOME") + #define KVM_BINARY_NAME "lkvm" + ++#ifndef PAGE_SIZE + #define PAGE_SIZE (sysconf(_SC_PAGE_SIZE)) ++#endif + + #define DEFINE_KVM_EXT(ext) \ + .name = #ext, \ +-- +2.9.4 +
Signature · 1 line
2.9.4
PATCH 1/3 kvmtool: add patch to fix build with musl
Hello,
Quoted 9 lines · Thomas Petazzoni
This commit backports an upstream patch that fixes the build of kvmtool with musl:
In file included from builtin-balloon.c:9:0:
include/kvm/kvm.h:22:0: warning: "PAGE_SIZE" redefined
#definePAGE_SIZE(sysconf(_SC_PAGE_SIZE))Fixes one part of:
Quoted 7 lines
http://autobuild.buildroot.net/results/4459a909e735343d1cf768d30466bc3c57eca19e/
Signed-off-by Thomas Petazzoni <[email protected]>--- .../kvmtool/0001-avoid-redefining-PAGE_SIZE.patch | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 package/kvmtool/0001-avoid-redefining-PAGE_SIZE.patch
All applied. Thanks Bernd for having tested the patches!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 2/3 kvmtool: fix build with kernel headers >= 4.12
In reply to Thomas PetazzoniIn Linux 4.12, the header <asm/msr-index.h> has been removed from the set of headers exported to userspace. Therefore, it cannot be used by kvmtool anymore. This commit takes the simple approach of duplicating inside kvmtool the MSR_* definitions that were used from this <asm/msr-index.h> header.
This fixes:
x86/kvm-cpu.c:7:27: fatal error: asm/msr-index.h: No such file or directory
#include <asm/msr-index.h>
Which is the second part of:
http://autobuild.buildroot.net/results/4459a909e735343d1cf768d30466bc3c57eca19e/
--- ...6-kvm-cpu.c-don-t-include-asm-msr-index.h.patch | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 package/kvmtool/0002-x86-kvm-cpu.c-don-t-include-asm-msr-index.h.patch
package/kvmtool/0002-x86-kvm-cpu.c-don-t-include-asm-msr-index.h.patch new file +58 -0
@@ -0,0 +1,58 @@ +From ce9abb649165aca728e4645ce09e7bb77e684b06 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni <[email protected]> +Date: Sat, 19 Aug 2017 16:35:59 +0200 +Subject: [PATCH] x86/kvm-cpu.c: don't include <asm/msr-index.h> + +Since kernel commit 25dc1d6cc3082aab293e5dad47623b550f7ddd2a ("x86: +stop exporting msr-index.h to userland"), <asm/msr-index.h> is no +longer exported to userspace. Therefore, any toolchain built with +kernel headers >= 4.12 will no longer have this header file, causing a +build failure in kvmtool. + +As a replacement, this patch includes inside x86/kvm-cpu.c the +necessary MSR_* definitions. + +Signed-off-by: Thomas Petazzoni <[email protected]> +Submitted-upstream: https://patchwork.kernel.org/patch/9910687/ +--- + x86/kvm-cpu.c | 17 ++++++++++++++++- + 1 file changed, 16 insertions(+), 1 deletion(-) + +diff --git a/x86/kvm-cpu.c b/x86/kvm-cpu.c +index 5cc4e1e..b02ff65 100644 +--- a/x86/kvm-cpu.c ++++ b/x86/kvm-cpu.c +@@ -4,7 +4,6 @@ + #include "kvm/util.h" + #include "kvm/kvm.h" + +-#include <asm/msr-index.h> + #include <asm/apicdef.h> + #include <linux/err.h> + #include <sys/ioctl.h> +@@ -136,6 +135,22 @@ static struct kvm_msrs *kvm_msrs__new(size_t nmsrs) + return vcpu; + } + ++#define MSR_IA32_SYSENTER_CS 0x00000174 ++#define MSR_IA32_SYSENTER_ESP 0x00000175 ++#define MSR_IA32_SYSENTER_EIP 0x00000176 ++ ++#define MSR_STAR 0xc0000081 /* legacy mode SYSCALL target */ ++#define MSR_LSTAR 0xc0000082 /* long mode SYSCALL target */ ++#define MSR_CSTAR 0xc0000083 /* compat mode SYSCALL target */ ++#define MSR_SYSCALL_MASK 0xc0000084 /* EFLAGS mask for syscall */ ++#define MSR_KERNEL_GS_BASE 0xc0000102 /* SwapGS GS shadow */ ++ ++#define MSR_IA32_TSC 0x00000010 ++#define MSR_IA32_MISC_ENABLE 0x000001a0 ++ ++#define MSR_IA32_MISC_ENABLE_FAST_STRING_BIT 0 ++#define MSR_IA32_MISC_ENABLE_FAST_STRING (1ULL << MSR_IA32_MISC_ENABLE_FAST_STRING_BIT) ++ + #define KVM_MSR_ENTRY(_index, _data) \ + (struct kvm_msr_entry) { .index = _index, .data = _data } + +-- +2.9.4 +
Signature · 1 line
2.9.4
PATCH 2/3 kvmtool: fix build with kernel headers >= 4.12
Am Sat, 19 Aug 2017 22:55:27 +0200 schrieb Thomas Petazzoni:
Quoted 8 lines
In Linux 4.12, the header <
asm/msr-index.h> has been removed from the set of headers exported to userspace. Therefore, it cannot be used by kvmtool anymore. This commit takes the simple approach of duplicating inside kvmtool the MSR_* definitions that were used from this <asm/msr-index.h> header.This fixes:
Quoted 7 lines
x86/kvm-cpu.c:7:27: fatal error:asm/msr-index.h: No such file or directory
#include <asm/msr-index.h>Which is the second part of:
results/4459a909e735343d1cf768d30466bc3c57eca19e/
[ build-tested using http://autobuild.buildroot.net/results/ae4/
ae434d85be12d07dddf4c955855120da83a19dd6/defconfig ]
PATCH 1/3 kvmtool: add patch to fix build with musl
In reply to Thomas PetazzoniAm Sat, 19 Aug 2017 22:55:26 +0200 schrieb Thomas Petazzoni:
Quoted 10 lines
This commit backports an upstream patch that fixes the build of kvmtool with musl:
In file included from builtin-balloon.c:9:0:
include/kvm/kvm.h:22:0: warning: "PAGE_SIZE" redefined
#definePAGE_SIZE(sysconf(_SC_PAGE_SIZE))Fixes one part of:
results/4459a909e735343d1cf768d30466bc3c57eca19e/
[ build-tested using http://autobuild.buildroot.net/results/ae4/
ae434d85be12d07dddf4c955855120da83a19dd6/defconfig ]
PATCH 3/3 kvmtool: add patches fixing build warnings with musl
In reply to Thomas PetazzoniThis commit backports three patches that are already upstream in kvmtool fixing build warnings with musl. Those are not strictly needed for the build to succeed, they just reduce the amount of warning noise.
---
This is by no mean mandatory for the master branch, I'm just doing it as I was working on kvmtool. If we don't want that for master, I'll submit a different patch for next that bumps kvmtool to a newer version that includes those fixes. Let me know what you think is best.
--- .../0003-use-poll.h-instead-of-sys-poll.h.patch | 33 ++++++++ ...nd-use-C-library-provided-strlcpy-and-str.patch | 90 ++++++++++++++++++++++ package/kvmtool/0005-Fix-call-to-connect.patch | 34 ++++++++ 3 files changed, 157 insertions(+) create mode 100644 package/kvmtool/0003-use-poll.h-instead-of-sys-poll.h.patch create mode 100644 package/kvmtool/0004-check-for-and-use-C-library-provided-strlcpy-and-str.patch create mode 100644 package/kvmtool/0005-Fix-call-to-connect.patch
package/kvmtool/0003-use-poll.h-instead-of-sys-poll.h.patch new file +33 -0
@@ -0,0 +1,33 @@ +From 19490e24895df95253e43a7aacf3ef408b830bd5 Mon Sep 17 00:00:00 2001 +From: Andre Przywara <[email protected]> +Date: Fri, 17 Jul 2015 17:02:15 +0100 +Subject: [PATCH] use <poll.h> instead of <sys/poll.h> + +The manpage of poll(2) states that the prototype of poll is defined +in <poll.h>. Use that header file instead of <sys/poll.h> to allow +compilation against musl-libc. + +Signed-off-by: Andre Przywara <[email protected]> +Signed-off-by: Will Deacon <[email protected]> +[backport from upstream commit 52c22e6e64a94cc701d86587d32cd3822ac5c293.] +Signed-off-by: Thomas Petazzoni <[email protected]> +--- + disk/core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/disk/core.c b/disk/core.c +index 309e16c..dd2f258 100644 +--- a/disk/core.c ++++ b/disk/core.c +@@ -5,7 +5,7 @@ + + #include <linux/err.h> + #include <sys/eventfd.h> +-#include <sys/poll.h> ++#include <poll.h> + + #define AIO_MAX 256 + +-- +2.9.4 +
package/kvmtool/0004-check-for-and-use-C-library-provided-strlcpy-and-str.patch new file +90 -0
90 lines not on this page · raw message
package/kvmtool/0005-Fix-call-to-connect.patch new file +34 -0
@@ -0,0 +1,34 @@ +From d375235f49184371026791ae8f6f9dc307de8a61 Mon Sep 17 00:00:00 2001 +From: Andre Przywara <[email protected]> +Date: Fri, 17 Jul 2015 17:02:14 +0100 +Subject: [PATCH] Fix call to connect() + +According to the manpage and the prototype the second argument to +connect(2) is a "const struct sockaddr*", so cast our protocol +specific type back to the super type. +This fixes compilation on musl-libc. + +Signed-off-by: Andre Przywara <[email protected]> +Signed-off-by: Will Deacon <[email protected]> +[backport from upstream commit d77bd4f466f341d4b35fe8b91176ef8a37160e19.] +Signed-off-by: Thomas Petazzoni <[email protected]> +--- + kvm-ipc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/kvm-ipc.c b/kvm-ipc.c +index b1c43dd..5a0b6e0 100644 +--- a/kvm-ipc.c ++++ b/kvm-ipc.c +@@ -99,7 +99,7 @@ int kvm__get_sock_by_instance(const char *name) + strlcpy(local.sun_path, sock_file, sizeof(local.sun_path)); + len = strlen(local.sun_path) + sizeof(local.sun_family); + +- r = connect(s, &local, len); ++ r = connect(s, (struct sockaddr *)&local, len); + if (r < 0 && errno == ECONNREFUSED) { + /* Tell the user clean ghost socket file */ + pr_err("\"%s\" could be a ghost socket file, please remove it", +-- +2.9.4 +
Signature · 1 line
2.9.4
PATCH 3/3 kvmtool: add patches fixing build warnings with musl
Am Sat, 19 Aug 2017 22:55:28 +0200 schrieb Thomas Petazzoni:
Quoted 6 lines
This commit backports three patches that are already upstream in kvmtool fixing build warnings with musl. Those are not strictly needed for the build to succeed, they just reduce the amount of warning noise.
Signed-off-by: Thomas Petazzoni
<[email protected]>
[ build-tested using http://autobuild.buildroot.net/results/ae4/
ae434d85be12d07dddf4c955855120da83a19dd6/defconfig ]