Merge pull request #4 from piernov/master

Fix for kernel 6.3
This commit is contained in:
JerryXiao 2023-05-03 20:13:40 +08:00 committed by GitHub
commit f472f9297f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 113 additions and 3 deletions

View file

@ -1,7 +1,7 @@
pkgbase = nvidia-340xx pkgbase = nvidia-340xx
pkgdesc = NVIDIA drivers for linux, 340xx legacy branch pkgdesc = NVIDIA drivers for linux, 340xx legacy branch
pkgver = 340.108 pkgver = 340.108
pkgrel = 32 pkgrel = 33
url = https://www.nvidia.com/ url = https://www.nvidia.com/
arch = x86_64 arch = x86_64
license = custom license = custom
@ -24,6 +24,7 @@ pkgbase = nvidia-340xx
source = 0010-kernel-5.18.patch source = 0010-kernel-5.18.patch
source = 0011-kernel-6.0.patch source = 0011-kernel-6.0.patch
source = 0012-kernel-6.2.patch source = 0012-kernel-6.2.patch
source = 0013-kernel-6.3.patch
b2sums = 6538bbec53b10f8d20977f9b462052625742e9709ef06e24cf2e55de5d0c55f1620a4bb21396cfd89ebc54c32f921ea17e3e47eaa95abcbc24ecbd144fb89028 b2sums = 6538bbec53b10f8d20977f9b462052625742e9709ef06e24cf2e55de5d0c55f1620a4bb21396cfd89ebc54c32f921ea17e3e47eaa95abcbc24ecbd144fb89028
b2sums = 49d99f612e8eee3ab5e34083c25348bfd14ed5fc8a7984dafc0dad7c0ae0df2c0b2a63a1bb993da440eb0a60293d7c753ca3889bd2f51991b8ddc51bce2fe4a8 b2sums = 49d99f612e8eee3ab5e34083c25348bfd14ed5fc8a7984dafc0dad7c0ae0df2c0b2a63a1bb993da440eb0a60293d7c753ca3889bd2f51991b8ddc51bce2fe4a8
b2sums = 7150233df867a55f57aa5e798b9c7618329d98459fecc35c4acfad2e9772236cb229703c4fa072381c509279d0588173d65f46297231f4d3bfc65a1ef52e65b1 b2sums = 7150233df867a55f57aa5e798b9c7618329d98459fecc35c4acfad2e9772236cb229703c4fa072381c509279d0588173d65f46297231f4d3bfc65a1ef52e65b1
@ -38,6 +39,7 @@ pkgbase = nvidia-340xx
b2sums = d69c9acbe550d5fccca68ca6a0d5095cbcaf887d2bc43704a8eb85533896692f16701eef07ead297881f596f5502c3105bb5bea77b2dcaf6c4dc2b49941f9f19 b2sums = d69c9acbe550d5fccca68ca6a0d5095cbcaf887d2bc43704a8eb85533896692f16701eef07ead297881f596f5502c3105bb5bea77b2dcaf6c4dc2b49941f9f19
b2sums = 682a7b8e58d2a008531b7e5179e32c0c71adad673891a1057acd1aa26e410d9d93ff607e46257c6701619621cee1a27e613ec9ae19a580acdd6f68f1c1fdedea b2sums = 682a7b8e58d2a008531b7e5179e32c0c71adad673891a1057acd1aa26e410d9d93ff607e46257c6701619621cee1a27e613ec9ae19a580acdd6f68f1c1fdedea
b2sums = 47681d1e4b16f0b50775120b0a02bc6d279de692cde6086b895eef80bb4598e914ffe1fae81707a771d00f23df60ee4df591dfe042f5b764856d2e07306f3821 b2sums = 47681d1e4b16f0b50775120b0a02bc6d279de692cde6086b895eef80bb4598e914ffe1fae81707a771d00f23df60ee4df591dfe042f5b764856d2e07306f3821
b2sums = ae16e2a5674a8a93c85aa624e73b1671e85b2be1854caf967986f5764b946f7ca39a1e75c1617ee79da40a8d9a86cc1b17f64a787bc7a8c38f8dca426edeff46
pkgname = nvidia-340xx pkgname = nvidia-340xx
pkgdesc = NVIDIA drivers for linux, 340xx legacy branch pkgdesc = NVIDIA drivers for linux, 340xx legacy branch

106
0013-kernel-6.3.patch Normal file
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

