remove gcc version mismatch check; add patches up to kernel 6.3 [release 340.108-16mamba;Thu Jul 27 2023]

This commit is contained in:
Silvan Calarco 2024-01-06 07:47:10 +01:00
parent 7b2cc10558
commit e6eb6a544f
3 changed files with 193 additions and 14 deletions

View File

@ -0,0 +1,61 @@
--- a/kernel/conftest.sh 2023-02-24 10:35:02.633467500 +0100
+++ b/kernel/conftest.sh 2023-02-24 11:13:02.892079164 +0100
@@ -794,12 +794,19 @@
echo "$CONFTEST_PREAMBLE
#include <linux/acpi.h>
+ #include <linux/version.h>
acpi_op_remove conftest_op_remove_routine;
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0)
+ void conftest_acpi_device_ops_remove(struct acpi_device *device) {
+ conftest_op_remove_routine(device);
+ }
+ #else
int conftest_acpi_device_ops_remove(struct acpi_device *device) {
return conftest_op_remove_routine(device);
- }" > conftest$$.c
+ }
+ #endif" > conftest$$.c
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
--- a/kernel/nv-acpi.c 2023-02-24 10:35:02.643467765 +0100
+++ b/kernel/nv-acpi.c 2023-02-24 11:09:14.821580592 +0100
@@ -26,8 +26,12 @@
#if !defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) || (NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2)
static int nv_acpi_remove_two_args(struct acpi_device *device, int type);
#else
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0)
+static void nv_acpi_remove_one_arg(struct acpi_device *device);
+#else
static int nv_acpi_remove_one_arg(struct acpi_device *device);
#endif
+#endif
static void nv_acpi_event (acpi_handle, u32, void *);
static acpi_status nv_acpi_find_methods (acpi_handle, u32, void *, void **);
@@ -356,8 +360,12 @@
#if !defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) || (NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2)
static int nv_acpi_remove_two_args(struct acpi_device *device, int type)
#else
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0)
+static void nv_acpi_remove_one_arg(struct acpi_device *device)
+#else
static int nv_acpi_remove_one_arg(struct acpi_device *device)
#endif
+#endif
{
/*
* This function will cause RM to relinquish control of the VGA ACPI device.
@@ -407,7 +415,9 @@
device->driver_data = NULL;
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0)
return status;
+#endif
}
static void nv_acpi_event(acpi_handle handle, u32 event_type, void *data)

View File

@ -0,0 +1,106 @@
--- a/kernel/nv-mmap.c 2023-05-03 11:48:48.481814709 +0200
+++ b/kernel/nv-mmap.c 2023-05-03 11:51:39.220313386 +0200
@@ -312,7 +312,11 @@
goto done;
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+ vm_flags_set(vma, VM_IO);
+#else
vma->vm_flags |= VM_IO;
+#endif
}
else
{
@@ -363,8 +367,13 @@
NV_PRINT_AT(NV_DBG_MEMINFO, at);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+ vm_flags_set(vma, VM_IO | VM_LOCKED | VM_RESERVED);
+ vm_flags_set(vma, VM_DONTEXPAND | VM_DONTDUMP);
+#else
vma->vm_flags |= (VM_IO | VM_LOCKED | VM_RESERVED);
vma->vm_flags |= (VM_DONTEXPAND | VM_DONTDUMP);
+#endif
}
if (status == 0)
@@ -374,8 +383,13 @@
if ((prot & NV_PROTECT_WRITEABLE) == 0)
{
vma->vm_page_prot = NV_PGPROT_READ_ONLY(vma->vm_page_prot);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+ vm_flags_clear(vma, VM_WRITE);
+ vm_flags_clear(vma, VM_MAYWRITE);
+#else
vma->vm_flags &= ~VM_WRITE;
vma->vm_flags &= ~VM_MAYWRITE;
+#endif
}
vma->vm_ops = &nv_vm_ops;
--- a/kernel/uvm/nvidia_uvm_lite.c 2023-05-03 12:00:17.508256190 +0200
+++ b/kernel/uvm/nvidia_uvm_lite.c 2023-05-03 12:03:59.160897071 +0200
@@ -1524,10 +1524,17 @@
vma->vm_ops = &uvmlite_vma_ops;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+ // Prohibit copying the vma on fork().
+ vm_flags_set(vma, VM_DONTCOPY);
+ // Prohibt mremap() that would expand the vma.
+ vm_flags_set(vma, VM_DONTEXPAND);
+#else
// Prohibit copying the vma on fork().
vma->vm_flags |= VM_DONTCOPY;
// Prohibt mremap() that would expand the vma.
vma->vm_flags |= VM_DONTEXPAND;
+#endif
// Other cases of vma modification are detected in _mmap_open().
@@ -1546,9 +1553,15 @@
return -EINVAL;
vma->vm_ops = &counters_vma_ops;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+ vm_flags_clear(vma, VM_MAYWRITE);
+ // prevent vm_insert_page from modifying the vma's flags:
+ vm_flags_set(vma, VM_MIXEDMAP);
+#else
vma->vm_flags &= ~VM_MAYWRITE;
// prevent vm_insert_page from modifying the vma's flags:
vma->vm_flags |= VM_MIXEDMAP;
+#endif
ret = 0;
}
UVM_DBG_PRINT_RL("vma 0x%p [0x%p, 0x%p) ret %d pgoff"
@@ -2527,8 +2540,13 @@
// Subsequent access from userspace after the pages are unmapped will cause
// a SIGSEGV.
//
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+ vm_flags_clear(vma, VM_READ|VM_MAYREAD);
+ vm_flags_clear(vma, VM_WRITE|VM_MAYWRITE);
+#else
vma->vm_flags &= ~(VM_READ|VM_MAYREAD);
vma->vm_flags &= ~(VM_WRITE|VM_MAYWRITE);
+#endif
}
//
@@ -2536,8 +2554,13 @@
//
static void _set_vma_accessible(struct vm_area_struct * vma)
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+ vm_flags_set(vma, VM_READ|VM_MAYREAD);
+ vm_flags_set(vma, VM_WRITE|VM_MAYWRITE);
+#else
vma->vm_flags |= (VM_READ|VM_MAYREAD);
vma->vm_flags |= (VM_WRITE|VM_MAYWRITE);
+#endif
}
//

View File

@ -2,7 +2,7 @@
Name: nvidia_340
Version: 340.108
Epoch: 1
Release: 15mamba
Release: 16mamba
Summary: NVIDIA proprietary accelerated drivers for the Linux Kernel
Group: System/Kernel and Hardware
Vendor: openmamba
@ -29,6 +29,8 @@ Patch12: nvidia_340-340.108-kernel-5.17.patch
Patch13: nvidia_340-340.108-kernel-5.18.patch
Patch14: nvidia_340-340.108-kernel-6.0.patch
Patch15: nvidia_340-340.108-dkms-rename_nvidia_340.patch
Patch16: nvidia_340-340.108-kernel-6.2.patch
Patch17: nvidia_340-340.108-kernel-6.3.patch
License: no OSI Approved
## AUTOBUILDREQ-BEGIN
BuildRequires: glibc-devel
@ -116,23 +118,30 @@ cd current
#%patch0 -p1
#%patch1 -p1
##%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1 -b .kernel-5.14
%patch10 -p1 -b .kernel-5.15
%patch11 -p1 -b .kernel-5.16
%patch12 -p1 -b .kernel-5.17
%patch13 -p1 -b .kernel-5.18
%patch14 -p1 -b .kernel-6.0
%patch15 -p0 -b .dkms
%patch 3 -p1
%patch 4 -p1
%patch 5 -p1
%patch 6 -p1
%patch 7 -p1
%patch 8 -p1
%patch 9 -p1 -b .kernel-5.14
%patch 10 -p1 -b .kernel-5.15
%patch 11 -p1 -b .kernel-5.16
%patch 12 -p1 -b .kernel-5.17
%patch 13 -p1 -b .kernel-5.18
%patch 14 -p1 -b .kernel-6.0
%patch 15 -p0 -b .dkms
%patch 16 -p1 -b .kernel-6.2
%patch 17 -p1 -b .kernel-6.3
tar xf nvidia-persistenced-init.tar.bz2
# remove gcc version mismatch check (kernel built with different gcc version)
rm -f kernel/gcc-version-check.c
cd ..
%build
%install
@ -349,6 +358,9 @@ fi
%doc current/{NVIDIA_Changelog,README.txt} current/html
%changelog
* Thu Jul 27 2023 Silvan Calarco <silvan.calarco@mambasoft.it> 340.108-16mamba
- remove gcc version mismatch check; add patches up to kernel 6.3
* Tue Feb 21 2023 Silvan Calarco <silvan.calarco@mambasoft.it> 340.108-15mamba
- add nvidia libraries to ldconfig and regenerate initramfs