linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration
@ 2012-10-19 16:55 David Howells
  2012-10-19 16:56 ` [PATCH 1/5] tools: Define a Makefile function to do subdir processing David Howells
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: David Howells @ 2012-10-19 16:55 UTC (permalink / raw)
  To: mingo, tglx, acme
  Cc: dhowells, davem, torvalds, paulus, linux-arch, linux-kernel, x86


Here are some potential fix ups for perf and other tools.  They need to be
applied on top of the x86 UAPI disintegration patch.

There are five patches:

 (1) Use a makefile $(call ...) function in tools/Makefile to make it easier
     to deal with.

     [NOTE!  I think the rule for selftests_install is wrong since it attempts
      to discard '_clean' from the end of the target name instead of
      '_install']

 (2) Fix handling of O= with a relative path when doing something like:

	make tools/perf O=foo

     from the top-level directory in the kernel source tree for all tools.

 (3) Make perf work for x86 by adding -I flags and changing long #includes
     with "../../include" in them into short <asm/foo.h> type things.

Now there are two patches that I'm not sure whether you want.  There are three
header files with bits used by perf that are not in the UAPI.  If these are
disintegrated then perf does not need to look in any KAPI headers at all and
the -I flag pointing there can be dropped after the first of these patches.

 (4) UAPI disintegrate asm/svm.h and asm/vmx.h.

 (5) UAPI disintegrate asm/perf_regs.h and convert a "../../include" style
     path into <asm/perf_regs.h>.

I'm not sure whether these should be exported to userspace, though this commit:

	commit 26bf264e871a4b9a8ac09c21a2b518e7f23830d5
	Author: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
	Date:   Mon Sep 17 16:31:13 2012 +0800
	KVM: x86: Export svm/vmx exit code and vector code to userspace

suggests that at least the first two should be - though since it didn't modify
Kbuild, this was not effective.

I haven't tried building perf for other arches at this time.

David
---
David Howells (5):
      x86: UAPI Disintegrate asm/perf_regs.h
      x86: Disintegrate asm/svm.h and asm/vmx.h to produce UAPI components for perf
      perf: Make perf build for x86 with UAPI disintegration applied
      tools: Honour the O= flag when tool build called from a higher Makefile
      tools: Define a Makefile function to do subdir processing


 Makefile                                |    6 +
 arch/x86/include/asm/perf_regs.h        |   33 --------
 arch/x86/include/asm/svm.h              |  133 -------------------------------
 arch/x86/include/asm/vmx.h              |   87 --------------------
 arch/x86/include/uapi/asm/perf_regs.h   |   33 ++++++++
 arch/x86/include/uapi/asm/svm.h         |  131 +++++++++++++++++++++++++++++++
 arch/x86/include/uapi/asm/vmx.h         |  108 +++++++++++++++++++++++++
 tools/Makefile                          |   24 +++---
 tools/perf/Makefile                     |   15 +++
 tools/perf/arch/x86/include/perf_regs.h |    2 
 tools/perf/builtin-kvm.c                |    6 +
 tools/perf/perf.h                       |   16 +---
 tools/scripts/Makefile.include          |   18 ++++
 13 files changed, 329 insertions(+), 283 deletions(-)
 delete mode 100644 arch/x86/include/asm/perf_regs.h
 create mode 100644 arch/x86/include/uapi/asm/perf_regs.h
 create mode 100644 arch/x86/include/uapi/asm/svm.h
 create mode 100644 arch/x86/include/uapi/asm/vmx.h


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/5] tools: Define a Makefile function to do subdir processing
  2012-10-19 16:55 [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration David Howells
@ 2012-10-19 16:56 ` David Howells
  2012-10-19 16:56 ` [PATCH 2/5] tools: Honour the O= flag when tool build called from a higher Makefile David Howells
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: David Howells @ 2012-10-19 16:56 UTC (permalink / raw)
  To: mingo, tglx, acme
  Cc: dhowells, davem, torvalds, paulus, linux-arch, linux-kernel, x86

Define a Makefile function that can be called with $(call ...) to wrap the
subdir make invocations in tools/Makefile.

This will allow us in the next patch to insert bits in there to honour O=
flags when called from the top-level Makefile.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 tools/Makefile                 |   24 ++++++++++++------------
 tools/scripts/Makefile.include |    8 ++++++++
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/tools/Makefile b/tools/Makefile
index 3ae4394..1f9a529 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -31,44 +31,44 @@ help:
 	@echo '  clean: a summary clean target to clean _all_ folders'
 
 cpupower: FORCE
-	$(QUIET_SUBDIR0)power/$@/ $(QUIET_SUBDIR1)
+	$(call descend,power/$@)
 
 firewire lguest perf usb virtio vm: FORCE
-	$(QUIET_SUBDIR0)$@/ $(QUIET_SUBDIR1)
+	$(call descend,$@)
 
 selftests: FORCE
-	$(QUIET_SUBDIR0)testing/$@/ $(QUIET_SUBDIR1)
+	$(call descend,testing/$@)
 
 turbostat x86_energy_perf_policy: FORCE
-	$(QUIET_SUBDIR0)power/x86/$@/ $(QUIET_SUBDIR1)
+	$(call descend,power/x86/$@)
 
 cpupower_install:
-	$(QUIET_SUBDIR0)power/$(@:_install=)/ $(QUIET_SUBDIR1) install
+	$(call descend,power/$(@:_install=),install)
 
 firewire_install lguest_install perf_install usb_install virtio_install vm_install:
-	$(QUIET_SUBDIR0)$(@:_install=)/ $(QUIET_SUBDIR1) install
+	$(call descend,$(@:_install=),install)
 
 selftests_install:
-	$(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) install
+	$(call descend,testing/$(@:_clean=),install)
 
 turbostat_install x86_energy_perf_policy_install:
-	$(QUIET_SUBDIR0)power/x86/$(@:_install=)/ $(QUIET_SUBDIR1) install
+	$(call descend,power/x86/$(@:_install=),install)
 
 install: cpupower_install firewire_install lguest_install perf_install \
 		selftests_install turbostat_install usb_install virtio_install \
 		vm_install x86_energy_perf_policy_install
 
 cpupower_clean:
-	$(QUIET_SUBDIR0)power/cpupower/ $(QUIET_SUBDIR1) clean
+	$(call descend,power/cpupower,clean)
 
 firewire_clean lguest_clean perf_clean usb_clean virtio_clean vm_clean:
-	$(QUIET_SUBDIR0)$(@:_clean=)/ $(QUIET_SUBDIR1) clean
+	$(call descend,$(@:_clean=),clean)
 
 selftests_clean:
-	$(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) clean
+	$(call descend,testing/$(@:_clean=),clean)
 
 turbostat_clean x86_energy_perf_policy_clean:
-	$(QUIET_SUBDIR0)power/x86/$(@:_clean=)/ $(QUIET_SUBDIR1) clean
+	$(call descend,power/x86/$(@:_clean=),clean)
 
 clean: cpupower_clean firewire_clean lguest_clean perf_clean selftests_clean \
 		turbostat_clean usb_clean virtio_clean vm_clean \
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index 96ce80a..4a9e317 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -41,6 +41,14 @@ else
 NO_SUBDIR = :
 endif
 
+#
+# Define a callable command for descending to a new directory
+#
+# Call by doing: $(call descend,directory[,target])
+#
+descend = \
+	$(QUIET_SUBDIR0)$(1) $(QUIET_SUBDIR1) $(2)
+
 QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
 QUIET_SUBDIR1  =
 


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/5] tools: Honour the O= flag when tool build called from a higher Makefile
  2012-10-19 16:55 [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration David Howells
  2012-10-19 16:56 ` [PATCH 1/5] tools: Define a Makefile function to do subdir processing David Howells
@ 2012-10-19 16:56 ` David Howells
  2012-10-26  5:34   ` Namhyung Kim
  2012-10-19 16:56 ` [PATCH 3/5] perf: Make perf build for x86 with UAPI disintegration applied David Howells
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: David Howells @ 2012-10-19 16:56 UTC (permalink / raw)
  To: mingo, tglx, acme
  Cc: dhowells, davem, torvalds, paulus, linux-arch, linux-kernel, x86

Honour the O= flag that was passed to a higher level Makefile and then passed
down as part of a tool build.

To make this work, the top-level Makefile passes the original O= flag and
subdir=tools to the tools/Makefile, and that in turn passes
subdir=$(O)/$(subdir)/foodir when building tool foo in directory
$(O)/$(subdir)/foodir (where the intervening slashes aren't added if an
element is missing).

For example, take perf.  This is found in tools/perf/.  Assume we're building
into directory ~/zebra/, so we pass O=~/zebra to make.  Dependening on where
we run the build from, we see:

	make run in dir		$(OUTPUT) dir
	=======================	==================
	linux			~/zebra/tools/perf/
	linux/tools		~/zebra/perf/
	linux/tools/perf	~/zebra/

and if O= is not set, we get:

	make run in dir		$(OUTPUT) dir
	=======================	==================
	linux			linux/tools/perf/
	linux/tools		linux/tools/perf/
	linux/tools/perf	linux/tools/perf/

The output directories are created by the descend function if they don't
already exist.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 Makefile                       |    6 ++++--
 tools/scripts/Makefile.include |   12 +++++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 366d0ab..e93ac4d 100644
--- a/Makefile
+++ b/Makefile
@@ -1310,10 +1310,12 @@ kernelversion:
 
 # Clear a bunch of variables before executing the submake
 tools/: FORCE
-	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= -C $(src)/tools/
+	$(Q)mkdir -p $(objtree)/tools
+	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/
 
 tools/%: FORCE
-	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= -C $(src)/tools/ $*
+	$(Q)mkdir -p $(objtree)/tools
+	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/ $*
 
 # Single targets
 # ---------------------------------------------------------------------------
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index 4a9e317..357cfea 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -1,7 +1,7 @@
 ifeq ("$(origin O)", "command line")
 	dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
 	ABSOLUTE_O := $(shell cd $(O) ; pwd)
-	OUTPUT := $(ABSOLUTE_O)/
+	OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/)
 	COMMAND_O := O=$(ABSOLUTE_O)
 endif
 
@@ -47,9 +47,10 @@ endif
 # Call by doing: $(call descend,directory[,target])
 #
 descend = \
-	$(QUIET_SUBDIR0)$(1) $(QUIET_SUBDIR1) $(2)
+	+mkdir -p $(OUTPUT)$(1) && \
+	$(MAKE) $(COMMAND_O) $(if $(subdir),subdir=$(subdir)/$(1)) $(PRINT_DIR) -C $(1)
 
-QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
+QUIET_SUBDIR0  = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir
 QUIET_SUBDIR1  =
 
 ifneq ($(findstring $(MAKEFLAGS),s),s)
@@ -64,5 +65,10 @@ ifndef V
 			 $(MAKE) $(PRINT_DIR) -C $$subdir
 	QUIET_FLEX     = @echo '   ' FLEX $@;
 	QUIET_BISON    = @echo '   ' BISON $@;
+
+	descend = \
+		@echo '   ' DESCEND $(1); \
+		mkdir -p $(OUTPUT)$(1) && \
+		$(MAKE) $(COMMAND_O) $(if $(subdir),subdir=$(subdir)/$(1)) $(PRINT_DIR) -C $(1)
 endif
 endif


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/5] perf: Make perf build for x86 with UAPI disintegration applied
  2012-10-19 16:55 [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration David Howells
  2012-10-19 16:56 ` [PATCH 1/5] tools: Define a Makefile function to do subdir processing David Howells
  2012-10-19 16:56 ` [PATCH 2/5] tools: Honour the O= flag when tool build called from a higher Makefile David Howells
@ 2012-10-19 16:56 ` David Howells
  2012-10-26  5:49   ` Namhyung Kim
  2012-10-19 16:56 ` [PATCH 4/5] x86: Disintegrate asm/svm.h and asm/vmx.h to produce UAPI components for perf David Howells
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: David Howells @ 2012-10-19 16:56 UTC (permalink / raw)
  To: mingo, tglx, acme
  Cc: dhowells, davem, torvalds, paulus, linux-arch, linux-kernel, x86