@ -6,7 +6,7 @@
pkgbase=nvidia-340xx pkgbase=nvidia-340xx
pkgname=(nvidia-340xx nvidia-340xx-dkms); [ -n "$NVIDIA_340XX_DKMS_ONLY" ] && pkgname=(nvidia-340xx-dkms) pkgname=(nvidia-340xx nvidia-340xx-dkms); [ -n "$NVIDIA_340XX_DKMS_ONLY" ] && pkgname=(nvidia-340xx-dkms)
pkgver=340.108 pkgver=340.108
pkgrel=32 pkgrel=33
pkgdesc="NVIDIA drivers for linux, 340xx legacy branch" pkgdesc="NVIDIA drivers for linux, 340xx legacy branch"
arch=('x86_64') arch=('x86_64')
url="https://www.nvidia.com/" url="https://www.nvidia.com/"
@ -29,6 +29,7 @@ source=("https://us.download.nvidia.com/XFree86/Linux-x86_64/${pkgver}/NVIDIA-Li
0010-kernel-5.18.patch 0010-kernel-5.18.patch
0011-kernel-6.0.patch 0011-kernel-6.0.patch
0012-kernel-6.2.patch 0012-kernel-6.2.patch
0013-kernel-6.3.patch
) )
b2sums=('6538bbec53b10f8d20977f9b462052625742e9709ef06e24cf2e55de5d0c55f1620a4bb21396cfd89ebc54c32f921ea17e3e47eaa95abcbc24ecbd144fb89028' b2sums=('6538bbec53b10f8d20977f9b462052625742e9709ef06e24cf2e55de5d0c55f1620a4bb21396cfd89ebc54c32f921ea17e3e47eaa95abcbc24ecbd144fb89028'
'49d99f612e8eee3ab5e34083c25348bfd14ed5fc8a7984dafc0dad7c0ae0df2c0b2a63a1bb993da440eb0a60293d7c753ca3889bd2f51991b8ddc51bce2fe4a8' '49d99f612e8eee3ab5e34083c25348bfd14ed5fc8a7984dafc0dad7c0ae0df2c0b2a63a1bb993da440eb0a60293d7c753ca3889bd2f51991b8ddc51bce2fe4a8'
@ -43,7 +44,8 @@ b2sums=('6538bbec53b10f8d20977f9b462052625742e9709ef06e24cf2e55de5d0c55f1620a4bb
'0266e1baaac9ffbb94d9e916a693b1663d8686b15e970bfc30f7c51f051a0af9267aa5f6a12b68586c69d2e9796a1124488b3997ba4b26db1a5ac10a892f0df2' '0266e1baaac9ffbb94d9e916a693b1663d8686b15e970bfc30f7c51f051a0af9267aa5f6a12b68586c69d2e9796a1124488b3997ba4b26db1a5ac10a892f0df2'
'd69c9acbe550d5fccca68ca6a0d5095cbcaf887d2bc43704a8eb85533896692f16701eef07ead297881f596f5502c3105bb5bea77b2dcaf6c4dc2b49941f9f19' 'd69c9acbe550d5fccca68ca6a0d5095cbcaf887d2bc43704a8eb85533896692f16701eef07ead297881f596f5502c3105bb5bea77b2dcaf6c4dc2b49941f9f19'
'682a7b8e58d2a008531b7e5179e32c0c71adad673891a1057acd1aa26e410d9d93ff607e46257c6701619621cee1a27e613ec9ae19a580acdd6f68f1c1fdedea' '682a7b8e58d2a008531b7e5179e32c0c71adad673891a1057acd1aa26e410d9d93ff607e46257c6701619621cee1a27e613ec9ae19a580acdd6f68f1c1fdedea'
'47681d1e4b16f0b50775120b0a02bc6d279de692cde6086b895eef80bb4598e914ffe1fae81707a771d00f23df60ee4df591dfe042f5b764856d2e07306f3821') '47681d1e4b16f0b50775120b0a02bc6d279de692cde6086b895eef80bb4598e914ffe1fae81707a771d00f23df60ee4df591dfe042f5b764856d2e07306f3821'
'ae16e2a5674a8a93c85aa624e73b1671e85b2be1854caf967986f5764b946f7ca39a1e75c1617ee79da40a8d9a86cc1b17f64a787bc7a8c38f8dca426edeff46')
_pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32" _pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32"
# default is 'linux' substitute custom name here # default is 'linux' substitute custom name here