Commit Graph

166 Commits

Author SHA1 Message Date
Martin Whitaker
0873e3b60a Include string.h, not memory.h, when using memcpy and memset.
memory.h is an anachronism, and not present on all systems.
2022-03-11 18:07:01 +00:00
Martin Whitaker
f6da06b117 Work around the halt/wakeup race in barrier_halt_wait() (issue #13)
There is an unavoidable race between one core halting after decrementing
the barrier count and another core sending it the wakeup NMI. This can
only occur if the core sending the wakeup is running at many times the
speed of the core halting, but it has been observed on an Intel Icelake
mobile processor.
2022-03-08 23:25:16 +00:00
Martin Whitaker
0076e63885 Optimise the barrier wait code.
This reduces the number of instructions between decrementing the count
and halting in the halt wait case. Use the same code for the spin wait
case for consistency.
2022-03-08 23:25:16 +00:00
Martin Whitaker
ed0fd7830f Use IP instead of PC in interrupt display.
It's better to use the x86 terminology here.
2022-03-08 23:25:16 +00:00
Doc TB
3ead0458c5
Merge pull request #16 from memtest86plus/x86fr/misc_features
New reset method
2022-03-08 23:42:23 +01:00
Sam DEMEULEMEESTER
4bc3b6a3c8 Add additional reset method 2022-03-08 23:30:31 +01:00
Sam DEMEULEMEESTER
09f5525f33 Add additional reset method 2022-03-08 23:24:25 +01:00
Martin Whitaker
b609c4dd81 Make detection of EHCI asynchronous transfer complete more robust.
Using Interrupt On Completion is not robust, because the interrupt flag
is also set if a short transfer is detected. So we need to poll the
Active flag in the transfer descriptors.
2022-03-06 18:20:53 +00:00
Martin Whitaker
e92f488753 Improve efficiency of random number generation (discussion #8).
Use a more efficient algorithm that can be in-lined, and keep the
generator state in a local variable.
2022-03-05 20:04:32 +00:00
Martin Whitaker
5e2ab9289b Make sure the XHCI private memory is accessible.
The XHCI device index and scratchpad buffers are mapped into high memory,
in order to conserve low memory. They need to be accessible in the virtual
address space to allow us to initialise them. After initialisation. only
the XHCI accesses them.

We also only need to access the data structures in the device private
workspace during initialisation, but keeping separate physical and virtual
addresses for these structures makes the code considerably more complex,
so for now, move these to low memory.
2022-03-05 16:27:24 +00:00
Martin Whitaker
6c79f4d214 Fix communication with low speed devices in OHCI driver (issue #6). 2022-03-04 18:15:17 +00:00
Martin Whitaker
4078b7760e Faster barrier implementation.
The old barrier implementation was very slow when running on a multi-socket
machine (pcmemtest issue 16).

The new implementation provides two options:

  - when blocked, spin on a thread-local flag
  - when blocked, execute a HLT instruction and wait for a NMI

The first option might be faster, but we need to measure it to find out. A
new boot command line option is provided to select between the two, with a
third setting that uses a mixture of the two.
2022-02-28 22:05:21 +00:00
Martin Whitaker
311a597766 Remove unnecessary memory fence from spin_lock().
The x86 locked instructions enforce total memory ordering, so the
additional fence is redundant.
2022-02-28 22:05:21 +00:00
Martin Whitaker
b3d350f454 Add support for 64-bit local APIC addresses found in the MADT.
This is untested, as I don't have any hardware that uses this option.
2022-02-28 22:05:21 +00:00
Martin Whitaker
631cd553aa Make sure the cache is enabled on all CPU cores, not just the BSP. 2022-02-28 22:05:21 +00:00
Martin Whitaker
06d670e9a8 Make sure the boot command line is accessible during startup.
If we remap other regions, it's possible it could get overlaid.
2022-02-28 22:05:21 +00:00
Martin Whitaker
03464dce85 Make sure the bootparams structure remains accessible during startup.
Once we start remapping other regions, it's possible it could get overlaid.
2022-02-28 22:05:21 +00:00
Martin Whitaker
9fca23105a Don't search for the RDSP at bootparams.acpi_rsdp_addr.
This field is only used internally by the Linux kernel, so will always
be zero when bootparams is passed to us by a bootloader.
2022-02-28 22:05:21 +00:00
Martin Whitaker
da7829d4c3 Ensure the ACPI tables and local APIC are mapped into an accessible region.
We only map the first 4GB of physical address space, so if the ACPI tables
or local APIC are located above 4GB, or are overlaid when we remap something
else (e.g. the video frame buffer), we need to map them to somewhere we can
access. The ACPI tables are only used during startup, but the local APIC
will be needed when we are running tests if we are saving power by halting
idle CPU cores and using a NMI to wake them up.
2022-02-28 22:05:21 +00:00
Martin Whitaker
5211b67e6c Add option to map_region to indicate we only use the region during startup.
This will avoid unnecessary remapping of the ACPI tables if they are
located in the third GB of memory.
2022-02-28 22:05:21 +00:00
Martin Whitaker
a65d6a795d Rename map_device to map_region to better describe its use. 2022-02-28 22:05:21 +00:00
Martin Whitaker
604b22449a Allow device mapping to reuse existing mapped regions when they fully overlap. 2022-02-28 22:05:21 +00:00
Martin Whitaker
e4ad2dfa1b Don't use the top 0.5GB of the 32-bit address space for device mapping.
This region is commonly used by the BIOS for mapping hardware devices,
so we can avoid a lot of remapping if we don't use it.
2022-02-28 22:05:21 +00:00
Martin Whitaker
6b570cd779 Reduce the maximum mapped size of the linear frame buffer.
This is needed for subsequent changes. If we do ever get presented with
a frame buffer larger than 8192x8192 pixels, we'll need to think again
about how to manage it.
2022-02-28 22:05:21 +00:00
martinwhitaker
15b233cc89
Merge pull request #4 from memtest86plus/debrouxl_misc_improvements
Misc small improvements
2022-02-22 23:17:05 +00:00
Lionel Debroux
3ed9276eb0 Optimize the interrupt handler a bit by using compile-time string concatenation. 2022-02-22 11:00:02 +01:00
Lionel Debroux
7b6855f608 Add CLI arguments for enabling trace. 2022-02-22 10:59:58 +01:00
Martin Whitaker
f109a5814b Implement EHCI handover to companion controllers.
Low/full speed USB devices attached directly to the root hub must be
rerouted to a companion controller. We can't rely on the BIOS to do
this for us. This requires us to initialise the EHCI device before
initialising any of its companions.

This also allows us to support keyboards attached via a high speed
hub on a system with EHCI plus companions.
2022-02-20 20:21:16 +00:00
Martin Whitaker
3245b6d916 Don't turn the cache off in test 0 when performing dummy runs.
This should fix the slow startup on multi-socket machines (issue #16).
2022-02-19 20:55:41 +00:00
Martin Whitaker
f8b82eb0bd Exclude copyright notices from Doxygen file descriptions. 2022-02-19 19:56:55 +00:00
Martin Whitaker
d04ec9f681 Rename to Memtest86+ v6.0. 2022-02-19 19:44:58 +00:00
Martin Whitaker
0075375632 Import code from pcmemtest. 2022-02-19 17:58:09 +00:00
Martin Whitaker
3b183b0bef Add preliminary (untested) code for supporting UHCI. 2022-02-19 16:24:47 +00:00
Martin Whitaker
76adad2fe6 Add ability to generate internal API documentation using Doxygen. 2022-02-19 16:17:40 +00:00
Martin Whitaker
d09c5ed7b4 Remove the power-saving delay loop from the usleep function.
Now we halt inactive CPU cores, this should no longer be needed.
2022-02-19 13:04:26 +00:00
Martin Whitaker
0e61b1605e Remove volatile qualifier from testword pointers.
Now we use the atomic read/write functions, these are redundant.
2022-02-19 13:01:42 +00:00
Martin Whitaker
02bcec2418 Remove unnecessary volatile qualifiers from test state variables.
Thread safety is ensured by the barriers.
2022-02-19 12:44:14 +00:00
Martin Whitaker
e032df50d2 Minor code improvement for efficiency. 2022-02-19 11:52:42 +00:00
Martin Whitaker
e99a7aedb3 Revert to starting APs before doing the dummy runs.
That optimisation occasionally caused a hang if the CPU sequencing
mode was reconfigured after testing had started. It didn't make a
significant difference to the startup delay, so just drop it.
2022-02-18 20:35:36 +00:00
Martin Whitaker
cadad583d7 Eliminate the spinlock used when halting inactive CPU cores.
This is a more efficient implementation.
2022-02-18 20:08:24 +00:00
Martin Whitaker
f4a413cf6d Translate non-usable EFI memory regions to E820_RESERVED, not E820_NONE.
This is more correct. Using E820_NONE may have been confusing the code
in pmem.c that sanitises the memory map.
2022-02-13 20:44:58 +00:00
Martin Whitaker
807c4153c1 Add tracing for AP startup.
Also comment out tracing of memory window starts to reduce verbosity.
2022-02-13 20:25:58 +00:00
Martin Whitaker
d1382b7a53 Increase timeout delay for starting APs. 2022-02-13 20:25:11 +00:00
Martin Whitaker
16b066c3e3 Exit config menu immediately when "skip test" is selected. 2022-02-13 12:38:38 +00:00
Martin Whitaker
efc9a9c16a Don't attempt to start the APs when restarting after a config change.
Leave the APs running whilst the BSP repeats the dummy runs. This means
we need to bypass the barriers during a dummy run. The APs will wait at
the first barrier until the BSP starts the first real run.
2022-02-12 19:37:58 +00:00
Martin Whitaker
c23b129e55 Remove delay loop from spinlock wait.
Now we halt CPU cores that are going to be idle for a lengthy period,
we don't need to try to save power in other ways. And anyway, this was
not very effective.
2022-02-12 19:33:53 +00:00
Martin Whitaker
2bf1623733 Halt CPU cores that are not active in a test.
This saves a lot of power when performing sequential tests.
2022-02-12 19:30:14 +00:00
Martin Whitaker
de32bc5412 Ensure we only use 32-bit reads and writes when accessing APIC registers. 2022-02-12 09:39:18 +00:00
Martin Whitaker
99e258457b Use je/jne instead of jz/jnz when testing boolean variables in startup code.
Just for readability - they are aliases for the same instructions.
2022-02-12 09:39:18 +00:00
Martin Whitaker
39d5715224 Fix interrupt handling when long mode is enabled in a 32-bit binary (part 2).
Handle passing the processor state to the application interrupt handler.
Update the 64-bit code to match the new trap state structure definition.
2022-02-12 09:39:09 +00:00