Make perf build for x86 once the UAPI disintegration patches for that arch
have been applied by adding the appropriate -I flags - in the right order -
and then converting some #includes that use ../.. notation to find main kernel
headerfiles to use <asm/foo.h> and <linux/foo.h> instead.

Note that -Iarch/foo/include/uapi is present _before_ -Iarch/foo/include.
This makes sure we get the userspace version of the pt_regs struct.  Ideally,
we wouldn't have the latter -I flag at all, but unfortunately we want
asm/svm.h and asm/vmx.h in buildin-kvm.c and these aren't part of the UAPI -
at least not for x86.  I wonder if the bits outside of the __KERNEL__ guards
*should* be transferred there.

I note also that perf seems to do its dependency handling manually by listing
all the header files it might want to use in LIB_H in the Makefile.  Can this
be changed to use -MD?

Signed-off-by: David Howells <dhowells@redhat.com>
---

 tools/perf/Makefile      |   16 +++++++++++++++-
 tools/perf/builtin-kvm.c |    6 +++---
 tools/perf/perf.h        |   16 +++-------------
 3 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index f7c968a..9024a42 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -169,7 +169,21 @@ endif
 
 ### --- END CONFIGURATION SECTION ---
 
-BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
+ifeq ($(srctree),)
+srctree := $(shell pwd)
+endif
+
+BASIC_CFLAGS = \
+	-Iutil/include \
+	-Iarch/$(ARCH)/include \
+	-I$(objtree)/arch/$(ARCH)/include/generated/uapi \
+	-I$(srctree)/arch/$(ARCH)/include/uapi \
+	-I$(srctree)/arch/$(ARCH)/include \
+	-I$(objtree)/include/generated/uapi \
+	-I$(srctree)/include/uapi \
+	-I$(OUTPUT)util \
+	-I$(TRACE_EVENT_DIR) \
+	-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
 BASIC_LDFLAGS =
 
 # Guard against environment variables
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 260abc5..e013bdb 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -22,9 +22,9 @@
 #include <pthread.h>
 #include <math.h>
 
