From b773f7844d03a07256f499fa190bf3ac939fd2a6 Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Sun, 3 Aug 2025 20:06:57 +0300 Subject: [PATCH] xfree86: loader: Make the X server work with both old and new versions of the proprietary nvidia DDX driver The 470 driver expects older abi, while the 570 driver uses different code at runtime depending of the abi version. This commit tells the new nvdia driver to use the older abi that the 470 driver expects. Signed-off-by: stefan11111 --- hw/xfree86/common/xf86Module.h | 3 +++ hw/xfree86/loader/loader.c | 37 +++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h index b790c31b9..2f314db6d 100644 --- a/hw/xfree86/common/xf86Module.h +++ b/hw/xfree86/common/xf86Module.h @@ -85,6 +85,9 @@ #define ABI_XINPUT_VERSION SET_ABI_VERSION(26, 0) #define ABI_EXTENSION_VERSION SET_ABI_VERSION(11, 0) +/* hack to get both modern and ancient nvidia DDX drivers to work at the same time */ +#define ABI_NVIDIA_VERSION SET_ABI_VERSION(25, 2) + #define MODINFOSTRING1 0xef23fdc5 #define MODINFOSTRING2 0x10dc023a diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c index c866b18dd..f2e173c79 100644 --- a/hw/xfree86/loader/loader.c +++ b/hw/xfree86/loader/loader.c @@ -172,7 +172,42 @@ LoaderGetABIVersion(const char *abiclass) int version; } classes[] = { {ABI_CLASS_ANSIC, LoaderVersionInfo.ansicVersion}, - {ABI_CLASS_VIDEODRV, LoaderVersionInfo.videodrvVersion}, + /* + * XXX This is a hack. XXX + * + * The 470 nvidia driver only knows about an older abi + * where struct _Screen has an extra field. + * + * The modern nvidia drivers (e.g. 570) know about both + * abi's, and have different code paths for supporting + * both abi's. + * + * The modern nvidia drivers use this function to determine + * what video abi the X server uses, so it knows whether or + * not to use the newer abi, or the older abi, where + * struct _Screen has an extra field. + * + * The X server implements the older abi for struct _Screen, + * that the 470 driver knows, and we lie to the nvidia drivers + * that we use that older abi for the entire X server, so that + * modern nvidia drivers know to use the code path for supporting + * this older abi. + * + * We lie to the nvidia driver and claim to have an older abi + * so that both modern and old nvidia drivers work. + * + * In the future, nvidia might remove the code path for supporting + * the old abi from it's DDX driver. + * + * When that happens, unless we want to add major hacks and + * complexity to the codebase, we will no longer be able to + * support both abi's at once. + * + * We will probably have to add a compile-time flag that switches + * between abi's. + */ + {ABI_CLASS_VIDEODRV, is_nvidia_proprietary ? ABI_NVIDIA_VERSION : + LoaderVersionInfo.videodrvVersion}, {ABI_CLASS_XINPUT, LoaderVersionInfo.xinputVersion}, {ABI_CLASS_EXTENSION, LoaderVersionInfo.extensionVersion}, {NULL, 0}