From nobody Sun Jul 26 11:01:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1783140859; cv=none; d=zohomail.com; s=zohoarc; b=gKKUANrx1ad8EAQtB//9hQCmEQ0s5nbS/1RX7RgO/oRQEMXRHFg2QC4BDKoGXV7hvBt1C/da2Gln56FAoZc08mtELT5J7SQTrd21lWsccXWATn4mLByEypM9EXhr1ZacPPk2jfYzggyukIzAltzwaZYfEdeTw5uXpRogyuLPhr8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783140859; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0CNVx6liB/UNUdd/yZShSDPiIsbIMeABUGo+654/gsY=; b=kNhwmseafcVr9PUzlaMUtVm6iHCjJDSMCsUhlusVoyflc5yPA49FGSRIvJLStp5J0g4DgS1lbYb+NLHXGKaPCWaXH63MQugIm+/m3f6LFX2TH+wR5KHIKWF/UqAqHr7as936LpugJD9iFcdD7J791FQovIeD8OrP9WDuuPqVKHs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1783140859291286.9984653107524; Fri, 3 Jul 2026 21:54:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wfsNd-000336-Mx; Sat, 04 Jul 2026 00:53:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wfsNc-00032c-H0 for qemu-devel@nongnu.org; Sat, 04 Jul 2026 00:53:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wfsNZ-0007ha-MR for qemu-devel@nongnu.org; Sat, 04 Jul 2026 00:53:28 -0400 Received: from mx-prod-mc-01.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-678-YQCojCXXMOSKoouvgPSRnQ-1; Sat, 04 Jul 2026 00:53:20 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C165619560BA; Sat, 4 Jul 2026 04:53:18 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.48.8]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C836930030E3; Sat, 4 Jul 2026 04:53:17 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 67F7D1800618; Sat, 04 Jul 2026 06:53:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783140803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0CNVx6liB/UNUdd/yZShSDPiIsbIMeABUGo+654/gsY=; b=M3T8dC77u+X3kHjIlti59B+DsOVg/7IiJlIl7gi4+RPTFgXqN63AkX3Aui/nZi/wzOrp64 z+/ReyLCmnd60Nj0iUCN1/buAoTWF/fDMUCvM/iKkhOtsBf5Au/8CD6VGzWAEDWGaYM21o j3quut7s25/ZxWJT/6WfKqK0sqwvR/0= X-MC-Unique: YQCojCXXMOSKoouvgPSRnQ-1 X-Mimecast-MFC-AGG-ID: YQCojCXXMOSKoouvgPSRnQ_1783140799 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Ani Sinha , Stefano Garzarella , Zhao Liu , Gerd Hoffmann , Luigi Leonardi Subject: [PULL 1/3] igvm: Report error on missing parameter area in directive handlers Date: Sat, 4 Jul 2026 06:53:14 +0200 Message-ID: <20260704045316.1624628-2-kraxel@redhat.com> In-Reply-To: <20260704045316.1624628-1-kraxel@redhat.com> References: <20260704045316.1624628-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1783140861767158500 From: Luigi Leonardi Parameter areas are how an IGVM file tells QEMU to allocate buffers for runtime information the guest needs =E2=80=94 VP count, memory map, MADT and so on. Usage directives reference a parameter area by index to tell QEMU where to write each piece of data. If the index doesn't match any declared parameter area, the data has nowhere to go and should be treated as an error. The directive handlers that look up a parameter area all return 0 (success) when `qigvm_find_param_entry()` can't find it. Therefore, the load succeeds but the guest never gets the expected parameters. Note that the IGVM library already validates parameter area indices when the file is loaded, so this path should only be reachable with a malformed file that bypassed library validation. This is defensive programming against that case. Report the error with error_setg() and return -1 instead. Signed-off-by: Luigi Leonardi Reviewed-by: Stefano Garzarella Message-ID: <20260626-microvm_device_tree-v6-1-9cd13cf057e2@redhat.com> Signed-off-by: Gerd Hoffmann --- include/system/igvm-internal.h | 3 ++- backends/igvm.c | 26 ++++++++++++++++---------- target/i386/igvm.c | 5 +++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/include/system/igvm-internal.h b/include/system/igvm-internal.h index 7f131c4d0392..7eb3792ed8c5 100644 --- a/include/system/igvm-internal.h +++ b/include/system/igvm-internal.h @@ -72,6 +72,7 @@ struct QIgvm { IgvmHandle qigvm_file_init(char *filename, Error **errp); =20 QIgvmParameterData* -qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index); +qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index, + Error **errp); =20 #endif diff --git a/backends/igvm.c b/backends/igvm.c index 3f4b97a5d417..a5a2a4eccc19 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -81,7 +81,8 @@ struct QEMU_PACKED sev_id_authentication { #define IGVM_SEV_ID_BLOCK_VERSION 1 =20 QIgvmParameterData* -qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index) +qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index, + Error **errp) { QIgvmParameterData *param_entry; QTAILQ_FOREACH(param_entry, &igvm->parameter_data, next) @@ -90,7 +91,8 @@ qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_ar= ea_index) return param_entry; } } - warn_report("IGVM: No parameter area for index %u", parameter_area_ind= ex); + error_setg(errp, "IGVM: parameter area index %u not found", + parameter_area_index); return NULL; } =20 @@ -528,9 +530,10 @@ static int qigvm_directive_parameter_insert(QIgvm *ctx, return 0; } =20 - param_entry =3D qigvm_find_param_entry(ctx, param->parameter_area_inde= x); + param_entry =3D qigvm_find_param_entry(ctx, + param->parameter_area_index, errp= ); if (param_entry =3D=3D NULL) { - return 0; + return -1; } =20 region =3D qigvm_prepare_memory(ctx, param->gpa, param_entry->size, @@ -601,9 +604,10 @@ static int qigvm_directive_memory_map(QIgvm *ctx, cons= t uint8_t *header_data, } =20 /* Find the parameter area that should hold the memory map */ - param_entry =3D qigvm_find_param_entry(ctx, param->parameter_area_inde= x); + param_entry =3D qigvm_find_param_entry(ctx, + param->parameter_area_index, errp= ); if (param_entry =3D=3D NULL) { - return 0; + return -1; } =20 max_entry_count =3D param_entry->size / sizeof(IGVM_VHS_MEMORY_MAP_ENT= RY); @@ -660,9 +664,10 @@ static int qigvm_directive_vp_count(QIgvm *ctx, const = uint8_t *header_data, uint32_t *vp_count; CPUState *cpu; =20 - param_entry =3D qigvm_find_param_entry(ctx, param->parameter_area_inde= x); + param_entry =3D qigvm_find_param_entry(ctx, + param->parameter_area_index, errp= ); if (param_entry =3D=3D NULL) { - return 0; + return -1; } =20 vp_count =3D (uint32_t *)(param_entry->data + param->byte_offset); @@ -683,9 +688,10 @@ static int qigvm_directive_environment_info(QIgvm *ctx, QIgvmParameterData *param_entry; IgvmEnvironmentInfo *environmental_state; =20 - param_entry =3D qigvm_find_param_entry(ctx, param->parameter_area_inde= x); + param_entry =3D qigvm_find_param_entry(ctx, + param->parameter_area_index, errp= ); if (param_entry =3D=3D NULL) { - return 0; + return -1; } =20 environmental_state =3D diff --git a/target/i386/igvm.c b/target/i386/igvm.c index f41b498b8924..ad9bf87761fb 100644 --- a/target/i386/igvm.c +++ b/target/i386/igvm.c @@ -191,9 +191,10 @@ int qigvm_directive_madt(QIgvm *ctx, const uint8_t *he= ader_data, Error **errp) int result =3D 0; =20 /* Find the parameter area that should hold the MADT data */ - param_entry =3D qigvm_find_param_entry(ctx, param->parameter_area_inde= x); + param_entry =3D qigvm_find_param_entry(ctx, + param->parameter_area_index, errp= ); if (param_entry =3D=3D NULL) { - return 0; + return -1; } =20 GArray *madt =3D acpi_build_madt_standalone(ctx->machine_state); --=20 2.55.0 From nobody Sun Jul 26 11:01:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1783140859; cv=none; d=zohomail.com; s=zohoarc; b=bnzBpclnDFZvErT3fHeJaZlvy0PViikPAUF10C/jQiTmvCVvlux094S26CQybGjcKNpEgeeXU5TSfqrKcZQFpfuetvwcAwOkOp7ZQUdIWtycyxQXs6XOu/MZoZOF49/C0jPzleOaZd4ypAnZb2BY50+3L0MFV9OR/d9Cvnd2exg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783140859; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=soRNAsriCkVHiMFoIKu9q9CuGHltyAS3PhevvB/IpO8=; b=GwBumatCgBP3MWjC1t1Bd56qxrkWiY+PpfJOp7lN2um0rXX4kp04zzP6v8KpjOjfSs0f9AOaD1pbcAPYeqtWOzSIfNygq0XxYyaUclxIID60NJeOV9zH4qmz0u/9F7YIOTVWSpa4u4bSFUhpIz5sDpnHE5hTWnv716qdJc2QH08= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1783140858893208.02181274596649; Fri, 3 Jul 2026 21:54:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wfsNf-00033d-5d; Sat, 04 Jul 2026 00:53:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wfsNc-00032W-Cr for qemu-devel@nongnu.org; Sat, 04 Jul 2026 00:53:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wfsNa-0007i0-Ge for qemu-devel@nongnu.org; Sat, 04 Jul 2026 00:53:28 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-GFzRDM2TOjOAxErZr5q_Ew-1; Sat, 04 Jul 2026 00:53:22 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 309001863B11; Sat, 4 Jul 2026 04:53:21 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.48.8]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1062A180061D; Sat, 4 Jul 2026 04:53:19 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 7D4E5180084D; Sat, 04 Jul 2026 06:53:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783140805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=soRNAsriCkVHiMFoIKu9q9CuGHltyAS3PhevvB/IpO8=; b=L6iXpjSmiHpfcotqBADwqZ5eBpwKsTD3SwsA6X78Ei2x50E047ltVYqRKDZv9/ac3/9xh5 6VVTrTQl1EgZ8B+ZDmJXsu/qjmbqdqSg8CdYTmtwX+lBz0cAINB9GXbG6EmUX42ByufAor T+Whho8ayAvhlLVwbitMnnO+GWmjEbk= X-MC-Unique: GFzRDM2TOjOAxErZr5q_Ew-1 X-Mimecast-MFC-AGG-ID: GFzRDM2TOjOAxErZr5q_Ew_1783140801 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Ani Sinha , Stefano Garzarella , Zhao Liu , Gerd Hoffmann , Luigi Leonardi Subject: [PULL 2/3] igvm: use idiomatic meson conditional for IGVM build files Date: Sat, 4 Jul 2026 06:53:15 +0200 Message-ID: <20260704045316.1624628-3-kraxel@redhat.com> In-Reply-To: <20260704045316.1624628-1-kraxel@redhat.com> References: <20260704045316.1624628-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1783140859988158500 Content-Type: text/plain; charset="utf-8" From: Luigi Leonardi Replace the explicit igvm.found() check with system_ss.add(when:, if_true:), matching the pattern used by all other optional backends. Suggested-by: Paolo Bonzini Signed-off-by: Luigi Leonardi Reviewed-by: Stefano Garzarella Message-ID: <20260626-microvm_device_tree-v6-2-9cd13cf057e2@redhat.com> Signed-off-by: Gerd Hoffmann --- backends/meson.build | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/backends/meson.build b/backends/meson.build index 60021f45d124..aabfaea5fd8d 100644 --- a/backends/meson.build +++ b/backends/meson.build @@ -34,11 +34,8 @@ if have_vhost_user_crypto endif system_ss.add(when: gio, if_true: files('dbus-vmstate.c')) system_ss.add(when: 'CONFIG_SGX', if_true: files('hostmem-epc.c')) -if igvm.found() - system_ss.add(igvm) - system_ss.add(files('igvm-cfg.c'), igvm) - system_ss.add(files('igvm.c'), igvm) -endif + +system_ss.add(when: igvm, if_true: [files('igvm-cfg.c', 'igvm.c')]) =20 system_ss.add(when: 'CONFIG_SPDM_SOCKET', if_true: files('spdm-socket.c')) =20 --=20 2.55.0 From nobody Sun Jul 26 11:01:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1783140865; cv=none; d=zohomail.com; s=zohoarc; b=frlU4l75Ee0bYd3vXxyW0u4lSPZYN7prJ5kUx+4BOupZ204cGwFfeQH7x1DB81UaA2+9GRVI5XdsCNkoPFmdPM5fIeBBulDcu8EitorCdZbItY8pjcIa77ZYc/Zsf8vqJ3/Fom4PlgUOy8xJUPne+x6ZYGfjD5vobzf9ZnKTCCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783140865; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zk3TZcngtC3GBV5X5R9Qkzk3YE0MN12ilj829zBD1wM=; b=ZnRJgG0OXPPHXqmjG8Dd9fEy2JMdPRne248yN/JG99/MQAF0xGm8Po+wbVgoL/r23WXJDbx9zaMKFDldfbWvT5HktorbsX82F3t+kw1lBsOGH3Sm0SUDuQc2Hpmbk44YlDwTlTC289wLoEPrP3hfwlr8gTwyU9drBZEUEHi+krk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1783140865807650.2808214861062; Fri, 3 Jul 2026 21:54:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wfsNf-00033U-1M; Sat, 04 Jul 2026 00:53:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wfsNb-00032F-6U for qemu-devel@nongnu.org; Sat, 04 Jul 2026 00:53:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wfsNZ-0007hY-DZ for qemu-devel@nongnu.org; Sat, 04 Jul 2026 00:53:26 -0400 Received: from mx-prod-mc-01.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-130-cPd42J_WMFCYtYkrLZX1Tg-1; Sat, 04 Jul 2026 00:53:21 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 73C7F19560BF; Sat, 4 Jul 2026 04:53:20 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.48.8]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1528A30030DF; Sat, 4 Jul 2026 04:53:19 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 8F73A1800DFC; Sat, 04 Jul 2026 06:53:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783140803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zk3TZcngtC3GBV5X5R9Qkzk3YE0MN12ilj829zBD1wM=; b=L3qnDgnAignUpj+bKJm0ISBwy/a8VzGiTRDUAHY/Aqk3pa94Q+N6xrW4Puq5Oqh4WuLxpC DhGMv40W+AdUWe3tiG2nD/YzrIO0n7DTgX84DLVLXgF+569vXfN/8duXhVW0F/T+uuLg9m i/vUlHtSsMuc5Ltz2fraymjDM9ICZTc= X-MC-Unique: cPd42J_WMFCYtYkrLZX1Tg-1 X-Mimecast-MFC-AGG-ID: cPd42J_WMFCYtYkrLZX1Tg_1783140800 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Ani Sinha , Stefano Garzarella , Zhao Liu , Gerd Hoffmann , Luigi Leonardi Subject: [PULL 3/3] igvm: add device tree parameter support Date: Sat, 4 Jul 2026 06:53:16 +0200 Message-ID: <20260704045316.1624628-4-kraxel@redhat.com> In-Reply-To: <20260704045316.1624628-1-kraxel@redhat.com> References: <20260704045316.1624628-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1783140867787158500 Content-Type: text/plain; charset="utf-8" From: Luigi Leonardi Coconut SVSM, with the upcoming device tree support [1], will use the IGVM device tree parameter to discover virtio-mmio and ISA serial devices instead of relying on the fw_cfg interface, which is QEMU-specific. The device tree is packed before copying into the IGVM parameter area to reduce its size, since IGVM files can define tighter memory constraints for parameter areas. Packing is done in the generic IGVM backend rather than in per-architecture device tree setup code, so that each architecture does not need to handle it individually. [1] https://github.com/coconut-svsm/svsm/pull/1006 Signed-off-by: Luigi Leonardi Reviewed-by: Stefano Garzarella Message-ID: <20260626-microvm_device_tree-v6-3-9cd13cf057e2@redhat.com> Signed-off-by: Gerd Hoffmann --- backends/igvm.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ backends/meson.build | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/backends/igvm.c b/backends/igvm.c index a5a2a4eccc19..80e87fe6029a 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -26,6 +26,10 @@ #include #include =20 +#ifdef CONFIG_FDT +#include +#endif + #ifndef IGVM_VHT_OPTIONAL_BIT #define IGVM_VHT_OPTIONAL_BIT (1U << 31) #endif @@ -121,6 +125,10 @@ static int qigvm_directive_snp_id_block(QIgvm *ctx, co= nst uint8_t *header_data, static int qigvm_initialization_guest_policy(QIgvm *ctx, const uint8_t *header_data, Error **errp); +#ifdef CONFIG_FDT +static int qigvm_directive_device_tree(QIgvm *ctx, const uint8_t *header_d= ata, + Error **errp); +#endif =20 struct QIGVMHandler { IgvmVariableHeaderType type; @@ -151,6 +159,10 @@ static struct QIGVMHandler handlers[] =3D { qigvm_initialization_guest_policy }, { IGVM_VHT_MADT, IGVM_HEADER_SECTION_DIRECTIVE, qigvm_directive_madt }, +#ifdef CONFIG_FDT + { IGVM_VHT_DEVICE_TREE, IGVM_HEADER_SECTION_DIRECTIVE, + qigvm_directive_device_tree }, +#endif }; =20 static int qigvm_handler(QIgvm *ctx, IgvmVariableHeaderType raw_type, @@ -786,6 +798,48 @@ static int qigvm_directive_snp_id_block(QIgvm *ctx, co= nst uint8_t *header_data, return 0; } =20 +#ifdef CONFIG_FDT +static int qigvm_directive_device_tree(QIgvm *ctx, const uint8_t *header_d= ata, + Error **errp) +{ + const IGVM_VHS_PARAMETER *param =3D (const IGVM_VHS_PARAMETER *)header= _data; + g_autofree void *fdt_packed =3D NULL; + QIgvmParameterData *param_entry; + uint32_t fdt_size; + + param_entry =3D qigvm_find_param_entry(ctx, + param->parameter_area_index, errp= ); + if (param_entry =3D=3D NULL) { + return -1; + } + + if (ctx->machine_state->fdt =3D=3D NULL) { + error_setg(errp, "IGVM: device tree not available"); + return -1; + } + + fdt_size =3D fdt_totalsize(ctx->machine_state->fdt); + fdt_packed =3D g_memdup2(ctx->machine_state->fdt, fdt_size); + + if (fdt_pack(fdt_packed)) { + error_setg(errp, "IGVM: failed to pack device tree"); + return -1; + } + + fdt_size =3D fdt_totalsize(fdt_packed); + if (fdt_size > param_entry->size) { + error_setg(errp, + "IGVM: device tree size exceeds parameter area" + " defined in IGVM file"); + return -1; + } + + memcpy(param_entry->data, fdt_packed, fdt_size); + + return 0; +} +#endif + static int qigvm_initialization_guest_policy(QIgvm *ctx, const uint8_t *header_data, Error *= *errp) { diff --git a/backends/meson.build b/backends/meson.build index aabfaea5fd8d..8792c58c361f 100644 --- a/backends/meson.build +++ b/backends/meson.build @@ -35,7 +35,7 @@ endif system_ss.add(when: gio, if_true: files('dbus-vmstate.c')) system_ss.add(when: 'CONFIG_SGX', if_true: files('hostmem-epc.c')) =20 -system_ss.add(when: igvm, if_true: [files('igvm-cfg.c', 'igvm.c')]) +system_ss.add(when: igvm, if_true: [files('igvm-cfg.c', 'igvm.c'), fdt]) =20 system_ss.add(when: 'CONFIG_SPDM_SOCKET', if_true: files('spdm-socket.c')) =20 --=20 2.55.0