From 96979188007a0671d3f067d7edf144742d7433ee Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 17 Dec 2009 21:26:50 -0500 Subject: [ported from 2008.3] Add tracing support and hook up Litmus KConfig for x86 - fix requesting more than 2^11 pages (MAX_ORDER) to system allocator Still to be merged: - feather-trace generic implementation --- arch/x86/include/asm/feather_trace.h | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 arch/x86/include/asm/feather_trace.h (limited to 'arch/x86/include/asm') diff --git a/arch/x86/include/asm/feather_trace.h b/arch/x86/include/asm/feather_trace.h new file mode 100644 index 00000000000..f60fbed07af --- /dev/null +++ b/arch/x86/include/asm/feather_trace.h @@ -0,0 +1,11 @@ +#ifndef _ARCH_FEATHER_TRACE_H +#define _ARCH_FEATHER_TRACE_H + +static inline unsigned long long ft_timestamp(void) +{ + unsigned long long ret; + __asm__ __volatile__("rdtsc" : "=A" (ret)); + return ret; +} + +#endif -- cgit v1.2.2 From 2a94c7bf9869a13e32de7a1fe94596de7b4789a8 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Fri, 28 May 2010 10:03:24 -0400 Subject: [ported from 2008.3] Add LITRMUS^RT syscalls to x86_32 --- arch/x86/include/asm/unistd_32.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'arch/x86/include/asm') diff --git a/arch/x86/include/asm/unistd_32.h b/arch/x86/include/asm/unistd_32.h index 6fb3c209a7e..34bc4204d37 100644 --- a/arch/x86/include/asm/unistd_32.h +++ b/arch/x86/include/asm/unistd_32.h @@ -343,9 +343,13 @@ #define __NR_rt_tgsigqueueinfo 335 #define __NR_perf_event_open 336 +#define __NR_LITMUS 337 + +#include "litmus/unistd.h" + #ifdef __KERNEL__ -#define NR_syscalls 337 +#define NR_syscalls 336 + NR_litmus_syscalls #define __ARCH_WANT_IPC_PARSE_VERSION #define __ARCH_WANT_OLD_READDIR -- cgit v1.2.2 From b085cafc43bc395e255626204169e20a587f28ba Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 17 Dec 2009 21:44:47 -0500 Subject: [ported from 2008.3] Add send_pull_timers() support for x86_32 arch --- arch/x86/include/asm/entry_arch.h | 1 + arch/x86/include/asm/hw_irq.h | 2 ++ arch/x86/include/asm/irq_vectors.h | 5 +++++ 3 files changed, 8 insertions(+) (limited to 'arch/x86/include/asm') diff --git a/arch/x86/include/asm/entry_arch.h b/arch/x86/include/asm/entry_arch.h index f5693c81a1d..19e22e3784d 100644 --- a/arch/x86/include/asm/entry_arch.h +++ b/arch/x86/include/asm/entry_arch.h @@ -13,6 +13,7 @@ BUILD_INTERRUPT(reschedule_interrupt,RESCHEDULE_VECTOR) BUILD_INTERRUPT(call_function_interrupt,CALL_FUNCTION_VECTOR) BUILD_INTERRUPT(call_function_single_interrupt,CALL_FUNCTION_SINGLE_VECTOR) +BUILD_INTERRUPT(pull_timers_interrupt,PULL_TIMERS_VECTOR) BUILD_INTERRUPT(irq_move_cleanup_interrupt,IRQ_MOVE_CLEANUP_VECTOR) BUILD_INTERRUPT(reboot_interrupt,REBOOT_VECTOR) diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h index ba180d93b08..162e5f9646e 100644 --- a/arch/x86/include/asm/hw_irq.h +++ b/arch/x86/include/asm/hw_irq.h @@ -53,6 +53,8 @@ extern void threshold_interrupt(void); extern void call_function_interrupt(void); extern void call_function_single_interrupt(void); +extern void pull_timers_interrupt(void); + /* PIC specific functions */ extern void disable_8259A_irq(unsigned int irq); extern void enable_8259A_irq(unsigned int irq); diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h index 5b21f0ec3df..28c3bf3f4c8 100644 --- a/arch/x86/include/asm/irq_vectors.h +++ b/arch/x86/include/asm/irq_vectors.h @@ -103,6 +103,11 @@ */ #define LOCAL_TIMER_VECTOR 0xef +/* + * LITMUS^RT pull timers IRQ vector + */ +#define PULL_TIMERS_VECTOR 0xee + /* * Generic system vector for platform specific use */ -- cgit v1.2.2 From 07ae7efcb81f95eb8e870cad21c7ba72573af7e8 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 17 Dec 2009 21:48:38 -0500 Subject: Add support for x86_64 architecture - Add syscall on x86_64 - Refactor __NR_sleep_next_period -> __NR_complete_job for both x86_32 and x86_64 --- arch/x86/include/asm/hw_irq.h | 1 + arch/x86/include/asm/unistd_32.h | 2 +- arch/x86/include/asm/unistd_64.h | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'arch/x86/include/asm') diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h index 162e5f9646e..68900e7dada 100644 --- a/arch/x86/include/asm/hw_irq.h +++ b/arch/x86/include/asm/hw_irq.h @@ -112,6 +112,7 @@ extern asmlinkage void smp_irq_move_cleanup_interrupt(void); extern void smp_reschedule_interrupt(struct pt_regs *); extern void smp_call_function_interrupt(struct pt_regs *); extern void smp_call_function_single_interrupt(struct pt_regs *); +extern void smp_pull_timers_interrupt(struct pt_regs *); #ifdef CONFIG_X86_32 extern void smp_invalidate_interrupt(struct pt_regs *); #else diff --git a/arch/x86/include/asm/unistd_32.h b/arch/x86/include/asm/unistd_32.h index 34bc4204d37..f9b507f30d6 100644 --- a/arch/x86/include/asm/unistd_32.h +++ b/arch/x86/include/asm/unistd_32.h @@ -345,7 +345,7 @@ #define __NR_LITMUS 337 -#include "litmus/unistd.h" +#include "litmus/unistd_32.h" #ifdef __KERNEL__ diff --git a/arch/x86/include/asm/unistd_64.h b/arch/x86/include/asm/unistd_64.h index 8d3ad0adbc6..33b2003c045 100644 --- a/arch/x86/include/asm/unistd_64.h +++ b/arch/x86/include/asm/unistd_64.h @@ -662,6 +662,10 @@ __SYSCALL(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo) #define __NR_perf_event_open 298 __SYSCALL(__NR_perf_event_open, sys_perf_event_open) +#define __NR_LITMUS 299 + +#include "litmus/unistd_64.h" + #ifndef __NO_STUBS #define __ARCH_WANT_OLD_READDIR #define __ARCH_WANT_OLD_STAT -- cgit v1.2.2 From d1a840d7194fdd09c1bd9977e30fd391ef2a7526 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Tue, 19 Jan 2010 19:38:14 -0500 Subject: [ported from 2008.3] Add Feather-Trace x86_32 architecture dependent code - [ported from 2008.3] Add x86_32 architecture dependent code. - Add the infrastructure for x86_32 - x86_64 integration. --- arch/x86/include/asm/feather_trace.h | 13 ++++-- arch/x86/include/asm/feather_trace_32.h | 80 +++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 arch/x86/include/asm/feather_trace_32.h (limited to 'arch/x86/include/asm') diff --git a/arch/x86/include/asm/feather_trace.h b/arch/x86/include/asm/feather_trace.h index f60fbed07af..86a4303fce7 100644 --- a/arch/x86/include/asm/feather_trace.h +++ b/arch/x86/include/asm/feather_trace.h @@ -1,11 +1,18 @@ #ifndef _ARCH_FEATHER_TRACE_H #define _ARCH_FEATHER_TRACE_H +#include + static inline unsigned long long ft_timestamp(void) { - unsigned long long ret; - __asm__ __volatile__("rdtsc" : "=A" (ret)); - return ret; + return __native_read_tsc(); } +#ifdef CONFIG_X86_32 +#include "feather_trace_32.h" +#else +/* not ready for integration yet */ +//#include "feather_trace_64.h" +#endif + #endif diff --git a/arch/x86/include/asm/feather_trace_32.h b/arch/x86/include/asm/feather_trace_32.h new file mode 100644 index 00000000000..192cd09b785 --- /dev/null +++ b/arch/x86/include/asm/feather_trace_32.h @@ -0,0 +1,80 @@ +/* Do not directly include this file. Include feather_trace.h instead */ + +#define feather_callback __attribute__((regparm(0))) + +/* + * make the compiler reload any register that is not saved in + * a cdecl function call + */ +#define CLOBBER_LIST "memory", "cc", "eax", "ecx", "edx" + +#define ft_event(id, callback) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " call " #callback " \n\t" \ + ".section __event_table, \"aw\" \n\t" \ + ".long " #id ", 0, 1b, 2f \n\t" \ + ".previous \n\t" \ + "2: \n\t" \ + : : : CLOBBER_LIST) + +#define ft_event0(id, callback) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " subl $4, %%esp \n\t" \ + " movl $" #id ", (%%esp) \n\t" \ + " call " #callback " \n\t" \ + " addl $4, %%esp \n\t" \ + ".section __event_table, \"aw\" \n\t" \ + ".long " #id ", 0, 1b, 2f \n\t" \ + ".previous \n\t" \ + "2: \n\t" \ + : : : CLOBBER_LIST) + +#define ft_event1(id, callback, param) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " subl $8, %%esp \n\t" \ + " movl %0, 4(%%esp) \n\t" \ + " movl $" #id ", (%%esp) \n\t" \ + " call " #callback " \n\t" \ + " addl $8, %%esp \n\t" \ + ".section __event_table, \"aw\" \n\t" \ + ".long " #id ", 0, 1b, 2f \n\t" \ + ".previous \n\t" \ + "2: \n\t" \ + : : "r" (param) : CLOBBER_LIST) + +#define ft_event2(id, callback, param, param2) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " subl $12, %%esp \n\t" \ + " movl %1, 8(%%esp) \n\t" \ + " movl %0, 4(%%esp) \n\t" \ + " movl $" #id ", (%%esp) \n\t" \ + " call " #callback " \n\t" \ + " addl $12, %%esp \n\t" \ + ".section __event_table, \"aw\" \n\t" \ + ".long " #id ", 0, 1b, 2f \n\t" \ + ".previous \n\t" \ + "2: \n\t" \ + : : "r" (param), "r" (param2) : CLOBBER_LIST) + + +#define ft_event3(id, callback, p, p2, p3) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " subl $16, %%esp \n\t" \ + " movl %2, 12(%%esp) \n\t" \ + " movl %1, 8(%%esp) \n\t" \ + " movl %0, 4(%%esp) \n\t" \ + " movl $" #id ", (%%esp) \n\t" \ + " call " #callback " \n\t" \ + " addl $16, %%esp \n\t" \ + ".section __event_table, \"aw\" \n\t" \ + ".long " #id ", 0, 1b, 2f \n\t" \ + ".previous \n\t" \ + "2: \n\t" \ + : : "r" (p), "r" (p2), "r" (p3) : CLOBBER_LIST) + +#define __ARCH_HAS_FEATHER_TRACE -- cgit v1.2.2 From 37b840336a1663a5ce62d663a702d9afefd56d23 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Mon, 1 Feb 2010 23:07:54 -0500 Subject: Add Feather-Trace x86_64 architecture dependent code --- arch/x86/include/asm/feather_trace.h | 3 +- arch/x86/include/asm/feather_trace_64.h | 69 +++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 arch/x86/include/asm/feather_trace_64.h (limited to 'arch/x86/include/asm') diff --git a/arch/x86/include/asm/feather_trace.h b/arch/x86/include/asm/feather_trace.h index 86a4303fce7..4fd31633405 100644 --- a/arch/x86/include/asm/feather_trace.h +++ b/arch/x86/include/asm/feather_trace.h @@ -11,8 +11,7 @@ static inline unsigned long long ft_timestamp(void) #ifdef CONFIG_X86_32 #include "feather_trace_32.h" #else -/* not ready for integration yet */ -//#include "feather_trace_64.h" +#include "feather_trace_64.h" #endif #endif diff --git a/arch/x86/include/asm/feather_trace_64.h b/arch/x86/include/asm/feather_trace_64.h new file mode 100644 index 00000000000..1cffa4eec5f --- /dev/null +++ b/arch/x86/include/asm/feather_trace_64.h @@ -0,0 +1,69 @@ +/* Do not directly include this file. Include feather_trace.h instead */ + +/* regparm is the default on x86_64 */ +#define feather_callback + +# define _EVENT_TABLE(id,from,to) \ + ".section __event_table, \"aw\"\n\t" \ + ".balign 8\n\t" \ + ".quad " #id ", 0, " #from ", " #to " \n\t" \ + ".previous \n\t" + +/* + * x86_64 callee only owns rbp, rbx, r12 -> r15 + * the called can freely modify the others + */ +#define CLOBBER_LIST "memory", "cc", "rdi", "rsi", "rdx", "rcx", \ + "r8", "r9", "r10", "r11", "rax" + +#define ft_event(id, callback) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " call " #callback " \n\t" \ + _EVENT_TABLE(id,1b,2f) \ + "2: \n\t" \ + : : : CLOBBER_LIST) + +#define ft_event0(id, callback) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " movq $" #id ", %%rdi \n\t" \ + " call " #callback " \n\t" \ + _EVENT_TABLE(id,1b,2f) \ + "2: \n\t" \ + : : : CLOBBER_LIST) + +#define ft_event1(id, callback, param) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " movq %0, %%rsi \n\t" \ + " movq $" #id ", %%rdi \n\t" \ + " call " #callback " \n\t" \ + _EVENT_TABLE(id,1b,2f) \ + "2: \n\t" \ + : : "r" (param) : CLOBBER_LIST) + +#define ft_event2(id, callback, param, param2) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " movq %1, %%rdx \n\t" \ + " movq %0, %%rsi \n\t" \ + " movq $" #id ", %%rdi \n\t" \ + " call " #callback " \n\t" \ + _EVENT_TABLE(id,1b,2f) \ + "2: \n\t" \ + : : "r" (param), "r" (param2) : CLOBBER_LIST) + +#define ft_event3(id, callback, p, p2, p3) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " movq %2, %%rcx \n\t" \ + " movq %1, %%rdx \n\t" \ + " movq %0, %%rsi \n\t" \ + " movq $" #id ", %%rdi \n\t" \ + " call " #callback " \n\t" \ + _EVENT_TABLE(id,1b,2f) \ + "2: \n\t" \ + : : "r" (p), "r" (p2), "r" (p3) : CLOBBER_LIST) + +#define __ARCH_HAS_FEATHER_TRACE -- cgit v1.2.2 From 425a6b5043bcc2142804107c853f978ac2fe3040 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Fri, 28 May 2010 10:49:09 -0400 Subject: Export shared_cpu_map The cpumap of CPUs that share the same cache level is not normally available outside intel_cacheinfo.c. This commit allows to export such map. --- arch/x86/include/asm/processor.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/x86/include/asm') diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index c9786480f0f..e75daac6496 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -172,6 +172,8 @@ extern void print_cpu_info(struct cpuinfo_x86 *); extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c); extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); extern unsigned short num_cache_leaves; +extern int get_shared_cpu_map(cpumask_var_t mask, + unsigned int cpu, int index); extern void detect_extended_topology(struct cpuinfo_x86 *c); extern void detect_ht(struct cpuinfo_x86 *c); -- cgit v1.2.2 From 152968b15afb74a6adba6d512c5eebf0280c8f00 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Sun, 30 May 2010 18:41:28 -0400 Subject: Make __ARCH_HAS_FEATHER_TRACE a proper CONFIG_ variable. The idea of the Feather-Trace default implementation is that LITMUS^RT should work without a specialized Feather-Trace implementation present. This was actually broken. Changes litmus/feather_trace.h to only include asm/feather_trace.h if actually promised by the architecture. --- arch/x86/include/asm/feather_trace_32.h | 1 - arch/x86/include/asm/feather_trace_64.h | 2 -- 2 files changed, 3 deletions(-) (limited to 'arch/x86/include/asm') diff --git a/arch/x86/include/asm/feather_trace_32.h b/arch/x86/include/asm/feather_trace_32.h index 192cd09b785..70202f90f16 100644 --- a/arch/x86/include/asm/feather_trace_32.h +++ b/arch/x86/include/asm/feather_trace_32.h @@ -77,4 +77,3 @@ "2: \n\t" \ : : "r" (p), "r" (p2), "r" (p3) : CLOBBER_LIST) -#define __ARCH_HAS_FEATHER_TRACE diff --git a/arch/x86/include/asm/feather_trace_64.h b/arch/x86/include/asm/feather_trace_64.h index 1cffa4eec5f..54ac2aeb3a2 100644 --- a/arch/x86/include/asm/feather_trace_64.h +++ b/arch/x86/include/asm/feather_trace_64.h @@ -65,5 +65,3 @@ _EVENT_TABLE(id,1b,2f) \ "2: \n\t" \ : : "r" (p), "r" (p2), "r" (p3) : CLOBBER_LIST) - -#define __ARCH_HAS_FEATHER_TRACE -- cgit v1.2.2 From 4382e90cf851fc1d209a466bab92e256aeb7acf1 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Mon, 31 May 2010 00:54:07 -0400 Subject: Make C-EDF depend on x86 and SYSFS C-EDF depends on intel_cacheinfo.c (for get_shared_cpu_map()) which is only available on x86 architectures. Furthermore, get_shared_cpu_map() is only available if SYSFS filesystem is present. --- arch/x86/include/asm/processor.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/x86/include/asm') diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 91d323f4736..48426f99147 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -173,8 +173,10 @@ extern void print_cpu_info(struct cpuinfo_x86 *); extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c); extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); extern unsigned short num_cache_leaves; +#ifdef CONFIG_SYSFS extern int get_shared_cpu_map(cpumask_var_t mask, unsigned int cpu, int index); +#endif extern void detect_extended_topology(struct cpuinfo_x86 *c); extern void detect_ht(struct cpuinfo_x86 *c); -- cgit v1.2.2 From 56c5c609615322bfbda5adff94ce011eb3d28fef Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Sat, 27 Aug 2011 16:10:06 +0200 Subject: Fix prototype mismatching and synch syscall numbers * Update prototypes for switched_to(), prio_changed(), select_task_rq(). * Fix missing pid field in printk output. * Synchronize syscall numbers for arm and x86. --- arch/x86/include/asm/unistd_64.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/x86/include/asm') diff --git a/arch/x86/include/asm/unistd_64.h b/arch/x86/include/asm/unistd_64.h index f24806cf3a0..e347f077378 100644 --- a/arch/x86/include/asm/unistd_64.h +++ b/arch/x86/include/asm/unistd_64.h @@ -682,7 +682,7 @@ __SYSCALL(__NR_sendmmsg, sys_sendmmsg) #define __NR_setns 308 __SYSCALL(__NR_setns, sys_setns) -#define __NR_LITMUS 303 +#define __NR_LITMUS 309 #include "litmus/unistd_64.h" -- cgit v1.2.2 From ea62a6fe914f7463f89422dcb1812eb071cbd495 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Wed, 24 Aug 2011 12:06:42 +0200 Subject: Update PULL_TIMERS_VECTOR number From 2.6.39 the "0xee" vector number that we used for pull_timers low-level management is is use by invalidate_tlb_X interrupts. Move the pull_timers vector below the max size of invalidate_tlb. --- arch/x86/include/asm/irq_vectors.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'arch/x86/include/asm') diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h index cf72a7060bf..99a44cf9845 100644 --- a/arch/x86/include/asm/irq_vectors.h +++ b/arch/x86/include/asm/irq_vectors.h @@ -97,11 +97,6 @@ #define THRESHOLD_APIC_VECTOR 0xf9 #define REBOOT_VECTOR 0xf8 -/* - * LITMUS^RT pull timers IRQ vector - */ -#define PULL_TIMERS_VECTOR 0xee - /* * Generic system vector for platform specific use */ @@ -140,6 +135,13 @@ #define INVALIDATE_TLB_VECTOR_START \ (INVALIDATE_TLB_VECTOR_END-NUM_INVALIDATE_TLB_VECTORS+1) +/* + * LITMUS^RT pull timers IRQ vector + * Make sure it's below the above max 32 vectors. + */ +#define PULL_TIMERS_VECTOR 0xce + + #define NR_VECTORS 256 #define FPU_IRQ 13 -- cgit v1.2.2 From 4bc55d3b64fdf0af17f4777013a74fbef7f40ced Mon Sep 17 00:00:00 2001 From: Bjoern Brandenburg Date: Wed, 30 May 2012 10:16:32 +0200 Subject: Update to improved x86 Feather-Trace triggers This patch imports recent upstream changes in Feather-Trace that reduce register pressure around Feather-Trace triggers. References: Commits 00713b8 and 225d734 in Feather-Trace. https://github.com/brandenburg/feather-trace/commit/00713b878636867ce07291c588509b38fa5bf152 https://github.com/brandenburg/feather-trace/commit/225d7348a08682cd87f72b127142bdfd6c0c7890 --- arch/x86/include/asm/feather_trace_32.h | 96 ++++++++++++++++++++---------- arch/x86/include/asm/feather_trace_64.h | 101 +++++++++++++++++++++++++------- 2 files changed, 145 insertions(+), 52 deletions(-) (limited to 'arch/x86/include/asm') diff --git a/arch/x86/include/asm/feather_trace_32.h b/arch/x86/include/asm/feather_trace_32.h index 70202f90f16..75e81a9f938 100644 --- a/arch/x86/include/asm/feather_trace_32.h +++ b/arch/x86/include/asm/feather_trace_32.h @@ -1,12 +1,45 @@ +/* Copyright (c) 2007-2012 Björn Brandenburg, + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + /* Do not directly include this file. Include feather_trace.h instead */ -#define feather_callback __attribute__((regparm(0))) +#define feather_callback __attribute__((regparm(3))) __attribute__((used)) /* - * make the compiler reload any register that is not saved in - * a cdecl function call + * Make the compiler reload any register that is not saved in a cdecl function + * call (minus the registers that we explicitly clobber as output registers). */ -#define CLOBBER_LIST "memory", "cc", "eax", "ecx", "edx" +#define __FT_CLOBBER_LIST0 "memory", "cc", "eax", "edx", "ecx" +#define __FT_CLOBBER_LIST1 "memory", "cc", "eax", "ecx" +#define __FT_CLOBBER_LIST2 "memory", "cc", "eax" +#define __FT_CLOBBER_LIST3 "memory", "cc", "eax" + +#define __FT_TMP1(x) "=d" (x) +#define __FT_ARG1(x) "0" ((long) (x)) +#define __FT_TMP2(x) "=c" (x) +#define __FT_ARG2(x) "1" ((long) (x)) + +#define __FT_ARG3(x) "r" ((long) (x)) #define ft_event(id, callback) \ __asm__ __volatile__( \ @@ -16,64 +49,67 @@ ".long " #id ", 0, 1b, 2f \n\t" \ ".previous \n\t" \ "2: \n\t" \ - : : : CLOBBER_LIST) + : : : __FT_CLOBBER_LIST0) #define ft_event0(id, callback) \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ - " subl $4, %%esp \n\t" \ - " movl $" #id ", (%%esp) \n\t" \ + " movl $" #id ", %%eax \n\t" \ " call " #callback " \n\t" \ - " addl $4, %%esp \n\t" \ ".section __event_table, \"aw\" \n\t" \ ".long " #id ", 0, 1b, 2f \n\t" \ ".previous \n\t" \ "2: \n\t" \ - : : : CLOBBER_LIST) + : : : __FT_CLOBBER_LIST0) -#define ft_event1(id, callback, param) \ +#define ft_event1(id, callback, param) \ + do { \ + long __ft_tmp1; \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ - " subl $8, %%esp \n\t" \ - " movl %0, 4(%%esp) \n\t" \ - " movl $" #id ", (%%esp) \n\t" \ + " movl $" #id ", %%eax \n\t" \ " call " #callback " \n\t" \ - " addl $8, %%esp \n\t" \ ".section __event_table, \"aw\" \n\t" \ ".long " #id ", 0, 1b, 2f \n\t" \ ".previous \n\t" \ "2: \n\t" \ - : : "r" (param) : CLOBBER_LIST) + : __FT_TMP1(__ft_tmp1) \ + : __FT_ARG1(param) \ + : __FT_CLOBBER_LIST1); \ + } while (0); #define ft_event2(id, callback, param, param2) \ + do { \ + long __ft_tmp1, __ft_tmp2; \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ - " subl $12, %%esp \n\t" \ - " movl %1, 8(%%esp) \n\t" \ - " movl %0, 4(%%esp) \n\t" \ - " movl $" #id ", (%%esp) \n\t" \ + " movl $" #id ", %%eax \n\t" \ " call " #callback " \n\t" \ - " addl $12, %%esp \n\t" \ ".section __event_table, \"aw\" \n\t" \ ".long " #id ", 0, 1b, 2f \n\t" \ ".previous \n\t" \ "2: \n\t" \ - : : "r" (param), "r" (param2) : CLOBBER_LIST) + : __FT_TMP1(__ft_tmp1), __FT_TMP2(__ft_tmp2) \ + : __FT_ARG1(param), __FT_ARG2(param2) \ + : __FT_CLOBBER_LIST2); \ + } while (0); -#define ft_event3(id, callback, p, p2, p3) \ +#define ft_event3(id, callback, param, param2, param3) \ + do { \ + long __ft_tmp1, __ft_tmp2; \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ - " subl $16, %%esp \n\t" \ - " movl %2, 12(%%esp) \n\t" \ - " movl %1, 8(%%esp) \n\t" \ - " movl %0, 4(%%esp) \n\t" \ - " movl $" #id ", (%%esp) \n\t" \ + " subl $4, %%esp \n\t" \ + " movl $" #id ", %%eax \n\t" \ + " movl %2, (%%esp) \n\t" \ " call " #callback " \n\t" \ - " addl $16, %%esp \n\t" \ + " addl $4, %%esp \n\t" \ ".section __event_table, \"aw\" \n\t" \ ".long " #id ", 0, 1b, 2f \n\t" \ ".previous \n\t" \ "2: \n\t" \ - : : "r" (p), "r" (p2), "r" (p3) : CLOBBER_LIST) - + : __FT_TMP1(__ft_tmp1), __FT_TMP2(__ft_tmp2) \ + : __FT_ARG1(param), __FT_ARG2(param2), __FT_ARG3(param3) \ + : __FT_CLOBBER_LIST3); \ + } while (0); diff --git a/arch/x86/include/asm/feather_trace_64.h b/arch/x86/include/asm/feather_trace_64.h index 54ac2aeb3a2..5ce49e2eebb 100644 --- a/arch/x86/include/asm/feather_trace_64.h +++ b/arch/x86/include/asm/feather_trace_64.h @@ -1,67 +1,124 @@ +/* Copyright (c) 2010 Andrea Bastoni, + * Copyright (c) 2012 Björn Brandenburg, + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + /* Do not directly include this file. Include feather_trace.h instead */ /* regparm is the default on x86_64 */ -#define feather_callback +#define feather_callback __attribute__((used)) -# define _EVENT_TABLE(id,from,to) \ +#define __FT_EVENT_TABLE(id,from,to) \ ".section __event_table, \"aw\"\n\t" \ ".balign 8\n\t" \ ".quad " #id ", 0, " #from ", " #to " \n\t" \ ".previous \n\t" /* - * x86_64 callee only owns rbp, rbx, r12 -> r15 - * the called can freely modify the others + * x86_64 caller only owns rbp, rbx, r12-r15; + * the callee can freely modify the others. */ -#define CLOBBER_LIST "memory", "cc", "rdi", "rsi", "rdx", "rcx", \ +#define __FT_CLOBBER_LIST0 "memory", "cc", "rdi", "rsi", "rdx", "rcx", \ + "r8", "r9", "r10", "r11", "rax" + +#define __FT_CLOBBER_LIST1 "memory", "cc", "rdi", "rdx", "rcx", \ + "r8", "r9", "r10", "r11", "rax" + +#define __FT_CLOBBER_LIST2 "memory", "cc", "rdi", "rcx", \ "r8", "r9", "r10", "r11", "rax" +#define __FT_CLOBBER_LIST3 "memory", "cc", "rdi", \ + "r8", "r9", "r10", "r11", "rax" + +/* The registers RDI, RSI, RDX, RCX, R8 and R9 are used for integer and pointer + * arguments. */ + +/* RSI */ +#define __FT_TMP1(x) "=S" (x) +#define __FT_ARG1(x) "0" ((long) (x)) + +/* RDX */ +#define __FT_TMP2(x) "=d" (x) +#define __FT_ARG2(x) "1" ((long) (x)) + +/* RCX */ +#define __FT_TMP3(x) "=c" (x) +#define __FT_ARG3(x) "2" ((long) (x)) + #define ft_event(id, callback) \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ " call " #callback " \n\t" \ - _EVENT_TABLE(id,1b,2f) \ + __FT_EVENT_TABLE(id,1b,2f) \ "2: \n\t" \ - : : : CLOBBER_LIST) + : : : __FT_CLOBBER_LIST0) #define ft_event0(id, callback) \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ " movq $" #id ", %%rdi \n\t" \ " call " #callback " \n\t" \ - _EVENT_TABLE(id,1b,2f) \ + __FT_EVENT_TABLE(id,1b,2f) \ "2: \n\t" \ - : : : CLOBBER_LIST) + : : : __FT_CLOBBER_LIST0) #define ft_event1(id, callback, param) \ + do { \ + long __ft_tmp1; \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ - " movq %0, %%rsi \n\t" \ " movq $" #id ", %%rdi \n\t" \ " call " #callback " \n\t" \ - _EVENT_TABLE(id,1b,2f) \ + __FT_EVENT_TABLE(id,1b,2f) \ "2: \n\t" \ - : : "r" (param) : CLOBBER_LIST) + : __FT_TMP1(__ft_tmp1) \ + : __FT_ARG1(param) \ + : __FT_CLOBBER_LIST1); \ + } while (0); #define ft_event2(id, callback, param, param2) \ + do { \ + long __ft_tmp1, __ft_tmp2; \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ - " movq %1, %%rdx \n\t" \ - " movq %0, %%rsi \n\t" \ " movq $" #id ", %%rdi \n\t" \ " call " #callback " \n\t" \ - _EVENT_TABLE(id,1b,2f) \ + __FT_EVENT_TABLE(id,1b,2f) \ "2: \n\t" \ - : : "r" (param), "r" (param2) : CLOBBER_LIST) + : __FT_TMP1(__ft_tmp1), __FT_TMP2(__ft_tmp2) \ + : __FT_ARG1(param), __FT_ARG2(param2) \ + : __FT_CLOBBER_LIST2); \ + } while (0); -#define ft_event3(id, callback, p, p2, p3) \ +#define ft_event3(id, callback, param, param2, param3) \ + do { \ + long __ft_tmp1, __ft_tmp2, __ft_tmp3; \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ - " movq %2, %%rcx \n\t" \ - " movq %1, %%rdx \n\t" \ - " movq %0, %%rsi \n\t" \ " movq $" #id ", %%rdi \n\t" \ " call " #callback " \n\t" \ - _EVENT_TABLE(id,1b,2f) \ + __FT_EVENT_TABLE(id,1b,2f) \ "2: \n\t" \ - : : "r" (p), "r" (p2), "r" (p3) : CLOBBER_LIST) + : __FT_TMP1(__ft_tmp1), __FT_TMP2(__ft_tmp2), __FT_TMP3(__ft_tmp3) \ + : __FT_ARG1(param), __FT_ARG2(param2), __FT_ARG3(param3) \ + : __FT_CLOBBER_LIST3); \ + } while (0); -- cgit v1.2.2