logo

overlay

Personnal gentoo overlay
commit: 7a56a857154cc0edfc199d869858a23f4c661465
parent: 0339bf3b1a04013a5d285d2dfaffbc59f6b948b1
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 30 Sep 2016 02:08:37 +0200

x11-drivers/nvidia-drivers: Import from gentoo repo

Diffstat:

x11-drivers/nvidia-drivers/files/50nvidia-prelink-blacklist | 1+
x11-drivers/nvidia-drivers/files/95-nvidia-settings | 2++
x11-drivers/nvidia-drivers/files/95-nvidia-settings-r1 | 2++
x11-drivers/nvidia-drivers/files/NVIDIA_glx-defines.patch | 11+++++++++++
x11-drivers/nvidia-drivers/files/NVIDIA_glx-glheader.patch | 13+++++++++++++
x11-drivers/nvidia-drivers/files/nvidia-169.07 | 14++++++++++++++
x11-drivers/nvidia-drivers/files/nvidia-drivers-331.13-pax-usercopy.patch | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
x11-drivers/nvidia-drivers/files/nvidia-drivers-337.12-pax-constify.patch | 25+++++++++++++++++++++++++
x11-drivers/nvidia-drivers/files/nvidia-drivers-346.16-pax-constify.patch | 25+++++++++++++++++++++++++
x11-drivers/nvidia-drivers/files/nvidia-drivers-346.16-pax-usercopy.patch | 47+++++++++++++++++++++++++++++++++++++++++++++++
x11-drivers/nvidia-drivers/files/nvidia-drivers-355.06-pax.patch | 102+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
x11-drivers/nvidia-drivers/files/nvidia-drivers-361.28-pax.patch | 351+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
x11-drivers/nvidia-drivers/files/nvidia-drivers-364.12-pax.patch | 398+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
x11-drivers/nvidia-drivers/files/nvidia-drivers-367.35-profiles-rc.patch | 11+++++++++++
x11-drivers/nvidia-drivers/files/nvidia-drivers-367.44-profiles-rc.patch | 11+++++++++++
x11-drivers/nvidia-drivers/files/nvidia-drivers-370.28-profiles-rc.patch | 11+++++++++++
x11-drivers/nvidia-drivers/files/nvidia-drivers-pax-const.patch | 17+++++++++++++++++
x11-drivers/nvidia-drivers/files/nvidia-drivers-pax-usercopy.patch | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
x11-drivers/nvidia-drivers/files/nvidia-drivers-settings.desktop | 7+++++++
x11-drivers/nvidia-drivers/files/nvidia-persistenced.conf | 8++++++++
x11-drivers/nvidia-drivers/files/nvidia-persistenced.init | 25+++++++++++++++++++++++++
x11-drivers/nvidia-drivers/files/nvidia-rmmod.conf | 3+++
x11-drivers/nvidia-drivers/files/nvidia-settings.desktop | 7+++++++
x11-drivers/nvidia-drivers/files/nvidia-smi.init | 25+++++++++++++++++++++++++
x11-drivers/nvidia-drivers/files/nvidia-udev.sh | 17+++++++++++++++++
x11-drivers/nvidia-drivers/files/nvidia-udev.sh-r1 | 20++++++++++++++++++++
x11-drivers/nvidia-drivers/files/nvidia-uvm.conf | 3+++
x11-drivers/nvidia-drivers/files/nvidia.udev-rule | 6++++++
x11-drivers/nvidia-drivers/nvidia-drivers-370.28.ebuild | 552+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
29 files changed, 1820 insertions(+), 0 deletions(-)

