From nobody Mon Sep 16 19:07:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) 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 17193103411951008.1845135332538; Tue, 25 Jun 2024 03:12:21 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 12C9D13A0; Tue, 25 Jun 2024 06:12:20 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C182B13A9; Tue, 25 Jun 2024 06:11:26 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A3434E79; Tue, 25 Jun 2024 06:11:22 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 38578136C for ; Tue, 25 Jun 2024 06:11:22 -0400 (EDT) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-426-y2G-DkDZN-qPqCT_ga-2rA-1; Tue, 25 Jun 2024 06:11:19 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 84E4C19560A2 for ; Tue, 25 Jun 2024 10:11:18 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BF76A19560BF for ; Tue, 25 Jun 2024 10:11:17 +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=3.0 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719310281; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z6CP6bZXdau6z+OmvubphXtOCwiybZzA413pdgxUkIM=; b=LwlIv/2Ssr8yqmvGTbmJJ9jcE1F4atYHA7yN+a3DtembSubIT7fcdRapK66BReve3bVDOD gdism+vNM3XCGkoPF52abDnv47TMF8wwkpn5dYJPXW8t0XfcY9d0mwIKsOQ+3LLbGKuX3z q1SX51gvbZFdNPAZ1WxK5s7pzLxSd5E= X-MC-Unique: y2G-DkDZN-qPqCT_ga-2rA-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 1/2] qemu_capabilities: Introduce QEMU_CAPS_SEV_GUEST_LEGACY_VM_TYPE Date: Tue, 25 Jun 2024 12:11:13 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: FD6USAY64DCS6KAF2FCNCR3DAQPEPFN6 X-Message-ID-Hash: FD6USAY64DCS6KAF2FCNCR3DAQPEPFN6 X-MailFrom: mprivozn@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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1719310342411100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This capability tracks whether the sev-guest object has 'legacy-vm-type' attribute. It's going to be important later. Signed-off-by: Michal Privoznik --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_9.1.0_x86_64.xml | 1 + 3 files changed, 4 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index fe704d16dd..f20b20e875 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -711,6 +711,7 @@ VIR_ENUM_IMPL(virQEMUCaps, =20 /* 460 */ "sev-snp-guest", /* QEMU_CAPS_SEV_SNP_GUEST */ + "sev-guest.legacy-vm-type", /* QEMU_CAPS_SEV_GUEST_LEGACY_VM= _TYPE */ ); =20 =20 @@ -1575,6 +1576,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsQMPSc= hemaQueries[] =3D { { "object-add/arg-type/+iothread/thread-pool-max", QEMU_CAPS_IOTHREAD_= THREAD_POOL_MAX }, { "query-migrate/ret-type/blocked-reasons", QEMU_CAPS_MIGRATION_BLOCKE= D_REASONS }, { "screendump/arg-type/format/^png", QEMU_CAPS_SCREENSHOT_FORMAT_PNG }, + { "object-add/arg-type/+sev-guest/legacy-vm-type", QEMU_CAPS_SEV_GUEST= _LEGACY_VM_TYPE }, }; =20 typedef struct _virQEMUCapsObjectTypeProps virQEMUCapsObjectTypeProps; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index a98da8c2eb..68dc30f095 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -690,6 +690,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ =20 /* 460 */ QEMU_CAPS_SEV_SNP_GUEST, /* -object sev-snp-guest */ + QEMU_CAPS_SEV_GUEST_LEGACY_VM_TYPE, /* -object sev-guest.legacy-vm-typ= e=3D */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_9.1.0_x86_64.xml b/tests/qemuc= apabilitiesdata/caps_9.1.0_x86_64.xml index a9973a0913..0fdf9e9964 100644 --- a/tests/qemucapabilitiesdata/caps_9.1.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_9.1.0_x86_64.xml @@ -204,6 +204,7 @@ + 9000050 43100246 v9.0.0-1388-g80e8f06021-dirty --=20 2.44.2 From nobody Mon Sep 16 19:07:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) 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 1719310322238297.1828876263278; Tue, 25 Jun 2024 03:12:02 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3586113B6; Tue, 25 Jun 2024 06:12:01 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id CA81513D1; Tue, 25 Jun 2024 06:11:24 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 82AEACD0; Tue, 25 Jun 2024 06:11:22 -0400 (EDT) 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 087D2CD0 for ; Tue, 25 Jun 2024 06:11:22 -0400 (EDT) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-HhdikLuGPwK5KkGsp9pyYg-1; Tue, 25 Jun 2024 06:11:20 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A3AC319560AF for ; Tue, 25 Jun 2024 10:11:19 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E055619560BF for ; Tue, 25 Jun 2024 10:11: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=3.0 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719310281; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=edljE6tbaOsm08cJCRk/xxZC85MggJhB0nTZE0YZiko=; b=D3LVSmd7W2KUeNy0A3CbWdMuI0Lr0tlgDctxrOW4TCyzAnH3Q+7VF2MTAwGWXoeDMggea3 s9Mo13wV/i9n4OFTgmyHVps6aY4BiPVF1r+QRE9FLz0Zx6YSHfEvec2gyB3NYq7WxwNomS jczo8dqCcPMOBVj1O225m1qgOi0Lp1Q= X-MC-Unique: HhdikLuGPwK5KkGsp9pyYg-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 2/2] qemu_command: Enable sev-guest.legacy-vm-type when possible Date: Tue, 25 Jun 2024 12:11:14 +0200 Message-ID: <7db44ee1625280e2755dac74a3b4b3a77b08573c.1719309954.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: KP24LPFV4OCMN45TDHNXQVBPDZ56QSRR X-Message-ID-Hash: KP24LPFV4OCMN45TDHNXQVBPDZ56QSRR X-MailFrom: mprivozn@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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1719310324338100001 Content-Type: text/plain; charset="utf-8"; x-default="true" With recent enough QEMU (yet unreleased) there's 'legacy-vm-type' attribute of 'sev-guest' object. It controls whether QEMU uses newer or older interface to init SEV guests. As a result, the measurements (e.g. implemented in tools/virt-qemu-sev-validate) are affected. There's no clear benefit in switching to the new interface and thus we should set the attribute to keep old style of measurements. Signed-off-by: Michal Privoznik --- src/qemu/qemu_command.c | 9 +++++++++ .../launch-security-sev-direct.x86_64-latest.args | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6ec1e9cbef..0bc3c1b521 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9729,6 +9729,7 @@ qemuBuildSEVCommandLine(virDomainObj *vm, virCommand = *cmd, qemuDomainObjPrivate *priv =3D vm->privateData; g_autofree char *dhpath =3D NULL; g_autofree char *sessionpath =3D NULL; + bool legacyVMType =3D false; =20 VIR_DEBUG("policy=3D0x%x cbitpos=3D%d reduced_phys_bits=3D%d", sev->policy, sev->common.cbitpos, sev->common.reduced_phys_b= its); @@ -9739,6 +9740,13 @@ qemuBuildSEVCommandLine(virDomainObj *vm, virCommand= *cmd, if (sev->session) sessionpath =3D g_strdup_printf("%s/session.base64", priv->libDir); =20 + /* Starting from QEMU 9.1.0 (v9.0.0-rc4-45-g023267334d specifically), = QEMU + * uses new interface to create SEV guests. This changes what is measu= red. + * Toggle this knob to preserve old style of measurements. */ + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_SEV_GUEST_LEGACY_VM_TYPE)= ) { + legacyVMType =3D true; + } + if (qemuMonitorCreateObjectProps(&props, "sev-guest", "lsec0", "u:cbitpos", sev->common.cbitpos, "u:reduced-phys-bits", sev->common.re= duced_phys_bits, @@ -9746,6 +9754,7 @@ qemuBuildSEVCommandLine(virDomainObj *vm, virCommand = *cmd, "S:dh-cert-file", dhpath, "S:session-file", sessionpath, "T:kernel-hashes", sev->common.kernel= _hashes, + "B:legacy-vm-type", legacyVMType, NULL) < 0) return -1; =20 diff --git a/tests/qemuxmlconfdata/launch-security-sev-direct.x86_64-latest= .args b/tests/qemuxmlconfdata/launch-security-sev-direct.x86_64-latest.args index 09df8a7cb6..93cc2f71b9 100644 --- a/tests/qemuxmlconfdata/launch-security-sev-direct.x86_64-latest.args +++ b/tests/qemuxmlconfdata/launch-security-sev-direct.x86_64-latest.args @@ -33,6 +33,6 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-1-storage","read-only":false}' \ -device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-stor= age","id":"ide0-0-0","bootindex":1}' \ -audiodev '{"id":"audio1","driver":"none"}' \ --object '{"qom-type":"sev-guest","id":"lsec0","cbitpos":47,"reduced-phys-b= its":1,"policy":1,"dh-cert-file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest= 1/dh_cert.base64","session-file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest= 1/session.base64","kernel-hashes":true}' \ +-object '{"qom-type":"sev-guest","id":"lsec0","cbitpos":47,"reduced-phys-b= its":1,"policy":1,"dh-cert-file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest= 1/dh_cert.base64","session-file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest= 1/session.base64","kernel-hashes":true,"legacy-vm-type":true}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ -msg timestamp=3Don --=20 2.44.2