From nobody Thu May 15 13:34:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1507129474989808.7000962087288; Wed, 4 Oct 2017 08:04:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0190B7F415; Wed, 4 Oct 2017 15:04:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D1F1F5E1AB; Wed, 4 Oct 2017 15:04:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 945C318355C2; Wed, 4 Oct 2017 15:04:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v94Ewt6e006839 for ; Wed, 4 Oct 2017 10:58:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id B490C5C542; Wed, 4 Oct 2017 14:58:55 +0000 (UTC) Received: from mamuti.net (unknown [10.34.246.102]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 898885C8BA for ; Wed, 4 Oct 2017 14:58:55 +0000 (UTC) Received: by mamuti.net (Postfix, from userid 500) id 497B410400B; Wed, 4 Oct 2017 16:58:50 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0190B7F415 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 4 Oct 2017 16:58:33 +0200 Message-Id: <47456c158f8db4d1f62776ed488ebe3bf02f364a.1507128897.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/23] cpu_x86: Disable blockers from unusable CPU models X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 04 Oct 2017 15:04:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When decoding CPUID data to virCPUDef we need to be careful about using a CPU model which cannot be directly used on the current host. Normally, libvirt would notice the features which prevent the model from being usable and it would disable them in the computed virCPUDef, but this won't work in case the definition of the CPU model in QEMU contains more features than what we have in cpu_map.xml. We need to count with the usability blockers we got from QEMU and explicitly disable all of them to make the computed virCPUDef usable. https://bugzilla.redhat.com/show_bug.cgi?id=3D1464832 Signed-off-by: Jiri Denemark Reviewed-by: John Ferlan --- src/cpu/cpu_x86.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index e197e31310..0dbc17f199 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -627,7 +627,8 @@ x86DataAddSignature(virCPUx86Data *data, static virCPUDefPtr x86DataToCPU(const virCPUx86Data *data, virCPUx86ModelPtr model, - virCPUx86MapPtr map) + virCPUx86MapPtr map, + virDomainCapsCPUModelPtr hvModel) { virCPUDefPtr cpu; virCPUx86Data copy =3D VIR_CPU_X86_DATA_INIT; @@ -647,6 +648,21 @@ x86DataToCPU(const virCPUx86Data *data, x86DataSubtract(©, &modelData); x86DataSubtract(&modelData, data); =20 + /* The hypervisor's version of the CPU model (hvModel) may contain + * additional features which may be currently unavailable. Such featur= es + * block usage of the CPU model and we need to explicitly disable them. + */ + if (hvModel && hvModel->blockers) { + char **blocker; + virCPUx86FeaturePtr feature; + + for (blocker =3D hvModel->blockers; *blocker; blocker++) { + if ((feature =3D x86FeatureFind(map, *blocker)) && + !x86DataIsSubset(©, &feature->data)) + x86DataAdd(&modelData, &feature->data); + } + } + /* because feature policy is ignored for host CPU */ cpu->type =3D VIR_CPU_TYPE_GUEST; =20 @@ -1835,6 +1851,7 @@ x86Decode(virCPUDefPtr cpu, virCPUx86Data copy =3D VIR_CPU_X86_DATA_INIT; virCPUx86Data features =3D VIR_CPU_X86_DATA_INIT; virCPUx86VendorPtr vendor; + virDomainCapsCPUModelPtr hvModel; uint32_t signature; ssize_t i; int rc; @@ -1855,7 +1872,7 @@ x86Decode(virCPUDefPtr cpu, */ for (i =3D map->nmodels - 1; i >=3D 0; i--) { candidate =3D map->models[i]; - if (!virCPUModelIsAllowed(candidate->name, models, NULL)) { + if (!virCPUModelIsAllowed(candidate->name, models, &hvModel)) { if (preferred && STREQ(candidate->name, preferred)) { if (cpu->fallback !=3D VIR_CPU_FALLBACK_ALLOW) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -1883,7 +1900,7 @@ x86Decode(virCPUDefPtr cpu, continue; } =20 - if (!(cpuCandidate =3D x86DataToCPU(&data, candidate, map))) + if (!(cpuCandidate =3D x86DataToCPU(&data, candidate, map, hvModel= ))) goto cleanup; cpuCandidate->type =3D cpu->type; =20 --=20 2.14.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list