Package: nvidia-kernel-source
Version: 173.14.09-5.0.hellion1
Severity: wishlist
Tags: patch

The nvidia kernel source is currently patched to remove the Xen special casing
in order to allow it to build and run against a kernel which has both
CONFIG_PARAVIRT=y and CONFIG_XEN=y but is running natively. (I think this was
due to #481485, #482305, #496173 etc)

The kernel team are proposing to enable a patch to support the old-style (i.e.
non-CONFIG_PARAVIRT) CONFIG_XEN in order to regain domain0 and 64 bit support
for Lenny. See http://lists.debian.org/debian-kernel/2008/09/msg00742.html and
http://lists.alioth.debian.org/pipermail/pkg-xen-devel/2008-September/002044.html
This will unfortunately break the compilation of the current nvidia kernel
source against these kernels.

I have updated the xen.patch to support both CONFIG_PARAVIRT-Xen (running Xen)
and Legacy-Xen. I have tested with 2.6.26-1-amd64 (CONFIG_PARAVIRT running on
native, pkg version 2.6.26-5) as well as 2.6.26-1-xen-amd64 (Legacy-Xen,
running as a Xen domain 0, pkg version 2.6.26-7~snapshot.12252) and
2.6.18.8-xen (Legacy-Xen, running as a Xen domain 0, my own build). I also
build tested against 2.6.26-1-686 but can't reboot that machine at the moment
since it's running a long running test.

I've filed this bug as a wishlist preemptively before the kernel is uploaded,
once the kernel goes in presumably the priority will increase.

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-1-xen-amd64 (SMP w/1 CPU core)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages nvidia-kernel-source depends on:
ii  debhelper                     7.0.17     helper programs for debian/rules
ii  dpatch                        2.0.30     patch maintenance system for Debia
ii  make                          3.81-5     The GNU version of the "make" util
ii  sed                           4.1.5-8    The GNU sed stream editor

Versions of packages nvidia-kernel-source recommends:
ii  devscripts                   2.10.35     scripts to make the life of a Debi
ii  kernel-package               11.001-0.1  A utility for building Linux kerne
ii  nvidia-glx                   173.14.09-5 NVIDIA binary Xorg driver

nvidia-kernel-source suggests no packages.

-- no debconf information
diff -x debian -x Module.symvers -x modules.order -x runtest -X /home/ijc/development/dontdiff.txt -purN usr/src/nv/conftest.sh usr/src/nv/conftest.sh
--- usr/src/nv/conftest.sh	2008-09-25 18:01:04.000000000 +0100
+++ usr/src/nv/conftest.sh	2008-09-25 18:08:37.000000000 +0100
@@ -31,7 +31,7 @@ test_xen() {
         # that it's not a Xen kernel.
         #
         echo "#include <linux/autoconf.h>
-        #ifdef CONFIG_XEN
+        #if defined(CONFIG_XEN) && !defined(CONFIG_PARAVIRT)
         #error CONFIG_XEN defined!
         #endif
         " > conftest$$.c
@@ -46,7 +46,7 @@ test_xen() {
     else
         CONFIG=$HEADERS/../.config
         if [ -f $CONFIG ]; then
-            if [ -z "$(grep "^CONFIG_XEN=y" $CONFIG)" ]; then
+            if [ -z "$(grep "^CONFIG_XEN=y" $CONFIG)" ] || [ -z $(grep "^CONFIG_PARAVIRT=y" /boot/config-2.6.26-1-xen-amd64 ) ]; then
                 XEN_PRESENT="0"
             fi
         fi
@@ -74,6 +74,7 @@ build_cflags() {
         fi
         if [ "$XEN_PRESENT" != "0" ]; then
             MACH_CFLAGS="-I$HEADERS/asm-$ARCH/mach-xen $MACH_CFLAGS"
+            MACH_CFLAGS="-I$HEADERS/asm-x86/mach-xen $MACH_CFLAGS"
         fi
     else
         MACH_CFLAGS="-I$HEADERS/asm/mach-default"
@@ -1244,33 +1245,7 @@ case "$5" in
     ;;
 
     xen_sanity_check)
-        #
-        # Check if the target kernel is a Xen kernel. If so, then exit, since
-        # the driver doesn't currently work with Xen.
-        #
-        VERBOSE=$6
-
-        if [ -n "$IGNORE_XEN_PRESENCE" ]; then
-            exit 0
-        fi
-
-        if [ "$XEN_PRESENT" != "0" ]; 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 ";
-            echo "you are using a stock distribution kernel, please install ";
-            echo "a variant of this kernel without Xen support; if this is a ";
-            echo "custom kernel, please install a standard Linux kernel.  Then ";
-            echo "try installing the NVIDIA kernel module again.";
-            echo "";
-            if [ "$VERBOSE" = "full_output" ]; then
-                echo "*** Failed Xen sanity check. Bailing out! ***";
-                echo "";
-            fi
-            exit 1
-        else
-            exit 0
-        fi
+        exit 0
     ;;
 
     compile_tests)
diff -x debian -x Module.symvers -x modules.order -x runtest -X /home/ijc/development/dontdiff.txt -purN usr/src/nv/nv.c usr/src/nv/nv.c
--- usr/src/nv/nv.c	2008-09-25 18:01:04.000000000 +0100
+++ usr/src/nv/nv.c	2008-09-25 18:09:31.000000000 +0100
@@ -2040,7 +2040,7 @@ int nv_kern_open(
             goto failed;
         }
 
-#if defined(CONFIG_XEN) && defined(NVCPU_X86)
+#if defined(NV_LEGACY_XEN) && defined(NVCPU_X86)
         if (HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL) > 0xfffff)
         {
             nv_printf(NV_DBG_ERRORS,
@@ -2063,7 +2063,7 @@ int nv_kern_open(
         nvl->tasklet.data = (unsigned long) nv;
         tasklet_enable(&nvl->tasklet);
 
-#if defined(CONFIG_XEN)
+#if defined(NV_LEGACY_XEN)
         if ((nvl->dev->dma_mask <= 0xffffffff) &&
             (HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL) > 0xfffff))
         {
@@ -3944,7 +3944,7 @@ RM_STATUS NV_API_CALL nv_agp_init(
     U032         config
 )
 {
-#if !defined(CONFIG_XEN)
+#if !defined(NV_LEGACY_XEN)
     RM_STATUS status = RM_ERROR;
     static int old_error = 0;
     nv_stack_t *sp = NULL;
diff -x debian -x Module.symvers -x modules.order -x runtest -X /home/ijc/development/dontdiff.txt -purN usr/src/nv/nv-linux.h usr/src/nv/nv-linux.h
--- usr/src/nv/nv-linux.h	2008-09-25 18:01:04.000000000 +0100
+++ usr/src/nv/nv-linux.h	2008-09-25 18:09:31.000000000 +0100
@@ -108,7 +108,11 @@
 #include <linux/completion.h>
 #include <linux/highmem.h>
 
-#ifdef CONFIG_XEN
+#if defined(CONFIG_XEN) && !defined(CONFIG_PARAVIRT)
+#define NV_LEGACY_XEN 1
+#endif
+
+#ifdef NV_LEGACY_XEN
 #include <asm/maddr.h>
 #include <xen/interface/memory.h>
 #endif
@@ -144,7 +148,7 @@
 #include <linux/agpgart.h>
 #endif
 
-#if (defined(NVCPU_X86) || defined(NVCPU_X86_64)) && !defined(CONFIG_XEN)
+#if (defined(NVCPU_X86) || defined(NVCPU_X86_64)) && !defined(NV_LEGACY_XEN)
 #define NV_ENABLE_PAT_SUPPORT
 #endif
 
@@ -727,7 +731,7 @@ static inline int nv_execute_on_all_cpus
 #define NV_TASK_STRUCT_RLIM(current)  ((current)->rlim)
 #endif
 
-#ifdef CONFIG_XEN
+#ifdef NV_LEGACY_XEN
 #define NV_GET_DMA_ADDRESS(phys_addr) phys_to_machine(phys_addr)
 #else
 #define NV_GET_DMA_ADDRESS(phys_addr) (phys_addr)
@@ -884,7 +888,7 @@ typedef void irqreturn_t;
 #else
 #error "NV_REMAP_PAGE_RANGE() undefined!"
 #endif
-#if !defined(CONFIG_XEN)
+#if !defined(NV_LEGACY_XEN)
 #define NV_IO_REMAP_PAGE_RANGE(from, offset, x...) \
     NV_REMAP_PAGE_RANGE(from, offset, x)
 #else
diff -x debian -x Module.symvers -x modules.order -x runtest -X /home/ijc/development/dontdiff.txt -purN usr/src/nv/nv-vm.c usr/src/nv/nv-vm.c
--- usr/src/nv/nv-vm.c	2008-09-25 18:01:04.000000000 +0100
+++ usr/src/nv/nv-vm.c	2008-09-25 18:09:31.000000000 +0100
@@ -312,7 +312,7 @@ static inline void nv_sg_unmap_buffer(
 #endif
 
 #if (defined(KERNEL_2_4) || defined(NV_CPA_DF_LIST_BUG) || \
-  (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20))) && !defined(CONFIG_XEN)
+  (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20))) && !defined(NV_LEGACY_XEN)
 #define NV_CPA_NEEDS_FLUSHING 1
 #endif
 
diff -x debian -x Module.symvers -x modules.order -x runtest -X /home/ijc/development/dontdiff.txt -purN usr/src/nv/os-interface.c usr/src/nv/os-interface.c
--- usr/src/nv/os-interface.c	2008-09-25 18:01:04.000000000 +0100
+++ usr/src/nv/os-interface.c	2008-09-25 18:09:31.000000000 +0100
@@ -609,7 +609,7 @@ RM_STATUS NV_API_CALL os_delay(U032 Mill
     if (jiffies) 
     {
         // if we have at least 1 full jiffy to wait, give up the cpu
-#if !defined(CONFIG_XEN)
+#if !defined(NV_LEGACY_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
@@ -623,7 +623,7 @@ RM_STATUS NV_API_CALL os_delay(U032 Mill
 #endif
             /* give up the cpu */
             current->state = TASK_INTERRUPTIBLE;
-#if !defined(CONFIG_XEN)
+#if !defined(NV_LEGACY_XEN)
         }
         else
         {
@@ -1377,7 +1377,7 @@ RM_STATUS NV_API_CALL os_set_mlock_capab
      * 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 !defined(NV_LEGACY_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);

Reply via email to