|
|
49d448 |
From 99a298a4a0575bf0072f504c4b8e4551400c44c0 Mon Sep 17 00:00:00 2001
|
|
|
49d448 |
Message-Id: <99a298a4a0575bf0072f504c4b8e4551400c44c0@dist-git>
|
|
|
49d448 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
49d448 |
Date: Tue, 26 Apr 2022 11:58:07 +0200
|
|
|
49d448 |
Subject: [PATCH] cpu_x86: Consolidate signature match in x86DecodeUseCandidate
|
|
|
49d448 |
|
|
|
49d448 |
Checking the signature in two different places makes no sense since the
|
|
|
49d448 |
code in between can only mark the candidate as the best option so far,
|
|
|
49d448 |
which is what the second signature match does as well.
|
|
|
49d448 |
|
|
|
49d448 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
49d448 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
49d448 |
(cherry picked from commit 35ce086667e68e8f546cf36473591dd7c19c72eb)
|
|
|
49d448 |
|
|
|
49d448 |
https://bugzilla.redhat.com/show_bug.cgi?id=1851227
|
|
|
49d448 |
|
|
|
49d448 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
49d448 |
---
|
|
|
49d448 |
src/cpu/cpu_x86.c | 31 ++++++++++++++-----------------
|
|
|
49d448 |
1 file changed, 14 insertions(+), 17 deletions(-)
|
|
|
49d448 |
|
|
|
49d448 |
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
|
49d448 |
index 5cb9caef8a..f007487824 100644
|
|
|
49d448 |
--- a/src/cpu/cpu_x86.c
|
|
|
49d448 |
+++ b/src/cpu/cpu_x86.c
|
|
|
49d448 |
@@ -2020,15 +2020,22 @@ x86DecodeUseCandidate(virCPUx86Model *current,
|
|
|
49d448 |
}
|
|
|
49d448 |
|
|
|
49d448 |
/* Ideally we want to select a model with family/model equal to
|
|
|
49d448 |
- * family/model of the real CPU. Once we found such model, we only
|
|
|
49d448 |
+ * family/model of the real CPU and once we found such model, we only
|
|
|
49d448 |
* consider candidates with matching family/model.
|
|
|
49d448 |
*/
|
|
|
49d448 |
- if (signature &&
|
|
|
49d448 |
- virCPUx86SignaturesMatch(current->signatures, signature) &&
|
|
|
49d448 |
- !virCPUx86SignaturesMatch(candidate->signatures, signature)) {
|
|
|
49d448 |
- VIR_DEBUG("%s differs in signature from matching %s",
|
|
|
49d448 |
- cpuCandidate->model, cpuCurrent->model);
|
|
|
49d448 |
- return 0;
|
|
|
49d448 |
+ if (signature) {
|
|
|
49d448 |
+ if (virCPUx86SignaturesMatch(current->signatures, signature) &&
|
|
|
49d448 |
+ !virCPUx86SignaturesMatch(candidate->signatures, signature)) {
|
|
|
49d448 |
+ VIR_DEBUG("%s differs in signature from matching %s",
|
|
|
49d448 |
+ cpuCandidate->model, cpuCurrent->model);
|
|
|
49d448 |
+ return 0;
|
|
|
49d448 |
+ }
|
|
|
49d448 |
+
|
|
|
49d448 |
+ if (!virCPUx86SignaturesMatch(current->signatures, signature) &&
|
|
|
49d448 |
+ virCPUx86SignaturesMatch(candidate->signatures, signature)) {
|
|
|
49d448 |
+ VIR_DEBUG("%s provides matching signature", cpuCandidate->model);
|
|
|
49d448 |
+ return 1;
|
|
|
49d448 |
+ }
|
|
|
49d448 |
}
|
|
|
49d448 |
|
|
|
49d448 |
if (cpuCurrent->nfeatures > cpuCandidate->nfeatures) {
|
|
|
49d448 |
@@ -2037,16 +2044,6 @@ x86DecodeUseCandidate(virCPUx86Model *current,
|
|
|
49d448 |
return 1;
|
|
|
49d448 |
}
|
|
|
49d448 |
|
|
|
49d448 |
- /* Prefer a candidate with matching signature even though it would
|
|
|
49d448 |
- * result in longer list of features.
|
|
|
49d448 |
- */
|
|
|
49d448 |
- if (signature &&
|
|
|
49d448 |
- virCPUx86SignaturesMatch(candidate->signatures, signature) &&
|
|
|
49d448 |
- !virCPUx86SignaturesMatch(current->signatures, signature)) {
|
|
|
49d448 |
- VIR_DEBUG("%s provides matching signature", cpuCandidate->model);
|
|
|
49d448 |
- return 1;
|
|
|
49d448 |
- }
|
|
|
49d448 |
-
|
|
|
49d448 |
VIR_DEBUG("%s does not result in shorter feature list than %s",
|
|
|
49d448 |
cpuCandidate->model, cpuCurrent->model);
|
|
|
49d448 |
return 0;
|
|
|
49d448 |
--
|
|
|
49d448 |
2.35.1
|
|
|
49d448 |
|