From patchwork Sun Aug 5 11:28:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 953518 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ilande.co.uk Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41jz8c4BVrz9s5c for ; Sun, 5 Aug 2018 21:29:51 +1000 (AEST) Received: from localhost ([::1]:58173 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmHEI-00069C-Kr for incoming@patchwork.ozlabs.org; Sun, 05 Aug 2018 07:29:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmHDk-00067T-46 for qemu-devel@nongnu.org; Sun, 05 Aug 2018 07:29:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmHDh-00054T-Gg for qemu-devel@nongnu.org; Sun, 05 Aug 2018 07:29:12 -0400 Received: from chuckie.co.uk ([82.165.15.123]:60359 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fmHDh-0004pa-9L for qemu-devel@nongnu.org; Sun, 05 Aug 2018 07:29:09 -0400 Received: from host86-164-28-221.range86-164.btcentralplus.com ([86.164.28.221] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fmHDm-0007Z3-Mh; Sun, 05 Aug 2018 12:29:15 +0100 From: Mark Cave-Ayland To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, lersek@redhat.com, qemu-devel@nongnu.org Date: Sun, 5 Aug 2018 12:28:49 +0100 Message-Id: <20180805112850.26063-2-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180805112850.26063-1-mark.cave-ayland@ilande.co.uk> References: <20180805112850.26063-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 86.164.28.221 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 1/2] sysbus: always allow explicit_ofw_unit_address() to override address generation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Some SysBusDevices either use sysbus_init_mmio() without sysbus_mmio_map() or the first MMIO memory region doesn't represent the bus address, causing a firmware device path with an invalid address to be generated. SysBusDeviceClass does provide a virtual explicit_ofw_unit_address() method that can be used to override this process, but it was originally intended only as as a fallback option meaning that any existing MMIO memory regions still take priority whilst determining the firmware device address. There is currently only one user of explicit_ofw_unit_address() and that is the PCI expander bridge (PXB) device which has no MMIO/PIO resources defined. This enables us to allow explicit_ofw_unit_address() to take priority without affecting backwards compatibility, allowing the address to be customised as required. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laszlo Ersek Reviewed-by: Thomas Huth Reviewed-by: Eduardo Habkost --- hw/core/sysbus.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 3c8e53b188..7ac36ad3e7 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -293,16 +293,8 @@ static char *sysbus_get_fw_dev_path(DeviceState *dev) { SysBusDevice *s = SYS_BUS_DEVICE(dev); SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(s); - /* for the explicit unit address fallback case: */ char *addr, *fw_dev_path; - if (s->num_mmio) { - return g_strdup_printf("%s@" TARGET_FMT_plx, qdev_fw_name(dev), - s->mmio[0].addr); - } - if (s->num_pio) { - return g_strdup_printf("%s@i%04x", qdev_fw_name(dev), s->pio[0]); - } if (sbc->explicit_ofw_unit_address) { addr = sbc->explicit_ofw_unit_address(s); if (addr) { @@ -311,6 +303,13 @@ static char *sysbus_get_fw_dev_path(DeviceState *dev) return fw_dev_path; } } + if (s->num_mmio) { + return g_strdup_printf("%s@" TARGET_FMT_plx, qdev_fw_name(dev), + s->mmio[0].addr); + } + if (s->num_pio) { + return g_strdup_printf("%s@i%04x", qdev_fw_name(dev), s->pio[0]); + } return g_strdup(qdev_fw_name(dev)); } From patchwork Sun Aug 5 11:28:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 953520 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ilande.co.uk Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41jzBw4DGqz9s0R for ; Sun, 5 Aug 2018 21:31:52 +1000 (AEST) Received: from localhost ([::1]:58182 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmHGI-000807-AZ for incoming@patchwork.ozlabs.org; Sun, 05 Aug 2018 07:31:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmHDk-00067S-3y for qemu-devel@nongnu.org; Sun, 05 Aug 2018 07:29:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmHDi-00057A-Et for qemu-devel@nongnu.org; Sun, 05 Aug 2018 07:29:12 -0400 Received: from chuckie.co.uk ([82.165.15.123]:60362 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fmHDi-0004rc-7x for qemu-devel@nongnu.org; Sun, 05 Aug 2018 07:29:10 -0400 Received: from host86-164-28-221.range86-164.btcentralplus.com ([86.164.28.221] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fmHDo-0007Z3-4k; Sun, 05 Aug 2018 12:29:17 +0100 From: Mark Cave-Ayland To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, lersek@redhat.com, qemu-devel@nongnu.org Date: Sun, 5 Aug 2018 12:28:50 +0100 Message-Id: <20180805112850.26063-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180805112850.26063-1-mark.cave-ayland@ilande.co.uk> References: <20180805112850.26063-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 86.164.28.221 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 2/2] fw_cfg: set the get_boot_devices_list() ignore_suffixes parameter from machine property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" For the older machines (such as Mac and SPARC) the DT nodes representing bootdevices for disk nodes are irregular for mainly historical reasons, and should be handled on an individual basis via a custom FWPathProvider. Since the majority of bootdevice nodes for these machines either do not have a separate disk node or require different (custom) names then it is much easier to allow the ignore_suffixes parameter to be set on a per-machine basis via a machine property. The default value for this new fwcfg_bootdevice_ignore_suffixes machine property is false to preserve compatibility for existing machines. Signed-off-by: Mark Cave-Ayland Reviewed-by: Thomas Huth --- hw/core/machine.c | 3 +++ hw/nvram/fw_cfg.c | 5 ++++- include/hw/boards.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index a9aeb22f03..fbadb35865 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -525,6 +525,9 @@ static void machine_class_init(ObjectClass *oc, void *data) mc->default_ram_size = 128 * MiB; mc->rom_file_has_mr = true; + /* Default to using fwcfg bootdevice suffixes */ + mc->fwcfg_bootdevice_ignore_suffixes = false; + /* numa node memory size aligned on 8MB by default. * On Linux, each node's border has to be 8MB aligned */ diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index b23e7f64a8..ec6b8113ab 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -861,7 +861,10 @@ static void fw_cfg_machine_reset(void *opaque) void *ptr; size_t len; FWCfgState *s = opaque; - char *bootindex = get_boot_devices_list(&len, false); + MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); + + char *bootindex = get_boot_devices_list(&len, + mc->fwcfg_bootdevice_ignore_suffixes); ptr = fw_cfg_modify_file(s, "bootorder", (uint8_t *)bootindex, len); g_free(ptr); diff --git a/include/hw/boards.h b/include/hw/boards.h index d139a431a6..2cf76d82a6 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -204,6 +204,7 @@ struct MachineClass { const char **valid_cpu_types; strList *allowed_dynamic_sysbus_devices; bool auto_enable_numa_with_memhp; + bool fwcfg_bootdevice_ignore_suffixes; void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes, int nb_nodes, ram_addr_t size);