From patchwork Tue Jun 10 12:56:13 2025 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: 895206 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:ecd:b0:3a4:ee3f:8f15 with SMTP id ea13csp2253765wrb; Tue, 10 Jun 2025 06:06:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVWVlmAPH2bairG4eSrTeIV68YqazIrK9iMDc/wkXnhctTXB6pwVfBRlGCgtjfXZhswrse63g==@linaro.org X-Google-Smtp-Source: AGHT+IH2wCZXLuetsc9G9tbTCYmBbVaPYGfXVj2M4y51HhuER6T0Rs8MDM2otZoMsLP3LQ+T1cX1 X-Received: by 2002:a05:600c:a08d:b0:43d:abd:ad1c with SMTP id 5b1f17b1804b1-45201373d52mr152341255e9.6.1749560815087; Tue, 10 Jun 2025 06:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1749560815; cv=none; d=google.com; s=arc-20240605; b=jX/8evkiaIVvb73ZiZlyezgeS0tT+tDNiwAB0vBPF41tAyByWP17h2CwpVWNd3kYVs H+gKowcrxyeCWSF7JalCZxi7p0c+iq3zdUjwayTrucLTNZtrRk972IJAJgWabeOVnAfl 5lkYMMCLrOcCCuCm2L6j5LVzyt6tPAKk0GqDtKTnAz8kzfFBNT3TzekAzQ+Cf7BV4DFC X9CGwAnLxCp5HNMofo9POXVwJt5Qcq3N6IWBciDzUpyeQoFT13q9Zr0wTcIkxJGGtlTd 2eGAcOc65QG6rg1dbEdCzC8PMHWZ6A/TSUt6xJBkIsAbMFXJ6Gt6hQYt4nMLcwa9/2b+ K3og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=c8bs9uu+7kLf40D2babTGQO+kwfnbkrmCW8mE247ZCQ=; fh=5KYNaH84KuhJkbNfHAKkJotxTHueTtQQGeWlMENxW3A=; b=b/EXoPPWymGGiF1SAxuFem1XV/bu8siq9C9hGIaXFPiBuZbLKXIfVH4t+UzBXbTq/q wY+1LVdGDEecuBeFJSTAN5bFRyJlaPtP3stggeeVq8+QcEOWp8ScvQxS9rf8qtz1Mn8v idWXGO4ZGaU0rKJnqUWQKtaJNc//6LbxBns14YbaKzxGssagnwOnsqvrL1Tcr5bk2P7V qodkB8pxkvUNOZr6kh2N0IXfeQCqVOFxkkMaasI4vVKjBrvM3dT7ALTnjhVH9NjbR1pC tnXMiOm+Zbp/21btJiLgLT2tQZZqk5B412X2T1YIyyAX5pthANteJ7vmnM82wbh7mliO Htow==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wcWvOv96; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ffacd0b85a97d-3a5324797a8si7377127f8f.580.2025.06.10.06.06.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Jun 2025 06:06:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wcWvOv96; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOyXH-0006as-9x; Tue, 10 Jun 2025 08:57:03 -0400 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 1uOyXC-0006Zd-9b for qemu-devel@nongnu.org; Tue, 10 Jun 2025 08:56:59 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uOyX9-0002Zs-MO for qemu-devel@nongnu.org; Tue, 10 Jun 2025 08:56:58 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-451ebd3d149so34147035e9.2 for ; Tue, 10 Jun 2025 05:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749560213; x=1750165013; 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=c8bs9uu+7kLf40D2babTGQO+kwfnbkrmCW8mE247ZCQ=; b=wcWvOv96w6eeSol8Z91fipI//S2r1YDZWGJ0ZPFSbkTZ2jNIoYG2SNCyLhd1klqp4t 9jQ0MA8g85A2TLbwM7JcWZf4PEJr3iyvxDtf+Zz+5uYJOx4ZH5DSVYNdo4jukrBh4D2R tn5IHVD0F4Xp9II4OWPs0oJ9kUtrdXrqEXeWrlx9ZRdvQLcgw22Z6lhN2QJRgleaoKLQ au7cAQaD2jK1NmIl6l17OM2rbWqjWZNye2TZ0SFTpBEdHs9JsYyizcsL/68aseO6AFlH pZ2Xmy0eABnBgpDbMrasbDf0wHdH3iIJmy6yxoIauCkJuoH81vv8fzVsbw+WdrH63pRb VLjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749560213; x=1750165013; 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=c8bs9uu+7kLf40D2babTGQO+kwfnbkrmCW8mE247ZCQ=; b=sxC+4IsPgZ1bJFIkdMnSxYtPU9lvkZb/mY1T4Av5Wd4fyqU1XJ/zhhO2gVi4S3aCN2 g1RkNa0hZOvXoYoxQo4Tump9IhiJnZua48olKg1J62ZjH17UnSt0+isHajX1TIyV04RN AcClAsqeRI+M8gDR2scE3ZSCgItIybsXbKzpSTnB/1/bchBcF7A+AOUYT7zsbs3/Wxky pXUMbA1Cr5Cyx9bstItEMCW/qZoDQRcI3ilJizXeZnPA6khKqdzZw/6rugOj5hhm/JDu fwYNiqEJxHBurJ60y/7IKIGRsY1OdMrA0E4DDTnX5HFZcLzaBiDY7Pir+cB3XqRe6zLZ axew== X-Gm-Message-State: AOJu0YxkVyYT68sOjODeZSmYooYluce5gY72zUcGdLvsVA74m4FII/8u cBEfj05A4h7NmQdoGmNAbnAN63oy5+zBREf/LKN2jeisFwIAp+YMhOrrGC+LGGSIhYpF+d+tq4f wu2IkjaE= X-Gm-Gg: ASbGncvdkVm8YHgmlxJkY3aZp4kXUyAyrnP+vUznDgFThRCvFpht8geNa2Vgl8FkRyz D0ZztPcu5dAFctRzXMLoyyjT6CFIVafUB7j0gMRN4czhJKcwMLn23clBwZhiqHRBahKLIpmm1kx NChF7NV/z97ZVfciCPQ6bjv5Fc+AIYklU9rEXNCBpBS1O0KjdwekygJe35c5iJp2EU6Mvc04OL0 5Qtp0gbzDVzPPp2iMSlMOuh6j5UIjOagS5qey9fAMPlDI6Ix67l+AxNqYSIxkjbqyFmRCLXhAWc GX6iOyfnugj1hVIMIfnSl5rt083oKSDXTlmGpo2CNoNXwcWpX4mSWOKr+NGdoMTO3Q5pWbfnFfF ZlJlDsWCnH4na/YvKEcahBIMXQyjQ3CyLVTVLUT7vpQ== X-Received: by 2002:a05:600c:58d8:b0:43d:17f1:2640 with SMTP id 5b1f17b1804b1-4520151f219mr101712615e9.26.1749560213375; Tue, 10 Jun 2025 05:56:53 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a532462d93sm12494764f8f.91.2025.06.10.05.56.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 10 Jun 2025 05:56:52 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: BALATON Zoltan , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 04/24] hw/pci-host/raven: Revert "raven: Move BIOS loading from board code to PCI host" Date: Tue, 10 Jun 2025 14:56:13 +0200 Message-ID: <20250610125633.24411-5-philmd@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250610125633.24411-1-philmd@linaro.org> References: <20250610125633.24411-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: BALATON Zoltan This reverts commit d0b25425749d5525b2ba6d9d966d8800a5643b35. Loading firmware from the PCI host is unusual and raven is only used by one board so this does not simplify anything but rather complicates it. Revert to loading firmware from board code as that is the usual way and also because raven has nothing to do with ROM so it is not a good place for this. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daudé Message-ID: <4ca4f71bf661923d9a91b7e6776a0e40726e2337.1746374076.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé --- hw/pci-host/raven.c | 55 --------------------------------------------- hw/ppc/prep.c | 27 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 57 deletions(-) diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c index b78a8f32d32..f8c0be5d21c 100644 --- a/hw/pci-host/raven.c +++ b/hw/pci-host/raven.c @@ -24,7 +24,6 @@ */ #include "qemu/osdep.h" -#include "qemu/datadir.h" #include "qemu/units.h" #include "qemu/log.h" #include "qapi/error.h" @@ -35,9 +34,7 @@ #include "migration/vmstate.h" #include "hw/intc/i8259.h" #include "hw/irq.h" -#include "hw/loader.h" #include "hw/or-irq.h" -#include "elf.h" #include "qom/object.h" #define TYPE_RAVEN_PCI_DEVICE "raven" @@ -47,10 +44,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(RavenPCIState, RAVEN_PCI_DEVICE) struct RavenPCIState { PCIDevice dev; - - uint32_t elf_machine; - char *bios_name; - MemoryRegion bios; }; typedef struct PRePPCIState PREPPCIState; @@ -77,8 +70,6 @@ struct PRePPCIState { int contiguous_map; }; -#define BIOS_SIZE (1 * MiB) - #define PCI_IO_BASE_ADDR 0x80000000 /* Physical address on main bus */ static inline uint32_t raven_pci_io_config(hwaddr addr) @@ -333,48 +324,9 @@ static void raven_pcihost_initfn(Object *obj) static void raven_realize(PCIDevice *d, Error **errp) { - RavenPCIState *s = RAVEN_PCI_DEVICE(d); - char *filename; - int bios_size = -1; - d->config[PCI_CACHE_LINE_SIZE] = 0x08; d->config[PCI_LATENCY_TIMER] = 0x10; d->config[PCI_CAPABILITY_LIST] = 0x00; - - if (!memory_region_init_rom_nomigrate(&s->bios, OBJECT(s), "bios", - BIOS_SIZE, errp)) { - return; - } - memory_region_add_subregion(get_system_memory(), (uint32_t)(-BIOS_SIZE), - &s->bios); - if (s->bios_name) { - filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, s->bios_name); - if (filename) { - if (s->elf_machine != EM_NONE) { - bios_size = load_elf(filename, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, - ELFDATA2MSB, s->elf_machine, 0, 0); - } - if (bios_size < 0) { - bios_size = get_image_size(filename); - if (bios_size > 0 && bios_size <= BIOS_SIZE) { - hwaddr bios_addr; - bios_size = (bios_size + 0xfff) & ~0xfff; - bios_addr = (uint32_t)(-BIOS_SIZE); - bios_size = load_image_targphys(filename, bios_addr, - bios_size); - } - } - } - g_free(filename); - if (bios_size < 0 || bios_size > BIOS_SIZE) { - memory_region_del_subregion(get_system_memory(), &s->bios); - error_setg(errp, "Could not load bios image '%s'", s->bios_name); - return; - } - } - - vmstate_register_ram_global(&s->bios); } static const VMStateDescription vmstate_raven = { @@ -417,19 +369,12 @@ static const TypeInfo raven_info = { }, }; -static const Property raven_pcihost_properties[] = { - DEFINE_PROP_UINT32("elf-machine", PREPPCIState, pci_dev.elf_machine, - EM_NONE), - DEFINE_PROP_STRING("bios-name", PREPPCIState, pci_dev.bios_name), -}; - static void raven_pcihost_class_init(ObjectClass *klass, const void *data) { DeviceClass *dc = DEVICE_CLASS(klass); set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); dc->realize = raven_pcihost_realizefn; - device_class_set_props(dc, raven_pcihost_properties); dc->fw_name = "pci"; } diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index 739526335ca..982e40e53e1 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -35,6 +35,7 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/log.h" +#include "qemu/datadir.h" #include "hw/loader.h" #include "hw/rtc/mc146818rtc.h" #include "hw/isa/pc87312.h" @@ -55,6 +56,8 @@ #define KERNEL_LOAD_ADDR 0x01000000 #define INITRD_LOAD_ADDR 0x01800000 +#define BIOS_ADDR 0xfff00000 +#define BIOS_SIZE (1 * MiB) #define NVRAM_SIZE 0x2000 static void fw_cfg_boot_set(void *opaque, const char *boot_device, @@ -241,6 +244,9 @@ static void ibm_40p_init(MachineState *machine) ISADevice *isa_dev; ISABus *isa_bus; void *fw_cfg; + MemoryRegion *bios = g_new(MemoryRegion, 1); + char *filename; + ssize_t bios_size = -1; uint32_t kernel_base = 0, initrd_base = 0; long kernel_size = 0, initrd_size = 0; char boot_device; @@ -263,10 +269,27 @@ static void ibm_40p_init(MachineState *machine) cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); qemu_register_reset(ppc_prep_reset, cpu); + /* allocate and load firmware */ + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (!filename) { + error_report("Could not find bios image '%s'", bios_name); + exit(1); + } + memory_region_init_rom(bios, NULL, "bios", BIOS_SIZE, &error_fatal); + memory_region_add_subregion(get_system_memory(), BIOS_ADDR, bios); + bios_size = load_elf(filename, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); + if (bios_size < 0) { + bios_size = load_image_targphys(filename, BIOS_ADDR, BIOS_SIZE); + } + if (bios_size < 0 || bios_size > BIOS_SIZE) { + error_report("Could not load bios image '%s'", filename); + return; + } + g_free(filename); + /* PCI host */ dev = qdev_new("raven-pcihost"); - qdev_prop_set_string(dev, "bios-name", bios_name); - qdev_prop_set_uint32(dev, "elf-machine", PPC_ELF_MACHINE); pcihost = SYS_BUS_DEVICE(dev); object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev)); sysbus_realize_and_unref(pcihost, &error_fatal);