From 6bc392e2eeb8f92db7fa5457a223fe9cec53791c Mon Sep 17 00:00:00 2001 From: Gilver Date: Thu, 24 Apr 2025 06:39:20 -0500 Subject: [PATCH] fix(nvidia*): Update and fix various spec parts (#4396) * fix(nvidia*): Update and fix various spec parts * Negativo what the heck was that Signed-off-by: Gilver * ? * Blegh * WTF * ???? --------- Signed-off-by: Gilver --- .../nvidia/dkms-nvidia/dkms-nvidia.spec | 8 +- .../dkms-nvidia/nvidia-kernel-ccflags-y.patch | 234 ++++++++++++++++++ anda/system/nvidia/kmod-nvidia/anda.hcl | 9 + .../kmod-nvidia/kmod-nvidia-ldflags.patch | 37 +++ .../kmod-nvidia-no-hostname-whoami.patch | 27 ++ .../nvidia/kmod-nvidia/kmod-nvidia.spec | 98 ++++++++ .../kmod-nvidia/nvidia-kernel-ccflags-y.patch | 117 +++++++++ anda/system/nvidia/kmod-nvidia/update.rhai | 1 + .../nvidia/nvidia-driver/nvidia-driver.spec | 71 +++--- .../nvidia/nvidia-kmod-common/99-nvidia.conf | 3 - .../nvidia-kmod-common/nvidia-boot-update | 186 -------------- .../nvidia-kmod-common.spec | 32 +-- .../nvidia-kmod/nvidia-kernel-ccflags-y.patch | 234 ++++++++++++++++++ .../nvidia/nvidia-kmod/nvidia-kmod.spec | 8 +- 14 files changed, 810 insertions(+), 255 deletions(-) create mode 100644 anda/system/nvidia/dkms-nvidia/nvidia-kernel-ccflags-y.patch create mode 100644 anda/system/nvidia/kmod-nvidia/anda.hcl create mode 100644 anda/system/nvidia/kmod-nvidia/kmod-nvidia-ldflags.patch create mode 100644 anda/system/nvidia/kmod-nvidia/kmod-nvidia-no-hostname-whoami.patch create mode 100644 anda/system/nvidia/kmod-nvidia/kmod-nvidia.spec create mode 100644 anda/system/nvidia/kmod-nvidia/nvidia-kernel-ccflags-y.patch create mode 100644 anda/system/nvidia/kmod-nvidia/update.rhai delete mode 100644 anda/system/nvidia/nvidia-kmod-common/99-nvidia.conf delete mode 100755 anda/system/nvidia/nvidia-kmod-common/nvidia-boot-update create mode 100644 anda/system/nvidia/nvidia-kmod/nvidia-kernel-ccflags-y.patch diff --git a/anda/system/nvidia/dkms-nvidia/dkms-nvidia.spec b/anda/system/nvidia/dkms-nvidia/dkms-nvidia.spec index 17a866c2a7..2921ca287f 100644 --- a/anda/system/nvidia/dkms-nvidia/dkms-nvidia.spec +++ b/anda/system/nvidia/dkms-nvidia/dkms-nvidia.spec @@ -5,13 +5,14 @@ Name: dkms-%{modulename} Version: 575.51.02 -Release: 1%?dist +Release: 2%?dist Summary: NVIDIA display driver kernel module Epoch: 3 License: NVIDIA License URL: https://www.nvidia.com/object/unix.html Source0: https://download.nvidia.com/XFree86/Linux-%{_arch}/%{version}/NVIDIA-Linux-%{_arch}-%{version}.run Source1: %{name}.conf +Patch0: nvidia-kernel-ccflags-y.patch BuildRequires: sed Provides: %{modulename}-kmod = %{?epoch:%{epoch}:}%{version} Requires: %{modulename}-kmod-common = %{?epoch:%{epoch}:}%{version} @@ -26,6 +27,7 @@ This package provides the proprietary NVIDIA kernel driver modules. %prep sh %{SOURCE0} -x --target dkms-nvidia-%{version}-%{_arch} %setup -T -D -n dkms-nvidia-%{version}-%{_arch} +%autopatch -p1 cp -f %{SOURCE1} dkms.conf @@ -43,10 +45,14 @@ dkms add -m %{modulename} -v %{version} -q --rpm_safe_upgrade || : # Rebuild and make available for the currently running kernel: dkms build -m %{modulename} -v %{version} -q || : dkms install -m %{modulename} -v %{version} -q --force || : +dracut --regenerate-all --force --quiet %preun # Remove all versions from DKMS registry: dkms remove -m %{modulename} -v %{version} -q --all --rpm_safe_upgrade || : +if [ "$1" == 0 ]; then + dracut --regenerate-all --force --quiet +fi %files %{_usrsrc}/%{modulename}-%{version} diff --git a/anda/system/nvidia/dkms-nvidia/nvidia-kernel-ccflags-y.patch b/anda/system/nvidia/dkms-nvidia/nvidia-kernel-ccflags-y.patch new file mode 100644 index 0000000000..1792b26793 --- /dev/null +++ b/anda/system/nvidia/dkms-nvidia/nvidia-kernel-ccflags-y.patch @@ -0,0 +1,234 @@ +diff -Naur nvidia-kmod-575.51.02-x86_64.old/kernel/Kbuild nvidia-kmod-575.51.02-x86_64/kernel/Kbuild +--- nvidia-kmod-575.51.02-x86_64.old/kernel/Kbuild 2025-04-22 18:54:37.758155663 +0200 ++++ nvidia-kmod-575.51.02-x86_64/kernel/Kbuild 2025-04-22 18:54:45.069483044 +0200 +@@ -75,21 +75,15 @@ + $(eval include $(src)/$(_module)/$(_module).Kbuild)) + + +-# +-# Define CFLAGS that apply to all the NVIDIA kernel modules. EXTRA_CFLAGS +-# is deprecated since 2.6.24 in favor of ccflags-y, but we need to support +-# older kernels which do not have ccflags-y. Newer kernels append +-# $(EXTRA_CFLAGS) to ccflags-y for compatibility. +-# +- +-EXTRA_CFLAGS += -I$(src)/common/inc +-EXTRA_CFLAGS += -I$(src) +-EXTRA_CFLAGS += -Wall $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-format-extra-args +-EXTRA_CFLAGS += -D__KERNEL__ -DMODULE -DNVRM +-EXTRA_CFLAGS += -DNV_VERSION_STRING=\"575.51.02\" ++ccflags-y += -std=gnu17 ++ccflags-y += -I$(src)/common/inc ++ccflags-y += -I$(src) ++ccflags-y += -Wall $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-format-extra-args ++ccflags-y += -D__KERNEL__ -DMODULE -DNVRM ++ccflags-y += -DNV_VERSION_STRING=\"575.51.02\" + + ifneq ($(SYSSRCHOST1X),) +- EXTRA_CFLAGS += -I$(SYSSRCHOST1X) ++ ccflags-y += -I$(SYSSRCHOST1X) + endif + + # Some Android kernels prohibit driver use of filesystem functions like +@@ -99,57 +93,57 @@ + PLATFORM_IS_ANDROID ?= 0 + + ifeq ($(PLATFORM_IS_ANDROID),1) +- EXTRA_CFLAGS += -DNV_FILESYSTEM_ACCESS_AVAILABLE=0 ++ ccflags-y += -DNV_FILESYSTEM_ACCESS_AVAILABLE=0 + else +- EXTRA_CFLAGS += -DNV_FILESYSTEM_ACCESS_AVAILABLE=1 ++ ccflags-y += -DNV_FILESYSTEM_ACCESS_AVAILABLE=1 + endif + +-EXTRA_CFLAGS += -Wno-unused-function ++ccflags-y += -Wno-unused-function + + ifneq ($(NV_BUILD_TYPE),debug) +- EXTRA_CFLAGS += -Wuninitialized ++ ccflags-y += -Wuninitialized + endif + +-EXTRA_CFLAGS += -fno-strict-aliasing ++ccflags-y += -fno-strict-aliasing + + ifeq ($(ARCH),arm64) +- EXTRA_CFLAGS += -mstrict-align ++ ccflags-y += -mstrict-align + endif + + ifeq ($(NV_BUILD_TYPE),debug) +- EXTRA_CFLAGS += -g ++ ccflags-y += -g + endif + +-EXTRA_CFLAGS += -ffreestanding ++ccflags-y += -ffreestanding + + ifeq ($(ARCH),arm64) +- EXTRA_CFLAGS += -mgeneral-regs-only -march=armv8-a +- EXTRA_CFLAGS += $(call cc-option,-mno-outline-atomics,) ++ ccflags-y += -mgeneral-regs-only -march=armv8-a ++ ccflags-y += $(call cc-option,-mno-outline-atomics,) + endif + + ifeq ($(ARCH),x86_64) +- EXTRA_CFLAGS += -mno-red-zone -mcmodel=kernel ++ ccflags-y += -mno-red-zone -mcmodel=kernel + endif + + ifeq ($(ARCH),powerpc) +- EXTRA_CFLAGS += -mlittle-endian -mno-strict-align ++ ccflags-y += -mlittle-endian -mno-strict-align + endif + +-EXTRA_CFLAGS += -DNV_UVM_ENABLE +-EXTRA_CFLAGS += $(call cc-option,-Werror=undef,) +-EXTRA_CFLAGS += -DNV_SPECTRE_V2=$(NV_SPECTRE_V2) +-EXTRA_CFLAGS += -DNV_KERNEL_INTERFACE_LAYER ++ccflags-y += -DNV_UVM_ENABLE ++ccflags-y += $(call cc-option,-Werror=undef,) ++ccflags-y += -DNV_SPECTRE_V2=$(NV_SPECTRE_V2) ++ccflags-y += -DNV_KERNEL_INTERFACE_LAYER + + # + # Detect SGI UV systems and apply system-specific optimizations. + # + + ifneq ($(wildcard /proc/sgi_uv),) +- EXTRA_CFLAGS += -DNV_CONFIG_X86_UV ++ ccflags-y += -DNV_CONFIG_X86_UV + endif + + ifdef VGX_FORCE_VFIO_PCI_CORE +- EXTRA_CFLAGS += -DNV_VGPU_FORCE_VFIO_PCI_CORE ++ ccflags-y += -DNV_VGPU_FORCE_VFIO_PCI_CORE + endif + + WARNINGS_AS_ERRORS ?= +@@ -183,7 +177,7 @@ + + NV_CFLAGS_FROM_CONFTEST := $(shell $(NV_CONFTEST_CMD) build_cflags) + +-NV_CONFTEST_CFLAGS = $(NV_CFLAGS_FROM_CONFTEST) $(EXTRA_CFLAGS) -fno-pie ++NV_CONFTEST_CFLAGS = $(NV_CFLAGS_FROM_CONFTEST) $(ccflags-y) -fno-pie + NV_CONFTEST_CFLAGS += $(call cc-disable-warning,pointer-sign) + NV_CONFTEST_CFLAGS += $(call cc-option,-fshort-wchar,) + NV_CONFTEST_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types,) +diff -Naur nvidia-kmod-575.51.02-x86_64.old/kernel-open/Kbuild nvidia-kmod-575.51.02-x86_64/kernel-open/Kbuild +--- nvidia-kmod-575.51.02-x86_64.old/kernel-open/Kbuild 2025-04-22 18:54:37.828156191 +0200 ++++ nvidia-kmod-575.51.02-x86_64/kernel-open/Kbuild 2025-04-22 18:54:45.069786396 +0200 +@@ -75,21 +75,15 @@ + $(eval include $(src)/$(_module)/$(_module).Kbuild)) + + +-# +-# Define CFLAGS that apply to all the NVIDIA kernel modules. EXTRA_CFLAGS +-# is deprecated since 2.6.24 in favor of ccflags-y, but we need to support +-# older kernels which do not have ccflags-y. Newer kernels append +-# $(EXTRA_CFLAGS) to ccflags-y for compatibility. +-# +- +-EXTRA_CFLAGS += -I$(src)/common/inc +-EXTRA_CFLAGS += -I$(src) +-EXTRA_CFLAGS += -Wall $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-format-extra-args +-EXTRA_CFLAGS += -D__KERNEL__ -DMODULE -DNVRM +-EXTRA_CFLAGS += -DNV_VERSION_STRING=\"575.51.02\" ++ccflags-y += -std=gnu17 ++ccflags-y += -I$(src)/common/inc ++ccflags-y += -I$(src) ++ccflags-y += -Wall $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-format-extra-args ++ccflags-y += -D__KERNEL__ -DMODULE -DNVRM ++ccflags-y += -DNV_VERSION_STRING=\"575.51.02\" + + ifneq ($(SYSSRCHOST1X),) +- EXTRA_CFLAGS += -I$(SYSSRCHOST1X) ++ ccflags-y += -I$(SYSSRCHOST1X) + endif + + # Some Android kernels prohibit driver use of filesystem functions like +@@ -99,57 +93,57 @@ + PLATFORM_IS_ANDROID ?= 0 + + ifeq ($(PLATFORM_IS_ANDROID),1) +- EXTRA_CFLAGS += -DNV_FILESYSTEM_ACCESS_AVAILABLE=0 ++ ccflags-y += -DNV_FILESYSTEM_ACCESS_AVAILABLE=0 + else +- EXTRA_CFLAGS += -DNV_FILESYSTEM_ACCESS_AVAILABLE=1 ++ ccflags-y += -DNV_FILESYSTEM_ACCESS_AVAILABLE=1 + endif + +-EXTRA_CFLAGS += -Wno-unused-function ++ccflags-y += -Wno-unused-function + + ifneq ($(NV_BUILD_TYPE),debug) +- EXTRA_CFLAGS += -Wuninitialized ++ ccflags-y += -Wuninitialized + endif + +-EXTRA_CFLAGS += -fno-strict-aliasing ++ccflags-y += -fno-strict-aliasing + + ifeq ($(ARCH),arm64) +- EXTRA_CFLAGS += -mstrict-align ++ ccflags-y += -mstrict-align + endif + + ifeq ($(NV_BUILD_TYPE),debug) +- EXTRA_CFLAGS += -g ++ ccflags-y += -g + endif + +-EXTRA_CFLAGS += -ffreestanding ++ccflags-y += -ffreestanding + + ifeq ($(ARCH),arm64) +- EXTRA_CFLAGS += -mgeneral-regs-only -march=armv8-a +- EXTRA_CFLAGS += $(call cc-option,-mno-outline-atomics,) ++ ccflags-y += -mgeneral-regs-only -march=armv8-a ++ ccflags-y += $(call cc-option,-mno-outline-atomics,) + endif + + ifeq ($(ARCH),x86_64) +- EXTRA_CFLAGS += -mno-red-zone -mcmodel=kernel ++ ccflags-y += -mno-red-zone -mcmodel=kernel + endif + + ifeq ($(ARCH),powerpc) +- EXTRA_CFLAGS += -mlittle-endian -mno-strict-align ++ ccflags-y += -mlittle-endian -mno-strict-align + endif + +-EXTRA_CFLAGS += -DNV_UVM_ENABLE +-EXTRA_CFLAGS += $(call cc-option,-Werror=undef,) +-EXTRA_CFLAGS += -DNV_SPECTRE_V2=$(NV_SPECTRE_V2) +-EXTRA_CFLAGS += -DNV_KERNEL_INTERFACE_LAYER ++ccflags-y += -DNV_UVM_ENABLE ++ccflags-y += $(call cc-option,-Werror=undef,) ++ccflags-y += -DNV_SPECTRE_V2=$(NV_SPECTRE_V2) ++ccflags-y += -DNV_KERNEL_INTERFACE_LAYER + + # + # Detect SGI UV systems and apply system-specific optimizations. + # + + ifneq ($(wildcard /proc/sgi_uv),) +- EXTRA_CFLAGS += -DNV_CONFIG_X86_UV ++ ccflags-y += -DNV_CONFIG_X86_UV + endif + + ifdef VGX_FORCE_VFIO_PCI_CORE +- EXTRA_CFLAGS += -DNV_VGPU_FORCE_VFIO_PCI_CORE ++ ccflags-y += -DNV_VGPU_FORCE_VFIO_PCI_CORE + endif + + WARNINGS_AS_ERRORS ?= +@@ -183,7 +177,7 @@ + + NV_CFLAGS_FROM_CONFTEST := $(shell $(NV_CONFTEST_CMD) build_cflags) + +-NV_CONFTEST_CFLAGS = $(NV_CFLAGS_FROM_CONFTEST) $(EXTRA_CFLAGS) -fno-pie ++NV_CONFTEST_CFLAGS = $(NV_CFLAGS_FROM_CONFTEST) $(ccflags-y) -fno-pie + NV_CONFTEST_CFLAGS += $(call cc-disable-warning,pointer-sign) + NV_CONFTEST_CFLAGS += $(call cc-option,-fshort-wchar,) + NV_CONFTEST_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types,) diff --git a/anda/system/nvidia/kmod-nvidia/anda.hcl b/anda/system/nvidia/kmod-nvidia/anda.hcl new file mode 100644 index 0000000000..3aa67f1119 --- /dev/null +++ b/anda/system/nvidia/kmod-nvidia/anda.hcl @@ -0,0 +1,9 @@ +project pkg { + rpm { + spec = "kmod-nvidia.spec" + } + labels { + subrepo = "nvidia" + mock = 1 + } +} diff --git a/anda/system/nvidia/kmod-nvidia/kmod-nvidia-ldflags.patch b/anda/system/nvidia/kmod-nvidia/kmod-nvidia-ldflags.patch new file mode 100644 index 0000000000..7c6358c2a9 --- /dev/null +++ b/anda/system/nvidia/kmod-nvidia/kmod-nvidia-ldflags.patch @@ -0,0 +1,37 @@ +From 38b7e1478b58b983724ec817562301edd5c244a2 Mon Sep 17 00:00:00 2001 +From: Neal Gompa +Date: Mon, 7 Apr 2025 19:34:49 -0400 +Subject: [PATCH] src/nvidia/Makefile: Drop broken addition of userspace linker + flags + +The Makefile currently causes the package build of the kernel modules +to fail with the following error: + +ld: unrecognized option '-Wl,-z,relro' +ld: use the --help option for usage information +make[1]: *** [Makefile:214: _out/Linux_x86_64/nv-kernel.o] Error 1 +make: *** [Makefile:34: src/nvidia/_out/Linux_x86_64/nv-kernel.o] Error 2 + +Dropping this line fixes this issue. + +Signed-off-by: Neal Gompa +--- + src/nvidia/Makefile | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/src/nvidia/Makefile b/src/nvidia/Makefile +index 931a74c0..423414af 100644 +--- a/src/nvidia/Makefile ++++ b/src/nvidia/Makefile +@@ -208,8 +208,6 @@ all: $(NV_KERNEL_O) + + LINKER_SCRIPT = nv-kernel.ld + +-NV_KERNEL_O_LDFLAGS += $(LDFLAGS) +- + $(NV_KERNEL_O): $(OBJS) $(EXPORTS_LINK_COMMAND) $(LINKER_SCRIPT) + $(call quiet_cmd,LD) \ + $(NV_KERNEL_O_LDFLAGS) \ +-- +2.48.1 + diff --git a/anda/system/nvidia/kmod-nvidia/kmod-nvidia-no-hostname-whoami.patch b/anda/system/nvidia/kmod-nvidia/kmod-nvidia-no-hostname-whoami.patch new file mode 100644 index 0000000000..59038ca030 --- /dev/null +++ b/anda/system/nvidia/kmod-nvidia/kmod-nvidia-no-hostname-whoami.patch @@ -0,0 +1,27 @@ +diff -Naur open-gpu-kernel-modules-570.133.07.old/utils.mk open-gpu-kernel-modules-570.133.07/utils.mk +--- open-gpu-kernel-modules-570.133.07.old/utils.mk 2025-04-12 15:13:09.368747667 +0200 ++++ open-gpu-kernel-modules-570.133.07/utils.mk 2025-04-12 15:14:11.297683469 +0200 +@@ -114,14 +114,8 @@ + CHMOD ?= chmod + OBJCOPY ?= objcopy + XZ ?= xz +-WHOAMI ?= whoami + PKG_CONFIG ?= pkg-config + +-ifndef HOSTNAME +- HOSTNAME = $(shell hostname) +-endif +- +- + NV_AUTO_DEPEND ?= 1 + NV_VERBOSE ?= 0 + +@@ -551,7 +545,7 @@ + # g_nvid_string.c depends on all objects except g_nvid_string.o, and version.mk + $(NVIDSTRING): $$(filter-out $$(call BUILD_OBJECT_LIST,$$(NVIDSTRING)), $(3)) $$(VERSION_MK) + $(at_if_quiet)$$(MKDIR) $$(dir $$@) +- $(at_if_quiet)$$(ECHO) "const char $(1)[] = \"nvidia id: NVIDIA $$(strip $(2)) for $$(TARGET_ARCH) $$(NVIDIA_VERSION) $$(NVIDSTRING_BUILD_TYPE_STRING) (`$$(WHOAMI)`@$$(HOSTNAME)) `$$(DATE)`\";" > $$@ ++ $(at_if_quiet)$$(ECHO) "const char $(1)[] = \"nvidia id: NVIDIA $$(strip $(2)) for $$(TARGET_ARCH) $$(NVIDIA_VERSION) $$(NVIDSTRING_BUILD_TYPE_STRING) `$$(DATE)`\";" > $$@ + $(at_if_quiet)$$(ECHO) "const char *const p$$(strip $(1)) = $(1) + 11;" >> $$@; + endef + diff --git a/anda/system/nvidia/kmod-nvidia/kmod-nvidia.spec b/anda/system/nvidia/kmod-nvidia/kmod-nvidia.spec new file mode 100644 index 0000000000..f6815a441f --- /dev/null +++ b/anda/system/nvidia/kmod-nvidia/kmod-nvidia.spec @@ -0,0 +1,98 @@ +%global kmod_name nvidia + +%global debug_package %{nil} + +# Generate kernel symbols requirements: +%global _use_internal_dependency_generator 0 + +%{!?kversion: %global kversion %(uname -r)} + +Name: kmod-%{kmod_name} +Version: 575.51.02 +Release: 1%{?dist} +Summary: NVIDIA display driver kernel module +Epoch: 3 +License: NVIDIA License +URL: http://www.nvidia.com/ +ExclusiveArch: x86_64 aarch64 + +Source0: https://github.com/NVIDIA/open-gpu-kernel-modules/archive/refs/tags/%{version}.tar.gz +# Kbuild: Convert EXTRA_CFLAGS to ccflags-y (6.15+) + std=gnu17 +Patch0: nvidia-kernel-ccflags-y.patch +# https://git.almalinux.org/ngompa/nvidia-kmod-el-rpm/ +Patch1: %{name}-ldflags.patch +Patch2: %{name}-no-hostname-whoami.patch + +BuildRequires: elfutils-libelf-devel +BuildRequires: gcc +BuildRequires: gcc-c++ +BuildRequires: kernel-abi-stablelists +BuildRequires: kernel-devel +BuildRequires: kernel-rpm-macros +BuildRequires: kmod +BuildRequires: redhat-rpm-config + +Provides: kabi-modules = %{kversion} +Provides: %{kmod_name}-kmod = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: module-init-tools + +%description +This package provides the proprietary NVIDIA kernel modules. It is built to +depend upon the specific ABI provided by a range of releases of the same variant +of the Linux kernel and not on any one specific build. + +%prep +%autosetup -p1 -n open-gpu-kernel-modules-%{version} + +echo "override %{kmod_name} * weak-updates/%{kmod_name}" > kmod-%{kmod_name}.conf + +%build +export SYSSRC=%{_usrsrc}/kernels/%{kversion} +export IGNORE_XEN_PRESENCE=1 +export IGNORE_PREEMPT_RT_PRESENCE=1 +export IGNORE_CC_MISMATCH=1 + +%make_build modules + +%install +export INSTALL_MOD_PATH=%{buildroot}%{_prefix} +export INSTALL_MOD_DIR=extra/%{kmod_name} + +make -C %{_usrsrc}/kernels/%{kversion} -j$(nproc) modules_install M=$PWD/kernel-open + +install -d %{buildroot}%{_sysconfdir}/depmod.d/ +install kmod-%{kmod_name}.conf %{buildroot}%{_sysconfdir}/depmod.d/ +# Remove the unrequired files. +rm -f %{buildroot}%{_prefix}/lib/modules/%{kversion}/modules.* + +find %{buildroot} -type f -name '*.ko' | xargs %{__strip} --strip-debug +find %{buildroot} -type f -name '*.ko' | xargs xz + +%post +if [ -e "/boot/System.map-%{kversion}" ]; then + %{_sbindir}/depmod -aeF "/boot/System.map-%{kversion}" "%{kversion}" > /dev/null || : +fi +modules=( $(find %{_prefix}/lib/modules/%{kversion}/extra/%{kmod_name} | grep '\.ko.xz$') ) +if [ -x "%{_sbindir}/weak-modules" ]; then + printf '%s\n' "${modules[@]}" | %{_sbindir}/weak-modules --add-modules +fi + +%preun +rpm -ql kmod-%{kmod_name}-%{version}-%{release}.%{_target_cpu} | grep '\.ko.xz$' > %{_var}/run/rpm-kmod-%{kmod_name}-modules + +%postun +if [ -e "/boot/System.map-%{kversion}" ]; then + %{_sbindir}/depmod -aeF "/boot/System.map-%{kversion}" "%{kversion}" > /dev/null || : +fi +modules=( $(cat /var/run/rpm-kmod-%{kmod_name}-modules) ) +rm %{_var}/run/rpm-kmod-%{kmod_name}-modules +if [ -x "%{_sbindir}/weak-modules" ]; then + printf '%s\n' "${modules[@]}" | %{_sbindir}/weak-modules --remove-modules +fi + +%files +%{_prefix}/lib/modules/%{kversion}/extra/* +%config %{_sysconfdir}/depmod.d/kmod-%{kmod_name}.conf + +%changelog +%autochangelog diff --git a/anda/system/nvidia/kmod-nvidia/nvidia-kernel-ccflags-y.patch b/anda/system/nvidia/kmod-nvidia/nvidia-kernel-ccflags-y.patch new file mode 100644 index 0000000000..4f724a820a --- /dev/null +++ b/anda/system/nvidia/kmod-nvidia/nvidia-kernel-ccflags-y.patch @@ -0,0 +1,117 @@ +diff -Naur open-gpu-kernel-modules-575.51.02.old/kernel-open/Kbuild open-gpu-kernel-modules-575.51.02/kernel-open/Kbuild +--- open-gpu-kernel-modules-575.51.02.old/kernel-open/Kbuild 2025-04-22 19:14:10.712973734 +0200 ++++ open-gpu-kernel-modules-575.51.02/kernel-open/Kbuild 2025-04-22 19:16:40.057981220 +0200 +@@ -75,21 +75,15 @@ + $(eval include $(src)/$(_module)/$(_module).Kbuild)) + + +-# +-# Define CFLAGS that apply to all the NVIDIA kernel modules. EXTRA_CFLAGS +-# is deprecated since 2.6.24 in favor of ccflags-y, but we need to support +-# older kernels which do not have ccflags-y. Newer kernels append +-# $(EXTRA_CFLAGS) to ccflags-y for compatibility. +-# +- +-EXTRA_CFLAGS += -I$(src)/common/inc +-EXTRA_CFLAGS += -I$(src) +-EXTRA_CFLAGS += -Wall $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-format-extra-args +-EXTRA_CFLAGS += -D__KERNEL__ -DMODULE -DNVRM +-EXTRA_CFLAGS += -DNV_VERSION_STRING=\"575.51.02\" ++ccflags-y += -std=gnu17 ++ccflags-y += -I$(src)/common/inc ++ccflags-y += -I$(src) ++ccflags-y += -Wall $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-format-extra-args ++ccflags-y += -D__KERNEL__ -DMODULE -DNVRM ++ccflags-y += -DNV_VERSION_STRING=\"575.51.02\" + + ifneq ($(SYSSRCHOST1X),) +- EXTRA_CFLAGS += -I$(SYSSRCHOST1X) ++ ccflags-y += -I$(SYSSRCHOST1X) + endif + + # Some Android kernels prohibit driver use of filesystem functions like +@@ -99,57 +93,57 @@ + PLATFORM_IS_ANDROID ?= 0 + + ifeq ($(PLATFORM_IS_ANDROID),1) +- EXTRA_CFLAGS += -DNV_FILESYSTEM_ACCESS_AVAILABLE=0 ++ ccflags-y += -DNV_FILESYSTEM_ACCESS_AVAILABLE=0 + else +- EXTRA_CFLAGS += -DNV_FILESYSTEM_ACCESS_AVAILABLE=1 ++ ccflags-y += -DNV_FILESYSTEM_ACCESS_AVAILABLE=1 + endif + +-EXTRA_CFLAGS += -Wno-unused-function ++ccflags-y += -Wno-unused-function + + ifneq ($(NV_BUILD_TYPE),debug) +- EXTRA_CFLAGS += -Wuninitialized ++ ccflags-y += -Wuninitialized + endif + +-EXTRA_CFLAGS += -fno-strict-aliasing ++ccflags-y += -fno-strict-aliasing + + ifeq ($(ARCH),arm64) +- EXTRA_CFLAGS += -mstrict-align ++ ccflags-y += -mstrict-align + endif + + ifeq ($(NV_BUILD_TYPE),debug) +- EXTRA_CFLAGS += -g ++ ccflags-y += -g + endif + +-EXTRA_CFLAGS += -ffreestanding ++ccflags-y += -ffreestanding + + ifeq ($(ARCH),arm64) +- EXTRA_CFLAGS += -mgeneral-regs-only -march=armv8-a +- EXTRA_CFLAGS += $(call cc-option,-mno-outline-atomics,) ++ ccflags-y += -mgeneral-regs-only -march=armv8-a ++ ccflags-y += $(call cc-option,-mno-outline-atomics,) + endif + + ifeq ($(ARCH),x86_64) +- EXTRA_CFLAGS += -mno-red-zone -mcmodel=kernel ++ ccflags-y += -mno-red-zone -mcmodel=kernel + endif + + ifeq ($(ARCH),powerpc) +- EXTRA_CFLAGS += -mlittle-endian -mno-strict-align ++ ccflags-y += -mlittle-endian -mno-strict-align + endif + +-EXTRA_CFLAGS += -DNV_UVM_ENABLE +-EXTRA_CFLAGS += $(call cc-option,-Werror=undef,) +-EXTRA_CFLAGS += -DNV_SPECTRE_V2=$(NV_SPECTRE_V2) +-EXTRA_CFLAGS += -DNV_KERNEL_INTERFACE_LAYER ++ccflags-y += -DNV_UVM_ENABLE ++ccflags-y += $(call cc-option,-Werror=undef,) ++ccflags-y += -DNV_SPECTRE_V2=$(NV_SPECTRE_V2) ++ccflags-y += -DNV_KERNEL_INTERFACE_LAYER + + # + # Detect SGI UV systems and apply system-specific optimizations. + # + + ifneq ($(wildcard /proc/sgi_uv),) +- EXTRA_CFLAGS += -DNV_CONFIG_X86_UV ++ ccflags-y += -DNV_CONFIG_X86_UV + endif + + ifdef VGX_FORCE_VFIO_PCI_CORE +- EXTRA_CFLAGS += -DNV_VGPU_FORCE_VFIO_PCI_CORE ++ ccflags-y += -DNV_VGPU_FORCE_VFIO_PCI_CORE + endif + + WARNINGS_AS_ERRORS ?= +@@ -183,7 +177,7 @@ + + NV_CFLAGS_FROM_CONFTEST := $(shell $(NV_CONFTEST_CMD) build_cflags) + +-NV_CONFTEST_CFLAGS = $(NV_CFLAGS_FROM_CONFTEST) $(EXTRA_CFLAGS) -fno-pie ++NV_CONFTEST_CFLAGS = $(NV_CFLAGS_FROM_CONFTEST) $(ccflags-y) -fno-pie + NV_CONFTEST_CFLAGS += $(call cc-disable-warning,pointer-sign) + NV_CONFTEST_CFLAGS += $(call cc-option,-fshort-wchar,) + NV_CONFTEST_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types,) diff --git a/anda/system/nvidia/kmod-nvidia/update.rhai b/anda/system/nvidia/kmod-nvidia/update.rhai new file mode 100644 index 0000000000..f25d05da71 --- /dev/null +++ b/anda/system/nvidia/kmod-nvidia/update.rhai @@ -0,0 +1 @@ +rpm.version(gh("NVIDIA/open-gpu-kernel-modules")); diff --git a/anda/system/nvidia/nvidia-driver/nvidia-driver.spec b/anda/system/nvidia/nvidia-driver/nvidia-driver.spec index ccae6e4e9b..a837013229 100644 --- a/anda/system/nvidia/nvidia-driver/nvidia-driver.spec +++ b/anda/system/nvidia/nvidia-driver/nvidia-driver.spec @@ -1,5 +1,5 @@ %global debug_package %{nil} -%global __strip /bin/true +%global __strip %{nil} %global __brp_ldconfig %{nil} %define _build_id_links none @@ -10,7 +10,7 @@ Name: nvidia-driver Version: 575.51.02 -Release: 1%?dist +Release: 2%?dist Summary: NVIDIA's proprietary display driver for NVIDIA graphic cards Epoch: 3 License: NVIDIA License @@ -75,7 +75,7 @@ Requires: libnvidia-ml%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release} Requires: vulkan-loader # dlopened Requires: libnvidia-gpucomp%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release} -Requires: libnvidia-ml = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: libnvidia-ml%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release} Conflicts: nvidia-x11-drv-libs Conflicts: nvidia-x11-drv-470xx-libs @@ -180,6 +180,11 @@ The NVIDIA X.org X11 driver and associated components. %prep source %{SOURCE99} export VERSION=%{version} +%ifarch %ix86 +export ARCH=x86_64 +%else +export ARCH=%{_arch} +%endif unpack() { set_vars @@ -189,23 +194,8 @@ unpack() { create_tarball } -%ifarch %{ix86} -export ARCH=x86_64 unpack -%setup -D -T -n %{name}-%{version}-i386 -%endif - -%ifarch x86_64 -export ARCH=x86_64 -unpack -%setup -D -T -n %{name}-%{version}-x86_64 -%endif - -%ifarch aarch64 -export ARCH=aarch64 -unpack -%setup -D -T -n %{name}-%{version}-aarch64 -%endif +%setup -D -T -n %{name}-%{version}-%{_arch} %ifarch x86_64 %if 0%{?rhel} == 8 @@ -309,19 +299,6 @@ install -p -m 0755 systemd/nvidia-sleep.sh %{buildroot}%{_bindir}/ install -p -m 0755 -D systemd/system-sleep/nvidia %{buildroot}%{_systemd_util_dir}/system-sleep/nvidia install -p -m 0644 -D nvidia-dbus.conf %{buildroot}%{_datadir}/dbus-1/system.d/nvidia-dbus.conf -%if 0%{?fedora} >= 41 -mkdir -p %{buildroot}%{_unitdir}/systemd-suspend.service.d/ -cat > %{buildroot}%{_unitdir}/systemd-suspend.service.d/10-nvidia.conf << EOF -[Service] -Environment="SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=false" -EOF -mkdir -p %{buildroot}%{_unitdir}/systemd-homed.service.d/ -cat > %{buildroot}%{_unitdir}/systemd-homed.service.d/10-nvidia.conf << EOF -[Service] -Environment="SYSTEMD_HOME_LOCK_FREEZE_SESSION=false" -EOF -%endif - # Ignore powerd binary exiting if hardware is not present # We should check for information in the DMI table sed -i -e 's/ExecStart=/ExecStart=-/g' %{buildroot}%{_unitdir}/nvidia-powerd.service @@ -335,6 +312,17 @@ install -p -m 0644 -D %{SOURCE40} %{buildroot}%{_metainfodir}/com.nvidia.driver. mkdir -p %{buildroot}%{_datadir}/pixmaps/ cp %{SOURCE42} %{buildroot}%{_datadir}/pixmaps/ +# nvsandboxutils configuration +install -p -m 0644 -D sandboxutils-filelist.json %{buildroot}%{_datadir}/nvidia/files.d/sandboxutils-filelist.json + +# dnf needs-restarting plugin +# dnf4 only for the moment: https://github.com/rpm-software-management/dnf5/issues/1815 +%if 0%{?fedora} < 42 || 0%{?rhel} +mkdir -p %{buildroot}%{_sysconfdir}/dnf/plugins/needs-restarting.d +echo %{name} > %{buildroot}%{_sysconfdir}/dnf/plugins/needs-restarting.d/%{name}.conf +echo %{name}-cuda > %{buildroot}%{_sysconfdir}/dnf/plugins/needs-restarting.d/%{name}-cuda.conf +%endif + %check # Using appstreamcli: appstreamcli validate --strict # Icon type local is not supported by appstreamcli for drivers @@ -356,14 +344,14 @@ appstream-util validate --nonet %{buildroot}%{_metainfodir}/com.nvidia.driver.me %systemd_preun nvidia-powerd.service %systemd_preun nvidia-resume.service %systemd_preun nvidia-suspend.service -%systemd_post nvidia-suspend-then-hibernate.service +%systemd_preun nvidia-suspend-then-hibernate.service %postun %systemd_postun nvidia-hibernate.service %systemd_postun nvidia-powerd.service %systemd_postun nvidia-resume.service %systemd_postun nvidia-suspend.service -%systemd_post nvidia-suspend-then-hibernate.service +%systemd_postun nvidia-suspend-then-hibernate.service %endif @@ -391,9 +379,8 @@ appstream-util validate --nonet %{buildroot}%{_metainfodir}/com.nvidia.driver.me %{_unitdir}/nvidia-resume.service %{_unitdir}/nvidia-suspend.service %{_unitdir}/nvidia-suspend-then-hibernate.service -%if 0%{?fedora} >= 41 -%{_unitdir}/systemd-suspend.service.d/10-nvidia.conf -%{_unitdir}/systemd-homed.service.d/10-nvidia.conf +%if 0%{?fedora} < 42 || 0%{?rhel} +%{_sysconfdir}/dnf/plugins/needs-restarting.d/%{name}.conf %endif %if 0%{?fedora} || 0%{?rhel} < 10 @@ -413,10 +400,14 @@ appstream-util validate --nonet %{buildroot}%{_metainfodir}/com.nvidia.driver.me %{_bindir}/nvidia-cuda-mps-server %{_bindir}/nvidia-debugdump %{_bindir}/nvidia-smi +%{_datadir}/nvidia/files.d/sandboxutils-filelist.json %{_mandir}/man1/nvidia-cuda-mps-control.1.* %{_mandir}/man1/nvidia-smi.* %{_prefix}/lib/nvidia/alternate-install-present %{_systemd_util_dir}/system-preset/70-nvidia-driver-cuda.preset +%if 0%{?fedora} < 42 || 0%{?rhel} +%{_sysconfdir}/dnf/plugins/needs-restarting.d/%{name}-cuda.conf +%endif %endif @@ -462,7 +453,9 @@ appstream-util validate --nonet %{buildroot}%{_metainfodir}/com.nvidia.driver.me %{_libdir}/libnvidia-vksc-core.so.%{version} %dir %{_libdir}/nvidia %dir %{_libdir}/nvidia/wine -%{_libdir}/nvidia/wine/*.dll +%{_libdir}/nvidia/wine/_nvngx.dll +%{_libdir}/nvidia/wine/nvngx.dll +%{_libdir}/nvidia/wine/nvngx_dlssg.dll %endif %files cuda-libs @@ -496,8 +489,6 @@ appstream-util validate --nonet %{buildroot}%{_metainfodir}/com.nvidia.driver.me %else %{_libdir}/libnvidia-pkcs11-openssl3.so.%{version} %endif -%{_libdir}/libnvidia-sandboxutils.so.1 -%{_libdir}/libnvidia-sandboxutils.so.%{version} %endif %files -n libnvidia-fbc diff --git a/anda/system/nvidia/nvidia-kmod-common/99-nvidia.conf b/anda/system/nvidia/nvidia-kmod-common/99-nvidia.conf deleted file mode 100644 index 6d64aaeb34..0000000000 --- a/anda/system/nvidia/nvidia-kmod-common/99-nvidia.conf +++ /dev/null @@ -1,3 +0,0 @@ -# Omit the nvidia driver from the ramdisk, to avoid needing to regenerate -# the ramdisk on updates. -omit_drivers+=" nvidia nvidia-drm nvidia-modeset nvidia-peermem nvidia-uvm " diff --git a/anda/system/nvidia/nvidia-kmod-common/nvidia-boot-update b/anda/system/nvidia/nvidia-kmod-common/nvidia-boot-update deleted file mode 100755 index 46cad2f238..0000000000 --- a/anda/system/nvidia/nvidia-kmod-common/nvidia-boot-update +++ /dev/null @@ -1,186 +0,0 @@ -#!/bin/sh - - -# EL8 (grub2 with BootLoaderSpec patches) -# -# kernel options: grub.cfg + grubenv + /etc/kernel/cmdline -# kernel options in /boot/loader/entries/*.conf use kernelopts from /boot/grub2/grubenv -# grubby -# - updates kernelopts in /boot/grub2/grubenv -# - does not update /etc/default/grub -# - does not update kernelopts in grub.cfg -# grub.cfg: -# - UEFI: /etc/grub2-efi.cfg -> /boot/efi/EFI//grub.cfg -# - BIOS: /etc/grub2.cfg -> /boot/grub2/grub.cfg - - -# EL9 (grub2 with BootLoaderSpec patches) -# -# kernel options: grub.cfg + /etc/kernel/cmdline + /boot/loader/entries/*.conf -# manually update: /etc/default/grub + /etc/kernel/cmdline -# grub2-mkconfig does not update /boot/loader/entries/*.conf -# grub.cfg: -# - UEFI: /etc/grub2-efi.cfg -> /boot/efi/EFI//grub.cfg -# - BIOS: /etc/grub2.cfg -> /boot/grub2/grub.cfg - - -# Fedora (grub2 with BootLoaderSpec patches) -# -# kernel options: grub.cfg + /etc/kernel/cmdline + /boot/loader/entries/*.conf -# manually update: /etc/default/grub + /etc/kernel/cmdline -# grub2-mkconfig does not update /boot/loader/entries/*.conf -# grub.cfg: -# - UEFI/BIOS: /boot/grub2/grub.cfg - - -# Fedora (systemd-boot) -# -# kernel options: grub.cfg + /boot/efi/loader/entries/*.conf (UEFI only) -# grubby as an updateloaderentries alias: -# - updates all entries in /boot/efi/loader/entries/*.conf -# - does not work with multiple parameters at once -# - does not update /etc/kernel/cmdline - - -# Complete use case coverage, regardless of boot loaders: -# -# - update options in /etc/default/grub -# - regenerate grub.cfg/grubenv -# - update options in /boot/{efi/}loader/entries/*.conf entries -# - update options in /etc/kernel/cmdline -# - cover both UEFI and BIOS case - -CMDLINE_ARGS_ADD="_dracutopts_in" -CMDLINE_ARGS_REMOVE="_dracutopts_rm" - -print_usage() { -cat <> /etc/default/grub - else - for param in $CMDLINE_ARGS_ADD; do - echo ${GRUB_CMDLINE_LINUX} | grep -q $param - [ $? -eq 1 ] && GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} ${param}" - done - for param in $CMDLINE_ARGS_REMOVE; do - echo ${GRUB_CMDLINE_LINUX} | grep -q $param - [ $? -eq 0 ] && GRUB_CMDLINE_LINUX="$(echo ${GRUB_CMDLINE_LINUX} | sed -e "s/ $param//g")" - done - sed -i -e "s|^GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX=\"${GRUB_CMDLINE_LINUX}\"|g" /etc/default/grub - fi - - grub2-mkconfig -o $GRUB_CFG &>/dev/null - - fi - - if [ -v BLS_ENTRIES ]; then - - for config_file in $BLS_ENTRIES/*.conf; do - for param in $CMDLINE_ARGS_ADD; do - grep -q $param $config_file - [ $? -eq 1 ] && sed -i -e "s|^options.*|& $param|" $config_file - done - for param in $CMDLINE_ARGS_REMOVE; do - grep -q $param $config_file - [ $? -eq 0 ] && sed -i -e "s| $param||" $config_file - done - done - - fi - -} - -preun() { - - if [ -v GRUB_CFG ]; then - - for param in $CMDLINE_ARGS_ADD; do - echo ${GRUB_CMDLINE_LINUX} | grep -q $param - [ $? -eq 0 ] && GRUB_CMDLINE_LINUX="$(echo ${GRUB_CMDLINE_LINUX} | sed -e "s/ $param//g")" - done - sed -i -e "s|^GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX=\"${GRUB_CMDLINE_LINUX}\"|g" /etc/default/grub - - grub2-mkconfig -o $GRUB_CFG &>/dev/null - - fi - - if [ -v BLS_ENTRIES ]; then - - for config_file in $BLS_ENTRIES/*.conf; do - for param in $CMDLINE_ARGS_ADD; do - grep -q $param $config_file - [ $? -eq 0 ] && sed -i -e "s| $param||" $config_file - done - done - - fi - -} - -case "$1" in - post) - check - post - exit 0 - ;; - preun) - check - preun - exit 0 - ;; - *) - print_usage - exit 0 - ;; -esac diff --git a/anda/system/nvidia/nvidia-kmod-common/nvidia-kmod-common.spec b/anda/system/nvidia/nvidia-kmod-common/nvidia-kmod-common.spec index d639aff4e9..25f8925f0d 100644 --- a/anda/system/nvidia/nvidia-kmod-common/nvidia-kmod-common.spec +++ b/anda/system/nvidia/nvidia-kmod-common/nvidia-kmod-common.spec @@ -4,11 +4,11 @@ # gsp_*.bin: ELF 64-bit LSB executable, UCB RISC-V %global _binaries_in_noarch_packages_terminate_build 0 -%global __strip /bin/true +%global __brp_strip %{nil} Name: nvidia-kmod-common Version: 575.51.02 -Release: 1%?dist +Release: 2%?dist Summary: Common file for NVIDIA's proprietary driver kernel modules Epoch: 3 License: NVIDIA License @@ -17,18 +17,14 @@ URL: http://www.nvidia.com/object/unix.html BuildArch: noarch Source0: http://download.nvidia.com/XFree86/Linux-x86_64/%{version}/NVIDIA-Linux-x86_64-%{version}.run -Source17: nvidia-boot-update Source18: kernel.conf Source19: nvidia-modeset.conf Source20: nvidia.conf Source21: 60-nvidia.rules -Source24: 99-nvidia.conf # UDev rule location (_udevrulesdir) and systemd macros: BuildRequires: systemd-rpm-macros -# Owns /usr/lib/firmware: -Requires: linux-firmware Requires: nvidia-modprobe Requires: nvidia-kmod = %{?epoch:%{epoch}:}%{version} Provides: nvidia-kmod-common = %{?epoch:%{epoch}:}%{version} @@ -43,13 +39,6 @@ sh %{SOURCE0} -x --target nvidia-kmod-%{version}-x86_64 %setup -T -D -n nvidia-kmod-%{version}-x86_64 %install -# Script for post/preun tasks -install -p -m 0755 -D %{SOURCE17} %{buildroot}%{_sbindir}/nvidia-boot-update -sed -i \ - -e 's/_dracutopts_in/%{_dracutopts_in}/g' \ - -e 's/_dracutopts_rm/%{_dracutopts_rm}/g' \ - %{buildroot}%{_sbindir}/nvidia-boot-update - # Choice of kernel module type: install -p -m 0644 -D %{SOURCE18} %{buildroot}%{_sysconfdir}/nvidia/kernel.conf @@ -59,9 +48,6 @@ install -p -m 0644 -D %{SOURCE19} %{buildroot}%{_sysconfdir}/modprobe.d/nvidia-m # Load nvidia-uvm, enable complete power management: install -p -m 0644 -D %{SOURCE20} %{buildroot}%{_modprobedir}/nvidia.conf -# Avoid Nvidia modules getting in the initrd: -install -p -m 0644 -D %{SOURCE24} %{buildroot}%{_dracut_conf_d}/99-nvidia.conf - # UDev rules # https://github.com/NVIDIA/nvidia-modprobe/blob/master/modprobe-utils/nvidia-modprobe-utils.h#L33-L46 # https://github.com/negativo17/nvidia-kmod-common/issues/11 @@ -72,19 +58,19 @@ install -p -m 644 -D %{SOURCE21} %{buildroot}%{_udevrulesdir}/60-nvidia.rules mkdir -p %{buildroot}%{_prefix}/lib/firmware/nvidia/%{version}/ install -p -m 644 firmware/* %{buildroot}%{_prefix}/lib/firmware/nvidia/%{version} -%post -%{_sbindir}/nvidia-boot-update post +%pre +# Remove the kernel command line adjustments one last time when doing an upgrade +# from a version that was still setting up the command line parameters: +if [ "$1" -eq "2" ] && [ -x %{_bindir}/nvidia-boot-update ]; then + %{_bindir}/nvidia-boot-update preun -%preun -if [ "$1" -eq "0" ]; then - %{_sbindir}/nvidia-boot-update preun fi ||: %files -%{_dracut_conf_d}/99-nvidia.conf %{_modprobedir}/nvidia.conf +%dir %{_prefix}/lib/firmware +%dir %{_prefix}/lib/firmware/nvidia %{_prefix}/lib/firmware/nvidia/%{version} -%{_sbindir}/nvidia-boot-update %config(noreplace) %{_sysconfdir}/modprobe.d/nvidia-modeset.conf %config(noreplace) %{_sysconfdir}/nvidia/kernel.conf %{_udevrulesdir}/60-nvidia.rules diff --git a/anda/system/nvidia/nvidia-kmod/nvidia-kernel-ccflags-y.patch b/anda/system/nvidia/nvidia-kmod/nvidia-kernel-ccflags-y.patch new file mode 100644 index 0000000000..1792b26793 --- /dev/null +++ b/anda/system/nvidia/nvidia-kmod/nvidia-kernel-ccflags-y.patch @@ -0,0 +1,234 @@ +diff -Naur nvidia-kmod-575.51.02-x86_64.old/kernel/Kbuild nvidia-kmod-575.51.02-x86_64/kernel/Kbuild +--- nvidia-kmod-575.51.02-x86_64.old/kernel/Kbuild 2025-04-22 18:54:37.758155663 +0200 ++++ nvidia-kmod-575.51.02-x86_64/kernel/Kbuild 2025-04-22 18:54:45.069483044 +0200 +@@ -75,21 +75,15 @@ + $(eval include $(src)/$(_module)/$(_module).Kbuild)) + + +-# +-# Define CFLAGS that apply to all the NVIDIA kernel modules. EXTRA_CFLAGS +-# is deprecated since 2.6.24 in favor of ccflags-y, but we need to support +-# older kernels which do not have ccflags-y. Newer kernels append +-# $(EXTRA_CFLAGS) to ccflags-y for compatibility. +-# +- +-EXTRA_CFLAGS += -I$(src)/common/inc +-EXTRA_CFLAGS += -I$(src) +-EXTRA_CFLAGS += -Wall $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-format-extra-args +-EXTRA_CFLAGS += -D__KERNEL__ -DMODULE -DNVRM +-EXTRA_CFLAGS += -DNV_VERSION_STRING=\"575.51.02\" ++ccflags-y += -std=gnu17 ++ccflags-y += -I$(src)/common/inc ++ccflags-y += -I$(src) ++ccflags-y += -Wall $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-format-extra-args ++ccflags-y += -D__KERNEL__ -DMODULE -DNVRM ++ccflags-y += -DNV_VERSION_STRING=\"575.51.02\" + + ifneq ($(SYSSRCHOST1X),) +- EXTRA_CFLAGS += -I$(SYSSRCHOST1X) ++ ccflags-y += -I$(SYSSRCHOST1X) + endif + + # Some Android kernels prohibit driver use of filesystem functions like +@@ -99,57 +93,57 @@ + PLATFORM_IS_ANDROID ?= 0 + + ifeq ($(PLATFORM_IS_ANDROID),1) +- EXTRA_CFLAGS += -DNV_FILESYSTEM_ACCESS_AVAILABLE=0 ++ ccflags-y += -DNV_FILESYSTEM_ACCESS_AVAILABLE=0 + else +- EXTRA_CFLAGS += -DNV_FILESYSTEM_ACCESS_AVAILABLE=1 ++ ccflags-y += -DNV_FILESYSTEM_ACCESS_AVAILABLE=1 + endif + +-EXTRA_CFLAGS += -Wno-unused-function ++ccflags-y += -Wno-unused-function + + ifneq ($(NV_BUILD_TYPE),debug) +- EXTRA_CFLAGS += -Wuninitialized ++ ccflags-y += -Wuninitialized + endif + +-EXTRA_CFLAGS += -fno-strict-aliasing ++ccflags-y += -fno-strict-aliasing + + ifeq ($(ARCH),arm64) +- EXTRA_CFLAGS += -mstrict-align ++ ccflags-y += -mstrict-align + endif + + ifeq ($(NV_BUILD_TYPE),debug) +- EXTRA_CFLAGS += -g ++ ccflags-y += -g + endif + +-EXTRA_CFLAGS += -ffreestanding ++ccflags-y += -ffreestanding + + ifeq ($(ARCH),arm64) +- EXTRA_CFLAGS += -mgeneral-regs-only -march=armv8-a +- EXTRA_CFLAGS += $(call cc-option,-mno-outline-atomics,) ++ ccflags-y += -mgeneral-regs-only -march=armv8-a ++ ccflags-y += $(call cc-option,-mno-outline-atomics,) + endif + + ifeq ($(ARCH),x86_64) +- EXTRA_CFLAGS += -mno-red-zone -mcmodel=kernel ++ ccflags-y += -mno-red-zone -mcmodel=kernel + endif + + ifeq ($(ARCH),powerpc) +- EXTRA_CFLAGS += -mlittle-endian -mno-strict-align ++ ccflags-y += -mlittle-endian -mno-strict-align + endif + +-EXTRA_CFLAGS += -DNV_UVM_ENABLE +-EXTRA_CFLAGS += $(call cc-option,-Werror=undef,) +-EXTRA_CFLAGS += -DNV_SPECTRE_V2=$(NV_SPECTRE_V2) +-EXTRA_CFLAGS += -DNV_KERNEL_INTERFACE_LAYER ++ccflags-y += -DNV_UVM_ENABLE ++ccflags-y += $(call cc-option,-Werror=undef,) ++ccflags-y += -DNV_SPECTRE_V2=$(NV_SPECTRE_V2) ++ccflags-y += -DNV_KERNEL_INTERFACE_LAYER + + # + # Detect SGI UV systems and apply system-specific optimizations. + # + + ifneq ($(wildcard /proc/sgi_uv),) +- EXTRA_CFLAGS += -DNV_CONFIG_X86_UV ++ ccflags-y += -DNV_CONFIG_X86_UV + endif + + ifdef VGX_FORCE_VFIO_PCI_CORE +- EXTRA_CFLAGS += -DNV_VGPU_FORCE_VFIO_PCI_CORE ++ ccflags-y += -DNV_VGPU_FORCE_VFIO_PCI_CORE + endif + + WARNINGS_AS_ERRORS ?= +@@ -183,7 +177,7 @@ + + NV_CFLAGS_FROM_CONFTEST := $(shell $(NV_CONFTEST_CMD) build_cflags) + +-NV_CONFTEST_CFLAGS = $(NV_CFLAGS_FROM_CONFTEST) $(EXTRA_CFLAGS) -fno-pie ++NV_CONFTEST_CFLAGS = $(NV_CFLAGS_FROM_CONFTEST) $(ccflags-y) -fno-pie + NV_CONFTEST_CFLAGS += $(call cc-disable-warning,pointer-sign) + NV_CONFTEST_CFLAGS += $(call cc-option,-fshort-wchar,) + NV_CONFTEST_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types,) +diff -Naur nvidia-kmod-575.51.02-x86_64.old/kernel-open/Kbuild nvidia-kmod-575.51.02-x86_64/kernel-open/Kbuild +--- nvidia-kmod-575.51.02-x86_64.old/kernel-open/Kbuild 2025-04-22 18:54:37.828156191 +0200 ++++ nvidia-kmod-575.51.02-x86_64/kernel-open/Kbuild 2025-04-22 18:54:45.069786396 +0200 +@@ -75,21 +75,15 @@ + $(eval include $(src)/$(_module)/$(_module).Kbuild)) + + +-# +-# Define CFLAGS that apply to all the NVIDIA kernel modules. EXTRA_CFLAGS +-# is deprecated since 2.6.24 in favor of ccflags-y, but we need to support +-# older kernels which do not have ccflags-y. Newer kernels append +-# $(EXTRA_CFLAGS) to ccflags-y for compatibility. +-# +- +-EXTRA_CFLAGS += -I$(src)/common/inc +-EXTRA_CFLAGS += -I$(src) +-EXTRA_CFLAGS += -Wall $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-format-extra-args +-EXTRA_CFLAGS += -D__KERNEL__ -DMODULE -DNVRM +-EXTRA_CFLAGS += -DNV_VERSION_STRING=\"575.51.02\" ++ccflags-y += -std=gnu17 ++ccflags-y += -I$(src)/common/inc ++ccflags-y += -I$(src) ++ccflags-y += -Wall $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-format-extra-args ++ccflags-y += -D__KERNEL__ -DMODULE -DNVRM ++ccflags-y += -DNV_VERSION_STRING=\"575.51.02\" + + ifneq ($(SYSSRCHOST1X),) +- EXTRA_CFLAGS += -I$(SYSSRCHOST1X) ++ ccflags-y += -I$(SYSSRCHOST1X) + endif + + # Some Android kernels prohibit driver use of filesystem functions like +@@ -99,57 +93,57 @@ + PLATFORM_IS_ANDROID ?= 0 + + ifeq ($(PLATFORM_IS_ANDROID),1) +- EXTRA_CFLAGS += -DNV_FILESYSTEM_ACCESS_AVAILABLE=0 ++ ccflags-y += -DNV_FILESYSTEM_ACCESS_AVAILABLE=0 + else +- EXTRA_CFLAGS += -DNV_FILESYSTEM_ACCESS_AVAILABLE=1 ++ ccflags-y += -DNV_FILESYSTEM_ACCESS_AVAILABLE=1 + endif + +-EXTRA_CFLAGS += -Wno-unused-function ++ccflags-y += -Wno-unused-function + + ifneq ($(NV_BUILD_TYPE),debug) +- EXTRA_CFLAGS += -Wuninitialized ++ ccflags-y += -Wuninitialized + endif + +-EXTRA_CFLAGS += -fno-strict-aliasing ++ccflags-y += -fno-strict-aliasing + + ifeq ($(ARCH),arm64) +- EXTRA_CFLAGS += -mstrict-align ++ ccflags-y += -mstrict-align + endif + + ifeq ($(NV_BUILD_TYPE),debug) +- EXTRA_CFLAGS += -g ++ ccflags-y += -g + endif + +-EXTRA_CFLAGS += -ffreestanding ++ccflags-y += -ffreestanding + + ifeq ($(ARCH),arm64) +- EXTRA_CFLAGS += -mgeneral-regs-only -march=armv8-a +- EXTRA_CFLAGS += $(call cc-option,-mno-outline-atomics,) ++ ccflags-y += -mgeneral-regs-only -march=armv8-a ++ ccflags-y += $(call cc-option,-mno-outline-atomics,) + endif + + ifeq ($(ARCH),x86_64) +- EXTRA_CFLAGS += -mno-red-zone -mcmodel=kernel ++ ccflags-y += -mno-red-zone -mcmodel=kernel + endif + + ifeq ($(ARCH),powerpc) +- EXTRA_CFLAGS += -mlittle-endian -mno-strict-align ++ ccflags-y += -mlittle-endian -mno-strict-align + endif + +-EXTRA_CFLAGS += -DNV_UVM_ENABLE +-EXTRA_CFLAGS += $(call cc-option,-Werror=undef,) +-EXTRA_CFLAGS += -DNV_SPECTRE_V2=$(NV_SPECTRE_V2) +-EXTRA_CFLAGS += -DNV_KERNEL_INTERFACE_LAYER ++ccflags-y += -DNV_UVM_ENABLE ++ccflags-y += $(call cc-option,-Werror=undef,) ++ccflags-y += -DNV_SPECTRE_V2=$(NV_SPECTRE_V2) ++ccflags-y += -DNV_KERNEL_INTERFACE_LAYER + + # + # Detect SGI UV systems and apply system-specific optimizations. + # + + ifneq ($(wildcard /proc/sgi_uv),) +- EXTRA_CFLAGS += -DNV_CONFIG_X86_UV ++ ccflags-y += -DNV_CONFIG_X86_UV + endif + + ifdef VGX_FORCE_VFIO_PCI_CORE +- EXTRA_CFLAGS += -DNV_VGPU_FORCE_VFIO_PCI_CORE ++ ccflags-y += -DNV_VGPU_FORCE_VFIO_PCI_CORE + endif + + WARNINGS_AS_ERRORS ?= +@@ -183,7 +177,7 @@ + + NV_CFLAGS_FROM_CONFTEST := $(shell $(NV_CONFTEST_CMD) build_cflags) + +-NV_CONFTEST_CFLAGS = $(NV_CFLAGS_FROM_CONFTEST) $(EXTRA_CFLAGS) -fno-pie ++NV_CONFTEST_CFLAGS = $(NV_CFLAGS_FROM_CONFTEST) $(ccflags-y) -fno-pie + NV_CONFTEST_CFLAGS += $(call cc-disable-warning,pointer-sign) + NV_CONFTEST_CFLAGS += $(call cc-option,-fshort-wchar,) + NV_CONFTEST_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types,) diff --git a/anda/system/nvidia/nvidia-kmod/nvidia-kmod.spec b/anda/system/nvidia/nvidia-kmod/nvidia-kmod.spec index 34345a3d90..dc15ee353e 100644 --- a/anda/system/nvidia/nvidia-kmod/nvidia-kmod.spec +++ b/anda/system/nvidia/nvidia-kmod/nvidia-kmod.spec @@ -5,7 +5,7 @@ Name: nvidia-kmod Version: 575.51.02 -Release: 1%?dist +Release: 2%?dist Summary: NVIDIA display driver kernel module Epoch: 3 License: NVIDIA License @@ -13,6 +13,9 @@ URL: http://www.nvidia.com/object/unix.html ExclusiveArch: x86_64 aarch64 Source0: http://download.nvidia.com/XFree86/Linux-%{_arch}/%{version}/NVIDIA-Linux-%{_arch}-%{version}.run +Patch0: nvidia-kernel-ccflags-y.patch +Requires: nvidia-kmod-common = %{?epoch:%{epoch}:}%{version} +Requires: akmods # Get the needed BuildRequires (in parts depending on what we build for): @@ -32,6 +35,7 @@ kmodtool --target %{_target_cpu} --repo terra.fyralabs.com --kmodname %{name} sh %{SOURCE0} -x --target nvidia-kmod-%{version}-%{_arch} %setup -T -D -n nvidia-kmod-%{version}-%{_arch} +%autopatch -p1 rm -f */dkms.conf @@ -199,4 +203,4 @@ done - Update to 510.54. * Wed Feb 02 2022 Simone Caronni - 3:510.47.03-1 -- Update to 510.47.03. \ No newline at end of file +- Update to 510.47.03.