Skip to content

Commit

Permalink
check_microarch: add rhel10 requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Hecko committed Aug 28, 2024
1 parent bc54b90 commit ceb5151
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
13 changes: 11 additions & 2 deletions repos/system_upgrade/common/actors/checkmicroarchitecture/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class CheckMicroarchitecture(Actor):
levels.
RHEL9 has a higher CPU requirement than older versions, it now requires a
CPU compatible with ``x86-64-v2`` instruction set or higher.
CPU compatible with ``x86-64-v2`` instruction set or higher. Similarly,
RHEL10 requires at least ``x86-64-v3`` instruction set.
.. table:: Required CPU features by microarchitecure level with a
corresponding flag as shown by ``lscpu``.
Expand All @@ -43,7 +44,15 @@ class CheckMicroarchitecture(Actor):
| | SSE4_2 | sse4_2 |
| | SSSE3 | ssse3 |
+------------+-------------+--------------------+
| ... | | |
| x86-64-v3 | AVX | avx |
| | AVX2 | avx2 |
| | BMI1 | bmi1 |
| | BMI2 | bmi2 |
| | F16C | f16c |
| | FMA | fma |
| | LZCNT | abm |
| | MOVBE | movbe |
| | OSXSAVE | xsave |
+------------+-------------+--------------------+
Note: To get the corresponding flag for the CPU feature consult the file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

X86_64_BASELINE_FLAGS = ['cmov', 'cx8', 'fpu', 'fxsr', 'mmx', 'syscall', 'sse', 'sse2']
X86_64_V2_FLAGS = ['cx16', 'lahf_lm', 'popcnt', 'pni', 'sse4_1', 'sse4_2', 'ssse3']
X86_64_V3_FLAGS = ['avx2', 'bmi1', 'bmi2', 'f16c', 'fma', 'abm', 'movbe', 'xsave']

MicroarchInfo = namedtuple('MicroarchInfo', ('required_flags', 'extra_report_fields', 'microarch_ver'))

Expand All @@ -16,15 +17,15 @@ def _inhibit_upgrade(missing_flags, target_rhel, microarch_ver, extra_report_fie
title = 'Current x86-64 microarchitecture is unsupported in {0}'.format(target_rhel)
summary = ('{0} has a higher CPU requirement than older versions, it now requires a CPU '
'compatible with {1} instruction set or higher.\n\n'
'Missings flags detected are: {2}\n'.format(target_rhel, microarch_ver, ', '.join(missing_flags)))
'Missings flags detected are: {2}\n').format(target_rhel, microarch_ver, ', '.join(missing_flags))

report_fields = [
reporting.Title(title),
reporting.Summary(summary),
reporting.Severity(reporting.Severity.HIGH),
reporting.Groups([reporting.Groups.INHIBITOR]),
reporting.Groups([reporting.Groups.SANITY]),
reporting.Remediation(hint=('If case of using virtualization, virtualization platforms often allow '
reporting.Remediation(hint=('If a case of using virtualization, virtualization platforms often allow '
'configuring a minimum denominator CPU model for compatibility when migrating '
'between different CPU models. Ensure that minimum requirements are not below '
'that of {0}\n').format(target_rhel)),
Expand Down Expand Up @@ -56,6 +57,9 @@ def process():
'9': MicroarchInfo(microarch_ver='x86-64-v2',
required_flags=(X86_64_BASELINE_FLAGS + X86_64_V2_FLAGS),
extra_report_fields=[rhel9_microarch_article]),
'10': MicroarchInfo(microarch_ver='x86-64-v3',
required_flags=(X86_64_BASELINE_FLAGS + X86_64_V2_FLAGS + X86_64_V3_FLAGS),
extra_report_fields=[]),
}

microarch_info = rhel_major_to_microarch_reqs.get(get_target_major_version())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ def test_not_x86_64_passes(monkeypatch, arch):
assert not reporting.create_report.called


ENTIRE_V2_FLAG_SET = checkmicroarchitecture.X86_64_BASELINE_FLAGS + checkmicroarchitecture.X86_64_V2_FLAGS
ENTIRE_V3_FLAG_SET = ENTIRE_V2_FLAG_SET + checkmicroarchitecture.X86_64_V3_FLAGS


@pytest.mark.parametrize(
('target_ver', 'cpu_flags'),
[
('9.0', checkmicroarchitecture.X86_64_BASELINE_FLAGS + checkmicroarchitecture.X86_64_V2_FLAGS)
('9.0', ENTIRE_V2_FLAG_SET),
('10.0', ENTIRE_V3_FLAG_SET)
]
)
def test_valid_microarchitecture(monkeypatch, target_ver, cpu_flags):
Expand All @@ -48,16 +53,22 @@ def test_valid_microarchitecture(monkeypatch, target_ver, cpu_flags):
assert not reporting.create_report.called


@pytest.mark.parametrize('target_ver', ['9.0'])
def test_invalid_microarchitecture(monkeypatch, target_ver):
@pytest.mark.parametrize(
('target_ver', 'cpu_flags'),
(
('9.0', checkmicroarchitecture.X86_64_BASELINE_FLAGS),
('10.0', ENTIRE_V2_FLAG_SET),
)
)
def test_invalid_microarchitecture(monkeypatch, target_ver, cpu_flags):
"""
Test report is generated on x86-64 architecture with invalid microarchitecture and the upgrade is inhibited
"""

cpu_info = CPUInfo(flags=cpu_flags)
monkeypatch.setattr(reporting, "create_report", create_report_mocked())
monkeypatch.setattr(api, 'current_logger', logger_mocked())
monkeypatch.setattr(api, 'current_actor',
CurrentActorMocked(arch=ARCH_X86_64, msgs=[CPUInfo()], dst_ver=target_ver))
CurrentActorMocked(arch=ARCH_X86_64, msgs=[cpu_info], dst_ver=target_ver))

checkmicroarchitecture.process()

Expand Down

0 comments on commit ceb5151

Please sign in to comment.