# HG changeset patch # User yamahata@xxxxxxxxxxxxx # Date 1155119096 -32400 # Node ID 0c0877c73915a42678778bdbc9fdaa703a77b965 # Parent dc37e8c2b96afe282d95a7263fb64ede040b28df p2m exposure test module PATCHNAME: p2m_exposure_test_module Signed-off-by: Isaku Yamahata diff -r dc37e8c2b96a -r 0c0877c73915 linux-2.6-xen-sparse/arch/ia64/xen/Makefile --- a/linux-2.6-xen-sparse/arch/ia64/xen/Makefile Wed Aug 09 19:24:35 2006 +0900 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/Makefile Wed Aug 09 19:24:56 2006 +0900 @@ -6,3 +6,5 @@ obj-y := hypercall.o xenivt.o xenentry.o hypervisor.o pci-dma-xen.o util.o pci-dma-xen-y := ../../i386/kernel/pci-dma-xen.o + +obj-m := expose_p2m.o \ No newline at end of file diff -r dc37e8c2b96a -r 0c0877c73915 linux-2.6-xen-sparse/arch/ia64/xen/expose_p2m.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/expose_p2m.c Wed Aug 09 19:24:56 2006 +0900 @@ -0,0 +1,105 @@ +/****************************************************************************** + * arch/ia64/xen/expose_p2m.c + * + * Copyright (c) 2006 Isaku Yamahata + * VA Linux Systems Japan K.K. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that 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 + * + */ + +#include +#include +#include +#include +#include +#include + +#define printd(fmt, ...) printk("%s:%d " fmt, __func__, __LINE__, \ + ##__VA_ARGS__) + + +static int __init +expose_p2m_init(void) +{ + unsigned long gpfn; + unsigned long mfn; + unsigned long p2m_mfn; + struct timeval before_tv; + struct timeval after_tv; + nsec_t hyper_nsec; + nsec_t p2m_nsec; + + int error_count = 0; + + printd("about to call p2m_expose_init()\n"); + if (p2m_expose_init() < 0) { + printd("p2m_expose_init() failed\n"); + return -EINVAL; + } + + printd("evaluate p2m time with hypercall.\n"); + do_gettimeofday(&before_tv); + for (gpfn = p2m_min_low_pfn; gpfn < p2m_max_low_pfn; gpfn++) { + mfn = HYPERVISOR_phystomach(gpfn); + } + do_gettimeofday(&after_tv); + hyper_nsec = timeval_to_ns(&after_tv) - timeval_to_ns(&before_tv); + + printd("evaluate p2m time with the p2m table.\n"); + do_gettimeofday(&before_tv); + for (gpfn = p2m_min_low_pfn; gpfn < p2m_max_low_pfn; gpfn++) { + p2m_mfn = p2m_phystomach(gpfn); + } + do_gettimeofday(&after_tv); + p2m_nsec = timeval_to_ns(&after_tv) - timeval_to_ns(&before_tv); + printd("hypercall:%ld nsec\n", hyper_nsec); + printd("p2m table:%ld nsec\n", p2m_nsec); + + printd("p2m_expose_init() success\n"); + for (gpfn = p2m_min_low_pfn; gpfn < p2m_max_low_pfn; gpfn++) { + mfn = HYPERVISOR_phystomach(gpfn); + p2m_mfn = p2m_phystomach(gpfn); + if (mfn != p2m_mfn) { + printd("gpfn 0x%016lx " + "mfn 0x%016lx p2m_mfn 0x%016lx\n", + gpfn, mfn, p2m_mfn); + printd("mpaddr 0x%016lx " + "maddr 0x%016lx p2m_maddr 0x%016lx\n", + gpfn << PAGE_SHIFT, + mfn << PAGE_SHIFT, p2m_mfn << PAGE_SHIFT); + + error_count++; + if (error_count > 16) { + printk("too many errors\n"); + return -EINVAL; + } + } + } + printd("p2m expose test done!\n"); + + return -EINVAL; +} + +static void __exit +expose_p2m_cleanup(void) +{ +} + +module_init(expose_p2m_init); +module_exit(expose_p2m_cleanup); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Isaku Yamahata ");