[PATCH 0/3] cpu_map: Install Ampere-1 ARM CPU models

BTW, the added test will not actually detect similar issues in the future (I'm thinking about such test, though), but it will help with other issues with the ARM CPU map as it hasn't been covered at all. Jiri Denemark (3): tests: Add a basic CPU test for aarch64 cpu_map: Install Ampere-1 ARM CPU models NEWS: Document ARM CPU map bug fix NEWS.rst | 6 +++++ src/cpu_map/meson.build | 2 ++ tests/cputest.c | 35 +++++++++++++++++++++++++++++ tests/cputestdata/aarch64-guest.xml | 4 ++++ 4 files changed, 47 insertions(+) create mode 100644 tests/cputestdata/aarch64-guest.xml -- 2.49.0

From: Jiri Denemark <jdenemar@redhat.com> The purpose of this test is to enforce loading and parsing of ARM CPU map so that possible issues are found earlier. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- tests/cputest.c | 35 +++++++++++++++++++++++++++++ tests/cputestdata/aarch64-guest.xml | 4 ++++ 2 files changed, 39 insertions(+) create mode 100644 tests/cputestdata/aarch64-guest.xml diff --git a/tests/cputest.c b/tests/cputest.c index 326ffebd09..401021e792 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -408,6 +408,34 @@ cpuTestHasFeature(const void *arg) } +static int +cpuTestValidateFeatures(const void *arg) +{ + const struct data *data = arg; + g_autoptr(virCPUDef) cpu = NULL; + int result; + + if (!(cpu = cpuTestLoadXML(data->arch, data->name))) + return -1; + + result = virCPUValidateFeatures(data->arch, cpu); + + if (data->result == -1) + virResetLastError(); + + if (data->result != result) { + VIR_TEST_VERBOSE("\nExpected result %s, got %s", + cpuTestBoolWithErrorStr(data->result), + cpuTestBoolWithErrorStr(result)); + /* Pad to line up with test name ... in virTestRun */ + VIR_TEST_VERBOSE("%74s", "... "); + return -1; + } + + return 0; +} + + typedef enum { /* No JSON data from QEMU. */ JSON_NONE, @@ -986,6 +1014,10 @@ mymain(void) host "/" feature " (" #result ")", \ host, feature, NULL, 0, NULL, 0, result) +#define DO_TEST_VALIDATEFEATURES(arch, name, result) \ + DO_TEST(arch, cpuTestValidateFeatures, name, \ + NULL, name, NULL, 0, NULL, 0, result) + #define DO_TEST_GUESTCPU(arch, host, cpu, models, result) \ DO_TEST(arch, cpuTestGuestCPU, \ host "/" cpu " (" #models ")", \ @@ -1235,6 +1267,9 @@ mymain(void) "Xeon-E5-2609-v3", "Xeon-E5-2650-v4"); DO_TEST_CPUID_BASELINE(VIR_ARCH_X86_64, "Haswell+Skylake", "Xeon-E7-8890-v3", "Xeon-Gold-5115"); + + DO_TEST_VALIDATEFEATURES(VIR_ARCH_AARCH64, "guest", 0); + cleanup: #if WITH_QEMU qemuTestDriverFree(&driver); diff --git a/tests/cputestdata/aarch64-guest.xml b/tests/cputestdata/aarch64-guest.xml new file mode 100644 index 0000000000..163bc66bb5 --- /dev/null +++ b/tests/cputestdata/aarch64-guest.xml @@ -0,0 +1,4 @@ +<cpu mode='custom' match='exact'> + <model fallback='forbid'>cortex-a57</model> + <feature name='pauth' policy='require'/> +</cpu> -- 2.49.0

From: Jiri Denemark <jdenemar@redhat.com> Fixes: 282f38ad3d3960b24aa97d75cae95c8c3d08a218 Fixes: https://gitlab.com/libvirt/libvirt/-/issues/762 Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/cpu_map/meson.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cpu_map/meson.build b/src/cpu_map/meson.build index 9a1c048620..dee8441a13 100644 --- a/src/cpu_map/meson.build +++ b/src/cpu_map/meson.build @@ -1,5 +1,7 @@ cpumap_data = [ 'arm_a64fx.xml', + 'arm_Ampere-1a.xml', + 'arm_Ampere-1.xml', 'arm_cortex-a53.xml', 'arm_cortex-a57.xml', 'arm_cortex-a72.xml', -- 2.49.0

From: Jiri Denemark <jdenemar@redhat.com> Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- NEWS.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index e2dc4e508b..2608086717 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -28,6 +28,12 @@ v11.3.0 (unreleased) * **Bug fixes** + * cpu_map: Install Ampere-1 ARM CPU models + + The Ampere-1 CPU models added in the previous release were not properly + installed and thus every attempt to start an ARM domain with custom + CPU definition would fail. + v11.2.0 (2025-04-01) ==================== -- 2.49.0

On Fri, Apr 04, 2025 at 02:49:57PM +0200, Jiri Denemark via Devel wrote:
BTW, the added test will not actually detect similar issues in the future (I'm thinking about such test, though), but it will help with other issues with the ARM CPU map as it hasn't been covered at all.
A test that parses the cpu_map.xml file and the src/cpu_map/meson.buld file and checks that every map entry is also listed in meson With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Fri, Apr 04, 2025 at 14:07:39 +0100, Daniel P. Berrangé wrote:
On Fri, Apr 04, 2025 at 02:49:57PM +0200, Jiri Denemark via Devel wrote:
BTW, the added test will not actually detect similar issues in the future (I'm thinking about such test, though), but it will help with other issues with the ARM CPU map as it hasn't been covered at all.
A test that parses the cpu_map.xml file and the src/cpu_map/meson.buld file and checks that every map entry is also listed in meson
Yes. I was even thinking about checking xml files in the src/cpu_map directory. Jirka

On 4/4/25 14:49, Jiri Denemark via Devel wrote:
BTW, the added test will not actually detect similar issues in the future (I'm thinking about such test, though), but it will help with other issues with the ARM CPU map as it hasn't been covered at all.
Jiri Denemark (3): tests: Add a basic CPU test for aarch64 cpu_map: Install Ampere-1 ARM CPU models NEWS: Document ARM CPU map bug fix
NEWS.rst | 6 +++++ src/cpu_map/meson.build | 2 ++ tests/cputest.c | 35 +++++++++++++++++++++++++++++ tests/cputestdata/aarch64-guest.xml | 4 ++++ 4 files changed, 47 insertions(+) create mode 100644 tests/cputestdata/aarch64-guest.xml
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (4)
-
Daniel P. Berrangé
-
Jiri Denemark
-
Jiří Denemark
-
Michal Prívozník