-#include "../../arch/x86/include/asm/svm.h"
-#include "../../arch/x86/include/asm/vmx.h"
-#include "../../arch/x86/include/asm/kvm.h"
+#include <asm/svm.h>
+#include <asm/vmx.h>
+#include <asm/kvm.h>
 
 struct event_key {
 	#define INVALID_KEY     (~0ULL)
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 2762877..238f923 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -5,8 +5,9 @@ struct winsize;
 
 void get_term_dimensions(struct winsize *ws);
 
+#include <asm/unistd.h>
+
 #if defined(__i386__)
-#include "../../arch/x86/include/asm/unistd.h"
 #define rmb()		asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
 #define cpu_relax()	asm volatile("rep; nop" ::: "memory");
 #define CPUINFO_PROC	"model name"
@@ -16,7 +17,6 @@ void get_term_dimensions(struct winsize *ws);
 #endif
 
 #if defined(__x86_64__)
-#include "../../arch/x86/include/asm/unistd.h"
 #define rmb()		asm volatile("lfence" ::: "memory")
 #define cpu_relax()	asm volatile("rep; nop" ::: "memory");
 #define CPUINFO_PROC	"model name"
@@ -26,20 +26,17 @@ void get_term_dimensions(struct winsize *ws);
 #endif
 
 #ifdef __powerpc__
-#include "../../arch/powerpc/include/asm/unistd.h"
 #define rmb()		asm volatile ("sync" ::: "memory")
 #define cpu_relax()	asm volatile ("" ::: "memory");
 #define CPUINFO_PROC	"cpu"
 #endif
 
 #ifdef __s390__
-#include "../../arch/s390/include/asm/unistd.h"
 #define rmb()		asm volatile("bcr 15,0" ::: "memory")
 #define cpu_relax()	asm volatile("" ::: "memory");
 #endif
 
 #ifdef __sh__
-#include "../../arch/sh/include/asm/unistd.h"
 #if defined(__SH4A__) || defined(__SH5__)
 # define rmb()		asm volatile("synco" ::: "memory")
 #else
@@ -50,35 +47,30 @@ void get_term_dimensions(struct winsize *ws);
 #endif
 
 #ifdef __hppa__
-#include "../../arch/parisc/include/asm/unistd.h"
 #define rmb()		asm volatile("" ::: "memory")
 #define cpu_relax()	asm volatile("" ::: "memory");
 #define CPUINFO_PROC	"cpu"
 #endif
 
 #ifdef __sparc__
-#include "../../arch/sparc/include/asm/unistd.h"
 #define rmb()		asm volatile("":::"memory")
 #define cpu_relax()	asm volatile("":::"memory")
 #define CPUINFO_PROC	"cpu"
 #endif
 
 #ifdef __alpha__
-#include "../../arch/alpha/include/asm/unistd.h"
 #define rmb()		asm volatile("mb" ::: "memory")
 #define cpu_relax()	asm volatile("" ::: "memory")
 #define CPUINFO_PROC	"cpu model"
 #endif
 
 #ifdef __ia64__
-#include "../../arch/ia64/include/asm/unistd.h"
 #define rmb()		asm volatile ("mf" ::: "memory")
 #define cpu_relax()	asm volatile ("hint @pause" ::: "memory")
 #define CPUINFO_PROC	"model name"
 #endif
 
 #ifdef __arm__
-#include "../../arch/arm/include/asm/unistd.h"
 /*
  * Use the __kuser_memory_barrier helper in the CPU helper page. See
  * arch/arm/kernel/entry-armv.S in the kernel source for details.
@@ -89,13 +81,11 @@ void get_term_dimensions(struct winsize *ws);
 #endif
 
 #ifdef __aarch64__
-#include "../../arch/arm64/include/asm/unistd.h"
 #define rmb()		asm volatile("dmb ld" ::: "memory")
 #define cpu_relax()	asm volatile("yield" ::: "memory")
 #endif
 
 #ifdef __mips__
-#include "../../arch/mips/include/asm/unistd.h"
 #define rmb()		asm volatile(					\
 				".set	mips2\n\t"			\
 				"sync\n\t"				\
@@ -112,7 +102,7 @@ void get_term_dimensions(struct winsize *ws);
 #include <sys/types.h>
 #include <sys/syscall.h>
 
-#include "../../include/uapi/linux/perf_event.h"
+#include <linux/perf_event.h>
 #include "util/types.h"
 #include <stdbool.h>
 


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/5] x86: Disintegrate asm/svm.h and asm/vmx.h to produce UAPI components for perf
  2012-10-19 16:55 [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration David Howells
                   ` (2 preceding siblings ...)
  2012-10-19 16:56 ` [PATCH 3/5] perf: Make perf build for x86 with UAPI disintegration applied David Howells
@ 2012-10-19 16:56 ` David Howells
  2012-10-19 16:56 ` [PATCH 5/5] x86: UAPI Disintegrate asm/perf_regs.h David Howells
  2012-10-24 18:43 ` [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration Arnaldo Carvalho de Melo
  5 siblings, 0 replies; 13+ messages in thread
From: David Howells @ 2012-10-19 16:56 UTC (permalink / raw)
  To: mingo, tglx, acme
  Cc: dhowells, davem, torvalds, paulus, linux-arch, linux-kernel, x86

Disintegrate asm/svm.h and asm/vmx.h to produce UAPI components for perf to
use:

 (1) The bits outside of the __KERNEL__ guards are moved to an equivalently
     named header under arch/x86/include/uapi/.

 (2) #includes are placed into the remnant files to include the UAPI files.

 (3) The __KERNEL__ guards are erased.

After this, perf no longer needs the -Iarch/foo/include flag and can just
manage with the uapi -I flags.

If these actually want posting to userspace, then they will need a headers-y
line adding to the uapi Kbuild file.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 arch/x86/include/asm/svm.h      |  133 +--------------------------------------
 arch/x86/include/asm/vmx.h      |   87 +-------------------------
 arch/x86/include/uapi/asm/svm.h |  131 ++++++++++++++++++++++++++++++++++++++
 arch/x86/include/uapi/asm/vmx.h |  108 ++++++++++++++++++++++++++++++++
 tools/perf/Makefile             |    1 
 5 files changed, 243 insertions(+), 217 deletions(-)
 create mode 100644 arch/x86/include/uapi/asm/svm.h
 create mode 100644 arch/x86/include/uapi/asm/vmx.h

diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h
index cdf5674..a986059 100644
--- a/arch/x86/include/asm/svm.h
+++ b/arch/x86/include/asm/svm.h
@@ -1,134 +1,7 @@
 #ifndef __SVM_H
 #define __SVM_H
 
-#define SVM_EXIT_READ_CR0      0x000
-#define SVM_EXIT_READ_CR3      0x003
-#define SVM_EXIT_READ_CR4      0x004
-#define SVM_EXIT_READ_CR8      0x008
-#define SVM_EXIT_WRITE_CR0     0x010
-#define SVM_EXIT_WRITE_CR3     0x013
-#define SVM_EXIT_WRITE_CR4     0x014
-#define SVM_EXIT_WRITE_CR8     0x018
-#define SVM_EXIT_READ_DR0      0x020
-#define SVM_EXIT_READ_DR1      0x021
-#define SVM_EXIT_READ_DR2      0x022
-#define SVM_EXIT_READ_DR3      0x023
-#define SVM_EXIT_READ_DR4      0x024
-#define SVM_EXIT_READ_DR5      0x025
-#define SVM_EXIT_READ_DR6      0x026
-#define SVM_EXIT_READ_DR7      0x027
-#define SVM_EXIT_WRITE_DR0     0x030
-#define SVM_EXIT_WRITE_DR1     0x031
-#define SVM_EXIT_WRITE_DR2     0x032
-#define SVM_EXIT_WRITE_DR3     0x033
-#define SVM_EXIT_WRITE_DR4     0x034
-#define SVM_EXIT_WRITE_DR5     0x035
-#define SVM_EXIT_WRITE_DR6     0x036
-#define SVM_EXIT_WRITE_DR7     0x037
-#define SVM_EXIT_EXCP_BASE     0x040
-#define SVM_EXIT_INTR          0x060
-#define SVM_EXIT_NMI           0x061
-#define SVM_EXIT_SMI           0x062
-#define SVM_EXIT_INIT          0x063
-#define SVM_EXIT_VINTR         0x064
-#define SVM_EXIT_CR0_SEL_WRITE 0x065
-#define SVM_EXIT_IDTR_READ     0x066
-#define SVM_EXIT_GDTR_READ     0x067
-#define SVM_EXIT_LDTR_READ     0x068
-#define SVM_EXIT_TR_READ       0x069
-#define SVM_EXIT_IDTR_WRITE    0x06a
-#define SVM_EXIT_GDTR_WRITE    0x06b
-#define SVM_EXIT_LDTR_WRITE    0x06c
-#define SVM_EXIT_TR_WRITE      0x06d
-#define SVM_EXIT_RDTSC         0x06e
-#define SVM_EXIT_RDPMC         0x06f
-#define SVM_EXIT_PUSHF         0x070
-#define SVM_EXIT_POPF          0x071
-#define SVM_EXIT_CPUID         0x072
-#define SVM_EXIT_RSM           0x073
-#define SVM_EXIT_IRET          0x074
-#define SVM_EXIT_SWINT         0x075
-#define SVM_EXIT_INVD          0x076
-#define SVM_EXIT_PAUSE         0x077
-#define SVM_EXIT_HLT           0x078
-#define SVM_EXIT_INVLPG        0x079
-#define SVM_EXIT_INVLPGA       0x07a
-#define SVM_EXIT_IOIO          0x07b
-#define SVM_EXIT_MSR           0x07c
-#define SVM_EXIT_TASK_SWITCH   0x07d
-#define SVM_EXIT_FERR_FREEZE   0x07e
-#define SVM_EXIT_SHUTDOWN      0x07f
-#define SVM_EXIT_VMRUN         0x080
-#define SVM_EXIT_VMMCALL       0x081
-#define SVM_EXIT_VMLOAD        0x082
-#define SVM_EXIT_VMSAVE        0x083
-#define SVM_EXIT_STGI          0x084
-#define SVM_EXIT_CLGI          0x085
-#define SVM_EXIT_SKINIT        0x086
-#define SVM_EXIT_RDTSCP        0x087
-#define SVM_EXIT_ICEBP         0x088
-#define SVM_EXIT_WBINVD        0x089
-#define SVM_EXIT_MONITOR       0x08a
-#define SVM_EXIT_MWAIT         0x08b
-#define SVM_EXIT_MWAIT_COND    0x08c
-#define SVM_EXIT_XSETBV        0x08d
-#define SVM_EXIT_NPF           0x400
-
-#define SVM_EXIT_ERR           -1
-
-#define SVM_EXIT_REASONS \
-	{ SVM_EXIT_READ_CR0,    "read_cr0" }, \
-	{ SVM_EXIT_READ_CR3,    "read_cr3" }, \
-	{ SVM_EXIT_READ_CR4,    "read_cr4" }, \
-	{ SVM_EXIT_READ_CR8,    "read_cr8" }, \
-	{ SVM_EXIT_WRITE_CR0,   "write_cr0" }, \
-	{ SVM_EXIT_WRITE_CR3,   "write_cr3" }, \
-	{ SVM_EXIT_WRITE_CR4,   "write_cr4" }, \
-	{ SVM_EXIT_WRITE_CR8,   "write_cr8" }, \
-	{ SVM_EXIT_READ_DR0,    "read_dr0" }, \
-	{ SVM_EXIT_READ_DR1,    "read_dr1" }, \
-	{ SVM_EXIT_READ_DR2,    "read_dr2" }, \
-	{ SVM_EXIT_READ_DR3,    "read_dr3" }, \
-	{ SVM_EXIT_WRITE_DR0,   "write_dr0" }, \
-	{ SVM_EXIT_WRITE_DR1,   "write_dr1" }, \
-	{ SVM_EXIT_WRITE_DR2,   "write_dr2" }, \
-	{ SVM_EXIT_WRITE_DR3,   "write_dr3" }, \
-	{ SVM_EXIT_WRITE_DR5,   "write_dr5" }, \
-	{ SVM_EXIT_WRITE_DR7,   "write_dr7" }, \
-	{ SVM_EXIT_EXCP_BASE + DB_VECTOR,       "DB excp" }, \
-	{ SVM_EXIT_EXCP_BASE + BP_VECTOR,       "BP excp" }, \
-	{ SVM_EXIT_EXCP_BASE + UD_VECTOR,       "UD excp" }, \
-	{ SVM_EXIT_EXCP_BASE + PF_VECTOR,       "PF excp" }, \
-	{ SVM_EXIT_EXCP_BASE + NM_VECTOR,       "NM excp" }, \
-	{ SVM_EXIT_EXCP_BASE + MC_VECTOR,       "MC excp" }, \
-	{ SVM_EXIT_INTR,        "interrupt" }, \
-	{ SVM_EXIT_NMI,         "nmi" }, \
-	{ SVM_EXIT_SMI,         "smi" }, \
-	{ SVM_EXIT_INIT,        "init" }, \
-	{ SVM_EXIT_VINTR,       "vintr" }, \
-	{ SVM_EXIT_CPUID,       "cpuid" }, \
-	{ SVM_EXIT_INVD,        "invd" }, \
-	{ SVM_EXIT_HLT,         "hlt" }, \
-	{ SVM_EXIT_INVLPG,      "invlpg" }, \
-	{ SVM_EXIT_INVLPGA,     "invlpga" }, \
-	{ SVM_EXIT_IOIO,        "io" }, \
-	{ SVM_EXIT_MSR,         "msr" }, \
-	{ SVM_EXIT_TASK_SWITCH, "task_switch" }, \
-	{ SVM_EXIT_SHUTDOWN,    "shutdown" }, \
-	{ SVM_EXIT_VMRUN,       "vmrun" }, \
-	{ SVM_EXIT_VMMCALL,     "hypercall" }, \
-	{ SVM_EXIT_VMLOAD,      "vmload" }, \
-	{ SVM_EXIT_VMSAVE,      "vmsave" }, \
-	{ SVM_EXIT_STGI,        "stgi" }, \
-	{ SVM_EXIT_CLGI,        "clgi" }, \
-	{ SVM_EXIT_SKINIT,      "skinit" }, \
-	{ SVM_EXIT_WBINVD,      "wbinvd" }, \
-	{ SVM_EXIT_MONITOR,     "monitor" }, \
-	{ SVM_EXIT_MWAIT,       "mwait" }, \
-	{ SVM_EXIT_XSETBV,      "xsetbv" }, \
-	{ SVM_EXIT_NPF,         "npf" }
-
-#ifdef __KERNEL__
+#include <uapi/asm/svm.h>
 
 enum {
 	INTERCEPT_INTR,
@@ -402,6 +275,4 @@ struct __attribute__ ((__packed__)) vmcb {
 #define SVM_STGI   ".byte 0x0f, 0x01, 0xdc"
 #define SVM_INVLPGA ".byte 0x0f, 0x01, 0xdf"
 
-#endif
-
-#endif
+#endif /* __SVM_H */
diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index 36ec21c..f0dff1b 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -25,88 +25,7 @@
  *
  */
 
-#define VMX_EXIT_REASONS_FAILED_VMENTRY         0x80000000
-
-#define EXIT_REASON_EXCEPTION_NMI       0
-#define EXIT_REASON_EXTERNAL_INTERRUPT  1
-#define EXIT_REASON_TRIPLE_FAULT        2
-
-#define EXIT_REASON_PENDING_INTERRUPT   7
-#define EXIT_REASON_NMI_WINDOW          8
-#define EXIT_REASON_TASK_SWITCH         9
-#define EXIT_REASON_CPUID               10
-#define EXIT_REASON_HLT                 12
-#define EXIT_REASON_INVD                13
-#define EXIT_REASON_INVLPG              14
-#define EXIT_REASON_RDPMC               15
-#define EXIT_REASON_RDTSC               16
-#define EXIT_REASON_VMCALL              18
-#define EXIT_REASON_VMCLEAR             19
-#define EXIT_REASON_VMLAUNCH            20
-#define EXIT_REASON_VMPTRLD             21
-#define EXIT_REASON_VMPTRST             22
-#define EXIT_REASON_VMREAD              23
-#define EXIT_REASON_VMRESUME            24
-#define EXIT_REASON_VMWRITE             25
-#define EXIT_REASON_VMOFF               26
-#define EXIT_REASON_VMON                27
-#define EXIT_REASON_CR_ACCESS           28
-#define EXIT_REASON_DR_ACCESS           29
-#define EXIT_REASON_IO_INSTRUCTION      30
-#define EXIT_REASON_MSR_READ            31
-#define EXIT_REASON_MSR_WRITE           32
-#define EXIT_REASON_INVALID_STATE       33
-#define EXIT_REASON_MWAIT_INSTRUCTION   36
-#define EXIT_REASON_MONITOR_INSTRUCTION 39
-#define EXIT_REASON_PAUSE_INSTRUCTION   40
-#define EXIT_REASON_MCE_DURING_VMENTRY  41
-#define EXIT_REASON_TPR_BELOW_THRESHOLD 43
-#define EXIT_REASON_APIC_ACCESS         44
-#define EXIT_REASON_EPT_VIOLATION       48
-#define EXIT_REASON_EPT_MISCONFIG       49
-#define EXIT_REASON_WBINVD              54
-#define EXIT_REASON_XSETBV              55
-#define EXIT_REASON_INVPCID             58
-
-#define VMX_EXIT_REASONS \
-	{ EXIT_REASON_EXCEPTION_NMI,         "EXCEPTION_NMI" }, \
-	{ EXIT_REASON_EXTERNAL_INTERRUPT,    "EXTERNAL_INTERRUPT" }, \
-	{ EXIT_REASON_TRIPLE_FAULT,          "TRIPLE_FAULT" }, \
-	{ EXIT_REASON_PENDING_INTERRUPT,     "PENDING_INTERRUPT" }, \
-	{ EXIT_REASON_NMI_WINDOW,            "NMI_WINDOW" }, \
-	{ EXIT_REASON_TASK_SWITCH,           "TASK_SWITCH" }, \
-	{ EXIT_REASON_CPUID,                 "CPUID" }, \
-	{ EXIT_REASON_HLT,                   "HLT" }, \
-	{ EXIT_REASON_INVLPG,                "INVLPG" }, \
-	{ EXIT_REASON_RDPMC,                 "RDPMC" }, \
-	{ EXIT_REASON_RDTSC,                 "RDTSC" }, \
-	{ EXIT_REASON_VMCALL,                "VMCALL" }, \
-	{ EXIT_REASON_VMCLEAR,               "VMCLEAR" }, \
-	{ EXIT_REASON_VMLAUNCH,              "VMLAUNCH" }, \
-	{ EXIT_REASON_VMPTRLD,               "VMPTRLD" }, \
-	{ EXIT_REASON_VMPTRST,               "VMPTRST" }, \
-	{ EXIT_REASON_VMREAD,                "VMREAD" }, \
-	{ EXIT_REASON_VMRESUME,              "VMRESUME" }, \
-	{ EXIT_REASON_VMWRITE,               "VMWRITE" }, \
-	{ EXIT_REASON_VMOFF,                 "VMOFF" }, \
-	{ EXIT_REASON_VMON,                  "VMON" }, \
-	{ EXIT_REASON_CR_ACCESS,             "CR_ACCESS" }, \
-	{ EXIT_REASON_DR_ACCESS,             "DR_ACCESS" }, \
-	{ EXIT_REASON_IO_INSTRUCTION,        "IO_INSTRUCTION" }, \
-	{ EXIT_REASON_MSR_READ,              "MSR_READ" }, \
-	{ EXIT_REASON_MSR_WRITE,             "MSR_WRITE" }, \
-	{ EXIT_REASON_MWAIT_INSTRUCTION,     "MWAIT_INSTRUCTION" }, \
-	{ EXIT_REASON_MONITOR_INSTRUCTION,   "MONITOR_INSTRUCTION" }, \
-	{ EXIT_REASON_PAUSE_INSTRUCTION,     "PAUSE_INSTRUCTION" }, \
-	{ EXIT_REASON_MCE_DURING_VMENTRY,    "MCE_DURING_VMENTRY" }, \
-	{ EXIT_REASON_TPR_BELOW_THRESHOLD,   "TPR_BELOW_THRESHOLD" }, \
-	{ EXIT_REASON_APIC_ACCESS,           "APIC_ACCESS" }, \
-	{ EXIT_REASON_EPT_VIOLATION,         "EPT_VIOLATION" }, \
-	{ EXIT_REASON_EPT_MISCONFIG,         "EPT_MISCONFIG" }, \
-	{ EXIT_REASON_WBINVD,                "WBINVD" }
-
-#ifdef __KERNEL__
-
+#include <uapi/asm/vmx.h>
 #include <linux/types.h>
 
 /*
@@ -526,6 +445,4 @@ enum vm_instruction_error_number {
 	VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID = 28,
 };
 
-#endif
-
-#endif
+#endif /* VMX_H */
diff --git a/arch/x86/include/uapi/asm/svm.h b/arch/x86/include/uapi/asm/svm.h
new file mode 100644
index 0000000..0e58fcf
--- /dev/null
+++ b/arch/x86/include/uapi/asm/svm.h
@@ -0,0 +1,131 @@
+#ifndef _UAPI_ASM_SVM_H
+#define _UAPI_ASM_SVM_H
+
+#define SVM_EXIT_READ_CR0      0x000
+#define SVM_EXIT_READ_CR3      0x003
+#define SVM_EXIT_READ_CR4      0x004
+#define SVM_EXIT_READ_CR8      0x008
+#define SVM_EXIT_WRITE_CR0     0x010
+#define SVM_EXIT_WRITE_CR3     0x013
+#define SVM_EXIT_WRITE_CR4     0x014
+#define SVM_EXIT_WRITE_CR8     0x018
+#define SVM_EXIT_READ_DR0      0x020
+#define SVM_EXIT_READ_DR1      0x021
+#define SVM_EXIT_READ_DR2      0x022
+#define SVM_EXIT_READ_DR3      0x023
+#define SVM_EXIT_READ_DR4      0x024
+#define SVM_EXIT_READ_DR5      0x025
+#define SVM_EXIT_READ_DR6      0x026
+#define SVM_EXIT_READ_DR7      0x027
+#define SVM_EXIT_WRITE_DR0     0x030
+#define SVM_EXIT_WRITE_DR1     0x031
+#define SVM_EXIT_WRITE_DR2     0x032
+#define SVM_EXIT_WRITE_DR3     0x033
+#define SVM_EXIT_WRITE_DR4     0x034
+#define SVM_EXIT_WRITE_DR5     0x035
+#define SVM_EXIT_WRITE_DR6     0x036
+#define SVM_EXIT_WRITE_DR7     0x037
+#define SVM_EXIT_EXCP_BASE     0x040
+#define SVM_EXIT_INTR          0x060
+#define SVM_EXIT_NMI           0x061
+#define SVM_EXIT_SMI           0x062
+#define SVM_EXIT_INIT          0x063
+#define SVM_EXIT_VINTR         0x064
+#define SVM_EXIT_CR0_SEL_WRITE 0x065
+#define SVM_EXIT_IDTR_READ     0x066
+#define SVM_EXIT_GDTR_READ     0x067
+#define SVM_EXIT_LDTR_READ     0x068
+#define SVM_EXIT_TR_READ       0x069
+#define SVM_EXIT_IDTR_WRITE    0x06a
+#define SVM_EXIT_GDTR_WRITE    0x06b
+#define SVM_EXIT_LDTR_WRITE    0x06c
+#define SVM_EXIT_TR_WRITE      0x06d
+#define SVM_EXIT_RDTSC         0x06e
+#define SVM_EXIT_RDPMC         0x06f
+#define SVM_EXIT_PUSHF         0x070
+#define SVM_EXIT_POPF          0x071
+#define SVM_EXIT_CPUID         0x072
+#define SVM_EXIT_RSM           0x073
+#define SVM_EXIT_IRET          0x074
+#define SVM_EXIT_SWINT         0x075
+#define SVM_EXIT_INVD          0x076
+#define SVM_EXIT_PAUSE         0x077
+#define SVM_EXIT_HLT           0x078
+#define SVM_EXIT_INVLPG        0x079
+#define SVM_EXIT_INVLPGA       0x07a
+#define SVM_EXIT_IOIO          0x07b
+#define SVM_EXIT_MSR           0x07c
+#define SVM_EXIT_TASK_SWITCH   0x07d
+#define SVM_EXIT_FERR_FREEZE   0x07e
+#define SVM_EXIT_SHUTDOWN      0x07f
+#define SVM_EXIT_VMRUN         0x080
+#define SVM_EXIT_VMMCALL       0x081
+#define SVM_EXIT_VMLOAD        0x082
+#define SVM_EXIT_VMSAVE        0x083
+#define SVM_EXIT_STGI          0x084
+#define SVM_EXIT_CLGI          0x085
+#define SVM_EXIT_SKINIT        0x086
+#define SVM_EXIT_RDTSCP        0x087
+#define SVM_EXIT_ICEBP         0x088
+#define SVM_EXIT_WBINVD        0x089
+#define SVM_EXIT_MONITOR       0x08a
+#define SVM_EXIT_MWAIT         0x08b
+#define SVM_EXIT_MWAIT_COND    0x08c
+#define SVM_EXIT_XSETBV        0x08d
+#define SVM_EXIT_NPF           0x400
+
+#define SVM_EXIT_ERR           -1
+
+#define SVM_EXIT_REASONS \
+	{ SVM_EXIT_READ_CR0,    "read_cr0" }, \
+	{ SVM_EXIT_READ_CR3,    "read_cr3" }, \
+	{ SVM_EXIT_READ_CR4,    "read_cr4" }, \
+	{ SVM_EXIT_READ_CR8,    "read_cr8" }, \
+	{ SVM_EXIT_WRITE_CR0,   "write_cr0" }, \
+	{ SVM_EXIT_WRITE_CR3,   "write_cr3" }, \
+	{ SVM_EXIT_WRITE_CR4,   "write_cr4" }, \
+	{ SVM_EXIT_WRITE_CR8,   "write_cr8" }, \
+	{ SVM_EXIT_READ_DR0,    "read_dr0" }, \
+	{ SVM_EXIT_READ_DR1,    "read_dr1" }, \
+	{ SVM_EXIT_READ_DR2,    "read_dr2" }, \
+	{ SVM_EXIT_READ_DR3,    "read_dr3" }, \
+	{ SVM_EXIT_WRITE_DR0,   "write_dr0" }, \
+	{ SVM_EXIT_WRITE_DR1,   "write_dr1" }, \
+	{ SVM_EXIT_WRITE_DR2,   "write_dr2" }, \
+	{ SVM_EXIT_WRITE_DR3,   "write_dr3" }, \
+	{ SVM_EXIT_WRITE_DR5,   "write_dr5" }, \
+	{ SVM_EXIT_WRITE_DR7,   "write_dr7" }, \
+	{ SVM_EXIT_EXCP_BASE + DB_VECTOR,       "DB excp" }, \
+	{ SVM_EXIT_EXCP_BASE + BP_VECTOR,       "BP excp" }, \
+	{ SVM_EXIT_EXCP_BASE + UD_VECTOR,       "UD excp" }, \
+	{ SVM_EXIT_EXCP_BASE + PF_VECTOR,       "PF excp" }, \
+	{ SVM_EXIT_EXCP_BASE + NM_VECTOR,       "NM excp" }, \
+	{ SVM_EXIT_EXCP_BASE + MC_VECTOR,       "MC excp" }, \
+	{ SVM_EXIT_INTR,        "interrupt" }, \
+	{ SVM_EXIT_NMI,         "nmi" }, \
+	{ SVM_EXIT_SMI,         "smi" }, \
+	{ SVM_EXIT_INIT,        "init" }, \
+	{ SVM_EXIT_VINTR,       "vintr" }, \
+	{ SVM_EXIT_CPUID,       "cpuid" }, \
+	{ SVM_EXIT_INVD,        "invd" }, \
+	{ SVM_EXIT_HLT,         "hlt" }, \
+	{ SVM_EXIT_INVLPG,      "invlpg" }, \
+	{ SVM_EXIT_INVLPGA,     "invlpga" }, \
+	{ SVM_EXIT_IOIO,        "io" }, \
+	{ SVM_EXIT_MSR,         "msr" }, \
+	{ SVM_EXIT_TASK_SWITCH, "task_switch" }, \
+	{ SVM_EXIT_SHUTDOWN,    "shutdown" }, \
+	{ SVM_EXIT_VMRUN,       "vmrun" }, \
+	{ SVM_EXIT_VMMCALL,     "hypercall" }, \
+	{ SVM_EXIT_VMLOAD,      "vmload" }, \
+	{ SVM_EXIT_VMSAVE,      "vmsave" }, \
+	{ SVM_EXIT_STGI,        "stgi" }, \
+	{ SVM_EXIT_CLGI,        "clgi" }, \
+	{ SVM_EXIT_SKINIT,      "skinit" }, \
+	{ SVM_EXIT_WBINVD,      "wbinvd" }, \
+	{ SVM_EXIT_MONITOR,     "monitor" }, \
+	{ SVM_EXIT_MWAIT,       "mwait" }, \
+	{ SVM_EXIT_XSETBV,      "xsetbv" }, \
+	{ SVM_EXIT_NPF,         "npf" }
+
+#endif /* _UAPI_ASM_SVM_H */
diff --git a/arch/x86/include/uapi/asm/vmx.h b/arch/x86/include/uapi/asm/vmx.h
new file mode 100644
index 0000000..501097a
--- /dev/null
+++ b/arch/x86/include/uapi/asm/vmx.h
@@ -0,0 +1,108 @@
+/*
+ * vmx.h: VMX Architecture related definitions
+ * Copyright (c) 2004, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * A few random additions are:
+ * Copyright (C) 2006 Qumranet
+ *    Avi Kivity <avi@qumranet.com>
+ *    Yaniv Kamay <yaniv@qumranet.com>
+ *
+ */
+
+#ifndef _UAPI_ASM_VMX_H
+#define _UAPI_ASM_VMX_H
+
+#define VMX_EXIT_REASONS_FAILED_VMENTRY         0x80000000
+
+#define EXIT_REASON_EXCEPTION_NMI       0
+#define EXIT_REASON_EXTERNAL_INTERRUPT  1
+#define EXIT_REASON_TRIPLE_FAULT        2
+
+#define EXIT_REASON_PENDING_INTERRUPT   7
+#define EXIT_REASON_NMI_WINDOW          8
+#define EXIT_REASON_TASK_SWITCH         9
+#define EXIT_REASON_CPUID               10
+#define EXIT_REASON_HLT                 12
+#define EXIT_REASON_INVD                13
+#define EXIT_REASON_INVLPG              14
+#define EXIT_REASON_RDPMC               15
+#define EXIT_REASON_RDTSC               16
+#define EXIT_REASON_VMCALL              18
+#define EXIT_REASON_VMCLEAR             19
+#define EXIT_REASON_VMLAUNCH            20
+#define EXIT_REASON_VMPTRLD             21
+#define EXIT_REASON_VMPTRST             22
+#define EXIT_REASON_VMREAD              23
+#define EXIT_REASON_VMRESUME            24
+#define EXIT_REASON_VMWRITE             25
+#define EXIT_REASON_VMOFF               26
+#define EXIT_REASON_VMON                27
+#define EXIT_REASON_CR_ACCESS           28
+#define EXIT_REASON_DR_ACCESS           29
+#define EXIT_REASON_IO_INSTRUCTION      30
+#define EXIT_REASON_MSR_READ            31
+#define EXIT_REASON_MSR_WRITE           32
+#define EXIT_REASON_INVALID_STATE       33
+#define EXIT_REASON_MWAIT_INSTRUCTION   36
+#define EXIT_REASON_MONITOR_INSTRUCTION 39
+#define EXIT_REASON_PAUSE_INSTRUCTION   40
+#define EXIT_REASON_MCE_DURING_VMENTRY  41
+#define EXIT_REASON_TPR_BELOW_THRESHOLD 43
+#define EXIT_REASON_APIC_ACCESS         44
+#define EXIT_REASON_EPT_VIOLATION       48
+#define EXIT_REASON_EPT_MISCONFIG       49
+#define EXIT_REASON_WBINVD              54
+#define EXIT_REASON_XSETBV              55
+#define EXIT_REASON_INVPCID             58
+
+#define VMX_EXIT_REASONS \
+	{ EXIT_REASON_EXCEPTION_NMI,         "EXCEPTION_NMI" }, \
+	{ EXIT_REASON_EXTERNAL_INTERRUPT,    "EXTERNAL_INTERRUPT" }, \
+	{ EXIT_REASON_TRIPLE_FAULT,          "TRIPLE_FAULT" }, \
+	{ EXIT_REASON_PENDING_INTERRUPT,     "PENDING_INTERRUPT" }, \
+	{ EXIT_REASON_NMI_WINDOW,            "NMI_WINDOW" }, \
+	{ EXIT_REASON_TASK_SWITCH,           "TASK_SWITCH" }, \
+	{ EXIT_REASON_CPUID,                 "CPUID" }, \
+	{ EXIT_REASON_HLT,                   "HLT" }, \
+	{ EXIT_REASON_INVLPG,                "INVLPG" }, \
+	{ EXIT_REASON_RDPMC,                 "RDPMC" }, \
+	{ EXIT_REASON_RDTSC,                 "RDTSC" }, \
+	{ EXIT_REASON_VMCALL,                "VMCALL" }, \
+	{ EXIT_REASON_VMCLEAR,               "VMCLEAR" }, \
+	{ EXIT_REASON_VMLAUNCH,              "VMLAUNCH" }, \
+	{ EXIT_REASON_VMPTRLD,               "VMPTRLD" }, \
+	{ EXIT_REASON_VMPTRST,               "VMPTRST" }, \
+	{ EXIT_REASON_VMREAD,                "VMREAD" }, \
+	{ EXIT_REASON_VMRESUME,              "VMRESUME" }, \
+	{ EXIT_REASON_VMWRITE,               "VMWRITE" }, \
+	{ EXIT_REASON_VMOFF,                 "VMOFF" }, \
+	{ EXIT_REASON_VMON,                  "VMON" }, \
+	{ EXIT_REASON_CR_ACCESS,             "CR_ACCESS" }, \
+	{ EXIT_REASON_DR_ACCESS,             "DR_ACCESS" }, \
+	{ EXIT_REASON_IO_INSTRUCTION,        "IO_INSTRUCTION" }, \
+	{ EXIT_REASON_MSR_READ,              "MSR_READ" }, \
+	{ EXIT_REASON_MSR_WRITE,             "MSR_WRITE" }, \
+	{ EXIT_REASON_MWAIT_INSTRUCTION,     "MWAIT_INSTRUCTION" }, \
+	{ EXIT_REASON_MONITOR_INSTRUCTION,   "MONITOR_INSTRUCTION" }, \
+	{ EXIT_REASON_PAUSE_INSTRUCTION,     "PAUSE_INSTRUCTION" }, \
+	{ EXIT_REASON_MCE_DURING_VMENTRY,    "MCE_DURING_VMENTRY" }, \
+	{ EXIT_REASON_TPR_BELOW_THRESHOLD,   "TPR_BELOW_THRESHOLD" }, \
+	{ EXIT_REASON_APIC_ACCESS,           "APIC_ACCESS" }, \
+	{ EXIT_REASON_EPT_VIOLATION,         "EPT_VIOLATION" }, \
+	{ EXIT_REASON_EPT_MISCONFIG,         "EPT_MISCONFIG" }, \
+	{ EXIT_REASON_WBINVD,                "WBINVD" }
+
+#endif /* _UAPI_ASM_VMX_H */
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 9024a42..d998628 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -178,7 +178,6 @@ BASIC_CFLAGS = \
 	-Iarch/$(ARCH)/include \
 	-I$(objtree)/arch/$(ARCH)/include/generated/uapi \
 	-I$(srctree)/arch/$(ARCH)/include/uapi \
-	-I$(srctree)/arch/$(ARCH)/include \
 	-I$(objtree)/include/generated/uapi \
 	-I$(srctree)/include/uapi \
 	-I$(OUTPUT)util \


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 5/5] x86: UAPI Disintegrate asm/perf_regs.h
  2012-10-19 16:55 [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration David Howells
                   ` (3 preceding siblings ...)
  2012-10-19 16:56 ` [PATCH 4/5] x86: Disintegrate asm/svm.h and asm/vmx.h to produce UAPI components for perf David Howells
@ 2012-10-19 16:56 ` David Howells
  2012-10-24 18:43 ` [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration Arnaldo Carvalho de Melo
  5 siblings, 0 replies; 13+ messages in thread
From: David Howells @ 2012-10-19 16:56 UTC (permalink / raw)
  To: mingo, tglx, acme
  Cc: dhowells, davem, torvalds, paulus, linux-arch, linux-kernel, x86

Disintegrate x86's asm/perf_regs.h for UAPI.  This just entails moving it to
the uapi directory.

With this, the #inclusion in perf's perf_regs.h can use <asm/perf_regs.h>.

If this actually wants posting to userspace, then it will need a headers-y
line adding to the Kbuild file.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 arch/x86/include/asm/perf_regs.h        |   33 -------------------------------
 arch/x86/include/uapi/asm/perf_regs.h   |   33 +++++++++++++++++++++++++++++++
 tools/perf/arch/x86/include/perf_regs.h |    2 +-
 3 files changed, 34 insertions(+), 34 deletions(-)
 delete mode 100644 arch/x86/include/asm/perf_regs.h
 create mode 100644 arch/x86/include/uapi/asm/perf_regs.h

diff --git a/arch/x86/include/asm/perf_regs.h b/arch/x86/include/asm/perf_regs.h
deleted file mode 100644
index 3f2207b..0000000
--- a/arch/x86/include/asm/perf_regs.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef _ASM_X86_PERF_REGS_H
-#define _ASM_X86_PERF_REGS_H
-
-enum perf_event_x86_regs {
-	PERF_REG_X86_AX,
-	PERF_REG_X86_BX,
-	PERF_REG_X86_CX,
-	PERF_REG_X86_DX,
-	PERF_REG_X86_SI,
-	PERF_REG_X86_DI,
-	PERF_REG_X86_BP,
-	PERF_REG_X86_SP,
-	PERF_REG_X86_IP,
-	PERF_REG_X86_FLAGS,
-	PERF_REG_X86_CS,
-	PERF_REG_X86_SS,
-	PERF_REG_X86_DS,
-	PERF_REG_X86_ES,
-	PERF_REG_X86_FS,
-	PERF_REG_X86_GS,
-	PERF_REG_X86_R8,
-	PERF_REG_X86_R9,
-	PERF_REG_X86_R10,
-	PERF_REG_X86_R11,
-	PERF_REG_X86_R12,
-	PERF_REG_X86_R13,
-	PERF_REG_X86_R14,
-	PERF_REG_X86_R15,
-
-	PERF_REG_X86_32_MAX = PERF_REG_X86_GS + 1,
-	PERF_REG_X86_64_MAX = PERF_REG_X86_R15 + 1,
-};
-#endif /* _ASM_X86_PERF_REGS_H */
diff --git a/arch/x86/include/uapi/asm/perf_regs.h b/arch/x86/include/uapi/asm/perf_regs.h
new file mode 100644
index 0000000..3f2207b
--- /dev/null
+++ b/arch/x86/include/uapi/asm/perf_regs.h
@@ -0,0 +1,33 @@
+#ifndef _ASM_X86_PERF_REGS_H
+#define _ASM_X86_PERF_REGS_H
+
+enum perf_event_x86_regs {
+	PERF_REG_X86_AX,
+	PERF_REG_X86_BX,
+	PERF_REG_X86_CX,
+	PERF_REG_X86_DX,
+	PERF_REG_X86_SI,
+	PERF_REG_X86_DI,
+	PERF_REG_X86_BP,
+	PERF_REG_X86_SP,
+	PERF_REG_X86_IP,
+	PERF_REG_X86_FLAGS,
+	PERF_REG_X86_CS,
+	PERF_REG_X86_SS,
+	PERF_REG_X86_DS,
+	PERF_REG_X86_ES,
+	PERF_REG_X86_FS,
+	PERF_REG_X86_GS,
+	PERF_REG_X86_R8,
+	PERF_REG_X86_R9,
+	PERF_REG_X86_R10,
+	PERF_REG_X86_R11,
+	PERF_REG_X86_R12,
+	PERF_REG_X86_R13,
+	PERF_REG_X86_R14,
+	PERF_REG_X86_R15,
+
+	PERF_REG_X86_32_MAX = PERF_REG_X86_GS + 1,
+	PERF_REG_X86_64_MAX = PERF_REG_X86_R15 + 1,
+};
+#endif /* _ASM_X86_PERF_REGS_H */
diff --git a/tools/perf/arch/x86/include/perf_regs.h b/tools/perf/arch/x86/include/perf_regs.h
index 46fc9f1..7fcdcdb 100644
--- a/tools/perf/arch/x86/include/perf_regs.h
+++ b/tools/perf/arch/x86/include/perf_regs.h
@@ -3,7 +3,7 @@
 
 #include <stdlib.h>
 #include "../../util/types.h"
-#include "../../../../../arch/x86/include/asm/perf_regs.h"
+#include <asm/perf_regs.h>
 
 #ifndef ARCH_X86_64
 #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1)


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration
  2012-10-19 16:55 [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration David Howells
                   ` (4 preceding siblings ...)
  2012-10-19 16:56 ` [PATCH 5/5] x86: UAPI Disintegrate asm/perf_regs.h David Howells
@ 2012-10-24 18:43 ` Arnaldo Carvalho de Melo
  2012-10-24 19:46   ` Borislav Petkov
  2012-10-25  7:57   ` David Howells
  5 siblings, 2 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2012-10-24 18:43 UTC (permalink / raw)
  To: Borislav Petkov, Namhyung Kim
  Cc: David Howells, mingo, tglx, davem, torvalds, paulus, linux-arch,
	linux-kernel, x86

Em Fri, Oct 19, 2012 at 05:55:58PM +0100, David Howells escreveu:
> 
> Here are some potential fix ups for perf and other tools.  They need to be
> applied on top of the x86 UAPI disintegration patch.

Borislav, Namhyung, can you take a look at this series?

- Arnaldo
 
> There are five patches:
> 
>  (1) Use a makefile $(call ...) function in tools/Makefile to make it easier
>      to deal with.
> 
>      [NOTE!  I think the rule for selftests_install is wrong since it attempts
>       to discard '_clean' from the end of the target name instead of
>       '_install']
> 
>  (2) Fix handling of O= with a relative path when doing something like:
> 
> 	make tools/perf O=foo
> 
>      from the top-level directory in the kernel source tree for all tools.
> 
>  (3) Make perf work for x86 by adding -I flags and changing long #includes
>      with "../../include" in them into short <asm/foo.h> type things.
> 
> Now there are two patches that I'm not sure whether you want.  There are three
> header files with bits used by perf that are not in the UAPI.  If these are
> disintegrated then perf does not need to look in any KAPI headers at all and
> the -I flag pointing there can be dropped after the first of these patches.
> 
>  (4) UAPI disintegrate asm/svm.h and asm/vmx.h.
> 
>  (5) UAPI disintegrate asm/perf_regs.h and convert a "../../include" style
>      path into <asm/perf_regs.h>.
> 
> I'm not sure whether these should be exported to userspace, though this commit:
> 
> 	commit 26bf264e871a4b9a8ac09c21a2b518e7f23830d5
> 	Author: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
> 	Date:   Mon Sep 17 16:31:13 2012 +0800
> 	KVM: x86: Export svm/vmx exit code and vector code to userspace
> 
> suggests that at least the first two should be - though since it didn't modify
> Kbuild, this was not effective.
> 
> I haven't tried building perf for other arches at this time.
> 
> David
> ---
> David Howells (5):
>       x86: UAPI Disintegrate asm/perf_regs.h
>       x86: Disintegrate asm/svm.h and asm/vmx.h to produce UAPI components for perf
>       perf: Make perf build for x86 with UAPI disintegration applied
>       tools: Honour the O= flag when tool build called from a higher Makefile
>       tools: Define a Makefile function to do subdir processing
> 
> 
>  Makefile                                |    6 +
>  arch/x86/include/asm/perf_regs.h        |   33 --------
>  arch/x86/include/asm/svm.h              |  133 -------------------------------
>  arch/x86/include/asm/vmx.h              |   87 --------------------
>  arch/x86/include/uapi/asm/perf_regs.h   |   33 ++++++++
>  arch/x86/include/uapi/asm/svm.h         |  131 +++++++++++++++++++++++++++++++
>  arch/x86/include/uapi/asm/vmx.h         |  108 +++++++++++++++++++++++++
>  tools/Makefile                          |   24 +++---
>  tools/perf/Makefile                     |   15 +++
>  tools/perf/arch/x86/include/perf_regs.h |    2 
>  tools/perf/builtin-kvm.c                |    6 +
>  tools/perf/perf.h                       |   16 +---
>  tools/scripts/Makefile.include          |   18 ++++
>  13 files changed, 329 insertions(+), 283 deletions(-)
>  delete mode 100644 arch/x86/include/asm/perf_regs.h
>  create mode 100644 arch/x86/include/uapi/asm/perf_regs.h
>  create mode 100644 arch/x86/include/uapi/asm/svm.h
>  create mode 100644 arch/x86/include/uapi/asm/vmx.h

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration
  2012-10-24 18:43 ` [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration Arnaldo Carvalho de Melo
@ 2012-10-24 19:46   ` Borislav Petkov
  2012-10-25  7:57   ` David Howells
  1 sibling, 0 replies; 13+ messages in thread
From: Borislav Petkov @ 2012-10-24 19:46 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, David Howells, mingo, tglx, davem, torvalds,
	paulus, linux-arch, linux-kernel, x86

On Wed, Oct 24, 2012 at 11:43:37AM -0700, Arnaldo Carvalho de Melo wrote:
> Em Fri, Oct 19, 2012 at 05:55:58PM +0100, David Howells escreveu:
> > 
> > Here are some potential fix ups for perf and other tools.  They need to be
> > applied on top of the x86 UAPI disintegration patch.
> 
> Borislav, Namhyung, can you take a look at this series?

Sure.

David, where can get that x86 UAPI disintegration patch?

> 
> - Arnaldo
>  
> > There are five patches:
> > 
> >  (1) Use a makefile $(call ...) function in tools/Makefile to make it easier
> >      to deal with.
> > 
> >      [NOTE!  I think the rule for selftests_install is wrong since it attempts
> >       to discard '_clean' from the end of the target name instead of
> >       '_install']

That's right, it should be "...testing/$(@:_install=)" instead. Good catch.

Thanks.

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration
  2012-10-24 18:43 ` [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration Arnaldo Carvalho de Melo
  2012-10-24 19:46   ` Borislav Petkov
@ 2012-10-25  7:57   ` David Howells
  2012-10-26  4:33     ` Namhyung Kim
  1 sibling, 1 reply; 13+ messages in thread
From: David Howells @ 2012-10-25  7:57 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: dhowells, Arnaldo Carvalho de Melo, Namhyung Kim, mingo, tglx,
	davem, torvalds, paulus, linux-arch, linux-kernel, x86

Borislav Petkov <bp@alien8.de> wrote:

> David, where can get that x86 UAPI disintegration patch?

The tip tree has it in branch x86/uapi or you can get it from:

	git://git.infradead.org/users/dhowells/linux-headers.git

branch disintegrate-x86 or tag disintegrate-x86-20121009.

I've posted a couple of additional patches to deal with files that became
empty, but they're only for dealing with people who construct their kernel
sources with the patch program.

David

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration
  2012-10-25  7:57   ` David Howells
@ 2012-10-26  4:33     ` Namhyung Kim
  2012-10-26  6:04       ` Namhyung Kim
  0 siblings, 1 reply; 13+ messages in thread
From: Namhyung Kim @ 2012-10-26  4:33 UTC (permalink / raw)
  To: David Howells
  Cc: Borislav Petkov, Arnaldo Carvalho de Melo, mingo, tglx, davem,
	torvalds, paulus, linux-arch, linux-kernel, x86

Hi David,

On Thu, 25 Oct 2012 08:57:20 +0100, David Howells wrote:
> Borislav Petkov <bp@alien8.de> wrote:
>
>> David, where can get that x86 UAPI disintegration patch?
>
> The tip tree has it in branch x86/uapi or you can get it from:
>
> 	git://git.infradead.org/users/dhowells/linux-headers.git
>
> branch disintegrate-x86 or tag disintegrate-x86-20121009.
>
> I've posted a couple of additional patches to deal with files that became
> empty, but they're only for dealing with people who construct their kernel
> sources with the patch program.

I applied this series on top of you disintegrate-x86 branch which has
following commit.

commit 8d2c63c2b664bae1fb0f386661ea5f635330e570
Author: David Howells <dhowells@redhat.com>
Date:   Tue Oct 9 09:47:54 2012 +0100

    UAPI: (Scripted) Disintegrate arch/x86/include/asm
    
    Signed-off-by: David Howells <dhowells@redhat.com>
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Acked-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Michael Kerrisk <mtk.manpages@gmail.com>
    Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
    Acked-by: Dave Jones <davej@redhat.com>


But I got a conflict like this:

--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@@ -112,7 -102,7 +102,11 @@@ void get_term_dimensions(struct winsiz
  #include <sys/types.h>
  #include <sys/syscall.h>
  
++<<<<<<< HEAD
 +#include "../../include/linux/perf_event.h"
++=======
+ #include <linux/perf_event.h>
++>>>>>>> perf: Make perf build for x86 with UAPI disintegration applied
  #include "util/types.h"
  #include <stdbool.h>

This was because your patch 3 has "uapi" between "include" and "linux".
It seems I need more patches to apply your series since there's no
perf_event.h under ../../include/uapi/linux directory.

Anyways, resolving the conflict resulted in build error:

    CC builtin-kvm.o
builtin-kvm.c:25:21: fatal error: asm/svm.h: No such file or directory
make: *** [builtin-kvm.o] Error 1

    CC util/evsel.o
In file included from util/perf_regs.h:5:0,
                 from util/evsel.c:23:
arch/x86/include/perf_regs.h:6:27: fatal error: asm/perf_regs.h: No such file or directory
make: *** [util/evsel.o] Error 1

    CC util/rbtree.o
../../lib/rbtree.c:24:36: fatal error: linux/rbtree_augmented.h: No such file or directory
make: *** [util/rbtree.o] Error 1

    CC util/header.o
util/header.c:2276:8: error: ‘PERF_ATTR_SIZE_VER3’ undeclared here (not in a function)
make: *** [util/header.o] Error 1


Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/5] tools: Honour the O= flag when tool build called from a higher Makefile
  2012-10-19 16:56 ` [PATCH 2/5] tools: Honour the O= flag when tool build called from a higher Makefile David Howells
@ 2012-10-26  5:34   ` Namhyung Kim
  0 siblings, 0 replies; 13+ messages in thread
From: Namhyung Kim @ 2012-10-26  5:34 UTC (permalink / raw)
  To: David Howells
  Cc: mingo, tglx, acme, davem, torvalds, paulus, linux-arch,
	linux-kernel, x86

On Fri, 19 Oct 2012 17:56:16 +0100, David Howells wrote:
> Honour the O= flag that was passed to a higher level Makefile and then passed
> down as part of a tool build.
>
> To make this work, the top-level Makefile passes the original O= flag and
> subdir=tools to the tools/Makefile, and that in turn passes
> subdir=$(O)/$(subdir)/foodir when building tool foo in directory
> $(O)/$(subdir)/foodir (where the intervening slashes aren't added if an
> element is missing).
>
> For example, take perf.  This is found in tools/perf/.  Assume we're building
> into directory ~/zebra/, so we pass O=~/zebra to make.  Dependening on where
> we run the build from, we see:
>
> 	make run in dir		$(OUTPUT) dir
> 	=======================	==================
> 	linux			~/zebra/tools/perf/
> 	linux/tools		~/zebra/perf/
> 	linux/tools/perf	~/zebra/
>
> and if O= is not set, we get:
>
> 	make run in dir		$(OUTPUT) dir
> 	=======================	==================
> 	linux			linux/tools/perf/
> 	linux/tools		linux/tools/perf/
> 	linux/tools/perf	linux/tools/perf/
>
> The output directories are created by the descend function if they don't
> already exist.

This is my test:

  namhyung@sejong:~$ cd project/linux
  namhyung@sejong:linux$ make O=~/build/zebra tools/perf
  /bin/sh: line 0: cd: /home/namhyung/build/zebra: No such file or directory
  Makefile:121: *** output directory "/home/namhyung/build/zebra" does not exist.  Stop.
  
  namhyung@sejong:tools$ mkdir ~/build/zebra
  namhyung@sejong:linux$ make O=~/build/zebra tools/perf
    HOSTCC  scripts/basic/fixdep
    GEN     /home/namhyung/build/zebra/Makefile
    HOSTCC  scripts/kconfig/conf.o
    HOSTCC  scripts/kconfig/zconf.tab.o
    HOSTLD  scripts/kconfig/conf
  scripts/kconfig/conf --silentoldconfig Kconfig
  ***
  *** Configuration file ".config" not found!
  ***
  *** Please run some configurator (e.g. "make oldconfig" or
  *** "make menuconfig" or "make xconfig").
  ***
  make[3]: *** [silentoldconfig] Error 1
  make[2]: *** [silentoldconfig] Error 2
      DESCEND perf
      MKDIR /home/namhyung/build/zebra/tools/perf/arch/
      MKDIR /home/namhyung/build/zebra/tools/perf/arch/x86/util/
      MKDIR /home/namhyung/build/zebra/tools/perf/bench/
      MKDIR /home/namhyung/build/zebra/tools/perf/scripts/perl/Perf-Trace-Util/
      MKDIR /home/namhyung/build/zebra/tools/perf/scripts/python/Perf-Trace-Util/
      MKDIR /home/namhyung/build/zebra/tools/perf/ui/
      MKDIR /home/namhyung/build/zebra/tools/perf/ui/browsers/
      MKDIR /home/namhyung/build/zebra/tools/perf/ui/gtk/
      MKDIR /home/namhyung/build/zebra/tools/perf/ui/stdio/
      MKDIR /home/namhyung/build/zebra/tools/perf/ui/tui/
      MKDIR /home/namhyung/build/zebra/tools/perf/util/
      MKDIR /home/namhyung/build/zebra/tools/perf/util/scripting-engines/
  PERF_VERSION = 3.7.rc2.1655.g54fa2b.dirty
      GEN /home/namhyung/build/zebra/tools/perf/common-cmds.h
      * new build flags or prefix
      CC /home/namhyung/build/zebra/tools/perf/perf.o
      ...

This looks ok but it'd be better if we can skip the config check when
building tools IMHO.


  namhyung@sejong:linux cd tools
  
  namhyung@sejong:tools$ make O=~/build/zebra perf
      DESCEND perf
      ...
      * new build flags or prefix
      CC /home/namhyung/build/zebra/perf.o
      ...

This looks not good as it doesn't build perf into
~/build/zebra/perf/perf.o.

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/5] perf: Make perf build for x86 with UAPI disintegration applied
  2012-10-19 16:56 ` [PATCH 3/5] perf: Make perf build for x86 with UAPI disintegration applied David Howells
@ 2012-10-26  5:49   ` Namhyung Kim
  0 siblings, 0 replies; 13+ messages in thread
From: Namhyung Kim @ 2012-10-26  5:49 UTC (permalink / raw)
  To: David Howells
  Cc: mingo, tglx, acme, davem, torvalds, paulus, linux-arch,
	linux-kernel, x86

On Fri, 19 Oct 2012 17:56:24 +0100, David Howells wrote:
> Make perf build for x86 once the UAPI disintegration patches for that arch
> have been applied by adding the appropriate -I flags - in the right order -
> and then converting some #includes that use ../.. notation to find main kernel
> headerfiles to use <asm/foo.h> and <linux/foo.h> instead.

Looks nice.

>
> Note that -Iarch/foo/include/uapi is present _before_ -Iarch/foo/include.
> This makes sure we get the userspace version of the pt_regs struct.  Ideally,
> we wouldn't have the latter -I flag at all, but unfortunately we want
> asm/svm.h and asm/vmx.h in buildin-kvm.c and these aren't part of the UAPI -
> at least not for x86.  I wonder if the bits outside of the __KERNEL__ guards
> *should* be transferred there.

What about asm/kvm.h?  Is it a part of the UAPI?

>
> I note also that perf seems to do its dependency handling manually by listing
> all the header files it might want to use in LIB_H in the Makefile.  Can this
> be changed to use -MD?

Yeah, that part could be improved, probably with -MMD.

>
> Signed-off-by: David Howells <dhowells@redhat.com>
> ---
>
>  tools/perf/Makefile      |   16 +++++++++++++++-
>  tools/perf/builtin-kvm.c |    6 +++---
>  tools/perf/perf.h        |   16 +++-------------
>  3 files changed, 21 insertions(+), 17 deletions(-)
>
> diff --git a/tools/perf/Makefile b/tools/perf/Makefile
> index f7c968a..9024a42 100644
> --- a/tools/perf/Makefile
> +++ b/tools/perf/Makefile
> @@ -169,7 +169,21 @@ endif
>  
>  ### --- END CONFIGURATION SECTION ---
>  
> -BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
> +ifeq ($(srctree),)
> +srctree := $(shell pwd)
> +endif

Isn't the srctree intended to point to kernel root?  Also you missed to
define the objtree which used below.

> +
> +BASIC_CFLAGS = \
> +	-Iutil/include \
> +	-Iarch/$(ARCH)/include \
> +	-I$(objtree)/arch/$(ARCH)/include/generated/uapi \
> +	-I$(srctree)/arch/$(ARCH)/include/uapi \
> +	-I$(srctree)/arch/$(ARCH)/include \
> +	-I$(objtree)/include/generated/uapi \
> +	-I$(srctree)/include/uapi \
> +	-I$(OUTPUT)util \
> +	-I$(TRACE_EVENT_DIR) \
> +	-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE

This isn't bad, but using '+=' looks more natural IMHO.

BASIC_CFLAGS  = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
BASIC_CFLAGS += -Iutil/include
BASIC_CFLAGS += -Iarch/$(ARCH)/include
...

>  BASIC_LDFLAGS =
>  
>  # Guard against environment variables
> diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
> index 260abc5..e013bdb 100644
> --- a/tools/perf/builtin-kvm.c
> +++ b/tools/perf/builtin-kvm.c
> @@ -22,9 +22,9 @@
>  #include <pthread.h>
>  #include <math.h>
>  
> -#include "../../arch/x86/include/asm/svm.h"
> -#include "../../arch/x86/include/asm/vmx.h"
> -#include "../../arch/x86/include/asm/kvm.h"
> +#include <asm/svm.h>
> +#include <asm/vmx.h>
> +#include <asm/kvm.h>
>  
>  struct event_key {
>  	#define INVALID_KEY     (~0ULL)
> diff --git a/tools/perf/perf.h b/tools/perf/perf.h
> index 2762877..238f923 100644
> --- a/tools/perf/perf.h
> +++ b/tools/perf/perf.h
> @@ -5,8 +5,9 @@ struct winsize;
>  
>  void get_term_dimensions(struct winsize *ws);
>  
> +#include <asm/unistd.h>
> +
>  #if defined(__i386__)
> -#include "../../arch/x86/include/asm/unistd.h"
>  #define rmb()		asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
>  #define cpu_relax()	asm volatile("rep; nop" ::: "memory");
>  #define CPUINFO_PROC	"model name"
> @@ -16,7 +17,6 @@ void get_term_dimensions(struct winsize *ws);
>  #endif
>  
>  #if defined(__x86_64__)
> -#include "../../arch/x86/include/asm/unistd.h"
>  #define rmb()		asm volatile("lfence" ::: "memory")
>  #define cpu_relax()	asm volatile("rep; nop" ::: "memory");
>  #define CPUINFO_PROC	"model name"
> @@ -26,20 +26,17 @@ void get_term_dimensions(struct winsize *ws);
>  #endif
>  
>  #ifdef __powerpc__
> -#include "../../arch/powerpc/include/asm/unistd.h"
>  #define rmb()		asm volatile ("sync" ::: "memory")
>  #define cpu_relax()	asm volatile ("" ::: "memory");
>  #define CPUINFO_PROC	"cpu"
>  #endif
>  
>  #ifdef __s390__
> -#include "../../arch/s390/include/asm/unistd.h"
>  #define rmb()		asm volatile("bcr 15,0" ::: "memory")
>  #define cpu_relax()	asm volatile("" ::: "memory");
>  #endif
>  
>  #ifdef __sh__
> -#include "../../arch/sh/include/asm/unistd.h"
>  #if defined(__SH4A__) || defined(__SH5__)
>  # define rmb()		asm volatile("synco" ::: "memory")
>  #else
> @@ -50,35 +47,30 @@ void get_term_dimensions(struct winsize *ws);
>  #endif
>  
>  #ifdef __hppa__
> -#include "../../arch/parisc/include/asm/unistd.h"
>  #define rmb()		asm volatile("" ::: "memory")
>  #define cpu_relax()	asm volatile("" ::: "memory");
>  #define CPUINFO_PROC	"cpu"
>  #endif
>  
>  #ifdef __sparc__
> -#include "../../arch/sparc/include/asm/unistd.h"

It might conflict with davem's sparc uapi patch which merged into tip:

commit 77626081849c9050b20670e5d832aca54c966936
Author: David Miller <davem@davemloft.net>
Date:   Wed Oct 17 01:06:56 2012 -0400

    perf tools: Fix build on sparc.
    
    More UAPI stuff.


>  #define rmb()		asm volatile("":::"memory")
>  #define cpu_relax()	asm volatile("":::"memory")
>  #define CPUINFO_PROC	"cpu"
>  #endif
>  
>  #ifdef __alpha__
> -#include "../../arch/alpha/include/asm/unistd.h"
>  #define rmb()		asm volatile("mb" ::: "memory")
>  #define cpu_relax()	asm volatile("" ::: "memory")
>  #define CPUINFO_PROC	"cpu model"
>  #endif
>  
>  #ifdef __ia64__
> -#include "../../arch/ia64/include/asm/unistd.h"
>  #define rmb()		asm volatile ("mf" ::: "memory")
>  #define cpu_relax()	asm volatile ("hint @pause" ::: "memory")
>  #define CPUINFO_PROC	"model name"
>  #endif
>  
>  #ifdef __arm__
> -#include "../../arch/arm/include/asm/unistd.h"
>  /*
>   * Use the __kuser_memory_barrier helper in the CPU helper page. See
>   * arch/arm/kernel/entry-armv.S in the kernel source for details.
> @@ -89,13 +81,11 @@ void get_term_dimensions(struct winsize *ws);
>  #endif
>  
>  #ifdef __aarch64__
> -#include "../../arch/arm64/include/asm/unistd.h"
>  #define rmb()		asm volatile("dmb ld" ::: "memory")
>  #define cpu_relax()	asm volatile("yield" ::: "memory")
>  #endif
>  
>  #ifdef __mips__
> -#include "../../arch/mips/include/asm/unistd.h"
>  #define rmb()		asm volatile(					\
>  				".set	mips2\n\t"			\
>  				"sync\n\t"				\
> @@ -112,7 +102,7 @@ void get_term_dimensions(struct winsize *ws);
>  #include <sys/types.h>
>  #include <sys/syscall.h>
>  
> -#include "../../include/uapi/linux/perf_event.h"

And I got a conflict here.

Thanks,
Namhyung


> +#include <linux/perf_event.h>
>  #include "util/types.h"
>  #include <stdbool.h>
>  

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration
  2012-10-26  4:33     ` Namhyung Kim
@ 2012-10-26  6:04       ` Namhyung Kim
  0 siblings, 0 replies; 13+ messages in thread
From: Namhyung Kim @ 2012-10-26  6:04 UTC (permalink / raw)
  To: David Howells
  Cc: Borislav Petkov, Arnaldo Carvalho de Melo, mingo, tglx, davem,
	torvalds, paulus, linux-arch, linux-kernel, x86

This time, I tried on tip/master since it seemed that it contains
related patches already.

At first I got a conflict with davem's change:

--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@@ -57,7 -53,6 +53,10 @@@ void get_term_dimensions(struct winsiz
  #endif
  
  #ifdef __sparc__
++<<<<<<< HEAD
 +#include "../../arch/sparc/include/uapi/asm/unistd.h"
++=======
++>>>>>>> perf: Make perf build for x86 with UAPI disintegration applied
  #define rmb()         asm volatile("":::"memory")
  #define cpu_relax()   asm volatile("":::"memory")
  #define CPUINFO_PROC  "cpu"


After resolving it, I got a tons of error mostly about redeclaration of
enum contants.  I managed to build perf with below patch:


------------ 8< ------------------- 8< -----------------
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index da040ff69b2b..7a73f37696b7 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -170,7 +170,11 @@ endif
 ### --- END CONFIGURATION SECTION ---
 
 ifeq ($(srctree),)
-srctree := $(shell pwd)
+srctree := $(shell cd ../../; pwd)
+endif
+
+ifeq ($(objtree),)
+objtree := $(shell cd ../../; pwd)
 endif
 
 BASIC_CFLAGS = \
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 618d41140abd..de882d5a4ab3 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -19,7 +19,6 @@
 #include "thread_map.h"
 #include "target.h"
 #include "../../../include/linux/hw_breakpoint.h"
-#include "../../../include/uapi/linux/perf_event.h"
 #include "perf_regs.h"
 
 #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 6f94d6dea00f..9ac02f655124 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -3,7 +3,7 @@
 
 #include <linux/list.h>
 #include <stdbool.h>
-#include "../../../include/uapi/linux/perf_event.h"
+#include <linux/perf_event.h>
 #include "types.h"
 #include "xyarray.h"
 #include "cgroup.h"
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 879d215cdac9..3c24404c8523 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -1,7 +1,7 @@
 #ifndef __PERF_HEADER_H
 #define __PERF_HEADER_H
 
-#include "../../../include/uapi/linux/perf_event.h"
+#include <linux/perf_event.h>
 #include <sys/types.h>
 #include <stdbool.h>
 #include "types.h"
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index ac9a6aacf2f5..146684787adb 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -7,7 +7,7 @@
 #include <linux/list.h>
 #include <stdbool.h>
 #include "types.h"
-#include "../../../include/uapi/linux/perf_event.h"
+#include <linux/perf_event.h>
 #include "types.h"
 
 struct list_head;
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 39f3abac7744..8410897cc856 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -2,7 +2,7 @@
 #define __PMU_H
 
 #include <linux/bitops.h>
-#include "../../../include/uapi/linux/perf_event.h"
+#include <linux/perf_event.h>
 
 enum {
 	PERF_PMU_FORMAT_VALUE_CONFIG,
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index dd6426163ba6..1768581bb4a6 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -7,7 +7,7 @@
 #include "symbol.h"
 #include "thread.h"
 #include <linux/rbtree.h>
-#include "../../../include/uapi/linux/perf_event.h"
+#include <linux/perf_event.h>
 
 struct sample_queue;
 struct ip_callchain;
------------ 8< ------------------- 8< -----------------

But it also failed to build like this:

    CC builtin-kvm.o
builtin-kvm.c:146:2: error: ‘DB_VECTOR’ undeclared here (not in a function)
builtin-kvm.c:146:2: error: ‘BP_VECTOR’ undeclared here (not in a function)
builtin-kvm.c:146:2: error: ‘UD_VECTOR’ undeclared here (not in a function)
builtin-kvm.c:146:2: error: ‘PF_VECTOR’ undeclared here (not in a function)
builtin-kvm.c:146:2: error: ‘NM_VECTOR’ undeclared here (not in a function)
builtin-kvm.c:146:2: error: ‘MC_VECTOR’ undeclared here (not in a function)
make: *** [builtin-kvm.o] Error 1


I can see that those are defined in arch/x86/include/asm/kvm.h.


Thanks,
Namhyung

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-10-26  6:04 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-19 16:55 [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration David Howells
2012-10-19 16:56 ` [PATCH 1/5] tools: Define a Makefile function to do subdir processing David Howells
2012-10-19 16:56 ` [PATCH 2/5] tools: Honour the O= flag when tool build called from a higher Makefile David Howells
2012-10-26  5:34   ` Namhyung Kim
2012-10-19 16:56 ` [PATCH 3/5] perf: Make perf build for x86 with UAPI disintegration applied David Howells
2012-10-26  5:49   ` Namhyung Kim
2012-10-19 16:56 ` [PATCH 4/5] x86: Disintegrate asm/svm.h and asm/vmx.h to produce UAPI components for perf David Howells
2012-10-19 16:56 ` [PATCH 5/5] x86: UAPI Disintegrate asm/perf_regs.h David Howells
2012-10-24 18:43 ` [RFC][PATCH 0/5] tools, perf: Fix up for x86 UAPI disintegration Arnaldo Carvalho de Melo
2012-10-24 19:46   ` Borislav Petkov
2012-10-25  7:57   ` David Howells
2012-10-26  4:33     ` Namhyung Kim
2012-10-26  6:04       ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).