diff -U 3 -H -d -r -N -- usr/src/nv/conftest.sh usr-patched/src/nv/conftest.sh --- usr/src/nv/conftest.sh 2008-07-18 03:42:51.000000000 +0200 +++ usr-patched/src/nv/conftest.sh 2008-08-14 17:43:14.000000000 +0200 @@ -25,6 +25,16 @@ test_xen() { FILE="linux/autoconf.h" + KERNEL_VERSION=` uname -r | tr "[:punct:]" " " | awk "{print \\\$1}"` + KERNEL_PATCHLEVEL=`uname -r | tr "[:punct:]" " " | awk "{print \\\$2}"` + KERNEL_SUBLEVEL=` uname -r | tr "[:punct:]" " " | awk "{print \\\$3}"` + KERNELVERSION=`expr $KERNEL_VERSION \* 65536 + $KERNEL_PATCHLEVEL \* 256 + $KERNEL_SUBLEVEL` + KERNEL_2_6_25=`expr 2 \* 65536 + 6 \* 256 + 25` + if [ $KERNELVERSION -ge $KERNEL_2_6_25 ]; then + XEN_PRESENT="-1" + return + fi + if [ -f $HEADERS/$FILE -o -f $OUTPUT/include/$FILE ]; then # # We are looking at a configured source tree; verify @@ -41,7 +51,7 @@ if [ -f conftest$$.o ]; then rm -f conftest$$.o - XEN_PRESENT=0 + XEN_PRESENT="0" fi else CONFIG=$HEADERS/../.config @@ -72,12 +82,12 @@ if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]; then MACH_CFLAGS="$MACH_CFLAGS -I$HEADERS/asm-x86/mach-default" fi - if [ "$XEN_PRESENT" != "0" ]; then + if [ "$XEN_PRESENT" == "1" ]; then MACH_CFLAGS="-I$HEADERS/asm-$ARCH/mach-xen $MACH_CFLAGS" fi else MACH_CFLAGS="-I$HEADERS/asm/mach-default" - if [ "$XEN_PRESENT" != "0" ]; then + if [ "$XEN_PRESENT" == "1" ]; then MACH_CFLAGS="-I$HEADERS/asm/mach-xen $MACH_CFLAGS" fi fi @@ -1254,7 +1264,7 @@ exit 0 fi - if [ "$XEN_PRESENT" != "0" ]; then + if [ "$XEN_PRESENT" == "1" ]; then echo "The kernel you are installing for is a Xen kernel!"; echo ""; echo "The NVIDIA driver does not currently work on Xen kernels. If "; @@ -1268,6 +1278,16 @@ echo ""; fi exit 1 + elif [ "$XEN_PRESENT" == "-1" ]; then + echo "You are running kernel in version 2.6.25 or above."; + echo ""; + echo "This kernel can be run both natively or as a Xen kernel."; + echo "However the NVIDIA driver does not currently work on Xen kernels."; + echo ""; + echo "We will continue, but this driver will not work when kernel is"; + echo "run in Xen. You have been warned."; + echo ""; + exit 0 else exit 0 fi diff -U 3 -H -d -r -N -- usr/src/nv/nv-linux.h usr-patched/src/nv/nv-linux.h --- usr/src/nv/nv-linux.h 2008-07-18 03:42:51.000000000 +0200 +++ usr-patched/src/nv/nv-linux.h 2008-08-14 17:07:53.000000000 +0200 @@ -108,7 +108,7 @@ #include #include -#ifdef CONFIG_XEN +#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) && defined(CONFIG_XEN) ) #include #include #endif @@ -144,7 +144,7 @@ #include #endif -#if (defined(NVCPU_X86) || defined(NVCPU_X86_64)) && !defined(CONFIG_XEN) +#if (defined(NVCPU_X86) || defined(NVCPU_X86_64)) && !( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) && defined(CONFIG_XEN) ) #define NV_ENABLE_PAT_SUPPORT #endif @@ -731,7 +731,7 @@ #define NV_TASK_STRUCT_RLIM(current) ((current)->rlim) #endif -#ifdef CONFIG_XEN +#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) && defined(CONFIG_XEN) ) #define NV_GET_DMA_ADDRESS(phys_addr) phys_to_machine(phys_addr) #else #define NV_GET_DMA_ADDRESS(phys_addr) (phys_addr) @@ -888,7 +888,7 @@ #else #error "NV_REMAP_PAGE_RANGE() undefined!" #endif -#if !defined(CONFIG_XEN) +#if !( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) && defined(CONFIG_XEN) ) #define NV_IO_REMAP_PAGE_RANGE(from, offset, x...) \ NV_REMAP_PAGE_RANGE(from, offset, x) #else diff -U 3 -H -d -r -N -- usr/src/nv/nv-vm.c usr-patched/src/nv/nv-vm.c --- usr/src/nv/nv-vm.c 2008-07-18 03:42:50.000000000 +0200 +++ usr-patched/src/nv/nv-vm.c 2008-08-14 17:08:10.000000000 +0200 @@ -346,7 +346,7 @@ static void nv_flush_caches(void) { -#if defined(CONFIG_XEN) +#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) && defined(CONFIG_XEN) ) return; #endif nv_execute_on_all_cpus(cache_flush, NULL); diff -U 3 -H -d -r -N -- usr/src/nv/nv.c usr-patched/src/nv/nv.c --- usr/src/nv/nv.c 2008-07-18 03:42:50.000000000 +0200 +++ usr-patched/src/nv/nv.c 2008-08-14 17:07:21.000000000 +0200 @@ -2040,7 +2040,7 @@ goto failed; } -#if defined(CONFIG_XEN) && defined(NVCPU_X86) +#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) && defined(CONFIG_XEN) ) && defined(NVCPU_X86) if (HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL) > 0xfffff) { nv_printf(NV_DBG_ERRORS, @@ -2063,7 +2063,7 @@ nvl->tasklet.data = (unsigned long) nv; tasklet_enable(&nvl->tasklet); -#if defined(CONFIG_XEN) +#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) && defined(CONFIG_XEN) ) if ((nvl->dev->dma_mask <= 0xffffffff) && (HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL) > 0xfffff)) { @@ -3944,7 +3944,7 @@ U032 config ) { -#if !defined(CONFIG_XEN) +#if !( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) && defined(CONFIG_XEN) ) RM_STATUS status = RM_ERROR; static int old_error = 0; nv_stack_t *sp = NULL; diff -U 3 -H -d -r -N -- usr/src/nv/os-interface.c usr-patched/src/nv/os-interface.c --- usr/src/nv/os-interface.c 2008-07-18 03:42:50.000000000 +0200 +++ usr-patched/src/nv/os-interface.c 2008-08-14 17:08:38.000000000 +0200 @@ -613,7 +613,7 @@ if (jiffies) { // if we have at least 1 full jiffy to wait, give up the cpu -#if !defined(CONFIG_XEN) +#if !( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) && defined(CONFIG_XEN) ) // but first, make sure we haven't raised the irql level on // this cpu (most likely holding a lock). I'm seeing cases // where we give up the cpu with raised irql, and never get @@ -627,7 +627,7 @@ #endif /* give up the cpu */ current->state = TASK_INTERRUPTIBLE; -#if !defined(CONFIG_XEN) +#if !( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) && defined(CONFIG_XEN) ) } else { @@ -1381,7 +1381,7 @@ * If you prefer to manually grant the necessary capability and * adjust the resource limit, disable the lines below. */ -#if !defined(CONFIG_XEN) && !defined(CONFIG_X86_4G) +#if !( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) && defined(CONFIG_XEN) ) && !defined(CONFIG_X86_4G) struct rlimit *rlim = NV_TASK_STRUCT_RLIM(current); rlim[RLIMIT_MEMLOCK].rlim_cur = RLIM_INFINITY; cap_raise(current->cap_effective, CAP_IPC_LOCK);