|
10 | 10 |
|
11 | 11 | import framework.utils_cpuid as cpuid_utils
|
12 | 12 | from framework import utils
|
| 13 | +from framework.properties import global_props |
13 | 14 | from framework.utils_cpuid import CPU_FEATURES_CMD, CpuModel
|
14 | 15 |
|
15 | 16 | PLATFORM = platform.machine()
|
@@ -81,25 +82,63 @@ def test_host_vs_guest_cpu_features_aarch64(uvm_nano):
|
81 | 82 | cpu_model = cpuid_utils.get_cpu_model_name()
|
82 | 83 | match cpu_model:
|
83 | 84 | case CpuModel.ARM_NEOVERSE_N1:
|
84 |
| - assert host_feats - guest_feats == set() |
85 |
| - # Kernel should hide this feature, but our guest kernel |
86 |
| - # currently lacks the commit with this change. |
87 |
| - # The commit that introduces the change: |
88 |
| - # https://github.com/torvalds/linux/commit/7187bb7d0b5c7dfa18ca82e9e5c75e13861b1d88 |
89 |
| - assert guest_feats - host_feats == {"ssbs"} |
| 85 | + expected_guest_minus_host = set() |
| 86 | + expected_host_minus_guest = set() |
| 87 | + |
| 88 | + # Upstream kernel v6.11+ hides "ssbs" from "lscpu" on Neoverse-N1 and Neoverse-V1 since |
| 89 | + # they have an errata whereby an MSR to the SSBS special-purpose register does not |
| 90 | + # affect subsequent speculative instructions, permitting speculative store bypassing for |
| 91 | + # a window of time. |
| 92 | + # https://github.com/torvalds/linux/commit/adeec61a4723fd3e39da68db4cc4d924e6d7f641 |
| 93 | + # |
| 94 | + # While Amazon Linux kernels (v5.10 and v6.1) backported the above commit, our test |
| 95 | + # ubuntu kernel (v6.8) and our guest kernels (v5.10 and v6.1) don't pick it. |
| 96 | + host_has_ssbs = global_props.host_os not in { |
| 97 | + "amzn2", |
| 98 | + "amzn2023", |
| 99 | + } and global_props.host_linux_version_tpl < (6, 11) |
| 100 | + guest_has_ssbs = vm.guest_kernel_version < (6, 11) |
| 101 | + |
| 102 | + if host_has_ssbs and not guest_has_ssbs: |
| 103 | + expected_host_minus_guest |= {"ssbs"} |
| 104 | + if not host_has_ssbs and guest_has_ssbs: |
| 105 | + expected_guest_minus_host |= {"ssbs"} |
| 106 | + |
| 107 | + assert host_feats - guest_feats == expected_host_minus_guest |
| 108 | + assert guest_feats - host_feats == expected_guest_minus_host |
90 | 109 | case CpuModel.ARM_NEOVERSE_V1:
|
| 110 | + expected_guest_minus_host = set() |
91 | 111 | # KVM does not enable PAC or SVE features by default
|
92 | 112 | # and Firecracker does not enable them either.
|
93 |
| - assert host_feats - guest_feats == { |
| 113 | + expected_host_minus_guest = { |
94 | 114 | "paca",
|
95 | 115 | "pacg",
|
96 | 116 | "sve",
|
97 | 117 | "svebf16",
|
98 | 118 | "svei8mm",
|
99 | 119 | }
|
100 |
| - # kernel should hide this feature, but our guest kernel |
101 |
| - # is not recent enough for this. |
102 |
| - assert guest_feats - host_feats == {"ssbs"} |
| 120 | + |
| 121 | + # Upstream kernel v6.11+ hides "ssbs" from "lscpu" on Neoverse-N1 and Neoverse-V1 since |
| 122 | + # they have an errata whereby an MSR to the SSBS special-purpose register does not |
| 123 | + # affect subsequent speculative instructions, permitting speculative store bypassing for |
| 124 | + # a window of time. |
| 125 | + # https://github.com/torvalds/linux/commit/adeec61a4723fd3e39da68db4cc4d924e6d7f641 |
| 126 | + # |
| 127 | + # While Amazon Linux kernels (v5.10 and v6.1) backported the above commit, our test |
| 128 | + # ubuntu kernel (v6.8) and our guest kernels (v5.10 and v6.1) don't pick it. |
| 129 | + host_has_ssbs = global_props.host_os not in { |
| 130 | + "amzn2", |
| 131 | + "amzn2023", |
| 132 | + } and global_props.host_linux_version_tpl < (6, 11) |
| 133 | + guest_has_ssbs = vm.guest_kernel_version < (6, 11) |
| 134 | + |
| 135 | + if host_has_ssbs and not guest_has_ssbs: |
| 136 | + expected_host_minus_guest |= {"ssbs"} |
| 137 | + if not host_has_ssbs and guest_has_ssbs: |
| 138 | + expected_guest_minus_host |= {"ssbs"} |
| 139 | + |
| 140 | + assert host_feats - guest_feats == expected_host_minus_guest |
| 141 | + assert guest_feats - host_feats == expected_guest_minus_host |
103 | 142 | case _:
|
104 | 143 | if os.environ.get("BUILDKITE") is not None:
|
105 | 144 | assert False, f"Cpu model {cpu_model} is not supported"
|
|
0 commit comments