0002-x86-kvm-cpu.c-don-t-include-asm-msr-index.h.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From ce9abb649165aca728e4645ce09e7bb77e684b06 Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Sat, 19 Aug 2017 16:35:59 +0200
  4. Subject: [PATCH] x86/kvm-cpu.c: don't include <asm/msr-index.h>
  5. Since kernel commit 25dc1d6cc3082aab293e5dad47623b550f7ddd2a ("x86:
  6. stop exporting msr-index.h to userland"), <asm/msr-index.h> is no
  7. longer exported to userspace. Therefore, any toolchain built with
  8. kernel headers >= 4.12 will no longer have this header file, causing a
  9. build failure in kvmtool.
  10. As a replacement, this patch includes inside x86/kvm-cpu.c the
  11. necessary MSR_* definitions.
  12. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  13. Submitted-upstream: https://patchwork.kernel.org/patch/9910687/
  14. ---
  15. x86/kvm-cpu.c | 17 ++++++++++++++++-
  16. 1 file changed, 16 insertions(+), 1 deletion(-)
  17. diff --git a/x86/kvm-cpu.c b/x86/kvm-cpu.c
  18. index 5cc4e1e..b02ff65 100644
  19. --- a/x86/kvm-cpu.c
  20. +++ b/x86/kvm-cpu.c
  21. @@ -4,7 +4,6 @@
  22. #include "kvm/util.h"
  23. #include "kvm/kvm.h"
  24. -#include <asm/msr-index.h>
  25. #include <asm/apicdef.h>
  26. #include <linux/err.h>
  27. #include <sys/ioctl.h>
  28. @@ -136,6 +135,22 @@ static struct kvm_msrs *kvm_msrs__new(size_t nmsrs)
  29. return vcpu;
  30. }
  31. +#define MSR_IA32_SYSENTER_CS 0x00000174
  32. +#define MSR_IA32_SYSENTER_ESP 0x00000175
  33. +#define MSR_IA32_SYSENTER_EIP 0x00000176
  34. +
  35. +#define MSR_STAR 0xc0000081 /* legacy mode SYSCALL target */
  36. +#define MSR_LSTAR 0xc0000082 /* long mode SYSCALL target */
  37. +#define MSR_CSTAR 0xc0000083 /* compat mode SYSCALL target */
  38. +#define MSR_SYSCALL_MASK 0xc0000084 /* EFLAGS mask for syscall */
  39. +#define MSR_KERNEL_GS_BASE 0xc0000102 /* SwapGS GS shadow */
  40. +
  41. +#define MSR_IA32_TSC 0x00000010
  42. +#define MSR_IA32_MISC_ENABLE 0x000001a0
  43. +
  44. +#define MSR_IA32_MISC_ENABLE_FAST_STRING_BIT 0
  45. +#define MSR_IA32_MISC_ENABLE_FAST_STRING (1ULL << MSR_IA32_MISC_ENABLE_FAST_STRING_BIT)
  46. +
  47. #define KVM_MSR_ENTRY(_index, _data) \
  48. (struct kvm_msr_entry) { .index = _index, .data = _data }
  49. --
  50. 2.9.4