Commit Graph

388 Commits

Author SHA1 Message Date
Lionel Debroux
20f05d5658 BROKEN Testing code for nontemporal writes in other tests, which usually slows down tests, sometimes a lot, especially when SMT is enabled ! 2023-02-11 22:33:45 +01:00
Lionel Debroux
a373e97175 Add experimental mode with nontemporal stores (movnt[iq]) in own addr test, the only one where it seems to uniformly help with performance across a number of processors I have access to, both single and multi-socket. Per #79, it saves several dozens of minutes on my 4S Opteron 62xx / 63xx servers equipped with 256 GB of RAM. 2023-02-11 22:33:36 +01:00
Lionel Debroux
ed8ea7cdc4 Add a rep stos[lq] path in the bit fade test, like in the mov_inv_fixed test. 2023-02-11 22:33:36 +01:00
Sam Demeulemeester
dfc41f7196 Solve incorrect core/thread count on some VIA CPUs
No Cyrix / VIA / CentaurHauls / Zhaoxin CPUs support HT, so disable it.
2023-02-11 19:00:36 +01:00
Martin Whitaker
f62bbfde32 Additional fix to support use on headless EFI systems (issue #240) 2023-02-11 09:14:56 +00:00
Jonathan Teh
8305d47675
Support cache and temperature info for VIA/Centaur/Zhaoxin CPUs (#259)
* Support cache and temperature info for VIA/Centaur/Zhaoxin CPUs

Use extended CPUID for VIA C3/C7/Nano cache information.

Use MSR reads for Nano/Zhaoxin and VIA C7 processor temperature.

Tested on VIA C7-D 1.5GHz.

* Small code conventions fixes

* Fix overallocation of cpuid_cache_info_t union (From PR #263)

---------

Co-authored-by: Sam Demeulemeester <github@x86-secret.com>
2023-02-10 22:32:31 +01:00
Jonathan Teh
a47f681151 smbus: Add support for VIA VT8237
Tested on Jetway J7F2 with VT8237R+.

Signed-off-by: Jonathan Teh <jonathan.teh@outlook.com>
2023-02-05 08:22:13 +01:00
Martin Whitaker
68e9542c1e Restore ability to build 64-bit binaries when building on 32-bit system. 2023-02-04 10:10:05 +00:00
Sam Demeulemeester
ce2c29eddc Bump version to v6.10 2023-02-02 23:52:18 +01:00
Martin Whitaker
b01c8e4388 Avoid sbverify warning about gap in section table.
We have a .setup section in the EFI image that contains the remainder of
the Linux boot header and the real-mode setup code to support booting via
an intermediate bootloader. This sits between the PE header and the .text
section. We don't want the EFI loader to load this section, so simply
increase the SizeOfHeader field in the PE header to cover it.
2023-02-02 14:01:13 +01:00
Martin Whitaker
d088740757 Fix the bss section size in 32-bit builds.
The AP stacks section was being discarded by the linker because the
change in section name and attributes hadn't been propagated from
the startup64.S to startup32.S.
2023-02-02 14:01:13 +01:00
Martin Whitaker
9c16a0568a Fix assembler warning about incorrect type/attributes for .reloc section. 2023-02-02 14:01:13 +01:00
Martin Whitaker
040e253b54 Remove the alignment characteristics from the EFI image PE section table.
The alignment characteristics are only valid in COFF files. The section
alignment for image files is determined by the SectionAlignment field
in the image header.
2023-02-02 14:01:13 +01:00
Martin Whitaker
2fa2346ae0 Use the correct name for the relocation type in the EFI image .reloc section.
The coding is the same, but IMAGE_REL_AMD64_ABSOLUTE is used for COFF
relocations, not for base relocations.
2023-02-02 14:01:13 +01:00
Martin Whitaker
e5d7119abf White space changes to improve readability. 2023-02-02 14:01:13 +01:00
Martin Whitaker
a4c9adc445 Fix the virtual memory addresses and sizes in the EFI image headers.
When the reloc and sbat sections were added by PR #34, three bugs were
introduced:

1. The virtual address and size fields in the PE headers were set to the
same values as the raw address and size fields. This is incorrect, because
the sections in the image file are aligned on 512 byte boundaries, but when
loaded into memory they need to be aligned on 4096 byte boundaries.

2. The value programmed into the SizeOfImage field was too large, as it
double-counted the region before the start of the .text section.

3. The value programmed into the SizeOfImage field no longer included the bss
size. That potentially allowed the EFI loader to load the image immediately
before a reserved region of memory without leaving enough space for the bss
section.

This commit fixes those bugs by calculating both file and virtual memory
offsets & sizes in the ld script. Note that we can't add a bss section to the
EFI image because many EFI loaders fail to load images that have uninitialised
data sections. Instead the text region size in virtual memory is increased
to include the bss size.

This fixes issue #243. It also eliminates the gaps between sections
observed in issue #202.
2023-02-02 14:01:13 +01:00
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