Commit 8e021b85cc for qemu.org

commit 8e021b85cc06caec24a24302aa68f040a0970c12
Author: Alex Rønne Petersen <alex@alexrp.com>
Date:   Sat Sep 26 14:05:34 2026 +0200

    linux-user/mips: pick Loongson-3A4000 if a pre-r6 mips64 binary needs nan2008

    Before this patch, we'd pick MIPS64R2-generic which does not have 2008 mode, so
    the binary would just fail to run without an explicit -cpu flag. Now it'll just
    work as in the pre-r6 mips32 case.

    Signed-off-by: Alex Rønne Petersen <alex@alexrp.com>
    Signed-off-by: Helge Deller <deller@gmx.de>

diff --git a/linux-user/mips/elfload.c b/linux-user/mips/elfload.c
index 1d62ae0a4d..19850f4835 100644
--- a/linux-user/mips/elfload.c
+++ b/linux-user/mips/elfload.c
@@ -20,17 +20,19 @@ const char *get_elf_cpu_model(uint32_t eflags)
     case EF_MIPS_MACH_LS2F:
         return "Loongson-2F";
     case EF_MIPS_MACH_LS3A:
-        return "Loongson-3A1000";
+        return (eflags & EF_MIPS_NAN2008) ? "Loongson-3A4000"
+                                          : "Loongson-3A1000";
     default:
         break;
     }
-    switch (eflags & EF_MIPS_ARCH) {
-    case EF_MIPS_ARCH_64R6:
+    if ((eflags & EF_MIPS_ARCH) == EF_MIPS_ARCH_64R6) {
         return "I6400";
-    case EF_MIPS_ARCH_64R2:
+    }
+    if (eflags & EF_MIPS_NAN2008) {
+        return "Loongson-3A4000";
+    }
+    if ((eflags & EF_MIPS_ARCH) == EF_MIPS_ARCH_64R2) {
         return "MIPS64R2-generic";
-    default:
-        break;
     }
     return "5KEf";
 #else