From nobody Mon May 13 08:40:15 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1709573753665144.79096471973583; Mon, 4 Mar 2024 09:35:53 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 653F519EA; Mon, 4 Mar 2024 12:35:52 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 644ED19B3; Mon, 4 Mar 2024 12:34:26 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id CD24919AC; Mon, 4 Mar 2024 12:34:21 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id F09F719AB for ; Mon, 4 Mar 2024 12:34:20 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-581-msLu_YZOPx2qyjbmXF55gA-1; Mon, 04 Mar 2024 12:34:18 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A819185A597 for ; Mon, 4 Mar 2024 17:34:18 +0000 (UTC) Received: from orkuz (unknown [10.45.225.223]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C3B140C6EBA for ; Mon, 4 Mar 2024 17:34:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: msLu_YZOPx2qyjbmXF55gA-1 From: Jiri Denemark To: devel@lists.libvirt.org Subject: [PATCH] cpu: x86: Check for invalid CPU data from hypervisor Date: Mon, 4 Mar 2024 18:34:13 +0100 Message-ID: <4f8d19841be5dac99e3af34da0a1aee5fd827d2f.1709573653.git.jdenemar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: JTUJ3MCLOLLUYX4BKCWN6LLDLJAJ2HC5 X-Message-ID-Hash: JTUJ3MCLOLLUYX4BKCWN6LLDLJAJ2HC5 X-MailFrom: jdenemar@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709573754358100001 Recently a kernel bug caused QEMU to report a CPU feature as enabled while listing it in the "unavailable-features" list of features that were requested, but could not be enabled. The feature was actually enabled, but we marked it as disabled when starting a domain. Later when the domain is migrated, the destination requests the feature to be disabled, which breaks the guest ABI or if we are lucky QEMU just fails to load the migration stream. Let's make similar bugs more visible in the future by refusing to even start the domain. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- src/cpu/cpu_x86.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 6b2531b360..e8409ce616 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -3019,6 +3019,14 @@ virCPUx86UpdateLive(virCPUDef *cpu, x86DataIsSubset(&modelDisabled->data, &feature->data)) expected =3D VIR_CPU_FEATURE_DISABLE; =20 + if (x86DataIsSubset(&enabled, &feature->data) && + x86DataIsSubset(&disabled, &feature->data)) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("hypervisor provided conflicting CPU data: fe= ature '%1$s' is both enabled and disabled at the same time"), + feature->name); + return -1; + } + if (expected =3D=3D VIR_CPU_FEATURE_DISABLE && x86DataIsSubset(&enabled, &feature->data)) { VIR_DEBUG("Feature '%s' enabled by the hypervisor", feature->n= ame); --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org