diff -Nur --exclude=RCS --exclude=CVS --exclude=SCCS --exclude=BitKeeper --exclude=ChangeSet xeno.bk/xen/arch/i386/entry.S xeno.foo/xen/arch/i386/entry.S --- xeno.bk/xen/arch/i386/entry.S Mon Feb 23 17:49:50 2004 +++ xeno.foo/xen/arch/i386/entry.S Tue Feb 24 17:58:04 2004 @@ -727,6 +727,7 @@ .long SYMBOL_NAME(do_set_timer_op) /* 20 */ .long SYMBOL_NAME(do_event_channel_op) .long SYMBOL_NAME(do_xen_version) + .long SYMBOL_NAME(do_get_page_info) .rept NR_syscalls-((.-hypervisor_call_table)/4) .long SYMBOL_NAME(do_ni_syscall) .endr diff -Nur --exclude=RCS --exclude=CVS --exclude=SCCS --exclude=BitKeeper --exclude=ChangeSet xeno.bk/xen/common/memory.c xeno.foo/xen/common/memory.c --- xeno.bk/xen/common/memory.c Mon Feb 23 14:32:33 2004 +++ xeno.foo/xen/common/memory.c Tue Feb 24 17:58:54 2004 @@ -1102,6 +1102,54 @@ } +/* + * allows a domain to get query some information on a page + * this is primarily for debugging purposes + * a normal domain is only allowed to query its own pages. + * privileged domains can query any page. + */ +long do_get_page_info(get_page_info_t *u_page_info) +{ + long ret = 0; + get_page_info_t *pi; + + if ( (pi = kmalloc(sizeof(*pi), GFP_KERNEL)) == NULL ) + return -ENOMEM; + + + /* sanity checks */ + if ( copy_from_user(pi, u_page_info, sizeof(*pi)) ) + { + ret = -EFAULT; + goto out; + } + + if ( unlikely(pi->pfn >= max_page) ) + { + ret = -EINVAL; + goto out; + } + + if ( (frame_table[pi->pfn].u.domain != current) && + !IS_PRIV(current) ) + { + ret = -EPERM; + goto out; + } + + /* copy the info */ + pi->owner = (unsigned long) frame_table[pi->pfn].u.domain; + pi->count_and_flags = frame_table[pi->pfn].count_and_flags; + pi->type_and_flags = frame_table[pi->pfn].type_and_flags; + pi->tlbflush_timestamp = frame_table[pi->pfn].tlbflush_timestamp; + + copy_to_user(u_page_info, pi, sizeof(*pi)); + out: + kfree(pi); + return 0; +} + + #ifndef NDEBUG /* * below are various memory debugging functions: diff -Nur --exclude=RCS --exclude=CVS --exclude=SCCS --exclude=BitKeeper --exclude=ChangeSet xeno.bk/xen/include/hypervisor-ifs/hypervisor-if.h xeno.foo/xen/include/hypervisor-ifs/hypervisor-if.h --- xeno.bk/xen/include/hypervisor-ifs/hypervisor-if.h Mon Feb 23 17:49:51 2004 +++ xeno.foo/xen/include/hypervisor-ifs/hypervisor-if.h Tue Feb 24 17:57:17 2004 @@ -63,6 +63,7 @@ #define __HYPERVISOR_set_timer_op 20 #define __HYPERVISOR_event_channel_op 21 #define __HYPERVISOR_xen_version 22 +#define __HYPERVISOR_get_page_info 23 /* And the trap vector is... */ #define TRAP_INSTR "int $0x82" @@ -245,6 +246,21 @@ unsigned long esp; unsigned long ss; } execution_context_t; + +/* + * returned by get_page_info hypercall + * usefull for debugging. allows a dom to find out info xen keeps about a page + */ +typedef struct +{ + unsigned long pfn; + unsigned long owner; + unsigned long count_and_flags; + unsigned long type_and_flags; + unsigned long tlbflush_timestamp; +} get_page_info_t; + + /* * Xen/guestos shared data -- pointer provided in start_info. diff -Nur --exclude=RCS --exclude=CVS --exclude=SCCS --exclude=BitKeeper --exclude=ChangeSet xeno.bk/xenolinux-2.4.25-sparse/include/asm-xeno/hypervisor.h xeno.foo/xenolinux-2.4.25-sparse/include/asm-xeno/hypervisor.h --- xeno.bk/xenolinux-2.4.25-sparse/include/asm-xeno/hypervisor.h Mon Feb 23 17:49:51 2004 +++ xeno.foo/xenolinux-2.4.25-sparse/include/asm-xeno/hypervisor.h Tue Feb 24 18:13:37 2004 @@ -446,4 +446,16 @@ return ret; } +static inline int HYPERVISOR_get_page_info(get_page_info_t *pi) +{ + int ret; + __asm__ __volatile__ ( + TRAP_INSTR + : "=a" (ret) : "0" (__HYPERVISOR_get_page_info), + "b" (pi) : "memory" ); + + return ret; +} + + #endif /* __HYPERVISOR_H__ */ diff -Nur --exclude=RCS --exclude=CVS --exclude=SCCS --exclude=BitKeeper --exclude=ChangeSet xeno.bk/xenolinux-sparse/include/asm-xeno/hypervisor.h xeno.foo/xenolinux-sparse/include/asm-xeno/hypervisor.h --- xeno.bk/xenolinux-sparse/include/asm-xeno/hypervisor.h Mon Feb 23 17:49:51 2004 +++ xeno.foo/xenolinux-sparse/include/asm-xeno/hypervisor.h Tue Feb 24 18:13:37 2004 @@ -446,4 +446,16 @@ return ret; } +static inline int HYPERVISOR_get_page_info(get_page_info_t *pi) +{ + int ret; + __asm__ __volatile__ ( + TRAP_INSTR + : "=a" (ret) : "0" (__HYPERVISOR_get_page_info), + "b" (pi) : "memory" ); + + return ret; +} + + #endif /* __HYPERVISOR_H__ */