diff --git a/x11-drivers/nvidia-drivers/files/50nvidia-prelink-blacklist b/x11-drivers/nvidia-drivers/files/50nvidia-prelink-blacklist @@ -0,0 +1 @@ +PRELINK_PATH_MASK="/usr/lib{,64}/tls/libnvidia-tls*:/usr/lib{,64}/libnvidia*:/usr/lib{,64}/libGL*:/usr/lib{,64}/opengl/nvidia/*:/usr/lib{,64}/OpenCL/vendors/nvidia/*:/usr/lib{,64}/xorg/modules/drivers/nvidia*:/usr/lib{,64}/libvdpau_nvidia*:/usr/lib{,64}/libXvMCNVIDIA*:/usr/lib{,64}/libcuda*:/usr/lib{,64}/libnvcuvid*" diff --git a/x11-drivers/nvidia-drivers/files/95-nvidia-settings b/x11-drivers/nvidia-drivers/files/95-nvidia-settings @@ -0,0 +1,2 @@ +#!/bin/sh +/opt/bin/nvidia-settings --load-config-only diff --git a/x11-drivers/nvidia-drivers/files/95-nvidia-settings-r1 b/x11-drivers/nvidia-drivers/files/95-nvidia-settings-r1 @@ -0,0 +1,2 @@ +#!/bin/sh +/usr/bin/nvidia-settings --load-config-only diff --git a/x11-drivers/nvidia-drivers/files/NVIDIA_glx-defines.patch b/x11-drivers/nvidia-drivers/files/NVIDIA_glx-defines.patch @@ -0,0 +1,11 @@ +diff -ur NVIDIA_GLX-1.0-4191/usr/include/GL/glx.h NVIDIA_GLX-1.0-4191.new/usr/include/GL/glx.h +--- NVIDIA_GLX-1.0-4191/usr/include/GL/glx.h 2002-12-09 21:26:55.000000000 +0100 ++++ NVIDIA_GLX-1.0-4191.new/usr/include/GL/glx.h 2003-01-30 18:20:23.000000000 +0100 +@@ -39,6 +39,7 @@ + typedef XID GLXPixmap; + typedef XID GLXDrawable; + typedef XID GLXPbuffer; ++typedef XID GLXPbufferSGIX; + typedef XID GLXWindow; + typedef XID GLXFBConfigID; + diff --git a/x11-drivers/nvidia-drivers/files/NVIDIA_glx-glheader.patch b/x11-drivers/nvidia-drivers/files/NVIDIA_glx-glheader.patch @@ -0,0 +1,13 @@ +--- usr/include/GL/gl.g.orig 2004-07-17 19:56:59.789410584 +1000 ++++ usr/include/GL/gl.h 2004-07-17 19:59:08.844791184 +1000 +@@ -66,6 +66,10 @@ + typedef double GLclampd; + typedef void GLvoid; + ++/* Patching for some better defines in the global system */ ++#ifndef GL_GLEXT_LEGACY ++#include <GL/glext.h> ++#endif + + /*************************************************************/ + diff --git a/x11-drivers/nvidia-drivers/files/nvidia-169.07 b/x11-drivers/nvidia-drivers/files/nvidia-169.07 @@ -0,0 +1,14 @@ +# Nvidia drivers support +alias char-major-195 nvidia +alias /dev/nvidiactl char-major-195 + +# To tweak the driver the following options can be used, note that +# you should be careful, as it could cause instability!! For more +# options see /usr/share/doc/PACKAGE/README +# +# !!! SECURITY WARNING !!! +# DO NOT MODIFY OR REMOVE THE DEVICE FILE RELATED OPTIONS UNLESS YOU KNOW +# WHAT YOU ARE DOING. +# ONLY ADD TRUSTED USERS TO THE VIDEO GROUP, THESE USERS MAY BE ABLE TO CRASH, +# COMPROMISE, OR IRREPARABLY DAMAGE THE MACHINE. +options nvidia NVreg_DeviceFileMode=432 NVreg_DeviceFileUID=0 NVreg_DeviceFileGID=VIDEOGID NVreg_ModifyDeviceFiles=1 diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-331.13-pax-usercopy.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-331.13-pax-usercopy.patch @@ -0,0 +1,52 @@ +--- a/kernel/nv-linux.h ++++ b/kernel/nv-linux.h +@@ -757,16 +757,16 @@ + + #if defined(NV_KMEM_CACHE_CREATE_PRESENT) + #if (NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT == 6) +-#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type) \ ++#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type, flags) \ + { \ + kmem_cache = kmem_cache_create(name, sizeof(type), \ +- 0, 0, NULL, NULL); \ ++ 0, flags, NULL, NULL); \ + } + #elif (NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT == 5) +-#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type) \ ++#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type, flags) \ + { \ + kmem_cache = kmem_cache_create(name, sizeof(type), \ +- 0, 0, NULL); \ ++ 0, flags, NULL); \ + } + #else + #error "NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT value unrecognized!" +--- a/kernel/nv.c ++++ b/kernel/nv.c +@@ -794,7 +794,7 @@ + NV_SPIN_LOCK_INIT(&km_lock); + #endif + +- NV_KMEM_CACHE_CREATE(nv_stack_t_cache, NV_STACK_CACHE_STR, nv_stack_t); ++ NV_KMEM_CACHE_CREATE(nv_stack_t_cache, NV_STACK_CACHE_STR, nv_stack_t, SLAB_USERCOPY); + if (nv_stack_t_cache == NULL) + { + nv_printf(NV_DBG_ERRORS, "NVRM: stack cache allocation failed!\n"); +@@ -924,7 +924,7 @@ + nv->os_state = (void *) &nv_ctl_device; + nv_lock_init_locks(nv); + +- NV_KMEM_CACHE_CREATE(nv_pte_t_cache, NV_PTE_CACHE_STR, nv_pte_t); ++ NV_KMEM_CACHE_CREATE(nv_pte_t_cache, NV_PTE_CACHE_STR, nv_pte_t, 0); + if (nv_pte_t_cache == NULL) + { + rc = -ENOMEM; +@@ -935,7 +935,7 @@ + if (NV_BUILD_MODULE_INSTANCES == 0) + { + NV_KMEM_CACHE_CREATE(nvidia_p2p_page_t_cache, "nvidia_p2p_page_t", +- nvidia_p2p_page_t); ++ nvidia_p2p_page_t, 0); + if (nvidia_p2p_page_t_cache == NULL) + { + rc = -ENOMEM; diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-337.12-pax-constify.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-337.12-pax-constify.patch @@ -0,0 +1,25 @@ +--- a/kernel/uvm/nvidia_uvm_common.c ++++ b/kernel/uvm/nvidia_uvm_common.c +@@ -95,7 +95,6 @@ static RM_STATUS uvmnext_gpu_event_stop_ + #endif // NVIDIA_UVM_NEXT_ENABLED + + static dev_t g_uvmBaseDev; +-struct UvmOpsUvmEvents g_exportedUvmOps; + + // TODO: This would be easier if RM allowed for multiple registrations, since we + // could register UVM-Lite and UVM-Next separately (bug 1372835). +@@ -147,9 +146,11 @@ static RM_STATUS uvmSetupGpuProvider(voi + RM_STATUS status = RM_OK; + + #ifdef NVIDIA_UVM_RM_ENABLED +- g_exportedUvmOps.startDevice = uvm_gpu_event_start_device; +- g_exportedUvmOps.stopDevice = uvm_gpu_event_stop_device; +- g_exportedUvmOps.isrTopHalf = uvmnext_isr_top_half; ++ static struct UvmOpsUvmEvents g_exportedUvmOps = { ++ .startDevice = uvm_gpu_event_start_device, ++ .stopDevice = uvm_gpu_event_stop_device, ++ .isrTopHalf = uvmnext_isr_top_half, ++ }; + + // call RM to exchange the function pointers. + status = nvUvmInterfaceRegisterUvmCallbacks(&g_exportedUvmOps); diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-346.16-pax-constify.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-346.16-pax-constify.patch @@ -0,0 +1,25 @@ +--- a/kernel/uvm/uvm_common.c ++++ b/kernel/uvm/uvm_common.c +@@ -95,7 +95,6 @@ static RM_STATUS uvmnext_gpu_event_stop_ + #endif // NVIDIA_UVM_NEXT_ENABLED + + static dev_t g_uvmBaseDev; +-struct UvmOpsUvmEvents g_exportedUvmOps; + + // TODO: This would be easier if RM allowed for multiple registrations, since we + // could register UVM-Lite and UVM-Next separately (bug 1372835). +@@ -147,9 +146,11 @@ static RM_STATUS uvmSetupGpuProvider(voi + RM_STATUS status = RM_OK; + + #ifdef NVIDIA_UVM_RM_ENABLED +- g_exportedUvmOps.startDevice = uvm_gpu_event_start_device; +- g_exportedUvmOps.stopDevice = uvm_gpu_event_stop_device; +- g_exportedUvmOps.isrTopHalf = uvmnext_isr_top_half; ++ static struct UvmOpsUvmEvents g_exportedUvmOps = { ++ .startDevice = uvm_gpu_event_start_device, ++ .stopDevice = uvm_gpu_event_stop_device, ++ .isrTopHalf = uvmnext_isr_top_half, ++ }; + + // call RM to exchange the function pointers. + status = nvUvmInterfaceRegisterUvmCallbacks(&g_exportedUvmOps); diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-346.16-pax-usercopy.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-346.16-pax-usercopy.patch @@ -0,0 +1,47 @@ +--- a/kernel/nv.c ++++ b/kernel/nv.c +@@ -705,7 +705,7 @@ int __init nvidia_init_module(void) + #endif + + nvidia_stack_t_cache = NV_KMEM_CACHE_CREATE(nvidia_stack_cache_name, +- nvidia_stack_t); ++ nvidia_stack_t, SLAB_USERCOPY); + if (nvidia_stack_t_cache == NULL) + { + nv_printf(NV_DBG_ERRORS, "NVRM: stack cache allocation failed!\n"); +@@ -846,7 +846,7 @@ int __init nvidia_init_module(void) + nv_lock_init_locks(nv); + + nvidia_pte_t_cache = NV_KMEM_CACHE_CREATE(nvidia_pte_cache_name, +- nvidia_pte_t); ++ nvidia_pte_t, 0); + if (nvidia_pte_t_cache == NULL) + { + rc = -ENOMEM; +@@ -857,7 +857,7 @@ int __init nvidia_init_module(void) + if (!nv_multiple_kernel_modules) + { + nvidia_p2p_page_t_cache = NV_KMEM_CACHE_CREATE(nvidia_p2p_page_cache_name, +- nvidia_p2p_page_t); ++ nvidia_p2p_page_t, 0); + if (nvidia_p2p_page_t_cache == NULL) + { + rc = -ENOMEM; +--- a/kernel/nv-linux.h ++++ b/kernel/nv-linux.h +@@ -1431,11 +1431,11 @@ extern void *nvidia_stack_t_cache; + + #if !defined(NV_VMWARE) + #if (NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT == 5) +-#define NV_KMEM_CACHE_CREATE(name, type) \ +- kmem_cache_create(name, sizeof(type), 0, 0, NULL) ++#define NV_KMEM_CACHE_CREATE(name, type, flags) \ ++ kmem_cache_create(name, sizeof(type), 0, flags, NULL) + #else +-#define NV_KMEM_CACHE_CREATE(name, type) \ +- kmem_cache_create(name, sizeof(type), 0, 0, NULL, \ ++#define NV_KMEM_CACHE_CREATE(name, type, flags) \ ++ kmem_cache_create(name, sizeof(type), 0, flags, NULL, \ + NULL) + #endif + #define NV_KMEM_CACHE_DESTROY(kmem_cache) \ diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-355.06-pax.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-355.06-pax.patch @@ -0,0 +1,102 @@ +diff -urp NVIDIA-Linux-x86_64-355.06.orig/kernel/common/inc/nv-linux.h NVIDIA-Linux-x86_64-355.06/kernel/common/inc/nv-linux.h +--- NVIDIA-Linux-x86_64-355.06.orig/kernel/common/inc/nv-linux.h 2015-07-29 05:13:57.000000000 +0200 ++++ NVIDIA-Linux-x86_64-355.06/kernel/common/inc/nv-linux.h 2015-08-21 16:45:55.624336728 +0200 +@@ -1408,11 +1408,11 @@ extern void *nvidia_stack_t_cache; + + #if !defined(NV_VMWARE) + #if (NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT == 5) +-#define NV_KMEM_CACHE_CREATE(name, type) \ +- kmem_cache_create(name, sizeof(type), 0, 0, NULL) ++#define NV_KMEM_CACHE_CREATE(name, type, flags) \ ++ kmem_cache_create(name, sizeof(type), 0, flags, NULL) + #else +-#define NV_KMEM_CACHE_CREATE(name, type) \ +- kmem_cache_create(name, sizeof(type), 0, 0, NULL, \ ++#define NV_KMEM_CACHE_CREATE(name, type, flags) \ ++ kmem_cache_create(name, sizeof(type), 0, flags, NULL, \ + NULL) + #endif + #define NV_KMEM_CACHE_DESTROY(kmem_cache) \ +diff -urp NVIDIA-Linux-x86_64-355.06.orig/kernel/nvidia/nv.c NVIDIA-Linux-x86_64-355.06/kernel/nvidia/nv.c +--- NVIDIA-Linux-x86_64-355.06.orig/kernel/nvidia/nv.c 2015-07-29 05:13:57.000000000 +0200 ++++ NVIDIA-Linux-x86_64-355.06/kernel/nvidia/nv.c 2015-08-21 16:44:51.008340178 +0200 +@@ -719,7 +719,7 @@ int __init nvidia_init_module(void) + #endif + + nvidia_stack_t_cache = NV_KMEM_CACHE_CREATE(nvidia_stack_cache_name, +- nvidia_stack_t); ++ nvidia_stack_t, SLAB_USERCOPY); + if (nvidia_stack_t_cache == NULL) + { + nv_printf(NV_DBG_ERRORS, "NVRM: stack cache allocation failed!\n"); +@@ -861,7 +861,7 @@ int __init nvidia_init_module(void) + nv_state_init_gpu_uuid_cache(nv); + + nvidia_pte_t_cache = NV_KMEM_CACHE_CREATE(nvidia_pte_cache_name, +- nvidia_pte_t); ++ nvidia_pte_t, 0); + if (nvidia_pte_t_cache == NULL) + { + rc = -ENOMEM; +@@ -872,7 +872,7 @@ int __init nvidia_init_module(void) + if (!nv_multiple_kernel_modules) + { + nvidia_p2p_page_t_cache = NV_KMEM_CACHE_CREATE(nvidia_p2p_page_cache_name, +- nvidia_p2p_page_t); ++ nvidia_p2p_page_t, 0); + if (nvidia_p2p_page_t_cache == NULL) + { + rc = -ENOMEM; +diff -urp NVIDIA-Linux-x86_64-355.06.orig/kernel/nvidia/nv-mmap.c NVIDIA-Linux-x86_64-355.06/kernel/nvidia/nv-mmap.c +--- NVIDIA-Linux-x86_64-355.06.orig/kernel/nvidia/nv-mmap.c 2015-07-29 05:13:57.000000000 +0200 ++++ NVIDIA-Linux-x86_64-355.06/kernel/nvidia/nv-mmap.c 2015-08-21 16:58:15.968297199 +0200 +@@ -113,12 +113,12 @@ nvidia_vma_release(struct vm_area_struct + } + + #if defined(NV_VM_OPERATIONS_STRUCT_HAS_ACCESS) +-static int ++static ssize_t + nvidia_vma_access( + struct vm_area_struct *vma, + unsigned long addr, + void *buffer, +- int length, ++ size_t length, + int write + ) + { +diff -urp NVIDIA-Linux-x86_64-355.06.orig/kernel/nvidia-uvm/uvm_common.c NVIDIA-Linux-x86_64-355.06/kernel/nvidia-uvm/uvm_common.c +--- NVIDIA-Linux-x86_64-355.06.orig/kernel/nvidia-uvm/uvm_common.c 2015-07-29 05:10:08.000000000 +0200 ++++ NVIDIA-Linux-x86_64-355.06/kernel/nvidia-uvm/uvm_common.c 2015-08-21 17:00:33.788289841 +0200 +@@ -60,7 +60,7 @@ static void uvmnext_exit(void) + { + + } +-static NV_STATUS uvmnext_isr_top_half(void) ++static NV_STATUS uvmnext_isr_top_half(UvmGpuUuid *gpuUuidStruct) + { + return NV_ERR_NO_INTR_PENDING; + } +@@ -79,7 +79,6 @@ NvBool uvmnext_activated(void) + #endif // NVIDIA_UVM_NEXT_ENABLED + + static dev_t g_uvmBaseDev; +-struct UvmOpsUvmEvents g_exportedUvmOps; + + // TODO: This would be easier if RM allowed for multiple registrations, since we + // could register UVM-Lite and UVM-Next separately (bug 1372835). +@@ -112,9 +111,11 @@ static NV_STATUS uvmSetupGpuProvider(voi + NV_STATUS status = NV_OK; + + #ifdef NVIDIA_UVM_RM_ENABLED +- g_exportedUvmOps.startDevice = uvm_gpu_event_start_device; +- g_exportedUvmOps.stopDevice = uvm_gpu_event_stop_device; +- g_exportedUvmOps.isrTopHalf = uvmnext_isr_top_half; ++ static struct UvmOpsUvmEvents g_exportedUvmOps = { ++ .startDevice = uvm_gpu_event_start_device, ++ .stopDevice = uvm_gpu_event_stop_device, ++ .isrTopHalf = uvmnext_isr_top_half, ++ }; + + // call RM to exchange the function pointers. + status = nvUvmInterfaceRegisterUvmCallbacks(&g_exportedUvmOps); diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-361.28-pax.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-361.28-pax.patch @@ -0,0 +1,351 @@ +diff -urp work.orig/kernel/common/inc/nv-linux.h work/kernel/common/inc/nv-linux.h +--- work.orig/kernel/common/inc/nv-linux.h 2016-02-03 23:31:51.000000000 +0100 ++++ work/kernel/common/inc/nv-linux.h 2016-02-10 11:49:15.309410457 +0100 +@@ -1351,6 +1351,9 @@ extern void *nvidia_stack_t_cache; + #define NV_KMEM_CACHE_CREATE(name, type) \ + NV_KMEM_CACHE_CREATE_FULL(name, sizeof(type), 0, 0, NULL) + ++#define NV_KMEM_CACHE_CREATE_USERCOPY(name, type) \ ++ NV_KMEM_CACHE_CREATE_FULL(name, sizeof(type), 0, SLAB_USERCOPY, NULL) ++ + #define NV_KMEM_CACHE_DESTROY(kmem_cache) \ + kmem_cache_destroy(kmem_cache) + +diff -urp work.orig/kernel/common/inc/nv-modeset-interface.h work/kernel/common/inc/nv-modeset-interface.h +--- work.orig/kernel/common/inc/nv-modeset-interface.h 2016-02-03 23:31:51.000000000 +0100 ++++ work/kernel/common/inc/nv-modeset-interface.h 2016-02-10 11:49:54.970985152 +0100 +@@ -70,7 +70,7 @@ typedef struct { + * mix nvidia and nvidia-modeset kernel modules from different + * releases. + */ +- const char *version_string; ++// const char *version_string; + + /* + * Allocate and free an nvidia_stack_t to pass into +@@ -104,6 +104,6 @@ typedef struct { + + } nvidia_modeset_rm_ops_t; + +-NV_STATUS nvidia_get_rm_ops(nvidia_modeset_rm_ops_t *rm_ops); ++NV_STATUS nvidia_get_rm_ops(const nvidia_modeset_rm_ops_t **rm_ops, const char **version_string); + + #endif /* _NV_MODESET_INTERFACE_H_ */ +diff -urp work.orig/kernel/common/inc/nv-register-module.h work/kernel/common/inc/nv-register-module.h +--- work.orig/kernel/common/inc/nv-register-module.h 2016-02-03 23:31:51.000000000 +0100 ++++ work/kernel/common/inc/nv-register-module.h 2016-02-10 11:50:18.941376865 +0100 +@@ -34,7 +34,7 @@ typedef struct nvidia_module_s { + int (*ioctl)(struct inode *, struct file * file, unsigned int cmd, unsigned long arg); + unsigned int (*poll)(struct file * file, poll_table *wait); + +-} nvidia_module_t; ++} __do_const nvidia_module_t; + + int nvidia_register_module(nvidia_module_t *); + int nvidia_unregister_module(nvidia_module_t *); +diff -urp work.orig/kernel/nvidia/nv.c work/kernel/nvidia/nv.c +--- work.orig/kernel/nvidia/nv.c 2016-02-03 23:31:51.000000000 +0100 ++++ work/kernel/nvidia/nv.c 2016-02-10 11:50:40.191828792 +0100 +@@ -704,7 +704,7 @@ int __init nvidia_init_module(void) + NV_SPIN_LOCK_INIT(&km_lock); + #endif + +- nvidia_stack_t_cache = NV_KMEM_CACHE_CREATE(nvidia_stack_cache_name, ++ nvidia_stack_t_cache = NV_KMEM_CACHE_CREATE_USERCOPY(nvidia_stack_cache_name, + nvidia_stack_t); + if (nvidia_stack_t_cache == NULL) + { +diff -urp work.orig/kernel/nvidia/nv-chrdev.c work/kernel/nvidia/nv-chrdev.c +--- work.orig/kernel/nvidia/nv-chrdev.c 2016-02-03 23:31:51.000000000 +0100 ++++ work/kernel/nvidia/nv-chrdev.c 2016-02-10 11:50:57.201126955 +0100 +@@ -20,8 +20,6 @@ int nv_register_chrdev(void *param) + { + nvidia_module_t *module = (nvidia_module_t *)param; + +- module->instance = nv_module_instance; +- + return (nvidia_register_module(module)); + } + +diff -urp work.orig/kernel/nvidia/nv-instance.c work/kernel/nvidia/nv-instance.c +--- work.orig/kernel/nvidia/nv-instance.c 2016-02-03 23:31:51.000000000 +0100 ++++ work/kernel/nvidia/nv-instance.c 2016-02-10 11:51:35.418977554 +0100 +@@ -54,6 +54,7 @@ struct pci_driver nv_pci_driver = { + nvidia_module_t nv_fops = { + .owner = THIS_MODULE, + .module_name = MODULE_NAME, ++ .instance = MODULE_INSTANCE_NUMBER, + .open = nvidia_open, + .close = nvidia_close, + .ioctl = nvidia_ioctl, +diff -urp work.orig/kernel/nvidia/nv-mmap.c work/kernel/nvidia/nv-mmap.c +--- work.orig/kernel/nvidia/nv-mmap.c 2016-02-03 23:31:51.000000000 +0100 ++++ work/kernel/nvidia/nv-mmap.c 2016-02-10 11:14:27.996577127 +0100 +@@ -113,12 +113,12 @@ nvidia_vma_release(struct vm_area_struct + } + + #if defined(NV_VM_OPERATIONS_STRUCT_HAS_ACCESS) +-static int ++static ssize_t + nvidia_vma_access( + struct vm_area_struct *vma, + unsigned long addr, + void *buffer, +- int length, ++ size_t length, + int write + ) + { +diff -urp work.orig/kernel/nvidia/nv-modeset-interface.c work/kernel/nvidia/nv-modeset-interface.c +--- work.orig/kernel/nvidia/nv-modeset-interface.c 2016-02-03 23:31:51.000000000 +0100 ++++ work/kernel/nvidia/nv-modeset-interface.c 2016-02-10 12:05:23.822391866 +0100 +@@ -59,10 +59,9 @@ void nvidia_modeset_resume(NvU32 gpuId) + } + } + +-NV_STATUS nvidia_get_rm_ops(nvidia_modeset_rm_ops_t *rm_ops) ++NV_STATUS nvidia_get_rm_ops(const nvidia_modeset_rm_ops_t **rm_ops, const char **version_string) + { +- const nvidia_modeset_rm_ops_t local_rm_ops = { +- .version_string = NV_VERSION_STRING, ++ static const nvidia_modeset_rm_ops_t local_rm_ops = { + .alloc_stack = nvidia_modeset_rm_ops_alloc_stack, + .free_stack = nvidia_modeset_rm_ops_free_stack, + .get_gpuid_list = nvidia_get_gpuid_list, +@@ -72,13 +71,13 @@ NV_STATUS nvidia_get_rm_ops(nvidia_modes + .set_callbacks = nvidia_modeset_set_callbacks, + }; + +- if (strcmp(rm_ops->version_string, NV_VERSION_STRING) != 0) ++ if (strcmp(*version_string, NV_VERSION_STRING) != 0) + { +- rm_ops->version_string = NV_VERSION_STRING; ++ *version_string = NV_VERSION_STRING; + return NV_ERR_GENERIC; + } + +- *rm_ops = local_rm_ops; ++ *rm_ops = &local_rm_ops; + + return NV_OK; + } +diff -urp work.orig/kernel/nvidia-modeset/nvidia-modeset-linux.c work/kernel/nvidia-modeset/nvidia-modeset-linux.c +--- work.orig/kernel/nvidia-modeset/nvidia-modeset-linux.c 2016-02-03 23:32:20.000000000 +0100 ++++ work/kernel/nvidia-modeset/nvidia-modeset-linux.c 2016-02-10 12:08:02.275059160 +0100 +@@ -320,49 +320,48 @@ static void nvkms_resume(NvU32 gpuId) + * so we can use a single nvidia_modeset_stack_ptr for calling RM. + *************************************************************************/ + +-static nvidia_modeset_rm_ops_t __rm_ops = { 0 }; ++static const nvidia_modeset_rm_ops_t *__rm_ops; + static nvidia_modeset_stack_ptr nvkms_nvidia_stack = NULL; + static nvidia_modeset_callbacks_t nvkms_rm_callbacks = { +- nvkms_suspend, +- nvkms_resume ++ .suspend = nvkms_suspend, ++ .resume = nvkms_resume + }; + + static int nvkms_alloc_rm(void) + { + NV_STATUS nvstatus; + int ret; ++ const char *version_string = NV_VERSION_STRING; + +- __rm_ops.version_string = NV_VERSION_STRING; +- +- nvstatus = nvidia_get_rm_ops(&__rm_ops); ++ nvstatus = nvidia_get_rm_ops(&__rm_ops, &version_string); + + if (nvstatus != NV_OK) { + printk(KERN_ERR NVKMS_LOG_PREFIX "Version mismatch: " + "nvidia.ko(%s) nvidia-modeset.ko(%s)\n", +- __rm_ops.version_string, NV_VERSION_STRING); ++ version_string, NV_VERSION_STRING); + return -EINVAL; + } + +- ret = __rm_ops.set_callbacks(&nvkms_rm_callbacks); ++ ret = __rm_ops->set_callbacks(&nvkms_rm_callbacks); + if (ret < 0) { + printk(KERN_ERR NVKMS_LOG_PREFIX "Failed to register callbacks\n"); + return ret; + } + +- return __rm_ops.alloc_stack(&nvkms_nvidia_stack); ++ return __rm_ops->alloc_stack(&nvkms_nvidia_stack); + } + + static void nvkms_free_rm(void) + { +- __rm_ops.set_callbacks(NULL); +- if (__rm_ops.free_stack != NULL) { +- __rm_ops.free_stack(nvkms_nvidia_stack); ++ __rm_ops->set_callbacks(NULL); ++ if (__rm_ops->free_stack != NULL) { ++ __rm_ops->free_stack(nvkms_nvidia_stack); + } + } + + void NVKMS_API_CALL nvkms_call_rm(void *ops) + { +- __rm_ops.op(nvkms_nvidia_stack, ops); ++ __rm_ops->op(nvkms_nvidia_stack, ops); + } + + /************************************************************************* +@@ -681,17 +680,17 @@ done: + + NvBool NVKMS_API_CALL nvkms_open_gpu(NvU32 gpuId) + { +- return __rm_ops.open_gpu(gpuId, nvkms_nvidia_stack) == 0; ++ return __rm_ops->open_gpu(gpuId, nvkms_nvidia_stack) == 0; + } + + void NVKMS_API_CALL nvkms_close_gpu(NvU32 gpuId) + { +- __rm_ops.close_gpu(gpuId, nvkms_nvidia_stack); ++ __rm_ops->close_gpu(gpuId, nvkms_nvidia_stack); + } + + NvBool NVKMS_API_CALL nvkms_list_gpus(NvU32 *gpu_ids, NvU32 *gpu_count) + { +- return __rm_ops.get_gpuid_list(gpu_ids, gpu_count); ++ return __rm_ops->get_gpuid_list(gpu_ids, gpu_count); + } + + /************************************************************************* +diff -urp work.orig/kernel/nvidia-uvm/uvm8_channel.c work/kernel/nvidia-uvm/uvm8_channel.c +--- work.orig/kernel/nvidia-uvm/uvm8_channel.c 2016-02-03 23:32:32.000000000 +0100 ++++ work/kernel/nvidia-uvm/uvm8_channel.c 2016-02-10 11:39:16.735603941 +0100 +@@ -268,7 +268,7 @@ void uvm_channel_end_push(uvm_push_t *pu + mb(); + + channel->cpu_put = new_cpu_put; +- ACCESS_ONCE(*channel->channel_info.GPPut) = new_cpu_put; ++ ACCESS_ONCE_RW(*channel->channel_info.GPPut) = new_cpu_put; + + uvm_spin_unlock(&channel->pool->lock); + +diff -urp work.orig/kernel/nvidia-uvm/uvm8_global.c work/kernel/nvidia-uvm/uvm8_global.c +--- work.orig/kernel/nvidia-uvm/uvm8_global.c 2016-02-03 23:32:32.000000000 +0100 ++++ work/kernel/nvidia-uvm/uvm8_global.c 2016-02-10 11:28:23.142115625 +0100 +@@ -32,16 +32,16 @@ + #include "nv_uvm_interface.h" + + uvm_global_t g_uvm_global; +-static struct UvmOpsUvmEvents g_exported_uvm8_ops; ++static struct UvmOpsUvmEvents g_exported_uvm8_ops = { ++ .startDevice = NULL, ++ .stopDevice = NULL, ++ .isrTopHalf = uvm8_isr_top_half, ++}; + + static NV_STATUS uvm8_register_callbacks(void) + { + NV_STATUS status = NV_OK; + +- g_exported_uvm8_ops.startDevice = NULL; +- g_exported_uvm8_ops.stopDevice = NULL; +- g_exported_uvm8_ops.isrTopHalf = uvm8_isr_top_half; +- + // Register the UVM callbacks with the main GPU driver: + status = uvm_rm_locked_call(nvUvmInterfaceRegisterUvmCallbacks(&g_exported_uvm8_ops)); + return status; +diff -urp work.orig/kernel/nvidia-uvm/uvm8_gpu_semaphore.c work/kernel/nvidia-uvm/uvm8_gpu_semaphore.c +--- work.orig/kernel/nvidia-uvm/uvm8_gpu_semaphore.c 2016-02-03 23:32:32.000000000 +0100 ++++ work/kernel/nvidia-uvm/uvm8_gpu_semaphore.c 2016-02-10 11:38:57.478030852 +0100 +@@ -288,7 +288,7 @@ NvU64 uvm_gpu_semaphore_get_gpu_va(uvm_g + + NvU32 uvm_gpu_semaphore_get_payload(uvm_gpu_semaphore_t *semaphore) + { +- return ACCESS_ONCE(*semaphore->payload); ++ return ACCESS_ONCE_RW(*semaphore->payload); + } + + void uvm_gpu_semaphore_set_payload(uvm_gpu_semaphore_t *semaphore, NvU32 payload) +@@ -304,7 +304,7 @@ void uvm_gpu_semaphore_set_payload(uvm_g + // being optimized out on non-SMP configs (we need them for interacting with + // the GPU correctly even on non-SMP). + mb(); +- ACCESS_ONCE(*semaphore->payload) = payload; ++ ACCESS_ONCE_RW(*semaphore->payload) = payload; + } + + NV_STATUS uvm_gpu_tracking_semaphore_alloc(uvm_gpu_semaphore_pool_t *pool, uvm_gpu_tracking_semaphore_t *tracking_sem) +diff -urp work.orig/kernel/nvidia-uvm/uvm8_hal.c work/kernel/nvidia-uvm/uvm8_hal.c +--- work.orig/kernel/nvidia-uvm/uvm8_hal.c 2016-02-03 23:32:32.000000000 +0100 ++++ work/kernel/nvidia-uvm/uvm8_hal.c 2016-02-10 11:47:13.377356162 +0100 +@@ -58,7 +58,7 @@ typedef struct + // arch_ops: id is an architecture + uvm_arch_hal_t arch_ops; + } u; +-} uvm_hal_class_ops_t; ++} __do_const uvm_hal_class_ops_t; + + // Table for copy engine functions. + // Each entry is associated with a copy engine class through the 'class' field. +diff -urp work.orig/kernel/nvidia-uvm/uvm8_mmu.h work/kernel/nvidia-uvm/uvm8_mmu.h +--- work.orig/kernel/nvidia-uvm/uvm8_mmu.h 2016-02-03 23:32:32.000000000 +0100 ++++ work/kernel/nvidia-uvm/uvm8_mmu.h 2016-02-10 12:09:05.463637996 +0100 +@@ -24,7 +24,6 @@ + #ifndef __UVM8_MMU_H__ + #define __UVM8_MMU_H__ + +-#include "uvm8_forward_decl.h" + #include "uvm8_pmm_gpu.h" + #include "uvmtypes.h" + #include "uvm_common.h" +diff -urp work.orig/kernel/nvidia-uvm/uvm_common.c work/kernel/nvidia-uvm/uvm_common.c +--- work.orig/kernel/nvidia-uvm/uvm_common.c 2016-02-03 23:32:32.000000000 +0100 ++++ work/kernel/nvidia-uvm/uvm_common.c 2016-02-10 11:45:58.008501609 +0100 +@@ -74,7 +74,6 @@ static int uvmnext_activated(void) + #endif + + static dev_t g_uvmBaseDev; +-struct UvmOpsUvmEvents g_exportedUvmOps; + + static char* uvm_driver_mode = "lite"; + +@@ -198,12 +197,17 @@ static NV_STATUS uvmSetupGpuProvider(voi + { + NV_STATUS status = NV_OK; + +- g_exportedUvmOps.startDevice = uvm_gpu_event_start_device; +- g_exportedUvmOps.stopDevice = uvm_gpu_event_stop_device; ++ static struct UvmOpsUvmEvents g_exportedUvmOps = { ++ .startDevice = uvm_gpu_event_start_device, ++ .stopDevice = uvm_gpu_event_stop_device, ++ }; ++ ++ pax_open_kernel(); + if (uvmnext_activated()) +- g_exportedUvmOps.isrTopHalf = uvmnext_isr_top_half; ++ *(void **)&g_exportedUvmOps.isrTopHalf = uvmnext_isr_top_half; + else if (uvmfull_activated()) +- g_exportedUvmOps.isrTopHalf = uvmfull_isr_top_half; ++ *(void **)&g_exportedUvmOps.isrTopHalf = uvmfull_isr_top_half; ++ pax_close_kernel(); + + // call RM to exchange the function pointers. + status = nvUvmInterfaceRegisterUvmCallbacks(&g_exportedUvmOps); +diff -urp work.orig/kernel/nvidia-uvm/uvm_full_fault_buffer.h work/kernel/nvidia-uvm/uvm_full_fault_buffer.h +--- work.orig/kernel/nvidia-uvm/uvm_full_fault_buffer.h 2016-02-03 23:32:32.000000000 +0100 ++++ work/kernel/nvidia-uvm/uvm_full_fault_buffer.h 2016-02-10 11:26:28.143422741 +0100 +@@ -31,6 +31,7 @@ + #define _UVM_FULL_FAULT_BUFFER_H_ + + #include "uvmtypes.h" ++#include "linux/compiler.h" + + #define MAXWELL_FAULT_BUFFER_A (0xb069) + #define MEM_RD32(a) (*(const volatile NvU32 *)(a)) +@@ -303,7 +304,7 @@ typedef struct + NvUvmControlPrefetch_t controlPrefetch; + NvUvmTestFaultBufferOverflow_t testFaultBufferOverflow; + NvUvmClearFaultBufferOverflow_t clearFaultBufferOverflow; +-} UvmFaultBufferOps; ++} __no_const UvmFaultBufferOps; + + /****************************************************************************** + uvmfull_fault_buffer_init diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-364.12-pax.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-364.12-pax.patch @@ -0,0 +1,398 @@ +diff -urp work.orig/kernel/common/inc/nv-linux.h work/kernel/common/inc/nv-linux.h +--- work.orig/kernel/common/inc/nv-linux.h 2016-03-17 03:58:29.000000000 +0100 ++++ work/kernel/common/inc/nv-linux.h 2016-03-22 13:51:58.637292065 +0100 +@@ -1307,6 +1307,9 @@ extern void *nvidia_stack_t_cache; + #define NV_KMEM_CACHE_CREATE(name, type) \ + NV_KMEM_CACHE_CREATE_FULL(name, sizeof(type), 0, 0, NULL) + ++#define NV_KMEM_CACHE_CREATE_USERCOPY(name, type) \ ++ NV_KMEM_CACHE_CREATE_FULL(name, sizeof(type), 0, SLAB_USERCOPY, NULL) ++ + #define NV_KMEM_CACHE_DESTROY(kmem_cache) \ + kmem_cache_destroy(kmem_cache) + +diff -urp work.orig/kernel/common/inc/nv-modeset-interface.h work/kernel/common/inc/nv-modeset-interface.h +--- work.orig/kernel/common/inc/nv-modeset-interface.h 2016-03-17 03:58:29.000000000 +0100 ++++ work/kernel/common/inc/nv-modeset-interface.h 2016-03-22 13:51:58.637292065 +0100 +@@ -72,7 +72,7 @@ typedef struct { + * mix nvidia and nvidia-modeset kernel modules from different + * releases. + */ +- const char *version_string; ++// const char *version_string; + + /* + * Allocate and free an nvidia_stack_t to pass into +@@ -115,6 +115,6 @@ typedef struct { + + } nvidia_modeset_rm_ops_t; + +-NV_STATUS nvidia_get_rm_ops(nvidia_modeset_rm_ops_t *rm_ops); ++NV_STATUS nvidia_get_rm_ops(const nvidia_modeset_rm_ops_t **rm_ops, const char **version_string); + + #endif /* _NV_MODESET_INTERFACE_H_ */ +diff -urp work.orig/kernel/common/inc/nv-register-module.h work/kernel/common/inc/nv-register-module.h +--- work.orig/kernel/common/inc/nv-register-module.h 2016-03-17 03:58:29.000000000 +0100 ++++ work/kernel/common/inc/nv-register-module.h 2016-03-22 13:51:58.637292065 +0100 +@@ -34,7 +34,7 @@ typedef struct nvidia_module_s { + int (*ioctl)(struct inode *, struct file * file, unsigned int cmd, unsigned long arg); + unsigned int (*poll)(struct file * file, poll_table *wait); + +-} nvidia_module_t; ++} __do_const nvidia_module_t; + + int nvidia_register_module(nvidia_module_t *); + int nvidia_unregister_module(nvidia_module_t *); +diff -urp work.orig/kernel/nvidia/nv.c work/kernel/nvidia/nv.c +--- work.orig/kernel/nvidia/nv.c 2016-03-17 03:58:29.000000000 +0100 ++++ work/kernel/nvidia/nv.c 2016-03-22 13:51:58.637292065 +0100 +@@ -654,7 +654,7 @@ int __init nvidia_init_module(void) + NV_SPIN_LOCK_INIT(&km_lock); + #endif + +- nvidia_stack_t_cache = NV_KMEM_CACHE_CREATE(nvidia_stack_cache_name, ++ nvidia_stack_t_cache = NV_KMEM_CACHE_CREATE_USERCOPY(nvidia_stack_cache_name, + nvidia_stack_t); + if (nvidia_stack_t_cache == NULL) + { +diff -urp work.orig/kernel/nvidia/nv-chrdev.c work/kernel/nvidia/nv-chrdev.c +--- work.orig/kernel/nvidia/nv-chrdev.c 2016-03-17 03:58:29.000000000 +0100 ++++ work/kernel/nvidia/nv-chrdev.c 2016-03-22 13:51:58.637292065 +0100 +@@ -20,8 +20,6 @@ int nv_register_chrdev(void *param) + { + nvidia_module_t *module = (nvidia_module_t *)param; + +- module->instance = nv_module_instance; +- + return (nvidia_register_module(module)); + } + +diff -urp work.orig/kernel/nvidia/nv-instance.c work/kernel/nvidia/nv-instance.c +--- work.orig/kernel/nvidia/nv-instance.c 2016-03-17 03:58:29.000000000 +0100 ++++ work/kernel/nvidia/nv-instance.c 2016-03-22 13:51:58.637292065 +0100 +@@ -51,6 +51,7 @@ struct pci_driver nv_pci_driver = { + nvidia_module_t nv_fops = { + .owner = THIS_MODULE, + .module_name = MODULE_NAME, ++ .instance = MODULE_INSTANCE_NUMBER, + .open = nvidia_open, + .close = nvidia_close, + .ioctl = nvidia_ioctl, +diff -urp work.orig/kernel/nvidia/nv-mmap.c work/kernel/nvidia/nv-mmap.c +--- work.orig/kernel/nvidia/nv-mmap.c 2016-03-17 03:58:29.000000000 +0100 ++++ work/kernel/nvidia/nv-mmap.c 2016-03-22 13:51:58.637292065 +0100 +@@ -113,12 +113,12 @@ nvidia_vma_release(struct vm_area_struct + } + + #if defined(NV_VM_OPERATIONS_STRUCT_HAS_ACCESS) +-static int ++static ssize_t + nvidia_vma_access( + struct vm_area_struct *vma, + unsigned long addr, + void *buffer, +- int length, ++ size_t length, + int write + ) + { +diff -urp work.orig/kernel/nvidia/nv-modeset-interface.c work/kernel/nvidia/nv-modeset-interface.c +--- work.orig/kernel/nvidia/nv-modeset-interface.c 2016-03-17 03:58:29.000000000 +0100 ++++ work/kernel/nvidia/nv-modeset-interface.c 2016-03-22 13:56:37.019870910 +0100 +@@ -100,10 +100,9 @@ static NvU32 nvidia_modeset_enumerate_gp + return count; + } + +-NV_STATUS nvidia_get_rm_ops(nvidia_modeset_rm_ops_t *rm_ops) ++NV_STATUS nvidia_get_rm_ops(const nvidia_modeset_rm_ops_t **rm_ops, const char **version_string) + { +- const nvidia_modeset_rm_ops_t local_rm_ops = { +- .version_string = NV_VERSION_STRING, ++ static const nvidia_modeset_rm_ops_t local_rm_ops = { + .alloc_stack = nvidia_modeset_rm_ops_alloc_stack, + .free_stack = nvidia_modeset_rm_ops_free_stack, + .get_gpuid_list = nvidia_get_gpuid_list, +@@ -114,13 +113,13 @@ NV_STATUS nvidia_get_rm_ops(nvidia_modes + .set_callbacks = nvidia_modeset_set_callbacks, + }; + +- if (strcmp(rm_ops->version_string, NV_VERSION_STRING) != 0) ++ if (strcmp(*version_string, NV_VERSION_STRING) != 0) + { +- rm_ops->version_string = NV_VERSION_STRING; ++ *version_string = NV_VERSION_STRING; + return NV_ERR_GENERIC; + } + +- *rm_ops = local_rm_ops; ++ *rm_ops = &local_rm_ops; + + return NV_OK; + } +diff -urp work.orig/kernel/nvidia-drm/nvidia-drm-drv.c work/kernel/nvidia-drm/nvidia-drm-drv.c +--- work.orig/kernel/nvidia-drm/nvidia-drm-drv.c 2016-03-17 03:57:24.000000000 +0100 ++++ work/kernel/nvidia-drm/nvidia-drm-drv.c 2016-03-22 14:23:07.084230003 +0100 +@@ -586,7 +586,7 @@ static const struct drm_ioctl_desc nv_dr + DRM_CONTROL_ALLOW|DRM_RENDER_ALLOW|DRM_UNLOCKED), + }; + +-static struct drm_driver nv_drm_driver = { ++static drm_driver_no_const nv_drm_driver __read_only = { + + .driver_features = DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER, + +@@ -643,6 +643,7 @@ static void nvidia_update_drm_driver_fea + return; + } + ++ pax_open_kernel(); + nv_drm_driver.driver_features |= DRIVER_MODESET | DRIVER_ATOMIC; + + nv_drm_driver.master_set = nvidia_drm_master_set; +@@ -651,6 +652,7 @@ static void nvidia_update_drm_driver_fea + nv_drm_driver.dumb_create = nvidia_drm_dumb_create; + nv_drm_driver.dumb_map_offset = nvidia_drm_dumb_map_offset; + nv_drm_driver.dumb_destroy = drm_gem_dumb_destroy; ++ pax_close_kernel(); + + #endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */ + } +diff -urp work.orig/kernel/nvidia-modeset/nvidia-modeset-linux.c work/kernel/nvidia-modeset/nvidia-modeset-linux.c +--- work.orig/kernel/nvidia-modeset/nvidia-modeset-linux.c 2016-03-17 03:57:25.000000000 +0100 ++++ work/kernel/nvidia-modeset/nvidia-modeset-linux.c 2016-03-22 13:55:05.208148788 +0100 +@@ -317,29 +317,28 @@ static void nvkms_resume(NvU32 gpuId) + * Interface with resman. + *************************************************************************/ + +-static nvidia_modeset_rm_ops_t __rm_ops = { 0 }; ++static const nvidia_modeset_rm_ops_t *__rm_ops; + static nvidia_modeset_callbacks_t nvkms_rm_callbacks = { +- nvkms_suspend, +- nvkms_resume ++ .suspend = nvkms_suspend, ++ .resume = nvkms_resume + }; + + static int nvkms_alloc_rm(void) + { + NV_STATUS nvstatus; + int ret; ++ const char *version_string = NV_VERSION_STRING; + +- __rm_ops.version_string = NV_VERSION_STRING; +- +- nvstatus = nvidia_get_rm_ops(&__rm_ops); ++ nvstatus = nvidia_get_rm_ops(&__rm_ops, &version_string); + + if (nvstatus != NV_OK) { + printk(KERN_ERR NVKMS_LOG_PREFIX "Version mismatch: " + "nvidia.ko(%s) nvidia-modeset.ko(%s)\n", +- __rm_ops.version_string, NV_VERSION_STRING); ++ version_string, NV_VERSION_STRING); + return -EINVAL; + } + +- ret = __rm_ops.set_callbacks(&nvkms_rm_callbacks); ++ ret = __rm_ops->set_callbacks(&nvkms_rm_callbacks); + if (ret < 0) { + printk(KERN_ERR NVKMS_LOG_PREFIX "Failed to register callbacks\n"); + return ret; +@@ -350,20 +349,20 @@ static int nvkms_alloc_rm(void) + + static void nvkms_free_rm(void) + { +- __rm_ops.set_callbacks(NULL); ++ __rm_ops->set_callbacks(NULL); + } + + void NVKMS_API_CALL nvkms_call_rm(void *ops) + { + nvidia_modeset_stack_ptr stack = NULL; + +- if (__rm_ops.alloc_stack(&stack) != 0) { ++ if (__rm_ops->alloc_stack(&stack) != 0) { + return; + } + +- __rm_ops.op(stack, ops); ++ __rm_ops->op(stack, ops); + +- __rm_ops.free_stack(stack); ++ __rm_ops->free_stack(stack); + } + + /************************************************************************* +@@ -685,13 +684,13 @@ NvBool NVKMS_API_CALL nvkms_open_gpu(NvU + nvidia_modeset_stack_ptr stack = NULL; + NvBool ret; + +- if (__rm_ops.alloc_stack(&stack) != 0) { ++ if (__rm_ops->alloc_stack(&stack) != 0) { + return NV_FALSE; + } + +- ret = __rm_ops.open_gpu(gpuId, stack) == 0; ++ ret = __rm_ops->open_gpu(gpuId, stack) == 0; + +- __rm_ops.free_stack(stack); ++ __rm_ops->free_stack(stack); + + return ret; + } +@@ -700,18 +699,18 @@ void NVKMS_API_CALL nvkms_close_gpu(NvU3 + { + nvidia_modeset_stack_ptr stack = NULL; + +- if (__rm_ops.alloc_stack(&stack) != 0) { ++ if (__rm_ops->alloc_stack(&stack) != 0) { + return; + } + +- __rm_ops.close_gpu(gpuId, stack); ++ __rm_ops->close_gpu(gpuId, stack); + +- __rm_ops.free_stack(stack); ++ __rm_ops->free_stack(stack); + } + + NvU32 NVKMS_API_CALL nvkms_enumerate_gpus(nv_gpu_info_t *gpu_info) + { +- return __rm_ops.enumerate_gpus(gpu_info); ++ return __rm_ops->enumerate_gpus(gpu_info); + } + + /************************************************************************* +diff -urp work.orig/kernel/nvidia-uvm/uvm8_global.c work/kernel/nvidia-uvm/uvm8_global.c +--- work.orig/kernel/nvidia-uvm/uvm8_global.c 2016-03-17 03:59:59.000000000 +0100 ++++ work/kernel/nvidia-uvm/uvm8_global.c 2016-03-22 14:00:03.852089935 +0100 +@@ -33,17 +33,17 @@ + #include "nv_uvm_interface.h" + + uvm_global_t g_uvm_global; +-static struct UvmOpsUvmEvents g_exported_uvm8_ops; ++static struct UvmOpsUvmEvents g_exported_uvm8_ops = { ++ .startDevice = NULL, ++ .stopDevice = NULL, ++ .isrTopHalf = uvm8_isr_top_half, ++}; + static bool g_ops_registered = false; + + static NV_STATUS uvm8_register_callbacks(void) + { + NV_STATUS status = NV_OK; + +- g_exported_uvm8_ops.startDevice = NULL; +- g_exported_uvm8_ops.stopDevice = NULL; +- g_exported_uvm8_ops.isrTopHalf = uvm8_isr_top_half; +- + // Register the UVM callbacks with the main GPU driver: + status = uvm_rm_locked_call(nvUvmInterfaceRegisterUvmCallbacks(&g_exported_uvm8_ops)); + if (status != NV_OK) +diff -urp work.orig/kernel/nvidia-uvm/uvm8_gpu_semaphore.c work/kernel/nvidia-uvm/uvm8_gpu_semaphore.c +--- work.orig/kernel/nvidia-uvm/uvm8_gpu_semaphore.c 2016-03-17 03:59:59.000000000 +0100 ++++ work/kernel/nvidia-uvm/uvm8_gpu_semaphore.c 2016-03-22 13:51:58.641294799 +0100 +@@ -285,7 +285,7 @@ NvU64 uvm_gpu_semaphore_get_gpu_va(uvm_g + + NvU32 uvm_gpu_semaphore_get_payload(uvm_gpu_semaphore_t *semaphore) + { +- return ACCESS_ONCE(*semaphore->payload); ++ return ACCESS_ONCE_RW(*semaphore->payload); + } + + void uvm_gpu_semaphore_set_payload(uvm_gpu_semaphore_t *semaphore, NvU32 payload) +@@ -301,7 +301,7 @@ void uvm_gpu_semaphore_set_payload(uvm_g + // being optimized out on non-SMP configs (we need them for interacting with + // the GPU correctly even on non-SMP). + mb(); +- ACCESS_ONCE(*semaphore->payload) = payload; ++ ACCESS_ONCE_RW(*semaphore->payload) = payload; + } + + NV_STATUS uvm_gpu_tracking_semaphore_alloc(uvm_gpu_semaphore_pool_t *pool, uvm_gpu_tracking_semaphore_t *tracking_sem) +diff -urp work.orig/kernel/nvidia-uvm/uvm8_hal.h work/kernel/nvidia-uvm/uvm8_hal.h +--- work.orig/kernel/nvidia-uvm/uvm8_hal.h 2016-03-17 03:59:59.000000000 +0100 ++++ work/kernel/nvidia-uvm/uvm8_hal.h 2016-03-22 13:55:38.620347598 +0100 +@@ -293,7 +293,7 @@ typedef struct + // fault_buffer_ops: id is a hardware class + uvm_fault_buffer_hal_t fault_buffer_ops; + } u; +-} uvm_hal_class_ops_t; ++} __do_const uvm_hal_class_ops_t; + + // When UVM next support is enabled support for future chips in the hal is + // enabled by providing additional hal table entries below. +diff -urp work.orig/kernel/nvidia-uvm/uvm8_mmu.h work/kernel/nvidia-uvm/uvm8_mmu.h +--- work.orig/kernel/nvidia-uvm/uvm8_mmu.h 2016-03-17 03:59:59.000000000 +0100 ++++ work/kernel/nvidia-uvm/uvm8_mmu.h 2016-03-22 13:57:44.255581049 +0100 +@@ -24,7 +24,6 @@ + #ifndef __UVM8_MMU_H__ + #define __UVM8_MMU_H__ + +-#include "uvm8_forward_decl.h" + #include "uvm8_hal_types.h" + #include "uvm8_pmm_gpu.h" + #include "uvmtypes.h" +diff -urp work.orig/kernel/nvidia-uvm/uvm_common.c work/kernel/nvidia-uvm/uvm_common.c +--- work.orig/kernel/nvidia-uvm/uvm_common.c 2016-03-17 03:59:59.000000000 +0100 ++++ work/kernel/nvidia-uvm/uvm_common.c 2016-03-22 13:59:20.045675359 +0100 +@@ -54,7 +54,6 @@ + #include "uvm8_forward_decl.h" + + static dev_t g_uvmBaseDev; +-struct UvmOpsUvmEvents g_exportedUvmOps; + + static char* uvm_driver_mode = "lite"; + +@@ -171,10 +170,16 @@ static NV_STATUS uvmSetupGpuProvider(voi + { + NV_STATUS status = NV_OK; + +- g_exportedUvmOps.startDevice = uvm_gpu_event_start_device; +- g_exportedUvmOps.stopDevice = uvm_gpu_event_stop_device; +- if (uvmfull_activated()) +- g_exportedUvmOps.isrTopHalf = uvmfull_isr_top_half; ++ static struct UvmOpsUvmEvents g_exportedUvmOps = { ++ .startDevice = uvm_gpu_event_start_device, ++ .stopDevice = uvm_gpu_event_stop_device, ++ }; ++ ++ if (uvmfull_activated()) { ++ pax_open_kernel(); ++ *(void **)&g_exportedUvmOps.isrTopHalf = uvmfull_isr_top_half; ++ pax_close_kernel(); ++ } + + // call RM to exchange the function pointers. + status = nvUvmInterfaceRegisterUvmCallbacks(&g_exportedUvmOps); +diff -urp work.orig/kernel/nvidia-uvm/uvm_full_fault_buffer.h work/kernel/nvidia-uvm/uvm_full_fault_buffer.h +--- work.orig/kernel/nvidia-uvm/uvm_full_fault_buffer.h 2016-03-17 03:59:59.000000000 +0100 ++++ work/kernel/nvidia-uvm/uvm_full_fault_buffer.h 2016-03-22 13:51:58.645297533 +0100 +@@ -31,6 +31,7 @@ + #define _UVM_FULL_FAULT_BUFFER_H_ + + #include "uvmtypes.h" ++#include "linux/compiler.h" + + #define MAXWELL_FAULT_BUFFER_A (0xb069) + #define MEM_RD32(a) (*(const volatile NvU32 *)(a)) +@@ -303,7 +304,7 @@ typedef struct + NvUvmControlPrefetch_t controlPrefetch; + NvUvmTestFaultBufferOverflow_t testFaultBufferOverflow; + NvUvmClearFaultBufferOverflow_t clearFaultBufferOverflow; +-} UvmFaultBufferOps; ++} __no_const UvmFaultBufferOps; + + /****************************************************************************** + uvmfull_fault_buffer_init +diff -urp work.orig/kernel/nvidia-uvm/uvm_linux.h work/kernel/nvidia-uvm/uvm_linux.h +--- work.orig/kernel/nvidia-uvm/uvm_linux.h 2016-03-17 03:59:59.000000000 +0100 ++++ work/kernel/nvidia-uvm/uvm_linux.h 2016-03-22 14:09:14.810534336 +0100 +@@ -485,7 +485,7 @@ static inline NvU64 NV_GETTIME(void) + + // WRITE_ONCE/READ_ONCE have incompatible definitions across versions, which produces warnings. + // Therefore, we define our own macros +-#define UVM_WRITE_ONCE(x, val) (ACCESS_ONCE(x) = (val)) ++#define UVM_WRITE_ONCE(x, val) (ACCESS_ONCE_RW(x) = (val)) + #define UVM_READ_ONCE(x) ACCESS_ONCE(x) + + // Added in 3.11 diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-367.35-profiles-rc.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-367.35-profiles-rc.patch @@ -0,0 +1,11 @@ +--- a/nvidia-application-profiles-367.35-rc ++++ b/nvidia-application-profiles-367.35-rc +@@ -44,7 +44,7 @@ + { + "name" : "NamedVertexAttributesApplyDivisor", + "settings" : [ "GL23cd0e", 1 ] +- }, ++ } + ], + "rules" : [ + { diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-367.44-profiles-rc.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-367.44-profiles-rc.patch @@ -0,0 +1,11 @@ +--- a/nvidia-application-profiles-367.44-rc ++++ b/nvidia-application-profiles-367.44-rc +@@ -44,7 +44,7 @@ + { + "name" : "NamedVertexAttributesApplyDivisor", + "settings" : [ "GL23cd0e", 1 ] +- }, ++ } + ], + "rules" : [ + { diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-370.28-profiles-rc.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-370.28-profiles-rc.patch @@ -0,0 +1,11 @@ +--- a/nvidia-application-profiles-370.28-rc ++++ b/nvidia-application-profiles-370.28-rc +@@ -44,7 +44,7 @@ + { + "name" : "NamedVertexAttributesApplyDivisor", + "settings" : [ "GL23cd0e", 1 ] +- }, ++ } + ], + "rules" : [ + { diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-pax-const.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-pax-const.patch @@ -0,0 +1,17 @@ +Binary files kernel.orig/.nv-procfs.c.swp and kernel/.nv-procfs.c.swp differ +diff -urp kernel.orig/nv-procfs.c kernel/nv-procfs.c +--- kernel.orig/nv-procfs.c 2011-07-13 03:29:30.000000000 +0200 ++++ kernel/nv-procfs.c 2011-07-19 15:45:27.982993911 +0200 +@@ -707,8 +707,10 @@ int nv_register_procfs(void) + * However, in preparation for this, we need to preserve + * the procfs read() and write() operations. + */ +- nv_procfs_registry_fops.read = entry->proc_fops->read; +- nv_procfs_registry_fops.write = entry->proc_fops->write; ++ pax_open_kernel(); ++ *(void **)&nv_procfs_registry_fops.read = entry->proc_fops->read; ++ *(void **)&nv_procfs_registry_fops.write = entry->proc_fops->write; ++ pax_close_kernel(); + + entry = NV_CREATE_PROC_FILE("registry", proc_nvidia, + nv_procfs_read_registry, diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-pax-usercopy.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-pax-usercopy.patch @@ -0,0 +1,54 @@ +diff -urp kernel.orig/nv.c kernel/nv.c +--- kernel.orig/nv.c 2011-09-24 02:32:09.000000000 +0200 ++++ kernel/nv.c 2011-10-05 19:13:41.474242252 +0200 +@@ -1105,7 +1105,7 @@ static int __init nvidia_init_module(voi + NV_SPIN_LOCK_INIT(&km_lock); + #endif + +- NV_KMEM_CACHE_CREATE(nv_stack_t_cache, "nv_stack_t", nv_stack_t); ++ NV_KMEM_CACHE_CREATE(nv_stack_t_cache, "nv_stack_t", nv_stack_t, SLAB_USERCOPY); + if (nv_stack_t_cache == NULL) + { + nv_printf(NV_DBG_ERRORS, "NVRM: stack cache allocation failed!\n"); +@@ -1220,7 +1220,7 @@ static int __init nvidia_init_module(voi + } + #endif + +- NV_KMEM_CACHE_CREATE(nv_pte_t_cache, "nv_pte_t", nv_pte_t); ++ NV_KMEM_CACHE_CREATE(nv_pte_t_cache, "nv_pte_t", nv_pte_t, 0); + if (nv_pte_t_cache == NULL) + { + rc = -ENOMEM; +@@ -1229,7 +1229,7 @@ static int __init nvidia_init_module(voi + } + + NV_KMEM_CACHE_CREATE(nvidia_p2p_page_t_cache, "nvidia_p2p_page_t", +- nvidia_p2p_page_t); ++ nvidia_p2p_page_t, 0); + if (nvidia_p2p_page_t_cache == NULL) + { + rc = -ENOMEM; +diff -urp kernel.orig/nv-linux.h kernel/nv-linux.h +--- kernel.orig/nv-linux.h 2011-09-24 02:32:09.000000000 +0200 ++++ kernel/nv-linux.h 2011-10-05 19:14:42.522238996 +0200 +@@ -695,16 +695,16 @@ extern nv_spinlock_t km_lock; + + #if defined(NV_KMEM_CACHE_CREATE_PRESENT) + #if (NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT == 6) +-#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type) \ ++#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type, flags) \ + { \ + kmem_cache = kmem_cache_create(name, sizeof(type), \ +- 0, 0, NULL, NULL); \ ++ 0, flags, NULL, NULL); \ + } + #elif (NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT == 5) +-#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type) \ ++#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type, flags) \ + { \ + kmem_cache = kmem_cache_create(name, sizeof(type), \ +- 0, 0, NULL); \ ++ 0, flags, NULL); \ + } + #else + #error "NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT value unrecognized!" diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-settings.desktop b/x11-drivers/nvidia-drivers/files/nvidia-drivers-settings.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Type=Application +Name=NVIDIA X Server Settings +Comment=Configure NVIDIA X Server Settings +Exec=/opt/bin/nvidia-settings +Icon=nvidia-drivers-settings +Categories=System;Settings; diff --git a/x11-drivers/nvidia-drivers/files/nvidia-persistenced.conf b/x11-drivers/nvidia-drivers/files/nvidia-persistenced.conf @@ -0,0 +1,8 @@ +# run-time configuration file for /etc/init.d/nvidia-persistenced + +# NVPD_USER: The user nvidia-persistenced is intended to run for +NVPD_USER="" + +# ARGS: Additional arguments to set the default persistence mode +# (see nvidia-persistenced(1)) +ARGS="" diff --git a/x11-drivers/nvidia-drivers/files/nvidia-persistenced.init b/x11-drivers/nvidia-drivers/files/nvidia-persistenced.init @@ -0,0 +1,25 @@ +#!/sbin/openrc-run +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +pidfile="/var/run/nvidia-persistenced/nvidia-persistenced.pid" + +start() { + if ! [ "${NVPD_USER}x" = x ]; then + ebegin "Starting nvidia-persistenced for ${NVPD_USER}" + NVPD_USER_ARG="--user ${NVPD_USER}" + else + ebegin "Starting nvidia-persistenced" + fi + start-stop-daemon --start --quiet --pidfile ${pidfile} \ + --background --exec /opt/bin/nvidia-persistenced \ + -- ${NVPD_USER_ARG} ${ARGS} + eend $? +} + +stop() { + ebegin "Stopping nvidia-persistenced" + start-stop-daemon --stop --quiet --pidfile ${pidfile} + eend $? +} diff --git a/x11-drivers/nvidia-drivers/files/nvidia-rmmod.conf b/x11-drivers/nvidia-drivers/files/nvidia-rmmod.conf @@ -0,0 +1,3 @@ +# Nvidia UVM support + +remove nvidia modprobe -r --ignore-remove nvidia-modeset nvidia-uvm nvidia diff --git a/x11-drivers/nvidia-drivers/files/nvidia-settings.desktop b/x11-drivers/nvidia-drivers/files/nvidia-settings.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Type=Application +Name=NVIDIA X Server Settings +Comment=Configure NVIDIA X Server Settings +Exec=/usr/bin/nvidia-settings +Icon=nvidia-settings +Categories=System;Settings; diff --git a/x11-drivers/nvidia-drivers/files/nvidia-smi.init b/x11-drivers/nvidia-drivers/files/nvidia-smi.init @@ -0,0 +1,25 @@ +#!/sbin/openrc-run +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +pidfile="/run/nvidia-smi.pid" + +depend() { + after modules +} + +start() { + ebegin "Starting NVIDIA System Management Interface" + rm -f ${pidfile} + start-stop-daemon --start --quiet --pidfile ${pidfile} \ + --make-pidfile --background --exec /opt/bin/nvidia-smi -- \ + -q -l 300 + eend $? +} + +stop() { + ebegin "Stopping NVIDIA System Management Interface" + start-stop-daemon --stop --quiet --pidfile ${pidfile} + eend $? +} diff --git a/x11-drivers/nvidia-drivers/files/nvidia-udev.sh b/x11-drivers/nvidia-drivers/files/nvidia-udev.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ $# -ne 1 ]; then + echo "Invalid args" >&2 + exit 1 +fi + +case $1 in + add|ADD) + /opt/bin/nvidia-smi > /dev/null + ;; + remove|REMOVE) + rm -f /dev/nvidia* + ;; +esac + +exit 0 diff --git a/x11-drivers/nvidia-drivers/files/nvidia-udev.sh-r1 b/x11-drivers/nvidia-drivers/files/nvidia-udev.sh-r1 @@ -0,0 +1,20 @@ +#!/bin/sh + +if [ $# -ne 1 ]; then + echo "Invalid args" >&2 + exit 1 +fi + +case $1 in + add|ADD) + #hopefully this prevents infinite loops like bug #454740 + if lsmod | grep -iq nvidia; then + /opt/bin/nvidia-smi > /dev/null + fi + ;; + remove|REMOVE) + rm -f /dev/nvidia* + ;; +esac + +exit 0 diff --git a/x11-drivers/nvidia-drivers/files/nvidia-uvm.conf b/x11-drivers/nvidia-drivers/files/nvidia-uvm.conf @@ -0,0 +1,3 @@ +# Nvidia UVM support + +remove nvidia modprobe -r --ignore-remove nvidia-uvm nvidia diff --git a/x11-drivers/nvidia-drivers/files/nvidia.udev-rule b/x11-drivers/nvidia-drivers/files/nvidia.udev-rule @@ -0,0 +1,6 @@ +ACTION=="add", DEVPATH=="/module/nvidia", SUBSYSTEM=="module", RUN+="nvidia-udev.sh $env{ACTION}" +# Previously the ACTION was "add|remove" but one user on bug #376527 had a +# problem until he recompiled udev-171-r5, which is one of the versions I +# tested with and it was fine. I'm breaking the rules out just to be safe +# so someone else doesn't have an issue +ACTION=="remove", DEVPATH=="/module/nvidia", SUBSYSTEM=="module", RUN+="nvidia-udev.sh $env{ACTION}" diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-370.28.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-370.28.ebuild @@ -0,0 +1,552 @@ +# Copyright 1999-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI=5 + +inherit eutils flag-o-matic linux-info linux-mod multilib nvidia-driver \ + portability toolchain-funcs unpacker user udev + +NV_URI="http://us.download.nvidia.com/XFree86/" +X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}" +AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}" +ARM_NV_PACKAGE="NVIDIA-Linux-armv7l-gnueabihf-${PV}" +X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}" +AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}" + +DESCRIPTION="NVIDIA Accelerated Graphics Driver" +HOMEPAGE="http://www.nvidia.com/ http://www.nvidia.com/Download/Find.aspx" +SRC_URI=" + amd64-fbsd? ( ${NV_URI}FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz ) + amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run ) + arm? ( ${NV_URI}Linux-x86-ARM/${PV}/${ARM_NV_PACKAGE}.run ) + x86-fbsd? ( ${NV_URI}FreeBSD-x86/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz ) + x86? ( ${NV_URI}Linux-x86/${PV}/${X86_NV_PACKAGE}.run ) + tools? ( ftp://download.nvidia.com/XFree86/nvidia-settings/nvidia-settings-${PV}.tar.bz2 ) +" + +LICENSE="GPL-2 NVIDIA-r2" +SLOT="0/${PV%.*}" +KEYWORDS="-* ~amd64 ~x86 ~amd64-fbsd ~x86-fbsd" +RESTRICT="bindist mirror" +EMULTILIB_PKG="true" + +IUSE="acpi compat +driver gtk3 kernel_FreeBSD kernel_linux +kms multilib pax_kernel static-libs +tools uvm wayland +X" +REQUIRED_USE=" + tools? ( X ) + static-libs? ( tools ) +" + +COMMON=" + app-eselect/eselect-opencl + kernel_linux? ( >=sys-libs/glibc-2.6.1 ) + tools? ( + dev-libs/atk + dev-libs/glib:2 + dev-libs/jansson + gtk3? ( x11-libs/gtk+:3 ) + x11-libs/cairo + x11-libs/gdk-pixbuf[X] + x11-libs/gtk+:2 + x11-libs/libX11 + x11-libs/libXext + x11-libs/libXrandr + x11-libs/libXv + x11-libs/libXxf86vm + x11-libs/pango[X] + ) + X? ( + >=app-eselect/eselect-opengl-1.0.9 + app-misc/pax-utils + ) +" +DEPEND=" + ${COMMON} + kernel_linux? ( virtual/linux-sources ) +" +RDEPEND=" + ${COMMON} + acpi? ( sys-power/acpid ) + tools? ( !media-video/nvidia-settings ) + wayland? ( dev-libs/wayland ) + X? ( + <x11-base/xorg-server-1.18.99:= + >=x11-libs/libvdpau-1.0 + multilib? ( + >=x11-libs/libX11-1.6.2[abi_x86_32] + >=x11-libs/libXext-1.3.2[abi_x86_32] + ) + ) +" + +QA_PREBUILT="opt/* usr/lib*" + +S=${WORKDIR}/ + +pkg_pretend() { + if use amd64 && has_multilib_profile && \ + [ "${DEFAULT_ABI}" != "amd64" ]; then + eerror "This ebuild doesn't currently support changing your default ABI" + die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}" + fi + + if use kernel_linux && kernel_is ge 4 8; then + ewarn "Gentoo supports kernels which are supported by NVIDIA" + ewarn "which are limited to the following kernels:" + ewarn "<sys-kernel/gentoo-sources-4.8" + ewarn "<sys-kernel/vanilla-sources-4.8" + ewarn "" + ewarn "You are free to utilize epatch_user to provide whatever" + ewarn "support you feel is appropriate, but will not receive" + ewarn "support as a result of those changes." + ewarn "" + ewarn "Do not file a bug report about this." + ewarn "" + fi + + # Since Nvidia ships many different series of drivers, we need to give the user + # some kind of guidance as to what version they should install. This tries + # to point the user in the right direction but can't be perfect. check + # nvidia-driver.eclass + nvidia-driver-check-warning + + # Kernel features/options to check for + CONFIG_CHECK="~ZONE_DMA ~MTRR ~SYSVIPC ~!LOCKDEP" + use x86 && CONFIG_CHECK+=" ~HIGHMEM" + + # Now do the above checks + use kernel_linux && check_extra_config +} + +pkg_setup() { + # try to turn off distcc and ccache for people that have a problem with it + export DISTCC_DISABLE=1 + export CCACHE_DISABLE=1 + + if use driver && use kernel_linux; then + MODULE_NAMES="nvidia(video:${S}/kernel)" + use uvm && MODULE_NAMES+=" nvidia-uvm(video:${S}/kernel)" + use kms && MODULE_NAMES+=" nvidia-modeset(video:${S}/kernel) nvidia-drm(video:${S}/kernel)" + + # This needs to run after MODULE_NAMES (so that the eclass checks + # whether the kernel supports loadable modules) but before BUILD_PARAMS + # is set (so that KV_DIR is populated). + linux-mod_pkg_setup + + BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \ + SYSOUT=${KV_OUT_DIR} CC=$(tc-getBUILD_CC) NV_VERBOSE=1" + + # linux-mod_src_compile calls set_arch_to_kernel, which + # sets the ARCH to x86 but NVIDIA's wrapping Makefile + # expects x86_64 or i386 and then converts it to x86 + # later on in the build process + BUILD_FIXES="ARCH=$(uname -m | sed -e 's/i.86/i386/')" + fi + + if use kernel_linux && kernel_is lt 2 6 9; then + eerror "You must build this against 2.6.9 or higher kernels." + fi + + # set variables to where files are in the package structure + if use kernel_FreeBSD; then + use x86-fbsd && S="${WORKDIR}/${X86_FBSD_NV_PACKAGE}" + use amd64-fbsd && S="${WORKDIR}/${AMD64_FBSD_NV_PACKAGE}" + NV_DOC="${S}/doc" + NV_OBJ="${S}/obj" + NV_SRC="${S}/src" + NV_MAN="${S}/x11/man" + NV_X11="${S}/obj" + NV_SOVER=1 + elif use kernel_linux; then + NV_DOC="${S}" + NV_OBJ="${S}" + NV_SRC="${S}/kernel" + NV_MAN="${S}" + NV_X11="${S}" + NV_SOVER=${PV} + else + die "Could not determine proper NVIDIA package" + fi +} + +src_prepare() { + epatch "${FILESDIR}"/${P}-profiles-rc.patch + + if use pax_kernel; then + ewarn "Using PAX patches is not supported. You will be asked to" + ewarn "use a standard kernel should you have issues. Should you" + ewarn "need support with these patches, contact the PaX team." + epatch "${FILESDIR}"/${PN}-364.12-pax.patch + fi + + # Allow user patches so they can support RC kernels and whatever else + epatch_user +} + +src_compile() { + # This is already the default on Linux, as there's no toplevel Makefile, but + # on FreeBSD there's one and triggers the kernel module build, as we install + # it by itself, pass this. + + cd "${NV_SRC}" + if use kernel_FreeBSD; then + MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \ + LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die + elif use driver && use kernel_linux; then + MAKEOPTS=-j1 linux-mod_src_compile + fi + + if use tools; then + emake -C "${S}"/nvidia-settings-${PV}/src \ + AR="$(tc-getAR)" \ + CC="$(tc-getCC)" \ + LIBDIR="$(get_libdir)" \ + NV_VERBOSE=1 \ + RANLIB="$(tc-getRANLIB)" \ + DO_STRIP= \ + build-xnvctrl + + emake -C "${S}"/nvidia-settings-${PV}/src \ + CC="$(tc-getCC)" \ + GTK3_AVAILABLE=$(usex gtk3 1 0) \ + LD="$(tc-getCC)" \ + LIBDIR="$(get_libdir)" \ + NVML_ENABLED=0 \ + NV_USE_BUNDLED_LIBJANSSON=0 \ + NV_VERBOSE=1 \ + DO_STRIP= + fi +} + +# Install nvidia library: +# the first parameter is the library to install +# the second parameter is the provided soversion +# the third parameter is the target directory if it is not /usr/lib +donvidia() { + # Full path to library + nv_LIB="${1}" + + # SOVER to use + nv_SOVER="$(scanelf -qF'%S#F' ${nv_LIB})" + + # Where to install + nv_DEST="${2}" + + # Get just the library name + nv_LIBNAME=$(basename "${nv_LIB}") + + if [[ "${nv_DEST}" ]]; then + exeinto ${nv_DEST} + action="doexe" + else + nv_DEST="/usr/$(get_libdir)" + action="dolib.so" + fi + + # Install the library + ${action} ${nv_LIB} || die "failed to install ${nv_LIBNAME}" + + # If the library has a SONAME and SONAME does not match the library name, + # then we need to create a symlink + if [[ ${nv_SOVER} ]] && ! [[ "${nv_SOVER}" = "${nv_LIBNAME}" ]]; then + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_SOVER} \ + || die "failed to create ${nv_DEST}/${nv_SOVER} symlink" + fi + + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_LIBNAME/.so*/.so} \ + || die "failed to create ${nv_LIBNAME/.so*/.so} symlink" +} + +src_install() { + if use driver && use kernel_linux; then + linux-mod_src_install + + # Add the aliases + # This file is tweaked with the appropriate video group in + # pkg_preinst, see bug #491414 + insinto /etc/modprobe.d + newins "${FILESDIR}"/nvidia-169.07 nvidia.conf + doins "${FILESDIR}"/nvidia-rmmod.conf + + # Ensures that our device nodes are created when not using X + exeinto "$(get_udevdir)" + newexe "${FILESDIR}"/nvidia-udev.sh-r1 nvidia-udev.sh + udev_newrules "${FILESDIR}"/nvidia.udev-rule 99-nvidia.rules + elif use kernel_FreeBSD; then + if use x86-fbsd; then + insinto /boot/modules + doins "${S}/src/nvidia.kld" + fi + + exeinto /boot/modules + doexe "${S}/src/nvidia.ko" + fi + + # NVIDIA kernel <-> userspace driver config lib + donvidia ${NV_OBJ}/libnvidia-cfg.so.${NV_SOVER} + + # NVIDIA framebuffer capture library + donvidia ${NV_OBJ}/libnvidia-fbc.so.${NV_SOVER} + + # NVIDIA video encode/decode <-> CUDA + if use kernel_linux; then + donvidia ${NV_OBJ}/libnvcuvid.so.${NV_SOVER} + donvidia ${NV_OBJ}/libnvidia-encode.so.${NV_SOVER} + fi + + if use X; then + # Xorg DDX driver + insinto /usr/$(get_libdir)/xorg/modules/drivers + doins ${NV_X11}/nvidia_drv.so + + # Xorg GLX driver + donvidia ${NV_X11}/libglx.so.${NV_SOVER} \ + /usr/$(get_libdir)/opengl/nvidia/extensions + + # Xorg nvidia.conf + if has_version '>=x11-base/xorg-server-1.16'; then + insinto /usr/share/X11/xorg.conf.d + newins {,50-}nvidia-drm-outputclass.conf + fi + fi + + # OpenCL ICD for NVIDIA + if use kernel_linux; then + insinto /etc/OpenCL/vendors + doins ${NV_OBJ}/nvidia.icd + fi + + # Documentation + dohtml ${NV_DOC}/html/* + if use kernel_FreeBSD; then + dodoc "${NV_DOC}/README" + use X && doman "${NV_MAN}/nvidia-xconfig.1" + use tools && doman "${NV_MAN}/nvidia-settings.1" + else + # Docs + newdoc "${NV_DOC}/README.txt" README + dodoc "${NV_DOC}/NVIDIA_Changelog" + doman "${NV_MAN}/nvidia-smi.1.gz" + use X && doman "${NV_MAN}/nvidia-xconfig.1.gz" + use tools && doman "${NV_MAN}/nvidia-settings.1.gz" + doman "${NV_MAN}/nvidia-cuda-mps-control.1.gz" + fi + + # Helper Apps + exeinto /opt/bin/ + + if use X; then + doexe ${NV_OBJ}/nvidia-xconfig + fi + + if use kernel_linux; then + doexe ${NV_OBJ}/nvidia-cuda-mps-control + doexe ${NV_OBJ}/nvidia-cuda-mps-server + doexe ${NV_OBJ}/nvidia-debugdump + doexe ${NV_OBJ}/nvidia-persistenced + doexe ${NV_OBJ}/nvidia-smi + + # install nvidia-modprobe setuid and symlink in /usr/bin (bug #505092) + doexe ${NV_OBJ}/nvidia-modprobe + fowners root:video /opt/bin/nvidia-modprobe + fperms 4710 /opt/bin/nvidia-modprobe + dosym /{opt,usr}/bin/nvidia-modprobe + + doman nvidia-cuda-mps-control.1.gz + doman nvidia-modprobe.1.gz + doman nvidia-persistenced.1.gz + newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi + newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced + newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced + fi + + if use tools; then + emake -C "${S}"/nvidia-settings-${PV}/src/ \ + DESTDIR="${D}" \ + GTK3_AVAILABLE=$(usex gtk3 1 0) \ + LIBDIR="${D}/usr/$(get_libdir)" \ + NV_USE_BUNDLED_LIBJANSSON=0 \ + NV_VERBOSE=1 \ + PREFIX=/usr \ + DO_STRIP= \ + install + + if use static-libs; then + dolib.a "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/libXNVCtrl.a + + insinto /usr/include/NVCtrl + doins "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/*.h + fi + + insinto /usr/share/nvidia/ + doins nvidia-application-profiles-${PV}-key-documentation + + insinto /etc/nvidia + newins \ + nvidia-application-profiles-${PV}-rc nvidia-application-profiles-rc + + # There is no icon in the FreeBSD tarball. + use kernel_FreeBSD || \ + doicon ${NV_OBJ}/nvidia-settings.png + + domenu "${FILESDIR}"/nvidia-settings.desktop + + exeinto /etc/X11/xinit/xinitrc.d + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings + + insinto /etc/vulkan/icd.d + doins nvidia_icd.json + fi + + dobin ${NV_OBJ}/nvidia-bug-report.sh + + if has_multilib_profile && use multilib; then + local OABI=${ABI} + for ABI in $(get_install_abis); do + src_install-libs + done + ABI=${OABI} + unset OABI + else + src_install-libs + fi + + is_final_abi || die "failed to iterate through all ABIs" + + readme.gentoo_create_doc +} + +src_install-libs() { + local inslibdir=$(get_libdir) + local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib" + local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia" + local libdir=${NV_OBJ} + + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "x86" ]]; then + libdir=${NV_OBJ}/32 + fi + + if use X; then + NV_GLX_LIBRARIES=( + "libEGL.so.1 ${GL_ROOT}" + "libEGL_nvidia.so.${NV_SOVER} ${GL_ROOT}" + "libGL.so.$(usex compat ${NV_SOVER} 1.0.0) ${GL_ROOT}" + "libGLESv1_CM.so.1 ${GL_ROOT}" + "libGLESv1_CM_nvidia.so.${NV_SOVER} ${GL_ROOT}" + "libGLESv2.so.2 ${GL_ROOT}" + "libGLESv2_nvidia.so.${NV_SOVER} ${GL_ROOT}" + "libGLX.so.0 ${GL_ROOT}" + "libGLX_nvidia.so.${NV_SOVER} ${GL_ROOT}" + "libGLdispatch.so.0 ${GL_ROOT}" + "libOpenCL.so.1.0.0 ${CL_ROOT}" + "libOpenGL.so.0 ${GL_ROOT}" + "libcuda.so.${NV_SOVER}" + "libnvcuvid.so.${NV_SOVER}" + "libnvidia-compiler.so.${NV_SOVER}" + "libnvidia-eglcore.so.${NV_SOVER}" + "libnvidia-encode.so.${NV_SOVER}" + "libnvidia-fatbinaryloader.so.${NV_SOVER}" + "libnvidia-fbc.so.${NV_SOVER}" + "libnvidia-glcore.so.${NV_SOVER}" + "libnvidia-glsi.so.${NV_SOVER}" + "libnvidia-ifr.so.${NV_SOVER}" + "libnvidia-opencl.so.${NV_SOVER}" + "libnvidia-ptxjitcompiler.so.${NV_SOVER}" + "libvdpau_nvidia.so.${NV_SOVER}" + ) + + if use wayland && has_multilib_profile && [[ ${ABI} == "amd64" ]]; + then + NV_GLX_LIBRARIES+=( + "libnvidia-egl-wayland.so.${NV_SOVER}" + ) + fi + + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "amd64" ]]; + then + NV_GLX_LIBRARIES+=( + "libnvidia-wfb.so.${NV_SOVER}" + ) + fi + + if use kernel_FreeBSD; then + NV_GLX_LIBRARIES+=( + "libnvidia-tls.so.${NV_SOVER}" + ) + fi + + if use kernel_linux; then + NV_GLX_LIBRARIES+=( + "libnvidia-ml.so.${NV_SOVER}" + "tls/libnvidia-tls.so.${NV_SOVER}" + ) + fi + + for NV_LIB in "${NV_GLX_LIBRARIES[@]}"; do + donvidia ${libdir}/${NV_LIB} + done + fi +} + +pkg_preinst() { + if use driver && use kernel_linux; then + linux-mod_pkg_preinst + + local videogroup="$(egetent group video | cut -d ':' -f 3)" + if [ -z "${videogroup}" ]; then + eerror "Failed to determine the video group gid" + die "Failed to determine the video group gid" + else + sed -i \ + -e "s:PACKAGE:${PF}:g" \ + -e "s:VIDEOGID:${videogroup}:" \ + "${D}"/etc/modprobe.d/nvidia.conf || die + fi + fi + + # Clean the dynamic libGL stuff's home to ensure + # we dont have stale libs floating around + if [ -d "${ROOT}"/usr/lib/opengl/nvidia ]; then + rm -rf "${ROOT}"/usr/lib/opengl/nvidia/* + fi + # Make sure we nuke the old nvidia-glx's env.d file + if [ -e "${ROOT}"/etc/env.d/09nvidia ]; then + rm -f "${ROOT}"/etc/env.d/09nvidia + fi +} + +pkg_postinst() { + use driver && use kernel_linux && linux-mod_pkg_postinst + + # Switch to the nvidia implementation + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia + "${ROOT}"/usr/bin/eselect opencl set --use-old nvidia + + readme.gentoo_print_elog + + if ! use X; then + elog "You have elected to not install the X.org driver. Along with" + elog "this the OpenGL libraries and VDPAU libraries were not" + elog "installed. Additionally, once the driver is loaded your card" + elog "and fan will run at max speed which may not be desirable." + elog "Use the 'nvidia-smi' init script to have your card and fan" + elog "speed scale appropriately." + elog + fi + if ! use tools; then + elog "USE=tools controls whether the nvidia-settings application" + elog "is installed. If you would like to use it, enable that" + elog "flag and re-emerge this ebuild. Optionally you can install" + elog "media-video/nvidia-settings" + elog + fi +} + +pkg_prerm() { + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11 +} + +pkg_postrm() { + use driver && use kernel_linux && linux-mod_pkg_postrm + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11 +}