Update to 340.108-8

This commit is contained in:
graysky 2020-06-11 13:13:17 -04:00
parent 4fed10e0c8
commit 572ee5e4a7
7 changed files with 9 additions and 506 deletions

View File

@ -1,7 +1,7 @@
pkgbase = nvidia-340xx
pkgdesc = NVIDIA drivers for linux, 340xx legacy branch
pkgver = 340.108
pkgrel = 7
pkgrel = 8
url = https://www.nvidia.com/
arch = x86_64
license = custom
@ -11,17 +11,9 @@ pkgbase = nvidia-340xx
conflicts = nvidia
options = !strip
source = https://us.download.nvidia.com/XFree86/Linux-x86_64/340.108/NVIDIA-Linux-x86_64-340.108-no-compat32.run
source = 01-fix_multi_core_build.patch
source = 02-unfuck-for-340.108-build-fix.patch
source = 03-unfuck-for-5.5.x.patch
source = 04-fix_message_in_dmesg.patch
source = 05-unfuck-for-kernel-5.6.x.patch
source = kernel-5.7.patch::https://gitlab.manjaro.org/packages/extra/linux57-extramodules/nvidia-340xx/-/raw/master/kernel-5.7.patch?inline=false
sha256sums = 995d44fef587ff5284497a47a95d71adbee0c13020d615e940ac928f180f5b77
sha256sums = 82d14e9e6ec47c345d225d9f398238b7254cd5ae581c70e8521b9157ec747890
sha256sums = 2b7e3ef24846a40f4492e749be946e4f7f70ebed054bc2c9079f6cbdcbfabe57
sha256sums = c28d65854dd03e6a9e00d79fa0ca3521c11b2c198882bbd50870c8e71d18d765
sha256sums = 7f90e80be6338f6fc902d257d8ceb09e89b40d008f7a3ad9fe82833cd5b89316
sha256sums = ac7e234b4304c621d8187823aa2c84db219fb1bec23099423b11efd6c30b39a2
sha256sums = c5f4e2d8840bef97b077da2ed05340a047a8ec420feab6153f7a59e0c547f877
pkgname = nvidia-340xx
pkgdesc = NVIDIA drivers for linux, 340xx legacy branch

View File

@ -1,20 +0,0 @@
This patch will allow the call to make by dkms to use all host cpu cores.
See: https://github.com/dell/dkms/issues/100
--- a/dkms.conf 2019-12-11 17:04:24.000000000 -0500
+++ b/dkms.conf 2020-01-10 12:47:44.770501121 -0500
@@ -1,7 +1,13 @@
+if [ -x /usr/bin/nproc ]; then
+ num_cpu_cores=$(nproc)
+else
+ num_cpu_cores=1
+fi
+
PACKAGE_NAME="nvidia"
PACKAGE_VERSION="340.108"
BUILT_MODULE_NAME[0]="$PACKAGE_NAME"
DEST_MODULE_LOCATION[0]="/kernel/drivers/video"
-MAKE[0]="make module KERNEL_UNAME=${kernelver}"
+MAKE[0]="make -j$num_cpu_cores module KERNEL_UNAME=${kernelver}"
CLEAN="make clean"
AUTOINSTALL="yes"

View File

