I am using FreeBSD 10.2 amd64. On my earlier i386 installation, memtest86+ ran perfectly. I recently upgraded my hardware, moving from EVM 2GB DDR3 RAM to Hynix (Hyundai) 8 GB DDR3 RAM, after which I moved to FreeBSD 10.2 amd64. When at the FreeBSD boot loader prompt, I issue the commands : 1) unload # ok till here 2) load /boot/opt/memtest86+ # problem : the system simply does dead/reboots Incidentally running memtest86 (not memtest86+) from a bootable CD runs on the system perfectly, producing zero errors in 2 passes secured in about 75 minutes. I don't think it is important, but just in case it is needed, my system uses MBR partitioning with just 1 partition ada0s4a for the root partition, which holds all data.
I've observed similar behavior of the port: previously (on 8.4/i386) it was working as intended (with/via BOOT option), but on recent -CURRENT/amd64 it resulted in infinite reboot cycle.
Created attachment 182690 [details] attempt to fix loading via freebsd boot chain I finally found some time to look into this and made a few interesting discoveries. Most importantly, the current version of memtest86+, unlike all previous versions, does not relocate itself to the low memory at the very start. That, of course, causes a problem when it switches to the real mode needed for making BIOS calls. That's why it crashed in mem_size -> query_pcbios. I've added a patch to add that early relocation (patch-main.c). I've changed the initial load address to a higher value as well (patch-memtest.lds). That way there should be a smaller chance of interfering with the loader. Also, it seems that the stack size was too small, at least on my system, and some global variables got corrupted after the BIOS calls. I've added a patch for that too (patch-test.h). Additionally I've fixed the SMP detection code for systems with older ACPI versions (patch-smp.c). Finally, I have fixed a couple of problems in the code, so that it can be compiled with newer GCC versions (4.9.x, 5.x) (patch-test.c, patch-lib.c, patch-io.h). Unfortunately, resulting binaries do not work correctly, so the compiler is still 4.8. I suspect that the newer compilers do progressively more aggressive optimizations and that results in the bad code because of some quite sloppy inline assembly (incorrect constraints and clobber lists) in test.c. Could you please test it and see if it works? Thank you!
Thanks for looking into this Andriy! I've applied the patch and rebuilt the port, and tried to load it here on my amd64 laptop, but it did not work ("don't know how to load module"). I've rebooted back to FreeBSD and tried to load it with kldload(8): > kldload: /boot/opt/memtest86+: Unsupported file layout Am I missing something here? I've reverted the port to its current state but it did not change the described behavior I'm seeing.
(In reply to Alexey Dokuchaev from comment #3) This binary is obviously not a FreeBSD kernel module, so it can't be loaded with kldload. However, loader(8) should be to load it as it is a kind of a kernel. If you have old loader config files, then you might need to issue 'unload' first to unload the FreeBSD kernel. I think that this information is in pkg-message.
(In reply to Andriy Gapon from comment #2) Hi Andriy. Damn this sounds complicated. I had the exact same problem with sysutils/memtest86+ and gave your patch a try. Now instead of rebooting after the "load" command, I get a black screen lock up after the "boot" command (Ctrl+Alt+Del doesn't work, can't toggle the keyboard LEDs). So that's progress. Thanks for trying to fix it. FreeBSD 11.1-STABLE #1 r330969M CPU: AMD Phenom(tm) 9550 Quad-Core Processor (2199.21-MHz K8-class CPU) Same version of memtest86+ (5.01) works on this computer when booting it directly from a USB drive BTW.
We don't know this issue will be fixed by the update in bug #246116. In fact, according to the thread in that PR, it seems the opposite.