xcp-1.6-updates/xen-4.1.hg
changeset 23259:ed5c1ad51a23
xenoprof: Adjust indentation
Bring indentation into Xen hypervisor standard coding style.
No functional changes.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 24536:212cf37d50e1
xen-unstable date: Mon Jan 23 09:36:01 2012 +0000
xenoprof: Handle 32-bit guest stacks properly in a 64-bit hypervisor
The dump_guest_backtrace() function attempted to walk the stack
based on the assumption that the guest and hypervisor pointer sizes
were the same; thus any 32-bit guest running under 64-bit hypervisor
would have unreliable results.
In 64-bit mode, read the 32-bit stack frame properly.
Signed-off-by: Marcus Granado <marcus.granado@eu.citrix.com>
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 24537:3c0a533d3af0
xen-unstable date: Mon Jan 23 09:36:29 2012 +0000
xenoprof: Use uint64_t explicitly for internal calls
A recent changeset to make XENOPROF_ESCAPE_CODE consistent across
32- and 64-bit builds caused a build failure, because values were
passed through functions as "unsigned long". Replace these with
uint64_t explicitly.
Also remove redundant function prototype from perfmon.c, now that
it's in a header file.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 24564:768c932ea8da
xen-unstable date: Thu Jan 26 11:03:23 2012 +0000
xenoprof: Make the escape code consistent across 32 and 64-bit xen
At the moment, the xenoprof escape code is defined as "~0UL".
Unfortunately, this expands to 0xffffffff on 32-bit systems
and 0xffffffffffffffff on 64-bit systems; with the result that
while 32-on-32 and 64-in-64 work fine, 32-on-64 (also known as
"compat mode") is broken.
This patch makes the definition consistent across architectures.
In so doing, it will break old-32-bit-on-new-Xen, and vice versa;
but this was seen as an acceptable thing to do.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 24565:1e27e827e6a8
xen-unstable date: Thu Jan 26 11:03:50 2012 +0000
Bring indentation into Xen hypervisor standard coding style.
No functional changes.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 24536:212cf37d50e1
xen-unstable date: Mon Jan 23 09:36:01 2012 +0000
xenoprof: Handle 32-bit guest stacks properly in a 64-bit hypervisor
The dump_guest_backtrace() function attempted to walk the stack
based on the assumption that the guest and hypervisor pointer sizes
were the same; thus any 32-bit guest running under 64-bit hypervisor
would have unreliable results.
In 64-bit mode, read the 32-bit stack frame properly.
Signed-off-by: Marcus Granado <marcus.granado@eu.citrix.com>
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 24537:3c0a533d3af0
xen-unstable date: Mon Jan 23 09:36:29 2012 +0000
xenoprof: Use uint64_t explicitly for internal calls
A recent changeset to make XENOPROF_ESCAPE_CODE consistent across
32- and 64-bit builds caused a build failure, because values were
passed through functions as "unsigned long". Replace these with
uint64_t explicitly.
Also remove redundant function prototype from perfmon.c, now that
it's in a header file.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 24564:768c932ea8da
xen-unstable date: Thu Jan 26 11:03:23 2012 +0000
xenoprof: Make the escape code consistent across 32 and 64-bit xen
At the moment, the xenoprof escape code is defined as "~0UL".
Unfortunately, this expands to 0xffffffff on 32-bit systems
and 0xffffffffffffffff on 64-bit systems; with the result that
while 32-on-32 and 64-in-64 work fine, 32-on-64 (also known as
"compat mode") is broken.
This patch makes the definition consistent across architectures.
In so doing, it will break old-32-bit-on-new-Xen, and vice versa;
but this was seen as an acceptable thing to do.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 24565:1e27e827e6a8
xen-unstable date: Thu Jan 26 11:03:50 2012 +0000
author | George Dunlap <george.dunlap@eu.citrix.com> |
---|---|
date | Wed Mar 07 10:58:25 2012 +0000 (2012-03-07) |
parents | dc7fc50b3594 |
children | 8a2e167905d3 |
files | xen/arch/ia64/xen/oprofile/perfmon.c xen/arch/x86/oprofile/backtrace.c xen/common/xenoprof.c xen/include/public/xenoprof.h xen/include/xen/xenoprof.h |
line diff
1.1 --- a/xen/arch/ia64/xen/oprofile/perfmon.c Wed Mar 07 10:54:11 2012 +0000 1.2 +++ b/xen/arch/ia64/xen/oprofile/perfmon.c Wed Mar 07 10:58:25 2012 +0000 1.3 @@ -38,8 +38,6 @@ 1.4 #include <asm/vmx.h> /* for vmx_user_mode() */ 1.5 1.6 // XXX move them to an appropriate header file 1.7 -extern void xenoprof_log_event(struct vcpu *vcpu, struct pt_regs * regs, 1.8 - unsigned long eip, int mode, int event); 1.9 extern int is_active(struct domain *d); 1.10 1.11 static int allow_virq;
2.1 --- a/xen/arch/x86/oprofile/backtrace.c Wed Mar 07 10:54:11 2012 +0000 2.2 +++ b/xen/arch/x86/oprofile/backtrace.c Wed Mar 07 10:58:25 2012 +0000 2.3 @@ -16,48 +16,82 @@ 2.4 #include<asm/guest_access.h> 2.5 2.6 struct frame_head { 2.7 - struct frame_head * ebp; 2.8 - unsigned long ret; 2.9 + struct frame_head * ebp; 2.10 + unsigned long ret; 2.11 } __attribute__((packed)); 2.12 2.13 +#ifdef CONFIG_X86_64 2.14 +struct frame_head_32bit { 2.15 + uint32_t ebp; 2.16 + unsigned long ret; 2.17 +} __attribute__((packed)); 2.18 +#endif 2.19 + 2.20 static struct frame_head * 2.21 dump_hypervisor_backtrace(struct domain *d, struct vcpu *vcpu, 2.22 struct frame_head * head, int mode) 2.23 { 2.24 - if (!xenoprof_add_trace(d, vcpu, head->ret, mode)) 2.25 - return 0; 2.26 + if (!xenoprof_add_trace(d, vcpu, head->ret, mode)) 2.27 + return 0; 2.28 + 2.29 + /* frame pointers should strictly progress back up the stack 2.30 + * (towards higher addresses) */ 2.31 + if (head >= head->ebp) 2.32 + return NULL; 2.33 + 2.34 + return head->ebp; 2.35 +} 2.36 2.37 - /* frame pointers should strictly progress back up the stack 2.38 - * (towards higher addresses) */ 2.39 - if (head >= head->ebp) 2.40 - return NULL; 2.41 - 2.42 - return head->ebp; 2.43 +#ifdef CONFIG_X86_64 2.44 +static inline int is_32bit_vcpu(struct vcpu *vcpu) 2.45 +{ 2.46 + if (is_hvm_vcpu(vcpu)) 2.47 + return !hvm_long_mode_enabled(vcpu); 2.48 + else 2.49 + return is_pv_32bit_vcpu(vcpu); 2.50 } 2.51 +#endif 2.52 2.53 static struct frame_head * 2.54 dump_guest_backtrace(struct domain *d, struct vcpu *vcpu, 2.55 struct frame_head * head, int mode) 2.56 { 2.57 - struct frame_head bufhead[2]; 2.58 - XEN_GUEST_HANDLE(char) guest_head = guest_handle_from_ptr(head, char); 2.59 - 2.60 - /* Also check accessibility of one struct frame_head beyond */ 2.61 - if (!guest_handle_okay(guest_head, sizeof(bufhead))) 2.62 - return 0; 2.63 - if (__copy_from_guest_offset((char *)bufhead, guest_head, 0, 2.64 - sizeof(bufhead))) 2.65 - return 0; 2.66 + struct frame_head bufhead[2]; 2.67 + XEN_GUEST_HANDLE(char) guest_head = guest_handle_from_ptr(head, char); 2.68 2.69 - if (!xenoprof_add_trace(d, vcpu, bufhead[0].ret, mode)) 2.70 - return 0; 2.71 - 2.72 - /* frame pointers should strictly progress back up the stack 2.73 - * (towards higher addresses) */ 2.74 - if (head >= bufhead[0].ebp) 2.75 - return NULL; 2.76 - 2.77 - return bufhead[0].ebp; 2.78 +#ifdef CONFIG_X86_64 2.79 + if ( is_32bit_vcpu(vcpu) ) 2.80 + { 2.81 + struct frame_head_32bit bufhead32[2]; 2.82 + /* Also check accessibility of one struct frame_head beyond */ 2.83 + if (!guest_handle_okay(guest_head, sizeof(bufhead32))) 2.84 + return 0; 2.85 + if (__copy_from_guest_offset((char *)bufhead32, guest_head, 0, 2.86 + sizeof(bufhead32))) 2.87 + return 0; 2.88 + bufhead[0].ebp=(struct frame_head *)(unsigned long)bufhead32[0].ebp; 2.89 + bufhead[0].ret=bufhead32[0].ret; 2.90 + } 2.91 + else 2.92 +#endif 2.93 + { 2.94 + /* Also check accessibility of one struct frame_head beyond */ 2.95 + if (!guest_handle_okay(guest_head, sizeof(bufhead))) 2.96 + return 0; 2.97 + if (__copy_from_guest_offset((char *)bufhead, guest_head, 0, 2.98 + sizeof(bufhead))) 2.99 + return 0; 2.100 + } 2.101 + 2.102 + if (!xenoprof_add_trace(d, vcpu, bufhead[0].ret, mode)) 2.103 + return 0; 2.104 + 2.105 + /* frame pointers should strictly progress back up the stack 2.106 + * (towards higher addresses) */ 2.107 + if (head >= bufhead[0].ebp) 2.108 + return NULL; 2.109 + 2.110 + return bufhead[0].ebp; 2.111 } 2.112 2.113 /* 2.114 @@ -94,22 +128,22 @@ dump_guest_backtrace(struct domain *d, s 2.115 static int valid_hypervisor_stack(struct frame_head * head, 2.116 struct cpu_user_regs * regs) 2.117 { 2.118 - unsigned long headaddr = (unsigned long)head; 2.119 + unsigned long headaddr = (unsigned long)head; 2.120 #ifdef CONFIG_X86_64 2.121 - unsigned long stack = (unsigned long)regs->rsp; 2.122 + unsigned long stack = (unsigned long)regs->rsp; 2.123 #else 2.124 - unsigned long stack = (unsigned long)regs; 2.125 + unsigned long stack = (unsigned long)regs; 2.126 #endif 2.127 - unsigned long stack_base = (stack & ~(STACK_SIZE - 1)) + STACK_SIZE; 2.128 + unsigned long stack_base = (stack & ~(STACK_SIZE - 1)) + STACK_SIZE; 2.129 2.130 - return headaddr > stack && headaddr < stack_base; 2.131 + return headaddr > stack && headaddr < stack_base; 2.132 } 2.133 #else 2.134 /* without fp, it's just junk */ 2.135 static int valid_hypervisor_stack(struct frame_head * head, 2.136 struct cpu_user_regs * regs) 2.137 { 2.138 - return 0; 2.139 + return 0; 2.140 } 2.141 #endif 2.142 2.143 @@ -117,16 +151,16 @@ void xenoprof_backtrace(struct domain *d 2.144 struct cpu_user_regs * const regs, 2.145 unsigned long depth, int mode) 2.146 { 2.147 - struct frame_head *head; 2.148 + struct frame_head *head; 2.149 2.150 - head = (struct frame_head *)regs->ebp; 2.151 + head = (struct frame_head *)regs->ebp; 2.152 2.153 - if (mode > 1) { 2.154 - while (depth-- && valid_hypervisor_stack(head, regs)) 2.155 - head = dump_hypervisor_backtrace(d, vcpu, head, mode); 2.156 - return; 2.157 - } 2.158 + if (mode > 1) { 2.159 + while (depth-- && valid_hypervisor_stack(head, regs)) 2.160 + head = dump_hypervisor_backtrace(d, vcpu, head, mode); 2.161 + return; 2.162 + } 2.163 2.164 - while (depth-- && head) 2.165 - head = dump_guest_backtrace(d, vcpu, head, mode); 2.166 + while (depth-- && head) 2.167 + head = dump_guest_backtrace(d, vcpu, head, mode); 2.168 }
3.1 --- a/xen/common/xenoprof.c Wed Mar 07 10:54:11 2012 +0000 3.2 +++ b/xen/common/xenoprof.c Wed Mar 07 10:58:25 2012 +0000 3.3 @@ -479,7 +479,7 @@ static int xenoprof_buf_space(struct dom 3.4 3.5 /* Check for space and add a sample. Return 1 if successful, 0 otherwise. */ 3.6 static int xenoprof_add_sample(struct domain *d, xenoprof_buf_t *buf, 3.7 - unsigned long eip, int mode, int event) 3.8 + uint64_t eip, int mode, int event) 3.9 { 3.10 int head, tail, size; 3.11 3.12 @@ -516,7 +516,7 @@ static int xenoprof_add_sample(struct do 3.13 } 3.14 3.15 int xenoprof_add_trace(struct domain *d, struct vcpu *vcpu, 3.16 - unsigned long eip, int mode) 3.17 + uint64_t eip, int mode) 3.18 { 3.19 xenoprof_buf_t *buf = d->xenoprof->vcpu[vcpu->vcpu_id].buffer; 3.20 3.21 @@ -531,7 +531,7 @@ int xenoprof_add_trace(struct domain *d, 3.22 } 3.23 3.24 void xenoprof_log_event(struct vcpu *vcpu, 3.25 - struct cpu_user_regs * regs, unsigned long eip, 3.26 + struct cpu_user_regs * regs, uint64_t eip, 3.27 int mode, int event) 3.28 { 3.29 struct domain *d = vcpu->domain;
4.1 --- a/xen/include/public/xenoprof.h Wed Mar 07 10:54:11 2012 +0000 4.2 +++ b/xen/include/public/xenoprof.h Wed Mar 07 10:58:25 2012 +0000 4.3 @@ -68,7 +68,7 @@ struct event_log { 4.4 }; 4.5 4.6 /* PC value that indicates a special code */ 4.7 -#define XENOPROF_ESCAPE_CODE ~0UL 4.8 +#define XENOPROF_ESCAPE_CODE (~0ULL) 4.9 /* Transient events for the xenoprof->oprofile cpu buf */ 4.10 #define XENOPROF_TRACE_BEGIN 1 4.11
5.1 --- a/xen/include/xen/xenoprof.h Wed Mar 07 10:54:11 2012 +0000 5.2 +++ b/xen/include/xen/xenoprof.h Wed Mar 07 10:58:25 2012 +0000 5.3 @@ -69,7 +69,7 @@ int is_passive(struct domain *d); 5.4 void free_xenoprof_pages(struct domain *d); 5.5 5.6 int xenoprof_add_trace(struct domain *d, struct vcpu *v, 5.7 - unsigned long eip, int mode); 5.8 + uint64_t eip, int mode); 5.9 5.10 #define PMU_OWNER_NONE 0 5.11 #define PMU_OWNER_XENOPROF 1 5.12 @@ -78,7 +78,7 @@ int acquire_pmu_ownship(int pmu_ownershi 5.13 void release_pmu_ownship(int pmu_ownership); 5.14 5.15 void xenoprof_log_event(struct vcpu *vcpu, 5.16 - struct cpu_user_regs * regs, unsigned long eip, 5.17 + struct cpu_user_regs * regs, uint64_t eip, 5.18 int mode, int event); 5.19 5.20 #endif /* __XEN__XENOPROF_H__ */