From patchwork Fri Dec 6 18:13:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13897546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 110E8E77179 for ; Fri, 6 Dec 2024 18:14:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJcqD-0001Ix-Fr; Fri, 06 Dec 2024 13:14:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tJcqB-0001Im-71 for qemu-devel@nongnu.org; Fri, 06 Dec 2024 13:14:11 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJcq9-0005OR-EI for qemu-devel@nongnu.org; Fri, 06 Dec 2024 13:14:10 -0500 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-385dece873cso1186818f8f.0 for ; Fri, 06 Dec 2024 10:14:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733508847; x=1734113647; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A0PBZR23Po9ToAnafigq0MA6TfCR66KP6lO73kHOKBI=; b=DMRIwzRNuVIo5SvL5RXpIVbv/ebsur9xmeVa+bKXdZ5li8hks2yOISX/8eTqD1nlWn yTvEUIfcqUOS9FriMltWGSMuDWy+EfR3DuybGxCSm16EfClObJwN/YlzcVB8s6qJcr3O c+CBhTO1B7y4w7dzyiXZXVej8ilAFNNW4SKuBaVo6sJNRknomXvV7Rm4x0jLW6snXI2B VXiuB0xn16SJz8Adt5UKM7cuHPtN6Z/+zt/h8j5FPJi32wo/ytvtqtfhOrnJXWM2TVyZ woroCq2w+ZMedtA5WAYoXxNo+78PuDrKgZa/ncHEzCoHzi582hTYNXEPM5/wWmsxme6h Hc/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733508847; x=1734113647; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A0PBZR23Po9ToAnafigq0MA6TfCR66KP6lO73kHOKBI=; b=Lj/KBxA2LowIBfV4ax2L5bSikqmp0o5/wgu5EdlZpS0YfuatJ6r8etywbYbtqdfJNP /d3QAUlxJKZBXhJj1Uvnc2dPseqTIf3A/qRQYc85PjFwG/KEOR1dQf1SzLz8umcyoMOX w74qZ4TswHn2v1IllX+JpadQ/NOy2xJLn8n8J0IZdQKJXI+RqZh65DD0iXqehgIwV+LI iKGO+x5p7MeZEFTSUKJWNS12ii8+NFevfKKamy4rn4aVX4Zp5+Nu76Ar24gFBCAe4/Ok EV4dMttz2+ltjvQWgiPpNFTkHw6cfkR0R5h4MJ+buUIyM9PwmddwzCkh31MJ+FLk9Xnl TJ7w== X-Forwarded-Encrypted: i=1; AJvYcCWUcsEuPpzksODw/fDntdZsQpBh24F92qh66nkelFv7bFV/OHNNz3dGGF1oxnheJAz8kMu24ncSu7oA@nongnu.org X-Gm-Message-State: AOJu0YxVbjvtQUD8sIrge6bHFisaPEwFy9ICqoss5NVJCDPBp5Fs4+OQ M0SRGQB3Tj6CwwPqi7Gd0JqnylqBAd1V/XhVN0ePK/gUMutfPOEIhpKhnQ2e6xM= X-Gm-Gg: ASbGncsjT5fSYeIrKpoVrm7wgwTSNsTUEdV58ZmplixRdayQVZNC4pbokGuc6OMFu6p 5UKsLabYRkJ1CWeVkk97b75RP/+AwqKLetvhtPFq3L1Oo+Ywrg+084QQewZ9Ad6pVZ8w3q1ZAKY 3uA3i+Z6nHH+l8JRwwSnLim8JKJO/IaXH5gROO5bdFWSGQtKsqQzUXVLcoI16hs8GmnsP0CKFkQ GmonHRhBM1Vg3fLQ2ESwnHDJi1nTr1WSiuiQGjfFROxDI8yXGnsT2w82YJ022+WSao= X-Google-Smtp-Source: AGHT+IGSywxEn3NkVJzw7GgsndWeufu5axp6NpAzKXr1O4Tw0ePmeockps3DpUR2efWMOuNPLCGQ5w== X-Received: by 2002:a05:6000:1846:b0:382:31a1:8dc3 with SMTP id ffacd0b85a97d-3862b39759fmr3099375f8f.35.1733508847568; Fri, 06 Dec 2024 10:14:07 -0800 (PST) Received: from localhost.localdomain ([95.127.41.180]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3862d05d82esm2147630f8f.40.2024.12.06.10.14.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Dec 2024 10:14:06 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Jiahui Cen , qemu-devel@nongnu.org Cc: Gerd Hoffmann , Eduardo Habkost , Gustavo Romero , Paolo Bonzini , Marcel Apfelbaum , "Michael S. Tsirkin" , Richard Henderson , Zhao Liu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bernhard Beschow Subject: [PATCH 1/6] hw/nvram/fw_cfg: Rename fw_cfg_add_[file]_from_generator() Date: Fri, 6 Dec 2024 19:13:47 +0100 Message-ID: <20241206181352.6836-2-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206181352.6836-1-philmd@linaro.org> References: <20241206181352.6836-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org fw_cfg_add_from_generator() is adding a 'file' entry, so rename as fw_cfg_add_file_from_generator() for clarity. Besides, we might introduce generators for other entry types. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé --- include/hw/nvram/fw_cfg.h | 6 +++--- hw/nvram/fw_cfg.c | 4 ++-- system/vl.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index fa426776192..14e68966c59 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -291,7 +291,7 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data, size_t len); /** - * fw_cfg_add_from_generator: + * fw_cfg_add_file_from_generator: * @s: fw_cfg device being modified * @filename: name of new fw_cfg file item * @gen_id: name of object implementing FW_CFG_DATA_GENERATOR interface @@ -307,8 +307,8 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data, * * Returns: %true on success, %false on error. */ -bool fw_cfg_add_from_generator(FWCfgState *s, const char *filename, - const char *gen_id, Error **errp); +bool fw_cfg_add_file_from_generator(FWCfgState *s, const char *filename, + const char *gen_id, Error **errp); /** * fw_cfg_add_extra_pci_roots: diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index b644577734c..fe3b86135a7 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -1027,8 +1027,8 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename, return NULL; } -bool fw_cfg_add_from_generator(FWCfgState *s, const char *filename, - const char *gen_id, Error **errp) +bool fw_cfg_add_file_from_generator(FWCfgState *s, const char *filename, + const char *gen_id, Error **errp) { FWCfgDataGeneratorClass *klass; GByteArray *array; diff --git a/system/vl.c b/system/vl.c index 2f855d83fbb..f103532a9a1 100644 --- a/system/vl.c +++ b/system/vl.c @@ -1184,7 +1184,7 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp) size = strlen(str); /* NUL terminator NOT included in fw_cfg blob */ buf = g_memdup(str, size); } else if (nonempty_str(gen_id)) { - if (!fw_cfg_add_from_generator(fw_cfg, name, gen_id, errp)) { + if (!fw_cfg_add_file_from_generator(fw_cfg, name, gen_id, errp)) { return -1; } return 0; From patchwork Fri Dec 6 18:13:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13897548 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96717E77173 for ; Fri, 6 Dec 2024 18:14:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJcqN-0001Mm-QN; Fri, 06 Dec 2024 13:14:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tJcqM-0001ME-Ge for qemu-devel@nongnu.org; Fri, 06 Dec 2024 13:14:22 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJcqK-0005PW-Id for qemu-devel@nongnu.org; Fri, 06 Dec 2024 13:14:22 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-434a83c6b01so16139105e9.0 for ; Fri, 06 Dec 2024 10:14:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733508859; x=1734113659; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jcfKXIJuNiuvzm2ydvBx89mK8MIYUVOg22CEhEE1H9M=; b=zAuPiWqkUAnLyuapXuXWEa131/B1BmQA9ITE/9cAbPclCeqTdqLr0A3RLUpiWrgV6T Fb2sOzPZ2BXs19DyNah3CcpAdYKxWiKJ70QRvjM/9/Q5caiHaKDle1gGtk/IkSqMt0+S L0ZrUX83W5uQGa9Xet8s4/bW5/tnX72fOi8WaYSPj+SyzewVOQ4IvXzcGEMt2iEjxDM3 xSpRVL7e8nS51i4ZcZ7NxUC47FSpbbctEzHnfDBde+Acv8lNEethhBiOa4183a+4IXEA H36W5jZMain9Gumq2PzDOQgKbhsH6x1DOXnPzoyyW6ALd5AsIpiLrxyeVeRMKl9w/1qn 0J5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733508859; x=1734113659; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jcfKXIJuNiuvzm2ydvBx89mK8MIYUVOg22CEhEE1H9M=; b=hC4gZ9V7FD1HBRbpzQlfxHlZ8xXJ7rarkD1jnDEV/bLYU3xvRYifSIIjlptrGrK1TN 95DEIo+zCYuM8kX29Hs/DQJVEuazM3ooKOfsnVubwryuhdHggArP0b5jInDFF3tcanEk pP123dTviUqgf4Y+xWGmGEOlmjQ4MolNNflpdIAJeapFKhyqhwu4zRBI+E3Rti4K1IQG OwtPuhitA5tiTYBiPxWcwOCVjE1WznmK1Jry5Qrdc1eDdfjz6+2RTgd12vUIkgcp/J3o Ma1D5SBoAYvKhNWkMb92KOxtH9L/LED4bVYraS5QR/A67ArDjMYT2EE5nVro3vPVE9cM 8YxA== X-Forwarded-Encrypted: i=1; AJvYcCWtMEuNLIjteSB9ig8QHZWxURMBKwFRQsjXMVnkDgrvjQ2OggVdbld9wIlWqwU5Z3zahgvJcyQvuoo5@nongnu.org X-Gm-Message-State: AOJu0Yw+TYtw/agraK1qJYgcKDkuwzqsREZhlAj9uMOnLCcH15CTx3n2 q+HGeQ3SmmdJKoYGOyx992njIjDjdJHBI9GpTwQQE+OKmcwqCI81bvFOYpK+f5Q= X-Gm-Gg: ASbGncuTEfqkGwiZ1sCids8e2zp2IDyFysRyhg5nz/Lv/TYbA4g4zGHdEf0YNpU8AT/ +31g7wkfEACUu0lpvN0Be5IVglcderoN9Hz6HyOHoM2JqeXIBnUfT1FJ8HQvu2MlYxhllgxI4QA vNMLe4ivMfpiiHzEo9G291DOQxiRh+JqtUKmH2cLG0Ra5F+SUD/C2UAL87G1vDLHIjQdjt8ES8/ n1/DIJbsU1APsk/QQh5Z0aWyPv3ovaZL7xmizcd6qOVF6svEiamEP+avxbzk9JnyV4= X-Google-Smtp-Source: AGHT+IHlaOCooYSRu6bTIhC/PfPUY7NA9to/ybCea651MHJEUR1wEhCjBtPLkV0dGpLBkXDFnDmNMA== X-Received: by 2002:a05:600c:19c7:b0:434:a781:f5d2 with SMTP id 5b1f17b1804b1-434ddea7f36mr35413855e9.5.1733508857333; Fri, 06 Dec 2024 10:14:17 -0800 (PST) Received: from localhost.localdomain ([95.127.41.180]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434d5272f99sm98988715e9.11.2024.12.06.10.14.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Dec 2024 10:14:15 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Jiahui Cen , qemu-devel@nongnu.org Cc: Gerd Hoffmann , Eduardo Habkost , Gustavo Romero , Paolo Bonzini , Marcel Apfelbaum , "Michael S. Tsirkin" , Richard Henderson , Zhao Liu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bernhard Beschow Subject: [PATCH 2/6] hw/nvram/fw_cfg: Pass QOM parent to fw_cfg_add_file_from_generator() Date: Fri, 6 Dec 2024 19:13:48 +0100 Message-ID: <20241206181352.6836-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206181352.6836-1-philmd@linaro.org> References: <20241206181352.6836-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Currently fw_cfg_add_file_from_generator() is restricted to command line created objects which reside in the '/objects' QOM container. In order to extend to other types of containers, pass the QOM parent by argument. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé --- include/hw/nvram/fw_cfg.h | 10 ++++++---- hw/nvram/fw_cfg.c | 11 ++++++----- system/vl.c | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index 14e68966c59..fcb06f18cc3 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -294,11 +294,12 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data, * fw_cfg_add_file_from_generator: * @s: fw_cfg device being modified * @filename: name of new fw_cfg file item - * @gen_id: name of object implementing FW_CFG_DATA_GENERATOR interface + * @part: name of object implementing FW_CFG_DATA_GENERATOR interface + * @parent: the object in which to resolve the @part * @errp: pointer to a NULL initialized error object * * Add a new NAMED fw_cfg item with the content generated from the - * @gen_id object. The data generated by the @gen_id object is copied + * @part object. The data generated by the @part object is copied * into the data structure of the fw_cfg device. * The next available (unused) selector key starting at FW_CFG_FILE_FIRST * will be used; also, a new entry will be added to the file directory @@ -307,8 +308,9 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data, * * Returns: %true on success, %false on error. */ -bool fw_cfg_add_file_from_generator(FWCfgState *s, const char *filename, - const char *gen_id, Error **errp); +bool fw_cfg_add_file_from_generator(FWCfgState *s, + Object *parent, const char *part, + const char *filename, Error **errp); /** * fw_cfg_add_extra_pci_roots: diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index fe3b86135a7..b94cd27bd85 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -1027,22 +1027,23 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename, return NULL; } -bool fw_cfg_add_file_from_generator(FWCfgState *s, const char *filename, - const char *gen_id, Error **errp) +bool fw_cfg_add_file_from_generator(FWCfgState *s, + Object *parent, const char *part, + const char *filename, Error **errp) { FWCfgDataGeneratorClass *klass; GByteArray *array; Object *obj; gsize size; - obj = object_resolve_path_component(object_get_objects_root(), gen_id); + obj = object_resolve_path_component(parent, part); if (!obj) { - error_setg(errp, "Cannot find object ID '%s'", gen_id); + error_setg(errp, "Cannot find object ID '%s'", part); return false; } if (!object_dynamic_cast(obj, TYPE_FW_CFG_DATA_GENERATOR_INTERFACE)) { error_setg(errp, "Object ID '%s' is not a '%s' subclass", - gen_id, TYPE_FW_CFG_DATA_GENERATOR_INTERFACE); + part, TYPE_FW_CFG_DATA_GENERATOR_INTERFACE); return false; } klass = FW_CFG_DATA_GENERATOR_GET_CLASS(obj); diff --git a/system/vl.c b/system/vl.c index f103532a9a1..4a370da624a 100644 --- a/system/vl.c +++ b/system/vl.c @@ -1184,7 +1184,8 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp) size = strlen(str); /* NUL terminator NOT included in fw_cfg blob */ buf = g_memdup(str, size); } else if (nonempty_str(gen_id)) { - if (!fw_cfg_add_file_from_generator(fw_cfg, name, gen_id, errp)) { + if (!fw_cfg_add_file_from_generator(fw_cfg, object_get_objects_root(), + gen_id, name, errp)) { return -1; } return 0; From patchwork Fri Dec 6 18:13:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13897551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0EE78E77173 for ; Fri, 6 Dec 2024 18:16:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJcqV-0001QQ-Kq; Fri, 06 Dec 2024 13:14:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tJcqT-0001NL-2r for qemu-devel@nongnu.org; Fri, 06 Dec 2024 13:14:29 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJcqR-0005Q6-GN for qemu-devel@nongnu.org; Fri, 06 Dec 2024 13:14:28 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4349fd77b33so22351885e9.2 for ; Fri, 06 Dec 2024 10:14:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733508866; x=1734113666; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=owh50kXvsaInzhL7G0fsDGVpNu3LUuVKio+jRzd7Ga0=; b=jozGh2IoKPNWCTj3dbz5Qt0NhO2Cw5BkhKyo/tCuLk//+v6PLmtV9UO9xEfAOpBYvW ZQf0Hz3VKN4NprnOojf5Vux1OLRmDRhRztbi14NXtoYQoloeL/yNuDXDdzHwSYVcAKkV DtyYg1TpIhicrdnK7J58LXksZpVy5RoJf4VYjfyaBstGUNYZGAJQvQsdKEBK/VDjv2GP lFhe2djhBtbkn9bsFkoNeL+cyYYQ5sDCj6O92EuWIab1teGVFC+FRmccXZ/e3jhvADpZ MZw6ZB3PsmeOmTvO0iLU8BSxuVlcUIkYz/MRMJ2AZ+ZhsFrLAKAUj8drsuq+JgbtlaaV 0WGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733508866; x=1734113666; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=owh50kXvsaInzhL7G0fsDGVpNu3LUuVKio+jRzd7Ga0=; b=FpMWlwCVq5dBUP60zMhpGjreOK9VD+KSgbT7e4tNL/GwBhfQ4aPXnPcmIzVHPG6aK6 P0QEoiNsB/OuCnooTEjdy4CVgMfhWN0SzPuSP+IidFWzAxU/rnjQLcLyWP6B2D2TZdaF xDeOWfu8P9bhUo2Rx2ZRfccXG7M0qxa7DY+aFWRVL/nAkeIXrmgCCwUklvg7LPhlExEf 1HQndz6BvwKt1mvHE9XpJ56Bu2CmARLAUn7g8oyxqJACOXxbeV/ddmIRrV+AkF619ho6 uN/MvC+6Odcv2sUb+mep8yrkcD2Ow3FJ9HMarxcKxFBF6RYAm1TiNi0MJNFnMkRaJYlw T0Yg== X-Forwarded-Encrypted: i=1; AJvYcCWNGCRCECN/18fOKf9gm+HhBmxw6GzDhhEcJhFUoDEqQOEzwIvaIv7oZuRaLL3sta4gO+HPFCpA0Aoh@nongnu.org X-Gm-Message-State: AOJu0YygyscT0TdxZ6xLAvPT8p9q70QLdN1UDKGlKmvcvH787GhWzL+u 9yBbLUIcwFTPGLNAlAw1umBz5318L1FTOlDnVsb2NTR9JmEOQko5uKI0YPvChYM= X-Gm-Gg: ASbGncsQ/zpYW9FDVkbl5APjbdXQ7yfzuB3uW/fdh2ZYmzG1efJOiTGYBvTOSP+wwq2 g8UazikvnacdMQzqeVtHGFR5lGqPIR60throjsI6m03P817jG5/Yo5v87N5sw6OkxbBmZN1RRjw oQxhkj9/MTAcp8pzMwMeK/HoipptWhlH6EeaS2OLdgwubPJtLTYic0TyMxP22bHQjW04fpAcFsl tK3FF5974cf8LZPsVAWtlzOgnvGpBfi3cnvTbI3AoH7yt9QoZXhWdPUYzqXDWaYBlc= X-Google-Smtp-Source: AGHT+IGiQ4AU4yZBjbudxHMOaNRjcOuD4Np3qXJ4Ty1c5BjKPryT2dTklSgCy/x5MFwLTKF3LJP2Jw== X-Received: by 2002:a05:600c:1d0b:b0:431:5ab3:d28d with SMTP id 5b1f17b1804b1-434ddeb5518mr37823825e9.9.1733508865965; Fri, 06 Dec 2024 10:14:25 -0800 (PST) Received: from localhost.localdomain ([95.127.41.180]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434d52c0be4sm100555205e9.28.2024.12.06.10.14.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Dec 2024 10:14:25 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Jiahui Cen , qemu-devel@nongnu.org Cc: Gerd Hoffmann , Eduardo Habkost , Gustavo Romero , Paolo Bonzini , Marcel Apfelbaum , "Michael S. Tsirkin" , Richard Henderson , Zhao Liu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bernhard Beschow Subject: [PATCH 3/6] hw/pci: Have PCI_BUS implement TYPE_FW_CFG_DATA_GENERATOR_INTERFACE Date: Fri, 6 Dec 2024 19:13:49 +0100 Message-ID: <20241206181352.6836-4-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206181352.6836-1-philmd@linaro.org> References: <20241206181352.6836-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The FW_CFG_DATA_GENERATOR allows any object to produce blob of data consumable by the fw_cfg device. Implement that for PCI bus objects. Signed-off-by: Philippe Mathieu-Daudé --- hw/pci/pci.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 1416ae202c3..8844251eceb 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -46,6 +46,7 @@ #include "hw/pci/msix.h" #include "hw/hotplug.h" #include "hw/boards.h" +#include "hw/nvram/fw_cfg.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "pci-internal.h" @@ -216,11 +217,41 @@ static uint16_t pcibus_numa_node(PCIBus *bus) return NUMA_NODE_UNASSIGNED; } +static GByteArray *pci_bus_fw_cfg_gen_data(Object *obj, Error **errp) +{ + PCIBus *bus = PCI_BUS(obj); + GByteArray *byte_array; + uint64_t extra_hosts = 0; + + if (!bus) { + return NULL; + } + + QLIST_FOREACH(bus, &bus->child, sibling) { + /* look for expander root buses */ + if (pci_bus_is_root(bus)) { + extra_hosts++; + } + } + + if (!extra_hosts) { + return NULL; + } + extra_hosts = cpu_to_le64(extra_hosts); + + byte_array = g_byte_array_new(); + g_byte_array_append(byte_array, + (const void *)&extra_hosts, sizeof(extra_hosts)); + + return byte_array; +} + static void pci_bus_class_init(ObjectClass *klass, void *data) { BusClass *k = BUS_CLASS(klass); PCIBusClass *pbc = PCI_BUS_CLASS(klass); ResettableClass *rc = RESETTABLE_CLASS(klass); + FWCfgDataGeneratorClass *fwgc = FW_CFG_DATA_GENERATOR_CLASS(klass); k->print_dev = pcibus_dev_print; k->get_dev_path = pcibus_get_dev_path; @@ -232,6 +263,8 @@ static void pci_bus_class_init(ObjectClass *klass, void *data) pbc->bus_num = pcibus_num; pbc->numa_node = pcibus_numa_node; + + fwgc->get_data = pci_bus_fw_cfg_gen_data; } static const TypeInfo pci_bus_info = { @@ -240,6 +273,10 @@ static const TypeInfo pci_bus_info = { .instance_size = sizeof(PCIBus), .class_size = sizeof(PCIBusClass), .class_init = pci_bus_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_FW_CFG_DATA_GENERATOR_INTERFACE }, + { } + } }; static const TypeInfo cxl_interface_info = { From patchwork Fri Dec 6 18:13:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13897550 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CE098E77179 for ; Fri, 6 Dec 2024 18:15:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJcqg-0001fn-Ag; Fri, 06 Dec 2024 13:14:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tJcqc-0001Z8-Ow for qemu-devel@nongnu.org; Fri, 06 Dec 2024 13:14:38 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJcqb-0005QW-7K for qemu-devel@nongnu.org; Fri, 06 Dec 2024 13:14:38 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-434a044dce2so27046765e9.2 for ; Fri, 06 Dec 2024 10:14:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733508876; x=1734113676; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C1k+dmjInIZ8nHyYwBxRGsxTlfJ8uy0DiQ6erMadlMM=; b=hty37EaH5Z4EVHdKe+a1bOodU/5O6eO3vDZzYEueYpWsOGZ3SCj+DllnIQPYOA6kLM 0HXTMFKN8C795JPYmLejYzDpywhRe9svpNBrCy0e+8V5ZqT18seyRelbi4VZL8czJiAI 8cAFr3s0ba3ApI32Cf4AVvg8ZfHP9TK8nDbX1/ozKQl1k7BblhV5o0qjFwNvNHINE8lt 1wBLBiPeoxJcGVEKha5Kzxz/vk4ONAloQPMRtuG/FesCXwILvM9F2PAaVvhThuDAwQn7 iGI1lQUlYrFUzphZMWZN17XWUvKUbD6sTzz42rjp4weIae4gKTcIXtP0l9xgN5XJ9ewG 2zfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733508876; x=1734113676; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C1k+dmjInIZ8nHyYwBxRGsxTlfJ8uy0DiQ6erMadlMM=; b=jyB+uv4OWTSlsOI5ky4AS7ZvLj4W0m35tbZXOGX6OPXGGb6tdXl9N8m8spHo4TUwEV 3gqXzqpgwmx69AI6Z20Zp027xT38KeS3qqbPljrMtu2hOE9pDFGDFY/6YA+IF4HjkHqH fTBzVl/vSMXEeSygMV5x3hkUPt5hxOu7aCK3dcwVptMQ2Ynm1IZS7GjxNHQF8lFt8H4L KFrZ/6VvILtK+OfxXPJnPCZcAaRNM6wKaoq1yGQyBigXMGcsW7Psvz5ilwE2WycTd7I9 BypCa4a/gvNDfev6J1PwGp4YmZaCeH6t0UNyoNyY3ONEjkpJU36cGe+meqPdK17NOFSH EEcA== X-Forwarded-Encrypted: i=1; AJvYcCWHmBMozId7z26JBDbD6UySzg2Nk1/NA1gixFdiA5iifQhCwVCQvXQvDvGiAl+y5rPFj9aMHTr2Amzv@nongnu.org X-Gm-Message-State: AOJu0YxdgKbmGqMyXBFO8MDCcdu0+8fms/wyP+ihWu+lxYF+VHYe4bmR r2/u2P+pZ5SCLAzaXGSwBf/syKyKNDB5QUjWJ2zymgGU0gLX4zdlklW8lJs/W88= X-Gm-Gg: ASbGncu1GsCKr/o2g+BNpgzRP+hPGtt+gw1IYBN2W5C7W8zzDuGMI0txoChdWbe1qXL dazHTaBP2+PlcLIKwWhcfOzKibOM9fmBVO/Yjs3DyIekFgixkrzbnD6Wh6AZRyUCBIYvJ6GGgVq Z79k+Sf9NA8YP51BHRjcVz2ezeklhxUBS7lAcOuSJBNsztRJnglKcq/2q/08lLmDfXLNQaxm+ow E8XyLS/GEssbH7NWXjYtrbVgeheDLxCy1d8Fw7aFkYh/zS0lXJTYfLW9ZJEkXKWdiU= X-Google-Smtp-Source: AGHT+IEjNW+Q39bvzV8SvBAEdzgVqcIk7gK2aOiSg+qS8DEC9sL7/5mLKpg6DJ9NKu+AXQtdXPDrVA== X-Received: by 2002:a05:600c:1d85:b0:434:a955:ede with SMTP id 5b1f17b1804b1-434ddeb8d9dmr43314725e9.14.1733508875758; Fri, 06 Dec 2024 10:14:35 -0800 (PST) Received: from localhost.localdomain ([95.127.41.180]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434e6af5819sm1660245e9.17.2024.12.06.10.14.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Dec 2024 10:14:34 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Jiahui Cen , qemu-devel@nongnu.org Cc: Gerd Hoffmann , Eduardo Habkost , Gustavo Romero , Paolo Bonzini , Marcel Apfelbaum , "Michael S. Tsirkin" , Richard Henderson , Zhao Liu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bernhard Beschow Subject: [PATCH 4/6] hw/pci: Add pci_bus_add_fw_cfg_extra_pci_roots() helper Date: Fri, 6 Dec 2024 19:13:50 +0100 Message-ID: <20241206181352.6836-5-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206181352.6836-1-philmd@linaro.org> References: <20241206181352.6836-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org pci_bus_add_fw_cfg_extra_pci_roots() calls the fw_cfg API with PCI bus specific arguments. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé --- include/hw/pci/pci.h | 3 +++ hw/pci/pci.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index c0717e31219..603c456c3a8 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -297,6 +297,9 @@ int pci_bus_get_irq_level(PCIBus *bus, int irq_num); uint32_t pci_bus_get_slot_reserved_mask(PCIBus *bus); void pci_bus_set_slot_reserved_mask(PCIBus *bus, uint32_t mask); void pci_bus_clear_slot_reserved_mask(PCIBus *bus, uint32_t mask); +bool pci_bus_add_fw_cfg_extra_pci_roots(FWCfgState *fw_cfg, + PCIBus *bus, + Error **errp); /* 0 <= pin <= 3 0 = INTA, 1 = INTB, 2 = INTC, 3 = INTD */ static inline int pci_swizzle(int slot, int pin) { diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 8844251eceb..bf0a1840dbe 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -217,6 +217,22 @@ static uint16_t pcibus_numa_node(PCIBus *bus) return NUMA_NODE_UNASSIGNED; } +bool pci_bus_add_fw_cfg_extra_pci_roots(FWCfgState *fw_cfg, + PCIBus *bus, + Error **errp) +{ + Object *obj; + + if (!bus) { + return true; + } + obj = OBJECT(bus); + + return fw_cfg_add_file_from_generator(fw_cfg, obj->parent, + object_get_canonical_path_component(obj), + "etc/extra-pci-roots", errp); +} + static GByteArray *pci_bus_fw_cfg_gen_data(Object *obj, Error **errp) { PCIBus *bus = PCI_BUS(obj); From patchwork Fri Dec 6 18:13:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13897549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E5F00E77173 for ; Fri, 6 Dec 2024 18:15:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJcqy-0001tU-3U; Fri, 06 Dec 2024 13:15:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tJcqn-0001p5-PL for qemu-devel@nongnu.org; Fri, 06 Dec 2024 13:14:51 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJcqm-0005R1-6A for qemu-devel@nongnu.org; Fri, 06 Dec 2024 13:14:49 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-37ed3bd6114so1046802f8f.2 for ; Fri, 06 Dec 2024 10:14:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733508886; x=1734113686; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SvVPy+gwf8NA8vrmhM2eQ3IGQk6ahNK7Fgaq5e8ko14=; b=PYc4rXasb3NI1BFNCi5nsKR4zPfNLk9ooRYSz4Mvbf2LGKwddbzZ//PfntnGC74Iwx bdYpn7AznzmK1Us7jzntkptkh8PvUrSE6PC/xJ6QhXgUNt2EJnrI2yCn0igOq+9y2SYm MzbrfpfUVNvO0EoSPn27u3L5n+8K/15gvMqzGtMXEagRA9lqoOyByZII8SRFhrN0bZu4 txDpHUAnqwkuxno7GPv6pk07qhMDT3s+Ttz+XKzzF9SO+4Sy89VSeBzaEunQPX4bxWKl 2i7CW33sLntD3OrlfW+wZ1fh8nQeBDdKGLkDge4H8hOExQ8nn45koNVbxpL2m+xpnmg0 hM0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733508886; x=1734113686; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SvVPy+gwf8NA8vrmhM2eQ3IGQk6ahNK7Fgaq5e8ko14=; b=MgG2xKnDM2bnAfdcSZh+L/QjpYjYwmVnev0OCoQNyhU6S8giksl4ABsoZzm6mUFitv v8VjUFl22Yjw0S9M0M+Cx5nHMkcNb/eRlri6MhYVH6ekeVoFrvXI+Q7iIz3LErTNRfir /GksZVe6W2ZO8tJnu00dNglfAdlvpg3KRwXzqzGxYYvpl2X6Q3r8y6+a2fuYYiF480AG /kA7FLEGGEXc+ZKqzSWWqy2dcYdhR8AJ92UaFCQQPh7/cEAsWEkJKWcOqzc7aYyuHGo+ T4tv+lsMepQJ6woUyttgoDKNwOnkYs7yh75nxzYTOFghp51vLdxIBO6jINzzrjn0HHnp Vi8A== X-Forwarded-Encrypted: i=1; AJvYcCVYTigZv1ctG+p11xknjTj6JBKznz0YOtfl43vwE5wue2JDqNlez+k0g4uZmmuW/TNCfk6MBHamKep5@nongnu.org X-Gm-Message-State: AOJu0Yy9KxdJ72a+t/LfGS/jKqAeknN/rcKGx9Cmw40j4XdrQd5U8ikU 3lL/AmQivXbxhlPznJSL/3f92DGP7gEhEFELk3Gh7rtH+wGUmV6r64qtj1tMAyY= X-Gm-Gg: ASbGnctr/HU+fMSqMX9Z0gVRGPt1X4ZX0Y2Ep5e97mv0rA4X8Q8jVC2tGnQv1ZJd6PK iAirpL0SHXXUxfaP1Do/JGhuDYDY2iRB7UXWOPbEQUdxtJXHkExhFLdnCGzt7YTnOzGpAo5DkBp g0X892uiC/BorzNzy0irE+3gFuupCqTHcQBPLKSIQAigbhTURx2FY9tlwJtUPKzaXK9YuWfdLH2 3kMJSD3tFPk2WtXr4cQTYr7OXAT0qYA8JDITBY3cfSZ2XVSCNEOsHZmzqazvOB+G+Y= X-Google-Smtp-Source: AGHT+IEmBrSnwEMO1xN+Ij87gZA/44nrHOI7vutX+9aTDBxlIheYbpedBUK3+qkTNdfHuU8vuMXzWg== X-Received: by 2002:a5d:59a6:0:b0:385:e013:73f6 with SMTP id ffacd0b85a97d-3862b3e8503mr3000827f8f.50.1733508886570; Fri, 06 Dec 2024 10:14:46 -0800 (PST) Received: from localhost.localdomain ([95.127.41.180]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3862e767db6sm1612934f8f.26.2024.12.06.10.14.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Dec 2024 10:14:43 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Jiahui Cen , qemu-devel@nongnu.org Cc: Gerd Hoffmann , Eduardo Habkost , Gustavo Romero , Paolo Bonzini , Marcel Apfelbaum , "Michael S. Tsirkin" , Richard Henderson , Zhao Liu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bernhard Beschow Subject: [PATCH 5/6] hw: Use pci_bus_add_fw_cfg_extra_pci_roots() Date: Fri, 6 Dec 2024 19:13:51 +0100 Message-ID: <20241206181352.6836-6-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206181352.6836-1-philmd@linaro.org> References: <20241206181352.6836-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org We want to remove fw_cfg_add_extra_pci_roots() which introduced PCI bus knowledge within the generic hw/nvram/fw_cfg.c file. Replace the calls by the pci_bus_add_fw_cfg_extra_pci_roots() which is a 1:1 equivalent, but using correct API. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé --- hw/arm/virt.c | 3 ++- hw/hppa/machine.c | 2 +- hw/i386/pc.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 1a381e9a2bd..191e1d65a8f 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1750,7 +1750,8 @@ void virt_machine_done(Notifier *notifier, void *data) exit(1); } - fw_cfg_add_extra_pci_roots(vms->bus, vms->fw_cfg); + pci_bus_add_fw_cfg_extra_pci_roots(vms->fw_cfg, vms->bus, + &error_abort); virt_acpi_setup(vms); virt_build_smbios(vms); diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index a31dc32a9f7..4e673353225 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -240,7 +240,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms, PCIBus *pci_bus, g_memdup2(qemu_version, sizeof(qemu_version)), sizeof(qemu_version)); - fw_cfg_add_extra_pci_roots(pci_bus, fw_cfg); + pci_bus_add_fw_cfg_extra_pci_roots(fw_cfg, pci_bus, &error_abort); return fw_cfg; } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 317aaca25a0..3a656f398fd 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -628,7 +628,8 @@ void pc_machine_done(Notifier *notifier, void *data) /* set the number of CPUs */ x86_rtc_set_cpus_count(x86ms->rtc, x86ms->boot_cpus); - fw_cfg_add_extra_pci_roots(pcms->pcibus, x86ms->fw_cfg); + pci_bus_add_fw_cfg_extra_pci_roots(x86ms->fw_cfg, pcms->pcibus, + &error_abort); acpi_setup(); if (x86ms->fw_cfg) { From patchwork Fri Dec 6 18:13:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13897552 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9AF68E77173 for ; Fri, 6 Dec 2024 18:16:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJcrv-0003Kq-Uj; Fri, 06 Dec 2024 13:16:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tJcrI-0002e0-1e for qemu-devel@nongnu.org; Fri, 06 Dec 2024 13:15:21 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJcrA-0005Sl-JL for qemu-devel@nongnu.org; Fri, 06 Dec 2024 13:15:14 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4349f160d62so16581035e9.2 for ; Fri, 06 Dec 2024 10:15:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733508911; x=1734113711; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=drnor6SocDhMk0Sf/VXY5/KGSh3UPEWhTs9UqjHuGlg=; b=BSDhbKH4cTIS9c9S3Rsrp4CKbevQE5m+sQYvxe9VEntFqFC1mbS4wwsYD8ArzZ3Hin tONTi/Z5KYVMtmUTXJIZq0RTdCxH26L3lV3uV1eodXpdviCYRIzQbt2aj+khT/ZIWfnN Mj9XGSztoUGv0RcM+wsJL2mFDsZEQRzOQOy6zgBJerAvxVpyN+kYOYTtVmvTzFahFQzA vzEHmtcVR1efdcEzHv1q5qAtrbLSBKwDGbL0u0JL4QFMF0gtHtMMZxD5xmtCZu1nsTLb jZbFj6fbpbWFL9Mqa2l4vAZ7fNSlCgDX4VF8knITirzkR4FWPReeNVXI6WlUnaWEq4xp Chmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733508911; x=1734113711; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=drnor6SocDhMk0Sf/VXY5/KGSh3UPEWhTs9UqjHuGlg=; b=t0Pnh4/0mU1BcJMHigZu3S8+BOslwWKWcKiWKDT+qNERYzgf+L9CEyRTXH4V3gguU/ Qwl1tQW/2uObwi1qp64/0ocoGq4V1z7QbJRtmfiCF+zlS6ohhE9jFnYB8AfSy0EOCUp9 OQYi07g118FFrGrT0kdEWr88I7S/ALH4bwpmrmmi0JbFkpsC154bicK5DPzr07N+d67U wj17L/tUjiLZlMvjiH4mJtGd1VE0LKHzKY3T14po1LTziFeSsGen1YTGBXH9vjNNBqL1 9RmksGbCUonug8EeS9N/TOa/0xLjU8vhanpbko+Ieu4f3hK+XYz9Ickx186lI3DwQjz7 vIWA== X-Forwarded-Encrypted: i=1; AJvYcCVN/jUQG37qXRQXXKtSe4B5fyf2EnvsFbxAstVy8RLyu8r27ImQHfeamHLRZuLbXTRBGnoAeupCNsCz@nongnu.org X-Gm-Message-State: AOJu0YzKoHVLMjptS7hnVfN7dkt4Jh+Wv+sw9I1AqbPfp6OLvppAjHi+ VOsvaqG73sd3GzBCdoT/ByhKAF8AqhCcUeLFT4pYZcFsMfYAGRQSytoG7jXKBrs= X-Gm-Gg: ASbGnctne1z0jRK54MjhKCbFMfPdSo3vyrlF269Caf4noLX1y8Ua9asZK6G3RylOdGs dRcB8xJPFRjjjWtninbtOl5+SSD0wF6GrDRko0eJ+G4zqoEHsTjOUctsxA3Axvz55fXdcjpU6lI RZnN/ECHe8d40WgB37AfEjreQtCfwCH12FfyOo9dzRPOcc7xJm2NrYC2dUdv9pLMO+JJDEyyVU0 MdnJXUrxndOSjbJ4wjZ17AtI+0zg6hfBDpd/Nlhs8JPUKsLoNJbHb4M06s6JAaZLGk= X-Google-Smtp-Source: AGHT+IGk6jyHWGkuEqUt2nikNgIYoWi02w1uOvaD7SfUIJVYOlUZ9MUpEoMHqHxXGJHFI6dagna2Qw== X-Received: by 2002:a05:600c:3aca:b0:431:5863:4240 with SMTP id 5b1f17b1804b1-434dded69bfmr34076075e9.24.1733508910870; Fri, 06 Dec 2024 10:15:10 -0800 (PST) Received: from localhost.localdomain ([95.127.41.180]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434da1133c3sm62876255e9.31.2024.12.06.10.14.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Dec 2024 10:14:54 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Jiahui Cen , qemu-devel@nongnu.org Cc: Gerd Hoffmann , Eduardo Habkost , Gustavo Romero , Paolo Bonzini , Marcel Apfelbaum , "Michael S. Tsirkin" , Richard Henderson , Zhao Liu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bernhard Beschow Subject: [PATCH 6/6] hw/nvram/fw_cfg: Remove fw_cfg_add_extra_pci_roots() Date: Fri, 6 Dec 2024 19:13:52 +0100 Message-ID: <20241206181352.6836-7-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206181352.6836-1-philmd@linaro.org> References: <20241206181352.6836-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Now that all uses of fw_cfg_add_extra_pci_roots() have been converted to the newer pci_bus_add_fw_cfg_extra_pci_roots(), we can remove that bogus method. hw/nvram/fw_cfg must stay generic. Device specific entries have to be implemented using TYPE_FW_CFG_DATA_GENERATOR_INTERFACE. This mostly reverts commit 0abd38885ac0fcdb08653922f339849cad387961 ("fw_cfg: Refactor extra pci roots addition"). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé --- include/hw/nvram/fw_cfg.h | 9 --------- hw/nvram/fw_cfg.c | 23 ----------------------- 2 files changed, 32 deletions(-) diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index fcb06f18cc3..80a1549ad05 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -312,15 +312,6 @@ bool fw_cfg_add_file_from_generator(FWCfgState *s, Object *parent, const char *part, const char *filename, Error **errp); -/** - * fw_cfg_add_extra_pci_roots: - * @bus: main pci root bus to be scanned from - * @s: fw_cfg device being modified - * - * Add a new fw_cfg item... - */ -void fw_cfg_add_extra_pci_roots(PCIBus *bus, FWCfgState *s); - FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase, AddressSpace *dma_as); FWCfgState *fw_cfg_init_mem(hwaddr ctl_addr, hwaddr data_addr); diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index b94cd27bd85..053db7e08cc 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -41,7 +41,6 @@ #include "qemu/cutils.h" #include "qapi/error.h" #include "hw/acpi/aml-build.h" -#include "hw/pci/pci_bus.h" #include "hw/loader.h" #define FW_CFG_FILE_SLOTS_DFLT 0x20 @@ -1057,28 +1056,6 @@ bool fw_cfg_add_file_from_generator(FWCfgState *s, return true; } -void fw_cfg_add_extra_pci_roots(PCIBus *bus, FWCfgState *s) -{ - int extra_hosts = 0; - - if (!bus) { - return; - } - - QLIST_FOREACH(bus, &bus->child, sibling) { - /* look for expander root buses */ - if (pci_bus_is_root(bus)) { - extra_hosts++; - } - } - - if (extra_hosts && s) { - uint64_t *val = g_malloc(sizeof(*val)); - *val = cpu_to_le64(extra_hosts); - fw_cfg_add_file(s, "etc/extra-pci-roots", val, sizeof(*val)); - } -} - static void fw_cfg_machine_reset(void *opaque) { MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());