@ -1,48 +0,0 @@
diff --git a/uvm/nvidia_uvm_lite.c b/uvm/nvidia_uvm_lite.c
index 6943e7c..c5d232c 100644
--- a/uvm/nvidia_uvm_lite.c
+++ b/uvm/nvidia_uvm_lite.c
@@ -820,7 +820,13 @@ done:
}
#if defined(NV_VM_OPERATIONS_STRUCT_HAS_FAULT)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
+vm_fault_t _fault(struct vm_fault *vmf)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+int _fault(struct vm_fault *vmf)
+#else
int _fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+#endif
{
#if defined(NV_VM_FAULT_HAS_ADDRESS)
unsigned long vaddr = vmf->address;
@@ -828,8 +834,15 @@ int _fault(struct vm_area_struct *vma, struct vm_fault *vmf)
unsigned long vaddr = (unsigned long)vmf->virtual_address;
#endif
struct page *page = NULL;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
+ vm_fault_t retval;
+#else
int retval;
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+ struct vm_area_struct *vma = vmf->vma;
+#endif
retval = _fault_common(vma, vaddr, &page, vmf->flags);
vmf->page = page;
@@ -868,7 +881,13 @@ static struct vm_operations_struct uvmlite_vma_ops =
// it's dealing with anonymous mapping (see handle_pte_fault).
//
#if defined(NV_VM_OPERATIONS_STRUCT_HAS_FAULT)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
+vm_fault_t _sigbus_fault(struct vm_fault *vmf)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+int _sigbus_fault(struct vm_fault *vmf)
+#else
int _sigbus_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+#endif
{
vmf->page = NULL;
return VM_FAULT_SIGBUS;

View File

@ -1,13 +0,0 @@
From: Osvaldo Costa <osvaldogcosta90@gmail.com>
--
diff --git a/uvm/Makefile b/uvm/Makefile
index 0cad8ff..043a08d 100644
--- a/uvm/Makefile
+++ b/uvm/Makefile
@@ -207,6 +207,7 @@ ccflags-y += $(EXTRA_CFLAGS)
RM_MODULE_SYMVERS:= $(RM_OUT_DIR)/Module.symvers
UVM_MODULE_SYMVERS:= $(obj)/Module.symvers
+KBUILD_EXTRA_SYMBOLS:= $(UVM_MODULE_SYMVERS)
module $(MODULE_NAME).ko: $(UVM_MODULE_SYMVERS) debug_diagnostics_printing

View File

@ -1,51 +0,0 @@
Patch by vova7890
> vova7890 commented on 2020-03-19 01:01
> I'm facing this message in dmesg: Bad or missing usercopy whitelist?
> Kernel memory exposure attempt detected from SLUB object 'nvidia_stack_t'
> A little search and I had portback this patch to 340xx.
> Can you please add this? https://zvova7890.com.ua/s/ed9JJG8KyQKQQBx
--
vova7890 commented on 2020-03-19 01:01
diff -Naur a/nv.c b/nv.c
--- a/nv.c 2019-12-12 00:04:24.000000000 +0200
+++ b/nv.c 2020-03-19 04:21:13.923750900 +0200
@@ -752,7 +752,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_USERCOPY(nv_stack_t_cache, NV_STACK_CACHE_STR, nv_stack_t);
if (nv_stack_t_cache == NULL)
{
nv_printf(NV_DBG_ERRORS, "NVRM: stack cache allocation failed!\n");
diff -Naur a/nv-linux.h b/nv-linux.h
--- a/nv-linux.h 2019-12-12 00:04:24.000000000 +0200
+++ b/nv-linux.h 2020-03-19 04:21:13.927084233 +0200
@@ -762,9 +762,27 @@
kmem_cache = kmem_cache_create(name, sizeof(type), \
0, 0, NULL); \
}
+#define NV_KMEM_CACHE_CREATE_FULL(name, size, align, flags, ctor) \
+ kmem_cache_create(name, size, align, flags, ctor)
#else
#error "NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT value unrecognized!"
#endif
+
+#define NV_KMEM_CACHE_CREATE_FULL_USERCOPY(name, size, align, flags, useroffset, usersize, ctor) \
+ kmem_cache_create_usercopy(name, size, align, flags, useroffset, usersize, ctor);
+
+#ifdef SLAB_USERCOPY
+#define NV_KMEM_CACHE_CREATE_USERCOPY(kmem_cache, name, type) \
+ { \
+ kmem_cache = NV_KMEM_CACHE_CREATE_FULL(name, sizeof(type), 0, SLAB_USERCOPY, NULL); \
+ }
+#else
+#define NV_KMEM_CACHE_CREATE_USERCOPY(kmem_cache, name, type) \
+ { \
+ kmem_cache = NV_KMEM_CACHE_CREATE_FULL_USERCOPY(name, sizeof(type), 0, 0, 0, sizeof(type), NULL); \
+ }
+#endif
+
#define NV_KMEM_CACHE_DESTROY(kmem_cache) \
{ \
kmem_cache_destroy(kmem_cache); \

View File

@ -1,342 +0,0 @@
diff --git a/Makefile b/Makefile
index 125a690..7575e44 100644
--- a/Makefile
+++ b/Makefile
@@ -114,6 +114,7 @@ COMPILE_TESTS = \
nvmap_support \
acpi_evaluate_integer \
ioremap_cache \
+ ioremap_nocache \
ioremap_wc \
proc_dir_entry \
INIT_WORK \
@@ -132,6 +133,7 @@ COMPILE_TESTS = \
proc_create_data \
pde_data \
proc_remove \
+ proc_ops \
sg_table \
pm_vt_switch_required \
pci_save_state \
@@ -148,8 +150,10 @@ COMPILE_TESTS = \
vm_fault_has_address \
drm_driver_unload_has_int_return_type \
drm_legacy_pci_init \
+ drm_pci_init \
timer_setup \
do_gettimeofday \
+ timeval \
drm_gem_object_put_unlocked \
drm_driver_legacy_feature_bit_present \
drm_driver_prime_flag_present
diff --git a/conftest.sh b/conftest.sh
index b7a85f0..08b20cd 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -1188,6 +1188,19 @@ compile_test() {
compile_check_conftest "$CODE" "NV_IOREMAP_CACHE_PRESENT" "" "functions"
;;
+ ioremap_nocache)
+ #
+ # Determine if the ioremap_nocache() function is present.
+ #
+ CODE="
+ #include <asm/io.h>
+ void conftest_ioremap_nocache(void) {
+ ioremap_nocache();
+ }"
+
+ compile_check_conftest "$CODE" "NV_IOREMAP_NOCACHE_PRESENT" "" "functions"
+ ;;
+
ioremap_wc)
#
# Determine if the ioremap_wc() function is present.
@@ -1607,6 +1620,19 @@ compile_test() {
compile_check_conftest "$CODE" "NV_PROC_REMOVE_PRESENT" "" "functions"
;;
+ proc_ops)
+ #
+ # Determine if struct proc_ops is present.
+ #
+ CODE="
+ #include <linux/proc_fs.h>
+ void conftest_proc_ops(void) {
+ struct proc_ops pops;
+ }"
+
+ compile_check_conftest "$CODE" "NV_PROC_OPS_PRESENT" "" "types"
+ ;;
+
vm_operations_struct)
#
# Determine if the 'vm_operations_struct' structure has
@@ -2066,6 +2092,28 @@ compile_test() {
compile_check_conftest "$CODE" "NV_DRM_LEGACY_PCI_INIT_PRESENT" "" "functions"
;;
+ drm_pci_init)
+ #
+ # Determine if drm_pci_init() is present. drm_pci_init() was
+ # deprecated and renamed to drm_legacy_pci_init by:
+ #
+ # 2017-05-24 10631d724deff712343d96dd3017cd323349f761
+ #
+ CODE="
+ #if defined(NV_DRM_DRMP_H_PRESENT)
+ #include <drm/drmP.h>
+ #endif
+
+ #if defined(NV_DRM_DRM_PCI_H_PRESENT)
+ #include <drm/drm_pci.h>
+ #endif
+ void conftest_drm_pci_init(void) {
+ drm_pci_init();
+ }"
+
+ compile_check_conftest "$CODE" "NV_DRM_PCI_INIT_PRESENT" "" "functions"
+ ;;
+
timer_setup)
#
# Determine if the function timer_setup() is present.
@@ -2109,6 +2157,22 @@ compile_test() {
compile_check_conftest "$CODE" "NV_DO_GETTIMEOFDAY_PRESENT" "" "functions"
;;
+ timeval)
+ #
+ # Determine if timeval is present.
+ #
+ CODE="
+ #include <linux/time.h>
+ #if defined(NV_LINUX_KTIME_H_PRESENT)
+ #include <linux/ktime.h>
+ #endif
+ void conftest_timeval(void) {
+ struct timeval tv;
+ }"
+
+ compile_check_conftest "$CODE" "NV_TIMEVAL_PRESENT" "" "types"
+ ;;
+
drm_gem_object_put_unlocked)
#
# Determine if the function drm_gem_object_put_unlocked() is present.
diff --git a/nv-drm.c b/nv-drm.c
index 0d1cdbf..4e6fa48 100644
--- a/nv-drm.c
+++ b/nv-drm.c
@@ -47,7 +47,61 @@
#include <drm/drm_gem.h>
#endif
-#if defined(NV_DRM_LEGACY_PCI_INIT_PRESENT)
+#if !defined(NV_DRM_LEGACY_PCI_INIT_PRESENT) && !defined(NV_DRM_PCI_INIT_PRESENT)
+static int nv_drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
+{
+ struct pci_dev *pdev = NULL;
+ const struct pci_device_id *pid;
+ int i;
+
+ DRM_DEBUG("\n");
+
+ if (WARN_ON(!(driver->driver_features & DRIVER_LEGACY)))
+ return -EINVAL;
+
+ /* If not using KMS, fall back to stealth mode manual scanning. */
+ INIT_LIST_HEAD(&driver->legacy_dev_list);
+ for (i = 0; pdriver->id_table[i].vendor != 0; i++) {
+ pid = &pdriver->id_table[i];
+
+ /* Loop around setting up a DRM device for each PCI device
+ * matching our ID and device class. If we had the internal
+ * function that pci_get_subsys and pci_get_class used, we'd
+ * be able to just pass pid in instead of doing a two-stage
+ * thing.
+ */
+ pdev = NULL;
+ while ((pdev =
+ pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
+ pid->subdevice, pdev)) != NULL) {
+ if ((pdev->class & pid->class_mask) != pid->class)
+ continue;
+
+ /* stealth mode requires a manual probe */
+ pci_dev_get(pdev);
+ drm_get_pci_dev(pdev, pid, driver);
+ }
+ }
+ return 0;
+}
+
+static void nv_drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
+{
+ struct drm_device *dev, *tmp;
+ DRM_DEBUG("\n");
+
+ if (!(driver->driver_features & DRIVER_LEGACY)) {
+ WARN_ON(1);
+ } else {
+ list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
+ legacy_dev_list) {
+ list_del(&dev->legacy_dev_list);
+ drm_put_dev(dev);
+ }
+ }
+ DRM_INFO("Module unloaded\n");
+}
+#elif defined(NV_DRM_LEGACY_PCI_INIT_PRESENT)
#define nv_drm_pci_init drm_legacy_pci_init
#define nv_drm_pci_exit drm_legacy_pci_exit
#else
diff --git a/nv-linux.h b/nv-linux.h
index b90eb95..1d709a3 100644
--- a/nv-linux.h
+++ b/nv-linux.h
@@ -688,11 +688,15 @@ extern nv_spinlock_t km_lock;
VM_ALLOC_RECORD(ptr, size, "vm_ioremap"); \
}
+#if defined(NV_IOREMAP_NOCACHE_PRESENT)
#define NV_IOREMAP_NOCACHE(ptr, physaddr, size) \
{ \
(ptr) = ioremap_nocache(physaddr, size); \
VM_ALLOC_RECORD(ptr, size, "vm_ioremap_nocache"); \
}
+#else
+#define NV_IOREMAP_NOCACHE NV_IOREMAP
+#endif
#if defined(NV_IOREMAP_CACHE_PRESENT)
#define NV_IOREMAP_CACHE(ptr, physaddr, size) \
@@ -1989,6 +1993,19 @@ extern NvU32 nv_assign_gpu_count;
})
#endif
+#if defined(NV_PROC_OPS_PRESENT)
+#define NV_CREATE_PROC_FILE(filename,parent,__name,__data) \
+ ({ \
+ struct proc_dir_entry *__entry; \
+ int mode = (S_IFREG | S_IRUGO); \
+ const struct proc_ops *fops = &nv_procfs_##__name##_fops; \
+ if (fops->proc_write != 0) \
+ mode |= S_IWUSR; \
+ __entry = NV_CREATE_PROC_ENTRY(filename, mode, parent, fops, \
+ __data); \
+ __entry; \
+ })
+#else
#define NV_CREATE_PROC_FILE(filename,parent,__name,__data) \
({ \
struct proc_dir_entry *__entry; \
@@ -2000,6 +2017,7 @@ extern NvU32 nv_assign_gpu_count;
__data); \
__entry; \
})
+#endif
/*
* proc_mkdir_mode exists in Linux 2.6.9, but isn't exported until Linux 3.0.
@@ -2041,6 +2059,24 @@ extern NvU32 nv_assign_gpu_count;
remove_proc_entry(entry->name, entry->parent);
#endif
+#if defined(NV_PROC_OPS_PRESENT)
+#define NV_DEFINE_PROCFS_SINGLE_FILE(__name) \
+ static int nv_procfs_open_##__name( \
+ struct inode *inode, \
+ struct file *filep \
+ ) \
+ { \
+ return single_open(filep, nv_procfs_read_##__name, \
+ NV_PDE_DATA(inode)); \
+ } \
+ \
+ static const struct proc_ops nv_procfs_##__name##_fops = { \
+ .proc_open = nv_procfs_open_##__name, \
+ .proc_read = seq_read, \
+ .proc_lseek = seq_lseek, \
+ .proc_release = single_release, \
+ };
+#else
#define NV_DEFINE_PROCFS_SINGLE_FILE(__name) \
static int nv_procfs_open_##__name( \
struct inode *inode, \
@@ -2058,6 +2094,7 @@ extern NvU32 nv_assign_gpu_count;
.llseek = seq_lseek, \
.release = single_release, \
};
+#endif
#endif /* CONFIG_PROC_FS */
diff --git a/nv-procfs.c b/nv-procfs.c
index ebca3e8..110cce1 100644
--- a/nv-procfs.c
+++ b/nv-procfs.c
@@ -409,6 +409,15 @@ done:
return ((status < 0) ? status : (int)count);
}
+#if defined(NV_PROC_OPS_PRESENT)
+static struct proc_ops nv_procfs_registry_fops = {
+ .proc_open = nv_procfs_open_registry,
+ .proc_read = seq_read,
+ .proc_write = nv_procfs_write_file,
+ .proc_lseek = seq_lseek,
+ .proc_release = nv_procfs_close_registry,
+};
+#else
static struct file_operations nv_procfs_registry_fops = {
.owner = THIS_MODULE,
.open = nv_procfs_open_registry,
@@ -417,6 +426,7 @@ static struct file_operations nv_procfs_registry_fops = {
.llseek = seq_lseek,
.release = nv_procfs_close_registry,
};
+#endif
static int
nv_procfs_read_unbind_lock(
@@ -538,6 +548,15 @@ done:
return rc;
}
+#if defined(NV_PROC_OPS_PRESENT)
+static struct proc_ops nv_procfs_unbind_lock_fops = {
+ .proc_open = nv_procfs_open_unbind_lock,
+ .proc_read = seq_read,
+ .proc_write = nv_procfs_write_file,
+ .proc_lseek = seq_lseek,
+ .proc_release = nv_procfs_close_unbind_lock,
+};
+#else
static struct file_operations nv_procfs_unbind_lock_fops = {
.owner = THIS_MODULE,
.open = nv_procfs_open_unbind_lock,
@@ -546,6 +565,7 @@ static struct file_operations nv_procfs_unbind_lock_fops = {
.llseek = seq_lseek,
.release = nv_procfs_close_unbind_lock,
};
+#endif
static int
nv_procfs_read_text_file(
diff --git a/nv-time.h b/nv-time.h
index a34ceb2..c904913 100644
--- a/nv-time.h
+++ b/nv-time.h
@@ -28,6 +28,10 @@
#include <linux/ktime.h>
#endif
+#if !defined(NV_TIMEVAL_PRESENT)
+#define timeval __kernel_old_timeval
+#endif
+
static inline void nv_gettimeofday(struct timeval *tv)
{
#ifdef NV_DO_GETTIMEOFDAY_PRESENT

View File

@ -6,7 +6,7 @@
pkgbase=nvidia-340xx
pkgname=(nvidia-340xx nvidia-340xx-dkms)
pkgver=340.108
pkgrel=7
pkgrel=8
pkgdesc="NVIDIA drivers for linux, 340xx legacy branch"
arch=('x86_64')
url="https://www.nvidia.com/"
@ -14,21 +14,11 @@ makedepends=("nvidia-340xx-utils=${pkgver}" 'linux>=5.5' 'linux-headers>=5.5')
conflicts=('nvidia')
license=('custom')
options=(!strip)
# seems manjaro is keeping this current
# https://gitlab.manjaro.org/packages?utf8=%E2%9C%93&filter=nvidia-340xx
source=("https://us.download.nvidia.com/XFree86/Linux-x86_64/${pkgver}/NVIDIA-Linux-x86_64-${pkgver}-no-compat32.run"
01-fix_multi_core_build.patch
02-unfuck-for-340.108-build-fix.patch
03-unfuck-for-5.5.x.patch
04-fix_message_in_dmesg.patch
05-unfuck-for-kernel-5.6.x.patch
kernel-5.7.patch::https://gitlab.manjaro.org/packages/extra/linux57-extramodules/nvidia-340xx/-/raw/master/kernel-5.7.patch?inline=false
)
sha256sums=('995d44fef587ff5284497a47a95d71adbee0c13020d615e940ac928f180f5b77'
'82d14e9e6ec47c345d225d9f398238b7254cd5ae581c70e8521b9157ec747890'
'2b7e3ef24846a40f4492e749be946e4f7f70ebed054bc2c9079f6cbdcbfabe57'
'c28d65854dd03e6a9e00d79fa0ca3521c11b2c198882bbd50870c8e71d18d765'
'7f90e80be6338f6fc902d257d8ceb09e89b40d008f7a3ad9fe82833cd5b89316'
'ac7e234b4304c621d8187823aa2c84db219fb1bec23099423b11efd6c30b39a2')
'c5f4e2d8840bef97b077da2ed05340a047a8ec420feab6153f7a59e0c547f877')
_pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32"
# default is 'linux' substitute custom name here
@ -40,14 +30,9 @@ prepare() {
sh "${_pkg}.run" --extract-only
cd "${_pkg}"
# patches here
local src
for src in "${source[@]}"; do
src="${src%%::*}"
src="${src##*/}"
[[ $src = *.patch ]] || continue
(cd kernel ; patch -p1 --no-backup-if-mismatch -i "../../$src")
done
# seems manjaro is keeping this current
# https://gitlab.manjaro.org/packages?utf8=%E2%9C%93&filter=nvidia-340xx
(patch -p1 --no-backup-if-mismatch -i "$srcdir"/kernel-5.7.patch)
cp -a kernel kernel-dkms
}