linuxPackages.nvidiaPackages.latest: 565.77 -> 575.57.08 (#412157)
This commit is contained in:
@@ -1,156 +0,0 @@
|
||||
From 88b8ae7642ef21e685d51148e8f57c3dfa1323ac Mon Sep 17 00:00:00 2001
|
||||
From: Bingwu Zhang <xtex@aosc.io>
|
||||
Date: Sat, 7 Dec 2024 23:56:43 +0800
|
||||
Subject: [PATCH 10/10] FROM AOSC: TTM fbdev emulation for Linux 6.13+
|
||||
|
||||
Link: https://github.com/torvalds/linux/commit/1000634477d8d178179b1ad45d92e925fabe3deb
|
||||
Link: https://github.com/NVIDIA/open-gpu-kernel-modules/issues/749
|
||||
Signed-off-by: xtex <xtexchooser@duck.com>
|
||||
Signed-off-by: Eric Naim <dnaim@cachyos.org>
|
||||
---
|
||||
kernel-open/nvidia-drm/nvidia-drm-drv.c | 72 +++++++++++++++++++
|
||||
kernel-open/nvidia-drm/nvidia-drm-linux.c | 4 ++
|
||||
.../nvidia-drm/nvidia-drm-os-interface.h | 5 ++
|
||||
3 files changed, 81 insertions(+)
|
||||
|
||||
diff --git a/kernel-open/nvidia-drm/nvidia-drm-drv.c b/kernel-open/nvidia-drm/nvidia-drm-drv.c
|
||||
index 2e4f6404..ab85152f 100644
|
||||
--- a/kernel-open/nvidia-drm/nvidia-drm-drv.c
|
||||
+++ b/kernel-open/nvidia-drm/nvidia-drm-drv.c
|
||||
@@ -1951,7 +1951,60 @@ void nv_drm_update_drm_driver_features(void)
|
||||
#endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
|
||||
}
|
||||
|
||||
+#if !defined(NV_DRM_FBDEV_TTM_AVAILABLE) && \
|
||||
+ !defined(NV_DRM_FBDEV_GENERIC_AVAILABLE)
|
||||
+// AOSC OS: Workaround for Linux 6.13+
|
||||
|
||||
+static const struct drm_fb_helper_funcs nv_drm_fbdev_helper_funcs = {
|
||||
+ .fb_probe = drm_fbdev_ttm_driver_fbdev_probe,
|
||||
+};
|
||||
+
|
||||
+static void nv_drm_fbdev_client_unregister(struct drm_client_dev *client)
|
||||
+{
|
||||
+ struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
|
||||
+ if (fb_helper->info) {
|
||||
+ drm_fb_helper_unregister_info(fb_helper);
|
||||
+ } else {
|
||||
+ drm_client_release(&fb_helper->client);
|
||||
+ drm_fb_helper_unprepare(fb_helper);
|
||||
+ kfree(fb_helper);
|
||||
+ }
|
||||
+}
|
||||
+static int nv_drm_fbdev_client_restore(struct drm_client_dev *client)
|
||||
+{
|
||||
+ drm_fb_helper_lastclose(client->dev);
|
||||
+ return 0;
|
||||
+}
|
||||
+static int nv_drm_fbdev_client_hotplug(struct drm_client_dev *client)
|
||||
+{
|
||||
+ struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
|
||||
+ struct drm_device *dev = client->dev;
|
||||
+ int ret;
|
||||
+ if (dev->fb_helper)
|
||||
+ return drm_fb_helper_hotplug_event(dev->fb_helper);
|
||||
+ ret = drm_fb_helper_init(dev, fb_helper);
|
||||
+ if (ret)
|
||||
+ goto err_drm_err;
|
||||
+ if (!drm_drv_uses_atomic_modeset(dev))
|
||||
+ drm_helper_disable_unused_functions(dev);
|
||||
+ ret = drm_fb_helper_initial_config(fb_helper);
|
||||
+ if (ret)
|
||||
+ goto err_drm_fb_helper_fini;
|
||||
+ return 0;
|
||||
+err_drm_fb_helper_fini:
|
||||
+ drm_fb_helper_fini(fb_helper);
|
||||
+err_drm_err:
|
||||
+ drm_err(dev, "AOSC OS: NV-DRM: fbdev: Failed to setup emulation (ret=%d)\n", ret);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static const struct drm_client_funcs nv_drm_fbdev_client_funcs = {
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .unregister = nv_drm_fbdev_client_unregister,
|
||||
+ .restore = nv_drm_fbdev_client_restore,
|
||||
+ .hotplug = nv_drm_fbdev_client_hotplug,
|
||||
+};
|
||||
+#endif
|
||||
|
||||
/*
|
||||
* Helper function for allocate/register DRM device for given NVIDIA GPU ID.
|
||||
@@ -1961,6 +2014,7 @@ void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info)
|
||||
struct nv_drm_device *nv_dev = NULL;
|
||||
struct drm_device *dev = NULL;
|
||||
struct device *device = gpu_info->os_device_ptr;
|
||||
+ struct drm_fb_helper *fb_helper = NULL;
|
||||
bool bus_is_pci;
|
||||
|
||||
DRM_DEBUG(
|
||||
@@ -2039,6 +2093,20 @@ void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info)
|
||||
drm_fbdev_ttm_setup(dev, 32);
|
||||
#elif defined(NV_DRM_FBDEV_GENERIC_AVAILABLE)
|
||||
drm_fbdev_generic_setup(dev, 32);
|
||||
+ #else
|
||||
+ // AOSC OS: Workaround for Linux 6.13+
|
||||
+ int drm_client_ret;
|
||||
+ fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL);
|
||||
+ if (!fb_helper)
|
||||
+ return;
|
||||
+ drm_fb_helper_prepare(dev, fb_helper, 32, &nv_drm_fbdev_helper_funcs);
|
||||
+ drm_client_ret = drm_client_init(dev, &fb_helper->client, "fbdev",
|
||||
+ &nv_drm_fbdev_client_funcs);
|
||||
+ if (drm_client_ret) {
|
||||
+ drm_err(dev, "AOSC OS: NV-DRM: Failed to register DRM client: %d\n", drm_client_ret);
|
||||
+ goto failed_drm_client_init;
|
||||
+ }
|
||||
+ drm_client_register(&fb_helper->client);
|
||||
#endif
|
||||
}
|
||||
#endif /* defined(NV_DRM_FBDEV_AVAILABLE) */
|
||||
@@ -2050,6 +2118,10 @@ void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info)
|
||||
|
||||
return; /* Success */
|
||||
|
||||
+failed_drm_client_init:
|
||||
+ drm_fb_helper_unprepare(fb_helper);
|
||||
+ kfree(fb_helper);
|
||||
+
|
||||
failed_drm_register:
|
||||
|
||||
nv_drm_dev_free(dev);
|
||||
diff --git a/kernel-open/nvidia-drm/nvidia-drm-linux.c b/kernel-open/nvidia-drm/nvidia-drm-linux.c
|
||||
index 83d40983..ac4fe967 100644
|
||||
--- a/kernel-open/nvidia-drm/nvidia-drm-linux.c
|
||||
+++ b/kernel-open/nvidia-drm/nvidia-drm-linux.c
|
||||
@@ -39,8 +39,12 @@ MODULE_PARM_DESC(
|
||||
fbdev,
|
||||
"Create a framebuffer device (1 = enable (default), 0 = disable) (EXPERIMENTAL)");
|
||||
module_param_named(fbdev, nv_drm_fbdev_module_param, bool, 0400);
|
||||
+#else
|
||||
+#error "nvidia-drm fbdev should always be available."
|
||||
#endif
|
||||
|
||||
+#else
|
||||
+#error "nvidia-drm is not available"
|
||||
#endif /* NV_DRM_AVAILABLE */
|
||||
|
||||
/*************************************************************************
|
||||
diff --git a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h
|
||||
index 71ca5f22..8195af32 100644
|
||||
--- a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h
|
||||
+++ b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h
|
||||
@@ -78,6 +78,11 @@ typedef struct nv_timer nv_drm_timer;
|
||||
#define NV_DRM_FBDEV_TTM_AVAILABLE
|
||||
#endif
|
||||
|
||||
+// AOSC OS: Always enable DRM fbdev
|
||||
+// FIXME: Add config test for drm helper functions.
|
||||
+// The implementation uses drm_client_register, which is added in v5.2-rc1.
|
||||
+#define NV_DRM_FBDEV_AVAILABLE
|
||||
+
|
||||
struct page;
|
||||
|
||||
/* Set to true when the atomic modeset feature is enabled. */
|
||||
--
|
||||
2.47.1
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
From 11501d99348a04c608a19330d984188f4766e603 Mon Sep 17 00:00:00 2001
|
||||
From: Bingwu Zhang <xtex@aosc.io>
|
||||
Date: Sat, 7 Dec 2024 23:01:26 +0800
|
||||
Subject: [PATCH 09/10] FROM AOSC: Use linux/aperture.c for removing
|
||||
conflicting PCI devices on Linux 6.13.0-rc1+
|
||||
|
||||
Link: https://github.com/torvalds/linux/commit/689274a56c0c088796d359f6c6267323931a2429
|
||||
Link: https://github.com/torvalds/linux/commit/7283f862bd991c8657e9bf1c02db772fcf018f13
|
||||
Link: https://github.com/NVIDIA/open-gpu-kernel-modules/issues/749
|
||||
Signed-off-by: Eric Naim <dnaim@cachyos.org>
|
||||
---
|
||||
kernel-open/conftest.sh | 19 +++++++++++++++++++
|
||||
kernel-open/header-presence-tests.mk | 1 +
|
||||
kernel-open/nvidia-drm/nvidia-drm-drv.c | 15 +++++++++++++++
|
||||
.../nvidia-drm/nvidia-drm-os-interface.h | 10 ++++++++++
|
||||
kernel-open/nvidia-drm/nvidia-drm-sources.mk | 1 +
|
||||
5 files changed, 46 insertions(+)
|
||||
|
||||
diff --git a/kernel-open/conftest.sh b/kernel-open/conftest.sh
|
||||
index fdceda72..5a0f39e0 100755
|
||||
--- a/kernel-open/conftest.sh
|
||||
+++ b/kernel-open/conftest.sh
|
||||
@@ -6615,6 +6615,8 @@ compile_test() {
|
||||
# Added by commit 2916059147ea ("drm/aperture: Add infrastructure
|
||||
# for aperture ownership") in v5.14.
|
||||
#
|
||||
+ # Removed by commit 689274a56c0c ("drm: Remove DRM aperture helpers") in v6.13.
|
||||
+ #
|
||||
CODE="
|
||||
#if defined(NV_DRM_DRM_APERTURE_H_PRESENT)
|
||||
#include <drm/drm_aperture.h>
|
||||
@@ -6626,6 +6628,23 @@ compile_test() {
|
||||
compile_check_conftest "$CODE" "NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT" "" "functions"
|
||||
;;
|
||||
|
||||
+ aperture_remove_conflicting_pci_devices)
|
||||
+ #
|
||||
+ # Determine whether aperture_remove_conflicting_pci_devices is present.
|
||||
+ #
|
||||
+ # Added by commit 7283f862bd99 ("drm: Implement DRM aperture helpers under video/") in v6.0.
|
||||
+ #
|
||||
+ CODE="
|
||||
+ #if defined(NV_LINUX_APERTURE_H_PRESENT)
|
||||
+ #include <linux/aperture.h>
|
||||
+ #endif
|
||||
+ void conftest_aperture_remove_conflicting_pci_devices(void) {
|
||||
+ aperture_remove_conflicting_pci_devices();
|
||||
+ }"
|
||||
+
|
||||
+ compile_check_conftest "$CODE" "NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT" "" "functions"
|
||||
+ ;;
|
||||
+
|
||||
drm_aperture_remove_conflicting_pci_framebuffers_has_driver_arg)
|
||||
#
|
||||
# Determine whether drm_aperture_remove_conflicting_pci_framebuffers
|
||||
diff --git a/kernel-open/header-presence-tests.mk b/kernel-open/header-presence-tests.mk
|
||||
index 9d5217a9..b0268541 100644
|
||||
--- a/kernel-open/header-presence-tests.mk
|
||||
+++ b/kernel-open/header-presence-tests.mk
|
||||
@@ -34,6 +34,7 @@ NV_HEADER_PRESENCE_TESTS = \
|
||||
generated/autoconf.h \
|
||||
generated/compile.h \
|
||||
generated/utsrelease.h \
|
||||
+ linux/aperture.h \
|
||||
linux/efi.h \
|
||||
linux/kconfig.h \
|
||||
linux/platform/tegra/mc_utils.h \
|
||||
diff --git a/kernel-open/nvidia-drm/nvidia-drm-drv.c b/kernel-open/nvidia-drm/nvidia-drm-drv.c
|
||||
index 8f905f82..2e4f6404 100644
|
||||
--- a/kernel-open/nvidia-drm/nvidia-drm-drv.c
|
||||
+++ b/kernel-open/nvidia-drm/nvidia-drm-drv.c
|
||||
@@ -65,7 +65,16 @@
|
||||
#endif
|
||||
|
||||
#if defined(NV_DRM_FBDEV_AVAILABLE)
|
||||
+// Commit 7283f862bd99 ("drm: Implement DRM aperture helpers under video/")
|
||||
+// moved implementation of drm_aperture_... to linux/aperture.c.
|
||||
+// Commit 689274a56c0c ("drm: Remove DRM aperture helpers")
|
||||
+// removed drm/drm_aperture.h.
|
||||
+#if defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT)
|
||||
#include <drm/drm_aperture.h>
|
||||
+#endif
|
||||
+#if defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT)
|
||||
+#include <linux/aperture.h>
|
||||
+#endif
|
||||
#include <drm/drm_fb_helper.h>
|
||||
#endif
|
||||
|
||||
@@ -2013,10 +2022,16 @@ void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info)
|
||||
if (bus_is_pci) {
|
||||
struct pci_dev *pdev = to_pci_dev(device);
|
||||
|
||||
+#if defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT)
|
||||
+ printk(KERN_INFO "%s: using drm_aperture for old kernels\n", nv_drm_driver.name);
|
||||
#if defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_HAS_DRIVER_ARG)
|
||||
drm_aperture_remove_conflicting_pci_framebuffers(pdev, &nv_drm_driver);
|
||||
#else
|
||||
drm_aperture_remove_conflicting_pci_framebuffers(pdev, nv_drm_driver.name);
|
||||
+#endif
|
||||
+#elif defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT)
|
||||
+ printk(KERN_INFO "%s: using linux/aperture workaround for Linux 6.13+\n", nv_drm_driver.name);
|
||||
+ aperture_remove_conflicting_pci_devices(pdev, nv_drm_driver.name);
|
||||
#endif
|
||||
nvKms->framebufferConsoleDisabled(nv_dev->pDevice);
|
||||
}
|
||||
diff --git a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h
|
||||
index a6b0f947..71ca5f22 100644
|
||||
--- a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h
|
||||
+++ b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h
|
||||
@@ -63,11 +63,21 @@ typedef struct nv_timer nv_drm_timer;
|
||||
#define NV_DRM_FBDEV_GENERIC_AVAILABLE
|
||||
#endif
|
||||
|
||||
+#if defined(NV_DRM_FBDEV_GENERIC_SETUP_PRESENT) && defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT)
|
||||
+#define NV_DRM_FBDEV_AVAILABLE
|
||||
+#define NV_DRM_FBDEV_GENERIC_AVAILABLE
|
||||
+#endif
|
||||
+
|
||||
#if defined(NV_DRM_FBDEV_TTM_SETUP_PRESENT) && defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT)
|
||||
#define NV_DRM_FBDEV_AVAILABLE
|
||||
#define NV_DRM_FBDEV_TTM_AVAILABLE
|
||||
#endif
|
||||
|
||||
+#if defined(NV_DRM_FBDEV_TTM_SETUP_PRESENT) && defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT)
|
||||
+#define NV_DRM_FBDEV_AVAILABLE
|
||||
+#define NV_DRM_FBDEV_TTM_AVAILABLE
|
||||
+#endif
|
||||
+
|
||||
struct page;
|
||||
|
||||
/* Set to true when the atomic modeset feature is enabled. */
|
||||
diff --git a/kernel-open/nvidia-drm/nvidia-drm-sources.mk b/kernel-open/nvidia-drm/nvidia-drm-sources.mk
|
||||
index 9aaebd04..a4dcad6d 100644
|
||||
--- a/kernel-open/nvidia-drm/nvidia-drm-sources.mk
|
||||
+++ b/kernel-open/nvidia-drm/nvidia-drm-sources.mk
|
||||
@@ -66,6 +66,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += dma_fence_set_error
|
||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += fence_set_error
|
||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += sync_file_get_fence
|
||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_aperture_remove_conflicting_pci_framebuffers
|
||||
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += aperture_remove_conflicting_pci_devices
|
||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fbdev_generic_setup
|
||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fbdev_ttm_setup
|
||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_connector_attach_hdr_output_metadata_property
|
||||
--
|
||||
2.47.1
|
||||
|
||||
@@ -1,251 +0,0 @@
|
||||
diff --git a/kernel-open/conftest.sh b/kernel-open/conftest.sh
|
||||
index fdceda72..3bfe39aa 100755
|
||||
--- a/kernel-open/conftest.sh
|
||||
+++ b/kernel-open/conftest.sh
|
||||
@@ -6721,6 +6721,47 @@ compile_test() {
|
||||
compile_check_conftest "$CODE" "NV_CRYPTO_PRESENT" "" "symbols"
|
||||
;;
|
||||
|
||||
+ crypto_akcipher_verify)
|
||||
+ #
|
||||
+ # Determine whether the crypto_akcipher_verify API is still present.
|
||||
+ # It was removed by commit 6b34562 ('crypto: akcipher - Drop sign/verify operations')
|
||||
+ # in v6.13-rc1 (2024-10-04).
|
||||
+ #
|
||||
+ # This test is dependent on the crypto conftest to determine whether crypto should be
|
||||
+ # enabled at all. That means that if the kernel is old enough such that crypto_akcipher_verify
|
||||
+ #
|
||||
+ # The test merely checks for the presence of the API, as it assumes that if the API
|
||||
+ # is no longer present, the new API to replace it (crypto_sig_verify) must be present.
|
||||
+ # If the kernel version is too old to have crypto_akcipher_verify, it will fail the crypto
|
||||
+ # conftest above and all crypto code will be compiled out.
|
||||
+ #
|
||||
+ CODE="
|
||||
+ #include <crypto/akcipher.h>
|
||||
+ #include <linux/crypto.h>
|
||||
+ void conftest_crypto_akcipher_verify(void) {
|
||||
+ (void)crypto_akcipher_verify;
|
||||
+ }"
|
||||
+
|
||||
+ compile_check_conftest "$CODE" "NV_CRYPTO_AKCIPHER_VERIFY_PRESENT" "" "symbols"
|
||||
+ ;;
|
||||
+
|
||||
+ ecc_digits_from_bytes)
|
||||
+ #
|
||||
+ # Determine whether ecc_digits_from_bytes is present.
|
||||
+ # It was added in commit c6ab5c915da4 ('crypto: ecc - Prevent ecc_digits_from_bytes from
|
||||
+ # reading too many bytes') in v6.10.
|
||||
+ #
|
||||
+ # This functionality is needed when crypto_akcipher_verify is not present.
|
||||
+ #
|
||||
+ CODE="
|
||||
+ #include <crypto/internal/ecc.h>
|
||||
+ void conftest_ecc_digits_from_bytes(void) {
|
||||
+ (void)ecc_digits_from_bytes;
|
||||
+ }"
|
||||
+
|
||||
+ compile_check_conftest "$CODE" "NV_ECC_DIGITS_FROM_BYTES_PRESENT" "" "symbols"
|
||||
+ ;;
|
||||
+
|
||||
mempolicy_has_unified_nodes)
|
||||
#
|
||||
# Determine if the 'mempolicy' structure has
|
||||
diff --git a/kernel-open/nvidia/internal_crypt_lib.h b/kernel-open/nvidia/internal_crypt_lib.h
|
||||
index 2eac7d5e..917acb26 100644
|
||||
--- a/kernel-open/nvidia/internal_crypt_lib.h
|
||||
+++ b/kernel-open/nvidia/internal_crypt_lib.h
|
||||
@@ -64,7 +64,9 @@
|
||||
* old or even just user disabled. If we should use LKCA, include headers, else
|
||||
* define stubs to return errors.
|
||||
*/
|
||||
-#if defined(NV_CRYPTO_PRESENT) && defined (NV_CONFIG_CRYPTO_PRESENT)
|
||||
+#if defined(NV_CRYPTO_PRESENT) && defined (NV_CONFIG_CRYPTO_PRESENT) && \
|
||||
+ (defined(NV_CRYPTO_AKCIPHER_VERIFY_PRESENT) || \
|
||||
+ (defined(NV_CRYPTO_SIG_H_PRESENT) && defined(NV_ECC_DIGITS_FROM_BYTES_PRESENT)))
|
||||
#define USE_LKCA 1
|
||||
#endif
|
||||
|
||||
diff --git a/kernel-open/nvidia/libspdm_ecc.c b/kernel-open/nvidia/libspdm_ecc.c
|
||||
index 1f8f0100..a9eb4db5 100644
|
||||
--- a/kernel-open/nvidia/libspdm_ecc.c
|
||||
+++ b/kernel-open/nvidia/libspdm_ecc.c
|
||||
@@ -30,14 +30,26 @@ MODULE_SOFTDEP("pre: ecdh_generic,ecdsa_generic");
|
||||
#include <crypto/akcipher.h>
|
||||
#include <crypto/ecdh.h>
|
||||
#include <crypto/internal/ecc.h>
|
||||
+#ifndef NV_CRYPTO_AKCIPHER_VERIFY_PRESENT
|
||||
+#include <crypto/sig.h>
|
||||
+
|
||||
+struct signature
|
||||
+{
|
||||
+ u64 r[ECC_MAX_DIGITS];
|
||||
+ u64 s[ECC_MAX_DIGITS];
|
||||
+};
|
||||
+#endif // NV_CRYPTO_AKCIPHER_VERIFY_PRESENT
|
||||
+
|
||||
+#define ECDSA_PUBKEY_HEADER_XY_PRESENT (0x4)
|
||||
|
||||
struct ecc_ctx {
|
||||
unsigned int curve_id;
|
||||
u64 priv_key[ECC_MAX_DIGITS]; // In big endian
|
||||
|
||||
struct {
|
||||
- // ecdsa wants byte preceding pub_key to be set to '4'
|
||||
- u64 pub_key_prefix;
|
||||
+ // ecdsa pubkey has header indicating length of pubkey
|
||||
+ u8 padding[7];
|
||||
+ u8 pub_key_prefix;
|
||||
u64 pub_key[2 * ECC_MAX_DIGITS];
|
||||
};
|
||||
|
||||
@@ -221,25 +233,84 @@ bool lkca_ec_compute_key(void *ec_context, const uint8_t *peer_public,
|
||||
#endif
|
||||
}
|
||||
|
||||
-bool lkca_ecdsa_verify(void *ec_context, size_t hash_nid,
|
||||
- const uint8_t *message_hash, size_t hash_size,
|
||||
- const uint8_t *signature, size_t sig_size)
|
||||
+#ifndef NV_CRYPTO_AKCIPHER_VERIFY_PRESENT
|
||||
+static bool lkca_ecdsa_verify_crypto_sig(void *ec_context, size_t hash_nid,
|
||||
+ const uint8_t *message_hash, size_t hash_size,
|
||||
+ const uint8_t *signature, size_t sig_size)
|
||||
{
|
||||
#ifndef USE_LKCA
|
||||
return false;
|
||||
#else
|
||||
struct ecc_ctx *ctx = ec_context;
|
||||
+ u8 *pub_key;
|
||||
+ int err;
|
||||
+ DECLARE_CRYPTO_WAIT(wait);
|
||||
+ struct crypto_sig * tfm = NULL;
|
||||
+ struct signature sig;
|
||||
+
|
||||
+ if (sig_size != ctx->size || !ctx->pub_key_set)
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ tfm = crypto_alloc_sig(ctx->name, CRYPTO_ALG_TYPE_SIG, 0);
|
||||
+ if (IS_ERR(tfm)) {
|
||||
+ pr_info("crypto_alloc_sig failed in lkca_ecdsa_verify\n");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // modify header of pubkey to indicate size
|
||||
+ pub_key = (u8 *) &(ctx->pub_key_prefix);
|
||||
+ *pub_key = ECDSA_PUBKEY_HEADER_XY_PRESENT;
|
||||
+ err = crypto_sig_set_pubkey(tfm, pub_key, ctx->size + 1);
|
||||
+ if (err != 0)
|
||||
+ {
|
||||
+ pr_info("crypto_sig_set_pubkey failed in lkca_ecdsa_verify: %d", -err);
|
||||
+ goto failTfm;
|
||||
+ }
|
||||
+
|
||||
+ //
|
||||
+ // Compared to the way we receive the signature, we need to:
|
||||
+ // - swap order of all digits
|
||||
+ // - swap endianness for each digit
|
||||
+ //
|
||||
+ memset(&sig, 0, sizeof(sig));
|
||||
+ ecc_digits_from_bytes(signature, ctx->size/2, sig.r, ECC_MAX_DIGITS);
|
||||
+ ecc_digits_from_bytes(signature + ctx->size/2, ctx->size/2, sig.s, ECC_MAX_DIGITS);
|
||||
+
|
||||
+ err = crypto_sig_verify(tfm, (void *)&sig, sizeof(sig), message_hash, hash_size);
|
||||
+ if (err != 0)
|
||||
+ {
|
||||
+ pr_info("crypto_sig_verify failed in lkca_ecdsa_verify %d\n", -err);
|
||||
+ }
|
||||
+
|
||||
+failTfm:
|
||||
+ crypto_free_sig(tfm);
|
||||
+
|
||||
+ return err == 0;
|
||||
+#endif // USE_LKCA
|
||||
+}
|
||||
+
|
||||
+#else // NV_CRYPTO_AKCIPHER_VERIFY_PRESENT
|
||||
+static bool lkca_ecdsa_verify_akcipher(void *ec_context, size_t hash_nid,
|
||||
+ const uint8_t *message_hash, size_t hash_size,
|
||||
+ const uint8_t *signature, size_t sig_size)
|
||||
+{
|
||||
+#ifndef USE_LKCA
|
||||
+ return false;
|
||||
+#else // USE_LKCA
|
||||
+ struct ecc_ctx *ctx = ec_context;
|
||||
+ u8 *pub_key;
|
||||
+ int err;
|
||||
+ DECLARE_CRYPTO_WAIT(wait);
|
||||
|
||||
// Roundabout way
|
||||
u64 ber_max_len = 3 + 2 * (4 + (ECC_MAX_BYTES));
|
||||
u64 ber_len = 0;
|
||||
u8 *ber = NULL;
|
||||
- u8 *pub_key;
|
||||
struct akcipher_request *req = NULL;
|
||||
struct crypto_akcipher *tfm = NULL;
|
||||
struct scatterlist sg;
|
||||
- DECLARE_CRYPTO_WAIT(wait);
|
||||
- int err;
|
||||
|
||||
if (sig_size != ctx->size) {
|
||||
return false;
|
||||
@@ -251,21 +322,21 @@ bool lkca_ecdsa_verify(void *ec_context, size_t hash_nid,
|
||||
|
||||
tfm = crypto_alloc_akcipher(ctx->name, CRYPTO_ALG_TYPE_AKCIPHER, 0);
|
||||
if (IS_ERR(tfm)) {
|
||||
- pr_info("ALLOC FAILED\n");
|
||||
+ pr_info("crypto_alloc_akcipher failed in lkca_ecdsa_verify\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
- pub_key = (u8 *) ctx->pub_key;
|
||||
- pub_key--; // Go back into byte of pub_key_prefix
|
||||
- *pub_key = 4; // And set it to 4 to placate kernel
|
||||
+ // modify header of pubkey to indicate size
|
||||
+ pub_key = (u8 *) &(ctx->pub_key_prefix);
|
||||
+ *pub_key = ECDSA_PUBKEY_HEADER_XY_PRESENT;
|
||||
if ((err = crypto_akcipher_set_pub_key(tfm, pub_key, ctx->size + 1)) != 0) {
|
||||
- pr_info("SET PUB KEY FAILED: %d\n", -err);
|
||||
+ pr_info("crypto_akcipher_set_pub_key failed in lkca_ecdsa_verify: %d\n", -err);
|
||||
goto failTfm;
|
||||
}
|
||||
|
||||
req = akcipher_request_alloc(tfm, GFP_KERNEL);
|
||||
if (IS_ERR(req)) {
|
||||
- pr_info("REQUEST ALLOC FAILED\n");
|
||||
+ pr_info("akcipher_request_alloc failed in lkca_ecdsa_verify\n");
|
||||
goto failTfm;
|
||||
}
|
||||
|
||||
@@ -310,9 +381,8 @@ bool lkca_ecdsa_verify(void *ec_context, size_t hash_nid,
|
||||
CRYPTO_TFM_REQ_MAY_SLEEP, crypto_req_done, &wait);
|
||||
akcipher_request_set_crypt(req, &sg, NULL, ber_len, hash_size);
|
||||
err = crypto_wait_req(crypto_akcipher_verify(req), &wait);
|
||||
-
|
||||
if (err != 0){
|
||||
- pr_info("Verify FAILED %d\n", -err);
|
||||
+ pr_info("crypto_akcipher_verify failed in lkca_ecdsa_verify %d\n", -err);
|
||||
}
|
||||
|
||||
kfree(ber);
|
||||
@@ -322,5 +392,19 @@ failTfm:
|
||||
crypto_free_akcipher(tfm);
|
||||
|
||||
return err == 0;
|
||||
-#endif
|
||||
+#endif // USE_LKCA
|
||||
+}
|
||||
+#endif // NV_CRYPTO_AKCIPHER_VERIFY_PRESENT
|
||||
+
|
||||
+bool lkca_ecdsa_verify(void *ec_context, size_t hash_nid,
|
||||
+ const uint8_t *message_hash, size_t hash_size,
|
||||
+ const uint8_t *signature, size_t sig_size)
|
||||
+{
|
||||
+#ifndef NV_CRYPTO_AKCIPHER_VERIFY_PRESENT
|
||||
+ return lkca_ecdsa_verify_crypto_sig(ec_context, hash_nid, message_hash, hash_size,
|
||||
+ signature, sig_size);
|
||||
+#else // NV_CRYPTO_AKCIPHER_VERIFY_PRESENT
|
||||
+ return lkca_ecdsa_verify_akcipher(ec_context, hash_nid, message_hash, hash_size,
|
||||
+ signature, sig_size);
|
||||
+#endif // NV_CRYPTO_AKCIPHER_VERIFY_PRESENT
|
||||
}
|
||||
@@ -53,6 +53,14 @@ let
|
||||
rev = "94dffc01e23a93c354a765ea7ac64484a3ef96c1";
|
||||
hash = "sha256-c94qXNZyMrSf7Dik7jvz2ECaGELqN7WEYNpnbUkzeeU=";
|
||||
};
|
||||
|
||||
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/840
|
||||
gpl_symbols_linux_615_patch = fetchpatch {
|
||||
url = "https://github.com/CachyOS/kernel-patches/raw/914aea4298e3744beddad09f3d2773d71839b182/6.15/misc/nvidia/0003-Workaround-nv_vm_flags_-calling-GPL-only-code.patch";
|
||||
hash = "sha256-YOTAvONchPPSVDP9eJ9236pAPtxYK5nAePNtm2dlvb4=";
|
||||
stripLen = 1;
|
||||
extraPrefix = "kernel/";
|
||||
};
|
||||
in
|
||||
rec {
|
||||
mkDriver = generic;
|
||||
@@ -70,24 +78,19 @@ rec {
|
||||
openSha256 = "sha256-2DpY3rgQjYFuPfTY4U/5TcrvNqsWWnsOSX0f2TfVgTs=";
|
||||
settingsSha256 = "sha256-5m6caud68Owy4WNqxlIQPXgEmbTe4kZV2vZyTWHWe+M=";
|
||||
persistencedSha256 = "sha256-OSo4Od7NmezRdGm7BLLzYseWABwNGdsomBCkOsNvOxA=";
|
||||
|
||||
patches = [ gpl_symbols_linux_615_patch ];
|
||||
};
|
||||
|
||||
latest = selectHighestVersion production (generic {
|
||||
version = "565.77";
|
||||
sha256_64bit = "sha256-CnqnQsRrzzTXZpgkAtF7PbH9s7wbiTRNcM0SPByzFHw=";
|
||||
sha256_aarch64 = "sha256-LSAYUnhfnK3rcuPe1dixOwAujSof19kNOfdRHE7bToE=";
|
||||
openSha256 = "sha256-Fxo0t61KQDs71YA8u7arY+503wkAc1foaa51vi2Pl5I=";
|
||||
settingsSha256 = "sha256-VUetj3LlOSz/LB+DDfMCN34uA4bNTTpjDrb6C6Iwukk=";
|
||||
persistencedSha256 = "sha256-wnDjC099D8d9NJSp9D0CbsL+vfHXyJFYYgU3CwcqKww=";
|
||||
patches = [
|
||||
./fix-for-linux-6.13.patch
|
||||
];
|
||||
patchesOpen = [
|
||||
./nvidia-nv-Convert-symbol-namespace-to-string-literal.patch
|
||||
./crypto-Add-fix-for-6.13-Module-compilation.patch
|
||||
./Use-linux-aperture.c-for-removing-conflict.patch
|
||||
./TTM-fbdev-emulation-for-Linux-6.13.patch
|
||||
];
|
||||
version = "575.57.08";
|
||||
sha256_64bit = "sha256-KqcB2sGAp7IKbleMzNkB3tjUTlfWBYDwj50o3R//xvI=";
|
||||
sha256_aarch64 = "sha256-VJ5z5PdAL2YnXuZltuOirl179XKWt0O4JNcT8gUgO98=";
|
||||
openSha256 = "sha256-DOJw73sjhQoy+5R0GHGnUddE6xaXb/z/Ihq3BKBf+lg=";
|
||||
settingsSha256 = "sha256-AIeeDXFEo9VEKCgXnY3QvrW5iWZeIVg4LBCeRtMs5Io=";
|
||||
persistencedSha256 = "sha256-Len7Va4HYp5r3wMpAhL4VsPu5S0JOshPFywbO7vYnGo=";
|
||||
|
||||
patches = [ gpl_symbols_linux_615_patch ];
|
||||
});
|
||||
|
||||
beta = selectHighestVersion latest (generic {
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
diff --git a/kernel/nvidia-modeset/nvidia-modeset.Kbuild b/kernel/nvidia-modeset/nvidia-modeset.Kbuild
|
||||
index a7d84e0..d417c28 100644
|
||||
--- a/kernel/nvidia-modeset/nvidia-modeset.Kbuild
|
||||
+++ b/kernel/nvidia-modeset/nvidia-modeset.Kbuild
|
||||
@@ -40,13 +40,15 @@ NV_KERNEL_MODULE_TARGETS += $(NVIDIA_MODESET_KO)
|
||||
NVIDIA_MODESET_BINARY_OBJECT := $(src)/nvidia-modeset/nv-modeset-kernel.o_binary
|
||||
NVIDIA_MODESET_BINARY_OBJECT_O := nvidia-modeset/nv-modeset-kernel.o
|
||||
|
||||
-quiet_cmd_symlink = SYMLINK $@
|
||||
-cmd_symlink = ln -sf $< $@
|
||||
+# Rel. commit 80f289101690 "kbuild: change working directory to external module directory with M=" (Masahiro Yamada, 10 Nov 2024)
|
||||
+# Ensure `$<` is absolute, since the link target is resolved relative to its path, not from where `ln` is run from.
|
||||
+quiet_cmd_symlinkabs = SYMLINK $@
|
||||
+ cmd_symlinkabs = ln -sf $(abspath $<) $@
|
||||
|
||||
targets += $(NVIDIA_MODESET_BINARY_OBJECT_O)
|
||||
|
||||
$(obj)/$(NVIDIA_MODESET_BINARY_OBJECT_O): $(NVIDIA_MODESET_BINARY_OBJECT) FORCE
|
||||
- $(call if_changed,symlink)
|
||||
+ $(call if_changed,symlinkabs)
|
||||
|
||||
nvidia-modeset-y += $(NVIDIA_MODESET_BINARY_OBJECT_O)
|
||||
|
||||
diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild
|
||||
index 31a6f92..62689f6 100644
|
||||
--- a/kernel/nvidia/nvidia.Kbuild
|
||||
+++ b/kernel/nvidia/nvidia.Kbuild
|
||||
@@ -40,13 +40,15 @@ NVIDIA_KO = nvidia/nvidia.ko
|
||||
NVIDIA_BINARY_OBJECT := $(src)/nvidia/nv-kernel.o_binary
|
||||
NVIDIA_BINARY_OBJECT_O := nvidia/nv-kernel.o
|
||||
|
||||
-quiet_cmd_symlink = SYMLINK $@
|
||||
- cmd_symlink = ln -sf $< $@
|
||||
+# Rel. commit 80f289101690 "kbuild: change working directory to external module directory with M=" (Masahiro Yamada, 10 Nov 2024)
|
||||
+# Ensure `$<` is absolute, since the link target is resolved relative to its path, not from where `ln` is run from.
|
||||
+quiet_cmd_symlinkabs = SYMLINK $@
|
||||
+ cmd_symlinkabs = ln -sf $(abspath $<) $@
|
||||
|
||||
targets += $(NVIDIA_BINARY_OBJECT_O)
|
||||
|
||||
$(obj)/$(NVIDIA_BINARY_OBJECT_O): $(NVIDIA_BINARY_OBJECT) FORCE
|
||||
- $(call if_changed,symlink)
|
||||
+ $(call if_changed,symlinkabs)
|
||||
|
||||
nvidia-y += $(NVIDIA_BINARY_OBJECT_O)
|
||||
|
||||
--
|
||||
2.47.0
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
From 35a25dda24d8f02ca89d53e5975fa7705058c39e Mon Sep 17 00:00:00 2001
|
||||
From: Eric Naim <dnaim@cachyos.org>
|
||||
Date: Mon, 9 Dec 2024 19:45:50 +0800
|
||||
Subject: [PATCH 07/10] nvidia/nv: Convert symbol namespace to string literal
|
||||
|
||||
Commit https://github.com/torvalds/linux/commit/cdd30ebb1b9f36159d66f088b61aee264e649d7a ("module: Convert symbol namespace to string literal")
|
||||
breaks importing symbol namespaces. Apply this change only for 6.13 and higher.
|
||||
|
||||
Signed-off-by: Eric Naim <dnaim@cachyos.org>
|
||||
---
|
||||
kernel-open/nvidia/nv.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/kernel-open/nvidia/nv.c b/kernel-open/nvidia/nv.c
|
||||
index 83705a05..1e7de9ea 100644
|
||||
--- a/kernel-open/nvidia/nv.c
|
||||
+++ b/kernel-open/nvidia/nv.c
|
||||
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/module.h> // for MODULE_FIRMWARE
|
||||
+#include <linux/version.h>
|
||||
|
||||
// must precede "nv.h" and "nv-firmware.h" includes
|
||||
#define NV_FIRMWARE_FOR_NAME(name) "nvidia/" NV_VERSION_STRING "/" name ".bin"
|
||||
@@ -127,7 +128,11 @@ MODULE_ALIAS_CHARDEV_MAJOR(NV_MAJOR_DEVICE_NUMBER);
|
||||
* DMA_BUF namespace is added by commit id 16b0314aa746
|
||||
* ("dma-buf: move dma-buf symbols into the DMA_BUF module namespace") in 5.16
|
||||
*/
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 13, 0)
|
||||
+MODULE_IMPORT_NS("DMA_BUF");
|
||||
+#else
|
||||
MODULE_IMPORT_NS(DMA_BUF);
|
||||
+#endif
|
||||
#endif // defined(MODULE_IMPORT_NS)
|
||||
|
||||
const NvBool nv_is_rm_firmware_supported_os = NV_TRUE;
|
||||
--
|
||||
2.47.1
|
||||
|
||||
Reference in New Issue
Block a user