Commit Graph

372 Commits

Author SHA1 Message Date
Sam Demeulemeester
485bfa46a3
Add a quirk to disable SMP on SuperMicro X10SDV (#244) 2023-01-30 16:47:54 +01:00
Sam Demeulemeester
b15a8bb632 Add SPD support for ATI SB400 Southbridge 2023-01-23 16:09:32 +01:00
martinwhitaker
327495ec61
Allow use on headless EFI systems. (#242)
A headless EFI system may have no GOP devices. In this case, disable
output to the physical display, but continue to write to the shadow
buffer. This allows operation via a serial console.
2023-01-23 15:50:52 +01:00
Lionel Debroux
8f788b27e1 Add support for configuring the error reporting mode through the command line. Fixes #83. 2023-01-23 15:49:45 +01:00
Lionel Debroux
f24e897883 Add support for configuring the CPU sequencing mode through the command line. Reorder tests in app/config.c::parse_option alphabetically. Fixes #82. 2023-01-23 15:49:45 +01:00
Lionel Debroux
3aeda70e24 Move more of the simple string functions to the header, to allow inlining and further optimization.
Before:
   text    data     bss     dec     hex filename
  10374      19    2712   13105    3331 app/config.o
 106854   26720   13344  146918   23de6 memtest_shared
   8734      19    2712   11465    2cc9 app/config.o
 111310   28392  294688  434390   6a0d6 memtest_shared

After:
   text    data     bss     dec     hex filename
  10105      19    2712   12836    3224 app/config.o
 106580   26720   13344  146644   23cd4 memtest_shared
   8653      19    2712   11384    2c78 app/config.o
 110969   28392  294688  434049   69f81 memtest_shared
2023-01-23 15:49:45 +01:00
Lionel Debroux
b6992b9ec0
Fix parallel build after d3d52b: boot/setup.S now contains #include "build_version.h", so that file needs to be generated beforehand. (#235) 2023-01-23 15:17:47 +01:00
Sam Demeulemeester
10e8435604 Add SPD support for legacy VIA Southbridges (VT82C686A/B & VT8235)
(From PR #236)

Author: Corentin Labbe clabbe.montjoie@gmail.com
Co-developed-by: Lionel Debroux lionel_debroux@yahoo.fr
2023-01-23 15:01:48 +01:00
martinwhitaker
186ef6e913
Improved own addr test (#219)
* For 64-bit images, use the physical address as the test pattern in test 2.

This will make it easier to diagnose faults.

* Disable test 1 by default (issue #155).

Test 2 provides the same test coverage. Test 1 may make it slightly easier
to diagnose faults with a 32-bit image, so leave it as an option.

* For 32 bit images, use the physical address to generate the offset in test 2.

Detecting a stage change and using that to reset the offset counter
could fail when the config menu was used to skip to the next test
(issue #224).
2023-01-04 23:26:22 +01:00
martinwhitaker
d0399fd287
Add a command line option to disable the big PASS/FAIL status display. (#227) 2023-01-04 16:16:55 +01:00
Anders Wenhaug
68deff493f
Change how BadRAM patterns are aggregated to minimize the number of covered addresses (#178)
* BadRAM: Rename pattern -> patterns

* BadRAM: Refactor COMBINE_MASK and add clarifying comment

* BadRAM: Extract DEFAULT_MASK into variable

* BadRAM: Add is_covered() for checking if pattern is already covered by one of the existing patterns

* BadRAM: Initialize patterns to 0

* BadRAM: Change how addr/masks are merged to minimize number of addresses covered by badram

Prior to this patch, a list of up to MAX_PATTERNS (=10) addr/mask tuples
(aka. pattern) were maintained, adding failing addresses one by one to
the list until it was full. When full, space was created by forcing a
merge of the new address with the existing pattern that would grow the
least (with regards to number of addresses covered by the pattern) by
merging it with the new address. This can lead to a great imbalance in
the number of addresses covered by the patterns. Consider the following:

MAX_PATTERNS=4 (for illustrative purposes).
The following addresses are faulted and added to patterns:
0x00, 0x10, 0x20, 0x68, 0xa0, 0xb0, 0xc0, 0xd0

This is the end result with the implementation prior to this commit:

patterns = [
  (0x00, 0xe8),
  (0x00, 0x18),
  (0x68, 0xf8),
  (0x90, 0x98)
]
Total addresses covered: 120.

This commit changes how the merges are done, not only considering a
merge between the new address and existing patterns, but also between
existing patterns. It keeps the patterns in ascending order (by .addr)
in patterns, and a new address is always inserted into patterns (even if
num_patterns == MAX_PATTERNS, patterns is of MAX_PATTERNS+1 size). Then,
if num_patterns > MAX_PATTERNS, we find the pair of patterns (only
considering neighbours, assuming for any pattern i, i-1 or i+1 will
be the best candidate for a merge) that would be the cheapest to
merge (using the same metric as prior to this patch), and merge those.

With this commit, this is the result of the exact same sequence of
addresses as above:
[
  (0x00, 0xe0),
  (0x68, 0xf8),
  (0xa0, 0xe8),
  (0xc0, 0xe8)
]
Total addresses covered: 72.

A drawback of the current implementation (as compared to the prior)
is that it does not make any attempt at merging patterns until
num_patterns == MAX_PATTERNS, which can lead to having several patterns
that could've been merged into one at no additional cost. I.e.:

patterns = [
  (0x00, 0xf8),
  (0x08, 0xf8)
]
can appear, even if
patterns = [
  (0x00, 0xf0)
]
represents the exact same addresses with one pattern instead of two.

* fixup! BadRAM: Change how addr/masks are merged to minimize number of addresses covered by badram

Co-authored-by: Anders Wenhaug <anders.wenhaug@solutionseeker.no>
2023-01-03 23:12:47 +01:00
Martin Whitaker
1fca6dbcab Update ,gitignore for build_version.h. 2023-01-03 12:01:05 +00:00
Martin Whitaker
a1af48a8cf Fix and improve documentation in heap.h (issue #232) 2023-01-03 11:55:51 +00:00
Martin Whitaker
03cd8d1898 Fix disabling SMP using F2 at startup dialogue.
smp_init() used to be called after the startup dialogue, so F2 only
needed to change the enable_smp flag. Now smp_init() is called earlier,
we also need to reset num_available_cpus.
2023-01-03 11:38:55 +00:00
Sam Demeulemeester
d3d52b8a11 Add Memtest86+ Version String to Kernel Header (#75) 2023-01-03 01:35:51 +01:00
Peter Jones
04980dfda3 EFI: Add support for .sbat signature revocations
This patch adds a new section, ".sbat", which allows for the revocation
of signed binaries given a numeric value representing the set of bugs
which allow for arbitrary code execution, and therefore a Secure Boot
breakout, in a given family of binaries.

In this case, the class is defined as "memtest86+", and the current set
of bugs is 1.  This doesn't imply that we're aware of bugs currently,
merely that when we change it to 2, any bugs that /have/ been discovered
have been fixed.

Documentation for how SBAT works can be found at the following URLs:

  https://github.com/rhboot/shim/blob/main/SBAT.md
  https://github.com/rhboot/shim/blob/main/SBAT.example.md

Signed-off-by: Peter Jones <pjones@redhat.com>
2023-01-03 00:58:52 +01:00
Peter Jones
d1014365c1 EFI: Add a dummy relocation section
In the past, we've seen some problems with some EFI loaders refusing to
load a binary that has both a .text section with the VMA set and no
relocations, when the VMA set to load is already allocated for some
other purpose.

This patch adds a dummy absolute relocation from 0 to 0, so the loader
can always feel like it has done something useful.

Signed-off-by: Peter Jones <pjones@redhat.com>
2023-01-03 00:58:52 +01:00
Peter Jones
e022441544 Fix Pe.OptHdr.SizeOfImage and SizeOfHeaders
SizeOfImage is defined as:

  The size (in bytes) of the image, including all headers, as the image
  is loaded in memory. It must be a multiple of SectionAlignment.

SizeOfHeaders likewise is defined as:

  The combined size of an MS-DOS stub, PE header, and section headers
  rounded up to a multiple of FileAlignment.

Currently SizeOfImage represents .bss and .text, but it doesn't include
.header or .setup, nor any sections we'll add later, and there's nothing
enforcing that it matches SectionAlignment.  Additionally, since .bss is
being set up in our running code and /not/ by the loader, the current
value is dangerously high, as in the event there is an error in the
section table, it could potentially lead the loader to mark memory
allocated at runtime holding user-supplied data by any EFI binary loaded
before us as executable.

This patch adds a new symbol, _img_end, which is after .text and is
rounded up to 4kB (which is also what SectionAlignment is set to).  It
also adds a local label, anchored with ".org 512", and uses that to set
SizeOfHeaders - this will ensure the build fails without outputting and
invalid binary if the headers take too much space.

Signed-off-by: Peter Jones <pjones@redhat.com>
2023-01-03 00:58:52 +01:00
Peter Jones
3dd1fa8959 EFI: Add Data Directory space
Currently, the PE headers we create in boot/header.S do not allocate
space for any Data Directory entries, as they haven't been needed.

In order to support signatures and compatibility with some loaders, we
need the Data Directory to be populated at least enough to set
DataDirectory.Certs and DataDirectory.BaseReloc.

This patch extends that space enough to include those entries.

Signed-off-by: Peter Jones <pjones@redhat.com>
2023-01-03 00:58:52 +01:00
Peter Jones
e3c0d6df60 Make header.S use symbolic names for values
This changes header.S to use the constants defined in peimage.h to for
the values in its structure, making it a lot easier to debug.

Signed-off-by: Peter Jones <pjones@redhat.com>
2023-01-03 00:58:52 +01:00
Peter Jones
87f03f3b10 Add declarations and defines for PE images
This adds a header file to describe the PE binary we're building.  This
has constants defined for all the values we use in the PE headers, as
well as the structures for reference (guarded by #ifdef __ASSEMBLY__).

This particular peimage.h is originally from binutils-2.10.0.18, which
is GPLv2 licensed, and is copyright the Free Software Foundation.  I've
added the few additional fields we need.

Signed-off-by: Peter Jones <pjones@redhat.com>
2023-01-03 00:58:52 +01:00
Peter Jones
f96c5b5093 Use gcc -x assembler-with-cpp instead of gcc -E --traditional
This patch makes it so we use "gcc -x assembler-with-cpp" to build our
.S files, instead of translating them to .s files and assembling
directly.  This allows us to use header files and simple symbolic
arithmetic more conveniently in .S files, and at the same time reduces
the number of temporary files created when building.

Signed-off-by: Peter Jones <pjones@redhat.com>
2023-01-03 00:58:52 +01:00
dependabot[bot]
59a0996070
Bump actions/stale from 6 to 7 (#222)
Bumps [actions/stale](https://github.com/actions/stale) from 6 to 7.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-03 00:40:55 +01:00
Sam Demeulemeester
da7b9b955d Move Memtest86+ version number to an external file (along with the the latest GIT commit hash) (#75) 2023-01-03 00:39:10 +01:00
Sam Demeulemeester
036922ab26 Bump version to v6.01 2022-12-30 16:41:28 +01:00
Martin Whitaker
5a2bc4c960 Skip segments in tests where the calculated chunk size is too small.
If the memory map contains very small segments and we have many active CPUs,
the tests that split the segments into chunks distributed across the CPUs may
end up with chunks that are too small for the test algorithm. With 4K pages
and the current limit of 256 active CPUs, this is currently only a problem
for the block move and modulo-n tests, but if we ever support more than 512
active CPUs, it could affect the other tests too.

For now, just skip segments that are too small in the affected tests. As it
only affects the block move and modulo-n tests and only affects very small
regions of memory, the loss of test coverage is negligable.

This may fix issue #216.
2022-12-10 15:24:26 +00:00
Sam Demeulemeester
9a86f115f4 Add 'press any key to remove' message on banner
By default, don't re-display FAIL banner after it has been discarded (#130 & #173)
Add an option to re-display FAIL banner even if previously discarded
2022-11-27 23:34:43 +01:00
dependabot[bot]
0beb172a0d
Bump actions/stale from 5 to 6 (#175)
Bumps [actions/stale](https://github.com/actions/stale) from 5 to 6.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-28 11:04:33 +02:00
Sam Demeulemeester
d3bc8fa7c2 V6.00 Final Release - Fix title '+' char shift 2022-10-23 20:21:09 +02:00
Sam Demeulemeester
1ee1078cf5
V6.00 Final Release PR (#187)
* Avoid FAIL banner being partially overwriten by new errors

* Remove beta on main title

* Remove v6 Beta Disclaimer & some README.me changes for release
2022-10-23 17:32:17 +02:00
Martin Whitaker
5036aa197a Provide a more user-oriented grub-memtest.iso.
grub-memtest.iso was originally intended as a means of testing all
the different boot modes. But as we publish it on memtest.org, let's
have a more user-friendly version that provides menu entries for the
most commonly needed boot options. The original test ISO can still
be built by 'make GRUB_CFG=grub-test grub-iso'.
2022-10-12 15:34:09 +01:00
Martin Whitaker
1278f02617 Add new code contributions section to README table of contents. 2022-10-09 18:26:51 +01:00
Martin Whitaker
85213a9a27 Add code contribution section to the README, referencing the README_DEVEL. 2022-10-09 13:51:32 +01:00
Martin Whitaker
83d08db69e Document the lack of support for USB hot-plugging in the README. 2022-10-09 13:45:26 +01:00
Martin Whitaker
aaa0cffaa6 Use virtual memory base address when probing USB controllers (issue #180)
We still want to display the physical address for debug purposes, but
must access the controller via the possibly remapped virtual address.
2022-10-07 13:06:42 +01:00
Martin Whitaker
66b1389348 Revert workaround for issue #6 and issue #71 (commit 3a10701).
The early USB handoff is a better fix for those issues.
2022-10-07 09:33:23 +01:00
martinwhitaker
407fb811c2
Take ownership of all USB controllers before probing for devices. (#167)
When two controllers are attached to a physical port (e.g. in the
case of EHCI and its companion controllers, problems can occur if
the BIOS still has control of one controller when we try to use the
other one. So perform a first pass to scan the PCI bus and take
ownership of and reset all the controllers we find, and perform a
second pass to initialise the controllers and probe for attached
devices.

As we don't support hot plugging, split the second pass into two,
with the first probing the EHCI controllers and handing over any
low and full speed devices to the companion controllers, and the
second probing the remaining controller types.
2022-10-07 09:32:09 +01:00
Sam Demeulemeester
ddbee66c85 Fix a cast issue that broke the run time clock on (very) fast CPUs 2022-09-14 20:47:29 +02:00
Lionel Debroux
1c4d7f4089
Document PCI vendor and device IDs for several SMBus controller models from SiS, EFAR and ALi; move the PCI vendor ID defines from system/smbus.h to system/pci.h and add several vendor IDs; use the defines from system/pci.h in system/hwquirks.c. (#154)
Inspired by #126.
2022-09-14 18:57:10 +02:00
Martin Whitaker
c41159084d Guard against unsupported or invalid USB controller types. 2022-09-09 19:48:59 +01:00
Sam Demeulemeester
03a5222ee2 Add support for Zen4/AM5 DDR5 SPD 2022-09-09 18:09:13 +02:00
Martin Whitaker
f265d1f1c5 Fix EHCI and XHCI drivers to handle USB1 hubs (issue #156) 2022-09-08 18:09:43 +01:00
Sam Demeulemeester
18f12116c0 Fix a rare capacity detection issue with DDR3 modules built using 3 or 4 ranks 2022-08-29 02:50:11 +02:00
Sam Demeulemeester
385f912776 Fix date decoding issue: week 53 is actually valid for some years 2022-08-29 02:12:05 +02:00
Sam Demeulemeester
6799bfba3c Fix timings decoding issues with DDR3 XMP Modules. Add quirks for early modules based on XMP Draft 2022-08-29 01:59:36 +02:00
01e3
540270513f smbus: introduce and use bcd_to_ui8 helper function
Introduce bcd_to_ui8 for converting BCD into uint8_t.

Currently, smbus.c is the only user of this code so I placed it there.
Once (if?) there are more, we may want to move it to a dedicated ".h" file.

Replace all BCD conversion in smbus.c with a call to bcd_to_ui8().

No change in the binary output.
2022-08-28 18:14:41 +02:00
01e3
5686da4b1d smbus: optimize parse_spd_* functions
Convert calling / return convention for all parse_spd_* functions from
returning the value of spd_info structure to updating the received
reference. This also allows to move / remove some boilerplate code,
like initializing spdi/curspd and setting slot_num.

At the end, print_smbus_startup_info wants curspd to be updated,
so we can do this in a more efficient way.

Before:
      text       data        bss      total filename
     10784       3887         18      14689 build32/system/smbus.o
     10486       4399         18      14903 build64/system/smbus.o

     79353      51101      13088     143542 build32/memtest_shared
     78438      58077     294432     430947 build64/memtest_shared

After:
      text       data        bss      total filename
     10379       3871         18      14268 build32/system/smbus.o
      9833       4399         18      14250 build64/system/smbus.o

     78937      51101      13088     143126 build32/memtest_shared
     77782      58077     294432     430291 build64/memtest_shared

gcc-11.3.0.
2022-08-28 18:14:41 +02:00
01e3
43b0f64ddb smbus: refactor SPD SKU (part number) handling
Replace SPD SKU reading code repeated multiple times across
all the parse_spd_* functions with a dedicated read_sku function.

Convert spd_infos.sku from len+data into classic NULL-terminated C-string.
Takes the same space, but simplifies handling. Also, use char instead of
uint8_t so no conversion is needed when printing.

Change the way how the end of part number is handled. Stop on the first
non-ASCII character and then trim all trailing spaces. This allows SKUs
with two (or more) spaces inside the name to be handled properly.

Finally, fix incorrect / inconsistent part number length handling, with
the following end result:
 - parse_spd_sdram: 18 [73-90] (no change)
 - parse_spd_rdram: 18 [73-90] (no change)
 - parse_spd_ddr:   18 [73-90] (no change)
 - parse_spd_ddr2:  18 [73-90] (no change)
 - parse_spd_ddr3:  20+1=21 -> 18 [128-145]
 - parse_spd_ddr4:  20+1=21 -> 20 [329-348]
 - parse_spd_ddr5:  29+1=30 -> 30 [521-550] (technicaly no change)

Before:
      text       data        bss      total filename
     13143       3795         18      16956 build32/system/smbus.o
     11735       4359         18      16112 build64/system/smbus.o

     81705      51133      13088     145926 build32/memtest_shared
     79686      58109     294432     432227 build64/memtest_shared

After:
      text       data        bss      total filename
     10784       3887         18      14689 build32/system/smbus.o
     10486       4399         18      14903 build64/system/smbus.o

     79353      51101      13088     143542 build32/memtest_shared
     78438      58077     294432     430947 build64/memtest_shared

gcc-11.3.0.
2022-08-28 18:14:41 +02:00
Sam Demeulemeester
0f8981412c
Various fixes on SPD decoding algorithms (#152)
* [DDR5] Fix rounding errors on SPD Timings

* [DDR5] Add a rounding factor of ~0.3% according to JEDEC to solve the last rounding issue found on NETAC Modules

* [DDR5] Add missing package ranks per channel parameter in total module capacity algorithm

* [DDR4] Fix rounding issues in SPD timings & frequency

* [DDR3] Fix rounding issues in SPD timings & frequency decoding. Check XMP Profile #2. Add a quirk for Kingston based on very early XMP 1.0 specs

* [DDR2] Fix CAS detection & rounding issues in SPD timings w/ EPP

* [DDR] Correct SPD timings rounding issues & add support for x.5 CAS latencies

* [SDR] Correct SPD Timings decoding due to rounding errors

* Add various JEP106 Manufacturers found while debugging

* Update timings display function to handle x.5 CAS
2022-08-26 21:56:12 +02:00
Martin Whitaker
93051adfc2 Update README.
- update text to indicate that benchmarking and SPD reporting has
  now been restored
- point to GitHub issue tracker for known limitations and bugs
2022-08-20 10:18:25 +01:00