aboutsummaryrefslogtreecommitdiffstats
path: root/xen
diff options
context:
space:
mode:
authorEmmanuel Ackaouy <ack@xensource.com>2007-01-05 17:34:37 +0000
committerEmmanuel Ackaouy <ack@xensource.com>2007-01-05 17:34:37 +0000
commitb0a4c24ddae72f424710456f054297153565222f (patch)
tree3602d32ea8b6193e8d6dcf7317cab176276e7074 /xen
parent62320af21e472e4e27791dd5858cc323776aa340 (diff)
downloadxen-b0a4c24ddae72f424710456f054297153565222f.tar.gz
xen-b0a4c24ddae72f424710456f054297153565222f.tar.bz2
xen-b0a4c24ddae72f424710456f054297153565222f.zip
Enable compatibility mode operation for HYPERVISOR_xenoprof_op.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Diffstat (limited to 'xen')
-rw-r--r--xen/arch/x86/x86_64/compat/entry.S1
-rw-r--r--xen/common/Makefile1
-rw-r--r--xen/common/compat/xenoprof.c40
-rw-r--r--xen/common/xenoprof.c68
-rw-r--r--xen/include/public/xenoprof.h2
-rw-r--r--xen/include/xen/xenoprof.h26
-rw-r--r--xen/include/xlat.lst2
7 files changed, 113 insertions, 27 deletions
diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compat/entry.S
index c0c900cbb7..28642aa338 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -278,7 +278,6 @@ CFIX14:
.section .rodata, "a", @progbits
-#define compat_xenoprof_op domain_crash_synchronous
#define compat_sysctl domain_crash_synchronous
#define compat_domctl domain_crash_synchronous
diff --git a/xen/common/Makefile b/xen/common/Makefile
index ac4683bb82..1997f461c2 100644
--- a/xen/common/Makefile
+++ b/xen/common/Makefile
@@ -45,4 +45,5 @@ ifeq ($(CONFIG_COMPAT),y)
acm_ops.o: compat/acm_ops.c
grant_table.o: compat/grant_table.c
schedule.o: compat/schedule.c
+xenoprof.o: compat/xenoprof.c
endif
diff --git a/xen/common/compat/xenoprof.c b/xen/common/compat/xenoprof.c
new file mode 100644
index 0000000000..e1cad00d2a
--- /dev/null
+++ b/xen/common/compat/xenoprof.c
@@ -0,0 +1,40 @@
+/*
+ * compat/xenoprof.c
+ */
+
+#include <compat/xenoprof.h>
+
+#define COMPAT
+
+#define do_xenoprof_op compat_xenoprof_op
+
+#define xen_oprof_init xenoprof_init
+CHECK_oprof_init;
+#undef xen_oprof_init
+
+#define xenoprof_get_buffer compat_oprof_get_buffer
+#define xenoprof_op_get_buffer compat_oprof_op_get_buffer
+
+#define xen_domid_t domid_t
+#define compat_domid_t domid_compat_t
+CHECK_TYPE(domid);
+#undef compat_domid_t
+#undef xen_domid_t
+
+#define xen_oprof_passive xenoprof_passive
+CHECK_oprof_passive;
+#undef xen_oprof_passive
+
+#define xenoprof_counter compat_oprof_counter
+
+#include "../xenoprof.c"
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/common/xenoprof.c b/xen/common/xenoprof.c
index f297859de5..d61e3f173e 100644
--- a/xen/common/xenoprof.c
+++ b/xen/common/xenoprof.c
@@ -9,6 +9,7 @@
* VA Linux Systems Japan K.K.
*/
+#ifndef COMPAT
#include <xen/guest_access.h>
#include <xen/sched.h>
#include <public/xenoprof.h>
@@ -72,7 +73,7 @@ static void xenoprof_reset_stat(void)
static void xenoprof_reset_buf(struct domain *d)
{
int j;
- struct xenoprof_buf *buf;
+ xenoprof_buf_t *buf;
if ( d->xenoprof == NULL )
{
@@ -86,8 +87,8 @@ static void xenoprof_reset_buf(struct domain *d)
buf = d->xenoprof->vcpu[j].buffer;
if ( buf != NULL )
{
- buf->event_head = 0;
- buf->event_tail = 0;
+ xenoprof_buf(d, buf, event_head) = 0;
+ xenoprof_buf(d, buf, event_tail) = 0;
}
}
}
@@ -166,15 +167,24 @@ static int alloc_xenoprof_struct(
for_each_vcpu ( d, v )
nvcpu++;
+ bufsize = sizeof(struct xenoprof_buf);
+ i = sizeof(struct event_log);
+#ifdef CONFIG_COMPAT
+ d->xenoprof->is_compat = IS_COMPAT(is_passive ? dom0 : d);
+ if ( XENOPROF_COMPAT(d->xenoprof) )
+ {
+ bufsize = sizeof(struct compat_oprof_buf);
+ i = sizeof(struct compat_event_log);
+ }
+#endif
+
/* reduce max_samples if necessary to limit pages allocated */
max_bufsize = (MAX_OPROF_SHARED_PAGES * PAGE_SIZE) / nvcpu;
- max_max_samples = ( (max_bufsize - sizeof(struct xenoprof_buf)) /
- sizeof(struct event_log) ) + 1;
+ max_max_samples = ( (max_bufsize - bufsize) / i ) + 1;
if ( (unsigned)max_samples > max_max_samples )
max_samples = max_max_samples;
- bufsize = sizeof(struct xenoprof_buf) +
- (max_samples - 1) * sizeof(struct event_log);
+ bufsize += (max_samples - 1) * i;
npages = (nvcpu * bufsize - 1) / PAGE_SIZE + 1;
d->xenoprof->rawbuf = alloc_xenheap_pages(get_order_from_pages(npages));
@@ -195,11 +205,12 @@ static int alloc_xenoprof_struct(
i = 0;
for_each_vcpu ( d, v )
{
+ xenoprof_buf_t *buf = (xenoprof_buf_t *)&d->xenoprof->rawbuf[i * bufsize];
+
d->xenoprof->vcpu[v->vcpu_id].event_size = max_samples;
- d->xenoprof->vcpu[v->vcpu_id].buffer =
- (struct xenoprof_buf *)&d->xenoprof->rawbuf[i * bufsize];
- d->xenoprof->vcpu[v->vcpu_id].buffer->event_size = max_samples;
- d->xenoprof->vcpu[v->vcpu_id].buffer->vcpu_id = v->vcpu_id;
+ d->xenoprof->vcpu[v->vcpu_id].buffer = buf;
+ xenoprof_buf(d, buf, event_size) = max_samples;
+ xenoprof_buf(d, buf, vcpu_id) = v->vcpu_id;
i++;
/* in the unlikely case that the number of active vcpus changes */
@@ -406,8 +417,9 @@ static int add_passive_list(XEN_GUEST_HANDLE(void) arg)
void xenoprof_log_event(
struct vcpu *vcpu, unsigned long eip, int mode, int event)
{
+ struct domain *d = vcpu->domain;
struct xenoprof_vcpu *v;
- struct xenoprof_buf *buf;
+ xenoprof_buf_t *buf;
int head;
int tail;
int size;
@@ -417,13 +429,13 @@ void xenoprof_log_event(
/* ignore samples of un-monitored domains */
/* Count samples in idle separate from other unmonitored domains */
- if ( !is_profiled(vcpu->domain) )
+ if ( !is_profiled(d) )
{
others_samples++;
return;
}
- v = &vcpu->domain->xenoprof->vcpu[vcpu->vcpu_id];
+ v = &d->xenoprof->vcpu[vcpu->vcpu_id];
/* Sanity check. Should never happen */
if ( v->buffer == NULL )
@@ -432,10 +444,10 @@ void xenoprof_log_event(
return;
}
- buf = vcpu->domain->xenoprof->vcpu[vcpu->vcpu_id].buffer;
+ buf = v->buffer;
- head = buf->event_head;
- tail = buf->event_tail;
+ head = xenoprof_buf(d, buf, event_head);
+ tail = xenoprof_buf(d, buf, event_tail);
size = v->event_size;
/* make sure indexes in shared buffer are sane */
@@ -447,28 +459,28 @@ void xenoprof_log_event(
if ( (head == tail - 1) || (head == size - 1 && tail == 0) )
{
- buf->lost_samples++;
+ xenoprof_buf(d, buf, lost_samples)++;
lost_samples++;
}
else
{
- buf->event_log[head].eip = eip;
- buf->event_log[head].mode = mode;
- buf->event_log[head].event = event;
+ xenoprof_buf(d, buf, event_log[head].eip) = eip;
+ xenoprof_buf(d, buf, event_log[head].mode) = mode;
+ xenoprof_buf(d, buf, event_log[head].event) = event;
head++;
if ( head >= size )
head = 0;
- buf->event_head = head;
+ xenoprof_buf(d, buf, event_head) = head;
if ( is_active(vcpu->domain) )
active_samples++;
else
passive_samples++;
if ( mode == 0 )
- buf->user_samples++;
+ xenoprof_buf(d, buf, user_samples)++;
else if ( mode == 1 )
- buf->kernel_samples++;
+ xenoprof_buf(d, buf, kernel_samples)++;
else
- buf->xen_samples++;
+ xenoprof_buf(d, buf, xen_samples)++;
}
}
@@ -494,6 +506,8 @@ static int xenoprof_op_init(XEN_GUEST_HANDLE(void) arg)
return 0;
}
+#endif /* !COMPAT */
+
static int xenoprof_op_get_buffer(XEN_GUEST_HANDLE(void) arg)
{
struct xenoprof_get_buffer xenoprof_get_buffer;
@@ -732,6 +746,10 @@ int do_xenoprof_op(int op, XEN_GUEST_HANDLE(void) arg)
return ret;
}
+#if defined(CONFIG_COMPAT) && !defined(COMPAT)
+#include "compat/xenoprof.c"
+#endif
+
/*
* Local variables:
* mode: C
diff --git a/xen/include/public/xenoprof.h b/xen/include/public/xenoprof.h
index 709b60fa1f..d16d8ca3f6 100644
--- a/xen/include/public/xenoprof.h
+++ b/xen/include/public/xenoprof.h
@@ -74,8 +74,10 @@ struct xenoprof_buf {
uint64_t lost_samples;
struct event_log event_log[1];
};
+#ifndef __XEN__
typedef struct xenoprof_buf xenoprof_buf_t;
DEFINE_XEN_GUEST_HANDLE(xenoprof_buf_t);
+#endif
struct xenoprof_init {
int32_t num_events;
diff --git a/xen/include/xen/xenoprof.h b/xen/include/xen/xenoprof.h
index b9fe9de528..8983f0c987 100644
--- a/xen/include/xen/xenoprof.h
+++ b/xen/include/xen/xenoprof.h
@@ -10,6 +10,7 @@
#ifndef __XEN_XENOPROF_H__
#define __XEN_XENOPROF_H__
+#include <xen/config.h>
#include <public/xenoprof.h>
#include <asm/xenoprof.h>
@@ -22,9 +23,19 @@
#define XENOPROF_READY 2
#define XENOPROF_PROFILING 3
+#ifndef CONFIG_COMPAT
+typedef struct xenoprof_buf xenoprof_buf_t;
+#else
+#include <compat/xenoprof.h>
+typedef union {
+ struct xenoprof_buf native;
+ struct compat_oprof_buf compat;
+} xenoprof_buf_t;
+#endif
+
struct xenoprof_vcpu {
int event_size;
- struct xenoprof_buf *buffer;
+ xenoprof_buf_t *buffer;
};
struct xenoprof {
@@ -35,9 +46,22 @@ struct xenoprof {
int domain_type;
int domain_ready;
int is_primary;
+#ifdef CONFIG_COMPAT
+ int is_compat;
+#endif
struct xenoprof_vcpu vcpu [MAX_VIRT_CPUS];
};
+#ifndef CONFIG_COMPAT
+#define XENOPROF_COMPAT(x) 0
+#define xenoprof_buf(d, b, field) ((b)->field)
+#else
+#define XENOPROF_COMPAT(x) ((x)->is_compat)
+#define xenoprof_buf(d, b, field) (*(!(d)->xenoprof->is_compat ? \
+ &(b)->native.field : \
+ &(b)->compat.field))
+#endif
+
struct domain;
void free_xenoprof_pages(struct domain *d);
diff --git a/xen/include/xlat.lst b/xen/include/xlat.lst
index 540bbd7de1..be9f112802 100644
--- a/xen/include/xlat.lst
+++ b/xen/include/xlat.lst
@@ -38,3 +38,5 @@
? sched_remote_shutdown sched.h
? sched_shutdown sched.h
! vcpu_runstate_info vcpu.h
+? xenoprof_init xenoprof.h
+? xenoprof_passive xenoprof.h